@orangecharts/wrun-chart-host 0.8.0 → 0.9.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 (145) hide show
  1. package/README.md +2 -1
  2. package/dist/constants/feature-flags.constants.d.ts +4 -0
  3. package/dist/constants/feature-flags.constants.js +27 -0
  4. package/dist/constants/marketCapabilities.constants.d.ts +14 -9
  5. package/dist/constants/marketCapabilities.constants.js +36 -13
  6. package/dist/constants/opra-compliance.constants.d.ts +14 -0
  7. package/dist/constants/opra-compliance.constants.js +14 -0
  8. package/dist/constants/option-venues.constants.d.ts +11 -6
  9. package/dist/constants/option-venues.constants.js +5 -2
  10. package/dist/host-env.d.ts +10 -4
  11. package/dist/host-ports.types.d.ts +39 -3
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +1 -0
  14. package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
  15. package/dist/interfaces/opra-realtime.interface.js +10 -10
  16. package/dist/interfaces/wrun-runtime.interface.d.ts +34 -13
  17. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +53 -10
  18. package/dist/kscript-data/controls/live-trades-merge.util.js +81 -16
  19. package/dist/market-data/billing.interface.d.ts +138 -17
  20. package/dist/market-data/billing.interface.js +25 -8
  21. package/dist/market-data/venues/index.d.ts +3 -3
  22. package/dist/market-data/venues/opra.contract.copy.json +5 -3
  23. package/dist/market-data/venues/opra.d.ts +3 -3
  24. package/dist/market-data/venues/opra.js +5 -4
  25. package/dist/replay/replayLadder.js +3 -1
  26. package/dist/utility/chart/crypto-index.leaf.d.ts +2 -2
  27. package/dist/utility/chart/crypto-index.leaf.js +2 -2
  28. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  29. package/dist/utility/chart/index-mode.util.d.ts +5 -2
  30. package/dist/utility/chart/index-mode.util.js +23 -13
  31. package/dist/utility/chart/kscript-venue-policy.util.d.ts +28 -21
  32. package/dist/utility/chart/kscript-venue-policy.util.js +30 -24
  33. package/dist/utility/chart/marketKind.util.d.ts +12 -10
  34. package/dist/utility/chart/marketKind.util.js +17 -7
  35. package/dist/utility/chart/om-panel-push-style.util.d.ts +7 -7
  36. package/dist/utility/chart/om-panel-push-style.util.js +17 -15
  37. package/dist/utility/chart/om-panel.util.js +6 -6
  38. package/dist/utility/chart/profile-block-size.util.d.ts +16 -0
  39. package/dist/utility/chart/profile-block-size.util.js +7 -0
  40. package/dist/utility/chart/quote-perp.leaf.d.ts +17 -0
  41. package/dist/utility/chart/quote-perp.leaf.js +20 -0
  42. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -0
  43. package/dist/utility/chart/wrun-run-result.util.js +4 -1
  44. package/dist/utility/common/transformations.util.d.ts +7 -0
  45. package/dist/utility/common/transformations.util.js +11 -0
  46. package/dist/utility/options/option-venue.util.d.ts +3 -3
  47. package/dist/utility/options/option-venue.util.js +3 -3
  48. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +1 -1
  49. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +2 -2
  50. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +2 -2
  51. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +5 -1
  52. package/dist/utility/wrun/sources/row-lane-registry.js +3 -2
  53. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +9 -3
  54. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +13 -5
  55. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +11 -0
  56. package/dist/utility/wrun/sources/row-lanes/option_prints.js +63 -9
  57. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +8 -0
  58. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +12 -0
  59. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +5 -2
  60. package/dist/utility/wrun/sources/row-lanes/option_surface.js +5 -2
  61. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +11 -5
  62. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +31 -10
  63. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +33 -1
  64. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +95 -6
  65. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +25 -5
  66. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +55 -18
  67. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +146 -40
  68. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +16 -3
  69. package/dist/utility/wrun/wrun-batched-marks.util.js +30 -19
  70. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +37 -9
  71. package/dist/utility/wrun/wrun-batched-readout.util.js +61 -15
  72. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -0
  73. package/dist/utility/wrun/wrun-cell-capacity.leaf.d.ts +66 -0
  74. package/dist/utility/wrun/wrun-cell-capacity.leaf.js +86 -0
  75. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +147 -9
  76. package/dist/utility/wrun/wrun-chart-market-facts.util.js +345 -11
  77. package/dist/utility/wrun/wrun-color-facts.util.d.ts +19 -9
  78. package/dist/utility/wrun/wrun-color-facts.util.js +24 -14
  79. package/dist/utility/wrun/wrun-color-settings.util.d.ts +15 -4
  80. package/dist/utility/wrun/wrun-color-settings.util.js +31 -12
  81. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.d.ts +17 -0
  82. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.js +9 -0
  83. package/dist/utility/wrun/wrun-download-meter.util.d.ts +92 -0
  84. package/dist/utility/wrun/wrun-download-meter.util.js +122 -0
  85. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +6 -1
  86. package/dist/utility/wrun/wrun-draft-overlay.util.js +23 -3
  87. package/dist/utility/wrun/wrun-frames.js +5 -5
  88. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
  89. package/dist/utility/wrun/wrun-hosted-wire-caps.js +7 -0
  90. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +33 -17
  91. package/dist/utility/wrun/wrun-hud-looks.util.js +30 -16
  92. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +8 -6
  93. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +8 -6
  94. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -2
  95. package/dist/utility/wrun/wrun-live-intake.util.d.ts +6 -2
  96. package/dist/utility/wrun/wrun-live-intake.util.js +136 -21
  97. package/dist/utility/wrun/wrun-live-tick.util.js +91 -38
  98. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.d.ts +53 -0
  99. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.js +162 -0
  100. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +166 -48
  101. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +216 -33
  102. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +51 -7
  103. package/dist/utility/wrun/wrun-market-size-defaults.util.js +314 -56
  104. package/dist/utility/wrun/wrun-option-prints.util.d.ts +41 -2
  105. package/dist/utility/wrun/wrun-option-prints.util.js +80 -13
  106. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +3 -0
  107. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +3 -0
  108. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +23 -0
  109. package/dist/utility/wrun/wrun-option-strike-flow.util.js +55 -0
  110. package/dist/utility/wrun/wrun-option-views.util.d.ts +51 -7
  111. package/dist/utility/wrun/wrun-option-views.util.js +151 -28
  112. package/dist/utility/wrun/wrun-options-stop.util.d.ts +2 -1
  113. package/dist/utility/wrun/wrun-options-stop.util.js +3 -2
  114. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
  115. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +31 -14
  116. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +22 -0
  117. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +7 -0
  118. package/dist/utility/wrun/wrun-overlay-recovery.util.js +25 -1
  119. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +7 -1
  120. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  121. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +34 -6
  122. package/dist/utility/wrun/wrun-overlay-run.util.js +416 -171
  123. package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +4 -4
  124. package/dist/utility/wrun/wrun-pack-widths.leaf.js +4 -4
  125. package/dist/utility/wrun/wrun-pack.util.d.ts +7 -3
  126. package/dist/utility/wrun/wrun-pack.util.js +20 -9
  127. package/dist/utility/wrun/wrun-panel-style.util.d.ts +27 -15
  128. package/dist/utility/wrun/wrun-panel-style.util.js +42 -20
  129. package/dist/utility/wrun/wrun-param-map.util.d.ts +7 -6
  130. package/dist/utility/wrun/wrun-param-map.util.js +8 -5
  131. package/dist/utility/wrun/wrun-param-values.util.d.ts +10 -2
  132. package/dist/utility/wrun/wrun-param-values.util.js +2 -0
  133. package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
  134. package/dist/utility/wrun/wrun-refusal.util.js +10 -1
  135. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +7 -0
  136. package/dist/utility/wrun/wrun-source-rows.util.d.ts +4 -0
  137. package/dist/utility/wrun/wrun-source-rows.util.js +92 -40
  138. package/dist/utility/wrun/wrun-tape-source.util.d.ts +126 -50
  139. package/dist/utility/wrun/wrun-tape-source.util.js +193 -68
  140. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +7 -5
  141. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +8 -6
  142. package/dist/workers/utils/volume-profile.worker.util.d.ts +4 -1
  143. package/dist/workers/utils/volume-profile.worker.util.js +5 -2
  144. package/dist/workers/wrun/wrun-abi-host.js +3 -2
  145. package/package.json +11 -11
