@orangecharts/wrun-chart-host 0.1.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.
- package/README.md +72 -0
- package/dist/constants/governed-exchanges.constants.d.ts +11 -0
- package/dist/constants/governed-exchanges.constants.js +11 -0
- package/dist/constants/indicator-sets.constants.d.ts +8 -0
- package/dist/constants/indicator-sets.constants.js +8 -0
- package/dist/constants/interval.constants.d.ts +34 -0
- package/dist/constants/interval.constants.js +121 -0
- package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +28 -0
- package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +65 -0
- package/dist/constants/tpo-color-schemes.constants.d.ts +30 -0
- package/dist/constants/tpo-color-schemes.constants.js +32 -0
- package/dist/host-env.d.ts +102 -0
- package/dist/host-env.js +26 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +96 -0
- package/dist/indicators/controls/tpo-letter.util.d.ts +2 -0
- package/dist/indicators/controls/tpo-letter.util.js +13 -0
- package/dist/indicators/controls/tpo-session.util.d.ts +99 -0
- package/dist/indicators/controls/tpo-session.util.js +389 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +64 -0
- package/dist/interfaces/kscript-diagnostics.interface.js +1 -0
- package/dist/interfaces/om-panel-data.interface.d.ts +103 -0
- package/dist/interfaces/om-panel-data.interface.js +7 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +2659 -0
- package/dist/interfaces/wrun-runtime.interface.js +55 -0
- package/dist/utility/chart/calendar-interval.util.d.ts +24 -0
- package/dist/utility/chart/calendar-interval.util.js +81 -0
- package/dist/utility/chart/candle-bar-end.util.d.ts +15 -0
- package/dist/utility/chart/candle-bar-end.util.js +23 -0
- package/dist/utility/chart/cme-realtime.util.d.ts +24 -0
- package/dist/utility/chart/cme-realtime.util.js +53 -0
- package/dist/utility/chart/interval-ladder.util.d.ts +27 -0
- package/dist/utility/chart/interval-ladder.util.js +92 -0
- package/dist/utility/chart/kscript-drawing-prep.util.d.ts +40 -0
- package/dist/utility/chart/kscript-drawing-prep.util.js +184 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +95 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +805 -0
- package/dist/utility/chart/kscript-legend-entries.util.d.ts +166 -0
- package/dist/utility/chart/kscript-legend-entries.util.js +538 -0
- package/dist/utility/chart/kscript-output-role.util.d.ts +32 -0
- package/dist/utility/chart/kscript-output-role.util.js +215 -0
- package/dist/utility/chart/kscript-provenance-keys.util.d.ts +22 -0
- package/dist/utility/chart/kscript-provenance-keys.util.js +56 -0
- package/dist/utility/chart/kscript-run-result-normalize.util.d.ts +53 -0
- package/dist/utility/chart/kscript-run-result-normalize.util.js +476 -0
- package/dist/utility/chart/kscript-run-result-shape.util.d.ts +14 -0
- package/dist/utility/chart/kscript-run-result-shape.util.js +66 -0
- package/dist/utility/chart/kscript-titancharts-container.util.d.ts +29 -0
- package/dist/utility/chart/kscript-titancharts-container.util.js +151 -0
- package/dist/utility/chart/kscript-viewport-overlays.util.d.ts +83 -0
- package/dist/utility/chart/kscript-viewport-overlays.util.js +443 -0
- package/dist/utility/chart/om-panel-push-style.util.d.ts +78 -0
- package/dist/utility/chart/om-panel-push-style.util.js +301 -0
- package/dist/utility/chart/om-panel.util.d.ts +166 -0
- package/dist/utility/chart/om-panel.util.js +815 -0
- package/dist/utility/chart/om-series.util.d.ts +42 -0
- package/dist/utility/chart/om-series.util.js +330 -0
- package/dist/utility/chart/om-target.util.d.ts +11 -0
- package/dist/utility/chart/om-target.util.js +24 -0
- package/dist/utility/chart/om-widget.util.d.ts +148 -0
- package/dist/utility/chart/om-widget.util.js +413 -0
- package/dist/utility/chart/overlay-output-budget.util.d.ts +16 -0
- package/dist/utility/chart/overlay-output-budget.util.js +109 -0
- package/dist/utility/chart/overlay-paint-flags.util.d.ts +24 -0
- package/dist/utility/chart/overlay-paint-flags.util.js +55 -0
- package/dist/utility/chart/profile-row-height.util.d.ts +21 -0
- package/dist/utility/chart/profile-row-height.util.js +110 -0
- package/dist/utility/chart/session-interval.util.d.ts +1 -0
- package/dist/utility/chart/session-interval.util.js +35 -0
- package/dist/utility/chart/technical-script-legend-value.util.d.ts +18 -0
- package/dist/utility/chart/technical-script-legend-value.util.js +53 -0
- package/dist/utility/chart/trading-day.util.d.ts +70 -0
- package/dist/utility/chart/trading-day.util.js +238 -0
- package/dist/utility/chart/wrun-legend-name.util.d.ts +25 -0
- package/dist/utility/chart/wrun-legend-name.util.js +87 -0
- package/dist/utility/chart/wrun-run-result.util.d.ts +977 -0
- package/dist/utility/chart/wrun-run-result.util.js +5179 -0
- package/dist/utility/chart/wrun-visibility-chart.util.d.ts +25 -0
- package/dist/utility/chart/wrun-visibility-chart.util.js +22 -0
- package/dist/utility/indicators/heatmap-sensitivity.util.d.ts +62 -0
- package/dist/utility/indicators/heatmap-sensitivity.util.js +82 -0
- package/dist/utility/number-format.util.d.ts +68 -0
- package/dist/utility/number-format.util.js +188 -0
- package/dist/utility/v2/opra-governed.util.d.ts +1 -0
- package/dist/utility/v2/opra-governed.util.js +13 -0
- package/dist/utility/wrun/wrun-auto-row.util.d.ts +54 -0
- package/dist/utility/wrun/wrun-auto-row.util.js +96 -0
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +341 -0
- package/dist/utility/wrun/wrun-batched-marks.util.js +938 -0
- package/dist/utility/wrun/wrun-batched-readout.util.d.ts +75 -0
- package/dist/utility/wrun/wrun-batched-readout.util.js +171 -0
- package/dist/utility/wrun/wrun-box-segment.util.d.ts +185 -0
- package/dist/utility/wrun/wrun-box-segment.util.js +570 -0
- package/dist/utility/wrun/wrun-build-memo.util.d.ts +133 -0
- package/dist/utility/wrun/wrun-build-memo.util.js +301 -0
- package/dist/utility/wrun/wrun-builtin-twin-ports.util.d.ts +25 -0
- package/dist/utility/wrun/wrun-builtin-twin-ports.util.js +75 -0
- package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-builtin-twin.util.js +40 -0
- package/dist/utility/wrun/wrun-canvas-cache.util.d.ts +28 -0
- package/dist/utility/wrun/wrun-canvas-cache.util.js +56 -0
- package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +69 -0
- package/dist/utility/wrun/wrun-canvas-readout.util.js +53 -0
- package/dist/utility/wrun/wrun-canvases.util.d.ts +295 -0
- package/dist/utility/wrun/wrun-canvases.util.js +1432 -0
- package/dist/utility/wrun/wrun-cap-notice.util.d.ts +77 -0
- package/dist/utility/wrun/wrun-cap-notice.util.js +296 -0
- package/dist/utility/wrun/wrun-card-style.util.d.ts +154 -0
- package/dist/utility/wrun/wrun-card-style.util.js +539 -0
- package/dist/utility/wrun/wrun-chart-context.util.d.ts +89 -0
- package/dist/utility/wrun/wrun-chart-context.util.js +213 -0
- package/dist/utility/wrun/wrun-chart-names.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-chart-names.util.js +33 -0
- package/dist/utility/wrun/wrun-chart-time.util.d.ts +12 -0
- package/dist/utility/wrun/wrun-chart-time.util.js +23 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +13 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.js +44 -0
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +40 -0
- package/dist/utility/wrun/wrun-color-facts.util.js +88 -0
- package/dist/utility/wrun/wrun-color-settings.lazy.d.ts +26 -0
- package/dist/utility/wrun/wrun-color-settings.lazy.js +9 -0
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +351 -0
- package/dist/utility/wrun/wrun-color-settings.util.js +1363 -0
- package/dist/utility/wrun/wrun-footprint-modes.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-footprint-modes.util.js +24 -0
- package/dist/utility/wrun/wrun-frames.d.ts +217 -0
- package/dist/utility/wrun/wrun-frames.js +1021 -0
- package/dist/utility/wrun/wrun-handles.util.d.ts +792 -0
- package/dist/utility/wrun/wrun-handles.util.js +2050 -0
- package/dist/utility/wrun/wrun-heatmap-cell-budget.util.d.ts +156 -0
- package/dist/utility/wrun/wrun-heatmap-cell-budget.util.js +342 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +218 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +667 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +40 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.js +27 -0
- package/dist/utility/wrun/wrun-hover.util.d.ts +182 -0
- package/dist/utility/wrun/wrun-hover.util.js +534 -0
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +246 -0
- package/dist/utility/wrun/wrun-hud-looks.util.js +587 -0
- package/dist/utility/wrun/wrun-integration-budget.util.d.ts +47 -0
- package/dist/utility/wrun/wrun-integration-budget.util.js +122 -0
- package/dist/utility/wrun/wrun-latest-snapshot.d.ts +19 -0
- package/dist/utility/wrun/wrun-latest-snapshot.js +7 -0
- package/dist/utility/wrun/wrun-levels-child.util.d.ts +131 -0
- package/dist/utility/wrun/wrun-levels-child.util.js +514 -0
- package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +75 -0
- package/dist/utility/wrun/wrun-lifecycle.contract.js +9 -0
- package/dist/utility/wrun/wrun-market-facts.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-market-facts.util.js +238 -0
- package/dist/utility/wrun/wrun-output-style.util.d.ts +344 -0
- package/dist/utility/wrun/wrun-output-style.util.js +1239 -0
- package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +84 -0
- package/dist/utility/wrun/wrun-overlay-identity.util.js +142 -0
- package/dist/utility/wrun/wrun-overlay-result.util.d.ts +120 -0
- package/dist/utility/wrun/wrun-overlay-result.util.js +219 -0
- package/dist/utility/wrun/wrun-pack.util.d.ts +70 -0
- package/dist/utility/wrun/wrun-pack.util.js +301 -0
- package/dist/utility/wrun/wrun-pane-format.util.d.ts +180 -0
- package/dist/utility/wrun/wrun-pane-format.util.js +299 -0
- package/dist/utility/wrun/wrun-panel-style.lazy.d.ts +25 -0
- package/dist/utility/wrun/wrun-panel-style.lazy.js +15 -0
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +174 -0
- package/dist/utility/wrun/wrun-panel-style.util.js +726 -0
- package/dist/utility/wrun/wrun-param-values.util.d.ts +69 -0
- package/dist/utility/wrun/wrun-param-values.util.js +230 -0
- package/dist/utility/wrun/wrun-refusal.util.d.ts +263 -0
- package/dist/utility/wrun/wrun-refusal.util.js +1259 -0
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +199 -0
- package/dist/utility/wrun/wrun-registry-errors.util.js +257 -0
- package/dist/utility/wrun/wrun-render-select.util.d.ts +336 -0
- package/dist/utility/wrun/wrun-render-select.util.js +1157 -0
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +434 -0
- package/dist/utility/wrun/wrun-script-inputs.util.js +1971 -0
- package/dist/utility/wrun/wrun-setting-words.lazy.d.ts +20 -0
- package/dist/utility/wrun/wrun-setting-words.lazy.js +9 -0
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +79 -0
- package/dist/utility/wrun/wrun-setting-words.util.js +176 -0
- package/dist/utility/wrun/wrun-socket-row-store.d.ts +98 -0
- package/dist/utility/wrun/wrun-socket-row-store.js +417 -0
- package/dist/utility/wrun/wrun-style-flags.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-style-flags.util.js +21 -0
- package/dist/utility/wrun/wrun-style-words.util.d.ts +148 -0
- package/dist/utility/wrun/wrun-style-words.util.js +439 -0
- package/dist/utility/wrun/wrun-table-look.util.d.ts +125 -0
- package/dist/utility/wrun/wrun-table-look.util.js +225 -0
- package/dist/utility/wrun/wrun-text-look.util.d.ts +51 -0
- package/dist/utility/wrun/wrun-text-look.util.js +227 -0
- package/dist/utility/wrun/wrun-text-params.util.d.ts +106 -0
- package/dist/utility/wrun/wrun-text-params.util.js +171 -0
- package/dist/utility/wrun/wrun-tpo-rows.util.d.ts +71 -0
- package/dist/utility/wrun/wrun-tpo-rows.util.js +438 -0
- package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +58 -0
- package/dist/utility/wrun/wrun-visibility-table.d.ts +437 -0
- package/dist/utility/wrun/wrun-visibility-table.js +237 -0
- package/dist/utility/wrun/wrun-volume-profile.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-volume-profile.util.js +278 -0
- package/package.json +38 -0
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wrun block kit (WRUN-INPUTS-PLAN 1.4, 1.6, 1.7): one vocabulary of
|
|
3
|
+
* blocks (`value`, `spark`, `gauge`, `pill`, `rows`, `meter`, `chips`) with
|
|
4
|
+
* three homes, the HUD tiles, the legend entries and the hover card. This
|
|
5
|
+
* module turns a sheet block (`WrunHoverBlock`, the declaration) plus the
|
|
6
|
+
* overlay's latest snapshot (`WrunLatestSnapshot`, published by the run
|
|
7
|
+
* path) into a `WrunBlockView`: formatted strings, resolved colours and
|
|
8
|
+
* plain number series, nothing a renderer has to interpret. `WrunBlocks.vue`
|
|
9
|
+
* draws the views; the inspector and the HUD layer both render through it.
|
|
10
|
+
*
|
|
11
|
+
* Pure and node-testable: no titan, DOM, store or chart access. Every
|
|
12
|
+
* number goes through the one formatter (wrun-pane-format.util): with a
|
|
13
|
+
* `WrunValuePlacement` (the owning chart's digits, built by the caller from
|
|
14
|
+
* the mounted chart, wrun-legend-hover wrunValuePlacement) it is the
|
|
15
|
+
* legend's own rule, `formatWrunLegendValue`, so a value reads the same in
|
|
16
|
+
* the legend, the card and the HUD; without one, `formatWrunValue` and its
|
|
17
|
+
* defaults (a card built off any chart).
|
|
18
|
+
*
|
|
19
|
+
* Template placeholders (plan 1.3, the alert placeholder style): `{{name}}`
|
|
20
|
+
* is an output or a string slot by name, `{{name:format}}` a format word
|
|
21
|
+
* from the frozen list, `{{label}}` and `{{value}}` the owning output;
|
|
22
|
+
* `{{row}}` / `{{col}}` belong to a matrix and stay as written here. An
|
|
23
|
+
* unknown name stays as written too, so a typo shows instead of vanishing.
|
|
24
|
+
*/
|
|
25
|
+
import { wrunLegendName } from '../chart/wrun-legend-name.util.js';
|
|
26
|
+
import { WRUN_MAX_BLOCK_HEIGHT_PX, WRUN_MAX_HUD_FONT_SIZE_PX, WRUN_MAX_HUD_RINGS, WRUN_MIN_BLOCK_HEIGHT_PX, WRUN_MIN_HUD_FONT_SIZE_PX, isWrunRowLeader, wrunBlockDraw, } from './wrun-hud-looks.util.js';
|
|
27
|
+
import { formatWrunLegendValue, formatWrunValue, isWrunValueFormat, } from './wrun-pane-format.util.js';
|
|
28
|
+
import { resolveWrunColorWord } from './wrun-style-words.util.js';
|
|
29
|
+
/** The sparkline's default window when a block declares no `bars`. */
|
|
30
|
+
export const WRUN_SPARK_DEFAULT_BARS = 32;
|
|
31
|
+
/** The chip separator inside one string slot ("Overbought|Rising"). */
|
|
32
|
+
const WRUN_CHIP_SEPARATOR = '|';
|
|
33
|
+
const WRUN_PLACEHOLDER = /\{\{\s*([A-Za-z_][A-Za-z0-9_]*)(?:\s*:\s*([^}\s]+))?\s*\}\}/g;
|
|
34
|
+
/** The names a matrix resolves itself; left as written everywhere else. */
|
|
35
|
+
const WRUN_MATRIX_PLACEHOLDERS = new Set(['row', 'col']);
|
|
36
|
+
function outputByName(metadata, name) {
|
|
37
|
+
if (name === undefined)
|
|
38
|
+
return undefined;
|
|
39
|
+
return metadata.outputs?.find((output) => output.name === name);
|
|
40
|
+
}
|
|
41
|
+
function isStringSlot(metadata, name) {
|
|
42
|
+
return name !== undefined && (metadata.string_slots?.some((slot) => slot.name === name) ?? false);
|
|
43
|
+
}
|
|
44
|
+
function latestValue(snapshot, name) {
|
|
45
|
+
if (name === undefined)
|
|
46
|
+
return Number.NaN;
|
|
47
|
+
const value = snapshot.values?.[name];
|
|
48
|
+
return typeof value === 'number' ? value : Number.NaN;
|
|
49
|
+
}
|
|
50
|
+
function latestText(snapshot, name) {
|
|
51
|
+
if (name === undefined)
|
|
52
|
+
return undefined;
|
|
53
|
+
const text = snapshot.strings?.[name];
|
|
54
|
+
return typeof text === 'string' ? text : undefined;
|
|
55
|
+
}
|
|
56
|
+
/** The format word a block or a reference resolves with: the explicit
|
|
57
|
+
* override when it is a frozen word, else the output's declared `format`. */
|
|
58
|
+
function formatWordFor(override, output) {
|
|
59
|
+
if (isWrunValueFormat(override))
|
|
60
|
+
return override;
|
|
61
|
+
const declared = output?.format;
|
|
62
|
+
return isWrunValueFormat(declared) ? declared : undefined;
|
|
63
|
+
}
|
|
64
|
+
/** The companions an output declares beside its `format` (OT32): decimals
|
|
65
|
+
* 0..8, signed, unit. An output without a format keeps today's meaning for
|
|
66
|
+
* them (a unit stays unprinted, X3), so nothing is passed. */
|
|
67
|
+
function formatOptionsFor(output) {
|
|
68
|
+
if (output === undefined || !isWrunValueFormat(output.format))
|
|
69
|
+
return undefined;
|
|
70
|
+
const { decimals, signed, unit } = output;
|
|
71
|
+
const options = {};
|
|
72
|
+
if (typeof decimals === 'number' && Number.isInteger(decimals) && decimals >= 0 && decimals <= 8) {
|
|
73
|
+
options.decimals = decimals;
|
|
74
|
+
}
|
|
75
|
+
if (signed === true)
|
|
76
|
+
options.signed = true;
|
|
77
|
+
if (typeof unit === 'string' && unit !== '')
|
|
78
|
+
options.unit = unit;
|
|
79
|
+
return Object.keys(options).length > 0 ? options : undefined;
|
|
80
|
+
}
|
|
81
|
+
const formatValue = formatWrunValue;
|
|
82
|
+
const formatLegendValue = formatWrunLegendValue;
|
|
83
|
+
/** One value of output `name` through `format`: the legend's rule at the
|
|
84
|
+
* placement's digits, the formatter's defaults without a placement; the
|
|
85
|
+
* output's format companions (OT32) ride along. */
|
|
86
|
+
function formatPlacedValue(value, name, format, placement, options) {
|
|
87
|
+
if (placement === undefined)
|
|
88
|
+
return formatValue(value, format, undefined, options);
|
|
89
|
+
const { priceDigits, builtinTwin } = placement;
|
|
90
|
+
return formatLegendValue(value, { onPrice: placement.onPrice(name), priceDigits, builtinTwin }, format, options);
|
|
91
|
+
}
|
|
92
|
+
/** A signed value (a delta) through the same rule: the magnitude behind an
|
|
93
|
+
* explicit sign, `+0.00` for zero; a hole reads '-'. */
|
|
94
|
+
function formatPlacedSignedValue(value, name, format, placement, options) {
|
|
95
|
+
if (!Number.isFinite(value))
|
|
96
|
+
return '-';
|
|
97
|
+
return `${value < 0 ? '-' : '+'}${formatPlacedValue(Math.abs(value), name, format, placement, options)}`;
|
|
98
|
+
}
|
|
99
|
+
/** A colour word painted for the placement's chart: a theme token resolves
|
|
100
|
+
* against the palette (DW13); without a palette, and for any other word,
|
|
101
|
+
* the word as written. */
|
|
102
|
+
function paintColor(word, placement) {
|
|
103
|
+
if (word === undefined)
|
|
104
|
+
return undefined;
|
|
105
|
+
const theme = placement?.colorTheme;
|
|
106
|
+
return theme === undefined ? word : resolveWrunColorWord(word, theme);
|
|
107
|
+
}
|
|
108
|
+
/** An output's display label: the declared `label`, else its name read as
|
|
109
|
+
* words (the legend's own rule, wrunLegendName). */
|
|
110
|
+
export function wrunOutputDisplayLabel(output) {
|
|
111
|
+
return wrunLegendName(output.name, output.label);
|
|
112
|
+
}
|
|
113
|
+
/** A sheet name as a legend surface prints it where the declaration carries
|
|
114
|
+
* no words of its own (a `render.legend` entry without `text`, a HUD's
|
|
115
|
+
* settings rows): the legend's own rule (wrunLegendName: `spot_entry` reads
|
|
116
|
+
* "Spot entry", `gex_flip` "GEX flip") with the first letter capitalized
|
|
117
|
+
* (`spot entry` reads "Spot entry", `RSI now` stays). A name is an
|
|
118
|
+
* identifier, never copy. */
|
|
119
|
+
export function wrunNameWords(name) {
|
|
120
|
+
const words = wrunLegendName(name);
|
|
121
|
+
return words === '' ? name : words[0].toUpperCase() + words.slice(1);
|
|
122
|
+
}
|
|
123
|
+
/** The rung a ladder value picks (floor; a non-finite value picks none). */
|
|
124
|
+
function ladderRung(value, size) {
|
|
125
|
+
if (!Number.isFinite(value) || size <= 0)
|
|
126
|
+
return undefined;
|
|
127
|
+
return Math.min(size - 1, Math.max(0, Math.floor(value)));
|
|
128
|
+
}
|
|
129
|
+
/** A ladder output's labels: a declared `labels` list on the output (an
|
|
130
|
+
* FE-only sheet key, read as parsed JSON) indexed by the value's rung. */
|
|
131
|
+
function ladderLabels(output) {
|
|
132
|
+
const labels = output?.labels;
|
|
133
|
+
return Array.isArray(labels) ? labels.filter((label) => typeof label === 'string') : [];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The colour a `color_by` ladder picks for a reference at the snapshot: the
|
|
137
|
+
* ladder output's latest value floors into `colors` (the block's, else the
|
|
138
|
+
* ladder output's own `colors`). A block may carry `color` beside the ladder
|
|
139
|
+
* (om parity): the ladder wins where it resolves, `color` is the fallback
|
|
140
|
+
* (no rung: NaN, no table); neither = undefined.
|
|
141
|
+
*/
|
|
142
|
+
export function resolveWrunLadderColor(spec, snapshot, metadata) {
|
|
143
|
+
const fallback = typeof spec.color === 'string' && spec.color.trim() !== '' ? spec.color : undefined;
|
|
144
|
+
if (spec.color_by === undefined)
|
|
145
|
+
return fallback;
|
|
146
|
+
const ladder = outputByName(metadata, spec.color_by);
|
|
147
|
+
const table = spec.colors ?? ladder?.colors ?? [];
|
|
148
|
+
const rung = ladderRung(latestValue(snapshot, spec.color_by), table.length);
|
|
149
|
+
return rung === undefined ? fallback : table[rung];
|
|
150
|
+
}
|
|
151
|
+
/** The chips a reference yields: a string slot's text split on `|`, else a
|
|
152
|
+
* ladder output's label at its latest rung. */
|
|
153
|
+
export function resolveWrunChips(name, snapshot, metadata) {
|
|
154
|
+
if (name === undefined)
|
|
155
|
+
return [];
|
|
156
|
+
if (isStringSlot(metadata, name)) {
|
|
157
|
+
return (latestText(snapshot, name) ?? '')
|
|
158
|
+
.split(WRUN_CHIP_SEPARATOR)
|
|
159
|
+
.map((chip) => chip.trim())
|
|
160
|
+
.filter((chip) => chip.length > 0);
|
|
161
|
+
}
|
|
162
|
+
const output = outputByName(metadata, name);
|
|
163
|
+
const labels = ladderLabels(output);
|
|
164
|
+
const rung = ladderRung(latestValue(snapshot, name), labels.length);
|
|
165
|
+
return rung === undefined ? [] : [labels[rung]];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* One placeholder grammar for every template: each `{{name}}` /
|
|
169
|
+
* `{{name:format}}` goes through `lookup`, which returns the replacement
|
|
170
|
+
* or undefined to keep the placeholder as written. `label` and `value`
|
|
171
|
+
* resolve against `self` when given (`value` at the placement's digits);
|
|
172
|
+
* `row` / `col` always stay.
|
|
173
|
+
*/
|
|
174
|
+
export function resolveWrunPlaceholders(template, lookup, self, placement) {
|
|
175
|
+
return template.replace(WRUN_PLACEHOLDER, (literal, name, format) => {
|
|
176
|
+
if (WRUN_MATRIX_PLACEHOLDERS.has(name))
|
|
177
|
+
return literal;
|
|
178
|
+
if (self !== undefined && name === 'label')
|
|
179
|
+
return self.label;
|
|
180
|
+
if (self !== undefined && name === 'value') {
|
|
181
|
+
return formatPlacedValue(self.value, self.name, isWrunValueFormat(format) ? format : self.format, placement);
|
|
182
|
+
}
|
|
183
|
+
return lookup(name, format) ?? literal;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/** A template against the overlay's latest snapshot: an output reads as its
|
|
187
|
+
* formatted latest value (the placeholder's word, else its declared
|
|
188
|
+
* `format`, at the placement's digits), a string slot as its latest text. */
|
|
189
|
+
export function resolveWrunTemplate(template, snapshot, metadata, self, placement) {
|
|
190
|
+
return resolveWrunPlaceholders(template, (name, format) => {
|
|
191
|
+
if (isStringSlot(metadata, name))
|
|
192
|
+
return latestText(snapshot, name) ?? '';
|
|
193
|
+
const output = outputByName(metadata, name);
|
|
194
|
+
if (output === undefined)
|
|
195
|
+
return undefined;
|
|
196
|
+
return formatPlacedValue(latestValue(snapshot, name), name, formatWordFor(format, output), placement, formatOptionsFor(output));
|
|
197
|
+
}, self, placement);
|
|
198
|
+
}
|
|
199
|
+
/** A reference's display text: a string slot's text, else the output's
|
|
200
|
+
* formatted latest value. */
|
|
201
|
+
function referenceText(name, format, snapshot, metadata, placement) {
|
|
202
|
+
if (name === undefined)
|
|
203
|
+
return '-';
|
|
204
|
+
if (isStringSlot(metadata, name))
|
|
205
|
+
return latestText(snapshot, name) ?? '-';
|
|
206
|
+
const output = outputByName(metadata, name);
|
|
207
|
+
return formatPlacedValue(latestValue(snapshot, name), name, formatWordFor(format, output), placement, formatOptionsFor(output));
|
|
208
|
+
}
|
|
209
|
+
/** The label a block shows: its own, else its reference's display label. */
|
|
210
|
+
function blockLabel(block, metadata) {
|
|
211
|
+
if (typeof block.label === 'string' && block.label.trim() !== '')
|
|
212
|
+
return block.label;
|
|
213
|
+
const name = block.output ?? block.slot;
|
|
214
|
+
const output = outputByName(metadata, name);
|
|
215
|
+
if (output !== undefined)
|
|
216
|
+
return wrunOutputDisplayLabel(output);
|
|
217
|
+
return name === undefined ? undefined : wrunLegendName(name);
|
|
218
|
+
}
|
|
219
|
+
/** The kinds that draw a mark in the series' own colour (a sparkline, an
|
|
220
|
+
* arc, a fill): without a declared colour they take the referenced
|
|
221
|
+
* output's. Text kinds (value, pill, rows, chips) stay the card's text
|
|
222
|
+
* colour unless the block declares one. */
|
|
223
|
+
const WRUN_MARK_KINDS = new Set(['spark', 'gauge', 'meter']);
|
|
224
|
+
/** A block's own colour: the static `color`, else its ladder, else (mark
|
|
225
|
+
* kinds only) the referenced output's static colour; a colour word is
|
|
226
|
+
* painted for the placement's chart (DW13). */
|
|
227
|
+
function blockColor(block, snapshot, metadata, placement) {
|
|
228
|
+
const laddered = resolveWrunLadderColor(block, snapshot, metadata);
|
|
229
|
+
if (laddered !== undefined)
|
|
230
|
+
return paintColor(laddered, placement);
|
|
231
|
+
if (!WRUN_MARK_KINDS.has(block.kind))
|
|
232
|
+
return undefined;
|
|
233
|
+
return paintColor(outputByName(metadata, block.output)?.color, placement);
|
|
234
|
+
}
|
|
235
|
+
function integerIn(value, min, max) {
|
|
236
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= min && value <= max ? value : undefined;
|
|
237
|
+
}
|
|
238
|
+
/** A gauge, meter or ring reading as a share of its range, clamped to 0..1;
|
|
239
|
+
* undefined for a hole or an empty range. */
|
|
240
|
+
function shareOf(value, min, max) {
|
|
241
|
+
if (!Number.isFinite(value) || !Number.isFinite(min) || !Number.isFinite(max) || max === min)
|
|
242
|
+
return undefined;
|
|
243
|
+
return Math.min(1, Math.max(0, (value - min) / (max - min)));
|
|
244
|
+
}
|
|
245
|
+
/** The LK04 / LK05 / LK06 words a block carries onto its view as declared
|
|
246
|
+
* (a word on a kind that does not take it is dropped, the way the kit
|
|
247
|
+
* refuses it); the HUD look fills the rest in later. */
|
|
248
|
+
function blockLookWords(block) {
|
|
249
|
+
const words = {};
|
|
250
|
+
const draw = wrunBlockDraw(block.kind, block.draw);
|
|
251
|
+
if (draw !== undefined)
|
|
252
|
+
words.draw = draw;
|
|
253
|
+
if (block.kind === 'value' || block.kind === 'pill') {
|
|
254
|
+
if (block.headline === true)
|
|
255
|
+
words.headline = true;
|
|
256
|
+
const fontSize = integerIn(block.font_size, WRUN_MIN_HUD_FONT_SIZE_PX, WRUN_MAX_HUD_FONT_SIZE_PX);
|
|
257
|
+
if (fontSize !== undefined)
|
|
258
|
+
words.fontSize = fontSize;
|
|
259
|
+
}
|
|
260
|
+
if (block.kind === 'spark' || block.kind === 'meter' || block.kind === 'rings') {
|
|
261
|
+
const height = integerIn(block.height, WRUN_MIN_BLOCK_HEIGHT_PX, WRUN_MAX_BLOCK_HEIGHT_PX);
|
|
262
|
+
if (height !== undefined)
|
|
263
|
+
words.height = height;
|
|
264
|
+
}
|
|
265
|
+
if (block.kind === 'rows' && isWrunRowLeader(block.leader))
|
|
266
|
+
words.leader = block.leader;
|
|
267
|
+
return words;
|
|
268
|
+
}
|
|
269
|
+
/** The rings of a rings block (LK07): outermost first, at most three, each
|
|
270
|
+
* its reading's share of its own min..max with the legend's label and value. */
|
|
271
|
+
function ringViews(block, snapshot, metadata, placement) {
|
|
272
|
+
const rings = Array.isArray(block.rings) ? block.rings.slice(0, WRUN_MAX_HUD_RINGS) : [];
|
|
273
|
+
return rings.flatMap((ring) => {
|
|
274
|
+
if (!ring || typeof ring !== 'object' || typeof ring.output !== 'string')
|
|
275
|
+
return [];
|
|
276
|
+
const output = outputByName(metadata, ring.output);
|
|
277
|
+
const current = latestValue(snapshot, ring.output);
|
|
278
|
+
const color = paintColor(typeof ring.color === 'string' && ring.color !== '' ? ring.color : undefined, placement);
|
|
279
|
+
return [
|
|
280
|
+
{
|
|
281
|
+
label: typeof ring.label === 'string' && ring.label !== '' ? ring.label : wrunLegendName(ring.output, output?.label),
|
|
282
|
+
value: formatPlacedValue(current, ring.output, formatWordFor(undefined, output), placement, formatOptionsFor(output)),
|
|
283
|
+
fraction: shareOf(current, ring.min, ring.max) ?? 0,
|
|
284
|
+
...(color !== undefined ? { color } : {}),
|
|
285
|
+
},
|
|
286
|
+
];
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function sparkPoints(snapshot, name, bars) {
|
|
290
|
+
if (name === undefined)
|
|
291
|
+
return [];
|
|
292
|
+
const history = snapshot.history?.[name];
|
|
293
|
+
if (!history)
|
|
294
|
+
return [];
|
|
295
|
+
const window = Number.isFinite(bars) && bars > 0 ? Math.floor(bars) : WRUN_SPARK_DEFAULT_BARS;
|
|
296
|
+
const points = [];
|
|
297
|
+
for (let at = Math.max(0, history.length - window); at < history.length; at += 1) {
|
|
298
|
+
const value = history[at];
|
|
299
|
+
if (Number.isFinite(value))
|
|
300
|
+
points.push(value);
|
|
301
|
+
}
|
|
302
|
+
return points;
|
|
303
|
+
}
|
|
304
|
+
function deltaTone(delta) {
|
|
305
|
+
if (!Number.isFinite(delta) || delta === 0)
|
|
306
|
+
return undefined;
|
|
307
|
+
return delta > 0 ? 'positive' : 'negative';
|
|
308
|
+
}
|
|
309
|
+
/** The view of one declared block (undefined for an unknown kind). */
|
|
310
|
+
function buildBlockView(block, snapshot, metadata, placement) {
|
|
311
|
+
if (!block || typeof block !== 'object')
|
|
312
|
+
return undefined;
|
|
313
|
+
const label = blockLabel(block, metadata);
|
|
314
|
+
const color = blockColor(block, snapshot, metadata, placement);
|
|
315
|
+
const labelled = label !== undefined ? { label } : {};
|
|
316
|
+
const words = blockLookWords(block);
|
|
317
|
+
const withColor = (view) => ({
|
|
318
|
+
...view,
|
|
319
|
+
...words,
|
|
320
|
+
...(color === undefined ? {} : { color }),
|
|
321
|
+
});
|
|
322
|
+
switch (block.kind) {
|
|
323
|
+
case 'value': {
|
|
324
|
+
const output = outputByName(metadata, block.output);
|
|
325
|
+
const format = formatWordFor(block.format, output);
|
|
326
|
+
const options = formatOptionsFor(output);
|
|
327
|
+
const value = block.slot !== undefined && block.output === undefined
|
|
328
|
+
? referenceText(block.slot, undefined, snapshot, metadata, placement)
|
|
329
|
+
: formatPlacedValue(latestValue(snapshot, block.output), block.output, format, placement, options);
|
|
330
|
+
const view = { kind: 'value', ...labelled, value };
|
|
331
|
+
if (block.delta !== undefined) {
|
|
332
|
+
const delta = latestValue(snapshot, block.delta);
|
|
333
|
+
// The delta reads in the block's word, else the delta output's own
|
|
334
|
+
// format, else the value's (a change in the value's own units).
|
|
335
|
+
const deltaOutput = outputByName(metadata, block.delta);
|
|
336
|
+
const deltaFormat = formatWordFor(block.format, deltaOutput) ?? format;
|
|
337
|
+
view.delta = formatPlacedSignedValue(delta, block.delta, deltaFormat, placement, formatOptionsFor(deltaOutput) ?? options);
|
|
338
|
+
const tone = deltaTone(delta);
|
|
339
|
+
if (tone !== undefined)
|
|
340
|
+
view.tone = tone;
|
|
341
|
+
}
|
|
342
|
+
return withColor(view);
|
|
343
|
+
}
|
|
344
|
+
case 'spark': {
|
|
345
|
+
const output = outputByName(metadata, block.output);
|
|
346
|
+
return withColor({
|
|
347
|
+
kind: 'spark',
|
|
348
|
+
...labelled,
|
|
349
|
+
value: formatPlacedValue(latestValue(snapshot, block.output), block.output, formatWordFor(block.format, output), placement, formatOptionsFor(output)),
|
|
350
|
+
points: sparkPoints(snapshot, block.output, block.bars),
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
case 'gauge':
|
|
354
|
+
case 'meter': {
|
|
355
|
+
const output = outputByName(metadata, block.output);
|
|
356
|
+
const current = latestValue(snapshot, block.output);
|
|
357
|
+
const min = Number.isFinite(block.min) ? block.min : 0;
|
|
358
|
+
const max = Number.isFinite(block.max) ? block.max : 100;
|
|
359
|
+
const format = formatWordFor(block.format, output);
|
|
360
|
+
const options = formatOptionsFor(output);
|
|
361
|
+
return withColor({
|
|
362
|
+
kind: block.kind,
|
|
363
|
+
...labelled,
|
|
364
|
+
value: formatPlacedValue(current, block.output, format, placement, options),
|
|
365
|
+
min,
|
|
366
|
+
max,
|
|
367
|
+
...(Number.isFinite(current) ? { current } : {}),
|
|
368
|
+
...(block.kind === 'meter' && Array.isArray(block.marks)
|
|
369
|
+
? { marks: block.marks.filter((mark) => Number.isFinite(mark)) }
|
|
370
|
+
: {}),
|
|
371
|
+
// The split meter's right-hand label: what is left of the range.
|
|
372
|
+
...(block.kind === 'meter' && Number.isFinite(current)
|
|
373
|
+
? { complement: formatPlacedValue(max - current, block.output, format, placement, options) }
|
|
374
|
+
: {}),
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
case 'pill':
|
|
378
|
+
return withColor({
|
|
379
|
+
kind: 'pill',
|
|
380
|
+
...labelled,
|
|
381
|
+
value: referenceText(block.slot ?? block.output, block.format, snapshot, metadata, placement),
|
|
382
|
+
});
|
|
383
|
+
case 'rows': {
|
|
384
|
+
const rows = (block.rows ?? []).flatMap((row) => {
|
|
385
|
+
if (!Array.isArray(row) || typeof row[0] !== 'string')
|
|
386
|
+
return [];
|
|
387
|
+
// A row is [label, reference] or [label, reference, format].
|
|
388
|
+
const [rowLabel, reference, rowFormat] = row;
|
|
389
|
+
const name = typeof reference === 'string' ? reference : undefined;
|
|
390
|
+
const swatch = paintColor(outputByName(metadata, name)?.color, placement);
|
|
391
|
+
const format = typeof rowFormat === 'string' ? rowFormat : undefined;
|
|
392
|
+
return [
|
|
393
|
+
{
|
|
394
|
+
label: rowLabel,
|
|
395
|
+
value: referenceText(name, format, snapshot, metadata, placement),
|
|
396
|
+
...(swatch !== undefined ? { swatch } : {}),
|
|
397
|
+
},
|
|
398
|
+
];
|
|
399
|
+
});
|
|
400
|
+
return withColor({ kind: 'rows', ...labelled, rows });
|
|
401
|
+
}
|
|
402
|
+
case 'chips':
|
|
403
|
+
return withColor({ kind: 'chips', chips: resolveWrunChips(block.slot ?? block.output, snapshot, metadata) });
|
|
404
|
+
case 'rings': {
|
|
405
|
+
const rings = ringViews(block, snapshot, metadata, placement);
|
|
406
|
+
if (rings.length === 0)
|
|
407
|
+
return undefined;
|
|
408
|
+
return withColor({ kind: 'rings', ...labelled, rings });
|
|
409
|
+
}
|
|
410
|
+
default:
|
|
411
|
+
return undefined;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
/** One block view per declared block (an unknown kind is dropped): each
|
|
415
|
+
* block stands alone, the way a HUD tile shows it. */
|
|
416
|
+
export function buildWrunBlockViews(blocks, snapshot, metadata, placement) {
|
|
417
|
+
return (blocks ?? []).flatMap((block) => {
|
|
418
|
+
const view = buildBlockView(block, snapshot, metadata, placement);
|
|
419
|
+
return view === undefined ? [] : [view];
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* The block views of ONE card, read top to bottom: a block is not repeated
|
|
424
|
+
* what the card already said. A sparkline or a meter of an output a value
|
|
425
|
+
* block above already headlines drops its own label and value (the lead
|
|
426
|
+
* number is right there); a gauge keeps its value (it is drawn inside the
|
|
427
|
+
* arc) and drops the label. With `owner` (the output the card answers for,
|
|
428
|
+
* named in the card's header) a block of that output drops its label too.
|
|
429
|
+
* A block with a declared `label` is the author's wording and stays whole.
|
|
430
|
+
*/
|
|
431
|
+
function composeCardViews(blocks, snapshot, metadata, owner, placement) {
|
|
432
|
+
const headlined = new Set();
|
|
433
|
+
const views = [];
|
|
434
|
+
for (const block of blocks ?? []) {
|
|
435
|
+
const view = buildBlockView(block, snapshot, metadata, placement);
|
|
436
|
+
if (view === undefined)
|
|
437
|
+
continue;
|
|
438
|
+
const declaredLabel = typeof block.label === 'string' && block.label.trim() !== '';
|
|
439
|
+
const reference = block.output;
|
|
440
|
+
if (reference !== undefined) {
|
|
441
|
+
if (view.kind === 'value') {
|
|
442
|
+
if (!declaredLabel && reference === owner)
|
|
443
|
+
delete view.label;
|
|
444
|
+
headlined.add(reference);
|
|
445
|
+
}
|
|
446
|
+
else if (!declaredLabel && WRUN_MARK_KINDS.has(view.kind)) {
|
|
447
|
+
if (headlined.has(reference)) {
|
|
448
|
+
delete view.label;
|
|
449
|
+
if (view.kind !== 'gauge')
|
|
450
|
+
delete view.value;
|
|
451
|
+
}
|
|
452
|
+
else if (reference === owner) {
|
|
453
|
+
delete view.label;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
views.push(view);
|
|
458
|
+
}
|
|
459
|
+
return views;
|
|
460
|
+
}
|
|
461
|
+
function cardOf(blocks, views, subtitle) {
|
|
462
|
+
const hint = (blocks ?? []).find((block) => typeof block?.hint === 'string' && block.hint.trim() !== '')?.hint;
|
|
463
|
+
const accent = views.find((view) => view.color !== undefined)?.color;
|
|
464
|
+
return {
|
|
465
|
+
...(subtitle !== undefined && subtitle !== '' ? { subtitle } : {}),
|
|
466
|
+
blocks: views,
|
|
467
|
+
...(hint !== undefined ? { hint } : {}),
|
|
468
|
+
badges: [],
|
|
469
|
+
...(accent !== undefined ? { accent } : {}),
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
/** The card for a list of blocks: the block views composed as one card, the
|
|
473
|
+
* first declared block `hint`, the first resolved block colour as the
|
|
474
|
+
* accent; badges stay empty (an output's `badges` ladder is added by
|
|
475
|
+
* wrunOutputHoverView). */
|
|
476
|
+
export function buildWrunHoverView(blocks, snapshot, metadata, subtitle, placement) {
|
|
477
|
+
return cardOf(blocks, composeCardViews(blocks, snapshot, metadata, undefined, placement), subtitle);
|
|
478
|
+
}
|
|
479
|
+
/** The separator between a card header's parts ("RSI · Sep 12 · 14:00"). */
|
|
480
|
+
const WRUN_HEADER_SEPARATOR = ' \u00b7 ';
|
|
481
|
+
/**
|
|
482
|
+
* The card an output answers a hover with (plan 1.6): its `hover` blocks,
|
|
483
|
+
* else its `tooltip` template as the lead text, else its formatted value.
|
|
484
|
+
* The header (the view's subtitle) names the output, then the caller's
|
|
485
|
+
* `subtitle` (the hovered bar's time), so the blocks never repeat the name.
|
|
486
|
+
* `value` is the reading at the hovered bar (the legend's floor row) when
|
|
487
|
+
* the caller has one, else the snapshot's latest, printed at the
|
|
488
|
+
* `placement`'s digits (the owning chart's); the output's `hint` and
|
|
489
|
+
* `badges` ladder, and its colour as the accent, ride every form.
|
|
490
|
+
*/
|
|
491
|
+
export function wrunOutputHoverView(output, snapshot, metadata, options = {}) {
|
|
492
|
+
const { placement } = options;
|
|
493
|
+
const label = wrunOutputDisplayLabel(output);
|
|
494
|
+
const value = options.value ?? latestValue(snapshot, output.name);
|
|
495
|
+
const format = formatWordFor(undefined, output);
|
|
496
|
+
const formatOptions = formatOptionsFor(output);
|
|
497
|
+
const self = { label, value, name: output.name, ...(format !== undefined ? { format } : {}) };
|
|
498
|
+
const header = [label, options.subtitle]
|
|
499
|
+
.filter((part) => typeof part === 'string' && part !== '')
|
|
500
|
+
.join(WRUN_HEADER_SEPARATOR);
|
|
501
|
+
let view;
|
|
502
|
+
if (Array.isArray(output.hover) && output.hover.length > 0) {
|
|
503
|
+
view = cardOf(output.hover, composeCardViews(output.hover, snapshot, metadata, output.name, placement), header);
|
|
504
|
+
}
|
|
505
|
+
else if (typeof output.tooltip === 'string' && output.tooltip.trim() !== '') {
|
|
506
|
+
view = {
|
|
507
|
+
subtitle: header,
|
|
508
|
+
blocks: [{ kind: 'value', value: resolveWrunTemplate(output.tooltip, snapshot, metadata, self, placement) }],
|
|
509
|
+
badges: [],
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
view = {
|
|
514
|
+
subtitle: header,
|
|
515
|
+
blocks: [{ kind: 'value', value: formatPlacedValue(value, output.name, format, placement, formatOptions) }],
|
|
516
|
+
badges: [],
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
if (typeof output.hint === 'string' && output.hint.trim() !== '')
|
|
520
|
+
view.hint = output.hint;
|
|
521
|
+
const badges = resolveWrunChips(output.badges, snapshot, metadata);
|
|
522
|
+
if (badges.length > 0)
|
|
523
|
+
view.badges = badges;
|
|
524
|
+
// The accent: a `color_by` ladder's current rung (the state colours the
|
|
525
|
+
// card's swatch dot), else the colour the caller saw the line painted in, else
|
|
526
|
+
// the output's static colour; a colour word is painted for the chart.
|
|
527
|
+
const laddered = output.color_by === undefined
|
|
528
|
+
? undefined
|
|
529
|
+
: resolveWrunLadderColor({ color_by: output.color_by, colors: output.colors }, snapshot, metadata);
|
|
530
|
+
const accent = paintColor(laddered ?? options.accent ?? output.color, placement);
|
|
531
|
+
if (accent !== undefined)
|
|
532
|
+
view.accent = accent;
|
|
533
|
+
return view;
|
|
534
|
+
}
|