@orangecharts/wrun-chart-host 0.6.0 → 0.7.1

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 (142) hide show
  1. package/README.md +14 -5
  2. package/dist/constants/marketCapabilities.constants.d.ts +5 -0
  3. package/dist/constants/marketCapabilities.constants.js +16 -0
  4. package/dist/host-ports.types.d.ts +35 -3
  5. package/dist/index.d.ts +11 -1
  6. package/dist/index.js +11 -1
  7. package/dist/indicators/controls/tpo-session.util.js +42 -18
  8. package/dist/market-data/billing.interface.d.ts +2 -1
  9. package/dist/settings-templates/index.d.ts +2 -0
  10. package/dist/settings-templates/index.js +19 -5
  11. package/dist/settings-templates/indicator-fields.d.ts +2 -0
  12. package/dist/settings-templates/indicator-fields.js +10 -0
  13. package/dist/settings-templates/tool-rules.d.ts +12 -2
  14. package/dist/settings-templates/tool-rules.js +9 -2
  15. package/dist/settings-templates/tool-tables.generated.js +9 -0
  16. package/dist/utility/chart/crypto-index.leaf.d.ts +16 -0
  17. package/dist/utility/chart/crypto-index.leaf.js +19 -0
  18. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  19. package/dist/utility/chart/index-mode.util.d.ts +11 -5
  20. package/dist/utility/chart/index-mode.util.js +22 -10
  21. package/dist/utility/chart/kscript-source-answer-budget.leaf.d.ts +36 -0
  22. package/dist/utility/chart/kscript-source-answer-budget.leaf.js +39 -0
  23. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +38 -1
  24. package/dist/utility/chart/kscript-source-degrade.leaf.js +39 -1
  25. package/dist/utility/chart/live-bucket.util.d.ts +2 -1
  26. package/dist/utility/chart/live-bucket.util.js +47 -15
  27. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +15 -1
  28. package/dist/utility/chart/local-kscript-warmup-depth.util.js +9 -0
  29. package/dist/utility/chart/market-session-schedule.util.d.ts +3 -1
  30. package/dist/utility/chart/market-session-schedule.util.js +24 -2
  31. package/dist/utility/chart/marketKind.util.d.ts +12 -7
  32. package/dist/utility/chart/marketKind.util.js +15 -5
  33. package/dist/utility/chart/ny-calendar.util.d.ts +104 -0
  34. package/dist/utility/chart/ny-calendar.util.js +346 -0
  35. package/dist/utility/chart/om-panel.util.d.ts +14 -2
  36. package/dist/utility/chart/om-panel.util.js +108 -40
  37. package/dist/utility/chart/rth-session.util.d.ts +10 -7
  38. package/dist/utility/chart/rth-session.util.js +17 -22
  39. package/dist/utility/chart/trading-day.util.js +90 -18
  40. package/dist/utility/chart/us-equities-session.util.js +20 -67
  41. package/dist/utility/chart/wrun-bar-session-facts.util.js +14 -1
  42. package/dist/utility/common/time.util.d.ts +7 -1
  43. package/dist/utility/common/time.util.js +11 -41
  44. package/dist/utility/number-format.util.d.ts +17 -7
  45. package/dist/utility/number-format.util.js +18 -8
  46. package/dist/utility/options/option-symbol.util.js +13 -2
  47. package/dist/utility/symbol-selection/contract-expiry.util.js +9 -1
  48. package/dist/utility/watchlist/import/import-request.leaf.d.ts +4 -1
  49. package/dist/utility/watchlist/import/import-request.leaf.js +5 -2
  50. package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +25 -4
  51. package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +62 -4
  52. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +19 -0
  53. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +57 -0
  54. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +23 -0
  55. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +90 -0
  56. package/dist/utility/wrun/run-schedule/wrun-lane-groups.util.d.ts +39 -0
  57. package/dist/utility/wrun/run-schedule/wrun-lane-groups.util.js +60 -0
  58. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +77 -0
  59. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +195 -0
  60. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +56 -0
  61. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +70 -0
  62. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +53 -0
  63. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +239 -0
  64. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +16 -0
  65. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +14 -0
  66. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +43 -18
  67. package/dist/utility/wrun/sources/lanes/options_flow.js +209 -72
  68. package/dist/utility/wrun/sources/lanes/token_supply.js +5 -31
  69. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -18
  70. package/dist/utility/wrun/sources/opra-option-lanes.util.js +12 -57
  71. package/dist/utility/wrun/sources/row-lane-registry.d.ts +1 -1
  72. package/dist/utility/wrun/sources/row-lane-registry.js +22 -8
  73. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +61 -0
  74. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +103 -8
  75. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +5 -0
  76. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +24 -12
  77. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +55 -0
  78. package/dist/utility/wrun/sources/row-lanes/option_prints.js +95 -18
  79. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +15 -1
  80. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +23 -8
  81. package/dist/utility/wrun/sources/row-lanes/option_surface.js +11 -11
  82. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +14 -2
  83. package/dist/utility/wrun/sources/wrun-poll-lane.types.js +6 -3
  84. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +43 -8
  85. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +77 -11
  86. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -16
  87. package/dist/utility/wrun/sources/wrun-row-lane.types.js +2 -0
  88. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +52 -12
  89. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +110 -46
  90. package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +10 -0
  91. package/dist/utility/wrun/wrun-browser-sources.leaf.js +12 -0
  92. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +3 -3
  93. package/dist/utility/wrun/wrun-coin-lane-live.util.js +53 -18
  94. package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -0
  95. package/dist/utility/wrun/wrun-color-settings.util.js +45 -0
  96. package/dist/utility/wrun/wrun-draft-overlay.util.js +14 -8
  97. package/dist/utility/wrun/wrun-failure-cause.d.ts +1 -1
  98. package/dist/utility/wrun/wrun-failure-cause.js +14 -0
  99. package/dist/utility/wrun/wrun-frames.js +6 -2
  100. package/dist/utility/wrun/wrun-host.service.d.ts +26 -18
  101. package/dist/utility/wrun/wrun-host.service.js +49 -52
  102. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +1 -1
  103. package/dist/utility/wrun/wrun-hosted-wire-caps.js +2 -0
  104. package/dist/utility/wrun/wrun-input-requirements.leaf.js +7 -4
  105. package/dist/utility/wrun/wrun-kit-run-tables.util.d.ts +24 -0
  106. package/dist/utility/wrun/wrun-kit-run-tables.util.js +87 -0
  107. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +2 -1
  108. package/dist/utility/wrun/wrun-live-tick.util.d.ts +8 -2
  109. package/dist/utility/wrun/wrun-live-tick.util.js +35 -16
  110. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +40 -13
  111. package/dist/utility/wrun/wrun-opra-flow.leaf.js +39 -12
  112. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +70 -21
  113. package/dist/utility/wrun/wrun-option-contract-flow.util.js +257 -112
  114. package/dist/utility/wrun/wrun-option-prints.util.d.ts +62 -22
  115. package/dist/utility/wrun/wrun-option-prints.util.js +148 -46
  116. package/dist/utility/wrun/wrun-option-views.util.d.ts +262 -0
  117. package/dist/utility/wrun/wrun-option-views.util.js +356 -0
  118. package/dist/utility/wrun/wrun-options-chain.util.d.ts +23 -2
  119. package/dist/utility/wrun/wrun-options-chain.util.js +37 -3
  120. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +18 -3
  121. package/dist/utility/wrun/wrun-overlay-drivers.util.js +32 -7
  122. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +9 -3
  123. package/dist/utility/wrun/wrun-overlay-recovery.util.js +146 -18
  124. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +50 -6
  125. package/dist/utility/wrun/wrun-overlay-run.util.js +816 -243
  126. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +5 -0
  127. package/dist/utility/wrun/wrun-pin-spelling.util.js +28 -12
  128. package/dist/utility/wrun/wrun-pin-venues.util.js +4 -6
  129. package/dist/utility/wrun/wrun-present-bits.util.d.ts +9 -0
  130. package/dist/utility/wrun/wrun-present-bits.util.js +39 -0
  131. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +3 -2
  132. package/dist/utility/wrun/wrun-refusal-surface.util.js +5 -4
  133. package/dist/utility/wrun/wrun-refusal.util.d.ts +66 -6
  134. package/dist/utility/wrun/wrun-refusal.util.js +335 -40
  135. package/dist/utility/wrun/wrun-source-rows.util.js +11 -0
  136. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +28 -3
  137. package/dist/utility/wrun/wrun-tier-grid.util.js +79 -19
  138. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +14 -3
  139. package/dist/utility/wrun/wrun-transient-rerun.util.js +33 -8
  140. package/package.json +5 -5
  141. package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +0 -12
  142. package/dist/utility/wrun/wrun-opra-underlying.util.js +0 -1
