@orangecharts/wrun-chart-host 0.14.0 → 0.16.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 (197) hide show
  1. package/README.md +1 -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 +11 -0
  5. package/dist/constants/feature-flags.constants.js +56 -4
  6. package/dist/constants/feature-limits.constants.d.ts +72 -4
  7. package/dist/constants/feature-limits.constants.js +98 -20
  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/typed-width-fold.leaf.d.ts +50 -0
  12. package/dist/constants/typed-width-fold.leaf.js +99 -0
  13. package/dist/constants/typed-width-source.leaf.d.ts +24 -0
  14. package/dist/constants/typed-width-source.leaf.js +126 -0
  15. package/dist/constants/typed-width.leaf.d.ts +57 -0
  16. package/dist/constants/typed-width.leaf.js +78 -0
  17. package/dist/host-env.d.ts +24 -0
  18. package/dist/host-env.js +22 -0
  19. package/dist/host-ports.types.d.ts +11 -0
  20. package/dist/index.d.ts +4 -0
  21. package/dist/index.js +4 -0
  22. package/dist/interfaces/kscript-diagnostics.interface.d.ts +28 -0
  23. package/dist/interfaces/wrun-runtime.interface.d.ts +107 -4
  24. package/dist/interfaces/wrun-runtime.interface.js +11 -0
  25. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
  26. package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
  27. package/dist/market-data/billing.interface.d.ts +12 -45
  28. package/dist/market-data/billing.interface.js +2 -2
  29. package/dist/market-data/venues/index.d.ts +2 -2
  30. package/dist/market-data/venues/opra.js +3 -3
  31. package/dist/market-data/venues/stocks.contract.copy.json +3 -2
  32. package/dist/market-data/venues/stocks.d.ts +2 -2
  33. package/dist/market-data/venues/stocks.js +10 -9
  34. package/dist/replay/replayLadder.js +7 -4
  35. package/dist/settings-templates/footprint-rows.d.ts +6 -0
  36. package/dist/settings-templates/footprint-rows.js +6 -0
  37. package/dist/settings-templates/frvp-fields.js +14 -0
  38. package/dist/settings-templates/indicator-fields.js +46 -0
  39. package/dist/settings-templates/tool-tables.generated.js +19 -1
  40. package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
  41. package/dist/utility/chart/cache-alignment.util.d.ts +65 -0
  42. package/dist/utility/chart/cache-alignment.util.js +124 -24
  43. package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
  44. package/dist/utility/chart/calendar-interval.util.js +152 -4
  45. package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
  46. package/dist/utility/chart/candle-bar-end.util.js +17 -6
  47. package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
  48. package/dist/utility/chart/chart-time-domain.util.js +13 -4
  49. package/dist/utility/chart/feed-interval.util.d.ts +4 -2
  50. package/dist/utility/chart/feed-interval.util.js +5 -2
  51. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
  52. package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
  53. package/dist/utility/chart/footprint-band.util.d.ts +21 -5
  54. package/dist/utility/chart/footprint-band.util.js +53 -14
  55. package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
  56. package/dist/utility/chart/footprint-display-mode.util.js +5 -0
  57. package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
  58. package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
  59. package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
  60. package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
  61. package/dist/utility/chart/history-wall.util.d.ts +13 -2
  62. package/dist/utility/chart/history-wall.util.js +11 -4
  63. package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
  64. package/dist/utility/chart/interval-ladder.util.js +44 -4
  65. package/dist/utility/chart/interval-registry.util.d.ts +22 -1
  66. package/dist/utility/chart/interval-registry.util.js +50 -2
  67. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
  68. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
  69. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
  70. package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
  71. package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
  72. package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
  73. package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
  74. package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
  75. package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
  76. package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
  77. package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
  78. package/dist/utility/chart/live-bucket.util.d.ts +29 -4
  79. package/dist/utility/chart/live-bucket.util.js +45 -12
  80. package/dist/utility/chart/market-session.util.d.ts +62 -10
  81. package/dist/utility/chart/market-session.util.js +93 -13
  82. package/dist/utility/chart/marketKind.util.d.ts +1 -7
  83. package/dist/utility/chart/marketKind.util.js +6 -8
  84. package/dist/utility/chart/mixed-mode.util.d.ts +17 -0
  85. package/dist/utility/chart/om-target.util.js +6 -4
  86. package/dist/utility/chart/price-precision.util.d.ts +20 -6
  87. package/dist/utility/chart/price-precision.util.js +34 -7
  88. package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
  89. package/dist/utility/chart/profile-frame-window.util.js +12 -0
  90. package/dist/utility/chart/rth-session.util.d.ts +3 -1
  91. package/dist/utility/chart/rth-session.util.js +3 -1
  92. package/dist/utility/chart/script-source-session.util.d.ts +43 -0
  93. package/dist/utility/chart/script-source-session.util.js +61 -0
  94. package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
  95. package/dist/utility/chart/typed-width-grid.util.js +203 -0
  96. package/dist/utility/chart/wrun-run-result.util.d.ts +9 -1
  97. package/dist/utility/chart/wrun-run-result.util.js +8 -2
  98. package/dist/utility/common/transformations.util.d.ts +6 -0
  99. package/dist/utility/common/transformations.util.js +28 -4
  100. package/dist/utility/number-format.util.d.ts +14 -1
  101. package/dist/utility/number-format.util.js +22 -4
  102. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
  103. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +113 -0
  104. package/dist/utility/v2/v2-enums.leaf.js +3 -0
  105. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +15 -5
  106. package/dist/utility/wrun/wrun-batched-marks.util.js +70 -20
  107. package/dist/utility/wrun/wrun-canvases.util.d.ts +28 -9
  108. package/dist/utility/wrun/wrun-canvases.util.js +99 -39
  109. package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
  110. package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
  111. package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
  112. package/dist/utility/wrun/wrun-card-style.util.js +2 -2
  113. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +8 -0
  114. package/dist/utility/wrun/wrun-chart-market-facts.util.js +13 -1
  115. package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
  116. package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
  117. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
  118. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
  119. package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
  120. package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
  121. package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
  122. package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
  123. package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
  124. package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
  125. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
  126. package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
  127. package/dist/utility/wrun/wrun-frames.d.ts +1 -1
  128. package/dist/utility/wrun/wrun-frames.js +2 -2
  129. package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
  130. package/dist/utility/wrun/wrun-handles.util.js +1 -1
  131. package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
  132. package/dist/utility/wrun/wrun-host.service.js +44 -2
  133. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
  134. package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
  135. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
  136. package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
  137. package/dist/utility/wrun/wrun-hover.util.d.ts +8 -2
  138. package/dist/utility/wrun/wrun-hover.util.js +24 -13
  139. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
  140. package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
  141. package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
  142. package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
  143. package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
  144. package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
  145. package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
  146. package/dist/utility/wrun/wrun-live-tick.util.js +81 -19
  147. package/dist/utility/wrun/wrun-output-words.util.d.ts +14 -0
  148. package/dist/utility/wrun/wrun-output-words.util.js +51 -0
  149. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +41 -0
  150. package/dist/utility/wrun/wrun-overlay-drivers.util.js +35 -0
  151. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +6 -1
  152. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  153. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +23 -2
  154. package/dist/utility/wrun/wrun-overlay-run.util.js +305 -51
  155. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +10 -2
  156. package/dist/utility/wrun/wrun-panel-mount.util.js +144 -18
  157. package/dist/utility/wrun/wrun-pin-venues.util.js +5 -1
  158. package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
  159. package/dist/utility/wrun/wrun-refusal.util.js +102 -13
  160. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  161. package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
  162. package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
  163. package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
  164. package/dist/utility/wrun/wrun-run-health.util.d.ts +6 -3
  165. package/dist/utility/wrun/wrun-run-health.util.js +5 -2
  166. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
  167. package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
  168. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +25 -8
  169. package/dist/utility/wrun/wrun-script-inputs.util.js +145 -45
  170. package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
  171. package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
  172. package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
  173. package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
  174. package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
  175. package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
  176. package/dist/utility/wrun/wrun-style-names.util.d.ts +23 -0
  177. package/dist/utility/wrun/wrun-style-names.util.js +74 -0
  178. package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
  179. package/dist/utility/wrun/wrun-style-words.util.js +46 -15
  180. package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
  181. package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
  182. package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
  183. package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
  184. package/dist/utility/wrun-display-name.util.d.ts +10 -0
  185. package/dist/utility/wrun-display-name.util.js +21 -0
  186. package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
  187. package/dist/utils/replay/replay-buffer-math.js +2 -0
  188. package/dist/workers/constants/socket-slots.d.ts +1 -1
  189. package/dist/workers/utils/time.worker.util.js +2 -2
  190. package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
  191. package/dist/workers/utils/volume-profile.worker.util.js +20 -0
  192. package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
  193. package/dist/workers/wrun/wrun-abi-host.js +82 -5
  194. package/dist/workers/wrun/wrun-engine-handler.js +53 -4
  195. package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
  196. package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
  197. package/package.json +11 -11
