@orangecharts/wrun-chart-host 0.14.0 → 0.15.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 (43) hide show
  1. package/dist/constants/feature-flags.constants.d.ts +1 -0
  2. package/dist/constants/feature-flags.constants.js +4 -0
  3. package/dist/host-env.d.ts +14 -0
  4. package/dist/host-env.js +15 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.js +1 -0
  7. package/dist/interfaces/wrun-runtime.interface.d.ts +44 -1
  8. package/dist/market-data/venues/index.d.ts +2 -2
  9. package/dist/market-data/venues/opra.js +3 -3
  10. package/dist/market-data/venues/stocks.contract.copy.json +3 -2
  11. package/dist/market-data/venues/stocks.d.ts +2 -2
  12. package/dist/market-data/venues/stocks.js +10 -9
  13. package/dist/settings-templates/indicator-fields.js +15 -0
  14. package/dist/utility/chart/cache-alignment.util.d.ts +23 -0
  15. package/dist/utility/chart/cache-alignment.util.js +36 -6
  16. package/dist/utility/chart/footprint-band.util.d.ts +21 -5
  17. package/dist/utility/chart/footprint-band.util.js +53 -14
  18. package/dist/utility/chart/wrun-run-result.util.d.ts +9 -1
  19. package/dist/utility/chart/wrun-run-result.util.js +8 -2
  20. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +6 -2
  21. package/dist/utility/wrun/wrun-batched-marks.util.js +5 -3
  22. package/dist/utility/wrun/wrun-canvases.util.d.ts +24 -7
  23. package/dist/utility/wrun/wrun-canvases.util.js +92 -27
  24. package/dist/utility/wrun/wrun-hover.util.d.ts +8 -2
  25. package/dist/utility/wrun/wrun-hover.util.js +24 -13
  26. package/dist/utility/wrun/wrun-live-tick.util.js +22 -15
  27. package/dist/utility/wrun/wrun-output-words.util.d.ts +14 -0
  28. package/dist/utility/wrun/wrun-output-words.util.js +51 -0
  29. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +41 -0
  30. package/dist/utility/wrun/wrun-overlay-drivers.util.js +32 -0
  31. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +6 -1
  32. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  33. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +8 -2
  34. package/dist/utility/wrun/wrun-overlay-run.util.js +31 -4
  35. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -1
  36. package/dist/utility/wrun/wrun-panel-mount.util.js +102 -5
  37. package/dist/utility/wrun/wrun-run-health.util.d.ts +6 -3
  38. package/dist/utility/wrun/wrun-run-health.util.js +5 -2
  39. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +25 -8
  40. package/dist/utility/wrun/wrun-script-inputs.util.js +145 -45
  41. package/dist/utility/wrun/wrun-style-names.util.d.ts +23 -0
  42. package/dist/utility/wrun/wrun-style-names.util.js +74 -0
  43. package/package.json +3 -3
@@ -59,6 +59,7 @@ export declare const FeatureFlag: {
59
59
  readonly OptionsAccessPrewarm: "options-access-prewarm";
60
60
  readonly WrunDownloadBudgetCut: "wrun-download-budget-cut";
61
61
  readonly WrunConvergingPrefix: "wrun-converging-prefix";
62
+ readonly ScreenshotLegacyCapture: "screenshot-legacy-capture";
62
63
  };
63
64
  export type FeatureFlagKey = (typeof FeatureFlag)[keyof typeof FeatureFlag];
64
65
  export declare const FEATURE_FLAG_KEYS: FeatureFlagKey[];
@@ -415,6 +415,10 @@ export const FeatureFlag = {
415
415
  // proves it on a rig; the dev/internal localStorage override lights it for a rig (`kiyo.flag-overrides` ->
416
416
  // `{"wrun-converging-prefix": true}`).
417
417
  WrunConvergingPrefix: 'wrun-converging-prefix',
418
+ // Kill switch of the in-place chart picture (src/utility/screenshot.util.ts captureLayered): ON sends every capture
419
+ // through the legacy html2canvas path (a clone of the whole page, seconds of frozen page). Unminted and absent read
420
+ // off, so production takes the in-place engine; mint it ON only to roll the engine back without a deploy.
421
+ ScreenshotLegacyCapture: 'screenshot-legacy-capture',
418
422
  };
419
423
  export const FEATURE_FLAG_KEYS = Object.values(FeatureFlag);
420
424
  /**
@@ -196,6 +196,15 @@ export interface WrunChartHostEnv {
196
196
  * draws). Absent: no read point composes anything, exactly as before the member (the sandbox worker and the phone
197
197
  * app never set it). wrun-session-composition.util is its one reader. */
198
198
  session?: WrunHostSession;
199
+ /** Optional, read wherever a chart surface names a line of a built-in's port (`wrunHostBuiltinLineWords` is its one
200
+ * reader, through utility/wrun/wrun-output-words.util `wrunOutputWords`). The words built-in `builtIn` names its
201
+ * line `label` by, in the viewer's language, or undefined when `label` is no line that built-in names. `label` is
202
+ * the output's sheet label as published: a proven twin's sheet keeps its kScript original's contract label there
203
+ * (MACD's `macdLine`, Bollinger Bands' `Lower Band`), the anchor its alerts match the line by, so the sheet cannot
204
+ * reword it. Absent, a blank answer or a call that throws: the line reads its sheet's words (wrunLegendName),
205
+ * exactly as before the member. web: the built-in's alert-contract output words (`builtinOutputI18nKey` through the
206
+ * i18n plugin), bound by the run binder. The sandbox worker and the phone app never set it. */
207
+ builtinLineWords?: (builtIn: string, label: string) => string | undefined;
199
208
  }
200
209
  /** A lane the host's session may compose: the tape (fill groups), the sided trades lane in contracts (`trades`) and
201
210
  * the same lane in US dollars (`trades_usd`). */
