@orangecharts/wrun-chart-host 0.15.0 → 0.17.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 (202) hide show
  1. package/README.md +2 -0
  2. package/dist/constants/economic.constants.d.ts +2 -0
  3. package/dist/constants/economic.constants.js +2 -0
  4. package/dist/constants/feature-flags.constants.d.ts +13 -5
  5. package/dist/constants/feature-flags.constants.js +76 -35
  6. package/dist/constants/feature-limits.constants.d.ts +72 -4
  7. package/dist/constants/feature-limits.constants.js +104 -24
  8. package/dist/constants/interval.constants.js +5 -0
  9. package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +12 -0
  10. package/dist/constants/kscript-data-interval-restrictions.constants.js +14 -0
  11. package/dist/constants/marketCapabilities.constants.d.ts +9 -0
  12. package/dist/constants/marketCapabilities.constants.js +39 -11
  13. package/dist/constants/typed-indicator-source.leaf.d.ts +7 -0
  14. package/dist/constants/typed-indicator-source.leaf.js +47 -0
  15. package/dist/constants/typed-session-history-venue.leaf.d.ts +7 -0
  16. package/dist/constants/typed-session-history-venue.leaf.js +9 -0
  17. package/dist/constants/typed-width-fold.leaf.d.ts +52 -0
  18. package/dist/constants/typed-width-fold.leaf.js +101 -0
  19. package/dist/constants/typed-width-source.leaf.d.ts +24 -0
  20. package/dist/constants/typed-width-source.leaf.js +126 -0
  21. package/dist/constants/typed-width.leaf.d.ts +57 -0
  22. package/dist/constants/typed-width.leaf.js +78 -0
  23. package/dist/host-env.d.ts +10 -0
  24. package/dist/host-env.js +7 -0
  25. package/dist/host-ports.types.d.ts +23 -17
  26. package/dist/index.d.ts +4 -0
  27. package/dist/index.js +4 -0
  28. package/dist/interfaces/kscript-diagnostics.interface.d.ts +35 -0
  29. package/dist/interfaces/wrun-runtime.interface.d.ts +66 -3
  30. package/dist/interfaces/wrun-runtime.interface.js +11 -0
  31. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
  32. package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
  33. package/dist/market-data/billing.interface.d.ts +12 -45
  34. package/dist/market-data/billing.interface.js +2 -2
  35. package/dist/replay/replayLadder.js +7 -4
  36. package/dist/settings-templates/footprint-rows.d.ts +6 -0
  37. package/dist/settings-templates/footprint-rows.js +6 -0
  38. package/dist/settings-templates/frvp-fields.js +14 -0
  39. package/dist/settings-templates/indicator-fields.js +36 -0
  40. package/dist/settings-templates/tool-tables.generated.js +19 -1
  41. package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
  42. package/dist/utility/chart/cache-alignment.util.d.ts +42 -0
  43. package/dist/utility/chart/cache-alignment.util.js +88 -18
  44. package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
  45. package/dist/utility/chart/calendar-interval.util.js +152 -4
  46. package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
  47. package/dist/utility/chart/candle-bar-end.util.js +17 -6
  48. package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
  49. package/dist/utility/chart/chart-time-domain.util.js +13 -4
  50. package/dist/utility/chart/feed-interval.util.d.ts +4 -2
  51. package/dist/utility/chart/feed-interval.util.js +5 -2
  52. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
  53. package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
  54. package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
  55. package/dist/utility/chart/footprint-display-mode.util.js +5 -0
  56. package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
  57. package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
  58. package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
  59. package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
  60. package/dist/utility/chart/history-wall.util.d.ts +13 -2
  61. package/dist/utility/chart/history-wall.util.js +11 -4
  62. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  63. package/dist/utility/chart/index-mode.util.d.ts +2 -2
  64. package/dist/utility/chart/index-mode.util.js +12 -6
  65. package/dist/utility/chart/index-otc.leaf.d.ts +37 -0
  66. package/dist/utility/chart/index-otc.leaf.js +68 -0
  67. package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
  68. package/dist/utility/chart/interval-ladder.util.js +44 -4
  69. package/dist/utility/chart/interval-registry.util.d.ts +22 -1
  70. package/dist/utility/chart/interval-registry.util.js +50 -2
  71. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
  72. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
  73. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
  74. package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
  75. package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
  76. package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
  77. package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
  78. package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
  79. package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
  80. package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
  81. package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
  82. package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
  83. package/dist/utility/chart/live-bucket.util.d.ts +29 -4
  84. package/dist/utility/chart/live-bucket.util.js +45 -12
  85. package/dist/utility/chart/market-session-schedule.util.d.ts +19 -0
  86. package/dist/utility/chart/market-session-schedule.util.js +2 -1
  87. package/dist/utility/chart/market-session.util.d.ts +62 -10
  88. package/dist/utility/chart/market-session.util.js +93 -13
  89. package/dist/utility/chart/marketKind.util.d.ts +11 -12
  90. package/dist/utility/chart/marketKind.util.js +45 -13
  91. package/dist/utility/chart/mixed-mode.util.d.ts +18 -0
  92. package/dist/utility/chart/om-target.util.js +6 -4
  93. package/dist/utility/chart/price-precision.util.d.ts +20 -6
  94. package/dist/utility/chart/price-precision.util.js +34 -7
  95. package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
  96. package/dist/utility/chart/profile-frame-window.util.js +12 -0
  97. package/dist/utility/chart/rth-session.util.d.ts +3 -1
  98. package/dist/utility/chart/rth-session.util.js +3 -1
  99. package/dist/utility/chart/script-source-session.util.d.ts +43 -0
  100. package/dist/utility/chart/script-source-session.util.js +61 -0
  101. package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
  102. package/dist/utility/chart/typed-width-grid.util.js +203 -0
  103. package/dist/utility/common/transformations.util.d.ts +6 -0
  104. package/dist/utility/common/transformations.util.js +28 -4
  105. package/dist/utility/market-events/market-events.util.js +3 -0
  106. package/dist/utility/number-format.util.d.ts +14 -1
  107. package/dist/utility/number-format.util.js +22 -4
  108. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
  109. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +115 -0
  110. package/dist/utility/v2/v2-enums.leaf.js +5 -0
  111. package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +2 -1
  112. package/dist/utility/wrun/sources/row-lanes/dark_pool.js +4 -3
  113. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +13 -3
  114. package/dist/utility/wrun/wrun-batched-marks.util.js +96 -17
  115. package/dist/utility/wrun/wrun-canvases.util.d.ts +4 -2
  116. package/dist/utility/wrun/wrun-canvases.util.js +7 -12
  117. package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
  118. package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
  119. package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
  120. package/dist/utility/wrun/wrun-card-style.util.js +2 -2
  121. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +23 -8
  122. package/dist/utility/wrun/wrun-chart-market-facts.util.js +24 -9
  123. package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
  124. package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
  125. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
  126. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
  127. package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +10 -6
  128. package/dist/utility/wrun/wrun-cme-root-specs.util.js +19 -13
  129. package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
  130. package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
  131. package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
  132. package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
  133. package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
  134. package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
  135. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
  136. package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
  137. package/dist/utility/wrun/wrun-frames.d.ts +1 -1
  138. package/dist/utility/wrun/wrun-frames.js +2 -2
  139. package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
  140. package/dist/utility/wrun/wrun-handles.util.js +1 -1
  141. package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
  142. package/dist/utility/wrun/wrun-host.service.js +44 -2
  143. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
  144. package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
  145. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
  146. package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
  147. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
  148. package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
  149. package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
  150. package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
  151. package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
  152. package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
  153. package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
  154. package/dist/utility/wrun/wrun-live-tick.util.js +64 -5
  155. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +40 -6
  156. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +2 -2
  157. package/dist/utility/wrun/wrun-market-size-defaults.util.js +10 -8
  158. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
  159. package/dist/utility/wrun/wrun-overlay-drivers.util.js +3 -0
  160. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +17 -0
  161. package/dist/utility/wrun/wrun-overlay-run.util.js +318 -55
  162. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +1 -1
  163. package/dist/utility/wrun/wrun-panel-mount.util.js +42 -13
  164. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +3 -2
  165. package/dist/utility/wrun/wrun-pin-venues.util.js +11 -4
  166. package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
  167. package/dist/utility/wrun/wrun-refusal.util.js +102 -13
  168. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  169. package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
  170. package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
  171. package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
  172. package/dist/utility/wrun/wrun-run-health.util.js +1 -1
  173. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
  174. package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
  175. package/dist/utility/wrun/wrun-session-composition.util.d.ts +3 -2
  176. package/dist/utility/wrun/wrun-session-composition.util.js +3 -2
  177. package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
  178. package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
  179. package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
  180. package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
  181. package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
  182. package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
  183. package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
  184. package/dist/utility/wrun/wrun-style-words.util.js +46 -15
  185. package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
  186. package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
  187. package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
  188. package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
  189. package/dist/utility/wrun-display-name.util.d.ts +10 -0
  190. package/dist/utility/wrun-display-name.util.js +21 -0
  191. package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
  192. package/dist/utils/replay/replay-buffer-math.js +2 -0
  193. package/dist/workers/constants/socket-slots.d.ts +1 -1
  194. package/dist/workers/utils/time.worker.util.js +2 -2
  195. package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
  196. package/dist/workers/utils/volume-profile.worker.util.js +20 -0
  197. package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
  198. package/dist/workers/wrun/wrun-abi-host.js +82 -5
  199. package/dist/workers/wrun/wrun-engine-handler.js +53 -4
  200. package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
  201. package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
  202. package/package.json +11 -11
