@orangecharts/wrun-chart-host 0.7.1 → 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 (210) hide show
  1. package/README.md +27 -4
  2. package/dist/constants/feature-flags.constants.d.ts +5 -0
  3. package/dist/constants/feature-flags.constants.js +32 -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 +29 -6
  9. package/dist/constants/option-venues.constants.js +19 -2
  10. package/dist/constants/venue-presets.constants.d.ts +17 -3
  11. package/dist/constants/venue-presets.constants.js +17 -3
  12. package/dist/host-env.d.ts +34 -4
  13. package/dist/host-env.js +21 -0
  14. package/dist/host-ports.types.d.ts +51 -3
  15. package/dist/index.d.ts +17 -0
  16. package/dist/index.js +17 -0
  17. package/dist/indicators/controls/tpo-session.util.d.ts +40 -11
  18. package/dist/indicators/controls/tpo-session.util.js +138 -14
  19. package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
  20. package/dist/interfaces/opra-realtime.interface.js +10 -10
  21. package/dist/interfaces/option-instrument.interface.d.ts +6 -0
  22. package/dist/interfaces/wrun-runtime.interface.d.ts +34 -13
  23. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +57 -10
  24. package/dist/kscript-data/controls/live-trades-merge.util.js +85 -16
  25. package/dist/market-data/billing.interface.d.ts +138 -17
  26. package/dist/market-data/billing.interface.js +25 -8
  27. package/dist/market-data/venues/index.d.ts +3 -3
  28. package/dist/market-data/venues/opra.contract.copy.json +5 -3
  29. package/dist/market-data/venues/opra.d.ts +3 -3
  30. package/dist/market-data/venues/opra.js +5 -4
  31. package/dist/replay/replayLadder.js +3 -1
  32. package/dist/settings-templates/footprint-rows.d.ts +25 -0
  33. package/dist/settings-templates/footprint-rows.js +127 -0
  34. package/dist/settings-templates/form-rows.d.ts +56 -0
  35. package/dist/settings-templates/form-rows.js +19 -0
  36. package/dist/settings-templates/frvp-fields.js +14 -0
  37. package/dist/settings-templates/index.d.ts +10 -1
  38. package/dist/settings-templates/index.js +11 -2
  39. package/dist/settings-templates/indicator-fields.js +78 -0
  40. package/dist/settings-templates/tool-rules.d.ts +35 -9
  41. package/dist/settings-templates/tool-rules.js +42 -8
  42. package/dist/settings-templates/tool-tables.generated.js +13 -2
  43. package/dist/utility/chart/candle-volume-unit.leaf.d.ts +16 -0
  44. package/dist/utility/chart/candle-volume-unit.leaf.js +61 -0
  45. package/dist/utility/chart/crypto-index.leaf.d.ts +2 -2
  46. package/dist/utility/chart/crypto-index.leaf.js +2 -2
  47. package/dist/utility/chart/footprint-columns.util.d.ts +74 -0
  48. package/dist/utility/chart/footprint-columns.util.js +106 -0
  49. package/dist/utility/chart/footprint-display-mode.util.d.ts +40 -0
  50. package/dist/utility/chart/footprint-display-mode.util.js +62 -0
  51. package/dist/utility/chart/footprint-sierra-look.util.d.ts +2 -0
  52. package/dist/utility/chart/footprint-sierra-look.util.js +37 -0
  53. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  54. package/dist/utility/chart/index-mode.util.d.ts +5 -2
  55. package/dist/utility/chart/index-mode.util.js +23 -13
  56. package/dist/utility/chart/kscript-venue-policy.util.d.ts +28 -21
  57. package/dist/utility/chart/kscript-venue-policy.util.js +34 -26
  58. package/dist/utility/chart/marketKind.util.d.ts +12 -10
  59. package/dist/utility/chart/marketKind.util.js +17 -7
  60. package/dist/utility/chart/om-panel-push-style.util.d.ts +7 -7
  61. package/dist/utility/chart/om-panel-push-style.util.js +17 -15
  62. package/dist/utility/chart/om-panel.util.d.ts +11 -0
  63. package/dist/utility/chart/om-panel.util.js +65 -6
  64. package/dist/utility/chart/profile-block-size.util.d.ts +16 -0
  65. package/dist/utility/chart/profile-block-size.util.js +7 -0
  66. package/dist/utility/chart/quote-perp.leaf.d.ts +17 -0
  67. package/dist/utility/chart/quote-perp.leaf.js +20 -0
  68. package/dist/utility/chart/window-geometry.leaf.d.ts +23 -1
  69. package/dist/utility/chart/window-geometry.leaf.js +78 -6
  70. package/dist/utility/chart/window-owner.leaf.d.ts +13 -0
  71. package/dist/utility/chart/window-owner.leaf.js +5 -0
  72. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -0
  73. package/dist/utility/chart/wrun-run-result.util.js +4 -1
  74. package/dist/utility/common/transformations.util.d.ts +7 -0
  75. package/dist/utility/common/transformations.util.js +11 -0
  76. package/dist/utility/options/cme-options-root.util.d.ts +25 -0
  77. package/dist/utility/options/cme-options-root.util.js +40 -0
  78. package/dist/utility/options/option-book.util.d.ts +27 -0
  79. package/dist/utility/options/option-book.util.js +76 -0
  80. package/dist/utility/options/option-trade-date.util.d.ts +50 -0
  81. package/dist/utility/options/option-trade-date.util.js +120 -0
  82. package/dist/utility/options/option-venue.util.d.ts +3 -3
  83. package/dist/utility/options/option-venue.util.js +3 -3
  84. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +1 -1
  85. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +2 -2
  86. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +2 -2
  87. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +5 -1
  88. package/dist/utility/wrun/sources/host-grid-landing.d.ts +4 -2
  89. package/dist/utility/wrun/sources/host-grid-landing.js +8 -0
  90. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +40 -4
  91. package/dist/utility/wrun/sources/lanes/options_flow.js +115 -18
  92. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +12 -9
  93. package/dist/utility/wrun/sources/opra-option-lanes.util.js +10 -7
  94. package/dist/utility/wrun/sources/row-lane-registry.js +10 -5
  95. package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
  96. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +3 -2
  97. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +30 -5
  98. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +9 -3
  99. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +13 -5
  100. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +25 -1
  101. package/dist/utility/wrun/sources/row-lanes/option_prints.js +161 -30
  102. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.d.ts +4 -0
  103. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +65 -0
  104. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +55 -1
  105. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +83 -2
  106. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +17 -1
  107. package/dist/utility/wrun/sources/row-lanes/option_surface.js +33 -2
  108. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +7 -1
  109. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +51 -5
  110. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +136 -3
  111. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +42 -0
  112. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +146 -0
  113. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +25 -5
  114. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +111 -20
  115. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +291 -48
  116. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +16 -3
  117. package/dist/utility/wrun/wrun-batched-marks.util.js +30 -19
  118. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +37 -9
  119. package/dist/utility/wrun/wrun-batched-readout.util.js +61 -15
  120. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -0
  121. package/dist/utility/wrun/wrun-cell-capacity.leaf.d.ts +66 -0
  122. package/dist/utility/wrun/wrun-cell-capacity.leaf.js +86 -0
  123. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +147 -9
  124. package/dist/utility/wrun/wrun-chart-market-facts.util.js +345 -11
  125. package/dist/utility/wrun/wrun-cloud-record.leaf.d.ts +27 -0
  126. package/dist/utility/wrun/wrun-cloud-record.leaf.js +71 -0
  127. package/dist/utility/wrun/wrun-cloud-record.util.d.ts +4 -21
  128. package/dist/utility/wrun/wrun-cloud-record.util.js +5 -65
  129. package/dist/utility/wrun/wrun-color-facts.util.d.ts +19 -9
  130. package/dist/utility/wrun/wrun-color-facts.util.js +24 -14
  131. package/dist/utility/wrun/wrun-color-settings.util.d.ts +22 -9
  132. package/dist/utility/wrun/wrun-color-settings.util.js +57 -23
  133. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.d.ts +17 -0
  134. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.js +9 -0
  135. package/dist/utility/wrun/wrun-download-meter.util.d.ts +92 -0
  136. package/dist/utility/wrun/wrun-download-meter.util.js +122 -0
  137. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +10 -3
  138. package/dist/utility/wrun/wrun-draft-overlay.util.js +63 -6
  139. package/dist/utility/wrun/wrun-frames.js +5 -5
  140. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
  141. package/dist/utility/wrun/wrun-hosted-wire-caps.js +11 -0
  142. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +33 -17
  143. package/dist/utility/wrun/wrun-hud-looks.util.js +30 -16
  144. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +29 -3
  145. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +33 -3
  146. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +8 -6
  147. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +8 -6
  148. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -2
  149. package/dist/utility/wrun/wrun-live-intake.util.d.ts +6 -2
  150. package/dist/utility/wrun/wrun-live-intake.util.js +136 -21
  151. package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -1
  152. package/dist/utility/wrun/wrun-live-tick.util.js +130 -44
  153. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.d.ts +53 -0
  154. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.js +162 -0
  155. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +224 -0
  156. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +342 -0
  157. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +88 -0
  158. package/dist/utility/wrun/wrun-market-size-defaults.util.js +471 -0
  159. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +43 -8
  160. package/dist/utility/wrun/wrun-opra-flow.leaf.js +37 -6
  161. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +51 -10
  162. package/dist/utility/wrun/wrun-option-contract-flow.util.js +85 -33
  163. package/dist/utility/wrun/wrun-option-prints.util.d.ts +172 -3
  164. package/dist/utility/wrun/wrun-option-prints.util.js +394 -17
  165. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +99 -0
  166. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +218 -0
  167. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +365 -0
  168. package/dist/utility/wrun/wrun-option-strike-flow.util.js +797 -0
  169. package/dist/utility/wrun/wrun-option-views.util.d.ts +231 -7
  170. package/dist/utility/wrun/wrun-option-views.util.js +643 -23
  171. package/dist/utility/wrun/wrun-options-chain.util.d.ts +6 -4
  172. package/dist/utility/wrun/wrun-options-chain.util.js +8 -5
  173. package/dist/utility/wrun/wrun-options-stop.util.d.ts +2 -1
  174. package/dist/utility/wrun/wrun-options-stop.util.js +3 -2
  175. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
  176. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +31 -14
  177. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +22 -0
  178. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +9 -1
  179. package/dist/utility/wrun/wrun-overlay-recovery.util.js +32 -3
  180. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +7 -1
  181. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  182. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +34 -6
  183. package/dist/utility/wrun/wrun-overlay-run.util.js +527 -180
  184. package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +15 -0
  185. package/dist/utility/wrun/wrun-pack-widths.leaf.js +22 -0
  186. package/dist/utility/wrun/wrun-pack.util.d.ts +13 -8
  187. package/dist/utility/wrun/wrun-pack.util.js +38 -21
  188. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +4 -0
  189. package/dist/utility/wrun/wrun-panel-mount.util.js +62 -22
  190. package/dist/utility/wrun/wrun-panel-style.util.d.ts +41 -14
  191. package/dist/utility/wrun/wrun-panel-style.util.js +86 -26
  192. package/dist/utility/wrun/wrun-param-map.util.d.ts +7 -6
  193. package/dist/utility/wrun/wrun-param-map.util.js +8 -5
  194. package/dist/utility/wrun/wrun-param-values.util.d.ts +10 -2
  195. package/dist/utility/wrun/wrun-param-values.util.js +2 -0
  196. package/dist/utility/wrun/wrun-pin-spelling.util.js +19 -10
  197. package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
  198. package/dist/utility/wrun/wrun-refusal.util.js +17 -2
  199. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +20 -0
  200. package/dist/utility/wrun/wrun-script-inputs.util.js +43 -0
  201. package/dist/utility/wrun/wrun-source-rows.util.d.ts +4 -0
  202. package/dist/utility/wrun/wrun-source-rows.util.js +92 -40
  203. package/dist/utility/wrun/wrun-tape-source.util.d.ts +133 -48
  204. package/dist/utility/wrun/wrun-tape-source.util.js +205 -62
  205. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +7 -5
  206. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +8 -6
  207. package/dist/workers/utils/volume-profile.worker.util.d.ts +4 -1
  208. package/dist/workers/utils/volume-profile.worker.util.js +5 -2
  209. package/dist/workers/wrun/wrun-abi-host.js +3 -2
  210. package/package.json +11 -11