@@ -625,6 +634,11 @@ export declare function wrunHostTapePerOrder(): boolean;
625
634
  * (`WrunChartHostEnv.carryWithBuild`): false for a host that never set the member, and before the realm's entry set
626
635
  * the env. Read at every run, never at module load. */
627
636
  export declare function wrunHostCarryWithBuild(): boolean;
637
+ /** The words built-in `builtIn` names its line `label` by (`WrunChartHostEnv.builtinLineWords`), or undefined: an env
638
+ * not set yet, a host without the member, an answer that holds no words, or a call that throws (the line keeps its
639
+ * sheet's words). Read when a surface names a line, never at module load; utility/wrun/wrun-output-words.util
640
+ * `wrunOutputWords` is its one reader. */
641
+ export declare function wrunHostBuiltinLineWords(builtIn: string, label: string): string | undefined;
628
642
  /** The error a host's `sharedHost()` throws before its load. */
629
643
  export declare function wrunChartHostUnloadedError(): Error;
630
644
  /** The shared host now, or its load: `undefined` once the env's `sharedHost()` answers, else the env's
package/dist/host-env.js CHANGED
@@ -47,6 +47,21 @@ export function wrunHostTapePerOrder() {
47
47
  export function wrunHostCarryWithBuild() {
48
48
  return hasWrunChartHostEnv() && wrunChartHostEnv().carryWithBuild === true;
49
49
  }
50
+ /** The words built-in `builtIn` names its line `label` by (`WrunChartHostEnv.builtinLineWords`), or undefined: an env
51
+ * not set yet, a host without the member, an answer that holds no words, or a call that throws (the line keeps its
52
+ * sheet's words). Read when a surface names a line, never at module load; utility/wrun/wrun-output-words.util
53
+ * `wrunOutputWords` is its one reader. */
54
+ export function wrunHostBuiltinLineWords(builtIn, label) {
55
+ if (!hasWrunChartHostEnv())
56
+ return undefined;
57
+ try {
58
+ const words = wrunChartHostEnv().builtinLineWords?.(builtIn, label);
59
+ return typeof words === 'string' && words.trim() !== '' ? words : undefined;
60
+ }
61
+ catch {
62
+ return undefined;
63
+ }
64
+ }
50
65
  /** The error a host's `sharedHost()` throws before its load. */