@@ -4,7 +4,9 @@
4
4
  * written once over the descriptor, so no consumer names a lane.
5
5
  *
6
6
  * - `planWrunRowLaneInputs`: the STATIC plan, from the sheet alone: each input of a row-lane class, which must be
7
- * celled with a `max_cells` (refused by name otherwise). The row builder runs it before any row.
7
+ * celled with a `max_cells` (refused by name otherwise), and the tuples its module holds a bar's block in (the
8
+ * sheet's `capacity ?? max_cells`, a capacity no build writes refused by name). The run pass runs it before any
9
+ * fetch and the row builder before any row.
8
10
  * - `planWrunRowLanes`: the run's plan against the chart, before any fetch, of every input the market demands (an
9
11
  * undemanded one is planned nowhere): the OPRA wall, the chart's admission, the lane's identity (once per lane) and
10
12
  * each input's facets, grouped into instances (equal facets share one fetch and one buffer; an
@@ -17,14 +19,17 @@
17
19
  * `missing: "empty"`).
18
20
  * - `fetchWrunRowLaneRows`: a lane's rows over a chart window: its asks under the tier rule, landed on the host
19
21
  * bars, the partial bars marked (a `latest` lane asked once, its rows as they come), a row-budget lane's newest bars
20
- * first (wrun-row-lane-first-paint.util), and so an instance's whose facets ask a per-bar word (OPTLOAD G5); every
22
+ * first, cut on a trade date's first bar where the chart reads one (wrun-row-lane-first-paint.util; a full run's
23
+ * first paint draws them before the older bars land, `onFirstSlice`), and so an instance's whose facets ask a
24
+ * per-bar word (OPTLOAD G5); every
21
25
  * packed block a worker transferred split into plain tuples of the instance's width as it lands
22
26
  * (`wrunRowLanePlainRow`).
23
27
  * - an option knob naming a setting read as its value before a lane's facets judge it (`resolveWrunOptionSettingKnobs`).
24
28
  * - `wrunRowLaneCellRows`: the row builder's read of one input: the lane's host-bar rows as cell blocks on the
25
29
  * chart's grid (exact width, finite values or NaN outside a lane's `finiteColumns`, the lane's per-input
26
- * projection with a partial bar kept partial unless the class carries no `present` mask; a `latest` lane on the
27
- * live row).
30
+ * projection, after its window-level pass over every held bar where it declares one, with a partial bar kept partial
31
+ * unless the class carries no `present` mask; a view block, the block of an input whose words name a fold, as it
32
+ * is, `wrunRowLaneAtWidth`; a `latest` lane on the live row).
28
33
  * - `wrunRowLaneReachFromMs` / `wrunRunSourceReachFromMs`: how far back a lane's source holds rows (its horizon, its
29
34
  * longest-kept tier), and where a run's history sources begin, which the warm-up decider reads so a first value a
30
35
  * source's history explains never buys a page of older candles.
@@ -44,13 +49,19 @@ export interface WrunRowLaneInput {
44
49
  source: WrunInputSource;
45
50
  lane: WrunRowLaneDescriptor;
46
51
  maxCells: number;
52
+ /** The tuples a bar's block may hold in the run's module (wrun-cell-capacity.leaf `wrunSheetCellBlockTuples`: the
53
+ * sheet's `capacity ?? max_cells`, a print union's whole only where the capacity holds it), the bound the packer
54
+ * refuses past: the row builder hands it to the input's projection. */
55
+ capacity: number;
47
56
  }
48
57
  /**
49
- * The static plan: every input whose class a row lane serves, in declaration order, with its lane. Refused by
50
- * name: a scalar input (a row lane serves cell blocks) and a celled one with no `max_cells` (the bound its blocks
51
- * are packed under). Empty when the sheet reads no row-lane class. The lane's width follows the input's own words
52
- * (wrun-option-views.util `wrunOptionInputTupleWidth`, the SDK's one rule: the strike kit fold's 14-value rows), so
53
- * the row builder reads and hands on the block each input's words make.
58
+ * The static plan: every input whose class a row lane serves, in declaration order, with its lane and its module's
59
+ * bound (`capacity`, `wrunSheetCellBlockTuples`). Refused by name: a scalar input (a row lane serves cell blocks), a
60
+ * celled one with no `max_cells` (the bound its blocks are packed under) and a capacity no build writes
61
+ * (`wrun_cell_capacity_invalid`). Empty when the sheet reads no row-lane class. The lane's width follows the input's
62
+ * own words (wrun-option-views.util `wrunOptionInputTupleWidth`, the SDK's one rule: a page view fold's view block,
63
+ * the strike kit fold's 14-value rows), so the row builder reads and hands on the block each input's words make; a
64
+ * block of another width than its class's is read as it is (`wrunRowLaneAtWidth`).
54
65
  */
55
66
  export declare function planWrunRowLaneInputs(metadata: WrunIndicatorMetadata): WrunRowLaneInput[];
56
67
  /** The id of the instance `extras` names: `row:<laneKey>` when the ask carries no extras, else the extras'
@@ -184,6 +195,19 @@ export interface WrunRowLaneWindow {
184
195
  intervalMs: number;
185
196
  barGrid?: LiveBucketVenue | null;
186
197
  nowMs: number;
198
+ /** The chart's trade date of a bar (its `time.trade_date`, epoch seconds), on which every run cuts a row-budget
199
+ * lane's slice so the slice holds whole sessions (wrun-row-lane-first-paint.util `wrunRowLaneFirstPaintSplit`): a
200
+ * first paint's asks and a later run's are the same windows. Absent: the plain cut, and no early answer. */
201
+ tradeDateOf?: (barOpenMs: number) => number;
202
+ }
203
+ /** What a row lane's fetch hands its caller beside the whole answer (`fetchWrunRowLaneRows`). */
204
+ export interface WrunRowLaneFetchOptions {
205
+ /**
206
+ * The first-paint slice's own answer, before the older asks land: called at most once, with the slice's rows, every
207
+ * bar it holds back read partial (bit 14), and the slice's first bar (`sliceFromTs`: every bar before it is held).
208
+ * Only a full run's first paint asks for it (wrun-overlay-run.util `runWrunSourceLanes`, the lane's early rows).
209
+ */
210
+ onFirstSlice?: (rows: unknown[][], sliceFromTs: number) => void;
187
211
  }
