@orangecharts/wrun-chart-host 0.9.0 → 0.10.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 (170) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/feature-flags.constants.d.ts +6 -1
  3. package/dist/constants/feature-flags.constants.js +67 -24
  4. package/dist/constants/opra-compliance.constants.d.ts +3 -2
  5. package/dist/constants/opra-compliance.constants.js +3 -2
  6. package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +26 -0
  7. package/dist/constants/scriptEditor/builtin-script-snippets.js +6 -0
  8. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +15 -0
  9. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +17 -0
  10. package/dist/constants/venue-presets.constants.d.ts +20 -20
  11. package/dist/constants/venue-presets.constants.js +24 -26
  12. package/dist/host-env.d.ts +29 -5
  13. package/dist/host-env.js +6 -0
  14. package/dist/host-ports.types.d.ts +69 -15
  15. package/dist/index.d.ts +13 -0
  16. package/dist/index.js +13 -0
  17. package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
  18. package/dist/interfaces/replay.interface.d.ts +8 -0
  19. package/dist/interfaces/wrun-runtime.interface.d.ts +18 -2
  20. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +41 -4
  21. package/dist/kscript-data/controls/live-trades-merge.util.js +52 -7
  22. package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +56 -0
  23. package/dist/kscript-data/controls/live-trades-order-gate.util.js +107 -0
  24. package/dist/market-data/billing.interface.d.ts +95 -31
  25. package/dist/market-data/billing.interface.js +36 -5
  26. package/dist/market-data/venue.d.ts +88 -6
  27. package/dist/market-data/venues/cme.contract.copy.json +66 -0
  28. package/dist/market-data/venues/cme.d.ts +126 -0
  29. package/dist/market-data/venues/cme.js +133 -0
  30. package/dist/market-data/venues/index.d.ts +162 -5
  31. package/dist/market-data/venues/index.js +48 -6
  32. package/dist/settings-templates/index.js +7 -3
  33. package/dist/settings-templates/indicator-fields.d.ts +5 -4
  34. package/dist/settings-templates/indicator-fields.js +45 -6
  35. package/dist/settings-templates/tool-rules.d.ts +27 -17
  36. package/dist/settings-templates/tool-rules.js +27 -11
  37. package/dist/settings-templates/tool-tables.generated.js +91 -31
  38. package/dist/utility/chart/book-live-bucket.util.d.ts +15 -0
  39. package/dist/utility/chart/book-live-bucket.util.js +47 -0
  40. package/dist/utility/chart/index-mode-admission.util.js +15 -2
  41. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +35 -11
  42. package/dist/utility/chart/kscript-drawing-safe-area.util.js +145 -35
  43. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +7 -2
  44. package/dist/utility/chart/kscript-live-coalesce.util.js +9 -3
  45. package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
  46. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
  47. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +32 -2
  48. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +45 -0
  49. package/dist/utility/chart/kscript-venue-policy.util.d.ts +54 -35
  50. package/dist/utility/chart/kscript-venue-policy.util.js +78 -42
  51. package/dist/utility/chart/market-session-schedule.util.d.ts +10 -0
  52. package/dist/utility/chart/market-session-schedule.util.js +16 -0
  53. package/dist/utility/chart/opra-read-access.leaf.d.ts +5 -3
  54. package/dist/utility/chart/opra-read-access.leaf.js +5 -3
  55. package/dist/utility/chart/rth-session.util.d.ts +3 -2
  56. package/dist/utility/chart/rth-session.util.js +2 -1
  57. package/dist/utility/chart/window-geometry.leaf.d.ts +8 -0
  58. package/dist/utility/chart/window-geometry.leaf.js +22 -6
  59. package/dist/utility/chart/wrun-run-result.util.d.ts +12 -0
  60. package/dist/utility/chart/wrun-run-result.util.js +141 -6
  61. package/dist/utility/options/option-bar-anchor.util.d.ts +145 -0
  62. package/dist/utility/options/option-bar-anchor.util.js +340 -0
  63. package/dist/utility/options/option-venue.util.d.ts +18 -0
  64. package/dist/utility/options/option-venue.util.js +27 -0
  65. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
  66. package/dist/utility/wrun/derived-roots.util.d.ts +213 -0
  67. package/dist/utility/wrun/derived-roots.util.js +471 -0
  68. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +41 -6
  69. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +89 -19
  70. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +9 -4
  71. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +47 -6
  72. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -2
  73. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -2
  74. package/dist/utility/wrun/sources/lanes/option_daily.js +5 -2
  75. package/dist/utility/wrun/sources/lanes/options_flow.js +5 -2
  76. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +64 -19
  77. package/dist/utility/wrun/sources/opra-option-lanes.util.js +105 -35
  78. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +2 -1
  79. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +2 -1
  80. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +3 -0
  81. package/dist/utility/wrun/sources/row-lanes/option_prints.js +19 -4
  82. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
  83. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +52 -13
  84. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +88 -19
  85. package/dist/utility/wrun/sources/row-lanes/option_surface.js +2 -1
  86. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
  87. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +24 -9
  88. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +39 -10
  89. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +64 -0
  90. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +89 -0
  91. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +15 -3
  92. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +22 -3
  93. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -0
  94. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +174 -13
  95. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +685 -27
  96. package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +12 -0
  97. package/dist/utility/wrun/wrun-builtin-twin.util.js +21 -0
  98. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +53 -12
  99. package/dist/utility/wrun/wrun-chart-market-facts.util.js +101 -53
  100. package/dist/utility/wrun/wrun-download-meter.util.d.ts +15 -0
  101. package/dist/utility/wrun/wrun-download-meter.util.js +14 -2
  102. package/dist/utility/wrun/wrun-download-plan.util.d.ts +99 -0
  103. package/dist/utility/wrun/wrun-download-plan.util.js +118 -0
  104. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +11 -3
  105. package/dist/utility/wrun/wrun-draft-legend-note.util.js +26 -4
  106. package/dist/utility/wrun/wrun-frames.d.ts +27 -6
  107. package/dist/utility/wrun/wrun-frames.js +73 -10
  108. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +7 -1
  109. package/dist/utility/wrun/wrun-hosted-wire.util.js +12 -2
  110. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +18 -4
  111. package/dist/utility/wrun/wrun-hud-looks.util.js +45 -13
  112. package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
  113. package/dist/utility/wrun/wrun-live-intake.util.d.ts +13 -7
  114. package/dist/utility/wrun/wrun-live-intake.util.js +82 -29
  115. package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -0
  116. package/dist/utility/wrun/wrun-live-tick.util.js +158 -14
  117. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +49 -10
  118. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +65 -5
  119. package/dist/utility/wrun/wrun-market-size-defaults.util.js +31 -5
  120. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +17 -4
  121. package/dist/utility/wrun/wrun-opra-lane.util.js +6 -4
  122. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.d.ts +31 -0
  123. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.js +119 -0
  124. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +23 -6
  125. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +47 -11
  126. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +86 -19
  127. package/dist/utility/wrun/wrun-option-strike-flow.util.js +168 -62
  128. package/dist/utility/wrun/wrun-option-views.util.d.ts +47 -13
  129. package/dist/utility/wrun/wrun-option-views.util.js +98 -26
  130. package/dist/utility/wrun/wrun-output-style.util.d.ts +6 -2
  131. package/dist/utility/wrun/wrun-output-style.util.js +20 -2
  132. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +17 -0
  133. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +10 -1
  134. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +52 -4
  135. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +100 -31
  136. package/dist/utility/wrun/wrun-overlay-run.util.js +733 -114
  137. package/dist/utility/wrun/wrun-pane-format.util.d.ts +2 -1
  138. package/dist/utility/wrun/wrun-pane-format.util.js +7 -3
  139. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -0
  140. package/dist/utility/wrun/wrun-panel-mount.util.js +63 -13
  141. package/dist/utility/wrun/wrun-panel-style.util.d.ts +10 -9
  142. package/dist/utility/wrun/wrun-panel-style.util.js +58 -9
  143. package/dist/utility/wrun/wrun-param-map.util.d.ts +14 -11
  144. package/dist/utility/wrun/wrun-param-map.util.js +10 -5
  145. package/dist/utility/wrun/wrun-param-values.util.d.ts +14 -4
  146. package/dist/utility/wrun/wrun-param-values.util.js +4 -0
  147. package/dist/utility/wrun/wrun-pin-spelling.util.js +12 -11
  148. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +50 -0
  149. package/dist/utility/wrun/wrun-refusal-surface.util.js +68 -0
  150. package/dist/utility/wrun/wrun-refused-latest.util.d.ts +10 -0
  151. package/dist/utility/wrun/wrun-refused-latest.util.js +12 -0
  152. package/dist/utility/wrun/wrun-row-source.d.ts +11 -0
  153. package/dist/utility/wrun/wrun-run-interval.util.d.ts +4 -2
  154. package/dist/utility/wrun/wrun-run-interval.util.js +9 -6
  155. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +45 -1
  156. package/dist/utility/wrun/wrun-script-inputs.util.js +112 -4
  157. package/dist/utility/wrun/wrun-setting-words.util.d.ts +7 -3
  158. package/dist/utility/wrun/wrun-setting-words.util.js +13 -5
  159. package/dist/utility/wrun/wrun-socket-row-source.d.ts +27 -2
  160. package/dist/utility/wrun/wrun-socket-row-source.js +113 -8
  161. package/dist/utility/wrun/wrun-source-rows.util.d.ts +5 -1
  162. package/dist/utility/wrun/wrun-source-rows.util.js +16 -3
  163. package/dist/utility/wrun/wrun-style-words.util.js +6 -4
  164. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +3 -2
  165. package/dist/utility/wrun/wrun-table-chrome.util.js +19 -11
  166. package/dist/utility/wrun/wrun-tape-per-order.util.d.ts +2 -0
  167. package/dist/utility/wrun/wrun-tape-per-order.util.js +26 -0
  168. package/dist/utils/replay/replay-buffer-math.d.ts +53 -2
  169. package/dist/utils/replay/replay-buffer-math.js +227 -20
  170. package/package.json +11 -11