51
66
  export function wrunChartHostUnloadedError() {
52
67
  return new Error('wrun_chart_host_unloaded');
package/dist/index.d.ts CHANGED
@@ -355,6 +355,7 @@ export * from './utility/wrun/wrun-option-views.util.js';
355
355
  export * from './utility/wrun/wrun-options-flow-underlying.leaf.js';
356
356
  export * from './utility/wrun/wrun-options-stop.util.js';
357
357
  export * from './utility/wrun/wrun-output-style.util.js';
358
+ export * from './utility/wrun/wrun-output-words.util.js';
358
359
  export * from './utility/wrun/wrun-overlay-drivers.util.js';
359
360
  export * from './utility/wrun/wrun-overlay-lifecycle.util.js';
360
361
  export * from './utility/wrun/wrun-overlay-metadata.util.js';
package/dist/index.js CHANGED
@@ -359,6 +359,7 @@ export * from './utility/wrun/wrun-option-views.util.js';
359
359
  export * from './utility/wrun/wrun-options-flow-underlying.leaf.js';
360
360
  export * from './utility/wrun/wrun-options-stop.util.js';
361
361
  export * from './utility/wrun/wrun-output-style.util.js';
362
+ export * from './utility/wrun/wrun-output-words.util.js';
362
363
  export * from './utility/wrun/wrun-overlay-drivers.util.js';
363
364
  export * from './utility/wrun/wrun-overlay-lifecycle.util.js';
364
365
  export * from './utility/wrun/wrun-overlay-metadata.util.js';
@@ -2541,7 +2541,8 @@ interface WrunBatchedSectionCommon {
2541
2541
  * number format, a word of WRUN_BATCHED_NUMBER_FORMATS (wrun-batched-readout.util:
2542
2542
  * `{{qty:units}}` prints a mark's quantity in the market's own unit, `{{qty:usd}}` in dollars). */
2543
2543
  tooltip?: string | null;
2544
- /** The readout title, 1..40 chars (absent = the name read as words). */
2544
+ /** The readout title and the Style line's, 1..40 chars, where the sheet's `style_names` table gives the section no
2545
+ * label (absent = the name read as words; wrun-style-names.util wrunStyleTitle). */
2545
2546
  label?: string;
2546
2547
  panel?: 'overlay';
2547
2548
  }
@@ -2647,6 +2648,42 @@ export interface WrunFlagsSection extends WrunBatchedSectionCommon {
2647
2648
  colors?: WrunBatchedColor[];
2648
2649
  }
2649
2650
  export type WrunBatchedSection = WrunMarksSection | WrunSpansSection | WrunRaysSection | WrunFlagsSection;
2651
+ /** The kinds of the sheet's `style_names` table whose entry titles a Style line: the four batched kinds, and a
2652
+ * renderer (any kind). */
2653
+ export type WrunStyleNameTitledKind = WrunBatchedMarksKind | 'renderer';
2654
+ /** The kinds of the table whose entry names colours only: an output and a heatmap keep their title in their own
2655
+ * `label` (one source per title), so the table names their swatches and never their line. */
2656
+ export type WrunStyleNameColorsKind = 'output' | 'heatmap';
2657
+ /** The drawn kinds the sheet's `style_names` table names. */
2658
+ export type WrunStyleNameKind = WrunStyleNameTitledKind | WrunStyleNameColorsKind;
2659
+ interface WrunStyleNameCommon {
2660
+ /** The section's, renderer's, output's or heatmap's own `name`. */
2661
+ name: string;
2662
+ /** One name per colour slot, in slot order, as long as that target's colour list (an output's: its two-tone pair or
2663
+ * its `color_by` ladder, one per rung; a heatmap's: its `palette`; a renderer's: its `colors`, the `color_by`
2664
+ * ladder): each names its swatch. Slots that share a name are one swatch that paints all of them. */
2665
+ colors?: string[];
2666
+ }
2667
+ /** A batched section's or a renderer's entry: the words its Style line is titled by, and its swatches' names. */
2668
+ export interface WrunStyleNameTitled extends WrunStyleNameCommon {
2669
+ kind: WrunStyleNameTitledKind;
2670
+ /** The words its Style line is titled by (absent: the section's own `label`, else its name read as words). */
2671
+ label?: string;
2672
+ }
2673
+ /** An output's or a heatmap's entry: its swatches' names alone (its title is its own `label`; a `label` here is read
2674
+ * as none). */
2675
+ export interface WrunStyleNameColors extends WrunStyleNameCommon {
2676
+ kind: WrunStyleNameColorsKind;
2677
+ label?: never;
2678
+ }
2679
+ /**
2680
+ * One entry of the sheet's `style_names` table (STYLE-PAGE-NAMES, frozen sheet contract, kit scaffold 118): the plain
2681
+ * words the settings box shows for one batched section, renderer, output or heatmap, named by its kind and `name`.
2682
+ * The table is a top-level key, never a section key, so a reader older than it strips it and the sections stay as
2683
+ * every kit wrote them (the sheet lists it in `ignorable` for the hosted extractor). wrun-style-names.util is its one
2684
+ * reader.
2685
+ */
2686
+ export type WrunStyleName = WrunStyleNameTitled | WrunStyleNameColors;
2650
2687
  export interface WrunIndicatorMetadata {
2651
2688
  id: string;
2652
2689
  name: string;
@@ -2811,6 +2848,12 @@ export interface WrunIndicatorMetadata {
2811
2848
  /** The dialog layout in source order (absent = today's `group` tabs). */
2812
2849
  layout?: WrunLayoutEntry[];
2813
2850
  presets?: WrunPreset[];
2851
+ /** The Style page's plain names for batched sections, renderers, outputs and heatmaps (WrunStyleName; absent = the
2852
+ * page titles each line by the section's own label or its name, and each swatch by what it paints or its place). */
2853
+ style_names?: WrunStyleName[];
2854
+ /** The word paths a reader older than them may skip (`inputs[].capacity`, `style_names`): the hosted extractor's
2855
+ * list, which the kit validates. The chart does not read it. */
2856
+ ignorable?: string[];
2814
2857
  /** The legend title template ({{name}} placeholders). */
2815
2858
  legend_title?: string;
2816
2859
  /** `render.legend` / `render.hud` declarations (never renderer kinds:
@@ -232,7 +232,7 @@ export declare const FLAG_GATED_MARKET_DATA_VENUES: readonly [{
232
232
  };
233
233
  readonly paymentItemPrefix: "stocks_";
234
234
  readonly professionalPolicy: "refuse";
235
- readonly internalRolePolicy: "refuse";
235
+ readonly internalRolePolicy: "report";
236
236
  readonly payFirst: true;
237
237
  readonly questionnaire: {
238
238
  readonly formVersion: "stocks-2026-10-20";
@@ -340,7 +340,7 @@ export declare const FLAG_GATED_MARKET_DATA_VENUES: readonly [{
340
340
  readonly i18nNamespace: "stocksRealtimeData";
341
341
  readonly storeId: "stocksRealtime";
342
342
  readonly surfaces: readonly ["contract-chart-delay-chip", "chart-source-line"];
343
- readonly contractRevision: "2026-11-04.1";
343
+ readonly contractRevision: "2026-11-08.1";
344
344
  }];
345
345
  type CarriedMarketDataVenue = (typeof MARKET_DATA_VENUES)[number] | (typeof FLAG_GATED_MARKET_DATA_VENUES)[number];
346
346
  /** A registered venue's key: a card the build carries, served now or dark. */
@@ -17,9 +17,9 @@ export const OPRA_VENUE = {
17
17
  planCard: { name: 'OPRA real-time', level: 'TOP OF BOOK', market: 'OPRA', region: '🇺🇸 USA' },
18
18
  paymentItemPrefix: 'opra_',
19
19
  professionalPolicy: 'refuse',
20
- // Staff are reported, as on CME (contract revision 2026-10-28.1; Kyle 2026-10-28: staff get OPRA real time): the
21
- // server records an internal account's grant as staff (`dev: true`) and the gate reports it. No role is consulted
22
- // here either way.
20
+ // Staff get OPRA real time through operator test grants (contract revision 2026-10-28.1, `internalPolicy: 'report'`;
21
+ // Kyle 2026-11-08: testing only): the server records a staff grant's rows as staff (`dev: true`) with no attestation,
22
+ // and they are in no report and filed nowhere. No role is consulted here either way.
23
23
  internalRolePolicy: 'report',
24
24
  payFirst: true,
25
25
  questionnaire: {
@@ -1,5 +1,5 @@
1
1
  {
2
- "revision": "2026-11-04.1",
2
+ "revision": "2026-11-08.1",
3
3
  "key": "stocks",
4
4
  "productGroups": ["NYSE", "NYSE_ARCA", "NASDAQ"],
5
5
  "products": [
@@ -60,5 +60,6 @@
60
60
  { "id": "paragraph12Titles", "required": true, "maxLength": 200 },
61
61
  { "id": "paragraph12Functions", "required": true, "maxLength": 500 }
62
62
  ],
63
- "legalNameFrom": ["firstName", "middleName", "lastName"]
63
+ "legalNameFrom": ["firstName", "middleName", "lastName"],
64
+ "internalPolicy": "report"
64
65
  }
@@ -18,7 +18,7 @@ export declare const STOCKS_VENUE: {
18
18
  };
19
19
  readonly paymentItemPrefix: "stocks_";
20
20
  readonly professionalPolicy: "refuse";
21
- readonly internalRolePolicy: "refuse";
21
+ readonly internalRolePolicy: "report";
22
22
  readonly payFirst: true;
23
23
  readonly questionnaire: {
24
24
  readonly formVersion: "stocks-2026-10-20";
@@ -126,5 +126,5 @@ export declare const STOCKS_VENUE: {
126
126
  readonly i18nNamespace: "stocksRealtimeData";
127
127
  readonly storeId: "stocksRealtime";
128
128
  readonly surfaces: readonly ["contract-chart-delay-chip", "chart-source-line"];
129
- readonly contractRevision: "2026-11-04.1";
129
+ readonly contractRevision: "2026-11-08.1";
130
130
  };
@@ -4,11 +4,11 @@
4
4
  * stocks on the plane"). Carried DARK: the registry lists it only while `us-equities-full` reads on
5
5
  * (`FLAG_GATED_MARKET_DATA_VENUES`, `marketDataVenueIsServed`), so with the flag off nothing in the app reads it.
6
6
  *
7
- * OPRA's policy set (pay first, one product, a professional refused), with what the tape adds: two agreements, one per
8
- * set of product groups (`agreements`: CTA's Exhibit B covers Tapes A and B, `NYSE_TAPE` and `NYSE_ARCA_TAPE`, the UTP
9
- * Subscriber Agreement covers Tape C, `NASDAQ_TAPE`; the gate release's `agreements:` names and versions, each version
10
- * the revision of the text orange serves), staff refused (ENTITLEMENT.md §7: no staff real time, the release's
11
- * `internal_realtime: false`), and a declaration that records the Exhibit B Section 2 answers (a) to (k), the
7
+ * OPRA's policy set (pay first, one product, a professional refused, staff on operator test grants: contract revision
8
+ * 2026-11-08.1, no attestation, in no report), with what the tape adds: two agreements, one per set of product
9
+ * groups (`agreements`: CTA's Exhibit B covers Tapes A and B, `NYSE_TAPE` and `NYSE_ARCA_TAPE`, the UTP Subscriber
10
+ * Agreement covers Tape C, `NASDAQ_TAPE`; the gate release's `agreements:` names and versions, each version the
11
+ * revision of the text orange serves), and a declaration that records the Exhibit B Section 2 answers (a) to (k), the
12
12
  * Paragraph 12 data and the UTP subscriber fields (`recordFields`, `legalNameFrom`). The question wording is the screen
13
13
  * NYSE approved on 2026-10-21: the content module is marked approved, so the plan page sells
14
14
  * (src/components/dialogs/market-data/questionnaires/stocks.ts).
@@ -35,9 +35,10 @@ export const STOCKS_VENUE = {
35
35
  planCard: { name: 'Real-time US stocks', level: 'ALL US VENUES', market: 'US stocks', region: '🇺🇸 USA' },
36
36
  paymentItemPrefix: 'stocks_',
37
37
  professionalPolicy: 'refuse',
38
- // Staff get no real time on the tape (ENTITLEMENT.md §7; the release refuses internal rows): the server's refusal
39
- // stands. No role is consulted here either way.
40
- internalRolePolicy: 'refuse',
38
+ // Staff get real-time US stocks through operator test grants (contract revision 2026-11-08.1, `internalPolicy:
39
+ // 'report'`; Kyle 2026-11-08: testing only): the server records a staff grant's rows as staff (`dev: true`) with no
40
+ // attestation, and they are in no report and filed nowhere. No role is consulted here either way.
41
+ internalRolePolicy: 'report',
41
42
  payFirst: true,
42
43
  questionnaire: {
43
44
  // The approved screen's submission date: the Exhibit B screen went to NYSE with Exhibit A on 2026-10-20, approved
@@ -115,5 +116,5 @@ export const STOCKS_VENUE = {
115
116
  storeId: 'stocksRealtime',
116
117
  // For now the delay statement shows on a tape chart's delay chip and its source line only.
117
118
  surfaces: ['contract-chart-delay-chip', 'chart-source-line'],
118
- contractRevision: '2026-11-04.1',
119
+ contractRevision: '2026-11-08.1',
119
120
  };
@@ -800,6 +800,9 @@ export const INDICATOR_COMMON_FIELDS = [
800
800
  // TPO's trading-hour stamp (2026-11-05, TPO_TRADING_HOUR_VERSION): without it a reload reads a picked All Hours as
801
801
  // the old default and turns it into Chart.
802
802
  ['tradingHourVersion', PREFERENCE],
803
+ // The footprint anchor's read stamp (2026-11-07, footprint-anchor-tick.util): a stamped anchor only moves finer, an
804
+ // older read's may heal coarser. Appended here, after the rows the golden fixture knows (row-keys.golden.spec).
805
+ ['anchorTickInference', PREFERENCE],
803
806
  ];
804
807
  /**
805
808
  * FEED (live series, docs/features/indicators/feeds.md): the rest of the C4 record beside `address`, `scope` and
@@ -886,6 +889,17 @@ const OPTIONS_GEX_FIELDS = [
886
889
  ['topNodeColor', PREFERENCE],
887
890
  ['axisTagLook', PREFERENCE],
888
891
  ];
892
+ /**
893
+ * The Order Book Profile's Grouping mode ('fixed' holds the picked grouping at every zoom, else it follows the zoom).
894
+ * Titan's row merge (`autoScaleBars`, `minRowPx`) is derived from it by the mount and the save door, so only the mode
895
+ * is a preference. A row that never picked holds no mode and draws Dynamic: the mount writes the mode only when one is
896
+ * stored, so untouched workspace rows are never rewritten (the row lane writes no unset). A template or a saved
897
+ * default captured from such a row carries 'dynamic' (`unset`, the default in web's orderbook-profile-grouping.util),
898
+ * so applied over a Fixed profile it restores Dynamic instead of leaving Fixed. Scoped to the type: the name is generic.
899
+ */
900
+ const ORDERBOOK_PROFILE_FIELDS = [
901
+ ['groupingMode', { lanes: ['row', 'template', 'default'], unset: 'dynamic' }],
902
+ ];
889
903
  /** The VRVP own-window scope rows (see INDICATOR_TYPE_FIELDS below). */
890
904
  const VISIBLE_RANGE_PROFILE_FIELDS = [
891
905
  ['profileWindow', PREFERENCE],
@@ -912,6 +926,7 @@ export const INDICATOR_TYPE_FIELDS = {
912
926
  */
913
927
  VISIBLE_RANGE_VOLUME_PROFILE: VISIBLE_RANGE_PROFILE_FIELDS,
914
928
  AGGREGATED_VISIBLE_RANGE_VOLUME_PROFILE: VISIBLE_RANGE_PROFILE_FIELDS,
929
+ ORDERBOOK_PROFILE: ORDERBOOK_PROFILE_FIELDS,
915
930
  OPEN_INTEREST_PROFILE: METRIC_PROFILE_FIELDS,
916
931
  LIQUIDATION_PROFILE: METRIC_PROFILE_FIELDS,
917
932
  OPTIONS_HEATMAP: OPTIONS_HEATMAP_FIELDS,
@@ -247,6 +247,12 @@ export interface MainPlanInput {
247
247
  todayLimit: number;
248
248
  numberOfCandles: number;
249
249
  demandBars: number;
250
+ /**
251
+ * The clock the venue serves through (ms): a delayed tape's cut (the main candles' stream clock), server now
252
+ * elsewhere. The bars a count ask can bring stop there, so the tail ask counts to it (`countLaneBarsSince`).
253
+ * Absent: `nowMs`.
254
+ */
255
+ servedNowMs?: number;
250
256
  };
251
257
  }
252
258
  type MainPlanLane = 'period' | 'count' | 'tail-boot' | 'dry-frontier' | 'whole';
@@ -414,6 +420,23 @@ export interface LandedMainTailVerdict {
414
420
  * Pure.
415
421
  */
416
422
  export declare function mergeLandedMainTailVerdict(held: LandedMainTailVerdict | null | undefined, landed: LandedMainTailVerdict): LandedMainTailVerdict;
423
+ /**
424
+ * The bars a count-fetched series (tradfi, forex, commodity, dex: "the newest N bars at or before an anchor") can
425
+ * have opened since its tail, the ONE count every count-lane tail ask is sized by (the main plan's count lane and the
426
+ * wake resync's): from the later of the tail bar and the instant the wire already answered through past it
427
+ * (`provenThroughMs`, the entry's tail verdict: a count reply anchored at now answers for every bar from its first row
428
+ * to its anchor, count-ask-receipt.util, so on a venue that printed nothing since its newest row the reply proves the
429
+ * closure), to the clock the venue serves through (`servedNowMs`: a delayed tape's cut, never server now, which
430
+ * counted the 15-minute delay as missing bars). Clock time between those two, never a calendar: the wire's word is
431
+ * what shrinks the count, so nothing here can hide a bar (an unmodelled holiday, an extended or overnight session).
432
+ * Pure.
433
+ */
434
+ export declare function countLaneBarsSince(input: {
435
+ tailMs: number;
436
+ provenThroughMs?: number | null;
437
+ servedNowMs: number;
438
+ intervalMs: number;
439
+ }): number;
417
440
  export declare function planMainRefetchAsks(input: MainPlanInput): MainPlanResult;
418
441
  /**
419
442
  * The span a staged family mounts (fix-forward lane S1, the 2026-09-27 ETH
@@ -553,6 +553,26 @@ export function mergeLandedMainTailVerdict(held, landed) {
553
553
  : Math.max(held.closedAtMs, landed.closedAtMs);
554
554
  return { tailTs: landed.tailTs, throughMs: Math.max(held.throughMs, landed.throughMs), closedAtMs };
555
555
  }
556
+ /**
557
+ * The bars a count-fetched series (tradfi, forex, commodity, dex: "the newest N bars at or before an anchor") can
558
+ * have opened since its tail, the ONE count every count-lane tail ask is sized by (the main plan's count lane and the
559
+ * wake resync's): from the later of the tail bar and the instant the wire already answered through past it
560
+ * (`provenThroughMs`, the entry's tail verdict: a count reply anchored at now answers for every bar from its first row
561
+ * to its anchor, count-ask-receipt.util, so on a venue that printed nothing since its newest row the reply proves the
562
+ * closure), to the clock the venue serves through (`servedNowMs`: a delayed tape's cut, never server now, which
563
+ * counted the 15-minute delay as missing bars). Clock time between those two, never a calendar: the wire's word is
564
+ * what shrinks the count, so nothing here can hide a bar (an unmodelled holiday, an extended or overnight session).
565
+ * Pure.
566
+ */
567
+ export function countLaneBarsSince(input) {
568
+ const { tailMs, provenThroughMs, servedNowMs, intervalMs } = input;
569
+ if (!(intervalMs > 0) || !Number.isFinite(tailMs) || !Number.isFinite(servedNowMs))
570
+ return 0;
571
+ const fromMs = typeof provenThroughMs === 'number' && Number.isFinite(provenThroughMs) && provenThroughMs > tailMs
572
+ ? provenThroughMs
573
+ : tailMs;
574
+ return Math.max(0, Math.floor((servedNowMs - fromMs) / intervalMs));
575
+ }
556
576
  export function planMainRefetchAsks(input) {
557
577
  const { window } = input;
558
578
  const none = {
@@ -575,8 +595,21 @@ export function planMainRefetchAsks(input) {
575
595
  if (input.indexMode) {
576
596
  const lane = input.countLane;
577
597
  const cachedLastTs = paint ? (lane?.cachedLastTs ?? paint.lastTs) : undefined;
598
+ const todayLimit = lane?.todayLimit ?? 0;
599
+ const cap = Math.max(lane?.numberOfCandles ?? 0, lane?.demandBars ?? 0);
600
+ const windowLimit = cap > 0 ? Math.min(Math.max(todayLimit, 1), cap) : Math.max(todayLimit, 1);
578
601
  if (paint && typeof cachedLastTs === 'number' && Number.isFinite(cachedLastTs)) {
579
- const barsSince = Math.max(0, Math.floor((input.nowMs - cachedLastTs) / intervalMs));
602
+ // The cached last bar and every bar the venue can have opened since (countLaneBarsSince): never a clock span
603
+ // the wire already answered for, so a closed or quiet market asks two bars once a reply has answered past its
604
+ // tail, where it asked the whole closure (1,973 bars on a Sunday, the 2026-11-08 INT AAPL dump). The ask still
605
+ // bridges every bar nothing proves (a merge over the painted rows needs no hole): a rebuild that would ask more
606
+ // than the window keeps its window send instead (boot-fetch-hoist `count-entry-rebuild`, titan-charts' count boot).
607
+ const limit = countLaneBarsSince({
608
+ tailMs: cachedLastTs,
609
+ provenThroughMs: paint.tailValidatedThroughMs,
610
+ servedNowMs: lane?.servedNowMs ?? input.nowMs,
611
+ intervalMs,
612
+ }) + 2;
580
613
  const fromSec = Math.floor(cachedLastTs / 1000);
581
614
  return {
582
615
  lane: 'count',
@@ -585,7 +618,7 @@ export function planMainRefetchAsks(input) {
585
618
  kind: 'count',
586
619
  from: nowSec,
587
620
  period: 0,
588
- limit: barsSince + 2,
621
+ limit,
589
622
  why: 'forming-tail',
590
623
  commitWindow: { fromSec, toSec: nowSec },
591
624
  },
@@ -594,12 +627,9 @@ export function planMainRefetchAsks(input) {
594
627
  reason: 'count-hit',
595
628
  };
596
629
  }
597
- const todayLimit = lane?.todayLimit ?? 0;
598
- const cap = Math.max(lane?.numberOfCandles ?? 0, lane?.demandBars ?? 0);
599
- const limit = cap > 0 ? Math.min(Math.max(todayLimit, 1), cap) : Math.max(todayLimit, 1);
600
630
  return {
601
631
  lane: 'count',
602
- asks: [{ kind: 'count', from: nowSec, period: 0, limit, why: 'uncovered-closed-bucket' }],
632
+ asks: [{ kind: 'count', from: nowSec, period: 0, limit: windowLimit, why: 'uncovered-closed-bucket' }],
603
633
  ...none,
604
634
  reason: 'count-miss',
605
635
  };
@@ -42,14 +42,30 @@ export declare function decimalPlaces(value: number): number;
42
42
  export declare function centeredFootprintBand(gridPrice: number, bandHeight: number, tickSize?: number | null): [number, number];
43
43
  /** Candle rows sampled for the tick inference (main rawData: [ts, o, h, l, c, ...]). */
44
44
  export declare const PRICE_TICK_INFERENCE_ROWS = 2000;
45
+ /**
46
+ * Share of a sample's distinct prices that may sit on a finer decimal place
47
+ * than the lattice the inference returns. A lattice puts at least half of its
48
+ * prices on its own decimal place (the odd multiples of 0.25, 0.05 and 1/64
49
+ * all end there), while prints off an exchange's lattice are rare: on a US
50
+ * stock tape the sub-penny and six-decimal executions (price improvement,
51
+ * midpoint and TRF prints) are a few per thousand. A GCD read over such
52
+ * prints is the decimal resolution of the odd print, not a tick, and it
53
+ * shrank as the sample grew: AAPL on the NASDAQ tape read 0.000004 at 252
54
+ * bars and 0.000001 at 500 (2026-11-05), the anchor keyed on it never
55
+ * settled, and every footprint board the cache held under one value was lost
56
+ * under the next. Prints finer than the lattice's place are set aside before
57
+ * the GCD; a thin sample (under 20 distinct prices) sets nothing aside.
58
+ */
59
+ export declare const PRICE_TICK_OUTLIER_SHARE = 0.05;
45
60
  /**
46
61
  * The exchange price tick as the chart's own candles reveal it: the greatest
47
62
  * common divisor of every OHLC value's distance to the first, computed in
48
- * whole units of the sample's decimal places and returned as a clean decimal.
49
- * No metadata carries a per-symbol tick, and the profile block catalog is not
50
- * one (Binance BTCUSDT: block 3.0, tick 0.1). Every traded price is a tick
51
- * multiple, so the estimate can only ever be the tick or a multiple of it (a
52
- * thin sample), never finer.
63
+ * whole units of the lattice's decimal place (`latticeDecimalPlaces`: the
64
+ * rare prints finer than it, PRICE_TICK_OUTLIER_SHARE, are set aside) and
65
+ * returned as a clean decimal. No metadata carries a per-symbol tick, and the
66
+ * profile block catalog is not one (Binance BTCUSDT: block 3.0, tick 0.1).
67
+ * Every traded price is a tick multiple, so the estimate can only ever be the
68
+ * tick or a multiple of it (a thin sample), never finer.
53
69
  *
54
70
  * Integer arithmetic, not the smallest float gap: at 85,000 a 0.01 gap
55
71
  * subtracts to 0.0099999999947 and snapping it to 9 significant digits kept
@@ -115,19 +115,53 @@ const PRICE_TICK_SIGNIFICANT_DIGITS = 12;
115
115
  * series with no lattice at all (split-adjusted 250 / 3), not a tick.
116
116
  */
117
117
  const PRICE_TICK_MIN_RELATIVE = 1e-10;
118
+ /**
119
+ * Share of a sample's distinct prices that may sit on a finer decimal place
120
+ * than the lattice the inference returns. A lattice puts at least half of its
121
+ * prices on its own decimal place (the odd multiples of 0.25, 0.05 and 1/64
122
+ * all end there), while prints off an exchange's lattice are rare: on a US
123
+ * stock tape the sub-penny and six-decimal executions (price improvement,
124
+ * midpoint and TRF prints) are a few per thousand. A GCD read over such
125
+ * prints is the decimal resolution of the odd print, not a tick, and it
126
+ * shrank as the sample grew: AAPL on the NASDAQ tape read 0.000004 at 252
127
+ * bars and 0.000001 at 500 (2026-11-05), the anchor keyed on it never
128
+ * settled, and every footprint board the cache held under one value was lost
129
+ * under the next. Prints finer than the lattice's place are set aside before
130
+ * the GCD; a thin sample (under 20 distinct prices) sets nothing aside.
131
+ */
132
+ export const PRICE_TICK_OUTLIER_SHARE = 0.05;
118
133
  function greatestCommonDivisor(a, b) {
119
134
  while (b)
120
135
  [a, b] = [b, a % b];
121
136
  return a;
122
137
  }
138
+ /**
139
+ * The decimal place the sample's lattice sits on: the coarsest place that
140
+ * leaves no more than PRICE_TICK_OUTLIER_SHARE of the distinct prices on a
141
+ * finer one. Null when even PRICE_TICK_MAX_DECIMALS leaves more (the series
142
+ * has no decimal lattice: AMM-priced tokens, split-adjusted stocks).
143
+ */
144
+ function latticeDecimalPlaces(placesByPrice) {
145
+ const finerThan = new Array(PRICE_TICK_MAX_DECIMALS + 1).fill(0);
146
+ for (const places of placesByPrice.values()) {
147
+ for (let k = 0; k < places && k <= PRICE_TICK_MAX_DECIMALS; k++)
148
+ finerThan[k] += 1;
149
+ }
150
+ const allowed = Math.floor(placesByPrice.size * PRICE_TICK_OUTLIER_SHARE);
151
+ for (let k = 0; k <= PRICE_TICK_MAX_DECIMALS; k++)
152
+ if (finerThan[k] <= allowed)
153
+ return k;
154
+ return null;
155
+ }
123
156
  /**
124
157
  * The exchange price tick as the chart's own candles reveal it: the greatest
125
158
  * common divisor of every OHLC value's distance to the first, computed in
126
- * whole units of the sample's decimal places and returned as a clean decimal.
127
- * No metadata carries a per-symbol tick, and the profile block catalog is not
128
- * one (Binance BTCUSDT: block 3.0, tick 0.1). Every traded price is a tick
129
- * multiple, so the estimate can only ever be the tick or a multiple of it (a
130
- * thin sample), never finer.
159
+ * whole units of the lattice's decimal place (`latticeDecimalPlaces`: the
160
+ * rare prints finer than it, PRICE_TICK_OUTLIER_SHARE, are set aside) and
161
+ * returned as a clean decimal. No metadata carries a per-symbol tick, and the
162
+ * profile block catalog is not one (Binance BTCUSDT: block 3.0, tick 0.1).
163
+ * Every traded price is a tick multiple, so the estimate can only ever be the
164
+ * tick or a multiple of it (a thin sample), never finer.
131
165
  *
132
166
  * Integer arithmetic, not the smallest float gap: at 85,000 a 0.01 gap
133
167
  * subtracts to 0.0099999999947 and snapping it to 9 significant digits kept
@@ -142,8 +176,8 @@ function greatestCommonDivisor(a, b) {
142
176
  export function inferPriceTickFromRows(rows, maxRows = PRICE_TICK_INFERENCE_ROWS, minRows = PRICE_TICK_INFERENCE_MIN_ROWS) {
143
177
  if (!rows || !(rows.length >= Math.max(1, minRows)))
144
178
  return null;
145
- const prices = [];
146
- let decimals = 0;
179
+ // Distinct prices in row order with their decimal places: a repeated price moves no GCD and no share.
180
+ const placesByPrice = new Map();
147
181
  const start = Math.max(0, rows.length - maxRows);
148
182
  for (let i = start; i < rows.length; i++) {
149
183
  const row = rows[i];
@@ -154,22 +188,27 @@ export function inferPriceTickFromRows(rows, maxRows = PRICE_TICK_INFERENCE_ROWS
154
188
  if (!positiveFinite(value))
155
189
  continue;
156
190
  const price = Number(value.toPrecision(PRICE_TICK_SIGNIFICANT_DIGITS));
157
- prices.push(price);
158
- decimals = Math.max(decimals, decimalPlaces(price));
191
+ if (!placesByPrice.has(price))
192
+ placesByPrice.set(price, decimalPlaces(price));
159
193
  }
160
194
  }
161
- if (prices.length < 2 || decimals > PRICE_TICK_MAX_DECIMALS)
195
+ if (placesByPrice.size < 2)
162
196
  return null;
163
- const scale = 10 ** decimals;
164
- const origin = Math.round(prices[0] * scale);
165
- if (!Number.isSafeInteger(origin))
197
+ const decimals = latticeDecimalPlaces(placesByPrice);
198
+ if (decimals === null)
166
199
  return null;
200
+ const scale = 10 ** decimals;
201
+ let origin = null;
167
202
  let units = 0;
168
203
  let maxPrice = 0;
169
- for (const price of prices) {
204
+ for (const [price, places] of placesByPrice) {
205
+ if (places > decimals)
206
+ continue;
170
207
  const scaled = Math.round(price * scale);
171
208
  if (!Number.isSafeInteger(scaled))
172
209
  return null;
210
+ if (origin === null)
211
+ origin = scaled;
173
212
  units = greatestCommonDivisor(units, Math.abs(scaled - origin));
174
213
  if (price > maxPrice)
175
214
  maxPrice = price;
@@ -29,7 +29,10 @@
29
29
  * price", `gex_curve` -> "GEX curve"), the column the kScript engine fills
30
30
  * from plot(label=...) and the legend, the alert pickers and the
31
31
  * price-axis menu read, never the numbered "Plot N" fallback. The lower
32
- * pane's outputs carry the same words.
32
+ * pane's outputs carry the same words. A built-in's port (`builtIn`)
33
+ * names each line its built-in names in that built-in's words instead
34
+ * (wrun-output-words.util wrunOutputWords: MACD's `macdLine` reads "MACD
35
+ * line"), the sheet's label kept everywhere else.
33
36
  * - Panes: an on-price result whose sheet leaves `overlay` undeclared and
34
37
  * draws a `lower` output owns ONE lower pane: a `series` child overlay
35
38
  * (`childOverlays`, mounted below by wrun-panel-mount.util through the
@@ -681,6 +684,11 @@ export interface WrunRunResultOptions {
681
684
  /** A live tick's build memo (wrun-build-memo.util): an output or band mount none of whose columns changed on the
682
685
  * newest row replays what it wrote last build. Full runs, reseeds and pans leave it absent. */
683
686
  buildMemo?: WrunBuildMemo;
687
+ /** The built-in the overlay ports (builtinPortOf over its settings; absent for any other package): every line its
688
+ * built-in names carries the built-in's words in `labels` (wrun-output-words.util wrunOutputWords), never the
689
+ * contract label a proven twin's sheet keeps (`macdLine`). The sheet, the output keys and every binding are as
690
+ * published: only the words change. */
691
+ builtIn?: string;
684
692
  }
685
693
  interface WrunRunResultOutput {
686
694
  plotType: string;
@@ -29,7 +29,10 @@
29
29
  * price", `gex_curve` -> "GEX curve"), the column the kScript engine fills
30
30
  * from plot(label=...) and the legend, the alert pickers and the
31
31
  * price-axis menu read, never the numbered "Plot N" fallback. The lower
32
- * pane's outputs carry the same words.
32
+ * pane's outputs carry the same words. A built-in's port (`builtIn`)
33
+ * names each line its built-in names in that built-in's words instead
34
+ * (wrun-output-words.util wrunOutputWords: MACD's `macdLine` reads "MACD
35
+ * line"), the sheet's label kept everywhere else.
33
36
  * - Panes: an on-price result whose sheet leaves `overlay` undeclared and
34
37
  * draws a `lower` output owns ONE lower pane: a `series` child overlay
35
38
  * (`childOverlays`, mounted below by wrun-panel-mount.util through the
@@ -557,6 +560,7 @@ import { kScriptLegendLines } from './kscript-legend-entries.util.js';
557
560
  import { KSCRIPT_CONTAINER_OUTPUT_KEY } from './kscript-titancharts-container.util.js';
558
561
  import { KSCRIPT_VIEWPORT_MINI_CHART_PLOT_TYPE } from './kscript-viewport-overlays.util.js';
559
562
  import { wrunLegendName } from './wrun-legend-name.util.js';
563
+ import { wrunOutputWords } from '../wrun/wrun-output-words.util.js';
560
564
  import { wrunChartHostEnv } from '../../host-env.js';
561
565
  import { evaluateWrunSpans, isWrunAlphaColor, readWrunBoxSpecs, readWrunSegmentSpecs, wrunSpanEdgeTs, wrunStrategyOf, } from '../wrun/wrun-box-segment.util.js';
562
566
  import { WRUN_BATCHED_MARKS_KINDS, wrunBatchedMarksChildren, } from '../wrun/wrun-batched-marks.util.js';
@@ -747,6 +751,7 @@ export function buildWrunRunResult(options) {
747
751
  options.intervalMs,
748
752
  options.selectContext,
749
753
  options.runTimeline,
754
+ options.builtIn,
750
755
  ], options.rows);
751
756
  try {
752
757
  const budget = options.renderBudget ?? createWrunRenderBudget();
@@ -1737,7 +1742,8 @@ function buildWrunRunResultWithSelection(options, memo) {
1737
1742
  // (Volume Bubbles' twenty) stays inside the integration row budget.
1738
1743
  const lastRunRow = rows.length - 1;
1739
1744
  const markEndRow = (lastMarkRow, tsOf) => lastRunRow < 0 || lastMarkRow === lastRunRow ? undefined : [tsOf(lastRunRow), Number.NaN];
1740
- const labelByName = new Map(orderedOutputs.map((output) => [output.name, wrunLegendName(output.name, output.label)]));
1745
+ // Each line's words (wrunOutputWords): the legend's rule, a built-in port's line in its built-in's words.
1746
+ const labelByName = new Map(orderedOutputs.map((output) => [output.name, wrunOutputWords(output, options.builtIn)]));
1741
1747
  const labelOf = (name) => labelByName.get(name) ?? wrunLegendName(name);
1742
1748
  // Sheet candle groups (frozen sheet contract): four consecutive plot
1743
1749
  // 'candle' outputs mount as ONE candle plot at the first member's slot in