@@ -5,6 +5,7 @@ import Timezone from 'dayjs/plugin/timezone.js';
5
5
  import IsoWeek from 'dayjs/plugin/isoWeek.js';
6
6
  import QuarterOfYear from 'dayjs/plugin/quarterOfYear.js';
7
7
  import { Intervals } from '../../constants/interval.constants.js';
8
+ import { nyMarketPhaseAt } from '../chart/ny-calendar.util.js';
8
9
  dayjs.extend(Utc);
9
10
  dayjs.extend(Timezone);
10
11
  dayjs.extend(IsoWeek);
@@ -260,53 +261,22 @@ export const calculatePollingPeriod = (interval, numberOfCandles = 2) => {
260
261
  export const isPollingFetchPayload = (payload) => payload?.isPolling === true ||
261
262
  (payload?.from === 0 && payload?.period === calculatePollingPeriod(payload?.interval ?? payload?.tf ?? ''));
262
263
  /**
263
- * US Market hours constants (in US/Eastern timezone)
264
- * Regular trading: 9:30 AM - 4:00 PM ET
265
- * Pre-market: 4:00 AM - 9:30 AM ET
266
- * After-hours: 4:00 PM - 8:00 PM ET
267
- */
268
- const US_MARKET_HOURS = {
269
- PRE_MARKET_START: { hour: 4, minute: 0 }, // 4:00 AM ET
270
- REGULAR_START: { hour: 9, minute: 30 }, // 9:30 AM ET
271
- REGULAR_END: { hour: 16, minute: 0 }, // 4:00 PM ET
272
- AFTER_HOURS_END: { hour: 20, minute: 0 }, // 8:00 PM ET
273
- };
274
- /**
275
- * Check if a given timestamp is within regular US market hours (9:30 AM - 4:00 PM ET)
264
+ * Check if a given timestamp is within regular US market hours (9:30 AM - 4:00 PM ET), on the
265
+ * weekday cycle in New York time: pre-market 4:00 AM - 9:30 AM, after-hours 4:00 PM - 8:00 PM,
266
+ * closed otherwise and all weekend (holidays are not modelled).
267
+ *
268
+ * Per-row callers (every landed stock bar) pay integer compares: the New York calendar
269
+ * (ny-calendar.util) resolves each date's session edges once. A non-number input keeps its old
270
+ * dayjs reading (`undefined` is now, a Date or a date string is its instant).
276
271
  * @param timestampMs - Timestamp in milliseconds
277
272
  * @returns Object containing:
278
273
  * - isRegularHours: true if within regular hours (9:30 AM - 4:00 PM ET)
279
274
  * - sessionType: 'pre' | 'regular' | 'after' | 'closed'
280
275
  */
281
276
  export function checkUSMarketHours(timestampMs) {
282
- // Convert timestamp to US/Eastern timezone
283
- const etTime = dayjs(timestampMs).tz('America/New_York');
284
- const dayOfWeek = etTime.day(); // 0 = Sunday, 6 = Saturday
285
- // Check if it's a weekend
286
- if (dayOfWeek === 0 || dayOfWeek === 6) {
287
- return { isRegularHours: false, sessionType: 'closed' };
288
- }
289
- const hour = etTime.hour();
290
- const minute = etTime.minute();
291
- const timeInMinutes = hour * 60 + minute;
292
- // Calculate time boundaries in minutes since midnight
293
- const preMarketStart = US_MARKET_HOURS.PRE_MARKET_START.hour * 60 + US_MARKET_HOURS.PRE_MARKET_START.minute;
294
- const regularStart = US_MARKET_HOURS.REGULAR_START.hour * 60 + US_MARKET_HOURS.REGULAR_START.minute;
295
- const regularEnd = US_MARKET_HOURS.REGULAR_END.hour * 60 + US_MARKET_HOURS.REGULAR_END.minute;
296
- const afterHoursEnd = US_MARKET_HOURS.AFTER_HOURS_END.hour * 60 + US_MARKET_HOURS.AFTER_HOURS_END.minute;
297
- // Determine session type
298
- if (timeInMinutes >= regularStart && timeInMinutes < regularEnd) {
299
- return { isRegularHours: true, sessionType: 'regular' };
300
- }
301
- else if (timeInMinutes >= preMarketStart && timeInMinutes < regularStart) {
302
- return { isRegularHours: false, sessionType: 'pre' };
303
- }
304
- else if (timeInMinutes >= regularEnd && timeInMinutes < afterHoursEnd) {
305
- return { isRegularHours: false, sessionType: 'after' };
306
- }
307
- else {
308
- return { isRegularHours: false, sessionType: 'closed' };
309
- }
277
+ const tsMs = typeof timestampMs === 'number' ? timestampMs : dayjs(timestampMs).valueOf();
278
+ const sessionType = nyMarketPhaseAt(tsMs);
279
+ return { isRegularHours: sessionType === 'regular', sessionType };
310
280
  }
311
281
  // ─── ET calendar helpers ─────────────────────────────────────────────────
312
282
  // Used for anything that needs to reason about "the current ET calendar day"
@@ -57,12 +57,17 @@ export declare function changeNumberFormat(value: number, precision: number): st
57
57
  export declare function formatAdaptiveVolume(value: number): string;
58
58
  export declare function safeDivide(a: number, b: number): number;
59
59
  /**
60
- * The price text the ticker surfaces print: the desktop ticker bar, the
61
- * orderbook ticker, and the mobile header, legend and stats, so one symbol
62
- * reads the same number on every one of them. The decimals come from the
63
- * price's own magnitude, because the FE holds no per-symbol tick size and the
64
- * chart's axis precision moves with every zoom. `reference` is the price a
65
- * difference belongs to: a 24h change prints at its price's resolution.
60
+ * The ticker's digits for a trade price, so one symbol reads the same number on
61
+ * every ticker surface. The decimals come from the price's own magnitude,
62
+ * because the FE holds no per-symbol tick size and the chart's axis precision
63
+ * moves with every zoom. `reference` is the price a difference belongs to: a
64
+ * 24h change prints at its price's resolution.
65
+ *
66
+ * Venue-blind: every value reads as a trade price. A surface that prints a
67
+ * market's figure asks the web's market-aware text
68
+ * (`src/utility/chart/market-price-text.util.ts`), which falls back to this for
69
+ * a plain price; through this ladder a crypto index market cap printed all
70
+ * thirteen digits.
66
71
  */
67
72
  export declare function formatPriceByMagnitude(value: number, reference?: number): string;
68
73
  export declare function titlePriceDirection(curr: unknown, prev: unknown, lastGlyph?: string): string;
@@ -74,8 +79,13 @@ export declare function titlePriceDirection(curr: unknown, prev: unknown, lastGl
74
79
  * ratio to "1.00". Negative values (spread formulas) keep the magnitude rule.
75
80
  */
76
81
  export declare function formatTitlePrice(price: number): string;
82
+ /**
83
+ * The tab title's price and its direction glyph, kept per chart and per market. `formatPrice` prints the price
84
+ * (default `formatTitlePrice`, venue-blind): the web passes its market-aware text
85
+ * (`src/utility/chart/market-price-text.util.ts`), so a crypto index reads in its own unit (`$1.08T ▲`).
86
+ */
77
87
  export declare function formatChartTitlePrice(price: number, tc: TitleChart, context: {
78
88
  symbolKey: string;
79
89
  previousPrice?: number;
80
- }): string;
90
+ }, formatPrice?: (price: number) => string): string;
81
91
  export {};