@@ -0,0 +1,118 @@
1
+ import { wrunChartHostEnv } from '../../host-env.js';
2
+ import { wrunRunDownloadBudgetBytes } from './wrun-download-meter.util.js';
3
+ const MINUTE_MS = 60_000;
4
+ function countOf(value) {
5
+ return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : 0;
6
+ }
7
+ /**
8
+ * A read's own meter: every charge goes on to the run's meter unchanged (the run's summary counts every read once) and
9
+ * into the read's tally, so a budgeted read learns what its newest slice downloaded while the run's other reads
10
+ * download beside it (wrun-row-lanes.util `fetchWrunRowLaneRows` `download`).
11
+ */
12
+ export function createWrunLaneDownloadMeter(run) {
13
+ let bytes = 0;
14
+ let asks = 0;
15
+ let cachedAsks = 0;
16
+ return {
17
+ charge(charge) {
18
+ run.charge(charge);
19
+ asks += 1;
20
+ const wire = charge.verdict?.wireBytes;
21
+ if (typeof wire === 'number' && Number.isFinite(wire) && wire >= 0) {
22
+ bytes += wire;
23
+ if (wire === 0)
24
+ cachedAsks += 1;
25
+ }
26
+ else {
27
+ bytes += countOf(charge.cellBytes);
28
+ }
29
+ },
30
+ spentBytes: () => bytes,
31
+ asks: () => asks,
32
+ cachedAsks: () => cachedAsks,
33
+ };
34
+ }
35
+ /** Where the kit's two windows meet on a log scale (the geometric mean of 5 minutes and an hour, about 17 minutes): a
36
+ * bar narrower is priced as the 5m window's, a wider one as the 1h window's. */
37
+ const KIT_INTERVAL_SPLIT_MS = Math.sqrt(5 * MINUTE_MS * 60 * MINUTE_MS);
38
+ /** The kit's window nearest a chart's bar (`wrunDownloadReadCost` prices '1h' and '5m' alone). */
39
+ export function wrunDownloadKitInterval(intervalMs) {
40
+ return Number.isFinite(intervalMs) && intervalMs > 0 && intervalMs < KIT_INTERVAL_SPLIT_MS ? '5m' : '1h';
41
+ }
42
+ /** A chart's market shape as the kit prices it: a CME Group exchange `cme`, a session market (a stock, an ETF, an index
43
+ * mode chart) `us-stock`, every other (a crypto venue, 24/7) `crypto`. */
44
+ export function wrunDownloadMarketOf(chart) {
45
+ if (chart.cme)
46
+ return 'cme';
47
+ return chart.indexMode ? 'us-stock' : 'crypto';
48
+ }
49
+ function sharedHostPrice(read, market, interval) {
50
+ return wrunChartHostEnv().sharedHost().wrunDownloadReadCost(read, market, interval);
51
+ }
52
+ /** The key a read's share is filed under. */
53
+ export function wrunDownloadPlanKeyOf(read) {
54
+ return read.key ?? read.inputs.join(',');
55
+ }
56
+ /** A read's projected bytes on the window: the lane's own projection where it carries one, else the kit's. */
57
+ export function wrunDownloadPlanReadBytes(read, window, price = sharedHostPrice) {
58
+ const own = read.projectedBytes;
59
+ if (typeof own === 'number' && Number.isFinite(own) && own >= 0)
60
+ return own;
61
+ const bytes = price(read, window.market, wrunDownloadKitInterval(window.intervalMs)).bytes;
62
+ return Number.isFinite(bytes) && bytes > 0 ? bytes : 0;
63
+ }
64
+ /**
65
+ * The run's mode, before any fetch: WHOLE when the reads' projection is at or under the run's budget, else BUDGETED
66
+ * with each history read's share of what the reserved reads leave, in proportion to its projection (a read the run
67
+ * cannot cut, a snapshot or a scalar read, keeps its projection and is never cut). A read's share never holds it to
68
+ * nothing: it asks its newest slice whatever the share (the lane's rule), so a share is what its older bars may spend.
69
+ */
70
+ export function wrunRunDownloadMode(reads, window, price = sharedHostPrice) {
71
+ const priced = reads.map((read) => ({ read, bytes: wrunDownloadPlanReadBytes(read, window, price) }));
72
+ const projectedBytes = priced.reduce((sum, { bytes }) => sum + bytes, 0);
73
+ const budgetBytes = wrunRunDownloadBudgetBytes(window.bars);
74
+ if (projectedBytes <= budgetBytes)
75
+ return { mode: 'whole', projectedBytes };
76
+ const reserved = priced.filter(({ read }) => read.history !== true).reduce((sum, { bytes }) => sum + bytes, 0);
77
+ const history = priced.filter(({ read }) => read.history === true);
78
+ const historyBytes = history.reduce((sum, { bytes }) => sum + bytes, 0);
79
+ const left = Math.max(0, budgetBytes - reserved);
80
+ const shares = new Map();
81
+ for (const { read, bytes } of history) {
82
+ const key = wrunDownloadPlanKeyOf(read);
83
+ const share = historyBytes > 0 ? Math.floor((left * bytes) / historyBytes) : 0;
84
+ shares.set(key, (shares.get(key) ?? 0) + share);
85
+ }
86
+ return { mode: 'budgeted', projectedBytes, budgetBytes, shares };
87
+ }
88
+ /**
89
+ * The sheet's reads as the kit charges them (`wrunDownloadPlanReads`, the declared-read half: every input it is handed
90
+ * is a read the plan left unasked, so each is charged from its declaration over the window), one per class and knob set
91
+ * with the inputs it serves: its knobs (a view, a fold, `history`, the strike knobs), its setting-bound knobs at the
92
+ * run's values (`settingOf`), its cap a bar (the input's capacity) and its width. `inputs` names the inputs the run
93
+ * reads (an input the market leaves undemanded is no read); the window is the run's, warm-up included
94
+ * (`[fromMs, toMs)`, at its bar). The chart's own candles are no read of the run (its rows answer them).
95
+ */
96
+ export function wrunRunDownloadReads(sheet, window, inputs, settingOf = () => undefined) {
97
+ if (inputs.length === 0 || !(window.intervalMs > 0) || !(window.toMs > window.fromMs))
98
+ return [];
99
+ const primary = {
100
+ key: 'wrun-download-window',
101
+ class: 'ohlcv',
102
+ exchange: '',
103
+ symbol: '',
104
+ foreign: false,
105
+ primary: true,
106
+ intervalMs: window.intervalMs,
107
+ fromMs: window.fromMs,
108
+ toMs: window.toMs,
109
+ fields: [],
110
+ };
111
+ // No wire names an ask of the plan, so every input is charged from its declaration.
112
+ const wires = inputs.map((inputName) => ({ kind: 'scalar', inputName, fetchKey: '' }));
113
+ const plan = { fetches: [primary], wires };
114
+ const host = wrunChartHostEnv().sharedHost();
115
+ // The kit asks a knob's setting by the knob's own words ("@rows" or "rows"): both read the setting `rows`.
116
+ const reads = host.wrunDownloadPlanReads(sheet, plan, (name) => settingOf(name.startsWith('@') ? name.slice(1) : name));
117
+ return reads.filter((read) => read.inputs.length > 0);
118
+ }
@@ -1,3 +1,4 @@
1
+ import { type WrunOpraServedReceipt } from './wrun-opra-lane.util.js';
1
2
  export declare function wrunDraftLegendNote(settings: unknown): string | undefined;