@@ -6,6 +6,7 @@
6
6
  * `@orangecharts/wrun-chart-host` package (docs/features/kscript/wrun/wrun-chart-host.md).
7
7
  */
8
8
  import { Intervals } from '../../constants/interval.constants.js';
9
+ import { isTypedWidth, TYPED_WIDTH_LABELS } from '../../constants/typed-width.leaf.js';
9
10
  // The classic labels the wire map lists first, in its order (the reversed length map keeps the last label of a
10
11
  // length, so the order is the resolver's).
11
12
  const STANDARD_INTERVAL_LABELS = ['1m', '5m', '15m', '1h', '4h', '1d', '1w', '1s', '30m', '1M', '3M', '1Y'];
@@ -28,11 +29,46 @@ const EXTENDED_INTERVAL_SET = new Set(EXTENDED_INTERVALS);
28
29
  export function isExtendedInterval(label) {
29
30
  return typeof label === 'string' && EXTENDED_INTERVAL_SET.has(label);
30
31
  }
31
- /** Every label the resolver knows, in the wire map's order: the classic ladder, the presets, the extended rungs. */
32
+ /** Every label the resolver knows, in the wire map's order: the classic ladder, the presets, the extended rungs, the
33
+ * typed widths (wire CUSTOM plus their length, typed-width.leaf). */
32
34
  export const RESOLVED_INTERVAL_LABELS = [
33
35
  ...STANDARD_INTERVAL_LABELS,
34
36
  ...CUSTOM_INTERVAL_LABELS,
35
37
  ...EXTENDED_INTERVAL_LABELS,
38
+ ...TYPED_WIDTH_LABELS,
39
+ ];
40
+ // The table's rungs written out, so a row added to Intervals.map_unit never joins a set-of-rungs reader's pick.
41
+ export const LENGTH_TABLE_INTERVAL_LABELS = [
42
+ '1s',
43
+ '5s',
44
+ '10s',
45
+ '15s',
46
+ '20s',
47
+ '30s',
48
+ '1m',
49
+ '2m',
50
+ '3m',
51
+ '4m',
52
+ '5m',
53
+ '10m',
54
+ '15m',
55
+ '30m',
56
+ '45m',
57
+ '1h',
58
+ '2h',
59
+ '3h',
60
+ '4h',
61
+ '6h',
62
+ '8h',
63
+ '12h',
64
+ '1d',
65
+ '3d',
66
+ '1w',
67
+ '1mm',
68
+ '1M',
69
+ '3M',
70
+ '6M',
71
+ '1Y',
36
72
  ];
37
73
  const hasOwn = (record, key) => Object.prototype.hasOwnProperty.call(record, key);
38
74
  // map_unit reversed over every label this resolver knows, so a label added
