@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,587 @@
|
|
|
1
|
+
import { WRUN_FONT_FAMILIES, isWrunColorWord, resolveWrunColorWord, wrunFontFamilyCss, wrunFontWeightCss, } from './wrun-style-words.util.js';
|
|
2
|
+
// ── Word lists (the om kit's `wrun-style/widgets.ts`, restated) ──────────────
|
|
3
|
+
/** LK01: the looks, the rows of the look table. */
|
|
4
|
+
export const WRUN_HUD_LOOKS = [
|
|
5
|
+
'default',
|
|
6
|
+
'glass',
|
|
7
|
+
'stage',
|
|
8
|
+
'signal',
|
|
9
|
+
'terminal',
|
|
10
|
+
'broadsheet',
|
|
11
|
+
'chart_desk',
|
|
12
|
+
'dial',
|
|
13
|
+
'grid',
|
|
14
|
+
'cockpit',
|
|
15
|
+
'phosphor',
|
|
16
|
+
'classic',
|
|
17
|
+
];
|
|
18
|
+
/** LK08 (as `chrome`, X16: `frame` is the data channel's word): the card's box. */
|
|
19
|
+
export const WRUN_HUD_CHROMES = ['card', 'none', 'brackets', 'rules', 'tag', 'title_bar', 'window', 'cover'];
|
|
20
|
+
/** LK08: a static surface texture. */
|
|
21
|
+
export const WRUN_HUD_TEXTURES = ['none', 'scanlines'];
|
|
22
|
+
/** LK06: title and label letter case (values never change case). */
|
|
23
|
+
export const WRUN_TEXT_CASES = ['none', 'upper', 'lower', 'small_caps'];
|
|
24
|
+
/** LK04: the drawing choice per tile kind. */
|
|
25
|
+
export const WRUN_GAUGE_DRAWS = ['arc', 'ring', 'dial', 'ticks', 'bar', 'blocks', 'text'];
|
|
26
|
+
export const WRUN_SPARK_DRAWS = ['line', 'area', 'dots', 'bars', 'text'];
|
|
27
|
+
export const WRUN_METER_DRAWS = ['bar', 'split', 'blocks', 'segments', 'scale', 'text'];
|
|
28
|
+
export const WRUN_PILL_DRAWS = ['capsule', 'dot', 'led', 'text'];
|
|
29
|
+
/** The tile kinds that take `draw`, each with its list. */
|
|
30
|
+
export const WRUN_BLOCK_DRAWS = {
|
|
31
|
+
gauge: WRUN_GAUGE_DRAWS,
|
|
32
|
+
spark: WRUN_SPARK_DRAWS,
|
|
33
|
+
meter: WRUN_METER_DRAWS,
|
|
34
|
+
pill: WRUN_PILL_DRAWS,
|
|
35
|
+
};
|
|
36
|
+
/** LK06: the rows tile's key-to-value leader. */
|
|
37
|
+
export const WRUN_ROW_LEADERS = ['none', 'dots'];
|
|
38
|
+
// ── Caps (the sheet ranges, restated for the paint pass) ─────────────────────
|
|
39
|
+
/** LK05 / LK07: a spark, meter or rings tile height, px. */
|
|
40
|
+
export const WRUN_MIN_BLOCK_HEIGHT_PX = 16;
|
|
41
|
+
export const WRUN_MAX_BLOCK_HEIGHT_PX = 120;
|
|
42
|
+
/** LK07: concentric rings per tile. */
|
|
43
|
+
export const WRUN_MAX_HUD_RINGS = 3;
|
|
44
|
+
/** LK08: the static text halo, px. */
|
|
45
|
+
export const WRUN_MAX_HUD_TEXT_GLOW_PX = 8;
|
|
46
|
+
/** DW22: a declared card width, px. */
|
|
47
|
+
export const WRUN_MIN_HUD_WIDTH_PX = 80;
|
|
48
|
+
export const WRUN_MAX_HUD_WIDTH_PX = 1200;
|
|
49
|
+
/** DW22: an offset entry, px, either sign. The layer clamps the applied offset
|
|
50
|
+
* into the price pane's inset rect (CLIP-AUDIT item 29): the sheet range is
|
|
51
|
+
* what validates, the pane is what shows. */
|
|
52
|
+
export const WRUN_MAX_HUD_OFFSET_PX = 4096;
|
|
53
|
+
/** Item 29: a card under this opacity is pointer-free (its tiles let every click through). */
|
|
54
|
+
export const WRUN_HUD_POINTER_FREE_OPACITY = 0.15;
|
|
55
|
+
/** DW22: the inner padding, px. */
|
|
56
|
+
export const WRUN_MAX_HUD_PADDING_PX = 24;
|
|
57
|
+
/** D1: `corner_radius`, px. */
|
|
58
|
+
export const WRUN_MAX_HUD_CORNER_RADIUS_PX = 32;
|
|
59
|
+
/** DW22: `border_width`, px. */
|
|
60
|
+
export const WRUN_MAX_HUD_BORDER_WIDTH_PX = 10;
|
|
61
|
+
/** LK05: `font_size` on a value or pill tile, px. */
|
|
62
|
+
export const WRUN_MIN_HUD_FONT_SIZE_PX = 6;
|
|
63
|
+
export const WRUN_MAX_HUD_FONT_SIZE_PX = 64;
|
|
64
|
+
/** LK05: the headline tile's size when it declares none, and today's lead sizes. */
|
|
65
|
+
export const WRUN_HUD_HEADLINE_FONT_SIZE_PX = 22;
|
|
66
|
+
/** The least label opacity a look's light variant names (template QA C17: the tiles' 0.55 read about 3.5:1). */
|
|
67
|
+
export const WRUN_HUD_LIGHT_LABEL_OPACITY_MIN = 0.75;
|
|
68
|
+
/** LK07: the rings tile's default height. */
|
|
69
|
+
export const WRUN_HUD_RINGS_HEIGHT_PX = 86;
|
|
70
|
+
/** The accent's strength per ring when the rings declare no colours (LK07). */
|
|
71
|
+
export const WRUN_HUD_RING_STRENGTHS = [1, 0.7, 0.45];
|
|
72
|
+
const WRUN_HUD_DEFAULT_CHROME = 'card';
|
|
73
|
+
const WRUN_HUD_DEFAULT_TEXTURE = 'none';
|
|
74
|
+
/** Today's title is uppercase and labels keep their case (LK06). */
|
|
75
|
+
const WRUN_HUD_DEFAULT_TITLE_CASE = 'upper';
|
|
76
|
+
const WRUN_HUD_DEFAULT_LABEL_CASE = 'none';
|
|
77
|
+
export function isWrunHudLook(value) {
|
|
78
|
+
return typeof value === 'string' && WRUN_HUD_LOOKS.includes(value);
|
|
79
|
+
}
|
|
80
|
+
export function isWrunHudChrome(value) {
|
|
81
|
+
return typeof value === 'string' && WRUN_HUD_CHROMES.includes(value);
|
|
82
|
+
}
|
|
83
|
+
export function isWrunHudTexture(value) {
|
|
84
|
+
return typeof value === 'string' && WRUN_HUD_TEXTURES.includes(value);
|
|
85
|
+
}
|
|
86
|
+
export function isWrunTextCase(value) {
|
|
87
|
+
return typeof value === 'string' && WRUN_TEXT_CASES.includes(value);
|
|
88
|
+
}
|
|
89
|
+
export function isWrunRowLeader(value) {
|
|
90
|
+
return typeof value === 'string' && WRUN_ROW_LEADERS.includes(value);
|
|
91
|
+
}
|
|
92
|
+
/** A tile's `draw` word when it is one of its kind's drawings (LK04); any
|
|
93
|
+
* other value, and a word on a kind that takes none, is undefined. */
|
|
94
|
+
export function wrunBlockDraw(kind, value) {
|
|
95
|
+
const draws = WRUN_BLOCK_DRAWS[kind];
|
|
96
|
+
return typeof value === 'string' && draws !== undefined && draws.includes(value) ? value : undefined;
|
|
97
|
+
}
|
|
98
|
+
const TODAY = {
|
|
99
|
+
draws: {},
|
|
100
|
+
chrome: 'card',
|
|
101
|
+
texture: 'none',
|
|
102
|
+
home: false,
|
|
103
|
+
};
|
|
104
|
+
/** The frozen look table (g3 addendum, "The look table"). `default` is
|
|
105
|
+
* today's card: the g3 HUD defaults with the g3 drawings (arc, line, bar,
|
|
106
|
+
* capsule), adaptive. Where the table names no accent and the look's mock
|
|
107
|
+
* paints one colour throughout, the row carries that colour as its accent
|
|
108
|
+
* (broadsheet newsprint ink, classic's navy, phosphor's green): without it
|
|
109
|
+
* LK03 would hand the look the app's accent (glass keeps the app's: its
|
|
110
|
+
* mock's reds and greens are reading tones, not an accent). */
|
|
111
|
+
export const WRUN_HUD_LOOK_TABLE = {
|
|
112
|
+
default: { ...TODAY, draws: { gauge: 'arc', spark: 'line', meter: 'bar', pill: 'capsule' } },
|
|
113
|
+
glass: {
|
|
114
|
+
background: '#1c1c1ee6',
|
|
115
|
+
borderColor: '#ffffff29',
|
|
116
|
+
borderWidth: 1,
|
|
117
|
+
cornerRadius: 22,
|
|
118
|
+
padding: 16,
|
|
119
|
+
shadow: '0 12px 32px rgba(0, 0, 0, 0.45)',
|
|
120
|
+
fontFamily: 'rounded',
|
|
121
|
+
titleCase: 'none',
|
|
122
|
+
headlineFontSize: 34,
|
|
123
|
+
draws: { gauge: 'ring', spark: 'area', meter: 'bar', pill: 'dot' },
|
|
124
|
+
chrome: 'card',
|
|
125
|
+
texture: 'none',
|
|
126
|
+
home: false,
|
|
127
|
+
light: { background: '#f2f2f7e6' },
|
|
128
|
+
},
|
|
129
|
+
stage: {
|
|
130
|
+
backgroundGradient: ['#2c6b46', '#1b3a28', '#121212', '#121212'],
|
|
131
|
+
cornerRadius: 10,
|
|
132
|
+
padding: 14,
|
|
133
|
+
fontFamily: 'ui',
|
|
134
|
+
textColor: '#ffffff',
|
|
135
|
+
headlineFontSize: 30,
|
|
136
|
+
headlineFontWeight: 'bold',
|
|
137
|
+
accentColor: '#1ed760',
|
|
138
|
+
draws: { gauge: 'bar', spark: 'line', meter: 'split', pill: 'text' },
|
|
139
|
+
chrome: 'cover',
|
|
140
|
+
texture: 'none',
|
|
141
|
+
home: true,
|
|
142
|
+
},
|
|
143
|
+
signal: {
|
|
144
|
+
background: '#000000',
|
|
145
|
+
borderColor: '#1d1d1d',
|
|
146
|
+
borderWidth: 1,
|
|
147
|
+
cornerRadius: 14,
|
|
148
|
+
fontFamily: 'ui',
|
|
149
|
+
textColor: '#ffffff',
|
|
150
|
+
titleCase: 'none',
|
|
151
|
+
headlineFontSize: 38,
|
|
152
|
+
draws: { spark: 'line', meter: 'split' },
|
|
153
|
+
sparkHeight: 78,
|
|
154
|
+
sparkBaseline: 'zero',
|
|
155
|
+
chrome: 'card',
|
|
156
|
+
texture: 'none',
|
|
157
|
+
home: true,
|
|
158
|
+
},
|
|
159
|
+
terminal: {
|
|
160
|
+
background: '#000000',
|
|
161
|
+
borderColor: '#3a3a3a',
|
|
162
|
+
borderWidth: 1,
|
|
163
|
+
cornerRadius: 0,
|
|
164
|
+
padding: 6,
|
|
165
|
+
fontFamily: 'mono',
|
|
166
|
+
textColor: '#ffffff',
|
|
167
|
+
labelTextColor: '#F7A21B',
|
|
168
|
+
titleCase: 'upper',
|
|
169
|
+
labelCase: 'upper',
|
|
170
|
+
accentColor: '#F7A21B',
|
|
171
|
+
draws: { gauge: 'text', spark: 'text', meter: 'text', pill: 'text' },
|
|
172
|
+
chrome: 'title_bar',
|
|
173
|
+
titleBarInk: '#000000',
|
|
174
|
+
texture: 'none',
|
|
175
|
+
home: true,
|
|
176
|
+
},
|
|
177
|
+
broadsheet: {
|
|
178
|
+
background: '#F6F1E7',
|
|
179
|
+
textColor: '#141414',
|
|
180
|
+
cornerRadius: 0,
|
|
181
|
+
padding: 14,
|
|
182
|
+
fontFamily: 'serif',
|
|
183
|
+
titleCase: 'small_caps',
|
|
184
|
+
headlineFontSize: 20,
|
|
185
|
+
/** Newsprint: the headline and every mark print in the ink, never the app's orange. */
|
|
186
|
+
accentColor: '#141414',
|
|
187
|
+
markInk: 'text',
|
|
188
|
+
draws: { spark: 'dots', meter: 'bar', pill: 'text' },
|
|
189
|
+
rowLeader: 'dots',
|
|
190
|
+
chrome: 'rules',
|
|
191
|
+
texture: 'none',
|
|
192
|
+
home: true,
|
|
193
|
+
},
|
|
194
|
+
chart_desk: {
|
|
195
|
+
background: '#ffffff',
|
|
196
|
+
textColor: '#121212',
|
|
197
|
+
cornerRadius: 0,
|
|
198
|
+
padding: 14,
|
|
199
|
+
fontFamily: 'ui',
|
|
200
|
+
titleCase: 'none',
|
|
201
|
+
accentColor: '#E3120B',
|
|
202
|
+
draws: { spark: 'bars', pill: 'text' },
|
|
203
|
+
sparkHeight: 96,
|
|
204
|
+
sparkBaseline: 'mark',
|
|
205
|
+
chrome: 'tag',
|
|
206
|
+
texture: 'none',
|
|
207
|
+
home: true,
|
|
208
|
+
},
|
|
209
|
+
dial: {
|
|
210
|
+
background: '#EBE8E1',
|
|
211
|
+
textColor: '#1d1d1b',
|
|
212
|
+
cornerRadius: 16,
|
|
213
|
+
padding: 14,
|
|
214
|
+
accentColor: '#E05A1E',
|
|
215
|
+
fontFamily: 'ui',
|
|
216
|
+
titleCase: 'none',
|
|
217
|
+
draws: { gauge: 'dial', meter: 'scale', pill: 'led' },
|
|
218
|
+
chrome: 'card',
|
|
219
|
+
texture: 'none',
|
|
220
|
+
home: true,
|
|
221
|
+
},
|
|
222
|
+
grid: {
|
|
223
|
+
background: '#F2F1EC',
|
|
224
|
+
textColor: '#111111',
|
|
225
|
+
cornerRadius: 0,
|
|
226
|
+
padding: 14,
|
|
227
|
+
accentColor: '#E30613',
|
|
228
|
+
fontFamily: 'ui',
|
|
229
|
+
headlineFontSize: 44,
|
|
230
|
+
headlineFontWeight: 'bold',
|
|
231
|
+
draws: { spark: 'line', meter: 'split', pill: 'text' },
|
|
232
|
+
markInk: 'text',
|
|
233
|
+
splitRest: 'accent',
|
|
234
|
+
chrome: 'rules',
|
|
235
|
+
texture: 'none',
|
|
236
|
+
home: true,
|
|
237
|
+
},
|
|
238
|
+
cockpit: {
|
|
239
|
+
background: '#030e12c2',
|
|
240
|
+
cornerRadius: 0,
|
|
241
|
+
padding: 12,
|
|
242
|
+
textColor: '#7DF9FF',
|
|
243
|
+
accentColor: '#FFB000',
|
|
244
|
+
fontFamily: 'mono',
|
|
245
|
+
titleCase: 'upper',
|
|
246
|
+
labelCase: 'upper',
|
|
247
|
+
textGlow: 6,
|
|
248
|
+
draws: { gauge: 'ticks', meter: 'segments', spark: 'line', pill: 'text' },
|
|
249
|
+
chrome: 'brackets',
|
|
250
|
+
texture: 'none',
|
|
251
|
+
home: true,
|
|
252
|
+
/** Over a light chart the translucent slate turned grey and let candles through, and the cyan labels at 0.55
|
|
253
|
+
* read about 3.5:1 (template QA C17): the slate goes opaque and the labels read at 0.8. */
|
|
254
|
+
light: { background: '#030e12', labelOpacity: 0.8 },
|
|
255
|
+
},
|
|
256
|
+
phosphor: {
|
|
257
|
+
background: '#05160B',
|
|
258
|
+
textColor: '#3BFF73',
|
|
259
|
+
cornerRadius: 12,
|
|
260
|
+
padding: 12,
|
|
261
|
+
fontFamily: 'mono',
|
|
262
|
+
textGlow: 5,
|
|
263
|
+
/** One phosphor throughout: the glyph bars and the headline glow in the text green. */
|
|
264
|
+
accentColor: '#3BFF73',
|
|
265
|
+
draws: { gauge: 'text', spark: 'text', meter: 'text', pill: 'text' },
|
|
266
|
+
chrome: 'none',
|
|
267
|
+
texture: 'scanlines',
|
|
268
|
+
home: true,
|
|
269
|
+
},
|
|
270
|
+
classic: {
|
|
271
|
+
background: '#C0C0C0',
|
|
272
|
+
textColor: '#000000',
|
|
273
|
+
cornerRadius: 0,
|
|
274
|
+
padding: 8,
|
|
275
|
+
fontFamily: 'ui',
|
|
276
|
+
/** The title bar's navy: the mock's progress bar fills in it. */
|
|
277
|
+
accentColor: '#000080',
|
|
278
|
+
draws: { gauge: 'blocks', meter: 'blocks', spark: 'line', pill: 'dot' },
|
|
279
|
+
chrome: 'window',
|
|
280
|
+
windowBar: ['#000080', '#1084D0'],
|
|
281
|
+
texture: 'none',
|
|
282
|
+
home: true,
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
function finiteNumber(value) {
|
|
286
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
287
|
+
}
|
|
288
|
+
function integerIn(value, min, max) {
|
|
289
|
+
const n = finiteNumber(value);
|
|
290
|
+
return n !== undefined && Number.isInteger(n) && n >= min && n <= max ? n : undefined;
|
|
291
|
+
}
|
|
292
|
+
function numberIn(value, min, max) {
|
|
293
|
+
const n = finiteNumber(value);
|
|
294
|
+
return n !== undefined && n >= min && n <= max ? n : undefined;
|
|
295
|
+
}
|
|
296
|
+
function colorWord(value) {
|
|
297
|
+
return isWrunColorWord(value) ? value : undefined;
|
|
298
|
+
}
|
|
299
|
+
function px(value) {
|
|
300
|
+
return `${value}px`;
|
|
301
|
+
}
|
|
302
|
+
/** A colour word resolved against the palette when one is given; a plain
|
|
303
|
+
* word passes as written (a hex is CSS already). */
|
|
304
|
+
function paint(word, theme) {
|
|
305
|
+
return theme === undefined ? word : resolveWrunColorWord(word, theme);
|
|
306
|
+
}
|
|
307
|
+
/** A colour at a share of its own alpha, left to CSS (no parsing here). */
|
|
308
|
+
function withShare(color, share) {
|
|
309
|
+
return `color-mix(in srgb, ${color} ${Math.round(share * 100)}%, transparent)`;
|
|
310
|
+
}
|
|
311
|
+
/** The accent ladder's rung (LK03, the color_by rule): the ladder output's
|
|
312
|
+
* latest value floored into the colours; no rung without a finite value. */
|
|
313
|
+
function accentRung(entry, snapshot) {
|
|
314
|
+
const by = entry.accent_color_by;
|
|
315
|
+
const colors = Array.isArray(entry.accent_colors) ? entry.accent_colors.filter(isWrunColorWord) : [];
|
|
316
|
+
if (typeof by !== 'string' || colors.length === 0)
|
|
317
|
+
return undefined;
|
|
318
|
+
const value = snapshot?.values?.[by];
|
|
319
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
320
|
+
return undefined;
|
|
321
|
+
return colors[Math.min(colors.length - 1, Math.max(0, Math.floor(value)))];
|
|
322
|
+
}
|
|
323
|
+
/** DW22: an offset moves inward from the anchored edges: x from a left or
|
|
324
|
+
* right edge (signed on the centre column), y from the top or bottom edge
|
|
325
|
+
* (signed on the middle row). The shift in screen px (`left`, `top`) a card
|
|
326
|
+
* at `anchor` takes from it; undefined for no offset or one off the range. */
|
|
327
|
+
export function wrunHudOffsetShift(offset, anchor) {
|
|
328
|
+
if (!Array.isArray(offset) || offset.length !== 2)
|
|
329
|
+
return undefined;
|
|
330
|
+
const x = integerIn(offset[0], -WRUN_MAX_HUD_OFFSET_PX, WRUN_MAX_HUD_OFFSET_PX);
|
|
331
|
+
const y = integerIn(offset[1], -WRUN_MAX_HUD_OFFSET_PX, WRUN_MAX_HUD_OFFSET_PX);
|
|
332
|
+
if (x === undefined || y === undefined)
|
|
333
|
+
return undefined;
|
|
334
|
+
const side = anchor ?? 'top_right';
|
|
335
|
+
return { left: side.endsWith('_right') ? -x : x, top: side.startsWith('bottom_') ? -y : y };
|
|
336
|
+
}
|
|
337
|
+
/** The inline style of a declared offset: the card moves relative to its seat in the stack. */
|
|
338
|
+
export function wrunHudOffsetCss(offset) {
|
|
339
|
+
return { position: 'relative', left: px(offset.left), top: px(offset.top) };
|
|
340
|
+
}
|
|
341
|
+
/** Item 29: a card under `WRUN_HUD_POINTER_FREE_OPACITY` takes no pointer
|
|
342
|
+
* (an invisible card must never trap a click meant for the chart). */
|
|
343
|
+
export function wrunHudPointerFree(style) {
|
|
344
|
+
return style.opacity !== undefined && style.opacity < WRUN_HUD_POINTER_FREE_OPACITY;
|
|
345
|
+
}
|
|
346
|
+
/** The card's background: a declared colour (at its declared opacity), a
|
|
347
|
+
* declared gradient, else the look's; a declared opacity alone dims today's
|
|
348
|
+
* surface. Undefined keeps today's rule. */
|
|
349
|
+
function backgroundCss(entry, row, light, theme) {
|
|
350
|
+
const direction = entry.gradient_direction === 'horizontal' ? 'to right' : 'to bottom';
|
|
351
|
+
const gradient = Array.isArray(entry.background_gradient)
|
|
352
|
+
? entry.background_gradient.filter(isWrunColorWord)
|
|
353
|
+
: undefined;
|
|
354
|
+
if (gradient !== undefined && gradient.length >= 2) {
|
|
355
|
+
return `linear-gradient(${direction}, ${gradient.map((stop) => paint(stop, theme)).join(', ')})`;
|
|
356
|
+
}
|
|
357
|
+
const opacity = numberIn(entry.background_opacity, 0, 1);
|
|
358
|
+
const lookBackground = light && row.light?.background !== undefined ? row.light.background : row.background;
|
|
359
|
+
const color = colorWord(entry.background_color) ?? lookBackground;
|
|
360
|
+
if (color !== undefined) {
|
|
361
|
+
const painted = paint(color, theme);
|
|
362
|
+
return opacity === undefined ? painted : withShare(painted, opacity);
|
|
363
|
+
}
|
|
364
|
+
if (row.backgroundGradient !== undefined && row.backgroundGradient.length >= 2) {
|
|
365
|
+
return `linear-gradient(to bottom, ${row.backgroundGradient.map((stop) => paint(stop, theme)).join(', ')})`;
|
|
366
|
+
}
|
|
367
|
+
if (opacity !== undefined)
|
|
368
|
+
return `color-mix(in srgb, var(--tooltip-bg, #17171c) ${Math.round(opacity * 100)}%, transparent)`;
|
|
369
|
+
return undefined;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* The style of one HUD entry: declared word > viewer pick > look row >
|
|
373
|
+
* today's (LK01, LK09). Every value lands in `css` as a custom property the
|
|
374
|
+
* card's base rules read (today's value is each rule's fallback), so an
|
|
375
|
+
* entry without a look and without a word resolves to an empty style.
|
|
376
|
+
*/
|
|
377
|
+
export function resolveWrunHudLook(entry, options = {}) {
|
|
378
|
+
const { theme } = options;
|
|
379
|
+
const authorLook = isWrunHudLook(entry.look) ? entry.look : undefined;
|
|
380
|
+
const viewerPick = isWrunHudLook(options.viewerPick) ? options.viewerPick : undefined;
|
|
381
|
+
const look = viewerPick ?? authorLook;
|
|
382
|
+
const row = look === undefined ? TODAY : WRUN_HUD_LOOK_TABLE[look];
|
|
383
|
+
const light = options.light === true;
|
|
384
|
+
const css = {};
|
|
385
|
+
// Surface
|
|
386
|
+
const background = backgroundCss(entry, row, light, theme);
|
|
387
|
+
if (background !== undefined)
|
|
388
|
+
css['--wrun-hud-bg'] = background;
|
|
389
|
+
const borderColor = colorWord(entry.border_color) ??
|
|
390
|
+
(light && row.light?.borderColor !== undefined ? row.light.borderColor : row.borderColor);
|
|
391
|
+
if (borderColor !== undefined)
|
|
392
|
+
css['--wrun-hud-border-color'] = paint(borderColor, theme);
|
|
393
|
+
const borderWidth = numberIn(entry.border_width, 0, WRUN_MAX_HUD_BORDER_WIDTH_PX) ?? row.borderWidth;
|
|
394
|
+
if (borderWidth !== undefined)
|
|
395
|
+
css['--wrun-hud-border-width'] = px(borderWidth);
|
|
396
|
+
if (entry.border_style === 'dashed' || entry.border_style === 'dotted' || entry.border_style === 'solid') {
|
|
397
|
+
css['--wrun-hud-border-style'] = entry.border_style;
|
|
398
|
+
}
|
|
399
|
+
const cornerRadius = numberIn(entry.corner_radius, 0, WRUN_MAX_HUD_CORNER_RADIUS_PX) ?? row.cornerRadius;
|
|
400
|
+
if (cornerRadius !== undefined)
|
|
401
|
+
css['--wrun-hud-radius'] = px(cornerRadius);
|
|
402
|
+
const padding = numberIn(entry.padding, 0, WRUN_MAX_HUD_PADDING_PX) ?? row.padding;
|
|
403
|
+
if (padding !== undefined)
|
|
404
|
+
css['--wrun-hud-padding'] = px(padding);
|
|
405
|
+
if (entry.shadow === false)
|
|
406
|
+
css['--wrun-hud-shadow'] = 'none';
|
|
407
|
+
else if (row.shadow !== undefined)
|
|
408
|
+
css['--wrun-hud-shadow'] = row.shadow;
|
|
409
|
+
const opacity = numberIn(entry.opacity, 0, 1);
|
|
410
|
+
if (opacity !== undefined)
|
|
411
|
+
css.opacity = String(opacity);
|
|
412
|
+
const width = integerIn(entry.width, WRUN_MIN_HUD_WIDTH_PX, WRUN_MAX_HUD_WIDTH_PX);
|
|
413
|
+
if (width !== undefined)
|
|
414
|
+
css.width = px(width);
|
|
415
|
+
const offset = wrunHudOffsetShift(entry.offset, options.anchor);
|
|
416
|
+
if (offset !== undefined)
|
|
417
|
+
Object.assign(css, wrunHudOffsetCss(offset));
|
|
418
|
+
// Type
|
|
419
|
+
const fontFamily = typeof entry.font_family === 'string' && WRUN_FONT_FAMILIES.includes(entry.font_family)
|
|
420
|
+
? entry.font_family
|
|
421
|
+
: row.fontFamily;
|
|
422
|
+
const fontCss = wrunFontFamilyCss(fontFamily);
|
|
423
|
+
if (fontCss !== undefined)
|
|
424
|
+
css['--wrun-hud-font'] = fontCss;
|
|
425
|
+
// A look with its own ink prints its title, labels and tracks in it (the
|
|
426
|
+
// app's muted and secondary inks belong to the app theme, not the paper);
|
|
427
|
+
// a declared text_color recolours the text alone (DW22).
|
|
428
|
+
const lookTextColor = light && row.light?.textColor !== undefined ? row.light.textColor : row.textColor;
|
|
429
|
+
const lookInk = lookTextColor === undefined ? undefined : paint(lookTextColor, theme);
|
|
430
|
+
if (lookInk !== undefined) {
|
|
431
|
+
css['--wrun-hud-title-ink'] = lookInk;
|
|
432
|
+
css['--wrun-hud-label-ink'] = row.labelTextColor === undefined ? lookInk : paint(row.labelTextColor, theme);
|
|
433
|
+
css['--wrun-hud-track'] = withShare(lookInk, 0.15);
|
|
434
|
+
}
|
|
435
|
+
const labelOpacity = light ? row.light?.labelOpacity : undefined;
|
|
436
|
+
if (labelOpacity !== undefined)
|
|
437
|
+
css['--wrun-hud-label-opacity'] = String(labelOpacity);
|
|
438
|
+
const declaredInk = colorWord(entry.text_color);
|
|
439
|
+
const ink = declaredInk === undefined ? lookInk : paint(declaredInk, theme);
|
|
440
|
+
if (ink !== undefined)
|
|
441
|
+
css['--tooltip-text'] = ink;
|
|
442
|
+
const titleInk = colorWord(entry.title_text_color);
|
|
443
|
+
if (titleInk !== undefined)
|
|
444
|
+
css['--wrun-hud-title-ink'] = paint(titleInk, theme);
|
|
445
|
+
if (row.headlineFontSize !== undefined)
|
|
446
|
+
css['--wrun-hud-headline-size'] = px(row.headlineFontSize);
|
|
447
|
+
const headlineWeight = wrunFontWeightCss(row.headlineFontWeight);
|
|
448
|
+
if (headlineWeight !== undefined)
|
|
449
|
+
css['--wrun-hud-headline-weight'] = String(headlineWeight);
|
|
450
|
+
const textGlow = numberIn(entry.text_glow, 0, WRUN_MAX_HUD_TEXT_GLOW_PX) ?? row.textGlow ?? 0;
|
|
451
|
+
if (textGlow > 0)
|
|
452
|
+
css['--wrun-hud-glow'] = `0 0 ${textGlow}px currentColor`;
|
|
453
|
+
// Accent (LK03): a declared colour, the ladder's rung, the look's, else the
|
|
454
|
+
// theme's for any look but `default` (today's marks keep the app accent).
|
|
455
|
+
const accentWord = colorWord(entry.accent_color) ??
|
|
456
|
+
accentRung(entry, options.snapshot) ??
|
|
457
|
+
row.accentColor ??
|
|
458
|
+
((look !== undefined && look !== 'default') || entry.accent_color_by !== undefined ? 'theme.accent' : undefined);
|
|
459
|
+
const accent = accentWord === undefined ? undefined : paint(accentWord, theme);
|
|
460
|
+
if (accent !== undefined) {
|
|
461
|
+
css['--wrun-hud-accent'] = accent;
|
|
462
|
+
css['--wrun-hud-mark'] = row.markInk === 'text' && ink !== undefined ? ink : accent;
|
|
463
|
+
css['--wrun-hud-split-rest'] = row.splitRest === 'accent' ? accent : paint('theme.down', theme ?? FALLBACK_THEME);
|
|
464
|
+
}
|
|
465
|
+
if (row.titleBarInk !== undefined)
|
|
466
|
+
css['--wrun-hud-title-bar-ink'] = paint(row.titleBarInk, theme);
|
|
467
|
+
if (row.windowBar !== undefined) {
|
|
468
|
+
css['--wrun-hud-window-bar'] =
|
|
469
|
+
`linear-gradient(90deg, ${row.windowBar.map((stop) => paint(stop, theme)).join(', ')})`;
|
|
470
|
+
}
|
|
471
|
+
return {
|
|
472
|
+
...(look !== undefined ? { look } : {}),
|
|
473
|
+
...(authorLook !== undefined ? { authorLook } : {}),
|
|
474
|
+
...(viewerPick !== undefined ? { viewerPick } : {}),
|
|
475
|
+
...(fontFamily !== undefined ? { fontFamily } : {}),
|
|
476
|
+
...(cornerRadius !== undefined ? { cornerRadius } : {}),
|
|
477
|
+
...(padding !== undefined ? { padding } : {}),
|
|
478
|
+
chrome: isWrunHudChrome(entry.chrome) ? entry.chrome : (row.chrome ?? WRUN_HUD_DEFAULT_CHROME),
|
|
479
|
+
texture: isWrunHudTexture(entry.texture) ? entry.texture : (row.texture ?? WRUN_HUD_DEFAULT_TEXTURE),
|
|
480
|
+
titleCase: isWrunTextCase(entry.title_case) ? entry.title_case : (row.titleCase ?? WRUN_HUD_DEFAULT_TITLE_CASE),
|
|
481
|
+
labelCase: isWrunTextCase(entry.label_case) ? entry.label_case : (row.labelCase ?? WRUN_HUD_DEFAULT_LABEL_CASE),
|
|
482
|
+
textGlow,
|
|
483
|
+
...(accent !== undefined ? { accent } : {}),
|
|
484
|
+
draws: { ...row.draws },
|
|
485
|
+
...(row.sparkHeight !== undefined ? { sparkHeight: row.sparkHeight } : {}),
|
|
486
|
+
...(row.sparkBaseline !== undefined ? { sparkBaseline: row.sparkBaseline } : {}),
|
|
487
|
+
...(row.rowLeader !== undefined ? { rowLeader: row.rowLeader } : {}),
|
|
488
|
+
...(offset !== undefined ? { offset } : {}),
|
|
489
|
+
...(opacity !== undefined ? { opacity } : {}),
|
|
490
|
+
css,
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
/** The dark-chart palette a resolver without a chart answers `theme.down` with. */
|
|
494
|
+
const FALLBACK_THEME = {
|
|
495
|
+
up: '#26a69a',
|
|
496
|
+
down: '#ef5350',
|
|
497
|
+
text: '#d1d4dc',
|
|
498
|
+
muted: 'rgba(209, 212, 220, 0.55)',
|
|
499
|
+
bg: '#131722',
|
|
500
|
+
grid: '#2a2e39',
|
|
501
|
+
accent: '#ff4608',
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* The defaults the look in force gives a tile of `kind` (undefined fields
|
|
505
|
+
* keep today's drawing). `cardMark` is the card's first meter mark, the
|
|
506
|
+
* baseline spark bars grow from on a look that says so.
|
|
507
|
+
*/
|
|
508
|
+
export function wrunHudTileLookDefaults(style, kind, cardMark) {
|
|
509
|
+
const defaults = {};
|
|
510
|
+
const draw = style.draws[kind];
|
|
511
|
+
if (draw !== undefined)
|
|
512
|
+
defaults.draw = draw;
|
|
513
|
+
if (kind === 'spark') {
|
|
514
|
+
if (style.sparkHeight !== undefined)
|
|
515
|
+
defaults.height = style.sparkHeight;
|
|
516
|
+
if (style.sparkBaseline === 'zero')
|
|
517
|
+
defaults.baseline = 0;
|
|
518
|
+
else if (style.sparkBaseline === 'mark' && cardMark !== undefined && Number.isFinite(cardMark)) {
|
|
519
|
+
defaults.baseline = cardMark;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (kind === 'rows' && style.rowLeader !== undefined)
|
|
523
|
+
defaults.leader = style.rowLeader;
|
|
524
|
+
return defaults;
|
|
525
|
+
}
|
|
526
|
+
/** The luminance of a palette's background, read as a light theme above
|
|
527
|
+
* 0.5; an unreadable colour counts as dark (the chart's default). */
|
|
528
|
+
export function wrunHudThemeIsLight(theme) {
|
|
529
|
+
const text = theme?.bg?.trim().toLowerCase() ?? '';
|
|
530
|
+
let r;
|
|
531
|
+
let g;
|
|
532
|
+
let b;
|
|
533
|
+
const hex = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(text);
|
|
534
|
+
if (hex) {
|
|
535
|
+
let digits = hex[1];
|
|
536
|
+
if (digits.length <= 4)
|
|
537
|
+
digits = [...digits].map((digit) => digit + digit).join('');
|
|
538
|
+
r = parseInt(digits.slice(0, 2), 16);
|
|
539
|
+
g = parseInt(digits.slice(2, 4), 16);
|
|
540
|
+
b = parseInt(digits.slice(4, 6), 16);
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
const rgb = /^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/.exec(text);
|
|
544
|
+
if (!rgb)
|
|
545
|
+
return false;
|
|
546
|
+
[r, g, b] = [Number(rgb[1]), Number(rgb[2]), Number(rgb[3])];
|
|
547
|
+
}
|
|
548
|
+
if (![r, g, b].every((channel) => Number.isFinite(channel)))
|
|
549
|
+
return false;
|
|
550
|
+
return (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255 > 0.5;
|
|
551
|
+
}
|
|
552
|
+
/** The quote assets a display symbol may end in; the rest is the base the
|
|
553
|
+
* `cover` chrome prints (LK08). */
|
|
554
|
+
const WRUN_HUD_QUOTE_SUFFIXES = [
|
|
555
|
+
'USDT',
|
|
556
|
+
'USDC',
|
|
557
|
+
'FDUSD',
|
|
558
|
+
'BUSD',
|
|
559
|
+
'TUSD',
|
|
560
|
+
'PERP',
|
|
561
|
+
'USD',
|
|
562
|
+
'DAI',
|
|
563
|
+
'EUR',
|
|
564
|
+
'GBP',
|
|
565
|
+
'JPY',
|
|
566
|
+
'BTC',
|
|
567
|
+
'ETH',
|
|
568
|
+
'BNB',
|
|
569
|
+
'SOL',
|
|
570
|
+
];
|
|
571
|
+
const WRUN_HUD_COVER_MAX_CHARS = 5;
|
|
572
|
+
/** The text the `cover` chrome's tile holds: the chart's base asset, read
|
|
573
|
+
* off the display symbol (a known quote suffix and a pool address stripped),
|
|
574
|
+
* at most five characters; empty for no symbol. */
|
|
575
|
+
export function wrunHudCoverText(symbol) {
|
|
576
|
+
if (typeof symbol !== 'string')
|
|
577
|
+
return '';
|
|
578
|
+
let base = symbol.split('·')[0].split(':').pop()?.trim().toUpperCase() ?? '';
|
|
579
|
+
base = base.replace(/[^A-Z0-9]/g, '');
|
|
580
|
+
for (const quote of WRUN_HUD_QUOTE_SUFFIXES) {
|
|
581
|
+
if (base.length > quote.length + 1 && base.endsWith(quote)) {
|
|
582
|
+
base = base.slice(0, -quote.length);
|
|
583
|
+
break;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return base.slice(0, WRUN_HUD_COVER_MAX_CHARS);
|
|
587
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { WrunRunResult } from '../chart/wrun-run-result.util.js';
|
|
2
|
+
import type { WrunRefusalSeed } from './wrun-refusal.util.js';
|
|
3
|
+
/**
|
|
4
|
+
* The rows of a wrun result (or a set of them, keyed under `outputs`) the chart integrates, as the
|
|
5
|
+
* view the kScript preflight's row budget counts. An output that draws on no bar leaves the view: the
|
|
6
|
+
* adapter's normalizer (`normalizeKScriptRunResultForTitanCharts`) drops every row with no drawable
|
|
7
|
+
* cell, so it mounts with no rows at all, while the result holds a NaN row per bar for it (a line or a
|
|
8
|
+
* box a setting switches off). An output drawn on any bar keeps all its rows: the adapter lays it back
|
|
9
|
+
* over the chart's bars. A view the budget already fits is returned as it is (it bounds this one), so
|
|
10
|
+
* a result under the budget pays no scan, and an output's verdict is kept with its rows (a live tick's
|
|
11
|
+
* build hands the rows of an unchanged output back).
|
|
12
|
+
*/
|
|
13
|
+
export declare function wrunIntegratedRowsView(view: {
|
|
14
|
+
outputs?: unknown;
|
|
15
|
+
}): {
|
|
16
|
+
outputs?: unknown;
|
|
17
|
+
};
|
|
18
|
+
/** A result the row budget refuses: the message the run's error carries (its `FE_KSCRIPT_OUTPUT_OVERSIZED` code is
|
|
19
|
+
* what `isWrunDrawingBudgetRefusal` and the recovery's deterministic latch read) and the refusal seed. */
|
|
20
|
+
export interface WrunIntegrationBudgetRefusal {
|
|
21
|
+
message: string;
|
|
22
|
+
seed: WrunRefusalSeed;
|
|
23
|
+
}
|
|
24
|
+
/** The policy's verdict: the result (its drawings trimmed in place when it fits), or the refusal and the result as
|
|
25
|
+
* it came (nothing trimmed). */
|
|
26
|
+
export interface WrunIntegrationBudgetVerdict {
|
|
27
|
+
result: WrunRunResult;
|
|
28
|
+
refusal?: WrunIntegrationBudgetRefusal;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The chart's integration budget over the parent and its lower panes (a series child counts against
|
|
32
|
+
* the same budget), caps that trim and say (WRUN-COST-GUARD U4):
|
|
33
|
+
* - rows past the kScript preflight's 400k refuse, with the kScript path's diagnostic code
|
|
34
|
+
* (rows cannot be trimmed without changing the plot), counted as the chart integrates them
|
|
35
|
+
* (`wrunIntegratedRowsView`): the code in the message is what
|
|
36
|
+
* `isWrunDrawingBudgetRefusal` reads to suspend a live session and what the recovery's
|
|
37
|
+
* deterministic latch keys on;
|
|
38
|
+
* - drawings past 2,000 keep the newest by `createdBar` (`trimWrunRunDrawings`, tables and widgets
|
|
39
|
+
* untouched), and ONE run context rides the parent and its lower panes to the drawing door, the
|
|
40
|
+
* only writer of the "Drawings capped" row.
|
|
41
|
+
* Trims the result's drawings in place when the rows fit; returns the verdict and never throws (the executor's
|
|
42
|
+
* `applyWrunIntegrationBudget` throws the refusal). `details` ride the preflight check as the executor passes them.
|
|
43
|
+
*/
|
|
44
|
+
export declare function applyWrunIntegrationBudgetPolicy(runResult: WrunRunResult, details?: {
|
|
45
|
+
chartIndex?: number;
|
|
46
|
+
indicatorId?: string;
|
|
47
|
+
}): WrunIntegrationBudgetVerdict;
|