2
3
  /**
3
4
  * The served tier of the chain a run's options_chain lane read (its acquisition record), named only
@@ -12,10 +13,17 @@ export declare function wrunChainServedTierNote(acquisition: Readonly<Record<str
12
13
  * alike). Undefined when every OPRA read rode real-time, or none was made.
13
14
  */
14
15
  export declare function wrunOpraLanesServedTierNote(acquisitions: Iterable<unknown> | undefined): string | undefined;
16
+ /**
17
+ * The served tier of a hosted (Cloud) run's OPRA reads as its frame's receipt names it (`WrunOpraServedReceipt`,
18
+ * contract opra-server-lanes C4), in the chain's own words: OPRA's delay notice for a delayed receipt (its minutes the
19
+ * receipt's own figure, else the venue's nominal delay), nothing for a real-time one. Nothing for no receipt: a frame
20
+ * that named no tier is unknown, and the account's current tier is never read in its place.
21
+ */
22
+ export declare function wrunCloudOpraServedNote(served: WrunOpraServedReceipt | undefined): string | undefined;
15
23
  /** The whole note a run's legend carries: the draft's word, then the served tier of its OPRA reads (the chain's,
16
- * else any OPRA lane's among `acquisitions`, the run's record by lane), joined by " · "; undefined when neither
17
- * applies. */
18
- export declare function wrunOverlayLegendNote(settings: unknown, chainAcquisition?: Readonly<Record<string, unknown>>, acquisitions?: Readonly<Record<string, unknown>>): string | undefined;
24
+ * else any OPRA lane's among `acquisitions`, the run's record by lane, else a Cloud run's frame receipt,
25
+ * `cloudOpraServed`), joined by " · "; undefined when none applies. */
26
+ export declare function wrunOverlayLegendNote(settings: unknown, chainAcquisition?: Readonly<Record<string, unknown>>, acquisitions?: Readonly<Record<string, unknown>>, cloudOpraServed?: WrunOpraServedReceipt): string | undefined;
19
27
  /**
20
28
  * Every wording a legend note can hold in a SAVED title that today's words do not produce: the title is
21
29
  * written by the run and kept in the overlay's settings, so a title written under an older build or another
@@ -13,6 +13,10 @@
13
13
  * lane (a poll lane's `opra`, a row lane's `governed: 'opra'`) names the tier its ask was routed to
14
14
  * by the same rule and the same words (its acquisition's `servedTier`, wrun-opra-lane.util), once
15
15
  * for every OPRA read the run made.
16
+ * - the served tier of a hosted (Cloud) run's OPRA reads, as its newest frame's receipt names it
17
+ * (contract opra-server-lanes C4: `wrunOpraTier` beside the cloud's OPRA mark, `WrunOpraServedReceipt`):
18
+ * the same delayed line for a delayed receipt, none for a real-time one, and none for a frame that
19
+ * named no tier (an unknown tier shows no word: the account's current tier is never put in its place).
16
20
  * The note lands in the define's custom title, which the overlay's settings keep: every reader of the
17
21
  * inputs alone (the indicator menu, the settings headers) drops it through `wrunWithoutLegendNote`, the
18
22
  * one stripper of whatever `wrunOverlayLegendNote` appends, in today's words and in every wording a saved
@@ -62,12 +66,30 @@ export function wrunOpraLanesServedTierNote(acquisitions) {
62
66
  }
63
67
  return undefined;
64
68
  }
69
+ /**
70
+ * The served tier of a hosted (Cloud) run's OPRA reads as its frame's receipt names it (`WrunOpraServedReceipt`,
71
+ * contract opra-server-lanes C4), in the chain's own words: OPRA's delay notice for a delayed receipt (its minutes the
72
+ * receipt's own figure, else the venue's nominal delay), nothing for a real-time one. Nothing for no receipt: a frame
73
+ * that named no tier is unknown, and the account's current tier is never read in its place.
74
+ */
75
+ export function wrunCloudOpraServedNote(served) {
76
+ if (served?.tier !== 'delayed')
77
+ return undefined;
78
+ const venue = optionVenueForExchange('OPRA');
79
+ if (!venue)
80
+ return undefined;
81
+ const minutes = typeof served.delaySeconds === 'number' && served.delaySeconds > 0
82
+ ? Math.max(1, Math.round(served.delaySeconds / 60))
83
+ : optionVenueDelayMinutes(venue);
84
+ return optionVenueDisclosure(venue, 'delayed', minutes, wrunChartHostEnv().t);
85
+ }
65
86
  /** The whole note a run's legend carries: the draft's word, then the served tier of its OPRA reads (the chain's,
66
- * else any OPRA lane's among `acquisitions`, the run's record by lane), joined by " · "; undefined when neither
67
- * applies. */
68
- export function wrunOverlayLegendNote(settings, chainAcquisition, acquisitions) {
87
+ * else any OPRA lane's among `acquisitions`, the run's record by lane, else a Cloud run's frame receipt,
88
+ * `cloudOpraServed`), joined by " · "; undefined when none applies. */
89
+ export function wrunOverlayLegendNote(settings, chainAcquisition, acquisitions, cloudOpraServed) {
69
90
  const opra = wrunChainServedTierNote(chainAcquisition) ??
70
- (acquisitions === undefined ? undefined : wrunOpraLanesServedTierNote(Object.values(acquisitions)));
91
+ (acquisitions === undefined ? undefined : wrunOpraLanesServedTierNote(Object.values(acquisitions))) ??
92
+ wrunCloudOpraServedNote(cloudOpraServed);
71
93
  const notes = [wrunDraftLegendNote(settings), opra].filter((note) => typeof note === 'string' && note.trim() !== '');
72
94
  return notes.length > 0 ? notes.join(' · ') : undefined;
73
95
  }