@@ -257,6 +257,15 @@ function payloadTransportFor(module, payloadSettings, owner) {
257
257
  };
258
258
  };
259
259
  }
260
+ /** Two batches' governed-plane marks joined (`WrunRowBatch.governed`): every plane either names, the later batch's
261
+ * receipt where both name one. Undefined while neither names any. */
262
+ function wrunGovernedJoined(earlier, later) {
263
+ if (earlier === undefined)
264
+ return later;
265
+ if (later === undefined)
266
+ return earlier;
267
+ return { ...earlier, ...later };
268
+ }
260
269
  /** The whole window a session spans (both bounds open). */
261
270
  const WRUN_SOCKET_SESSION_WINDOW = { fromMs: Number.NEGATIVE_INFINITY, toMs: Number.POSITIVE_INFINITY };
262
271
  /** The bars a window without finite bounds asks for: the replay lane's window through its cutoff while the chart
@@ -329,7 +338,14 @@ class SocketWrunRowSourceAdapter {
329
338
  catch (error) {
330
339
  throw this.module !== undefined ? this.module.wrunSocketPagingFailure(error) : error;
331
340
  }
332
- return created.sheet !== undefined && whole.sheet === undefined ? { ...whole, sheet: created.sheet } : whole;
341
+ // The run's governed-plane mark is kept across the create-then-range paging: every plane the create's answer named
342
+ // rides the paged batch too (the source's mark is sticky for the run; this keeps it whatever the page answered).
343
+ const governed = wrunGovernedJoined(created.governed, whole.governed);
344
+ return {
345
+ ...whole,
346
+ ...(created.sheet !== undefined && whole.sheet === undefined ? { sheet: created.sheet } : {}),
347
+ ...(governed !== undefined ? { governed } : {}),
348
+ };
333
349
  }
334
350
  async range(window) {
335
351
  const source = await this.loaded();
@@ -21,7 +21,7 @@
21
21
  * lanes; no source carries a sentence. A refused family leaves the sheet the batch delivered
22
22
  * (`wrunRowBatchDeliveredSheet`, the one rule the pass reads every batch by).
23
23
  */
24
- import type { WrunHostedGrid, WrunHostedRefusal, WrunHostedWire } from './wrun-hosted-wire.util.js';
24
+ import type { WrunGovernedMark, WrunHostedGrid, WrunHostedRefusal, WrunHostedWire } from './wrun-hosted-wire.util.js';
25
25
  import type { WrunOpraServedReceipt } from './wrun-opra-lane.util.js';
26
26
  import type { RuntimeDiagnostic } from '../../interfaces/kscript-diagnostics.interface.js';
27
27
  import type { WrunIndicatorMetadata } from '../../interfaces/wrun-runtime.interface.js';