@@ -56,16 +92,17 @@ export function intervalMs(label) {
56
92
  // The classic ladder, ascending: the labels the tuning tables were written for.
57
93
  // The scan keeps the last (largest) match.
58
94
  const TUNING_STANDARD_INTERVALS = Intervals.INTERVAL_ORDER;
59
- /** A label with no tuning rows of its own: a preset or an extended rung. */
95
+ /** A label with no tuning rows of its own: a preset, an extended rung or a typed width. */
60
96
  function readsTuningAtOrBelow(label) {
61
- return isCustomInterval(label) || isExtendedInterval(label);
97
+ return isCustomInterval(label) || isExtendedInterval(label) || isTypedWidth(label);
62
98
  }
63
99
  /**
64
100
  * The standard label whose per-interval settings a label uses. Tuning tables
65
101
  * (profile rows, footprint bars, heatmap depth, restrictions...) list only
66
102
  * the classic ladder, so a preset or an extended rung takes the largest
67
103
  * classic label that is no longer than it (5s 15s 30s -> 1s, 3m -> 1m,
68
- * 10m -> 5m, 45m -> 30m, 6h -> 4h, 12h -> 4h, 3d -> 1d, 6M -> 3M). A classic
104
+ * 10m -> 5m, 45m -> 30m, 6h -> 4h, 12h -> 4h, 3d -> 1d, 6M -> 3M, typed 20m -> 15m, 3h -> 1h, 2d to 6d -> 1d,
105
+ * 8d and up and every week size -> 1w). A classic
69
106
  * or unknown label comes back unchanged. Never use this for a wire interval:
70
107
  * a chart must not be served another interval's bars.
71
108
  */
@@ -77,6 +114,9 @@ export function standardIntervalAtOrBelow(label) {
77
114
  return label;
78
115
  let standard = label;
79
116
  for (const candidate of TUNING_STANDARD_INTERVALS) {
117
+ // A typed day or week size never lands on a calendar rung (the ladder is ascending: 1M is the first one).
118
+ if (candidate === '1M' && isTypedWidth(label))
119
+ break;
80
120
  const candidateMs = intervalMs(candidate);
81
121
  if (candidateMs !== undefined && candidateMs <= ms)
82
122
  standard = candidate;
@@ -16,8 +16,29 @@ export declare function lookupGrpcInterval(label: unknown): AggregationInterval
16
16
  /**
17
17
  * `lookupGrpcInterval` with MINUTE for a missing label: worker payloads that
18
18
  * legitimately omit their tf keep the default they always had. An unknown
19
- * label string warns once, so the fallback is visible.
19
+ * label string warns once, so the fallback is visible. A typed width reads
20
+ * CUSTOM, never MINUTE.
20
21
  */
21
22
  export declare function grpcIntervalOf(label: unknown): AggregationInterval;
23
+ /**
24
+ * The wire interval a series read sends for a label: its fixed rung, or CUSTOM for a typed width (sent with
25
+ * `wireBarSecondsOf`), `undefined` for anything else. Only the series adapters and the transport read it: every other
26
+ * reader keeps `lookupGrpcInterval`, which knows no typed width, so links, books and parsers stay on the ladder.
27
+ */
28
+ export declare function wireIntervalOf(label: unknown): number | undefined;
29
+ /**
30
+ * Whether a source may be asked at `label`: a fixed rung, or a typed width while typed widths are on (`typedWidthsOn`,
31
+ * read by the main-thread caller only for a typed width). A label with only a length (4m today, any typed width while off) is not: its caller
32
+ * keeps the chart's interval, the route it took before typed widths had rows.
33
+ */
34
+ export declare function isSourceAskInterval(label: unknown, typedWidthsOn?: () => boolean): boolean;
35
+ /** The `barSeconds` a typed width's read carries beside CUSTOM, `undefined` for every other label. */
36
+ export declare function wireBarSecondsOf(label: unknown): number | undefined;
37
+ /**
38
+ * Where a label this build does not know lands, read by its own spelling: the longest fixed rung with a wire interval
39
+ * no longer than it (a typed width an older build offered: 144m gives 2h, 24m gives 15m). `undefined` for a known
40
+ * label and for one that spells no length, which stay as they are.
41
+ */
42
+ export declare function rungAtOrBelowUnknownLabel(label: unknown): string | undefined;
22
43
  /** True for the rungs shorter than a minute (1s 5s 15s 30s): one Plus gate, one venue rule, served where 1s is. */
23
44
  export declare function isSubMinuteInterval(label: unknown): boolean;
@@ -10,7 +10,8 @@
10
10
  * (`grpcIntervalOf`), so a label missing here would paint 1m candles.
11
11
  */
12
12
  import { AggregationInterval } from '../v2/v2-enums.leaf.js';
13
- import { intervalMs } from './interval-ladder.util.js';
13
+ import { CUSTOM_WIRE_INTERVAL, isTypedWidth, typedWidthSeconds } from '../../constants/typed-width.leaf.js';
14
+ import { intervalMs, LENGTH_TABLE_INTERVAL_LABELS, } from './interval-ladder.util.js';
14
15
  // The label half (the labels, their lengths and the tuning ladder) is the pure leaf's (interval-ladder.util); its
15
16
  // importers keep this path.
16
17
  export { CUSTOM_INTERVALS, EXTENDED_INTERVALS, intervalLabelForMs, intervalMs, isCustomInterval, isExtendedInterval, standardIntervalAtOrBelow, standardIntervalMsAtOrBelow, } from './interval-ladder.util.js';
@@ -64,18 +65,65 @@ const warnedUnknownLabels = new Set();
64
65
  /**
65
66
  * `lookupGrpcInterval` with MINUTE for a missing label: worker payloads that
66
67
  * legitimately omit their tf keep the default they always had. An unknown
67
- * label string warns once, so the fallback is visible.
68
+ * label string warns once, so the fallback is visible. A typed width reads
69
+ * CUSTOM, never MINUTE.
68
70
  */
69
71
  export function grpcIntervalOf(label) {
70
72
  const interval = lookupGrpcInterval(label);
71
73
  if (interval !== undefined)
72
74
  return interval;
75
+ // A typed width is never asked as MINUTE: CUSTOM, which the transport refuses off trade candles (wireRefusalReason).
76
+ if (isTypedWidth(label))
77
+ return CUSTOM_WIRE_INTERVAL;
73
78
  if (typeof label === 'string' && !warnedUnknownLabels.has(label)) {
74
79
  warnedUnknownLabels.add(label);
75
80
  console.warn(`[interval-registry] Unknown interval "${label}"; requesting 1m.`);
76
81
  }
77
82
  return AggregationInterval.MINUTE;
78
83
  }
84
+ /**
85
+ * The wire interval a series read sends for a label: its fixed rung, or CUSTOM for a typed width (sent with
86
+ * `wireBarSecondsOf`), `undefined` for anything else. Only the series adapters and the transport read it: every other
87
+ * reader keeps `lookupGrpcInterval`, which knows no typed width, so links, books and parsers stay on the ladder.
88
+ */
89
+ export function wireIntervalOf(label) {
90
+ return lookupGrpcInterval(label) ?? (isTypedWidth(label) ? CUSTOM_WIRE_INTERVAL : undefined);
91
+ }
92
+ /**
93
+ * Whether a source may be asked at `label`: a fixed rung, or a typed width while typed widths are on (`typedWidthsOn`,
94
+ * read by the main-thread caller only for a typed width). A label with only a length (4m today, any typed width while off) is not: its caller
95
+ * keeps the chart's interval, the route it took before typed widths had rows.
96
+ */
97
+ export function isSourceAskInterval(label, typedWidthsOn = () => false) {
98
+ return lookupGrpcInterval(label) !== undefined || (isTypedWidth(label) && typedWidthsOn());
99
+ }
100
+ /** The `barSeconds` a typed width's read carries beside CUSTOM, `undefined` for every other label. */
101
+ export function wireBarSecondsOf(label) {
102
+ return typedWidthSeconds(label);
103
+ }
104
+ const LABEL_UNIT_MS = { s: 1e3, m: 6e4, h: 36e5, d: 864e5, w: 6048e5 };
105
+ /**
106
+ * Where a label this build does not know lands, read by its own spelling: the longest fixed rung with a wire interval
107
+ * no longer than it (a typed width an older build offered: 144m gives 2h, 24m gives 15m). `undefined` for a known
108
+ * label and for one that spells no length, which stay as they are.
109
+ */
110
+ export function rungAtOrBelowUnknownLabel(label) {
111
+ if (typeof label !== 'string' || intervalMs(label) !== undefined)
112
+ return undefined;
113
+ const match = /^(\d+)([smhdw])$/.exec(label);
114
+ if (!match)
115
+ return undefined;
116
+ const ms = Number(match[1]) * LABEL_UNIT_MS[match[2]];
117
+ let rung;
118
+ // The table is ascending; a calendar rung (1M 3M 6M 1Y) has no fixed length to compare.
119
+ for (const candidate of LENGTH_TABLE_INTERVAL_LABELS) {
120
+ if (/[MY]$/.test(candidate) || lookupGrpcInterval(candidate) === undefined)
121
+ continue;
122
+ if ((intervalMs(candidate) ?? Infinity) <= ms)
123
+ rung = candidate;
124
+ }
125
+ return rung;
126
+ }
79
127
  /** True for the rungs shorter than a minute (1s 5s 15s 30s): one Plus gate, one venue rule, served where 1s is. */
80
128
  export function isSubMinuteInterval(label) {
81
129
  const ms = intervalMs(label);
@@ -1,6 +1,34 @@
1
+ /** An indicator type's verdict at a typed width: `legs` is allowed only when every leg is servable. */
2
+ export type TypedWidthIndicatorVerdict = 'allowed' | 'legs' | 'restricted';
3
+ /** Who builds a typed width's candles on the chart (the app's rolled-interval.util `typedWidthBuilder`). */
4
+ export type TypedWidthBuilder = 'server' | 'app' | null;
1
5
  /**
2
- * @param kscriptType
3
- * @param interval
4
- * @returns
6
+ * The chart a verdict is asked for, when the caller has one: who builds its typed candles, and its metadata (the
7
+ * rule reads it for the chart's bar grid).
5
8
  */
6
- export declare function isKScriptDataRestrictedForInterval(kscriptType: string, interval: string): boolean;
9
+ export type TypedWidthIndicatorChart = {
10
+ readonly builder: TypedWidthBuilder;
11
+ readonly meta: unknown;
12
+ };
13
+ /**
14
+ * The per-width class rule (the app's utility/chart/typed-width-indicator-rules.util, loaded with the indicator fetch
15
+ * pipeline so its lists stay off the boot path): the verdict of a type it decides at `interval` on `chart`, undefined
16
+ * for a type it does not name.
17
+ */
18
+ export type TypedWidthIndicatorRule = (type: string, interval: string, chart?: TypedWidthIndicatorChart) => TypedWidthIndicatorVerdict | undefined;
19
+ /**
20
+ * THE verdict of an indicator type at the typed width `interval`, read by the fetch gate and the live gate. `rule`
21
+ * decides every type it names; a type it does not name takes the boot list (TYPED_WIDTH_BOOT_INDICATORS), and a type
22
+ * no one names is restricted. Each type is named in exactly one place, so the rule never overrides the boot list.
23
+ * Without the rule (not loaded yet) only the boot list answers: every other type reads as restricted, which a caller
24
+ * on the boot path may only use to skip a cached preview. On a chart whose candles the app builds the boot list does
25
+ * not answer: the rule decides every type there, and without it every type reads as restricted.
26
+ */
27
+ export declare function typedWidthIndicatorVerdict(indicatorType: string, interval: string, rule?: TypedWidthIndicatorRule, chart?: TypedWidthIndicatorChart): TypedWidthIndicatorVerdict;
28
+ /**
29
+ * Whether the chart's fetch gate refuses the kScript data source `kscriptType` at `interval`. `builder` is who builds
30
+ * the chart's typed candles, when the caller has the chart: on a chart the app builds, every source is refused at a
31
+ * typed width, because a source read carries the chart's width to the wire as CUSTOM, which the worker refuses off
32
+ * the crypto domain and the gateway refuses off its venue list (the K_OHLCV read does not fold).
33
+ */
34
+ export declare function isKScriptDataRestrictedForInterval(kscriptType: string, interval: string, builder?: TypedWidthBuilder): boolean;
@@ -4,14 +4,31 @@
4
4
  * it reads the restrictions constants module and the interval registry (a chart-host package module), so it moves into
5
5
  * the package with the phase 2 closure; the indicator util re-exports it.
6
6
  */
7
- import { ALLOWED_1S_INDICATORS, KSCRIPT_DATA_INTERVAL_RESTRICTIONS, ROLLED_INTERVAL_RESTRICTED_KSCRIPT_DATA, } from '../../constants/kscript-data-interval-restrictions.constants.js';
7
+ import { ALLOWED_1S_INDICATORS, KSCRIPT_DATA_INTERVAL_RESTRICTIONS, ROLLED_INTERVAL_RESTRICTED_KSCRIPT_DATA, TYPED_WIDTH_ALLOWED_KSCRIPT_DATA, TYPED_WIDTH_BOOT_INDICATORS, } from '../../constants/kscript-data-interval-restrictions.constants.js';
8
+ import { isTypedWidth } from '../../constants/typed-width.leaf.js';
8
9
  import { isCustomInterval, isSubMinuteInterval, standardIntervalAtOrBelow } from './interval-registry.util.js';
9
10
  /**
10
- * @param kscriptType
11
- * @param interval
12
- * @returns
11
+ * THE verdict of an indicator type at the typed width `interval`, read by the fetch gate and the live gate. `rule`
12
+ * decides every type it names; a type it does not name takes the boot list (TYPED_WIDTH_BOOT_INDICATORS), and a type
13
+ * no one names is restricted. Each type is named in exactly one place, so the rule never overrides the boot list.
14
+ * Without the rule (not loaded yet) only the boot list answers: every other type reads as restricted, which a caller
15
+ * on the boot path may only use to skip a cached preview. On a chart whose candles the app builds the boot list does
16
+ * not answer: the rule decides every type there, and without it every type reads as restricted.
13
17
  */
14
- export function isKScriptDataRestrictedForInterval(kscriptType, interval) {
18
+ export function typedWidthIndicatorVerdict(indicatorType, interval, rule, chart) {
19
+ return (rule?.(indicatorType, interval, chart) ??
20
+ (chart?.builder !== 'app' && TYPED_WIDTH_BOOT_INDICATORS.includes(indicatorType) ? 'allowed' : 'restricted'));
21
+ }
22
+ /**
23
+ * Whether the chart's fetch gate refuses the kScript data source `kscriptType` at `interval`. `builder` is who builds
24
+ * the chart's typed candles, when the caller has the chart: on a chart the app builds, every source is refused at a
25
+ * typed width, because a source read carries the chart's width to the wire as CUSTOM, which the worker refuses off
26
+ * the crypto domain and the gateway refuses off its venue list (the K_OHLCV read does not fold).
27
+ */
28
+ export function isKScriptDataRestrictedForInterval(kscriptType, interval, builder) {
29
+ // The gateway serves a typed width for plain trade candles only.
30
+ if (isTypedWidth(interval))
31
+ return builder === 'app' || !TYPED_WIDTH_ALLOWED_KSCRIPT_DATA.includes(kscriptType);
15
32
  if (isSubMinuteInterval(interval)) {
16
33
  return !ALLOWED_1S_INDICATORS.includes(kscriptType);
17
34
  }
@@ -101,6 +101,16 @@ export declare function holdChartChromeSafeArea(tc: LegendSafeAreaChart, holderI
101
101
  * back to null.
102
102
  */
103
103
  export declare function releaseChartChromeSafeArea(tc: LegendSafeAreaChart, holderId: string): void;
104
+ /** The hold every engine keeps for its whole life (`attachChartChromeSafeArea`); no record id takes this shape. */
105
+ export declare const CHART_LIFETIME_CHROME_HOLD = "chart-chrome:lifetime";
106
+ /**
107
+ * Keeps the engine told where its pane chrome is for the chart's whole life
108
+ * (the module doc): the insets reach the engine now, follow the legend as it
109
+ * grows, shrinks, folds and as panes resize, come and go, and go back to null
110
+ * when the returned function runs (the chart's teardown, before the engine's
111
+ * destroy). The one door for every engine the app builds.
112
+ */
113
+ export declare function attachChartChromeSafeArea(tc: LegendSafeAreaChart): () => void;
104
114
  /**
105
115
  * The set to hand `updateDrawings`: each top group (`top_left`,
106
116
  * `top_center`, `top_right`) moved under the chart's legend when they meet, a
@@ -39,6 +39,15 @@
39
39
  * chart serves the mounted sets, the listeners and the holds, and the insets
40
40
  * go back to null once the last of them lets go.
41
41
  *
42
+ * The engine's own surfaces read them on every chart, wrun or not: the
43
+ * volume profiles' stats block (Fixed Range, session, visible range; titan
44
+ * `profileStatsBlock.ts` places it in the pane band under `topLeft`) and the
45
+ * Ruler's touch readout. So every engine holds the tracker for its whole life
46
+ * (`attachChartChromeSafeArea`, from initializeChart right after the engine
47
+ * is built, released with the chart's other listeners on teardown): a plain
48
+ * chart once told the engine nothing, and the stats block drew under the
49
+ * legend (QA 2026-11-13).
50
+ *
42
51
  * A notice or label that did not opt in clears the buttons too (template QA
43
52
  * A17, B10): on a pane with a measured button strip (the price pane's action
44
53
  * bar, a lower pane's move buttons), a plain `top_right` or `top_center` group
@@ -106,11 +115,12 @@ const DEFAULT_LABEL_SIZE = 12;
106
115
  // row on a Hyperliquid pane with a wallet: measured without it, a top-left seat
107
116
  // landed on the pill's chips, OPRA QA 2026-10-22); titan's rows live in the main
108
117
  // section's legend section (`.titan-charts-legend-area` per plotted overlay,
109
- // the "N indicators" summary's indicator). All are content-sized, and hover
118
+ // the "N indicators" summary's indicator and the engine's pause mark beside it,
119
+ // which shows even when the app hides that indicator). All are content-sized, and hover
110
120
  // fades them by opacity, so the measured box holds still under the pointer.
111
121
  const HOST_ROW_SELECTOR = '.symbol-interval-row, .polymarket-row-1, .polymarket-row-2, .polymarket-row-3, .hlqt-anchor';
112
122
  const PLOT_SELECTOR = '.titan-charts-main-section .titan-charts-legend-section';
113
- const TITAN_ROW_SELECTOR = '.titan-charts-legend-area, .titan-charts-legend-collapse-indicator';
123
+ const TITAN_ROW_SELECTOR = '.titan-charts-legend-area, .titan-charts-legend-collapse-indicator, .titan-charts-legend-summary-note';
114
124
  const SECTION_PREFIX = '.titan-charts-';
115
125
  const SECTION_SUFFIX = '-section';
116
126
  const LEGEND_SECTION_SELECTOR = '.titan-charts-legend-section';
@@ -572,7 +582,11 @@ function cssEscape(value) {
572
582
  function offchartLegendSection(pane, paneId) {
573
583
  return pane.main.querySelector(`${SECTION_PREFIX}${cssEscape(paneId)}${SECTION_SUFFIX} ${LEGEND_SECTION_SELECTOR}`);
574
584
  }
575
- /** The chart cell's compare strip height (`--compare-strip-h`, set inline by ChartArea), 0 without one. */
585
+ /**
586
+ * The chart cell's compare strip height, 0 without one: `--compare-strip-h`, which ChartArea binds inline from the
587
+ * strip seat's MEASURED height (compare-strip-height.util), every wrapped row counted, so a wrapped strip moves the
588
+ * action bar's clearance with it. Read off the cell, never assumed: the cell's style change re-measures (watch).
589
+ */
576
590
  function compareStripPx(root) {
577
591
  const style = root.style;
578
592
  let value = typeof style?.getPropertyValue === 'function' ? style.getPropertyValue(COMPARE_STRIP_PROPERTY) : '';
@@ -878,6 +892,19 @@ export function releaseChartChromeSafeArea(tc, holderId) {
878
892
  if (idle(tracker))
879
893
  dropTracker(tc, tracker);
880
894
  }
895
+ /** The hold every engine keeps for its whole life (`attachChartChromeSafeArea`); no record id takes this shape. */
896
+ export const CHART_LIFETIME_CHROME_HOLD = 'chart-chrome:lifetime';
897
+ /**
898
+ * Keeps the engine told where its pane chrome is for the chart's whole life
899
+ * (the module doc): the insets reach the engine now, follow the legend as it
900
+ * grows, shrinks, folds and as panes resize, come and go, and go back to null
901
+ * when the returned function runs (the chart's teardown, before the engine's
902
+ * destroy). The one door for every engine the app builds.
903
+ */
904
+ export function attachChartChromeSafeArea(tc) {
905
+ holdChartChromeSafeArea(tc, CHART_LIFETIME_CHROME_HOLD);
906
+ return () => releaseChartChromeSafeArea(tc, CHART_LIFETIME_CHROME_HOLD);
907
+ }
881
908
  /** A pane-pixel handle at an anchor the pane's buttons sit over (top_right, top_center), in any pane. */
882
909
  function meetsButtonStrip(drawing) {
883
910
  const member = memberOf(drawing);
@@ -171,8 +171,25 @@ export declare function kScriptLegendSlotIdAt(index: number): string;
171
171
  /** The colour a legend line paints with (lineColor: its own, never a palette slot). */
172
172
  export declare function kScriptLegendLineColor(meta: unknown, line: KScriptLegendLine): string;
173
173
  /**
174
- * Pad a legend result to the full slot pool with empty text, name and dot so
175
- * slots a previous run addressed (a line hidden by a settings toggle) never
176
- * keep a stale reading. Slots already present are left untouched.
174
+ * How many pool slots a legend hook has addressed so far. One holder per hook
175
+ * closure (one per overlay): the engine writes only the ids a hook answers, so
176
+ * only slots some earlier answer filled can hold a stale reading.
177
177
  */
178
- export declare function padKScriptLegendSlots(entries: KScriptLegendEntry[]): KScriptLegendEntry[];
178
+ export interface KScriptLegendSlotsUsed {
179
+ used: number;
180
+ }
181
+ /** A fresh holder for one legend hook closure. */
182
+ export declare function createKScriptLegendSlotsUsed(): KScriptLegendSlotsUsed;
183
+ /**
184
+ * Pad a legend result with empty text, name and dot so slots a previous run
185
+ * addressed (a line hidden by a settings toggle) never keep a stale reading.
186
+ * Slots already present are left untouched.
187
+ *
188
+ * With a holder, only the slots this hook has ever addressed are padded, so a
189
+ * two-line script answers two entries instead of the whole pool (every padded
190
+ * id costs the engine one cell pass per frame). `used` only rises: other
191
+ * callers (the data window) run the same hook at other bars, and a slot a
192
+ * wider answer filled must still be cleared later. Without a holder the whole
193
+ * pool is padded, as before.
194
+ */
195
+ export declare function padKScriptLegendSlots(entries: KScriptLegendEntry[], slots?: KScriptLegendSlotsUsed): KScriptLegendEntry[];
@@ -537,15 +537,37 @@ export function kScriptLegendSlotIdAt(index) {
537
537
  export function kScriptLegendLineColor(meta, line) {
538
538
  return lineColor(meta, line);
539
539
  }
540
+ /** A fresh holder for one legend hook closure. */
541
+ export function createKScriptLegendSlotsUsed() {
542
+ return { used: 0 };
543
+ }
544
+ const KSCRIPT_LEGEND_SLOT_INDEX = new Map(kScriptLegendSlotIds().map((id, index) => [id, index]));
540
545
  /**
541
- * Pad a legend result to the full slot pool with empty text, name and dot so
542
- * slots a previous run addressed (a line hidden by a settings toggle) never
543
- * keep a stale reading. Slots already present are left untouched.
546
+ * Pad a legend result with empty text, name and dot so slots a previous run
547
+ * addressed (a line hidden by a settings toggle) never keep a stale reading.
548
+ * Slots already present are left untouched.
549
+ *
550
+ * With a holder, only the slots this hook has ever addressed are padded, so a
551
+ * two-line script answers two entries instead of the whole pool (every padded
552
+ * id costs the engine one cell pass per frame). `used` only rises: other
553
+ * callers (the data window) run the same hook at other bars, and a slot a
554
+ * wider answer filled must still be cleared later. Without a holder the whole
555
+ * pool is padded, as before.
544
556
  */
545
- export function padKScriptLegendSlots(entries) {
557
+ export function padKScriptLegendSlots(entries, slots) {
546
558
  const present = new Set(entries.map((entry) => entry.id));
559
+ let limit = KSCRIPT_LEGEND_MAX_ENTRIES;
560
+ if (slots) {
561
+ for (const id of present) {
562
+ const index = KSCRIPT_LEGEND_SLOT_INDEX.get(id);
563
+ if (index !== undefined && index + 1 > slots.used)
564
+ slots.used = index + 1;
565
+ }
566
+ limit = slots.used;
567
+ }
547
568
  const padded = [...entries];
548
- for (const id of kScriptLegendSlotIds()) {
569
+ for (let index = 0; index < limit; index += 1) {
570
+ const id = kScriptLegendSlotId(index);
549
571
  if (present.has(id))
550
572
  continue;
551
573
  padded.push({ id, text: '', label: '', color: KSCRIPT_LEGEND_VALUE_INK, swatch: '' });
@@ -3,7 +3,8 @@
3
3
  * kscript-titancharts-integration.util.ts with no change (the adapter imports them back):
4
4
  * `alignKScriptIndexDecoratorsToMainChart` lays every plot of a tree that holds an index decorator (a `bgcolor` or
5
5
  * `barcolor`) on the chart's bars, and `padContinuousKScriptOutputGapsOnMainGrid` gives a continuous plot a NaN row
6
- * on every chart bar its own covered span skips. Both read the chart's main bars and nothing else of the chart. A leaf
6
+ * on every chart bar its own covered span skips (a bar, never a hole slot: a time the chart holds a slot for with no
7
+ * bar in it). Both read the chart's main bars and nothing else of the chart. A leaf
7
8
  * with no app edge, so the wrun chart-host package runs the stages web runs
8
9
  * (docs/features/kscript/wrun/wrun-chart-host.md, "Leaves").
9
10
  */
@@ -20,6 +21,9 @@ const KSCRIPT_MAIN_INDEX_ALIGNMENT_EXCLUDED_PLOT_TYPES = new Set([
20
21
  // Continuous plot families draw a segment between consecutive rows, so a
21
22
  // sparse row set (orderbook buckets with holes, partially covered history)
22
23
  // renders as lines connecting across bars the script never computed. Gap
24
+ // padding names BARS only (mainChartBarTimesForKScriptGapPad): a hole slot is
25
+ // a time with no bar, which no script can compute, so a NaN row there cut
26
+ // every line at every second without a trade. Gap
23
27
  // padding is bounded to each output's own [first, last] covered span: rows
24
28
  // outside the span must stay ABSENT (not explicit NaN) so windowed replays
25
29
  // and live batches keep merging as no-ops beyond their window instead of
@@ -83,6 +87,36 @@ function mainChartTimesForKScriptIndexAlignment(tc) {
83
87
  const times = rows.map(finiteRowTime);
84
88
  return times.every((time) => time !== null) ? times : [];
85
89
  }
90
+ /**
91
+ * A hole slot of the main rows: a time the chart keeps a slot for with no bar in it. The gap policy pads one in for
92
+ * every interval a 'detect' market did not trade (titan-charts insertSyntheticGaps: NaN OHLC), and it is told by its
93
+ * shape, as the engine tells it (syntheticFlags hasGapShapedOhlc: no feed sends a NaN open).
94
+ */
95
+ function isMainChartHoleRow(row) {
96
+ if (!Array.isArray(row))
97
+ return false;
98
+ const open = row[1];
99
+ return typeof open === 'number' && Number.isNaN(open);
100
+ }
101
+ /**
102
+ * The times of the chart's BARS: its main rows without the hole slots. What the continuous-plot pad reads, since a
103
+ * plot can only have skipped a bar that exists: on a seconds chart most hole slots are seconds without a trade, and a
104
+ * NaN row on each of them broke every line into dashes (2026-11-11, an EMA on DOGEUSDT 1s). The index alignment keeps
105
+ * `mainChartTimesForKScriptIndexAlignment`: a `bgcolor` or `barcolor` is read by the main row's index, hole slots
106
+ * included.
107
+ */
108
+ function mainChartBarTimesForKScriptGapPad(tc) {
109
+ const times = [];
110
+ for (const row of mainChartRowsForKScriptIndexAlignment(tc)) {
111
+ const time = finiteRowTime(row);
112
+ // The same rule as the slot times: one row that cannot be placed and the grid is not read at all.
113
+ if (time === null)
114
+ return [];
115
+ if (!isMainChartHoleRow(row))
116
+ times.push(time);
117
+ }
118
+ return times;
119
+ }
86
120
  /** Whether the main times strictly increase (no repeated bar): read once per times array. */
87
121
  const strictlyIncreasingMainTimes = new WeakMap();
88
122
  function mainTimesStrictlyIncrease(mainTimes) {
@@ -99,41 +133,57 @@ function mainTimesStrictlyIncrease(mainTimes) {
99
133
  }
100
134
  return verdict;
101
135
  }
136
+ /** The main times as a set, built once per times array: one realign call shares one array across every row set. */
137
+ const mainTimeSets = new WeakMap();
102
138
  /**
103
- * The aligned rows of a row set that already sits on a prefix of the main
104
- * grid (row i stamped mainTimes[i], every row an array, the grid strictly
105
- * increasing): the rows themselves when they cover the grid, else the rows
106
- * followed by a NaN filler per newer bar. Exactly what the general walk below
107
- * returns for such rows, without its per-call set, map and copy (a mounted
108
- * overlay's rows sit on the grid after every apply, so the live realigns of
109
- * an index-decorated overlay take this branch). Null when the rows are off
110
- * the grid prefix: the general walk decides.
139
+ * The aligned rows of a row set that already sits on the main grid in order
140
+ * (every row an array with a finite time on a grid slot, each row on a later
141
+ * slot than the one before, the grid strictly increasing): a dense window and
142
+ * a sparse decorator, marker or label set alike. One merge over the grid puts
143
+ * the very row object on its slot and a NaN filler of the widest payload on
144
+ * every other slot; the rows themselves when they cover the grid. Exactly what
145
+ * the general walk below returns for such rows, without its per-call set and
146
+ * map. Null on any other shape (a time off the grid, an unsorted or repeated
147
+ * time, a non-array row, an unplaceable time, a grid that does not strictly
148
+ * increase): the general walk decides.
111
149
  */
112
- function alignRowsOnMainGridPrefix(rows, mainTimes) {
150
+ function alignRowsOnMainGrid(rows, mainTimes) {
113
151
  if (rows.length > mainTimes.length || !mainTimesStrictlyIncrease(mainTimes))
114
152
  return null;
115
153
  let payloadWidth = 1;
116
- for (let index = 0; index < rows.length; index += 1) {
117
- const row = rows[index];
118
- if (!Array.isArray(row) || row[0] !== mainTimes[index])
154
+ // A first pass without allocation: the widest payload, and no filler is built for a set that falls back here.
155
+ for (const row of rows) {
156
+ if (!Array.isArray(row) || !Number.isFinite(row[0]))
119
157
  return null;
120
158
  payloadWidth = Math.max(payloadWidth, row.length - 1);
121
159
  }
122
- if (rows.length === mainTimes.length)
123
- return rows;
124
- const aligned = rows.slice();
125
- for (let index = rows.length; index < mainTimes.length; index += 1) {
126
- aligned.push([mainTimes[index], ...Array.from({ length: payloadWidth }, () => Number.NaN)]);
160
+ const placed = rows;
161
+ const aligned = [];
162
+ let next = 0;
163
+ for (let slot = 0; slot < mainTimes.length; slot += 1) {
164
+ const time = mainTimes[slot];
165
+ const rowTime = placed[next]?.[0];
166
+ if (rowTime === time)
167
+ aligned.push(placed[next++]);
168
+ // A row before this slot was on no slot at all, or out of order: the grid only grows from here.
169
+ else if (rowTime < time)
170
+ return null;
171
+ else
172
+ aligned.push([time, ...Array.from({ length: payloadWidth }, () => Number.NaN)]);
127
173
  }
128
- return aligned;
174
+ if (next < rows.length)
175
+ return null;
176
+ return rows.length === mainTimes.length ? rows : aligned;
129
177
  }
130
178
  function alignRowsToMainChartIndex(rows, mainTimes, options = {}) {
131
179
  if (!Array.isArray(rows) || rows.length === 0 || mainTimes.length === 0)
132
180
  return rows;
133
- const onGrid = alignRowsOnMainGridPrefix(rows, mainTimes);
181
+ const onGrid = alignRowsOnMainGrid(rows, mainTimes);
134
182
  if (onGrid !== null)
135
183
  return onGrid;
136
- const mainTimeSet = new Set(mainTimes);
184
+ let mainTimeSet = mainTimeSets.get(mainTimes);
185
+ if (!mainTimeSet)
186
+ mainTimeSets.set(mainTimes, (mainTimeSet = new Set(mainTimes)));
137
187
  const rowsByTime = new Map();
138
188
  let finiteRows = 0;
139
189
  let matchedRows = 0;
@@ -322,10 +372,10 @@ function padContinuousKScriptOutputTreeGaps(output, mainTimes) {
322
372
  function padContinuousKScriptOutputGapsOnMainGrid(runResult, tc) {
323
373
  if (!outputTreeHasContinuousGapPadPlot(runResult))
324
374
  return runResult;
325
- const mainTimes = mainChartTimesForKScriptIndexAlignment(tc);
326
- if (mainTimes.length === 0)
375
+ const barTimes = mainChartBarTimesForKScriptGapPad(tc);
376
+ if (barTimes.length === 0)
327
377
  return runResult;
328
- return padContinuousKScriptOutputTreeGaps(runResult, mainTimes);
378
+ return padContinuousKScriptOutputTreeGaps(runResult, barTimes);
329
379
  }
330
380
  export { alignKScriptIndexDecoratorsToMainChart, padContinuousKScriptOutputGapsOnMainGrid,
331
381
  // The adapter's own steps read these too (the mounted realign, the run-interval projection, the live tail view).
@@ -63,6 +63,12 @@ export const KSCRIPT_RESERVED_PROVENANCE_KEYS = new Set([
63
63
  // as a plane script and the console marks its output, so a same-named input
64
64
  // must never clear it.
65
65
  'metaCmeExchange',
66
+ // The pane place (PANES-ANY-SIDE, pane-place.util `panePlace`): where the
67
+ // script's own pane sits (Top, Bottom, Clean, Left, Right). A package param
68
+ // of this name must never move or reshape its own pane, and the place must
69
+ // never save over a same-named input. The control carries it by name
70
+ // through every rebuild (restampPanePlace).
71
+ 'panePlace',
66
72
  ]);
67
73
  export function isReservedKScriptProvenanceKey(name) {
68
74
  return typeof name === 'string' && KSCRIPT_RESERVED_PROVENANCE_KEYS.has(name);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The name a mounted script row goes by on the chart, decided at every apply before the result reaches the engine.
3
+ *
4
+ * The engine names an overlay from the result it applies (`meta.name = define.title`) and paints the legend title
5
+ * from that in the same apply. The row's own name is `settings.customName`: a user's rename, or the name its mount
6
+ * stamped. The adapter's engine doors (kscript-titancharts-integration.util `withKScriptRowTitle`) are the ONE place
7
+ * that reads it, from the row as it is at that apply: a run and its live session carry the package's own title, never
8
+ * a row's name, so a rename or a clear (a save that schedules no run) shows at the next apply, a live tick included.
9
+ * The legend then equals what the Objects panel lists (`meta.name`). The name is display only: no record, saved
10
+ * package name or identity key is written from it.
11
+ */
12
+ /** The row's own name: `settings.customName` when it is a non-blank string, else undefined (a cleared rename). */
13
+ export declare function kScriptRowOwnName(settings: unknown): string | undefined;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The name a mounted script row goes by on the chart, decided at every apply before the result reaches the engine.
3
+ *
4
+ * The engine names an overlay from the result it applies (`meta.name = define.title`) and paints the legend title
5
+ * from that in the same apply. The row's own name is `settings.customName`: a user's rename, or the name its mount
6
+ * stamped. The adapter's engine doors (kscript-titancharts-integration.util `withKScriptRowTitle`) are the ONE place
7
+ * that reads it, from the row as it is at that apply: a run and its live session carry the package's own title, never
8
+ * a row's name, so a rename or a clear (a save that schedules no run) shows at the next apply, a live tick included.
9
+ * The legend then equals what the Objects panel lists (`meta.name`). The name is display only: no record, saved
10
+ * package name or identity key is written from it.
11
+ */
12
+ /** The row's own name: `settings.customName` when it is a non-blank string, else undefined (a cleared rename). */
13
+ export function kScriptRowOwnName(settings) {
14
+ if (settings === null || typeof settings !== 'object')
15
+ return undefined;
16
+ const customName = settings.customName;
17
+ return typeof customName === 'string' && customName.trim() !== '' ? customName : undefined;
18
+ }