@@ -15,10 +15,15 @@
15
15
  * columns`). The frame payload types live here beside their parsers (X24);
16
16
  * the sheet declaration types stay in wrun-runtime.interface.ts.
17
17
  *
18
+ * One exception to refusing: a panel's legend text past its cap (a frame
19
+ * `title`, `caption` or `hole_caption`) draws clipped to the cap with an
20
+ * ellipsis, and the parsed frame carries a notice that says so
21
+ * (`wrunPanelFrameNotices`). A long caption is no reason to lose the panel.
22
+ *
18
23
  * Guard G2 (the no-disguises rule) runs on every string a frame carries,
19
24
  * after the JSON decode, before the grammar.
20
25
  */
21
- import type { WrunFontWeight, WrunLevels, WrunMatrix, WrunPanel, WrunPanelGuide, WrunPanelHighlight, WrunPanelBadge, WrunPanelMarker, WrunPanelQuadrants } from '../../interfaces/wrun-runtime.interface.js';
26
+ import type { WrunFontWeight, WrunLevels, WrunMatrix, WrunPanel, WrunPanelGuide, WrunPanelHighlight, WrunPanelBadge, WrunPanelMarker, WrunPanelQuadrants, WrunPanelXLabels } from '../../interfaces/wrun-runtime.interface.js';
22
27
  import { type ParsedPanel } from '../chart/om-panel.util.js';
23
28
  import type { FeedLine, LadderProps, LadderRow } from '../chart/om-widget.util.js';
24
29
  import type { WrunMiniChartsFrame } from '@orangecharts/indicator-kit/host';
@@ -159,8 +164,17 @@ export interface WrunPanelFrameChrome {
159
164
  /** A table's rows' markets (UW-PARITY H4), one per row: null or the market
160
165
  * a click on the row opens (wrun-row-market.util). */
161
166
  markets?: (WrunRowMarket | null)[];
167
+ /** C3: a numeric-x line's or bars' label per row, "" for a row without one
168
+ * (WrunPanelXLabels); the pane prints it where the row's x number would be. */
169
+ x_labels?: WrunPanelXLabels;
162
170
  }
163
171
  export type WrunPanelFrameWord = keyof WrunPanelFrameChrome;
172
+ /** A parsed panel frame and the notices of what the host changed to draw it:
173
+ * one plain-English line per chrome text drawn clipped to its cap (the
174
+ * register of the canvas notices); absent when the frame drew as written. */
175
+ export type WrunParsedPanelFrame = ParsedPanel & {
176
+ notices?: string[];
177
+ };
164
178
  /** A styled matrix cell: at least one field. */
165
179
  export interface WrunMatrixCellStyle {
166
180
  value?: number;
@@ -204,7 +218,7 @@ export declare const WRUN_LEVELS_SPAN_KEYS: readonly ["start", "end", "prices",
204
218
  export declare function parseWrunLevelsFrame(raw: string, slot: string, declaration?: Partial<Pick<WrunLevels, 'name' | 'span'>>): WrunLevelsFrame | WrunLevelsSpansFrame;
205
219
  type PanelKind = WrunPanel['kind'];
206
220
  /** Which kinds take each frame key; x_min / x_max also need x "index" or
207
- * "number" on a line, like the declared words. */
221
+ * "number" on a line, like the declared words, and x_labels x "number" (C3). */
208
222
  export declare const WRUN_PANEL_FRAME_WORD_KINDS: Readonly<Record<WrunPanelFrameWord, ReadonlyArray<PanelKind>>>;
209
223
  /** The frame keys this panel's kind accepts beside `rows`. */
210
224
  export declare function wrunPanelFrameWords(kind: PanelKind): WrunPanelFrameWord[];
@@ -212,13 +226,20 @@ export declare function wrunPanelFrameWords(kind: PanelKind): WrunPanelFrameWord
212
226
  * any key outside the kind's words refuses by name, each value goes
213
227
  * through its declared word's ranges, then the cross rules against the
214
228
  * declaration. Returns the parsed chrome (empty when the frame carries
215
- * only rows). */
216
- export declare function parseWrunPanelChrome(frame: Record<string, unknown>, declaration: WrunPanel, slot: string): WrunPanelFrameChrome;
229
+ * only rows); a legend text drawn clipped adds its line to `notices`. */
230
+ export declare function parseWrunPanelChrome(frame: Record<string, unknown>, declaration: WrunPanel, slot: string, notices?: string[]): WrunPanelFrameChrome;
217
231
  /** Parses a panel frame: `rows` through the receive-lane validator (one row
218
232
  * grammar on both lanes; the wrun lane carries the declaration's style
219
233
  * words) plus the kind's chrome keys through {@link parseWrunPanelChrome},
220
- * returned as `ParsedPanel.chrome` when the frame carries any. */
221
- export declare function parseWrunPanelFrame(raw: string, slot: string, declaration: WrunPanel): ParsedPanel;
234
+ * returned as `ParsedPanel.chrome` when the frame carries any, and the
235
+ * notices of a legend text drawn clipped as `notices` when there are any. */
236
+ export declare function parseWrunPanelFrame(raw: string, slot: string, declaration: WrunPanel): WrunParsedPanelFrame;
237
+ /** A parsed panel frame's notices (a legend text drawn clipped to its cap), a
238
+ * fresh array, empty when the frame drew as written: the panel's share of a
239
+ * run result's `notices`, the warning rows the Indicator's legend shows. It
240
+ * takes the `ParsedPanel` a panel child carries; the lines ride the object
241
+ * parseWrunPanelFrame returned. */
242
+ export declare function wrunPanelFrameNotices(frame: ParsedPanel): string[];
222
243
  export declare function parseWrunLadderFrame(raw: string, slot: string): WrunLadderFrame;
223
244
  export declare function parseWrunFeedFrame(raw: string, slot: string): WrunFeedFrame;
224
245
  /** Parses a matrix frame through the kit's grammar (`WrunMatrixFrameSchema`:
@@ -424,7 +424,7 @@ const ALL_PANEL_KINDS = [
424
424
  ];
425
425
  const AXIS_PANEL_KINDS = ['line', 'bars', 'histogram', 'scatter'];
426
426
  /** Which kinds take each frame key; x_min / x_max also need x "index" or
427
- * "number" on a line, like the declared words. */
427
+ * "number" on a line, like the declared words, and x_labels x "number" (C3). */
428
428
  export const WRUN_PANEL_FRAME_WORD_KINDS = {
429
429
  title: ALL_PANEL_KINDS,
430
430
  caption: ALL_PANEL_KINDS,
@@ -443,6 +443,7 @@ export const WRUN_PANEL_FRAME_WORD_KINDS = {
443
443
  hole_text: ['pie'],
444
444
  hole_caption: ['pie'],
445
445
  markets: ['table'],
446
+ x_labels: ['line', 'bars'],
446
447
  };
447
448
  const PANEL_FRAME_WORDS = Object.keys(WRUN_PANEL_FRAME_WORD_KINDS);
448
449
  /** The frame keys this panel's kind accepts beside `rows`. */
@@ -471,6 +472,40 @@ const RICH_CHROME_MESSAGE = "needs chrome 'grid' or 'none' on a time, category o
471
472
  function panelText(value, key, max, at, path) {
472
473
  return text(value, max) ? value : at(path, `${key} must be 1 to ${max} characters`);
473
474
  }
475
+ /** A panel's legend text (a frame `title`, `caption` or `hole_caption`).
476
+ * Past its cap it draws clipped and `clipped` records it: the OPRA QA OI
477
+ * Changes frame (2026-10-22) lost its whole panel to an 88-character
478
+ * caption. An empty or non-text value still refuses, with the kit's message. */
479
+ function panelClippedText(value, key, max, at, clipped) {
480
+ if (typeof value !== 'string' || value.length < 1)
481
+ return at([key], `${key} must be 1 to ${max} characters`);
482
+ if (value.length <= max)
483
+ return value;
484
+ clipped(key, value.length, max);
485
+ return clipText(value, max);
486
+ }
487
+ /** `value` cut to `max` UTF-16 units (the caps' unit: the kit counts string
488
+ * length) with an ellipsis as the last one, never splitting a surrogate pair. */
489
+ function clipText(value, max) {
490
+ let end = max - 1;
491
+ const last = value.charCodeAt(end - 1);
492
+ if (last >= 0xd800 && last <= 0xdbff)
493
+ end -= 1;
494
+ return `${value.slice(0, end)}…`;
495
+ }
496
+ /** C3 `x_labels`: one entry per row, "" for a row without a label. The count
497
+ * against the rows waits for the row parse (parseWrunPanelFrame). */
498
+ function xLabelsRowsMessage(rows) {
499
+ const count = rows === undefined ? '' : ` (${rows})`;
500
+ return `x_labels must hold one entry per row${count}, "" for a row without a label`;
501
+ }
502
+ function panelXLabels(value, at) {
503
+ if (!Array.isArray(value))
504
+ return at(['x_labels'], xLabelsRowsMessage());
505
+ return value.map((label, i) => text(label, WRUN_PANEL_MAX_LABEL_CHARS, 0)
506
+ ? label
507
+ : at(['x_labels', i], `x_labels entries must be 0 to ${WRUN_PANEL_MAX_LABEL_CHARS} characters`));
508
+ }
474
509
  function panelNumber(value, key, at, path) {
475
510
  return finite(value) ? value : at(path, `${key} must be a finite number`);
476
511
  }
@@ -670,9 +705,13 @@ function effectivePanelChrome(panel) {
670
705
  * x_max on a numeric line or a scatter, the box-line rule on markers,
671
706
  * category marker keys, a point marker's series among the declared ones
672
707
  * (C3), the paired ranges (a frame half against the declared other half),
673
- * hole text needs a hole. */
708
+ * hole text needs a hole, x_labels needs x "number" (C3). */
674
709
  function refinePanelChrome(panel, chrome, at) {
675
710
  const numeric = panel.x === 'index' || panel.x === 'number';
711
+ // A label stands in for a row's x number, so only a numeric x has one to replace.
712
+ if (chrome.x_labels !== undefined && panel.x !== 'number') {
713
+ at(['x_labels'], "x_labels is only valid for a line or bars with x 'number'");
714
+ }
676
715
  for (const word of ['x_min', 'x_max']) {
677
716
  if (chrome[word] !== undefined && panel.kind !== 'scatter' && !numeric) {
678
717
  at([word], `${word} is only valid for a line with x 'index' or 'number', and scatter`);
@@ -714,9 +753,13 @@ function refinePanelChrome(panel, chrome, at) {
714
753
  * any key outside the kind's words refuses by name, each value goes
715
754
  * through its declared word's ranges, then the cross rules against the
716
755
  * declaration. Returns the parsed chrome (empty when the frame carries
717
- * only rows). */
718
- export function parseWrunPanelChrome(frame, declaration, slot) {
756
+ * only rows); a legend text drawn clipped adds its line to `notices`. */
757
+ export function parseWrunPanelChrome(frame, declaration, slot, notices) {
719
758
  const at = refuser(slot);
759
+ // The panel's name leads the line, as a TPO's does in the canvas notices.
760
+ const clipped = (key, written, max) => {
761
+ notices?.push(`panel '${declaration.name}': ${key} clipped from ${written} to ${max} characters`);
762
+ };
720
763
  const allowed = wrunPanelFrameWords(declaration.kind);
721
764
  for (const key of Object.keys(frame)) {
722
765
  if (key !== 'rows' && !allowed.includes(key)) {
@@ -730,10 +773,10 @@ export function parseWrunPanelChrome(frame, declaration, slot) {
730
773
  continue;
731
774
  switch (word) {
732
775
  case 'title':
733
- chrome.title = panelText(value, word, WRUN_PANEL_MAX_TITLE_CHARS, at, [word]);
776
+ chrome.title = panelClippedText(value, word, WRUN_PANEL_MAX_TITLE_CHARS, at, clipped);
734
777
  break;
735
778
  case 'caption':
736
- chrome.caption = panelText(value, word, WRUN_PANEL_MAX_CAPTION_CHARS, at, [word]);
779
+ chrome.caption = panelClippedText(value, word, WRUN_PANEL_MAX_CAPTION_CHARS, at, clipped);
737
780
  break;
738
781
  case 'badge':
739
782
  chrome.badge = panelBadge(value, at);
@@ -762,8 +805,13 @@ export function parseWrunPanelChrome(frame, declaration, slot) {
762
805
  chrome.summary = panelSummary(value, at);
763
806
  break;
764
807
  case 'hole_text':
808
+ chrome.hole_text = panelText(value, word, WRUN_PANEL_MAX_LABEL_CHARS, at, [word]);
809
+ break;
765
810
  case 'hole_caption':
766
- chrome[word] = panelText(value, word, WRUN_PANEL_MAX_LABEL_CHARS, at, [word]);
811
+ chrome.hole_caption = panelClippedText(value, word, WRUN_PANEL_MAX_LABEL_CHARS, at, clipped);
812
+ break;
813
+ case 'x_labels':
814
+ chrome.x_labels = panelXLabels(value, at);
767
815
  break;
768
816
  case 'markets': {
769
817
  // The entries here; their count against the rows once the rows parsed (parseWrunPanelFrame).
@@ -782,10 +830,12 @@ export function parseWrunPanelChrome(frame, declaration, slot) {
782
830
  /** Parses a panel frame: `rows` through the receive-lane validator (one row
783
831
  * grammar on both lanes; the wrun lane carries the declaration's style
784
832
  * words) plus the kind's chrome keys through {@link parseWrunPanelChrome},
785
- * returned as `ParsedPanel.chrome` when the frame carries any. */
833
+ * returned as `ParsedPanel.chrome` when the frame carries any, and the
834
+ * notices of a legend text drawn clipped as `notices` when there are any. */
786
835
  export function parseWrunPanelFrame(raw, slot, declaration) {
787
836
  const frame = decodeFrame(raw, slot);
788
- const chrome = parseWrunPanelChrome(frame, declaration, slot);
837
+ const notices = [];
838
+ const chrome = parseWrunPanelChrome(frame, declaration, slot, notices);
789
839
  if (!('rows' in frame))
790
840
  refuser(slot)(['rows'], 'a panel frame must be an object with rows');
791
841
  const { name: _name, frame: _frame, ...panel } = declaration;
@@ -808,7 +858,20 @@ export function parseWrunPanelFrame(raw, slot, declaration) {
808
858
  if (chrome.markets !== undefined && chrome.markets.length !== result.data.rows.length) {
809
859
  refuser(slot)(['markets'], wrunRowMarketsLengthMessage('row', result.data.rows.length));
810
860
  }
811
- return Object.keys(chrome).length > 0 ? { ...result.data, chrome } : result.data;
861
+ if (chrome.x_labels !== undefined && chrome.x_labels.length !== result.data.rows.length) {
862
+ refuser(slot)(['x_labels'], xLabelsRowsMessage(result.data.rows.length));
863
+ }
864
+ const parsed = Object.keys(chrome).length > 0 ? { ...result.data, chrome } : result.data;
865
+ return notices.length > 0 ? { ...parsed, notices } : parsed;
866
+ }
867
+ /** A parsed panel frame's notices (a legend text drawn clipped to its cap), a
868
+ * fresh array, empty when the frame drew as written: the panel's share of a
869
+ * run result's `notices`, the warning rows the Indicator's legend shows. It
870
+ * takes the `ParsedPanel` a panel child carries; the lines ride the object
871
+ * parseWrunPanelFrame returned. */
872
+ export function wrunPanelFrameNotices(frame) {
873
+ const { notices } = frame;
874
+ return notices !== undefined ? [...notices] : [];
812
875
  }
813
876
  // ---------------------------------------------------------------------------
814
877
  // Ladder and feed frames (g3 DW15, DW38)
@@ -37,7 +37,13 @@ export interface WrunHostedRunLevel {
37
37
  /** The reply's OPRA mark (UW-PARITY contract opra-server-lanes 10b): true when the run's plan reads OPRA, on every
38
38
  * frame of such a run. Only the JSON boolean `true` counts; anything else reads as absent. */
39
39
  wrunOpra?: true;
40
+ /** The receipt of the OPRA rows the frame was computed from (contract opra-server-lanes C4): the tier the gate
41
+ * served (`wrunOpraTier`, `realtime` or `delayed`), read only beside the mark; any other word reads as absent. */
42
+ wrunOpraTier?: 'realtime' | 'delayed';
43
+ /** That tier's delay in seconds (`wrunOpraDelaySeconds`, a finite number from 0), read only beside a tier. */
44
+ wrunOpraDelaySeconds?: number;
40
45
  }
41
46
  /** Read a reply's run-level keys beside the wire: each own key exactly as the reply carries it (the OPRA mark only as
42
- * the boolean `true`), never a key inside `wrunHost`. A reply that is not a record carries none. */
47
+ * the boolean `true`, its receipt only beside it), never a key inside `wrunHost`. A reply that is not a record
48
+ * carries none. */
43
49
  export declare function readWrunHostedRunLevel(output: unknown): WrunHostedRunLevel;
@@ -7,7 +7,8 @@ export async function readWrunHostedWire(output) {
7
7
  return decodeWrunHostedWire(output);
8
8
  }
9
9
  /** Read a reply's run-level keys beside the wire: each own key exactly as the reply carries it (the OPRA mark only as
10
- * the boolean `true`), never a key inside `wrunHost`. A reply that is not a record carries none. */
10
+ * the boolean `true`, its receipt only beside it), never a key inside `wrunHost`. A reply that is not a record
11
+ * carries none. */
11
12
  export function readWrunHostedRunLevel(output) {
12
13
  if (!isRecord(output))
13
14
  return {};
@@ -20,8 +21,17 @@ export function readWrunHostedRunLevel(output) {
20
21
  if (Object.hasOwn(output, 'wrunServedLegs') && output.wrunServedLegs !== undefined) {
21
22
  level.wrunServedLegs = output.wrunServedLegs;
22
23
  }
23
- if (Object.hasOwn(output, 'wrunOpra') && output.wrunOpra === true)
24
+ if (Object.hasOwn(output, 'wrunOpra') && output.wrunOpra === true) {
24
25
  level.wrunOpra = true;
26
+ // The frame's receipt rides the mark alone: a tier without the mark names rows the run never read.
27
+ const tier = Object.hasOwn(output, 'wrunOpraTier') ? output.wrunOpraTier : undefined;
28
+ if (tier === 'realtime' || tier === 'delayed') {
29
+ level.wrunOpraTier = tier;
30
+ const delay = Object.hasOwn(output, 'wrunOpraDelaySeconds') ? output.wrunOpraDelaySeconds : undefined;
31
+ if (typeof delay === 'number' && Number.isFinite(delay) && delay >= 0)
32
+ level.wrunOpraDelaySeconds = delay;
33
+ }
34
+ }
25
35
  return level;
26
36
  }
27
37
  function isRecord(value) {
@@ -138,18 +138,32 @@ export interface WrunHudLookRow {
138
138
  /** The `window` chrome's two-colour title bar. */
139
139
  windowBar?: [string, string];
140
140
  texture: WrunHudTexture;
141
- /** A home look keeps its paper in both themes; an adaptive one resolves
142
- * tokens per theme and may name a light variant. A home look may name one
143
- * too, to keep its paper legible over a light chart (cockpit: the same
144
- * slate, opaque, with stronger labels). */
141
+ /** A home look keeps its own paper (its colours are the look's, never the
142
+ * app theme's); an adaptive one resolves tokens per theme and may name a
143
+ * light variant. A home look whose paper is dark names one too: over a
144
+ * light chart it wears that light paper, ink, rules and accent instead of
145
+ * sitting black on the chart (OPRA QA 2026-10-22: the inline paper beats
146
+ * the light rule of the stylesheet, which covers the default look alone;
147
+ * wrun-hud-looks.util.spec.ts fails a dark home row without one). A light
148
+ * paper needs none: it reads on both charts. Cockpit's variant keeps its
149
+ * slate on purpose (opaque, with stronger labels: template QA C17). */
145
150
  home: boolean;
151
+ /** What the look wears over a light chart, each word in place of the row's own. */
146
152
  light?: {
147
153
  background?: string;
154
+ /** A vertical gradient's stops (stage's wash). */
155
+ backgroundGradient?: string[];
148
156
  borderColor?: string;
149
157
  textColor?: string;
158
+ /** The label ink (terminal's amber labels go a dark amber on white). */
159
+ labelTextColor?: string;
160
+ /** The accent: a bright accent made for a dark paper reads too faint on a light one. */
161
+ accentColor?: string;
150
162
  /** The tiles' label opacity (`--wrun-hud-label-opacity`, 0.55 when absent);
151
163
  * at least WRUN_HUD_LIGHT_LABEL_OPACITY_MIN. */
152
164
  labelOpacity?: number;
165
+ /** The text halo: a glow is a dark paper's effect and smudges the glyphs on a light one. */
166
+ textGlow?: number;
153
167
  };
154
168
  }
155
169
  /** The frozen look table (g3 addendum, "The look table"). `default` is the
@@ -148,6 +148,14 @@ export const WRUN_HUD_LOOK_TABLE = {
148
148
  chrome: 'cover',
149
149
  texture: 'none',
150
150
  home: true,
151
+ /** Over a light chart the green wash fades into a light paper, the type goes ink (15:1) and the green
152
+ * deepens so the 30 px headline still reads (3.8:1 on the wash, 4.4:1 on the paper). */
153
+ light: {
154
+ backgroundGradient: ['#d3eedd', '#eaf6ee', '#f6f6f6', '#f6f6f6'],
155
+ textColor: '#121212',
156
+ accentColor: '#13853d',
157
+ labelOpacity: 0.75,
158
+ },
151
159
  },
152
160
  signal: {
153
161
  background: '#000000',
@@ -164,6 +172,8 @@ export const WRUN_HUD_LOOK_TABLE = {
164
172
  chrome: 'card',
165
173
  texture: 'none',
166
174
  home: true,
175
+ /** Over a light chart the same slab in white: black type, a hairline edge (labels at 0.55 read 4.8:1). */
176
+ light: { background: '#ffffff', borderColor: '#e3e3e3', textColor: '#000000' },
167
177
  },
168
178
  terminal: {
169
179
  background: '#000000',
@@ -182,6 +192,17 @@ export const WRUN_HUD_LOOK_TABLE = {
182
192
  titleBarInk: '#000000',
183
193
  texture: 'none',
184
194
  home: true,
195
+ /** Over a light chart (the OPRA cards, QA 2026-10-22): white paper, black type, a grey frame, the labels a
196
+ * dark amber at 0.8 (4.7:1), and the title bar a deeper amber that still takes its black ink (6.1:1) and
197
+ * inks the headline at 3.4:1 (bold 22 px). */
198
+ light: {
199
+ background: '#ffffff',
200
+ borderColor: '#b8b8b8',
201
+ textColor: '#000000',
202
+ labelTextColor: '#7a4700',
203
+ accentColor: '#c77800',
204
+ labelOpacity: 0.8,
205
+ },
185
206
  },
186
207
  broadsheet: {
187
208
  background: '#F6F1E7',
@@ -275,6 +296,9 @@ export const WRUN_HUD_LOOK_TABLE = {
275
296
  chrome: 'none',
276
297
  texture: 'scanlines',
277
298
  home: true,
299
+ /** Over a light chart a pale green paper with the phosphor printed in a deep green (7.4:1), labels at 0.8
300
+ * (4.6:1), no glow; the scanlines stay. */
301
+ light: { background: '#eef7f0', textColor: '#0b5d27', accentColor: '#0b5d27', labelOpacity: 0.8, textGlow: 0 },
278
302
  },
279
303
  classic: {
280
304
  background: '#C0C0C0',
@@ -353,8 +377,9 @@ export function wrunHudPointerFree(style) {
353
377
  return style.opacity !== undefined && style.opacity < WRUN_HUD_POINTER_FREE_OPACITY;
354
378
  }
355
379
  /** The card's background: a declared colour (at its declared opacity), a
356
- * declared gradient, else the look's; a declared opacity alone dims today's
357
- * surface. Undefined keeps today's rule. */
380
+ * declared gradient, else the look's (its light variant's paper over a light
381
+ * chart); a declared opacity alone dims today's surface. Undefined keeps
382
+ * today's rule. */
358
383
  function backgroundCss(entry, row, light, theme) {
359
384
  const direction = entry.gradient_direction === 'horizontal' ? 'to right' : 'to bottom';
360
385
  const gradient = Array.isArray(entry.background_gradient)
@@ -364,14 +389,16 @@ function backgroundCss(entry, row, light, theme) {
364
389
  return `linear-gradient(${direction}, ${gradient.map((stop) => paint(stop, theme)).join(', ')})`;
365
390
  }
366
391
  const opacity = numberIn(entry.background_opacity, 0, 1);
367
- const lookBackground = light && row.light?.background !== undefined ? row.light.background : row.background;
392
+ const variant = light ? row.light : undefined;
393
+ const lookBackground = variant?.background ?? row.background;
368
394
  const color = colorWord(entry.background_color) ?? lookBackground;
369
395
  if (color !== undefined) {
370
396
  const painted = paint(color, theme);
371
397
  return opacity === undefined ? painted : withShare(painted, opacity);
372
398
  }
373
- if (row.backgroundGradient !== undefined && row.backgroundGradient.length >= 2) {
374
- return `linear-gradient(to bottom, ${row.backgroundGradient.map((stop) => paint(stop, theme)).join(', ')})`;
399
+ const lookGradient = variant?.backgroundGradient ?? row.backgroundGradient;
400
+ if (lookGradient !== undefined && lookGradient.length >= 2) {
401
+ return `linear-gradient(to bottom, ${lookGradient.map((stop) => paint(stop, theme)).join(', ')})`;
375
402
  }
376
403
  if (opacity !== undefined)
377
404
  return `color-mix(in srgb, var(--tooltip-bg, #17171c) ${Math.round(opacity * 100)}%, transparent)`;
@@ -391,13 +418,15 @@ export function resolveWrunHudLook(entry, options = {}) {
391
418
  const look = viewerPick ?? authorLook ?? 'default';
392
419
  const row = WRUN_HUD_LOOK_TABLE[look];
393
420
  const light = options.light === true;
421
+ // Over a light chart the look's light variant stands in for its paper, ink, rules and accent word by word; on a
422
+ // dark chart there is none, so every word below reads the row as it always did.
423
+ const variant = light ? row.light : undefined;
394
424
  const css = {};
395
425
  // Surface
396
426
  const background = backgroundCss(entry, row, light, theme);
397
427
  if (background !== undefined)
398
428
  css['--wrun-hud-bg'] = background;
399
- const borderColor = colorWord(entry.border_color) ??
400
- (light && row.light?.borderColor !== undefined ? row.light.borderColor : row.borderColor);
429
+ const borderColor = colorWord(entry.border_color) ?? variant?.borderColor ?? row.borderColor;
401
430
  if (borderColor !== undefined)
402
431
  css['--wrun-hud-border-color'] = paint(borderColor, theme);
403
432
  const borderWidth = numberIn(entry.border_width, 0, WRUN_MAX_HUD_BORDER_WIDTH_PX) ?? row.borderWidth;
@@ -435,14 +464,15 @@ export function resolveWrunHudLook(entry, options = {}) {
435
464
  // A look with its own ink prints its title, labels and tracks in it (the
436
465
  // app's muted and secondary inks belong to the app theme, not the paper);
437
466
  // a declared text_color recolours the text alone (DW22).
438
- const lookTextColor = light && row.light?.textColor !== undefined ? row.light.textColor : row.textColor;
467
+ const lookTextColor = variant?.textColor ?? row.textColor;
439
468
  const lookInk = lookTextColor === undefined ? undefined : paint(lookTextColor, theme);
440
469
  if (lookInk !== undefined) {
441
470
  css['--wrun-hud-title-ink'] = lookInk;
442
- css['--wrun-hud-label-ink'] = row.labelTextColor === undefined ? lookInk : paint(row.labelTextColor, theme);
471
+ const labelTextColor = variant?.labelTextColor ?? row.labelTextColor;
472
+ css['--wrun-hud-label-ink'] = labelTextColor === undefined ? lookInk : paint(labelTextColor, theme);
443
473
  css['--wrun-hud-track'] = withShare(lookInk, 0.15);
444
474
  }
445
- const labelOpacity = light ? row.light?.labelOpacity : undefined;
475
+ const labelOpacity = variant?.labelOpacity;
446
476
  if (labelOpacity !== undefined)
447
477
  css['--wrun-hud-label-opacity'] = String(labelOpacity);
448
478
  const declaredInk = colorWord(entry.text_color);
@@ -457,13 +487,15 @@ export function resolveWrunHudLook(entry, options = {}) {
457
487
  const headlineWeight = wrunFontWeightCss(row.headlineFontWeight);
458
488
  if (headlineWeight !== undefined)
459
489
  css['--wrun-hud-headline-weight'] = String(headlineWeight);
460
- const textGlow = numberIn(entry.text_glow, 0, WRUN_MAX_HUD_TEXT_GLOW_PX) ?? row.textGlow ?? 0;
490
+ const textGlow = numberIn(entry.text_glow, 0, WRUN_MAX_HUD_TEXT_GLOW_PX) ?? variant?.textGlow ?? row.textGlow ?? 0;
461
491
  if (textGlow > 0)
462
492
  css['--wrun-hud-glow'] = `0 0 ${textGlow}px currentColor`;
463
- // Accent (LK03): a declared colour, the ladder's rung, the look's, else the
464
- // theme's for any look but `default` (whose marks ink in the text colour).
493
+ // Accent (LK03): a declared colour, the ladder's rung, the look's (its light
494
+ // variant's over a light chart), else the theme's for any look but `default`
495
+ // (whose marks ink in the text colour).
465
496
  const accentWord = colorWord(entry.accent_color) ??
466
497
  accentRung(entry, options.snapshot) ??
498
+ variant?.accentColor ??
467
499
  row.accentColor ??
468
500
  (look !== 'default' || entry.accent_color_by !== undefined ? 'theme.accent' : undefined);
469
501
  const accent = accentWord === undefined ? undefined : paint(accentWord, theme);