188
212
  /**
189
213
  * A row lane's rows over a chart window `[barOpens[0], last bar's end)`: a flow or snapshot lane's asks under the
@@ -191,17 +215,28 @@ export interface WrunRowLaneWindow {
191
215
  * extras), cut to its horizon and its row budget, each answer landed on the host bars (`wrunLandCellRowsOnHostBars`,
192
216
  * the lane's own `fold` when it has one), a snapshot's bar its tier answered nothing for asked again one tier coarser
193
217
  * where one fits and retains it when the lane's `coarserWhenEmpty` says so of the acquisition (D12), and the bars no
194
- * tier retains (or the budget left out) marked partial (bit 14, a marker tuple when empty); a `latest` lane asked
195
- * once over `fallback`, its rows as they come. A flow sums every bucket inside its bar, so its plan reads the window's
196
- * bar grid as its session grid (wrun-tier-grid.util `wrunCmeSessionBarSpan`): a CME session bar of a day or longer
197
- * is fit, budgeted and asked over its Globex session, from the 17:00 Chicago open before its 00:00Z stamp, never from
198
- * a UTC day bucket; a snapshot keeps its stamps (D12's settlement DAY rows). `ask` is the caller's fetch (the full
199
- * run's, a reconcile's). Ascending, one row per host bar.
218
+ * tier retains (or the budget left out) marked partial (bit 14, a marker tuple when empty; never on an instance its
219
+ * facets widen, whose rows carry no mask: `wrunRowLaneAtWidth`); a `latest` lane asked once over `fallback`, its rows
220
+ * as they come. A flow sums every bucket inside its bar, so its plan reads the window's bar grid as its session grid
221
+ * (wrun-tier-grid.util `wrunCmeSessionBarSpan`): a CME session bar of a day or longer is fit, budgeted and asked over
222
+ * its Globex session, from the 17:00 Chicago open before its 00:00Z stamp, never from a UTC day bucket; a snapshot
223
+ * keeps its stamps (D12's settlement DAY rows). `ask` is the caller's fetch (the full run's, a reconcile's).
224
+ * Ascending, one row per host bar.
225
+ *
226
+ * A row-budget lane's first-paint slice is cut on a trade date's first bar wherever the chart reads trade dates
227
+ * (`window.tradeDateOf`), on every run, so it holds whole sessions and every run asks the same windows.
228
+ * `opts.onFirstSlice` (a full run's first paint): every ask still leaves at once and the promise still answers the
229
+ * whole window, but the slice's own answer is handed over first, once, if it lands with rows while an older ask is
230
+ * still out a macrotask later: the slice's rows, every older bar the projection reads rows for read partial
231
+ * (wrun-row-lane-first-paint.util `wrunRowLaneFirstSliceHeldBars`), and the slice's first bar. Never when no cut falls
232
+ * on a session's first bar (a session longer than the slice: the plain split, asked as today), for a block with no
233
+ * `present` mask (it cannot read a bar as partial), a kit fold carrying the next bar (its pages ask one at a time), or
234
+ * a snapshot whose empty bars ask a coarser tier (that pass would ask the slice's bars again).
200
235
  */
201
236
  export declare function fetchWrunRowLaneRows(lane: WrunRowLaneDescriptor, extras: Readonly<Record<string, unknown>>, window: WrunRowLaneWindow, fallback: {
202
237
  fromTs: number;
203
238
  toTs: number;
204
- }, ask: (extras: Readonly<Record<string, unknown>>, fromTs: number, toTs: number) => Promise<ReadonlyArray<ReadonlyArray<unknown>>>): Promise<unknown[][]>;
239
+ }, ask: (extras: Readonly<Record<string, unknown>>, fromTs: number, toTs: number) => Promise<ReadonlyArray<ReadonlyArray<unknown>>>, opts?: WrunRowLaneFetchOptions): Promise<unknown[][]>;
205
240
  /**
206
241
  * A landed row with every packed block (a Float64Array a worker handed the page by transfer, `count x width` values back
207
242
  * to back: OPTLOAD G5 O6) split into plain tuples of `width` values, every other cell as it is; a new array. The one
@@ -290,9 +325,11 @@ export declare function wrunRowLaneOwnAsk(extras: Readonly<Record<string, unknow
290
325
  * bar the lane holds no row for reads a present EMPTY block). A PARTIAL bar stays partial through the projection
291
326
  * (`wrunProjectedBlock`). A `latest` lane's newest row lands on the LIVE row alone (`liveTs`, the chart's last row;
292
327
  * the options chain's rule) whatever its stamp, every other row reading an empty block. `afterTs` (a tail build's
293
- * carry) keeps the rows stamped after it, except a `latest` lane's newest.
328
+ * carry) keeps the rows stamped after it, except a `latest` lane's newest. An input reading a window-level pass
329
+ * (`cellsWindow`) reads every row the lane holds first, whatever `afterTs` keeps, and each bar's projection reads the
330
+ * answer.
294
331
  */