@@ -89,6 +89,13 @@ export interface WrunRowBatch {
89
89
  * batch the session's newest receipt (absent once a result names no OPRA read, or no tier); on a live frame, the
90
90
  * frame's own, present only when it carried the mark and a tier. Absent: no tier word, never the account's tier. */
91
91
  opraServed?: WrunOpraServedReceipt;
92
+ /** The cloud run's governed-plane mark (the governed-lanes cutover's cross-repo contract, the hosted reply's
93
+ * `output.wrunGoverned`): one entry per governed plane (`cme`, `stocks`) the run read. Its `cme` entry stamps the
94
+ * overlay's CME provenance before any row lands (wrun-cloud-cme-stamp.util): no CME-derived row reaches Kata or any
95
+ * AI feature. Sticky for the run: once a batch or a frame of a run carried a plane, every later batch and frame of
96
+ * that run carries it (paging, re-range, reconnect). Fail closed: a mark the source could not read names every
97
+ * plane. Absent from a source that does not speak it (the browser lanes stamp their own runs). */
98
+ governed?: WrunGovernedMark;
92
99
  /** On a live frame only, with no rows: the cloud served the session's OPRA rows at another tier than the rows the
93
100
  * session held (a downgrade or an upgrade of the owner's tier, the receipt's transition). The source dropped
94
101
  * every row it held, its coverage and its run-level keys; the overlay takes its rows off the chart, ends its live
@@ -140,11 +140,14 @@ export interface WrunRunHealth {
140
140
  warmup: number;
141
141
  /** Continuous plots that are NaN (or never finite) on every ready row, in slot order. */
142
142
  silentOutputs: string[];
143
- /** The display label of each silent output by name (the declared `label`, else the name read
144
- * as words): present only while an output is silent. */
143
+ /** The display label of each silent output by name, the words the chart's surfaces name it by
144
+ * (wrun-output-words.util wrunOutputWords: the declared `label`, else the name read as words; a
145
+ * built-in port's line in its built-in's words): present only while an output is silent. */
145
146
  labels?: Readonly<Record<string, string>>;
146
147
  }
147
- export declare function wrunRunHealth(metadata: Pick<WrunIndicatorMetadata, 'outputs'>, rows: ReadonlyArray<WrunOutputRow>): WrunRunHealth;
148
+ /** The run's health over `rows`; `builtIn` is the built-in the overlay ports (builtinPortOf over
149
+ * its settings), whose words name a silent line it names (absent: the sheet's words). */
150
+ export declare function wrunRunHealth(metadata: Pick<WrunIndicatorMetadata, 'outputs'>, rows: ReadonlyArray<WrunOutputRow>, builtIn?: string): WrunRunHealth;
148
151
  /** True when two health row sets state the same verdicts (a live session recomputing its
149
152
  * health on every tick republishes only when the verdict changes, never for a bar count). */
150
153
  export declare function sameWrunRunHealthVerdict(current: ReadonlyArray<RuntimeDiagnostic>, next: ReadonlyArray<RuntimeDiagnostic>): boolean;
@@ -1,5 +1,6 @@
1
1
  import { wrunLegendName } from '../chart/wrun-legend-name.util.js';
2
2
  import { isWrunLegStreamClass } from './wrun-leg-stream-classes.js';
3
+ import { wrunOutputWords } from './wrun-output-words.util.js';
3
4
  import { WRUN_VISIBILITY_RULES, wrunOutputDraw } from './wrun-visibility-table.js';
4
5
  import { attachWrunRefusal, wrunOptionsStopSeed, wrunRefusalFor, } from './wrun-refusal.util.js';
5
6
  export const WRUN_NO_READY_ROWS_CODE = 'WRUN_NO_READY_ROWS';