@@ -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 ──────────────────────────────────────────────────────────
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * The batched records' readout (WRUN-BATCHED-MARKS): a `marks`, `spans` or `rays` record's meta
3
- * decode, the number formats a template (and a marks caption) prints with, and the tooltip text.
3
+ * decode, the number formats a template (and a marks caption) prints with (THE one list,
4
+ * WRUN_BATCHED_NUMBER_FORMATS), and the tooltip text.
4
5
  * The batched mount registers the text as its readout's `text` (wrun-batched-marks.util
5
6
  * `wrunBatchedChildConfig`), so the boot-path hover inspector prints a record through the thin
6
7
  * registry (wrun-canvas-readout.util) and never loads this module itself. A timed spans or rays
@@ -51,22 +52,49 @@ export declare const WRUN_BATCHED_TIMED_TOOLTIP_TOKENS: Readonly<{
51
52
  * at the start).
52
53
  */
53
54
  export declare function wrunTimedRecordSpan(record: Pick<WrunBatchedHoverRecord, 'ts' | 'fields'>): [number, number];
54
- /** The number formats a batched template (and a marks caption) prints with. */
55
- export type WrunBatchedNumberFormat = 'compact' | 'price' | 'int';
55
+ /**
56
+ * THE number formats a batched template and a marks caption print with, the kit's WRUN_MARK_TEXT_FORMATS (its
57
+ * WRUN_BATCHED_TOOLTIP_FORMATS): `compact` (Big Trades 0.3.2's caption, "1.2M", "1.2K"), `price` (the pane's price),
58
+ * `int` (rounded), `usd` ("$" before the compact amount, "$12M", "-$1.2K") and `units` (a mark's quantity in the
59
+ * market's own unit, `wrunMarkQtyInUnits`, printed compact; in dollars where no unit is proven). The layout gate's
60
+ * vocabulary, the engine settings and this readout read this list, and the format type derives from it: a word added
61
+ * in one hand copy alone refused the section ("Needs a newer chart") or printed the placeholder as written
62
+ * (tests/utility/wrun/wrun-batched-readout.util.spec.ts holds it to its golden and finds any second spelling of it in
63
+ * the package). TitanCharts keeps the engine's own copy for the caption, pinned to the same golden there.
64
+ */
65
+ export declare const WRUN_BATCHED_NUMBER_FORMATS: readonly ["compact", "price", "int", "usd", "units"];
66
+ /** A number format of the one list. */
67
+ export type WrunBatchedNumberFormat = (typeof WRUN_BATCHED_NUMBER_FORMATS)[number];
68
+ /** Whether a word is a number format of the one list. */
69
+ export declare function isWrunBatchedNumberFormat(word: unknown): word is WrunBatchedNumberFormat;
70
+ /** A market's dollar unit as the host hands it (`valuePerUnit`: the US dollars one price unit times one size unit is
71
+ * worth) when it is one, finite and above zero; undefined for anything else (no unit is proven). */
72
+ export declare function wrunMarkUnitValue(value: unknown): number | undefined;
73
+ /**
74
+ * A mark's quantity in the market's own unit (the `units` format): `qty`, its US dollar value, over the record's own
75
+ * price times the market's dollar unit. 25 NQ contracts at 24,000 at $20 a point ($12M) read 25, $12M of BTC at
76
+ * 100,000 reads 120. Exact for a combined trade too: the record's price is the trade's dollar VWAP, so the quotient is
77
+ * the sum of its fills' own units. Undefined where no dollar unit is proven or the price is no price above zero: the
78
+ * caller prints dollars (`usd`) then, never a wrong number.
79
+ */
80
+ export declare function wrunMarkQtyInUnits(qty: number, price: number, valuePerUnit: number | undefined): number | undefined;
56
81
  /** A number in a batched format: `compact` is Big Trades 0.3.2's caption ("1.2M", "1.2K", a whole
57
- * number from 100, one decimal from 1, two below 1), `int` the rounded whole number, `price` the
58
- * pane's price; a negative value keeps its sign. Not finite: '-'. */
82
+ * number from 100, one decimal from 1, two below 1), `usd` the same after a "$" ("$12M", "-$1.2K"),
83
+ * `units` compact (a mark's quantity reaches it converted, `wrunMarkQtyInUnits`), `int` the rounded
84
+ * whole number, `price` the pane's price; a negative value keeps its sign. Not finite: '-'. */
59
85
  export declare function formatWrunBatchedNumber(value: number, format: WrunBatchedNumberFormat | 'amount', formatPrice: (value: number) => string): string;
60
86
  /**
61
- * A batched record's tooltip (WRUN-BATCHED-MARKS): `{{name}}` or `{{name:<compact|price|int>}}`.
62
- * Marks read `{{side}}`, `{{qty}}` (default the full amount), `{{price}}` (default price) and
63
- * `{{fills}}` (default int); spans `{{top}}` and `{{bottom}}`, rays `{{y1}}` and `{{y2}}` (default
87
+ * A batched record's tooltip (WRUN-BATCHED-MARKS): `{{name}}` or `{{name:<format>}}`, a word of
88
+ * WRUN_BATCHED_NUMBER_FORMATS. Marks read `{{side}}`, `{{qty}}` (default the full amount; `{{qty:units}}`
89
+ * the quantity in the market's own unit over the record's price and the readout's `valuePerUnit`, in
90
+ * dollars where none is proven), `{{price}}` (default price) and `{{fills}}` (default int); spans
91
+ * `{{top}}` and `{{bottom}}`, rays `{{y1}}` and `{{y2}}` (default
64
92
  * price), both `{{length}}` (the length in bars, default int) and `{{word}}` (the section's word the meta
65
93
  * names, '' when none); a timed record (stride 5) `{{start}}` and `{{end}}` in place of `{{length}}`,
66
94
  * each the time as the chart prints it (`formatters.formatTime`, else wrun-chart-time.util shifted by
67
95
  * the display offset the mount door stamped on the readout), its meta its fifth field; `{{label}}` is
68
96
  * the readout's title. A placeholder
69
- * the record does not read, or a format word outside the three, stays as written; a hole (a
97
+ * the record does not read, or a format word outside the list, stays as written; a hole (a
70
98
  * non-finite field) prints '-'.
71
99
  */
72
100
  export declare function wrunBatchedReadoutText(readout: WrunCanvasReadout, record: WrunBatchedHoverRecord, formatters: {
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * The batched records' readout (WRUN-BATCHED-MARKS): a `marks`, `spans` or `rays` record's meta
3
- * decode, the number formats a template (and a marks caption) prints with, and the tooltip text.
3
+ * decode, the number formats a template (and a marks caption) prints with (THE one list,
4
+ * WRUN_BATCHED_NUMBER_FORMATS), and the tooltip text.
4
5
  * The batched mount registers the text as its readout's `text` (wrun-batched-marks.util
5
6
  * `wrunBatchedChildConfig`), so the boot-path hover inspector prints a record through the thin
6
7
  * registry (wrun-canvas-readout.util) and never loads this module itself. A timed spans or rays
@@ -58,7 +59,40 @@ export function wrunTimedRecordSpan(record) {
58
59
  const end = at(TIMED_END);
59
60
  return [start, Number.isFinite(end) && end > start ? end : start];
60
61
  }
61
- const BATCHED_FORMATS = new Set(['compact', 'price', 'int']);
62
+ /**
63
+ * THE number formats a batched template and a marks caption print with, the kit's WRUN_MARK_TEXT_FORMATS (its
64
+ * WRUN_BATCHED_TOOLTIP_FORMATS): `compact` (Big Trades 0.3.2's caption, "1.2M", "1.2K"), `price` (the pane's price),
65
+ * `int` (rounded), `usd` ("$" before the compact amount, "$12M", "-$1.2K") and `units` (a mark's quantity in the
66
+ * market's own unit, `wrunMarkQtyInUnits`, printed compact; in dollars where no unit is proven). The layout gate's
67
+ * vocabulary, the engine settings and this readout read this list, and the format type derives from it: a word added
68
+ * in one hand copy alone refused the section ("Needs a newer chart") or printed the placeholder as written
69
+ * (tests/utility/wrun/wrun-batched-readout.util.spec.ts holds it to its golden and finds any second spelling of it in
70
+ * the package). TitanCharts keeps the engine's own copy for the caption, pinned to the same golden there.
71
+ */
72
+ export const WRUN_BATCHED_NUMBER_FORMATS = Object.freeze(['compact', 'price', 'int', 'usd', 'units']);
73
+ const BATCHED_FORMATS = new Set(WRUN_BATCHED_NUMBER_FORMATS);
74
+ /** Whether a word is a number format of the one list. */
75
+ export function isWrunBatchedNumberFormat(word) {
76
+ return typeof word === 'string' && BATCHED_FORMATS.has(word);
77
+ }
78
+ /** A market's dollar unit as the host hands it (`valuePerUnit`: the US dollars one price unit times one size unit is
79
+ * worth) when it is one, finite and above zero; undefined for anything else (no unit is proven). */
80
+ export function wrunMarkUnitValue(value) {
81
+ return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : undefined;
82
+ }
83
+ /**
84
+ * A mark's quantity in the market's own unit (the `units` format): `qty`, its US dollar value, over the record's own
85
+ * price times the market's dollar unit. 25 NQ contracts at 24,000 at $20 a point ($12M) read 25, $12M of BTC at
86
+ * 100,000 reads 120. Exact for a combined trade too: the record's price is the trade's dollar VWAP, so the quotient is
87
+ * the sum of its fills' own units. Undefined where no dollar unit is proven or the price is no price above zero: the
88
+ * caller prints dollars (`usd`) then, never a wrong number.
89
+ */
90
+ export function wrunMarkQtyInUnits(qty, price, valuePerUnit) {
91
+ const unit = wrunMarkUnitValue(valuePerUnit);
92
+ if (unit === undefined || !(Number.isFinite(price) && price > 0))
93
+ return undefined;
94
+ return qty / (price * unit);
95
+ }
62
96
  /** `tenths` (a whole count of tenths) as "1.5" or "2" (never "2.0"). */
63
97
  function tenthsText(tenths) {
64
98
  const whole = Math.trunc(tenths / 10);
@@ -74,9 +108,18 @@ function amountText(value) {
74
108
  return tenthsText(Math.round(value * 10));
75
109
  return (Math.round(value * 100) / 100).toFixed(2);
76
110
  }
111
+ /** A size, at least 0, compact: "1.2M", "1.2K", else the full amount. */
112
+ function compactText(size) {
113
+ if (size >= 1_000_000)
114
+ return `${tenthsText(Math.round(size / 100_000))}M`;
115
+ if (size >= 1_000)
116
+ return `${tenthsText(Math.round(size / 100))}K`;
117
+ return amountText(size);
118
+ }
77
119
  /** A number in a batched format: `compact` is Big Trades 0.3.2's caption ("1.2M", "1.2K", a whole
78
- * number from 100, one decimal from 1, two below 1), `int` the rounded whole number, `price` the
79
- * pane's price; a negative value keeps its sign. Not finite: '-'. */
120
+ * number from 100, one decimal from 1, two below 1), `usd` the same after a "$" ("$12M", "-$1.2K"),
121
+ * `units` compact (a mark's quantity reaches it converted, `wrunMarkQtyInUnits`), `int` the rounded
122
+ * whole number, `price` the pane's price; a negative value keeps its sign. Not finite: '-'. */
80
123
  export function formatWrunBatchedNumber(value, format, formatPrice) {
81
124
  if (!Number.isFinite(value))
82
125
  return '-';
@@ -88,26 +131,24 @@ export function formatWrunBatchedNumber(value, format, formatPrice) {
88
131
  const size = Math.abs(value);
89
132
  if (format === 'amount')
90
133
  return `${sign}${amountText(size)}`;
91
- if (size >= 1_000_000)
92
- return `${sign}${tenthsText(Math.round(size / 100_000))}M`;
93
- if (size >= 1_000)
94
- return `${sign}${tenthsText(Math.round(size / 100))}K`;
95
- return `${sign}${amountText(size)}`;
134
+ return `${sign}${format === 'usd' ? '$' : ''}${compactText(size)}`;
96
135
  }
97
136
  /** The side words `{{side}}` prints, the template's own register (the author writes the template
98
137
  * around them, as Big Trades 0.3.2's module wrote "Buy" and "Sell"). Sides 2 and 3 print their
99
138
  * number. */
100
139
  const SIDE_WORDS = { 0: 'Sell', 1: 'Buy' };
101
140
  /**
102
- * A batched record's tooltip (WRUN-BATCHED-MARKS): `{{name}}` or `{{name:<compact|price|int>}}`.
103
- * Marks read `{{side}}`, `{{qty}}` (default the full amount), `{{price}}` (default price) and
104
- * `{{fills}}` (default int); spans `{{top}}` and `{{bottom}}`, rays `{{y1}}` and `{{y2}}` (default
141
+ * A batched record's tooltip (WRUN-BATCHED-MARKS): `{{name}}` or `{{name:<format>}}`, a word of
142
+ * WRUN_BATCHED_NUMBER_FORMATS. Marks read `{{side}}`, `{{qty}}` (default the full amount; `{{qty:units}}`
143
+ * the quantity in the market's own unit over the record's price and the readout's `valuePerUnit`, in
144
+ * dollars where none is proven), `{{price}}` (default price) and `{{fills}}` (default int); spans
145
+ * `{{top}}` and `{{bottom}}`, rays `{{y1}}` and `{{y2}}` (default
105
146
  * price), both `{{length}}` (the length in bars, default int) and `{{word}}` (the section's word the meta
106
147
  * names, '' when none); a timed record (stride 5) `{{start}}` and `{{end}}` in place of `{{length}}`,
107
148
  * each the time as the chart prints it (`formatters.formatTime`, else wrun-chart-time.util shifted by
108
149
  * the display offset the mount door stamped on the readout), its meta its fifth field; `{{label}}` is
109
150
  * the readout's title. A placeholder
110
- * the record does not read, or a format word outside the three, stays as written; a hole (a
151
+ * the record does not read, or a format word outside the list, stays as written; a hole (a
111
152
  * non-finite field) prints '-'.
112
153
  */
113
154
  export function wrunBatchedReadoutText(readout, record, formatters) {
@@ -135,8 +176,13 @@ export function wrunBatchedReadoutText(readout, record, formatters) {
135
176
  switch (name) {
136
177
  case 'side':
137
178
  return markMeta === null ? '-' : (SIDE_WORDS[markMeta.side] ?? String(markMeta.side));
138
- case 'qty':
139
- return number(field(1), format, 'amount');
179
+ case 'qty': {
180
+ if (format !== 'units')
181
+ return number(field(1), format, 'amount');
182
+ // The quantity in the market's own unit; dollars where the readout holds no unit or the record no price.
183
+ const units = wrunMarkQtyInUnits(field(1), field(0), readout.valuePerUnit);
184
+ return units === undefined ? number(field(1), 'usd', 'amount') : number(units, 'units', 'amount');
185
+ }
140
186
  case 'price':
141
187
  return number(field(0), format, 'price');
142
188
  case 'fills':
@@ -27,6 +27,10 @@ export interface WrunCanvasReadout {
27
27
  timed?: true;
28
28
  /** The display offset (ms) a timed record's `{{start}}` and `{{end}}` print in, stamped by the mount door. */
29
29
  timeOffsetMs?: number;
30
+ /** Marks: the market's dollar unit (US dollars per price unit and size unit, the run's `wrunMarketDollarUnit`),
31
+ * which `{{qty:units}}` divides a record's dollar value by; stamped by the batched build, absent where none is
32
+ * proven (`units` then prints dollars). */
33
+ valuePerUnit?: number;
30
34
  /** A batched record's tooltip text, registered with the readout by its mount. */
31
35
  text?: (record: WrunBatchedHoverRecord, formatters: {
32
36
  formatPrice: (value: number) => string;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The tuples one bar's block of a celled input may hold in the module a run drives, read off the module's own sheet.
3
+ * Kit scaffold 97 writes `capacity` on every celled input of a sheet it builds: the tuples the build sized the input's
4
+ * buffer and `in_<name>_capacity` by (`max_cells`, or `max_cells + newest` for a print class's union). Every host sizes
5
+ * a block by `capacity ?? max_cells` (om wrun-host `wrunModuleCellCapacity`, `wrunCellBlockTuples`), never by the
6
+ * read's knobs: a module built before scaffold 96 sized a union's buffer at `max_cells`, and a sheet built before
7
+ * scaffold 97 names no capacity, so it reads `max_cells` and a union input keeps the cut before the union (each bar's
8
+ * `max_cells` largest). One rule for every module, however it reached the run: a registry package, a draft the compile
9
+ * lane built, a dev fixture, the phone app's runs.
10
+ *
11
+ * A capacity no build writes refuses the run by name (`wrun_cell_capacity_invalid`, the kit schema's rule): the browser
12
+ * reads registry and fixture sheets without the kit's schema. The packer, the row-lane plan (each input's projection)
13
+ * and the live tape read one answer (`wrunSheetCellBlockTuples`), so they never disagree.
14
+ *
15
+ * LIGHT at module load: a leaf of the packer, the row-lane plan and the live tick, importing types alone.
16
+ */
17
+ import type { WrunIndicatorMetadata } from '../../interfaces/wrun-runtime.interface.js';
18
+ /** om's refusal of a celled input's capacity no build writes (`WRUN_CELL_CAPACITY_INVALID_CODE`, stage validate). */
19
+ export declare const WRUN_CELL_CAPACITY_INVALID_CODE = "wrun_cell_capacity_invalid";
20
+ /**
21
+ * The tuples one bar of a celled input's READ holds (om `wrunOptionInputCapacity`, the rule a build sizes the module's
22
+ * buffer by and writes as the input's `capacity`): its `max_cells`, and for a print class (`option_prints`,
23
+ * `option_prints_v2`) under `overflow: "largest"` beside `newest` N (a whole number, 1 and up) `max_cells + N`: each
24
+ * bar's `max_cells` largest unioned with its prints inside the window's N newest (the lane's projection,
25
+ * sources/row-lanes/option_prints `wrunLargestOrNewestOptionPrints`). Every other input keeps `max_cells`. Never a
26
+ * module's block bound: `wrunCellBlockTuples` reads the module's own capacity.
27
+ */
28
+ export declare function wrunCellReadCapacity(source: Readonly<Record<string, unknown>> | undefined, maxCells: number): number;
29
+ /** A celled input's two caps as its sheet declares them (om `WrunCellCapacityInput`): `max_cells`, and `capacity`, the
30
+ * tuples the module's own build sized its buffer by (scaffold 97, absent on every older sheet). */
31
+ export interface WrunCellCapacityInput {
32
+ readonly max_cells?: number | undefined;
33
+ readonly capacity?: number | undefined;
34
+ }
35
+ /** The tuples the module's buffer holds for a celled input (om `wrunModuleCellCapacity`): the sheet's `capacity`, which
36
+ * its build wrote beside `max_cells`, else `max_cells`, the buffer every build gives an input. */
37
+ export declare function wrunModuleCellCapacity(input: WrunCellCapacityInput): number;
38
+ /**
39
+ * The tuples one bar's block may hold on its way into the module (om `wrunCellBlockTuples`, the rule of every host
40
+ * that hands a module a block): its capacity (`wrunModuleCellCapacity`), except a print class's union the capacity does
41
+ * not hold whole (below `max_cells + newest`), whose bar keeps its `max_cells` largest, the cut before the union.
42
+ */
43
+ export declare function wrunCellBlockTuples(input: WrunCellCapacityInput, source: Readonly<Record<string, unknown>> | undefined): number;
44
+ /**
45
+ * The refusal of a celled input's declared `capacity` (om `wrunCellCapacityIssue`, the sheet schema's rule, in its
46
+ * words), or undefined when it stands or is absent: one on a scalar input, one that is no positive whole number (the
47
+ * schema's type check), one below `max_cells` (every build gives the buffer at least that) and one above what the
48
+ * input's read can hold a bar (`wrunCellReadCapacity`). A celled input without `max_cells` refuses on its own rule.
49
+ */
50
+ export declare function wrunCellCapacityIssue(input: {
51
+ readonly name: string;
52
+ readonly cellType?: string;
53
+ readonly max_cells?: number;
54
+ readonly capacity?: unknown;
55
+ }, source: Readonly<Record<string, unknown>> | undefined): string | undefined;
56
+ /**
57
+ * The tuples one bar's block of a sheet's celled input may hold in the module the sheet pins (`wrunCellBlockTuples`
58
+ * over its `capacity ?? max_cells`): the one bound the packer refuses past, the row-lane plan hands each input's
59
+ * projection and the live tape holds a forming bar to. A capacity no build writes refuses the run by name first
60
+ * (`wrunCellCapacityIssue`), before any block is sized by it.
61
+ */
62
+ export declare function wrunSheetCellBlockTuples(metadata: Pick<WrunIndicatorMetadata, 'id' | 'inputSources'>, input: WrunIndicatorMetadata['inputs'][number]): number;
63
+ /** The bound a block refusal names (`wrun_cell_block_too_large`): `max_cells is N`, or for a module whose capacity holds
64
+ * a print union past `max_cells`, `its capacity is N (max_cells M and newest K)`. The refusal record reads N either
65
+ * way (wrun-refusal.util), the most this Indicator was built for. */
66
+ export declare function wrunCellBoundWords(maxCells: number | undefined, tuples: number): string;
@@ -0,0 +1,86 @@
1
+ /** The print classes, whose `overflow: "largest"` beside `newest` reads the union (om `isWrunOptionPrintClass`). */
2
+ const WRUN_PRINT_CLASSES = new Set(['option_prints', 'option_prints_v2']);
3
+ /** om's refusal of a celled input's capacity no build writes (`WRUN_CELL_CAPACITY_INVALID_CODE`, stage validate). */
4
+ export const WRUN_CELL_CAPACITY_INVALID_CODE = 'wrun_cell_capacity_invalid';
5
+ /**
6
+ * The tuples one bar of a celled input's READ holds (om `wrunOptionInputCapacity`, the rule a build sizes the module's
7
+ * buffer by and writes as the input's `capacity`): its `max_cells`, and for a print class (`option_prints`,
8
+ * `option_prints_v2`) under `overflow: "largest"` beside `newest` N (a whole number, 1 and up) `max_cells + N`: each
9
+ * bar's `max_cells` largest unioned with its prints inside the window's N newest (the lane's projection,
10
+ * sources/row-lanes/option_prints `wrunLargestOrNewestOptionPrints`). Every other input keeps `max_cells`. Never a
11
+ * module's block bound: `wrunCellBlockTuples` reads the module's own capacity.
12
+ */
13
+ export function wrunCellReadCapacity(source, maxCells) {
14
+ if (source === undefined || !WRUN_PRINT_CLASSES.has(String(source.source)))
15
+ return maxCells;
16
+ const newest = source.newest;
17
+ return source.overflow === 'largest' && typeof newest === 'number' && Number.isInteger(newest) && newest >= 1
18
+ ? maxCells + newest
19
+ : maxCells;
20
+ }
21
+ /** The tuples the module's buffer holds for a celled input (om `wrunModuleCellCapacity`): the sheet's `capacity`, which
22
+ * its build wrote beside `max_cells`, else `max_cells`, the buffer every build gives an input. */
23
+ export function wrunModuleCellCapacity(input) {
24
+ return input.capacity ?? input.max_cells ?? Number.POSITIVE_INFINITY;
25
+ }
26
+ /**
27
+ * The tuples one bar's block may hold on its way into the module (om `wrunCellBlockTuples`, the rule of every host
28
+ * that hands a module a block): its capacity (`wrunModuleCellCapacity`), except a print class's union the capacity does
29
+ * not hold whole (below `max_cells + newest`), whose bar keeps its `max_cells` largest, the cut before the union.
30
+ */
31
+ export function wrunCellBlockTuples(input, source) {
32
+ const capacity = wrunModuleCellCapacity(input);
33
+ const maxCells = input.max_cells ?? Number.POSITIVE_INFINITY;
34
+ return capacity >= wrunCellReadCapacity(source, maxCells) ? capacity : Math.min(capacity, maxCells);
35
+ }
36
+ /**
37
+ * The refusal of a celled input's declared `capacity` (om `wrunCellCapacityIssue`, the sheet schema's rule, in its
38
+ * words), or undefined when it stands or is absent: one on a scalar input, one that is no positive whole number (the
39
+ * schema's type check), one below `max_cells` (every build gives the buffer at least that) and one above what the
40
+ * input's read can hold a bar (`wrunCellReadCapacity`). A celled input without `max_cells` refuses on its own rule.
41
+ */
42
+ export function wrunCellCapacityIssue(input, source) {
43
+ const capacity = input.capacity;
44
+ if (capacity === undefined)
45
+ return undefined;
46
+ const declared = typeof capacity === 'number' ? String(capacity) : JSON.stringify(capacity);
47
+ const who = `${WRUN_CELL_CAPACITY_INVALID_CODE}: input '${input.name}' declares capacity ${declared}`;
48
+ if (input.cellType !== 'array') {
49
+ return `${who} without cellType "array"; capacity is the tuples a celled input's buffer holds, which a scalar input has none of`;
50
+ }
51
+ if (typeof capacity !== 'number' || !Number.isInteger(capacity) || capacity < 1) {
52
+ return `${who}, no positive whole number of tuples; the build writes capacity itself, so delete it and rebuild`;
53
+ }
54
+ const maxCells = input.max_cells;
55
+ if (maxCells === undefined)
56
+ return undefined;
57
+ if (capacity < maxCells) {
58
+ return `${who} below its max_cells ${maxCells}; every build gives the input's buffer at least max_cells tuples and writes capacity itself, so delete it and rebuild`;
59
+ }
60
+ const most = wrunCellReadCapacity(source, maxCells);
61
+ if (capacity > most) {
62
+ return `${who} above the ${most} tuples its read can hold a bar (${most === maxCells ? 'max_cells' : "max_cells + newest, a print class's union"}); the build writes capacity itself, so delete it and rebuild`;
63
+ }
64
+ return undefined;
65
+ }
66
+ /**
67
+ * The tuples one bar's block of a sheet's celled input may hold in the module the sheet pins (`wrunCellBlockTuples`
68
+ * over its `capacity ?? max_cells`): the one bound the packer refuses past, the row-lane plan hands each input's
69
+ * projection and the live tape holds a forming bar to. A capacity no build writes refuses the run by name first
70
+ * (`wrunCellCapacityIssue`), before any block is sized by it.
71
+ */
72
+ export function wrunSheetCellBlockTuples(metadata, input) {
73
+ const source = metadata.inputSources[input.name];
74
+ const issue = wrunCellCapacityIssue(input, source);
75
+ if (issue !== undefined)
76
+ throw new Error(`WRUN ${metadata.id}: ${issue}`);
77
+ return wrunCellBlockTuples(input, source);
78
+ }
79
+ /** The bound a block refusal names (`wrun_cell_block_too_large`): `max_cells is N`, or for a module whose capacity holds
80
+ * a print union past `max_cells`, `its capacity is N (max_cells M and newest K)`. The refusal record reads N either
81
+ * way (wrun-refusal.util), the most this Indicator was built for. */
82
+ export function wrunCellBoundWords(maxCells, tuples) {
83
+ return maxCells === undefined || maxCells === tuples
84
+ ? `max_cells is ${tuples}`
85
+ : `its capacity is ${tuples} (max_cells ${maxCells} and newest ${tuples - maxCells})`;
86
+ }