295
- export declare function wrunRowLaneCellRows(lane: Pick<WrunRowLaneDescriptor, 'width' | 'landing' | 'cells' | 'finiteColumns' | 'presentMask'>, rows: ReadonlyArray<ReadonlyArray<unknown>>, input: WrunRowLaneCellInput, opts?: {
332
+ export declare function wrunRowLaneCellRows(lane: Pick<WrunRowLaneDescriptor, 'width' | 'landing' | 'cells' | 'cellsWindow' | 'finiteColumns' | 'presentMask'>, rows: ReadonlyArray<ReadonlyArray<unknown>>, input: WrunRowLaneCellInput, opts?: {
296
333
  liveTs?: number;
297
334
  afterTs?: number;
298
335
  }): Array<{
@@ -3,16 +3,33 @@ import { wrunRowLaneByKey, wrunRowLaneOfClass, wrunRowLanes } from './row-lane-r
3
3
  import { assertWrunLaneChainPlaneReadable, stableJson, wrunChainLaneStop, wrunChartOpraPlane, wrunHostGridAsksWithinHorizon, wrunLaneNoChainRefusal, wrunOpraPlaneStopDetail, wrunPollLaneChainAsk, wrunPollLaneChainExchange, wrunPollLaneChainGovernedExchange, wrunPollLaneChainPlane, resolveWrunOptionSettingKnobs, wrunUnservedLaneInput, } from './wrun-poll-lanes.util.js';
4
4
  import { WRUN_ROW_LANE_ID_PREFIX, } from './wrun-row-lane.types.js';
5
5
  import { assertWrunOpraLaneReadable } from '../wrun-opra-lane.util.js';
6
+ import { wrunSheetCellBlockTuples } from '../wrun-cell-capacity.leaf.js';
6
7
  import { WRUN_OPTION_FLOW_TODAY_FIELD, wrunOptionFlowTodayFromOf } from '../wrun-option-contract-flow.util.js';
7
8
  import { wrunOptionInputTupleWidth, wrunOptionKitBarHasRows, wrunOptionLaneCarriesNext, wrunOptionLaneFirstPaintBudget, wrunOptionLaneTupleWidth, } from '../wrun-option-views.util.js';
8
9
  import { wrunPartialMarkerTuple, wrunPresentIsPartial, wrunTuplesMarkedPartial } from '../wrun-present-bits.util.js';
9
10
  import { wrunCellRowsWithPartialBars, wrunHostBarSpanOf, wrunHostGridAsks, wrunHostGridFallbackAsks, wrunLandCellRowsOnHostBars, } from '../wrun-tier-grid.util.js';
10
11
  /**
11
- * The static plan: every input whose class a row lane serves, in declaration order, with its lane. Refused by
12
- * name: a scalar input (a row lane serves cell blocks) and a celled one with no `max_cells` (the bound its blocks
13
- * are packed under). Empty when the sheet reads no row-lane class. The lane's width follows the input's own words
14
- * (wrun-option-views.util `wrunOptionInputTupleWidth`, the SDK's one rule: the strike kit fold's 14-value rows), so
15
- * the row builder reads and hands on the block each input's words make.
12
+ * A row lane at the width an input's words or an instance's facets make its block (wrun-option-views.util
13
+ * `wrunOptionInputTupleWidth`, `wrunOptionLaneTupleWidth`): the lane itself at its class's tuple width; at any other
14
+ * width a VIEW BLOCK (a page view fold's rows, the strike kit fold's: column 0 each row's layout, the widest layout's
15
+ * fields after it), read as the SDK's adapter reads one (kit `wrunCellBlockIsViewRows`, `kscriptViewRows`): every row
16
+ * of the width whole, a member that is no finite number NaN (`finiteColumns: []`), and no `present` mask
17
+ * (`presentMask: false`), so nothing reads or writes bit 14 in its last column, a fold's field or padding. Under the
18
+ * class tuple's rules Top Contracts' totals row (ending with `put_change`) marked every other row of the block partial
19
+ * at a change of 20,000 (bit 14 set), and was dropped whole on a block its knobs keep empty (no strike: `low_strike`
20
+ * and `high_strike` NaN).
21
+ */
22
+ function wrunRowLaneAtWidth(lane, width) {
23
+ return width === lane.width ? lane : { ...lane, width, finiteColumns: [], presentMask: false };
24
+ }
25
+ /**
26
+ * The static plan: every input whose class a row lane serves, in declaration order, with its lane and its module's
27
+ * bound (`capacity`, `wrunSheetCellBlockTuples`). Refused by name: a scalar input (a row lane serves cell blocks), a
28
+ * celled one with no `max_cells` (the bound its blocks are packed under) and a capacity no build writes
29
+ * (`wrun_cell_capacity_invalid`). Empty when the sheet reads no row-lane class. The lane's width follows the input's
30
+ * own words (wrun-option-views.util `wrunOptionInputTupleWidth`, the SDK's one rule: a page view fold's view block,
31
+ * the strike kit fold's 14-value rows), so the row builder reads and hands on the block each input's words make; a
32
+ * block of another width than its class's is read as it is (`wrunRowLaneAtWidth`).
16
33
  */
17
34
  export function planWrunRowLaneInputs(metadata) {
18
35
  const planned = [];
@@ -38,8 +55,9 @@ export function planWrunRowLaneInputs(metadata) {
38
55
  inputIndex: input.index,
39
56
  inputName: input.name,
40
57
  source,
41
- lane: width === lane.width ? lane : { ...lane, width },
58
+ lane: wrunRowLaneAtWidth(lane, width),
42
59
  maxCells,
60
+ capacity: wrunSheetCellBlockTuples(metadata, input),
43
61
  });
44
62
  }
45
63
  return planned;
@@ -283,17 +301,30 @@ export const WRUN_ROW_LANE_TIER_FIELD = 'tier';
283
301
  * extras), cut to its horizon and its row budget, each answer landed on the host bars (`wrunLandCellRowsOnHostBars`,
284
302
  * the lane's own `fold` when it has one), a snapshot's bar its tier answered nothing for asked again one tier coarser
285
303
  * where one fits and retains it when the lane's `coarserWhenEmpty` says so of the acquisition (D12), and the bars no
286
- * tier retains (or the budget left out) marked partial (bit 14, a marker tuple when empty); a `latest` lane asked
287
- * once over `fallback`, its rows as they come. A flow sums every bucket inside its bar, so its plan reads the window's
288
- * bar grid as its session grid (wrun-tier-grid.util `wrunCmeSessionBarSpan`): a CME session bar of a day or longer
289
- * is fit, budgeted and asked over its Globex session, from the 17:00 Chicago open before its 00:00Z stamp, never from
290
- * a UTC day bucket; a snapshot keeps its stamps (D12's settlement DAY rows). `ask` is the caller's fetch (the full
291
- * run's, a reconcile's). Ascending, one row per host bar.
304
+ * tier retains (or the budget left out) marked partial (bit 14, a marker tuple when empty; never on an instance its
305
+ * facets widen, whose rows carry no mask: `wrunRowLaneAtWidth`); a `latest` lane asked once over `fallback`, its rows
306
+ * as they come. A flow sums every bucket inside its bar, so its plan reads the window's bar grid as its session grid
307
+ * (wrun-tier-grid.util `wrunCmeSessionBarSpan`): a CME session bar of a day or longer is fit, budgeted and asked over
308
+ * its Globex session, from the 17:00 Chicago open before its 00:00Z stamp, never from a UTC day bucket; a snapshot
309
+ * keeps its stamps (D12's settlement DAY rows). `ask` is the caller's fetch (the full run's, a reconcile's).
310
+ * Ascending, one row per host bar.
311
+ *
312
+ * A row-budget lane's first-paint slice is cut on a trade date's first bar wherever the chart reads trade dates
313
+ * (`window.tradeDateOf`), on every run, so it holds whole sessions and every run asks the same windows.
314
+ * `opts.onFirstSlice` (a full run's first paint): every ask still leaves at once and the promise still answers the
315
+ * whole window, but the slice's own answer is handed over first, once, if it lands with rows while an older ask is
316
+ * still out a macrotask later: the slice's rows, every older bar the projection reads rows for read partial
317
+ * (wrun-row-lane-first-paint.util `wrunRowLaneFirstSliceHeldBars`), and the slice's first bar. Never when no cut falls
318
+ * on a session's first bar (a session longer than the slice: the plain split, asked as today), for a block with no
319
+ * `present` mask (it cannot read a bar as partial), a kit fold carrying the next bar (its pages ask one at a time), or
320
+ * a snapshot whose empty bars ask a coarser tier (that pass would ask the slice's bars again).
292
321
  */
293
- export async function fetchWrunRowLaneRows(lane, extras, window, fallback, ask) {
322
+ export async function fetchWrunRowLaneRows(lane, extras, window, fallback, ask, opts = {}) {
294
323
  const landing = lane.landing;
295
- // The instance's rows are its facets' (a strike kit fold's 14-value rows), read as plain tuples once landed.
296
- const width = wrunOptionLaneTupleWidth(lane.sourceClass, extras, lane.width);
324
+ // The instance's rows are its facets' (a strike kit fold's 14-value rows), read as plain tuples once landed; at
325
+ // another width than the class's they carry no `present` mask (`wrunRowLaneAtWidth`).
326
+ const sized = wrunRowLaneAtWidth(lane, wrunOptionLaneTupleWidth(lane.sourceClass, extras, lane.width));
327
+ const width = sized.width;
297
328
  if (landing.kind === 'latest') {
298
329
  return (await ask(extras, fallback.fromTs, fallback.toTs)).map((row) => wrunRowLanePlainRow(row, width));
299
330
  }
@@ -313,9 +344,24 @@ export async function fetchWrunRowLaneRows(lane, extras, window, fallback, ask)
313
344
  // and so are an instance's whose facets ask a per-bar word of the gateway (OPTLOAD G5: a surface pick, the strike kit
314
345
  // fold), sized by the rows its answer holds; every other instance asks as the tier rule made it.
315
346
  const sliceBudget = lane.rowBudget ?? wrunOptionLaneFirstPaintBudget(lane.sourceClass, extras, lane.width);
316
- const ordered = sliceBudget === undefined
317
- ? asks
318
- : (await import('./wrun-row-lane-first-paint.util.js')).wrunRowLaneFirstPaintAsks(asks, window, sliceBudget, budgetAcquisition, sessionGrid);
347
+ const firstPaint = sliceBudget === undefined ? undefined : await import('./wrun-row-lane-first-paint.util.js');
348
+ // The slice is cut on a trade date's first bar wherever the chart reads trade dates (`window.tradeDateOf`), so it
349
+ // holds whole sessions, on every run alike: a first paint asks the windows a later run asks (one cache entry each).
350
+ const split = firstPaint === undefined || sliceBudget === undefined
351
+ ? undefined
352
+ : firstPaint.wrunRowLaneFirstPaintSplit(asks, window, sliceBudget, budgetAcquisition, sessionGrid, window.tradeDateOf);
353
+ const ordered = split === undefined ? asks : [...split.first, ...split.older];
354
+ // The bars the slice's early answer holds back (`opts.onFirstSlice`), or undefined when it has none.
355
+ const coarserPass = landing.kind === 'snapshot' && landing.tiers !== undefined && landing.coarserWhenEmpty?.(extras) === true;
356
+ const heldBack = opts.onFirstSlice === undefined ||
357
+ firstPaint === undefined ||
358
+ split === undefined ||
359
+ sliceBudget === undefined ||
360
+ sized.presentMask === false ||
361
+ coarserPass ||
362
+ wrunOptionLaneCarriesNext(lane.sourceClass, extras)
363
+ ? undefined
364
+ : firstPaint.wrunRowLaneFirstSliceHeldBars(split, window, sliceBudget, budgetAcquisition, sessionGrid);
319
365
  const fold = landing.fold;
320
366
  // `askToMs` reads past the ask's own end (a kit fold's seam, below); only the ask's own bars ever land.
321
367
  const askAndLand = async (gridAsk, askToMs = gridAsk.toMs) => {
@@ -326,8 +372,50 @@ export async function fetchWrunRowLaneRows(lane, extras, window, fallback, ask)
326
372
  return wrunLandCellRowsOnHostBars(rows, landing.kind, { intervalMs: window.intervalMs, barGrid: window.barGrid, tierMs: gridAsk.tier?.ms, nowMs: window.nowMs }, fold === undefined ? undefined : (group) => fold(group, askExtras)).map((row) => wrunRowLanePlainRow(row, width));
327
373
  };
328
374
  const byBar = new Map();
329
- if (!wrunOptionLaneCarriesNext(lane.sourceClass, extras)) {
330
- for (const landed of await Promise.all(ordered.map((gridAsk) => askAndLand(gridAsk)))) {
375
+ const landAll = (gridAsks) => Promise.all(gridAsks.map((gridAsk) => askAndLand(gridAsk)));
376
+ if (heldBack !== undefined && split !== undefined && opts.onFirstSlice !== undefined) {
377
+ // Every ask leaves at once, as below; the slice's answer is handed over first while an older ask is still out.
378
+ const onFirstSlice = opts.onFirstSlice;
379
+ // The slice's first bar: the first bar the cut keeps (every bar before it is held).
380
+ const cutMs = split.sliceFromMs ?? Number.POSITIVE_INFINITY;
381
+ const sliceFromTs = window.barOpens.find((stampMs) => wrunHostBarSpanOf(stampMs, window.intervalMs, sessionGrid).fromMs >= cutMs);
382
+ const firstLanded = landAll(split.first);
383
+ const olderLanded = landAll(split.older);
384
+ let olderSettled = false;
385
+ void olderLanded.then(() => {
386
+ olderSettled = true;
387
+ }, () => {
388
+ olderSettled = true;
389
+ });
390
+ void firstLanded
391
+ .then(async (answers) => {
392
+ // One macrotask before the handover is judged: older asks that answered in the same turn (a cache) settle
393
+ // first, so a window already whole never draws half of itself and a rung to adopt the rest.
394
+ await new Promise((resolve) => setTimeout(resolve, 0));
395
+ if (olderSettled || sliceFromTs === undefined)
396
+ return;
397
+ const held = new Set(heldBack);
398
+ const slice = new Map();
399
+ for (const landed of answers) {
400
+ for (const row of landed)
401
+ if (!held.has(Number(row[0])))
402
+ slice.set(Number(row[0]), row);
403
+ }
404
+ if (slice.size === 0)
405
+ return;
406
+ const rows = [...slice.entries()].sort((a, b) => a[0] - b[0]).map(([, row]) => row);
407
+ onFirstSlice(wrunCellRowsWithPartialBars(rows, [...new Set([...partialBars, ...heldBack])], width), sliceFromTs);
408
+ }, () => undefined)
409
+ // A failed handover only costs the early picture: the whole answer still comes.
410
+ .catch(() => undefined);
411
+ const [firstAnswers, olderAnswers] = await Promise.all([firstLanded, olderLanded]);
412
+ for (const landed of [...firstAnswers, ...olderAnswers]) {
413
+ for (const row of landed)
414
+ byBar.set(Number(row[0]), row);
415
+ }
416
+ }
417
+ else if (!wrunOptionLaneCarriesNext(lane.sourceClass, extras)) {
418
+ for (const landed of await landAll(ordered)) {
331
419
  for (const row of landed)
332
420
  byBar.set(Number(row[0]), row);
333
421
  }
@@ -366,8 +454,9 @@ export async function fetchWrunRowLaneRows(lane, extras, window, fallback, ask)
366
454
  }
367
455
  }
368
456
  const landed = [...byBar.entries()].sort((a, b) => a[0] - b[0]).map(([, row]) => row);
369
- // A class with no `present` mask marks nothing: a partial bar asked nothing and reads an empty block.
370
- return lane.presentMask === false ? landed : wrunCellRowsWithPartialBars(landed, partialBars, width);
457
+ // A block with no `present` mask (its class's, or an instance's its facets widen) marks nothing: a partial bar asked
458
+ // nothing and reads an empty block.
459
+ return sized.presentMask === false ? landed : wrunCellRowsWithPartialBars(landed, partialBars, width);
371
460
  }
372
461
  /**
373
462
  * Where a kit fold page carrying the next bar's strikes is read to (the paging seam, OPTLOAD G5): through the end of the
@@ -570,9 +659,10 @@ function wrunCellMember(member) {
570
659
  /** A row's tuples as the host's exact adapter reads them: arrays of exactly `width` numbers, finite in every column
571
660
  * (the kit's rule for an exact class: any other tuple is dropped whole), or, for a lane naming its `finiteColumns`,
572
661
  * finite in those columns while any other column that is not a finite number reads NaN (om's adapter for such a
573
- * class: a null, a missing member or an infinity is NaN, never 0). A packed block (a Float64Array of `count x width`
574
- * values, a worker's transfer) reads as its tuples back to back, each under the same rule; a block that is no whole
575
- * number of tuples is skipped like any cell of another shape. */
662
+ * class: a null, a missing member or an infinity is NaN, never 0; a view block names none, so every row of its width
663
+ * is read, `wrunRowLaneAtWidth`). A packed block (a Float64Array of `count x width` values, a worker's transfer)
664
+ * reads as its tuples back to back, each under the same rule; a block that is no whole number of tuples is skipped
665
+ * like any cell of another shape. */
576
666
  function exactTuples(row, lane) {
577
667
  const { width, finiteColumns } = lane;
578
668
  const tuples = [];
@@ -608,10 +698,11 @@ function exactTuples(row, lane) {
608
698
  * (bit 14 of the `present` mask, the last column): when any of the bar's tuples says partial (a bar no fitting tier
609
699
  * retains, or the marker tuple of one that holds none), every tuple the projection keeps or rebuilds carries bit 14,
610
700
  * and a block the projection empties reads the marker tuple, so a package never reads missing history as a quiet bar.
611
- * A class with no `present` mask (`presentMask: false`) is projected as it is: its last column is a value.
701
+ * A block with no `present` mask (`presentMask: false`: its class's, or a view block's, `wrunRowLaneAtWidth`) is
702
+ * projected as it is: its last column is a value.
612
703
  */
613
- function wrunProjectedBlock(lane, tuples, input) {
614
- const projected = lane.cells ? lane.cells(tuples, input) : tuples;
704
+ function wrunProjectedBlock(lane, tuples, input, bar) {
705
+ const projected = lane.cells ? lane.cells(tuples, input, bar) : tuples;
615
706
  if (lane.presentMask === false)
616
707
  return projected;
617
708
  if (!tuples.some((tuple) => wrunPresentIsPartial(tuple[tuple.length - 1])))
@@ -625,27 +716,42 @@ function wrunProjectedBlock(lane, tuples, input) {
625
716
  * bar the lane holds no row for reads a present EMPTY block). A PARTIAL bar stays partial through the projection
626
717
  * (`wrunProjectedBlock`). A `latest` lane's newest row lands on the LIVE row alone (`liveTs`, the chart's last row;
627
718
  * the options chain's rule) whatever its stamp, every other row reading an empty block. `afterTs` (a tail build's
628
- * carry) keeps the rows stamped after it, except a `latest` lane's newest.
719
+ * carry) keeps the rows stamped after it, except a `latest` lane's newest. An input reading a window-level pass
720
+ * (`cellsWindow`) reads every row the lane holds first, whatever `afterTs` keeps, and each bar's projection reads the
721
+ * answer.
629
722
  */
630
723
  export function wrunRowLaneCellRows(lane, rows, input, opts = {}) {
631
- const project = (tuples) => wrunProjectedBlock(lane, tuples, input).flatMap((tuple) => [...tuple]);
724
+ // The input's window-level pass, if it reads one: every held bar's exact tuples, read once, then each bar's
725
+ // projection reads its answer.
726
+ const windowPass = lane.cellsWindow?.(input);
727
+ const bars = windowPass === undefined
728
+ ? undefined
729
+ : rows.map((row) => ({ openMs: Number(row[0]), tuples: exactTuples(row, lane) }));
730
+ const window = windowPass === undefined || bars === undefined
731
+ ? undefined
732
+ : windowPass(bars.filter((bar) => Number.isFinite(bar.openMs)));
733
+ const project = (at) => {
734
+ const tuples = bars?.[at].tuples ?? exactTuples(rows[at], lane);
735
+ const bar = bars === undefined ? undefined : { openMs: Number(rows[at][0]), window };
736
+ return wrunProjectedBlock(lane, tuples, input, bar).flatMap((tuple) => [...tuple]);
737
+ };
632
738
  if (lane.landing.kind === 'latest') {
633
739
  if (opts.liveTs === undefined || !Number.isFinite(opts.liveTs))
634
740
  return [];
635
- let newest;
636
- for (const row of rows) {
741
+ let newest = -1;
742
+ rows.forEach((row, at) => {
637
743
  const ts = Number(row[0]);
638
- if (Number.isFinite(ts) && (newest === undefined || ts > Number(newest[0])))
639
- newest = row;
640
- }
641
- return newest === undefined ? [] : [{ ts: opts.liveTs, cells: project(exactTuples(newest, lane)) }];
744
+ if (Number.isFinite(ts) && (newest < 0 || ts > Number(rows[newest][0])))
745
+ newest = at;
746
+ });
747
+ return newest < 0 ? [] : [{ ts: opts.liveTs, cells: project(newest) }];
642
748
  }
643
749
  const out = [];
644
- for (const row of rows) {
750
+ rows.forEach((row, at) => {
645
751
  const ts = Number(row[0]);
646
752
  if (!Number.isFinite(ts) || (opts.afterTs !== undefined && ts <= opts.afterTs))
647
- continue;
648
- out.push({ ts, cells: project(exactTuples(row, lane)) });
649
- }
753
+ return;
754
+ out.push({ ts, cells: project(at) });
755
+ });
650
756
  return out;
651
757
  }
@@ -51,13 +51,19 @@
51
51
  * it keeps the hover text (the mount door's, and the mount's re-registration after a pass that
52
52
  * failed part way); the boot-path hover inspector calls it through the thin registry and never
53
53
  * imports this module.
54
+ * - The caption's and the hover's number words (r11, Big Trades 0.7.0 "Size shown as"): THE one format list,
55
+ * WRUN_BATCHED_NUMBER_FORMATS (wrun-batched-readout.util), which the gate's vocabulary and the engine settings read
56
+ * here. `usd` prints dollars, `units` a mark's quantity in the market's own unit: its dollar value over the record's
57
+ * price times the market's dollar unit, which every build hands in (`valuePerUnit`, the run's
58
+ * `wrunMarketDollarUnit`) and a marks child carries on its settings (the engine's caption) and its readout (the
59
+ * hover). Where no unit is proven the engine is handed `usd` in place of `units`, never a wrong number.
54
60
  */
55
61
  import type { WrunBatchedMarksKind, WrunBatchedSection, WrunIndicatorMetadata, WrunOutputRow } from '../../interfaces/wrun-runtime.interface.js';
56
62
  import { type WrunCellsCapSummary } from './wrun-cap-notice.util.js';
57
63
  import { type WrunCanvasReadout } from './wrun-canvas-readout.util.js';
58
64
  import { wrunCanvasMergeLive } from './wrun-canvases.util.js';
59
65
  import { type WrunColorTheme } from './wrun-style-words.util.js';
60
- export { decodeWrunMarkMeta, decodeWrunSpanMeta, formatWrunBatchedNumber, wrunBatchedReadoutText, WRUN_MARK_META_MAX_OFFSET_MS, type WrunBatchedNumberFormat, type WrunMarkMeta, type WrunSpanMeta, } from './wrun-batched-readout.util.js';
66
+ export { decodeWrunMarkMeta, decodeWrunSpanMeta, formatWrunBatchedNumber, isWrunBatchedNumberFormat, WRUN_BATCHED_NUMBER_FORMATS, wrunBatchedReadoutText, wrunMarkQtyInUnits, WRUN_MARK_META_MAX_OFFSET_MS, type WrunBatchedNumberFormat, type WrunMarkMeta, type WrunSpanMeta, } from './wrun-batched-readout.util.js';
61
67
  export type { WrunBatchedHoverRecord } from './wrun-canvas-readout.util.js';
62
68
  /** The three kinds, in mount order: each a sheet key, a child id kind and the engine plot type. */
63
69
  export declare const WRUN_BATCHED_MARKS_KINDS: ReadonlyArray<WrunBatchedMarksKind>;
@@ -194,14 +200,21 @@ export interface WrunBatchedChildOverlay {
194
200
  export declare function wrunBatchedLayoutVerdict(kind: WrunBatchedMarksKind, section: Record<string, unknown>): string | null;
195
201
  /** The engine settings of a section's child: the geometry (`slots`, `stride`; `first_output` stays
196
202
  * here, the child rows start at field 0), the look of its kind, and `hoverReadout` when a tooltip is
197
- * declared (the engine registers its drawn records for hover then). Colours stay as declared. */
198
- export declare function wrunBatchedSettingsOf(spec: WrunBatchedSectionSpec): Record<string, unknown>;
203
+ * declared (the engine registers its drawn records for hover then). Colours stay as declared. A marks
204
+ * child also carries the market's dollar unit (`valuePerUnit`) when the build hands a proven one; spans
205
+ * and rays never do (their records hold no quantity). */
206
+ export declare function wrunBatchedSettingsOf(spec: WrunBatchedSectionSpec, context?: Pick<WrunBatchedChildrenOptions, 'valuePerUnit'>): Record<string, unknown>;
199
207
  /** What a build of the batched children takes beside the sheet and the rows. */
200
208
  export interface WrunBatchedChildrenOptions {
201
209
  /** A live tick's changed tail: the timestamp the tick re-evaluated from (the previous forming bar's,
202
210
  * the session's watermark). Each child is built from the parent rows at or after it only (walked
203
211
  * back from the newest), charges nothing and is marked `tailOnly`. */
204
212
  tailFromTs?: number;
213
+ /** The chart market's dollar unit (US dollars per price unit and size unit: the run's `wrunMarketDollarUnit`,
214
+ * handed in beside its size unit by every result build): a marks child's caption (`settings.valuePerUnit`, the
215
+ * engine's `units`) and hover (`readout.valuePerUnit`) divide a record's dollar value by it. Absent, or no number
216
+ * above zero: none is proven, and `units` prints dollars. A tail takes the one its full build took. */
217
+ valuePerUnit?: number;
205
218
  }
206
219
  /**
207
220
  * One child per batched section the Style rows leave visible, in mount order. A full build charges
@@ -6,8 +6,8 @@ import { wrunCanvasMergeLive } from './wrun-canvases.util.js';
6
6
  import { decodeWrunPackedColor, isWrunStyleTargetHidden, wrunPaintedDeclarationOf } from './wrun-color-settings.util.js';
7
7
  import { WRUN_HEATMAP_TRIM_WATERMARK, wrunHeatmapCellShares, wrunHeatmapTrimTarget, } from './wrun-heatmap-cell-budget.util.js';
8
8
  import { resolveWrunColorWord, wrunThemeTokenOfPacked, wrunThemeTokenWord, } from './wrun-style-words.util.js';
9
- import { decodeWrunMarkMeta, decodeWrunSpanMeta, wrunBatchedReadoutText } from './wrun-batched-readout.util.js';
10
- export { decodeWrunMarkMeta, decodeWrunSpanMeta, formatWrunBatchedNumber, wrunBatchedReadoutText, WRUN_MARK_META_MAX_OFFSET_MS, } from './wrun-batched-readout.util.js';
9
+ import { decodeWrunMarkMeta, decodeWrunSpanMeta, isWrunBatchedNumberFormat, WRUN_BATCHED_NUMBER_FORMATS, wrunBatchedReadoutText, wrunMarkUnitValue, } from './wrun-batched-readout.util.js';
10
+ export { decodeWrunMarkMeta, decodeWrunSpanMeta, formatWrunBatchedNumber, isWrunBatchedNumberFormat, WRUN_BATCHED_NUMBER_FORMATS, wrunBatchedReadoutText, wrunMarkQtyInUnits, WRUN_MARK_META_MAX_OFFSET_MS, } from './wrun-batched-readout.util.js';
11
11
  // ── The vocabulary ──────────────────────────────────────────────────────────
12
12
  /** The three kinds, in mount order: each a sheet key, a child id kind and the engine plot type. */
13
13
  export const WRUN_BATCHED_MARKS_KINDS = Object.freeze(['marks', 'spans', 'rays']);
@@ -312,7 +312,6 @@ function wordIndex(value, words, fallback) {
312
312
  const MARK_LOOKS = ['circle', 'dot', 'ring', 'square'];
313
313
  const MARK_TEXT_MODES = ['off', 'largest', 'all'];
314
314
  const MARK_X_WORDS = ['bar', 'offset'];
315
- const MARK_TEXT_FORMATS = new Set(['compact', 'price', 'int']);
316
315
  const LINE_STYLES = new Set(['solid', 'dashed', 'dotted']);
317
316
  // ── The gate: layouts newer than this chart ─────────────────────────────────
318
317
  /** A key's rule in the gate's vocabulary: `ANY` (the reader takes any value, clamping or defaulting
@@ -346,7 +345,7 @@ const SECTION_VOCABULARY = {
346
345
  size: { law: ['sqrt', 'linear'], unit: ANY, scale: ANY },
347
346
  opacity_pct: ANY,
348
347
  look: MARK_LOOK_VALUES,
349
- text: { mode: MARK_TEXT_MODE_VALUES, field: ['qty'], format: [...MARK_TEXT_FORMATS], min_px: ANY },
348
+ text: { mode: MARK_TEXT_MODE_VALUES, field: ['qty'], format: WRUN_BATCHED_NUMBER_FORMATS, min_px: ANY },
350
349
  x: MARK_X_VALUES,
351
350
  colors: ANY,
352
351
  tooltip: ANY,
@@ -466,14 +465,20 @@ function wordsOf(value) {
466
465
  /** The marks look the engine draws (r6 parity): `look` 0..3 (Bubble, Soft dot, Ring, Square), the
467
466
  * size law over the quantity (`unit` the Min size, `scale` the Bubble size 1..10), `x` 0..1
468
467
  * (Candle center, Trade time), `opacity_pct` 10..80, the caption (`text.mode` 0 Off, 1 Big
469
- * bubbles, 2 All; its format and the smallest bubble that holds one). A key left out, or an option
470
- * that is none of its values (look, x, law, the caption's mode and format), takes the kit's default
471
- * (LOOK_DEFAULTS.marks); a number past its range is clamped. */
472
- function marksSettings(section) {
468
+ * bubbles, 2 All; its format, a word of the one list, and the smallest bubble that holds one). A key
469
+ * left out, or an option that is none of its values (look, x, law, the caption's mode and format),
470
+ * takes the kit's default (LOOK_DEFAULTS.marks); a number past its range is clamped. The market's
471
+ * dollar unit (`valuePerUnit`, proven: finite and above zero) rides at the top for the `units`
472
+ * caption; without one, `units` is handed to the engine as `usd`. */
473
+ function marksSettings(section, valuePerUnit) {
473
474
  const defaults = LOOK_DEFAULTS.marks;
474
475
  const size = isRecord(section.size) ? section.size : {};
475
476
  const text = isRecord(section.text) ? section.text : {};
476
477
  const legacyShape = section.shape;
478
+ const written = isWrunBatchedNumberFormat(text.format) ? text.format : defaults.text.format;
479
+ // `units` divides by the market's dollar unit: with none proven it would caption a wrong number, so the engine reads
480
+ // the same amount in dollars (the hover's rule, wrun-batched-readout.util `wrunMarkQtyInUnits`).
481
+ const format = written === 'units' && valuePerUnit === undefined ? 'usd' : written;
477
482
  return {
478
483
  look: wordIndex(section.look ?? legacyShape, MARK_LOOKS, defaults.look),
479
484
  size: {
@@ -487,9 +492,10 @@ function marksSettings(section) {
487
492
  text: {
488
493
  mode: wordIndex(text.mode, MARK_TEXT_MODES, defaults.text.mode),
489
494
  field: defaults.text.field,
490
- format: typeof text.format === 'string' && MARK_TEXT_FORMATS.has(text.format) ? text.format : defaults.text.format,
495
+ format,
491
496
  min_px: clampTo(text.min_px, 0, 64, defaults.text.min_px),
492
497
  },
498
+ ...(valuePerUnit !== undefined ? { valuePerUnit } : {}),
493
499
  };
494
500
  }
495
501
  /** A span's edge: a `null` the sheet holds draws none; a declared edge takes each key it leaves out
@@ -531,10 +537,12 @@ function tooltipOf(section) {
531
537
  }
532
538
  /** The engine settings of a section's child: the geometry (`slots`, `stride`; `first_output` stays
533
539
  * here, the child rows start at field 0), the look of its kind, and `hoverReadout` when a tooltip is
534
- * declared (the engine registers its drawn records for hover then). Colours stay as declared. */
535
- export function wrunBatchedSettingsOf(spec) {
540
+ * declared (the engine registers its drawn records for hover then). Colours stay as declared. A marks
541
+ * child also carries the market's dollar unit (`valuePerUnit`) when the build hands a proven one; spans
542
+ * and rays never do (their records hold no quantity). */
543
+ export function wrunBatchedSettingsOf(spec, context = {}) {
536
544
  const look = spec.kind === 'marks'
537
- ? marksSettings(spec.declaration)
545
+ ? marksSettings(spec.declaration, wrunMarkUnitValue(context.valuePerUnit))
538
546
  : spec.kind === 'spans'
539
547
  ? spansSettings(spec.declaration)
540
548
  : raysSettings(spec.declaration);
@@ -543,8 +551,9 @@ export function wrunBatchedSettingsOf(spec) {
543
551
  /** The readout a section with a tooltip registers at its mount, with the record's text (the template
544
552
  * printed by wrun-batched-readout.util) on it: the child carries the readout it registers, so a
545
553
  * registration from the child alone (the mount's `syncCanvasReadouts` after a pass that failed part
546
- * way) keeps the hover text. */
547
- function readoutOf(spec) {
554
+ * way) keeps the hover text. A marks readout carries the market's dollar unit its `{{qty:units}}`
555
+ * divides by (proven only). */
556
+ function readoutOf(spec, valuePerUnit) {
548
557
  const tooltip = tooltipOf(spec.declaration);
549
558
  if (tooltip === null)
550
559
  return undefined;
@@ -559,17 +568,18 @@ function readoutOf(spec) {
559
568
  ...(words.length > 0 ? { words } : {}),
560
569
  // A timed record's `{{start}}` and `{{end}}` (their display offset is the mount door's to stamp).
561
570
  ...(timed ? { timed: true } : {}),
571
+ ...(spec.kind === 'marks' && valuePerUnit !== undefined ? { valuePerUnit } : {}),
562
572
  };
563
573
  readout.text = (record, formatters) => wrunBatchedReadoutText(readout, record, formatters);
564
574
  return readout;
565
575
  }
566
- function childOf(spec, data, extra) {
567
- const readout = readoutOf(spec);
576
+ function childOf(spec, data, extra, valuePerUnit) {
577
+ const readout = readoutOf(spec, valuePerUnit);
568
578
  return {
569
579
  kind: spec.kind,
570
580
  name: spec.name,
571
581
  data,
572
- settings: wrunBatchedSettingsOf(spec),
582
+ settings: wrunBatchedSettingsOf(spec, { valuePerUnit }),
573
583
  ...(readout !== undefined ? { readout } : {}),
574
584
  ...extra,
575
585
  };
@@ -602,6 +612,7 @@ export function wrunBatchedMarksChildren(sheet, outputRows, options = {}) {
602
612
  const specs = readWrunBatchedSections(sheet).filter((spec) => !isWrunStyleTargetHidden(spec.declaration));
603
613
  if (specs.length === 0)
604
614
  return [];
615
+ const valuePerUnit = wrunMarkUnitValue(options.valuePerUnit);
605
616
  if (options.tailFromTs !== undefined) {
606
617
  const from = wrunBatchedTailStart(outputRows, options.tailFromTs);
607
618
  return specs.map((spec) => {
@@ -611,7 +622,7 @@ export function wrunBatchedMarksChildren(sheet, outputRows, options = {}) {
611
622
  const data = wrunBatchedRowsOf(spec, outputRows, from, audit);
612
623
  return audit.newer !== undefined
613
624
  ? refusedChildOf(spec, audit.newer, { tailOnly: true })
614
- : childOf(spec, data, { tailOnly: true });
625
+ : childOf(spec, data, { tailOnly: true }, valuePerUnit);
615
626
  });
616
627
  }
617
628
  const bars = outputRows.length;
@@ -661,7 +672,7 @@ export function wrunBatchedMarksChildren(sheet, outputRows, options = {}) {
661
672
  cells: data[at].length * perBar,
662
673
  bars: data[at].length,
663
674
  },
664
- });
675
+ }, valuePerUnit);
665
676
  });
666
677
  }
667
678
  // ── The mount door ──────────────────────────────────────────────────────────