@@ -182,7 +183,9 @@ export function wrunUnservedLegDiagnostics(legs, ctx) {
182
183
  /** Plots that draw a value on every ready bar; a sheet output with no `plot` draws a line. */
183
184
  const CONTINUOUS_PLOTS = new Set(['line', 'area', 'histogram', 'bar']);
184
185
  const DEFAULT_PLOT = 'line';
185
- export function wrunRunHealth(metadata, rows) {
186
+ /** The run's health over `rows`; `builtIn` is the built-in the overlay ports (builtinPortOf over
187
+ * its settings), whose words name a silent line it names (absent: the sheet's words). */
188
+ export function wrunRunHealth(metadata, rows, builtIn) {
186
189
  const outputs = Array.isArray(metadata?.outputs) ? metadata.outputs : [];
187
190
  const watched = outputs.filter((output) => CONTINUOUS_PLOTS.has(output.plot ?? DEFAULT_PLOT) &&
188
191
  output.legend !== false &&
@@ -210,7 +213,7 @@ export function wrunRunHealth(metadata, rows) {
210
213
  warmup: rows.length - ready,
211
214
  silentOutputs: silent.map((output) => output.name),
212
215
  ...(silent.length > 0
213
- ? { labels: Object.fromEntries(silent.map((output) => [output.name, wrunLegendName(output.name, output.label)])) }
216
+ ? { labels: Object.fromEntries(silent.map((output) => [output.name, wrunOutputWords(output, builtIn)])) }
214
217
  : {}),
215
218
  };
216
219
  }
@@ -32,7 +32,7 @@
32
32
  * registry and dedupe table.
33
33
  */
34
34
  import type { WrunChartHandle } from '../../host-ports.types.js';
35
- import type { WrunIndicatorMetadata, WrunModuleHandle, WrunOutputRow } from '../../interfaces/wrun-runtime.interface.js';
35
+ import { type WrunIndicatorMetadata, type WrunModuleHandle, type WrunOutputRow } from '../../interfaces/wrun-runtime.interface.js';
36
36
  import type { WrunCellRows } from './wrun-canvases.util.js';
37
37
  import { type WrunStrategyRunInput } from './wrun-host.service.js';
38
38
  import { type WrunInputRow } from './wrun-pack.util.js';
@@ -33,6 +33,8 @@
33
33
  */
34
34
  import { ensureWrunChartHostSharedHost, wrunChartHostEnv } from '../../host-env.js';
35
35
  import { KSCRIPT_STALLED_CODE } from '../../constants/scriptEditor/execution.constants.js';
36
+ import { wrunTrapOf, } from '../../interfaces/wrun-runtime.interface.js';
37
+ import { attachWrunTrapSeed } from './wrun-trap-replay.util.js';
36
38
  import { isWrunBandedBookSource } from './wrun-book-bands.leaf.js';
37
39
  import { wrunHandlesOf } from './wrun-handles.util.js';
38
40
  import { getWrunBrowserHost } from './wrun-host.service.js';
@@ -335,9 +337,12 @@ export class SandboxWrunRowSource {
335
337
  // The session lock this call's live open holds (released by the landing, or below on a failure).
336
338
  let release;
337
339
  let epoch;
340
+ // What the editor's trap replay needs from the plan (declared inside the try): the request and the live flag.
341
+ let seed;
338
342
  try {
339
343
  this.assertStanding(indicatorId);
340
344
  const plan = await this.host.prepare(window, record);
345
+ seed = { request: plan.request, live: plan.live };
341
346
  this.assertStanding(indicatorId);
342
347
  let rows;
343
348
  if (plan.live) {
@@ -378,6 +383,10 @@ export class SandboxWrunRowSource {
378
383
  release();
379
384
  }
380
385
  this.lowerHold(hold);
386
+ // A trap in this full run or live start: the replay's seed rides the rejection (references only).
387
+ const trap = wrunTrapOf(error);
388
+ if (seed !== undefined && trap !== undefined)
389
+ attachWrunTrapSeed(error, seed, trap);
381
390
  throw error;
382
391
  }
383
392
  }
@@ -83,7 +83,16 @@
83
83
  * and wrun-style-patch.util; a `colors` row and a prefixed target's rows
84
84
  * repaint through a rerun). A cloud record mounts the same rows (the registry
85
85
  * loader builds both lanes' records here, over the full sheet): the one pass
86
- * paints either row source's batch through the chart's own builders.
86
+ * paints either row source's batch through the chart's own builders. The
87
+ * page's words for a batched section or a renderer come first from the
88
+ * sheet's `style_names` table (wrun-style-names.util, the one reader): its
89
+ * label titles the line (styleTargetTitle) and its colour names name each
90
+ * swatch of the line's colours row (`swatchNames`). Its entry for an output
91
+ * or a heatmap names colours alone (the title stays their own `label`): a
92
+ * heatmap's palette stops, an output's two-tone pair, and a `color_by` ladder
93
+ * whose every rung it names, which gains a colours row even where an unnamed
94
+ * ladder has none (three or more rungs, a line's, an inset strip's:
95
+ * outputColorList). A sheet without the table reads as before.
87
96
  *
88
97
  * The layout (buildWrunScriptLayout) groups the flat rows into pages and
89
98
  * sections: from the sheet's `layout` when it declares one (params before
@@ -210,6 +219,11 @@ export interface WrunScriptInputDeclaration {
210
219
  };
211
220
  /** A `colors` style row: what each swatch paints, in value order. */
212
221
  swatches?: WrunStyleSwatch[];
222
+ /** A `colors` style row the sheet's `style_names` table names (wrun-style-names.util): one plain name per swatch, in
223
+ * value order, as long as `swatches`. Slots that share a name are one swatch on the page whose pick writes every
224
+ * one of them (wrun-dialog-rows wrunSwatchViews); a named swatch's hover title is its name. Absent while the table
225
+ * names none of the row's slots, so an unnamed row is exactly what it always was. */
226
+ swatchNames?: string[];
213
227
  /** A text row (wrun-5): the UTF-8 byte cap the field enforces and whether
214
228
  * it takes several lines (a text area; newlines survive). Carried on the
215
229
  * row so the dialog and the hosted lanes know them without the sheet. */
@@ -260,7 +274,7 @@ export interface WrunScriptLayout {
260
274
  * visibility table lists (the Style rows' targets, wrun-visibility-table.ts
261
275
  * WrunVisibilitySheet: no list of its own here), input sources (host
262
276
  * bindings), layout and presets when present. */
263
- export type WrunScriptInputsSheet = Pick<WrunIndicatorMetadata, 'params'> & WrunVisibilitySheet & Partial<Pick<WrunIndicatorMetadata, 'inputSources' | 'layout' | 'presets'>>;
277
+ export type WrunScriptInputsSheet = Pick<WrunIndicatorMetadata, 'params'> & WrunVisibilitySheet & Partial<Pick<WrunIndicatorMetadata, 'inputSources' | 'layout' | 'presets' | 'style_names'>>;
264
278
  /**
265
279
  * The words a settings row prints: its label verbatim (an author's words are
266
280
  * never re-cased: "ATRs" stays "ATRs"), else the name read as words. A label
@@ -341,12 +355,15 @@ export declare function wrunRowSettingReader(rows: ReadonlyArray<WrunScriptInput
341
355
  * its label and hint from that build, matched by name (a unit composite and
342
356
  * its value member, which share a name, each from its own kind). An older
343
357
  * build stamped a param's description as its label and no hint; the saved
344
- * indicator reads the same as a fresh add without a rerun. Values, types and
345
- * every other key stay as persisted; a style row (its label is its property
346
- * key) and a row the sheet no longer builds keep their own; a row whose
347
- * words already match is returned as is. `options` builds the words as the
348
- * mount did (a port's hint rule, WrunRowBuildOptions), so a row persisted
349
- * before the rule reads without its encoding legend.
358
+ * indicator reads the same as a fresh add without a rerun. A style row keeps
359
+ * its label (its property key) and takes the swatch names the sheet's
360
+ * `style_names` table gives its colours now (`swatchNames`, or none), so a
361
+ * row persisted before the table names its swatches as a fresh add does.
362
+ * Values, types and every other key stay as persisted; a row the sheet no
363
+ * longer builds keeps its own; a row whose words already match is returned
364
+ * as is. `options` builds the words as the mount did (a port's hint rule,
365
+ * WrunRowBuildOptions), so a row persisted before the rule reads without its
366
+ * encoding legend.
350
367
  */
351
368
  export declare function wrunRowsWithSheetWords(rows: ReadonlyArray<WrunScriptInputDeclaration>, sheet: WrunScriptInputsSheet | undefined, options?: WrunRowBuildOptions): WrunScriptInputDeclaration[];
352
369
  /**
@@ -83,7 +83,16 @@
83
83
  * and wrun-style-patch.util; a `colors` row and a prefixed target's rows
84
84
  * repaint through a rerun). A cloud record mounts the same rows (the registry
85
85
  * loader builds both lanes' records here, over the full sheet): the one pass
86
- * paints either row source's batch through the chart's own builders.
86
+ * paints either row source's batch through the chart's own builders. The
87
+ * page's words for a batched section or a renderer come first from the
88
+ * sheet's `style_names` table (wrun-style-names.util, the one reader): its
89
+ * label titles the line (styleTargetTitle) and its colour names name each
90
+ * swatch of the line's colours row (`swatchNames`). Its entry for an output
91
+ * or a heatmap names colours alone (the title stays their own `label`): a
92
+ * heatmap's palette stops, an output's two-tone pair, and a `color_by` ladder
93
+ * whose every rung it names, which gains a colours row even where an unnamed
94
+ * ladder has none (three or more rungs, a line's, an inset strip's:
95
+ * outputColorList). A sheet without the table reads as before.
87
96
  *
88
97
  * The layout (buildWrunScriptLayout) groups the flat rows into pages and
89
98
  * sections: from the sheet's `layout` when it declares one (params before
@@ -108,6 +117,7 @@ import { isWrunColorWord, wrunThemeTokenOfPacked, wrunThemeTokenWord } from './w
108
117
  import { isWrunColorParam, isWrunStyleParam, wrunColorArrayKey, wrunColorPalette, wrunColorParamDefault, wrunColorSettingString, wrunLineStyles, wrunParamChoices, wrunSelectOptionValue, wrunStyleBinding, parseWrunStyleTarget, wrunVisibilityOwnedOutputs, wrunVisibilityOwners, } from './wrun-color-settings.util.js';
109
118
  import { findWrunVisibilityTarget, WRUN_HANDLE_KIND_RULES, WRUN_VISIBILITY_RULES, wrunVisibilityEntryTarget, wrunVisibilityTargetAt, } from './wrun-visibility-table.js';
110
119
  import { isTruthySetting, wrunCodedWords } from './wrun-setting-words.util.js';
120
+ import { wrunStyleNameOf, wrunStyleSlotNames, wrunStyleTitle } from './wrun-style-names.util.js';
111
121
  import { wrunRowVisibleHere, wrunVisibleBySettingKeys } from './wrun-market-facts.util.js';
112
122
  import { bitmaskValue, finiteNumber, nonEmptyString, numericValue, toggleValue, wrunMultiLabels, wrunTimeValue, } from './wrun-param-values.util.js';
113
123
  import { wrunLegendLiteral, wrunTextParamCap, wrunTextParamDefault, wrunTextValueWithinCap, } from './wrun-text-params.util.js';
@@ -431,6 +441,40 @@ function twoTonePair(output, kind) {
431
441
  return colors.length === 2 ? [...colors] : undefined;
432
442
  return colors.length >= 2 ? colors.slice(0, 2) : undefined;
433
443
  }
444
+ /**
445
+ * The colour list an output's `colors` Style row recolours (contract C1), as declared:
446
+ * - a bar's two-tone pair (twoTonePair), named or not: its sign palette's up and down swatches, or its two-rung
447
+ * ladder's rungs;
448
+ * - any other list the run-result adapter paints from the output's own `colors`, only where the sheet's
449
+ * `style_names` table names every one of its slots: a `color_by` ladder of any length on an output that styles (a
450
+ * bar's of three or more rungs, a line's, a mark's: the adapter's ladder reads it whole) or on an inset strip
451
+ * (wrunInsetLook: its ladder's palette, else its sign pair, up then down). Unnamed, its swatches could say only
452
+ * "Color n", so the page offers no row for it, as before the table.
453
+ * Undefined for anything else: a packed per-bar colour, a list holding a word that is no colour, a candle tint.
454
+ */
455
+ function outputColorList(metadata, output, kind) {
456
+ const namesOf = (colors) => wrunStyleSlotNames(wrunStyleNameOf(metadata, output.name), colors.length);
457
+ const ladder = output.color_by !== undefined;
458
+ const pair = kind === undefined ? undefined : twoTonePair(output, kind);
459
+ if (pair !== undefined) {
460
+ const names = namesOf(pair);
461
+ const swatches = ladder ? ['stop', 'stop'] : ['up', 'down'];
462
+ return { colors: pair, swatches, ...(names !== undefined ? { names } : {}) };
463
+ }
464
+ const inset = output.plot === 'inset';
465
+ if (kind === undefined && !inset)
466
+ return undefined;
467
+ if (output.color_packed_by !== undefined || !Array.isArray(output.colors))
468
+ return undefined;
469
+ const declared = output.colors;
470
+ if (!declared.every((color) => nonEmptyString(color) !== undefined))
471
+ return undefined;
472
+ const colors = ladder ? [...declared] : inset && declared.length >= 2 ? declared.slice(0, 2) : [];
473
+ const names = colors.length === 0 ? undefined : namesOf(colors);
474
+ if (names === undefined)
475
+ return undefined;
476
+ return { colors, swatches: ladder ? colors.map(() => 'stop') : ['up', 'down'], names };
477
+ }
434
478
  /** True when a line strokes colours of its own and never reads its static
435
479
  * `color` (style-rows audit item 3): two or more OT13 `gradient` stops (the
436
480
  * look patch lays them as `gradientColors`, wrun-output-style.util) or an
@@ -457,16 +501,17 @@ function strokesOwnColors(output) {
457
501
  * stops, an OT14 split's up / down pair; style-rows audit item 3), whose
458
502
  * width, lineStyle and opacity rows stay; never on a candle group (its
459
503
  * colours are a pair).
460
- * - `colors`: a bar's two-tone pair (twoTonePair) in place of `color`: the
461
- * up and down swatches of its sign palette, or the two rungs of its
462
- * ladder.
504
+ * - `colors` (`hasColors`, outputColorList): a bar's two-tone pair
505
+ * (twoTonePair) in place of `color`: the up and down swatches of its sign
506
+ * palette, or the two rungs of its ladder; and a `color_by` ladder of any
507
+ * other length or kind whose every rung the sheet's `style_names` names.
463
508
  * - `opacity`: it folds into the static colour (a gradient's stops and a
464
509
  * split's pair alike) and an area's fill tint, so an area always carries
465
510
  * it, a bar when its static colour paints, and a line or mark only when
466
511
  * the sheet declares one (a declared opacity REPLACES the picked colour's
467
512
  * alpha, so it needs its own control).
468
513
  */
469
- function stylePropertiesOf(output, kind) {
514
+ function stylePropertiesOf(output, kind, hasColors) {
470
515
  const staticColor = kind !== 'candle' &&
471
516
  output.color_by === undefined &&
472
517
  output.color_packed_by === undefined &&
@@ -478,7 +523,7 @@ function stylePropertiesOf(output, kind) {
478
523
  ...(staticWidth ? ['width'] : []),
479
524
  ...(kind === 'line' || kind === 'area' ? ['lineStyle'] : []),
480
525
  ...(staticColor && !strokesOwnColors(output) ? ['color'] : []),
481
- ...(twoTonePair(output, kind) !== undefined ? ['colors'] : []),
526
+ ...(hasColors ? ['colors'] : []),
482
527
  ...(opacity ? ['opacity'] : []),
483
528
  ];
484
529
  }
@@ -541,6 +586,10 @@ const WRUN_STYLE_KEYS = {
541
586
  ['width', 'width'],
542
587
  ['line_style', 'lineStyle'],
543
588
  ]),
589
+ // A flags section's colours by part (fill, edge, text): a colour param bound to them is that row.
590
+ flags: new Map([['colors', 'colors']]),
591
+ // Every batched kind is listed (the type below): each offers a colours row, so a param bound to its keys must take
592
+ // that row's place, or the page shows two controls over one colour (flags missed it until the dark pool round).
544
593
  };
545
594
  const WRUN_OUTPUT_STYLE_KEYS = WRUN_STYLE_KEYS.outputs;
546
595
  /** An output style property word in either spelling: the om binding's
@@ -673,7 +722,7 @@ function declaredStyleKnobs(metadata) {
673
722
  function undeclaredWidthOf(kind) {
674
723
  return kind === 'mark' ? 2 : 1;
675
724
  }
676
- function styleRowDefault(output, paletteAt, property, kind) {
725
+ function styleRowDefault(output, paletteAt, property, kind, colors) {
677
726
  switch (property) {
678
727
  case 'visible':
679
728
  return output.visible !== false;
@@ -688,7 +737,7 @@ function styleRowDefault(output, paletteAt, property, kind) {
688
737
  nonEmptyString(output.colors?.[0]) ??
689
738
  WRUN_OUTPUT_DEFAULT_PALETTE[paletteAt % WRUN_OUTPUT_DEFAULT_PALETTE.length]);
690
739
  case 'colors':
691
- return twoTonePair(output, kind) ?? [];
740
+ return colors?.colors ?? [];
692
741
  default: {
693
742
  const opacity = finiteNumber(output.opacity);
694
743
  return opacity !== undefined && opacity >= 0 && opacity <= 1 ? opacity : 1;
@@ -699,7 +748,7 @@ function styleRowDefault(output, paletteAt, property, kind) {
699
748
  * construction: no init slot, it writes only its target's colour(s) /
700
749
  * width / line_style / opacity through the paint seam, or its visibility
701
750
  * after integration. */
702
- function styleRowOf(target, property, defaultValue, swatches) {
751
+ function styleRowOf(target, property, defaultValue, swatches, swatchNames) {
703
752
  return {
704
753
  name: wrunStyleRowName(target, property),
705
754
  // The property key: the dialog draws the frozen localized word for it.
@@ -710,14 +759,18 @@ function styleRowOf(target, property, defaultValue, swatches) {
710
759
  ...(property === 'width' ? { constraints: { min: 0, max: 20, step: 0.5 } } : {}),
711
760
  ...(property === 'opacity' ? { constraints: { min: 0, max: 1, step: 0.05 } } : {}),
712
761
  ...(swatches !== undefined ? { swatches } : {}),
762
+ ...(swatchNames !== undefined ? { swatchNames } : {}),
713
763
  settingsTier: 'redraw',
714
764
  affectsCompute: false,
715
765
  styleOf: { output: target, property },
716
766
  };
717
767
  }
718
- function styleRow(output, paletteAt, property, kind) {
719
- const swatches = property !== 'colors' ? undefined : output.color_by !== undefined ? ['stop', 'stop'] : ['up', 'down'];
720
- return styleRowOf(output.name, property, styleRowDefault(output, paletteAt, property, kind), swatches);
768
+ /** One Style row of a drawn output; a `colors` row recolours its colour list (outputColorList), each swatch saying
769
+ * what it paints and carrying the sheet's name for it when the table names them. */
770
+ function styleRow(output, paletteAt, property, kind, colors) {
771
+ const list = property === 'colors' ? colors : undefined;
772
+ const defaultValue = styleRowDefault(output, paletteAt, property, kind, colors);
773
+ return styleRowOf(output.name, property, defaultValue, list?.swatches, list?.names);
721
774
  }
722
775
  /** A declared colour word, as written: a hex or rgb colour, or a theme
723
776
  * token (`theme.up`); anything else (a number, an `@param` the extractor
@@ -788,7 +841,9 @@ function undeclaredTextColorOf(renderer) {
788
841
  * records only feed another's tooltips (`tooltip_from`) never draws and is
789
842
  * no target; every other renderer kind (shape, bgcolor, barcolor, table,
790
843
  * stats_row, inset) offers Visible only;
791
- * - a heatmap (`heatmap:<name>`): its declared palette;
844
+ * - a heatmap (`heatmap:<name>`): its declared palette, each stop carrying
845
+ * the sheet's name for it when the `style_names` table names every one
846
+ * (`swatchNames`);
792
847
  * - a price profile (`profile:<name>`): its colours: a footprint's buy /
793
848
  * sell pair (theme up / down when undeclared, the canvas mount's rule)
794
849
  * wherever it paints: never on a cluster, ladder or imbalance_only grid of
@@ -809,17 +864,22 @@ function undeclaredTextColorOf(renderer) {
809
864
  * LOOK_DEFAULTS); a ray its width (default 1) and line style (default
810
865
  * solid) too. A flags section (`flags:<name>`) takes its colours alone (it
811
866
  * declares no opacity). Its look, size, caption and position take no row: a
812
- * param binds them (`style_targets`);
867
+ * param binds them (`style_targets`). Its colours row carries the sheet's
868
+ * name for each slot when the `style_names` table names every one
869
+ * (`swatchNames`, wrun-style-names.util wrunStyleSlotNames);
813
870
  * - a band (`range:<upper>/<lower>#<n>`, `fill:<first>/<second>#<n>`), a box,
814
871
  * a segment, a sheet drawing, a draw-API handle kind, a matrix and a panel:
815
872
  * Visible only (their colours ride params or the declaration).
816
873
  */
817
- function childStyleRows(targets, declared) {
874
+ function childStyleRows(metadata, targets, declared) {
818
875
  const rows = [];
819
- const add = (target, property, defaultValue, swatches) => {
820
- if (!declared.has(`${target}.${property}`))
821
- rows.push(styleRowOf(target, property, defaultValue, swatches));
876
+ const add = (target, property, defaultValue, swatches, swatchNames) => {
877
+ if (!declared.has(`${target}.${property}`)) {
878
+ rows.push(styleRowOf(target, property, defaultValue, swatches, swatchNames));
879
+ }
822
880
  };
881
+ // A batched or heatmap colours row's slot names: the table's, when it names every slot of the list (else none).
882
+ const slotNames = (target, colors) => wrunStyleSlotNames(wrunStyleNameOf(metadata, target), colors.length);
823
883
  const stops = (palette) => palette.map(() => 'stop');
824
884
  for (const { target, section, kind, entry } of targets) {
825
885
  if (section === 'outputs')
@@ -836,7 +896,7 @@ function childStyleRows(targets, declared) {
836
896
  case 'heatmaps': {
837
897
  const palette = paletteOf(entry.palette);
838
898
  if (palette !== undefined)
839
- add(target, 'colors', palette, stops(palette));
899
+ add(target, 'colors', palette, stops(palette), slotNames(target, palette));
840
900
  break;
841
901
  }
842
902
  case 'profiles': {
@@ -867,7 +927,7 @@ function childStyleRows(targets, declared) {
867
927
  const colors = batchedColorsOf(entry.colors);
868
928
  if (colors !== undefined) {
869
929
  const swatches = colors.map((_color, at) => section === 'marks' && at < 2 ? (at === 0 ? 'sell' : 'buy') : 'stop');
870
- add(target, 'colors', colors, swatches);
930
+ add(target, 'colors', colors, swatches, slotNames(target, colors));
871
931
  }
872
932
  const opacity = section === 'marks'
873
933
  ? (finiteNumber(entry.opacity_pct) ?? 30) / 100
@@ -883,7 +943,7 @@ function childStyleRows(targets, declared) {
883
943
  case 'flags': {
884
944
  const colors = batchedColorsOf(entry.colors);
885
945
  if (colors !== undefined)
886
- add(target, 'colors', colors, stops(colors));
946
+ add(target, 'colors', colors, stops(colors), slotNames(target, colors));
887
947
  break;
888
948
  }
889
949
  default:
@@ -975,8 +1035,9 @@ function drawnStyleOutputs(metadata, targets = wrunVisibilityTargets(metadata))
975
1035
  : []);
976
1036
  }
977
1037
  /** The style rows of a sheet's drawn targets (wrun-visibility-table.ts, in
978
- * its order): the outputs' rows, by how each draws (a candle tint and an
979
- * inset strip offer Visible only), then every other drawn target's
1038
+ * its order): the outputs' rows, by how each draws (a candle tint offers
1039
+ * Visible only, an inset strip Visible and the colours the sheet's
1040
+ * `style_names` names: outputColorList), then every other drawn target's
980
1041
  * (childStyleRows). */
981
1042
  function styleRows(metadata) {
982
1043
  const targets = wrunVisibilityTargets(metadata);
@@ -984,17 +1045,27 @@ function styleRows(metadata) {
984
1045
  const rows = [];
985
1046
  for (const { output, paletteAt, draw } of drawnStyleOutputs(metadata, targets)) {
986
1047
  const kind = draw.style;
987
- for (const property of kind === undefined ? ['visible'] : stylePropertiesOf(output, kind)) {
1048
+ const colors = outputColorList(metadata, output, kind);
1049
+ const properties = kind !== undefined
1050
+ ? stylePropertiesOf(output, kind, colors !== undefined)
1051
+ : colors !== undefined
1052
+ ? ['visible', 'colors']
1053
+ : ['visible'];
1054
+ for (const property of properties) {
988
1055
  if (declared.has(`${output.name}.${property}`))
989
1056
  continue;
990
1057
  // The output's `visible_by` rides its Style rows: where it mounts nothing, they hide.
991
- rows.push({ ...styleRow(output, paletteAt, property, kind ?? 'line'), ...wrunRowVisibleBy(output.visible_by) });
1058
+ const row = styleRow(output, paletteAt, property, kind ?? 'line', colors);
1059
+ rows.push({ ...row, ...wrunRowVisibleBy(output.visible_by) });
992
1060
  }
993
1061
  }
994
- rows.push(...childStyleRows(targets, declared));
1062
+ rows.push(...childStyleRows(metadata, targets, declared));
995
1063
  return rows;
996
1064
  }
997
- /** The sections whose readout `label` titles their Style line. */
1065
+ /** The sections whose own readout `label` titles their Style line where the sheet's `style_names` table gives none
1066
+ * (wrunStyleTitle's order; a heatmap's entry in the table names its colours alone, so a heatmap always reads its
1067
+ * own). A renderer's line takes the table's label or its name: a renderer key named `label` says something else and
1068
+ * titles nothing. */
998
1069
  const LABELLED_STYLE_SECTIONS = new Set(['heatmaps', 'marks', 'spans', 'rays', 'flags']);
999
1070
  /** A draw-API handle kind's Style line title, the dialog's English fallback
1000
1071
  * (WrunLayoutPanel localizes a handles section by its id). */
@@ -1011,12 +1082,16 @@ export function isWrunLocalizedStyleTarget(target) {
1011
1082
  }
1012
1083
  /** A style target as the Style page names it, the legend's rule
1013
1084
  * (wrunLegendName: a declared label, else the name read as words, `oi_change`
1014
- * -> "OI change"): an output by its `label`, a heatmap or a batched section by
1015
- * its readout `label`, a band by its sides' names (`Upper / Lower`; a range
1016
- * by its own `label` when it declares one; a second band over the same pair
1017
- * numbered), a sheet drawing by its name, a handle kind by its kind's word,
1018
- * anything else (a renderer, a profile, a docked level, a box, a segment, a
1019
- * matrix, a panel) by its name. */
1085
+ * -> "OI change"): an output by its own `label` (the sheet's `style_names`
1086
+ * names an output's colours, never its line), a band by its sides' names
1087
+ * (`Upper / Lower`; a range by its own `label` when it declares one; a second
1088
+ * band over the same pair numbered), a sheet drawing by its name, a handle
1089
+ * kind by its kind's word; anything else in the one order every surface
1090
+ * titles a drawn target by (wrun-style-names.util wrunStyleTitle): the
1091
+ * sheet's `style_names` label (a batched section, a renderer; a heatmap's
1092
+ * entry gives none), else a heatmap's or a batched section's readout
1093
+ * `label`, else the name (a renderer, a profile, a docked level, a box, a
1094
+ * segment, a matrix, a panel). */
1020
1095
  function styleTargetTitle(metadata, target) {
1021
1096
  const { kind, name } = parseWrunStyleTarget(target);
1022
1097
  const outputTitle = (output) => {
@@ -1041,7 +1116,7 @@ function styleTargetTitle(metadata, target) {
1041
1116
  return wrunLegendName(name.slice(name.indexOf(':') + 1));
1042
1117
  const found = findWrunVisibilityTarget(metadata, target);
1043
1118
  const labelled = found !== undefined && LABELLED_STYLE_SECTIONS.has(found.section) ? found.entry.label : undefined;
1044
- return wrunLegendName(name, typeof labelled === 'string' ? labelled : undefined);
1119
+ return wrunStyleTitle(metadata, target, name, labelled);
1045
1120
  }
1046
1121
  // ---------------------------------------------------------------------------
1047
1122
  // The flat list (the persistence whitelist).
@@ -1227,30 +1302,55 @@ function paramInput(param, base) {
1227
1302
  * its label and hint from that build, matched by name (a unit composite and
1228
1303
  * its value member, which share a name, each from its own kind). An older
1229
1304
  * build stamped a param's description as its label and no hint; the saved
1230
- * indicator reads the same as a fresh add without a rerun. Values, types and
1231
- * every other key stay as persisted; a style row (its label is its property
1232
- * key) and a row the sheet no longer builds keep their own; a row whose
1233
- * words already match is returned as is. `options` builds the words as the
1234
- * mount did (a port's hint rule, WrunRowBuildOptions), so a row persisted
1235
- * before the rule reads without its encoding legend.
1305
+ * indicator reads the same as a fresh add without a rerun. A style row keeps
1306
+ * its label (its property key) and takes the swatch names the sheet's
1307
+ * `style_names` table gives its colours now (`swatchNames`, or none), so a
1308
+ * row persisted before the table names its swatches as a fresh add does.
1309
+ * Values, types and every other key stay as persisted; a row the sheet no
1310
+ * longer builds keeps its own; a row whose words already match is returned
1311
+ * as is. `options` builds the words as the mount did (a port's hint rule,
1312
+ * WrunRowBuildOptions), so a row persisted before the rule reads without its
1313
+ * encoding legend.
1236
1314
  */
1237
1315
  export function wrunRowsWithSheetWords(rows, sheet, options) {
1238
- if (sheet === undefined || !Array.isArray(sheet.params) || sheet.params.length === 0)
1316
+ if (sheet === undefined)
1239
1317
  return [...rows];
1240
1318
  const keyOf = (row) => `${row.virtual === true ? 'virtual' : 'value'}:${row.name}`;
1241
1319
  const fresh = new Map();
1242
- for (const row of buildWrunScriptInputs({ params: sheet.params }, options)) {
1243
- if (row.styleOf === undefined && !fresh.has(keyOf(row)))
1244
- fresh.set(keyOf(row), row);
1320
+ if (Array.isArray(sheet.params) && sheet.params.length > 0) {
1321
+ for (const row of buildWrunScriptInputs({ params: sheet.params }, options)) {
1322
+ if (row.styleOf === undefined && !fresh.has(keyOf(row)))
1323
+ fresh.set(keyOf(row), row);
1324
+ }
1325
+ }
1326
+ // The swatch names the sheet gives its Style rows now, by row name (none to build without a table).
1327
+ const swatchNames = new Map();
1328
+ if (Array.isArray(sheet.style_names)) {
1329
+ for (const row of styleRows(sheet))
1330
+ if (row.swatchNames !== undefined)
1331
+ swatchNames.set(row.name, row.swatchNames);
1245
1332
  }
1246
1333
  return rows.map((row) => {
1247
- const built = row.styleOf === undefined ? fresh.get(keyOf(row)) : undefined;
1334
+ if (row.styleOf !== undefined) {
1335
+ const names = swatchNames.get(row.name);
1336
+ if (sameWords(row.swatchNames, names))
1337
+ return row;
1338
+ const { swatchNames: _persistedNames, ...rest } = row;
1339
+ return names === undefined ? rest : { ...rest, swatchNames: names };
1340
+ }
1341
+ const built = fresh.get(keyOf(row));
1248
1342
  if (built === undefined || (row.label === built.label && row.hint === built.hint))
1249
1343
  return row;
1250
1344
  const { hint: _persistedHint, ...rest } = row;
1251
1345
  return { ...rest, label: built.label, ...(built.hint !== undefined ? { hint: built.hint } : {}) };
1252
1346
  });
1253
1347
  }
1348
+ /** Two word lists alike (both absent, or the same words in the same order). */
1349
+ function sameWords(a, b) {
1350
+ if (a === undefined || b === undefined)
1351
+ return a === b;
1352
+ return a.length === b.length && a.every((word, at) => word === b[at]);
1353
+ }
1254
1354
  /**
1255
1355
  * The rows an overlay persisted, with every Style row its sheet offers now
1256
1356
  * that they lack appended in the builder's order: an overlay added before a
@@ -43,11 +43,18 @@ export interface WrunSettingWords {
43
43
  * own, a zone moves its clock); UTC when absent. */
44
44
  zoneOffsetMs?: DisplayOffset;
45
45
  }
46
- /** A choice label as the viewer reads it: a platform word ("chart", a line
47
- * style) in the viewer's language when the surface passes its words, any
48
- * other label as written. Display only: a stored value, a persisted label
49
- * and every lookup by label keep the original word. */
50
- export declare function wrunChoiceWord(label: string, words?: WrunSettingWords): string;
46
+ /** True when a choice is a line style choice: it has options and every one of them (its label, as the row shows
47
+ * it) is a line style word, case ignored. A choice that merely holds one such word among others (a mark look
48
+ * labelled "Solid" beside "Glass") is not. */
49
+ export declare function wrunIsLineStyleChoice(labels: ReadonlyArray<string>): boolean;
50
+ /** A choice label as the viewer reads it: a platform word in the viewer's
51
+ * language when the surface passes its words ("chart" always; a line style
52
+ * word only when `lineStyleChoice` says the choice is a line style choice:
53
+ * `wrunIsLineStyleChoice` over its labels, or a Style row's `lineStyle`),
54
+ * any other label as written. A look option labelled "Solid" keeps "Solid".
55
+ * Display only: a stored value, a persisted label and every lookup by label
56
+ * keep the original word. */
57
+ export declare function wrunChoiceWord(label: string, words?: WrunSettingWords, lineStyleChoice?: boolean): string;
51
58
  /** The words of a coded setting (a choice, a multi, a time, a session clock);
52
59
  * undefined for every other kind, which a surface prints its own way. */
53
60
  export declare function wrunCodedWords(shape: WrunWordsShape, value: unknown, words?: WrunSettingWords): string | undefined;