@@ -164,12 +164,17 @@ export function safeDivide(a, b) {
164
164
  const TICKER_MIN_SIGNIFICANT_DIGITS = 3;
165
165
  const MAX_TICKER_DECIMALS = 20;
166
166
  /**
167
- * The price text the ticker surfaces print: the desktop ticker bar, the
168
- * orderbook ticker, and the mobile header, legend and stats, so one symbol
169
- * reads the same number on every one of them. The decimals come from the
170
- * price's own magnitude, because the FE holds no per-symbol tick size and the
171
- * chart's axis precision moves with every zoom. `reference` is the price a
172
- * difference belongs to: a 24h change prints at its price's resolution.
167
+ * The ticker's digits for a trade price, so one symbol reads the same number on
168
+ * every ticker surface. The decimals come from the price's own magnitude,
169
+ * because the FE holds no per-symbol tick size and the chart's axis precision
170
+ * moves with every zoom. `reference` is the price a difference belongs to: a
171
+ * 24h change prints at its price's resolution.
172
+ *
173
+ * Venue-blind: every value reads as a trade price. A surface that prints a
174
+ * market's figure asks the web's market-aware text
175
+ * (`src/utility/chart/market-price-text.util.ts`), which falls back to this for
176
+ * a plain price; through this ladder a crypto index market cap printed all
177
+ * thirteen digits.
173
178
  */
174
179
  export function formatPriceByMagnitude(value, reference = value) {
175
180
  const ladder = value >= 10000 ? 1 : value >= 1000 ? 2 : value >= 100 ? 3 : value >= 10 ? 4 : 5;
@@ -209,11 +214,16 @@ export function formatTitlePrice(price) {
209
214
  }
210
215
  // Keyed by the chart instance so a destroyed chart takes its entry with it (no retainer).
211
216
  const titlePricesByChart = new WeakMap();
212
- export function formatChartTitlePrice(price, tc, context) {
217
+ /**
218
+ * The tab title's price and its direction glyph, kept per chart and per market. `formatPrice` prints the price
219
+ * (default `formatTitlePrice`, venue-blind): the web passes its market-aware text
220
+ * (`src/utility/chart/market-price-text.util.ts`), so a crypto index reads in its own unit (`$1.08T ▲`).
221
+ */
222
+ export function formatChartTitlePrice(price, tc, context, formatPrice = formatTitlePrice) {
213
223
  const stored = titlePricesByChart.get(tc);
214
224
  const previous = stored?.symbolKey === context.symbolKey ? stored : undefined;
215
225
  const glyph = titlePriceDirection(price, previous ? previous.price : context.previousPrice, previous?.glyph);
216
226
  titlePricesByChart.set(tc, { symbolKey: context.symbolKey, price, glyph });
217
- const formattedPrice = formatTitlePrice(price);
227
+ const formattedPrice = formatPrice(price);
218
228
  return glyph ? `${formattedPrice} ${glyph}` : formattedPrice;
219
229
  }
@@ -1,3 +1,4 @@
1
+ import { zoneWallMsAt } from '../chart/ny-calendar.util.js';
1
2
  import { contractExpiryEndMs, parseCmeContractExpiry } from '../symbol-selection/contract-expiry.util.js';
2
3
  const MONTHS = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'];
3
4
  // Same contract pattern `OptionChainService.resolveOptionContractSelection` reads, e.g. `ESU6 C5400`.
@@ -80,8 +81,8 @@ const NEW_YORK_PARTS = new Intl.DateTimeFormat('en-US', {
80
81
  hour: '2-digit',
81
82
  minute: '2-digit',
82
83
  });
83
- /** The New York wall clock of an instant, as a UTC-shaped epoch (minutes precision) for offset arithmetic. */
84
- function newYorkWallClockMs(instantMs) {
84
+ /** The New York wall clock read from Intl: for the instants the zone clock does not serve (it throws for a non-date). */
85
+ function readNewYorkWallClockMs(instantMs) {
85
86
  const read = {};
86
87
  for (const part of NEW_YORK_PARTS.formatToParts(new Date(instantMs))) {
87
88
  if (part.type !== 'literal')
@@ -89,6 +90,16 @@ function newYorkWallClockMs(instantMs) {
89
90
  }
90
91
  return Date.UTC(read.year, read.month - 1, read.day, read.hour, read.minute);
91
92
  }
93
+ const MINUTE_MS = 60_000;
94
+ /**
95
+ * The New York wall clock of an instant, as a UTC-shaped epoch (minutes precision) for offset
96
+ * arithmetic: one Intl reading per UTC day (the zone clock in ny-calendar.util), since the 0DTE
97
+ * filter asks it for every flow row.
98
+ */
99
+ function newYorkWallClockMs(instantMs) {
100
+ const wallMs = zoneWallMsAt(OSI_NEW_YORK, instantMs);
101
+ return Number.isNaN(wallMs) ? readNewYorkWallClockMs(instantMs) : Math.floor(wallMs / MINUTE_MS) * MINUTE_MS;
102
+ }
92
103
  /** The New York calendar day an instant falls on, in days since the epoch: the US options trade date. */
93
104
  export function newYorkDayNumber(instantMs) {
94
105
  return Math.floor(newYorkWallClockMs(instantMs) / 86_400_000);
@@ -51,13 +51,21 @@ export function isContractExpired(rawSymbol, now = new Date()) {
51
51
  return false;
52
52
  return contractExpiryEndMs(expiry) < now.getTime();
53
53
  }
54
+ /** One delivery-label formatter per date locale: the venue list labels every contract row with it. */
55
+ const deliveryFormatters = new Map();
54
56
  /** Localized delivery label, e.g. "Jul 2026" / "2026年7月". '' when undecodable. */
55
57
  export function formatContractExpiry(rawSymbol, locale, now = new Date()) {
56
58
  const expiry = parseCmeContractExpiry(rawSymbol, now);
57
59
  if (!expiry)
58
60
  return '';
59
61
  try {
60
- return new Intl.DateTimeFormat(getDateLocale(locale), { month: 'short', year: 'numeric', timeZone: 'UTC' }).format(new Date(Date.UTC(expiry.year, expiry.monthIndex, 15)));
62
+ const dateLocale = getDateLocale(locale);
63
+ let formatter = deliveryFormatters.get(dateLocale);
64
+ if (formatter === undefined) {
65
+ formatter = new Intl.DateTimeFormat(dateLocale, { month: 'short', year: 'numeric', timeZone: 'UTC' });
66
+ deliveryFormatters.set(dateLocale, formatter);
67
+ }
68
+ return formatter.format(new Date(Date.UTC(expiry.year, expiry.monthIndex, 15)));
61
69
  }
62
70
  catch {
63
71
  return '';
@@ -6,5 +6,8 @@
6
6
  * over a literal, never written (the phase 2 leaf-state guard's immutable form).
7
7
  */
8
8
  export declare const IMPORT_REQUEST_TIMEOUT_MS = 20000;
9
- /** The types the poll asks for: a priced row of any venue answers on one of them. */
9
+ /**
10
+ * The types the poll asks for: a priced row of any venue answers on one of them. A crypto index (CRYPTOCAP: BTC.D,
11
+ * TOTAL2) answers only on its candle type, so a `CRYPTOCAP:` entry and a pin on one are found by name too.
12
+ */
10
13
  export declare const IMPORT_MARKET_TYPES: readonly string[];
@@ -6,5 +6,8 @@
6
6
  * over a literal, never written (the phase 2 leaf-state guard's immutable form).
7
7
  */
8
8
  export const IMPORT_REQUEST_TIMEOUT_MS = 20_000;
9
- /** The types the poll asks for: a priced row of any venue answers on one of them. */
10
- export const IMPORT_MARKET_TYPES = ['TICKER_AGG', 'TRADE'];
9
+ /**
10
+ * The types the poll asks for: a priced row of any venue answers on one of them. A crypto index (CRYPTOCAP: BTC.D,
11
+ * TOTAL2) answers only on its candle type, so a `CRYPTOCAP:` entry and a pin on one are found by name too.
12
+ */
13
+ export const IMPORT_MARKET_TYPES = ['TICKER_AGG', 'TRADE', 'CRYPTO_DOMINANCE_AGG'];
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * The pure half of the TradingView list util (tradingview-list.util.ts, which re-exports every name): the prefix
3
3
  * tables (our native escape, the perpetual suffix, the US stock, forex, CME and crypto venues, TVC's spot metals, the
4
- * venue back to its TradingView prefix, the CME continuous roots, the ticker aliases) and the symbol parsers
5
- * (`cmeContinuousKeyOf`, `splitCryptoSymbol`, `cryptoCandidate`, `fxPair`). No imports: the wrun pin spelling step
6
- * (wrun-pin-spelling.util) reads them, and it moves into the wrun chart-host package, which the util's catalog and
7
- * legacy-venue reads may not reach.
4
+ * venue back to its TradingView prefix, the CME continuous roots, the ticker aliases, the CRYPTOCAP ticker renames)
5
+ * and the symbol parsers (`cmeContinuousKeyOf`, `splitCryptoSymbol`, `cryptoCandidate`, `fxPair`, `cryptoCapSeriesOf`).
6
+ * No imports: the wrun pin spelling step (wrun-pin-spelling.util) reads them, and it moves into the wrun chart-host
7
+ * package, which the util's catalog and legacy-venue reads may not reach.
8
8
  */
9
9
  /** Our native escape: `OPENMARKET:<full key>`, for markets TradingView has no name for. */
10
10
  export declare const NATIVE_PREFIX = "OPENMARKET";
@@ -74,3 +74,24 @@ export declare function cryptoCandidate(exchange: string, symbol: string): Marke
74
74
  export declare function fxPair(symbol: string): [string, string] | null;
75
75
  /** Tickers some venues spell their own way. */
76
76
  export declare const BASE_ALIASES: Readonly<Record<string, string>>;
77
+ /** TradingView's crypto index prefix, and our venue of the same series (docs/features/data/cryptocap-indices.md). */
78
+ export declare const CRYPTOCAP_PREFIX = "CRYPTOCAP";
79
+ /**
80
+ * The coins TradingView tickers its own way, TradingView's ticker to ours, for a coin's dominance (`HYPEH.D` is our
81
+ * `HYPE.D`) and its market cap (`HYPEH`, our `MCAP.HYPE`) alike. Matched 2026-10-21 by comparing TradingView's caps
82
+ * with CoinGecko's; every other coin shares its ticker. The watchlist import and the wrun pin spelling step both read
83
+ * this one table.
84
+ */
85
+ export declare const CRYPTOCAP_TICKER_RENAMES: Readonly<Record<string, string>>;
86
+ /**
87
+ * A TradingView `CRYPTOCAP:` symbol as our series: an index by its name (`TOTAL2`), a dominance by its coin's ticker
88
+ * (`BTC.D`; `HYPEH.D` is `HYPE.D`), a coin's market cap (`BTC`, TradingView's cap) as `MCAP.<TICKER>`. `proof` is the
89
+ * listed series that shows we carry it: the series itself, or, for a market cap (the catalog lists no `MCAP.*`
90
+ * series), the coin's dominance, listed for every coin the indices cover. Null for a symbol of no such shape.
91
+ */
92
+ export declare function cryptoCapSeriesOf(symbol: string): {
93
+ series: string;
94
+ proof: string;
95
+ } | null;
96
+ /** Our CRYPTOCAP series as TradingView spells it (`HYPE.D` is `HYPEH.D`, `MCAP.BTC` is `BTC`), null for no such one. */
97
+ export declare function tradingViewCryptoCapSymbol(series: string): string | null;
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * The pure half of the TradingView list util (tradingview-list.util.ts, which re-exports every name): the prefix
3
3
  * tables (our native escape, the perpetual suffix, the US stock, forex, CME and crypto venues, TVC's spot metals, the
4
- * venue back to its TradingView prefix, the CME continuous roots, the ticker aliases) and the symbol parsers
5
- * (`cmeContinuousKeyOf`, `splitCryptoSymbol`, `cryptoCandidate`, `fxPair`). No imports: the wrun pin spelling step
6
- * (wrun-pin-spelling.util) reads them, and it moves into the wrun chart-host package, which the util's catalog and
7
- * legacy-venue reads may not reach.
4
+ * venue back to its TradingView prefix, the CME continuous roots, the ticker aliases, the CRYPTOCAP ticker renames)
5
+ * and the symbol parsers (`cmeContinuousKeyOf`, `splitCryptoSymbol`, `cryptoCandidate`, `fxPair`, `cryptoCapSeriesOf`).
6
+ * No imports: the wrun pin spelling step (wrun-pin-spelling.util) reads them, and it moves into the wrun chart-host
7
+ * package, which the util's catalog and legacy-venue reads may not reach.
8
8
  */
9
9
  /** Our native escape: `OPENMARKET:<full key>`, for markets TradingView has no name for. */
10
10
  export const NATIVE_PREFIX = 'OPENMARKET';
@@ -219,3 +219,61 @@ export function fxPair(symbol) {
219
219
  }
220
220
  /** Tickers some venues spell their own way. */
221
221
  export const BASE_ALIASES = { XBT: 'BTC', XDG: 'DOGE' };
222
+ // ── CRYPTOCAP: the crypto indices ───────────────────────────────────────────────────────────────────────────────
223
+ /** TradingView's crypto index prefix, and our venue of the same series (docs/features/data/cryptocap-indices.md). */
224
+ export const CRYPTOCAP_PREFIX = 'CRYPTOCAP';
225
+ /**
226
+ * The coins TradingView tickers its own way, TradingView's ticker to ours, for a coin's dominance (`HYPEH.D` is our
227
+ * `HYPE.D`) and its market cap (`HYPEH`, our `MCAP.HYPE`) alike. Matched 2026-10-21 by comparing TradingView's caps
228
+ * with CoinGecko's; every other coin shares its ticker. The watchlist import and the wrun pin spelling step both read
229
+ * this one table.
230
+ */
231
+ export const CRYPTOCAP_TICKER_RENAMES = {
232
+ HYPEH: 'HYPE',
233
+ USDEE: 'USDE',
234
+ TAOB: 'TAO',
235
+ ARBI: 'ARB',
236
+ APTO: 'APT',
237
+ JUPI: 'JUP',
238
+ PUMPF: 'PUMP',
239
+ ASTER2: 'ASTER',
240
+ WLDW: 'WLD',
241
+ MONAD: 'MON',
242
+ };
243
+ /** The indices both sides name alike: never a coin's market cap. */
244
+ const CRYPTOCAP_INDEX_NAMES = new Set(['TOTAL', 'TOTAL2', 'TOTAL3', 'OTHERS']);
245
+ const DOMINANCE_SUFFIX = '.D';
246
+ const CRYPTOCAP_TICKER_RE = /^[A-Z0-9]{1,15}$/;
247
+ /**
248
+ * A TradingView `CRYPTOCAP:` symbol as our series: an index by its name (`TOTAL2`), a dominance by its coin's ticker
249
+ * (`BTC.D`; `HYPEH.D` is `HYPE.D`), a coin's market cap (`BTC`, TradingView's cap) as `MCAP.<TICKER>`. `proof` is the
250
+ * listed series that shows we carry it: the series itself, or, for a market cap (the catalog lists no `MCAP.*`
251
+ * series), the coin's dominance, listed for every coin the indices cover. Null for a symbol of no such shape.
252
+ */
253
+ export function cryptoCapSeriesOf(symbol) {
254
+ const upper = symbol.trim().toUpperCase();
255
+ if (CRYPTOCAP_INDEX_NAMES.has(upper))
256
+ return { series: upper, proof: upper };
257
+ const dominance = upper.endsWith(DOMINANCE_SUFFIX);
258
+ const ticker = dominance ? upper.slice(0, -DOMINANCE_SUFFIX.length) : upper;
259
+ if (!CRYPTOCAP_TICKER_RE.test(ticker))
260
+ return null;
261
+ const ours = CRYPTOCAP_TICKER_RENAMES[ticker] ?? ticker;
262
+ const proof = `${ours}${DOMINANCE_SUFFIX}`;
263
+ return dominance ? { series: proof, proof } : { series: `MCAP.${ours}`, proof };
264
+ }
265
+ /** Our CRYPTOCAP series as TradingView spells it (`HYPE.D` is `HYPEH.D`, `MCAP.BTC` is `BTC`), null for no such one. */
266
+ export function tradingViewCryptoCapSymbol(series) {
267
+ const upper = series.trim().toUpperCase();
268
+ if (CRYPTOCAP_INDEX_NAMES.has(upper))
269
+ return upper;
270
+ const cap = upper.startsWith('MCAP.');
271
+ const dominance = !cap && upper.endsWith(DOMINANCE_SUFFIX);
272
+ if (!cap && !dominance)
273
+ return null;
274
+ const ours = cap ? upper.slice('MCAP.'.length) : upper.slice(0, -DOMINANCE_SUFFIX.length);
275
+ if (!CRYPTOCAP_TICKER_RE.test(ours))
276
+ return null;
277
+ const theirs = Object.keys(CRYPTOCAP_TICKER_RENAMES).find((ticker) => CRYPTOCAP_TICKER_RENAMES[ticker] === ours);
278
+ return `${theirs ?? ours}${dominance ? DOMINANCE_SUFFIX : ''}`;
279
+ }
@@ -0,0 +1,19 @@
1
+ import type { WrunGateReaderIntentSurface, WrunGateReaderIntentWarm } from '../../../host-ports.types.js';
2
+ /**
3
+ * The exchange a gate plane's lane reads name, the one the transport routes them by: an OPRA lane asks by the plane's
4
+ * own exchange whatever the chart's venue spelling (`wrunLaneOpraPlaneChain`, the stats lanes' `statsExchange`), a CME
5
+ * chain lane by the chart's own CME exchange.
6
+ */
7
+ export declare function wrunGateReadExchangeOf(plane: 'cme' | 'opra', chartExchange: string): string;
8
+ /** The exchange the reads of a chart's options route by on their gate plane (see the module comment), or null for a
9
+ * chart whose options ride no plane. Rejects only when the options gate cannot load. */
10
+ export declare function wrunChartGateReadExchange(chartExchange: string): Promise<string | null>;
11
+ /**
12
+ * Warm the gate reader the chart's options are read on, for a surface whose open suspects an options add is coming:
13
+ * dialed through the transport only when no other tab of this browser holds that reader for this identity and tier,
14
+ * once per reader's life (a reader this tab already dials or holds is left alone), and under every guard of a dial (a
15
+ * guest, a terms wall, a refusal). A reader no read ever uses is released by the transport's idle sweep. Resolves with
16
+ * what it did (`no-plane` for a chart whose options ride no gate plane, `failed` when a load or a port failed); never
17
+ * rejects.
18
+ */
19
+ export declare function warmWrunChartGateReaderOnIntent(chartExchange: string | null | undefined, surface: WrunGateReaderIntentSurface): Promise<WrunGateReaderIntentWarm>;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The gate reader a chart's options are read on, decided once for both warms of it (OPTLOAD g1):
3
+ *
4
+ * - the door warm of a package whose sheet reads that plane (wrun-gate-reader-warm.util `warmWrunSheetGateReaders`):
5
+ * the add's own dial, made earlier, so it contests another tab's session exactly as the add always did;
6
+ * - the intent warm of a surface whose open suspects an options add is coming (round 2: the Indicators dialog's open,
7
+ * the Options panel's), `warmWrunChartGateReaderOnIntent`: the same reader, dialed only when no other tab of this
8
+ * browser holds it for this identity and tier (the transport's lease, V2Service `warmGateReaderOnIntent`), so an
9
+ * open never takes another tab's session.
10
+ *
11
+ * The plane is the one the run's planner judges the chart by (`governedOptionPlane`: OPRA on a US stock or ETF chart,
12
+ * CME on a CME futures chart, under the account's option venue gates), read once the `opra` flag is known when that
13
+ * flag decides the chart's options (bounded, the run head's own wait), so an unhydrated flag map never reads as a chart
14
+ * off the plane. Light at module load (the env and the plane's exchange): a surface's open loads no lane registry.
15
+ */
16
+ import { wrunChartHostEnv } from '../../../host-env.js';
17
+ import { OPRA_GOVERNED_EXCHANGES } from '../../../interfaces/opra-realtime.interface.js';
18
+ /**
19
+ * The exchange a gate plane's lane reads name, the one the transport routes them by: an OPRA lane asks by the plane's
20
+ * own exchange whatever the chart's venue spelling (`wrunLaneOpraPlaneChain`, the stats lanes' `statsExchange`), a CME
21
+ * chain lane by the chart's own CME exchange.
22
+ */
23
+ export function wrunGateReadExchangeOf(plane, chartExchange) {
24
+ return plane === 'opra' ? OPRA_GOVERNED_EXCHANGES[0] : chartExchange;
25
+ }
26
+ /** The exchange the reads of a chart's options route by on their gate plane (see the module comment), or null for a
27
+ * chart whose options ride no plane. Rejects only when the options gate cannot load. */
28
+ export async function wrunChartGateReadExchange(chartExchange) {
29
+ const gate = await wrunChartHostEnv().market.loadOptionsGate();
30
+ if (gate.opraFlagDecidesChartOptions({ exchange: chartExchange }))
31
+ await gate.awaitOpraFlagHydration();
32
+ const plane = gate.governedOptionPlane({ exchange: chartExchange });
33
+ return plane === null ? null : wrunGateReadExchangeOf(plane, chartExchange);
34
+ }
35
+ /**
36
+ * Warm the gate reader the chart's options are read on, for a surface whose open suspects an options add is coming:
37
+ * dialed through the transport only when no other tab of this browser holds that reader for this identity and tier,
38
+ * once per reader's life (a reader this tab already dials or holds is left alone), and under every guard of a dial (a
39
+ * guest, a terms wall, a refusal). A reader no read ever uses is released by the transport's idle sweep. Resolves with
40
+ * what it did (`no-plane` for a chart whose options ride no gate plane, `failed` when a load or a port failed); never
41
+ * rejects.
42
+ */
43
+ export async function warmWrunChartGateReaderOnIntent(chartExchange, surface) {
44
+ try {
45
+ if (typeof chartExchange !== 'string' || chartExchange === '')
46
+ return 'no-plane';
47
+ const exchange = await wrunChartGateReadExchange(chartExchange);
48
+ if (exchange === null)
49
+ return 'no-plane';
50
+ const { default: v2 } = await wrunChartHostEnv().transport.loadV2Service();
51
+ return await v2.warmGateReaderOnIntent(exchange, surface);
52
+ }
53
+ catch {
54
+ // Advice: the add's own door warm, and its first ask, dial for themselves.
55
+ return 'failed';
56
+ }
57
+ }
@@ -0,0 +1,23 @@
1
+ import type { WrunGateReaderIntentSurface } from '../../../host-ports.types.js';
2
+ import type { WrunIndicatorMetadata } from '../../../interfaces/wrun-runtime.interface.js';
3
+ /** Whether a poll source class's plan reads the chart's options chain: an OPRA lane resolves the chain's underlying, a
4
+ * chain lane the chain itself (sources/opra-option-lanes.util), one summary read on the network. The run's lanes known
5
+ * without it never wait for that plan (`prepareWrunSandboxRun`), and its reads ride the chain's plane. */
6
+ export declare function wrunPollClassReadsChain(sourceClass: unknown): boolean;
7
+ /** Whether a row source class's plan reads the chart's options chain (a governed OPRA lane's underlying, a chain
8
+ * lane's chain): the poll lanes' rule (`wrunPollClassReadsChain`). */
9
+ export declare function wrunRowClassReadsChain(sourceClass: unknown): boolean;
10
+ /** Whether one declared source class reads the chart's options on their gate plane: a chain-reading poll or row lane,
11
+ * or the options chain itself. */
12
+ export declare function wrunSourceClassReadsGatePlane(sourceClass: unknown): boolean;
13
+ /** Whether any input of a sheet reads the chart's options on their gate plane (`wrunSourceClassReadsGatePlane`). */
14
+ export declare function wrunSheetReadsGatePlane(metadata: Pick<WrunIndicatorMetadata, 'inputs' | 'inputSources'>): boolean;
15
+ /**
16
+ * Dial the gate reader a sheet's lanes read on this chart, and start the chunk loads their plans await (see the module
17
+ * comment). The plane and its exchange are the chart's (`wrunChartGateReadExchange`, the decision the intent warm of a
18
+ * surface's open shares: the plane the run's planner judges the chart by, read once the `opra` flag is known when that
19
+ * flag decides the chart's options). `intent`: no add was asked yet (a row's settled intent), so the dial asks the
20
+ * transport's lease-guarded warm (`warmGateReaderOnIntent`) and never takes another tab's session; without it the dial
21
+ * is the add's own (`warmGateReaderFor`). Resolves once the dial was asked for, or nothing was to warm.
22
+ */
23
+ export declare function warmWrunSheetGateReaders(metadata: Pick<WrunIndicatorMetadata, 'inputs' | 'inputSources'> | null | undefined, chartExchange: string | null | undefined, intent?: WrunGateReaderIntentSurface): Promise<void>;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * The gate reader a run's first lane ask rides, dialed when the door that mounts the package knows the run
3
+ * (OPTLOAD g1, 2026-10-21).
4
+ *
5
+ * Why: a lane that reads a gate plane (an OPRA poll lane, a governed or chain row lane, the options chain) asks on that
6
+ * plane's reader socket, and the transport dialed that socket on demand, at the lane's first ask: after the package
7
+ * download, the module compile and the plan. From Singapore the handshake (TCP, TLS and the upgrade, about 1 s
8
+ * measured on INT) then followed every other wait of the add. Exposure History at 1h on SPY planned at 689 ms, sent its
9
+ * one DAY stats ask at 706 ms, and had its answer at 1,956 ms, where the ask's own wire was 0.25 to 0.43 s: the reader
10
+ * opened 1 s after the ask. Every OPRA indicator measured showed the same open right before its first answer.
11
+ *
12
+ * The door that mounts or warms a package holds its version doc (whose sheet names the lanes) and the chart (whose
13
+ * market names the plane) from its first step. `warmWrunSheetGateReaders` dials the plane's reader then, so the
14
+ * handshake overlaps the download, the compile and the plan, and the lane's ask is one round trip. Beside the dial it
15
+ * starts the chunk loads the lanes' plans await (the options gate, the chain venues, the Deribit listing, the chain
16
+ * resolver), so a cold first add never loads them after the plan.
17
+ *
18
+ * A hint, never a keepalive: the transport keeps every guard of an on-demand dial (a kick, a refusal, a guest on a
19
+ * plane with no guest reads, an unconfigured plane), its idle sweep releases a reader no read ever wants, and a sheet
20
+ * that reads no gate lane, or a chart whose options ride no plane, warms nothing. The lane's own ask still dials for
21
+ * itself when the warm did not (or could not) run. Never throws, never rejects.
22
+ *
23
+ * A door with no add asked yet (round 2: a row's settled intent, `surface` `add-intent`) dials through the transport's
24
+ * intent warm instead, which never takes the session of another tab of the browser reading that reader
25
+ * (V2Service `warmGateReaderOnIntent`); an add's own doors contest it as the add always did.
26
+ */
27
+ import { wrunChartHostEnv } from '../../../host-env.js';
28
+ import { wrunPollLanesOfClass } from '../sources/registry.js';
29
+ import { wrunRowLaneOfClass } from '../sources/row-lane-registry.js';
30
+ import { wrunChartGateReadExchange } from './wrun-chart-gate-reader.util.js';
31
+ /** The options chain lane's class: its chain summary and expiry reads ride the chart's plane too. */
32
+ const OPTIONS_CHAIN_SOURCE_CLASS = 'options_chain';
33
+ /** Whether a poll source class's plan reads the chart's options chain: an OPRA lane resolves the chain's underlying, a
34
+ * chain lane the chain itself (sources/opra-option-lanes.util), one summary read on the network. The run's lanes known
35
+ * without it never wait for that plan (`prepareWrunSandboxRun`), and its reads ride the chain's plane. */
36
+ export function wrunPollClassReadsChain(sourceClass) {
37
+ return wrunPollLanesOfClass(sourceClass).some((lane) => lane.opra === true || lane.chain !== undefined);
38
+ }
39
+ /** Whether a row source class's plan reads the chart's options chain (a governed OPRA lane's underlying, a chain
40
+ * lane's chain): the poll lanes' rule (`wrunPollClassReadsChain`). */
41
+ export function wrunRowClassReadsChain(sourceClass) {
42
+ const rowLane = wrunRowLaneOfClass(sourceClass);
43
+ return rowLane?.governed === 'opra' || rowLane?.chain !== undefined;
44
+ }
45
+ /** Whether one declared source class reads the chart's options on their gate plane: a chain-reading poll or row lane,
46
+ * or the options chain itself. */
47
+ export function wrunSourceClassReadsGatePlane(sourceClass) {
48
+ return (sourceClass === OPTIONS_CHAIN_SOURCE_CLASS ||
49
+ wrunPollClassReadsChain(sourceClass) ||
50
+ wrunRowClassReadsChain(sourceClass));
51
+ }
52
+ /** Whether any input of a sheet reads the chart's options on their gate plane (`wrunSourceClassReadsGatePlane`). */
53
+ export function wrunSheetReadsGatePlane(metadata) {
54
+ return (metadata.inputs ?? []).some((input) => wrunSourceClassReadsGatePlane(metadata.inputSources?.[input.name]?.source));
55
+ }
56
+ /**
57
+ * Dial the gate reader a sheet's lanes read on this chart, and start the chunk loads their plans await (see the module
58
+ * comment). The plane and its exchange are the chart's (`wrunChartGateReadExchange`, the decision the intent warm of a
59
+ * surface's open shares: the plane the run's planner judges the chart by, read once the `opra` flag is known when that
60
+ * flag decides the chart's options). `intent`: no add was asked yet (a row's settled intent), so the dial asks the
61
+ * transport's lease-guarded warm (`warmGateReaderOnIntent`) and never takes another tab's session; without it the dial
62
+ * is the add's own (`warmGateReaderFor`). Resolves once the dial was asked for, or nothing was to warm.
63
+ */
64
+ export async function warmWrunSheetGateReaders(metadata, chartExchange, intent) {
65
+ try {
66
+ if (!metadata || typeof chartExchange !== 'string' || chartExchange === '')
67
+ return;
68
+ if (!wrunSheetReadsGatePlane(metadata))
69
+ return;
70
+ const env = wrunChartHostEnv();
71
+ // The plan's own loads (resolveWrunLaneChainChart, resolveWrunChartChain): advice, so a failed load is the plan's
72
+ // to report when it asks again.
73
+ void Promise.allSettled([
74
+ env.market.loadOptionsChainVenues(),
75
+ env.market.loadDeribitOptions(),
76
+ env.market.loadOptionsChartSource(),
77
+ ]);
78
+ const exchange = await wrunChartGateReadExchange(chartExchange);
79
+ if (exchange === null)
80
+ return;
81
+ const { default: v2 } = await env.transport.loadV2Service();
82
+ if (intent === undefined)
83
+ v2.warmGateReaderFor(exchange);
84
+ else
85
+ await v2.warmGateReaderOnIntent(exchange, intent);
86
+ }
87
+ catch {
88
+ // A warm is advice: the lane's first ask dials the reader for itself, as before.
89
+ }
90
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * A run's lane dispatch by group (run scheduling, 2026-10-20): every lane dispatches the moment ITS inputs are known,
3
+ * never after a plan it does not read.
4
+ *
5
+ * Why: the run planned every lane first and dispatched them together, so a lane whose inputs were known at the plan
6
+ * (a daily candle leg, a daily options stats poll lane) waited for every other lane's plan: a chain lane resolving
7
+ * the chart's options chain (one summary read, 1 to 7 s on INT), then the options chain lane's expiry directory. The
8
+ * first source request of an options indicator left a median 2.2 s after the add (74 of 90 measured cells over 1 s;
9
+ * INDICATOR-LOAD-BUDGET, "Frontend costs every add pays"). Now each group is added with the promise of its plan and
10
+ * dispatches through the run's own lane runner as that plan resolves:
11
+ *
12
+ * - `add(planned)`: a group's thunks once its plan resolved (undefined: nothing to dispatch). Groups are added in the
13
+ * order their plans were read before (the run's: the lanes it knows now, the poll lanes, the row lanes, the options
14
+ * chain), and that order decides which refusal wins.
15
+ * - `planned(retract)`: resolves once every plan resolved. The first plan to reject, in group order, is the run's
16
+ * refusal: no later group dispatches, every lane already dispatched is retracted (`retract`: the run lowers the
17
+ * pending mark it raised at dispatch, data-loading rule 3), and its read is abandoned, never aborted (its answer
18
+ * lands in the fetch cache). A plan that never answers keeps only its own lanes waiting.
19
+ * - `settled()`: every dispatched group's outcome, merged by the run (`merge`: declaration order, as one dispatch
20
+ * would have reported them).
21
+ *
22
+ * No timer is armed here: a group dispatches on its plan's own settle (a microtask after it), so a lane whose inputs
23
+ * are known at the plan is on the wire before anything the plans wait for answers (pinned by
24
+ * tests/utility/wrun/wrun-overlay-run.dispatch-at-mount.spec.ts under fake timers).
25
+ */
26
+ export interface WrunLaneGroupPorts<Thunks, Run> {
27
+ /** The run's lane runner (`runWrunSourceLanes` under the run's policy): dispatches every thunk at once. */
28
+ run: (thunks: Thunks) => Promise<Run>;
29
+ /** The lane ids a group's thunks dispatch (the ids its pending marks name). */
30
+ lanesOf: (thunks: Thunks) => Iterable<string>;
31
+ /** The groups' outcomes as one run's (declaration order). */
32
+ merge: (runs: Run[]) => Run;
33
+ }
34
+ export interface WrunLaneGroupSchedule<Thunks, Run> {
35
+ add(planned: Promise<Thunks | undefined>): void;
36
+ planned(retract: (lane: string) => void): Promise<void>;
37
+ settled(): Promise<Run>;
38
+ }
39
+ export declare function scheduleWrunLaneGroups<Thunks, Run>(ports: WrunLaneGroupPorts<Thunks, Run>): WrunLaneGroupSchedule<Thunks, Run>;