@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,539 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WRUN-STYLE g3 (DW01 DW04 DW05 DW06 DW11 DW38): the widget looks of
|
|
3
|
+
* `draw.card`, `draw.feed`, `draw.meter` and `draw.ladder`, from the sheet's
|
|
4
|
+
* snake_case words to the engine's camelCase keys (titan `DrawingCardStyle`,
|
|
5
|
+
* `DrawingLadderStyle`, `DrawingCardHeadline` and the record props beside
|
|
6
|
+
* them). Three doors, all pure (no chart, no DOM, worker safe):
|
|
7
|
+
*
|
|
8
|
+
* - `wrunWidgetEngineProps(drawing, sheetId)`: the `style` block of a card,
|
|
9
|
+
* feed or meter record (DW04 chrome preset and inks, DW11 surface and type,
|
|
10
|
+
* DW01 rule). A card always carries an opaque surface and, without
|
|
11
|
+
* `state_by`, no state chrome (template QA D30, C39, B16); a feed or meter
|
|
12
|
+
* carries nothing when the declaration has no look word, so its record
|
|
13
|
+
* stays byte-identical. It also checks every other word of the declaration
|
|
14
|
+
* (headline fields, row colours, feed and meter words) so one door refuses
|
|
15
|
+
* by name.
|
|
16
|
+
* - `wrunLadderEngineStyle(drawing, sheetId)`: the ladder's own `style` (DW38).
|
|
17
|
+
* - `wrunWidgetRecordPatch(drawing, props, ctx)`: the record props beside the
|
|
18
|
+
* style: the headline's font fields (DW01), `layer` (DW05), `safeArea`
|
|
19
|
+
* (DW06), the feed's `timeFormat`, the meter's `barHeight` and
|
|
20
|
+
* `trackColor`, the ladder's pre-formatted `valueTexts` (DW38).
|
|
21
|
+
*
|
|
22
|
+
* Every range the kit enforces is restated here (X22) and refused by name:
|
|
23
|
+
* `WRUN <sheet id>: <kind> drawing '<name>' <key> ...`. Colour words ride
|
|
24
|
+
* through unresolved (a theme token resolves at the drawing door,
|
|
25
|
+
* kscript-drawings.util); font words resolve to their CSS stacks here (X14),
|
|
26
|
+
* since titan never sees a font word. `corner_radius` lands as the engine's
|
|
27
|
+
* `cornerRadius` (D1, X15).
|
|
28
|
+
*
|
|
29
|
+
* One word is translated rather than passed through (clip audit item 30):
|
|
30
|
+
* `controls: "none"` reaches the engine as `hover` (wrunWidgetEngineControls),
|
|
31
|
+
* so a widget never loses the viewer's hide control.
|
|
32
|
+
*/
|
|
33
|
+
import { formatWrunNumber, isWrunColorWord, WRUN_FONT_FAMILIES, WRUN_FONT_WEIGHTS, WRUN_MAX_VALUE_DECIMALS, WRUN_MAX_VALUE_UNIT_CHARS, WRUN_VALUE_FORMATS, wrunFontFamilyCss, } from './wrun-style-words.util.js';
|
|
34
|
+
// Bounds (the kit's, restated per X22; D1 for the corner radius).
|
|
35
|
+
export const WRUN_WIDGET_CORNER_RADIUS_MAX_PX = 32;
|
|
36
|
+
export const WRUN_WIDGET_PADDING_MAX_PX = 24;
|
|
37
|
+
export const WRUN_WIDGET_WIDTH_MIN_PX = 80;
|
|
38
|
+
export const WRUN_WIDGET_WIDTH_MAX_PX = 1200;
|
|
39
|
+
export const WRUN_WIDGET_BORDER_WIDTH_MAX_PX = 10;
|
|
40
|
+
export const WRUN_WIDGET_OFFSET_MAX_PX = 4096;
|
|
41
|
+
export const WRUN_WIDGET_FONT_SIZE_MIN_PX = 6;
|
|
42
|
+
export const WRUN_WIDGET_FONT_SIZE_MAX_PX = 64;
|
|
43
|
+
export const WRUN_WIDGET_GRADIENT_MIN_STOPS = 2;
|
|
44
|
+
export const WRUN_WIDGET_GRADIENT_MAX_STOPS = 8;
|
|
45
|
+
export const WRUN_LADDER_WIDTH_FRAC_MIN = 0.02;
|
|
46
|
+
export const WRUN_LADDER_WIDTH_FRAC_MAX = 0.5;
|
|
47
|
+
export const WRUN_METER_BAR_HEIGHT_MIN_PX = 2;
|
|
48
|
+
export const WRUN_METER_BAR_HEIGHT_MAX_PX = 40;
|
|
49
|
+
/** The card headline's defaults (DW01): 24 px, bold, left-aligned. */
|
|
50
|
+
export const WRUN_CARD_HEADLINE_FONT_SIZE_PX = 24;
|
|
51
|
+
export const WRUN_CARD_HEADLINE_FONT_WEIGHT = 'bold';
|
|
52
|
+
export const WRUN_CARD_HEADLINE_ALIGN = 'left';
|
|
53
|
+
const WRUN_WIDGET_CHROMES = ['state', 'plain'];
|
|
54
|
+
const WRUN_WIDGET_CONTROLS = ['always', 'hover', 'none'];
|
|
55
|
+
const WRUN_WIDGET_PANELS = ['overlay', 'lower'];
|
|
56
|
+
/**
|
|
57
|
+
* The engine's controls word for a declared one (clip audit item 30). The
|
|
58
|
+
* sheet's `none` still validates and still removes the glyphs at rest, but
|
|
59
|
+
* it reaches the engine as `hover`: the engine's own `none` never paints a
|
|
60
|
+
* hide glyph AND ignores the viewer's hidden override, which leaves a widget
|
|
61
|
+
* on the chart with no way to close it. `hover` paints nothing until the
|
|
62
|
+
* pointer is inside the box, then the hide control (the collapse glyph beside
|
|
63
|
+
* it), and honours the override. `always` and `hover` pass through untouched.
|
|
64
|
+
*/
|
|
65
|
+
export function wrunWidgetEngineControls(word) {
|
|
66
|
+
return word === 'none' ? 'hover' : word;
|
|
67
|
+
}
|
|
68
|
+
const WRUN_BORDER_STYLES = ['solid', 'dashed', 'dotted'];
|
|
69
|
+
const WRUN_GRADIENT_DIRECTIONS = ['vertical', 'horizontal'];
|
|
70
|
+
const WRUN_TEXT_ALIGNS = ['left', 'center', 'right'];
|
|
71
|
+
const WRUN_FEED_TIME_FORMATS = ['HH:mm:ss', 'HH:mm', 'MM-dd HH:mm', 'none'];
|
|
72
|
+
const WRUN_CARD_VALUE_FORMAT_WORDS = [...WRUN_VALUE_FORMATS, 'pct'];
|
|
73
|
+
/** The frozen colour-word message (the foundation's, 2.1). */
|
|
74
|
+
export const WRUN_COLOR_WORD_MESSAGE = 'a colour must be #rrggbb, #rrggbbaa or one of theme.up, theme.down, theme.text, theme.muted, theme.bg, theme.grid, theme.accent';
|
|
75
|
+
/**
|
|
76
|
+
* DW04: what `chrome: "plain"` stands for, in the sheet's words: no state
|
|
77
|
+
* text, no stripe, no border, a muted title, glyphs on hover. A word declared
|
|
78
|
+
* beside the preset wins over it.
|
|
79
|
+
*/
|
|
80
|
+
export const WRUN_CHROME_PLAIN_DEFAULTS = Object.freeze({
|
|
81
|
+
show_state: false,
|
|
82
|
+
stripe: false,
|
|
83
|
+
border_width: 0,
|
|
84
|
+
title_text_color: 'theme.muted',
|
|
85
|
+
controls: 'hover',
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* The surface of a card that declares none (template QA D30, C39): the
|
|
89
|
+
* chart's own background, opaque. The engine's default card surface is a
|
|
90
|
+
* 7 to 10 percent wash, so candles drew through the rows of a card anchored
|
|
91
|
+
* over the newest bars. A declared `background_color` or
|
|
92
|
+
* `background_gradient` wins; a declared `background_opacity` alone dims
|
|
93
|
+
* this surface.
|
|
94
|
+
*/
|
|
95
|
+
export const WRUN_CARD_DEFAULT_BACKGROUND = 'theme.bg';
|
|
96
|
+
/**
|
|
97
|
+
* What a card without `state_by` paints instead of state chrome (template QA
|
|
98
|
+
* B16): no state word (the engine would print "ok"), no state stripe, and a
|
|
99
|
+
* frame in the grid ink instead of the `ok` state teal. The stripe and the
|
|
100
|
+
* frame stay the author's when the card names its own ink (`accent_color` or
|
|
101
|
+
* `state_colors`), and every word declared beside them wins.
|
|
102
|
+
*/
|
|
103
|
+
export const WRUN_CARD_STATELESS_DEFAULTS = Object.freeze({
|
|
104
|
+
show_state: false,
|
|
105
|
+
stripe: false,
|
|
106
|
+
border_color: 'theme.grid',
|
|
107
|
+
});
|
|
108
|
+
function isRecord(value) {
|
|
109
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
110
|
+
}
|
|
111
|
+
function quoted(words) {
|
|
112
|
+
return words.map((word) => `'${word}'`).join(', ');
|
|
113
|
+
}
|
|
114
|
+
function wordListMessage(key, words) {
|
|
115
|
+
return words.length === 2
|
|
116
|
+
? `${key} must be '${words[0]}' or '${words[1]}'`
|
|
117
|
+
: `${key} must be one of ${quoted(words)}`;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* One declaration's reader: every refusal names the sheet, the kind, the
|
|
121
|
+
* drawing and the key (`prefix` names a nested object, `headline.`).
|
|
122
|
+
*/
|
|
123
|
+
class WidgetWords {
|
|
124
|
+
words;
|
|
125
|
+
sheetId;
|
|
126
|
+
kind;
|
|
127
|
+
name;
|
|
128
|
+
prefix;
|
|
129
|
+
constructor(words, sheetId, kind, name, prefix = '') {
|
|
130
|
+
this.words = words;
|
|
131
|
+
this.sheetId = sheetId;
|
|
132
|
+
this.kind = kind;
|
|
133
|
+
this.name = name;
|
|
134
|
+
this.prefix = prefix;
|
|
135
|
+
}
|
|
136
|
+
nested(key, words) {
|
|
137
|
+
return new WidgetWords(words, this.sheetId, this.kind, this.name, `${this.prefix}${key}.`);
|
|
138
|
+
}
|
|
139
|
+
refuse(message) {
|
|
140
|
+
const sheet = this.sheetId === '' ? 'WRUN' : `WRUN ${this.sheetId}:`;
|
|
141
|
+
throw new Error(`${sheet} ${this.kind} drawing '${this.name}' ${message}`);
|
|
142
|
+
}
|
|
143
|
+
label(key) {
|
|
144
|
+
return `${this.prefix}${key}`;
|
|
145
|
+
}
|
|
146
|
+
has(key) {
|
|
147
|
+
return this.words[key] !== undefined;
|
|
148
|
+
}
|
|
149
|
+
raw(key) {
|
|
150
|
+
return this.words[key];
|
|
151
|
+
}
|
|
152
|
+
boolean(key) {
|
|
153
|
+
const value = this.words[key];
|
|
154
|
+
if (value === undefined)
|
|
155
|
+
return undefined;
|
|
156
|
+
if (typeof value !== 'boolean')
|
|
157
|
+
this.refuse(`${this.label(key)} must be true or false`);
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
word(key, words) {
|
|
161
|
+
const value = this.words[key];
|
|
162
|
+
if (value === undefined)
|
|
163
|
+
return undefined;
|
|
164
|
+
if (typeof value !== 'string' || !words.includes(value)) {
|
|
165
|
+
this.refuse(wordListMessage(this.label(key), words));
|
|
166
|
+
}
|
|
167
|
+
return value;
|
|
168
|
+
}
|
|
169
|
+
number(key, min, max) {
|
|
170
|
+
const value = this.words[key];
|
|
171
|
+
if (value === undefined)
|
|
172
|
+
return undefined;
|
|
173
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value < min || value > max) {
|
|
174
|
+
this.refuse(`${this.label(key)} must be between ${min} and ${max}`);
|
|
175
|
+
}
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
integer(key, min, max) {
|
|
179
|
+
const value = this.words[key];
|
|
180
|
+
if (value === undefined)
|
|
181
|
+
return undefined;
|
|
182
|
+
if (typeof value !== 'number' || !Number.isInteger(value) || value < min || value > max) {
|
|
183
|
+
this.refuse(`${this.label(key)} must be an integer from ${min} to ${max}`);
|
|
184
|
+
}
|
|
185
|
+
return value;
|
|
186
|
+
}
|
|
187
|
+
color(key) {
|
|
188
|
+
const value = this.words[key];
|
|
189
|
+
if (value === undefined)
|
|
190
|
+
return undefined;
|
|
191
|
+
if (!isWrunColorWord(value))
|
|
192
|
+
this.refuse(`${this.label(key)}: ${WRUN_COLOR_WORD_MESSAGE}`);
|
|
193
|
+
return value;
|
|
194
|
+
}
|
|
195
|
+
colors(key, min, max, message) {
|
|
196
|
+
const value = this.words[key];
|
|
197
|
+
if (value === undefined)
|
|
198
|
+
return undefined;
|
|
199
|
+
if (!Array.isArray(value) || value.length < min || value.length > max)
|
|
200
|
+
this.refuse(`${this.label(key)} ${message}`);
|
|
201
|
+
return value.map((entry) => {
|
|
202
|
+
if (!isWrunColorWord(entry))
|
|
203
|
+
this.refuse(`${this.label(key)}: ${WRUN_COLOR_WORD_MESSAGE}`);
|
|
204
|
+
return entry;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/** A colour word, or the row-colour ladder `{ color_by, colors }` (DW01, DW23). */
|
|
208
|
+
colorOrLadder(key) {
|
|
209
|
+
const value = this.words[key];
|
|
210
|
+
if (value === undefined)
|
|
211
|
+
return;
|
|
212
|
+
if (isRecord(value)) {
|
|
213
|
+
if (typeof value.color_by !== 'string')
|
|
214
|
+
this.refuse(`${this.label(key)}.color_by must name a declared output`);
|
|
215
|
+
if (!Array.isArray(value.colors) || value.colors.length < 2) {
|
|
216
|
+
this.refuse(`${this.label(key)}.colors must list at least 2 entries`);
|
|
217
|
+
}
|
|
218
|
+
for (const stop of value.colors) {
|
|
219
|
+
if (!isWrunColorWord(stop))
|
|
220
|
+
this.refuse(`${this.label(key)}.colors: ${WRUN_COLOR_WORD_MESSAGE}`);
|
|
221
|
+
}
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (!isWrunColorWord(value))
|
|
225
|
+
this.refuse(`${this.label(key)}: ${WRUN_COLOR_WORD_MESSAGE}`);
|
|
226
|
+
}
|
|
227
|
+
fontSize(key) {
|
|
228
|
+
return this.integer(key, WRUN_WIDGET_FONT_SIZE_MIN_PX, WRUN_WIDGET_FONT_SIZE_MAX_PX);
|
|
229
|
+
}
|
|
230
|
+
fontWeight(key) {
|
|
231
|
+
return this.word(key, WRUN_FONT_WEIGHTS);
|
|
232
|
+
}
|
|
233
|
+
/** A font word as its CSS stack (X14): titan takes CSS strings only. */
|
|
234
|
+
fontFamily(key) {
|
|
235
|
+
const word = this.word(key, WRUN_FONT_FAMILIES);
|
|
236
|
+
return word === undefined ? undefined : wrunFontFamilyCss(word);
|
|
237
|
+
}
|
|
238
|
+
/** The number-format companions (conventions 8, X3): `decimals`, `signed`
|
|
239
|
+
* and `unit` need `format`; `format` takes the shared words (plus `pct`
|
|
240
|
+
* on a card row or headline). Undefined when nothing is declared. */
|
|
241
|
+
numberFormat(cardWords) {
|
|
242
|
+
const formatWords = cardWords ? WRUN_CARD_VALUE_FORMAT_WORDS : WRUN_VALUE_FORMATS;
|
|
243
|
+
const format = this.word('format', formatWords);
|
|
244
|
+
const decimals = this.integer('decimals', 0, WRUN_MAX_VALUE_DECIMALS);
|
|
245
|
+
const signed = this.boolean('signed');
|
|
246
|
+
const unit = this.words.unit;
|
|
247
|
+
if (unit !== undefined && (typeof unit !== 'string' || unit.length > WRUN_MAX_VALUE_UNIT_CHARS)) {
|
|
248
|
+
this.refuse(`${this.label('unit')} takes at most ${WRUN_MAX_VALUE_UNIT_CHARS} characters`);
|
|
249
|
+
}
|
|
250
|
+
if (format === undefined) {
|
|
251
|
+
if (decimals !== undefined)
|
|
252
|
+
this.refuse(`${this.label('decimals')} needs format`);
|
|
253
|
+
if (signed !== undefined)
|
|
254
|
+
this.refuse(`${this.label('signed')} needs format`);
|
|
255
|
+
if (unit !== undefined)
|
|
256
|
+
this.refuse(`${this.label('unit')} needs format`);
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
format,
|
|
261
|
+
...(decimals !== undefined ? { decimals } : {}),
|
|
262
|
+
...(signed !== undefined ? { signed } : {}),
|
|
263
|
+
...(unit !== undefined ? { unit: unit } : {}),
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function widgetWords(drawing, sheetId) {
|
|
268
|
+
return new WidgetWords(drawing, sheetId, drawing.kind, drawing.name);
|
|
269
|
+
}
|
|
270
|
+
/** A key/value pair only when the value is declared. */
|
|
271
|
+
function keyed(key, value) {
|
|
272
|
+
return value === undefined ? {} : { [key]: value };
|
|
273
|
+
}
|
|
274
|
+
/** A card's own words beyond its style (DW01 DW23): the headline's source,
|
|
275
|
+
* number format, font, alignment and colour, and every row colour as a
|
|
276
|
+
* colour word (a ladder's stops included). Refuses by name. */
|
|
277
|
+
function checkCardWords(drawing, words) {
|
|
278
|
+
drawing.rows.forEach((row, index) => {
|
|
279
|
+
if (row.color === undefined)
|
|
280
|
+
return;
|
|
281
|
+
words.nested(`rows[${index}]`, row).colorOrLadder('color');
|
|
282
|
+
});
|
|
283
|
+
const headline = drawing.headline;
|
|
284
|
+
if (headline === undefined)
|
|
285
|
+
return;
|
|
286
|
+
const fields = words.nested('headline', headline);
|
|
287
|
+
if ((headline.output === undefined) === (headline.text === undefined)) {
|
|
288
|
+
words.refuse('headline needs exactly one of output (a numeric output) or text (a string slot)');
|
|
289
|
+
}
|
|
290
|
+
fields.numberFormat(true);
|
|
291
|
+
fields.fontSize('font_size');
|
|
292
|
+
fields.fontWeight('font_weight');
|
|
293
|
+
fields.word('align', WRUN_TEXT_ALIGNS);
|
|
294
|
+
fields.colorOrLadder('color');
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The surface, type and chrome words of a card, feed or meter (DW04 DW11
|
|
298
|
+
* DW01) as the engine's `style` block. The `chrome: "plain"` preset fills
|
|
299
|
+
* `showState`, `stripe`, `borderWidth`, `titleColor` and `controls` unless
|
|
300
|
+
* the same word is declared beside it; a card's `state_colors` and
|
|
301
|
+
* `accent_color` are exclusive; `controls: "none"` lands as `hover`
|
|
302
|
+
* (wrunWidgetEngineControls, item 30). A card always carries a surface
|
|
303
|
+
* (WRUN_CARD_DEFAULT_BACKGROUND when it declares none) and, without
|
|
304
|
+
* `state_by`, no state chrome (WRUN_CARD_STATELESS_DEFAULTS). A feed or meter
|
|
305
|
+
* gets `{}` (no `style` key) when no look word is declared, so its record is
|
|
306
|
+
* what it always was. Every other word of the declaration is checked here
|
|
307
|
+
* too, so one door refuses by name.
|
|
308
|
+
*/
|
|
309
|
+
export function wrunWidgetEngineProps(drawing, sheetId) {
|
|
310
|
+
if (drawing.kind !== 'card' && drawing.kind !== 'feed' && drawing.kind !== 'meter')
|
|
311
|
+
return {};
|
|
312
|
+
const words = widgetWords(drawing, sheetId);
|
|
313
|
+
const chrome = words.word('chrome', WRUN_WIDGET_CHROMES);
|
|
314
|
+
const plain = chrome === 'plain';
|
|
315
|
+
words.word('panel', WRUN_WIDGET_PANELS);
|
|
316
|
+
words.boolean('above_drawings');
|
|
317
|
+
words.boolean('safe_area');
|
|
318
|
+
const style = {
|
|
319
|
+
...keyed('background', words.color('background_color')),
|
|
320
|
+
...keyed('backgroundOpacity', words.number('background_opacity', 0, 1)),
|
|
321
|
+
...keyed('backgroundGradient', words.colors('background_gradient', WRUN_WIDGET_GRADIENT_MIN_STOPS, WRUN_WIDGET_GRADIENT_MAX_STOPS, `must list ${WRUN_WIDGET_GRADIENT_MIN_STOPS} to ${WRUN_WIDGET_GRADIENT_MAX_STOPS} colours`)),
|
|
322
|
+
...keyed('gradientDirection', words.word('gradient_direction', WRUN_GRADIENT_DIRECTIONS)),
|
|
323
|
+
...keyed('borderColor', words.color('border_color')),
|
|
324
|
+
...keyed('borderWidth', words.number('border_width', 0, WRUN_WIDGET_BORDER_WIDTH_MAX_PX) ??
|
|
325
|
+
(plain ? WRUN_CHROME_PLAIN_DEFAULTS.border_width : undefined)),
|
|
326
|
+
...keyed('borderStyle', words.word('border_style', WRUN_BORDER_STYLES)),
|
|
327
|
+
...keyed('cornerRadius', words.number('corner_radius', 0, WRUN_WIDGET_CORNER_RADIUS_MAX_PX)),
|
|
328
|
+
...keyed('padding', words.number('padding', 0, WRUN_WIDGET_PADDING_MAX_PX)),
|
|
329
|
+
...keyed('width', words.integer('width', WRUN_WIDGET_WIDTH_MIN_PX, WRUN_WIDGET_WIDTH_MAX_PX)),
|
|
330
|
+
...keyed('opacity', words.number('opacity', 0, 1)),
|
|
331
|
+
...keyed('fontSize', words.fontSize('font_size')),
|
|
332
|
+
...keyed('fontFamily', words.fontFamily('font_family')),
|
|
333
|
+
...keyed('fontWeight', words.fontWeight('font_weight')),
|
|
334
|
+
...keyed('textColor', words.color('text_color')),
|
|
335
|
+
...keyed('labelColor', words.color('label_text_color')),
|
|
336
|
+
...keyed('titleColor', words.color('title_text_color') ?? (plain ? WRUN_CHROME_PLAIN_DEFAULTS.title_text_color : undefined)),
|
|
337
|
+
...keyed('titleFontSize', words.fontSize('title_font_size')),
|
|
338
|
+
...keyed('titleFontWeight', words.fontWeight('title_font_weight')),
|
|
339
|
+
...keyed('accentColor', words.color('accent_color')),
|
|
340
|
+
...keyed('stripe', words.boolean('stripe') ?? (plain ? WRUN_CHROME_PLAIN_DEFAULTS.stripe : undefined)),
|
|
341
|
+
...keyed('controls', wrunWidgetEngineControls(words.word('controls', WRUN_WIDGET_CONTROLS) ?? (plain ? WRUN_CHROME_PLAIN_DEFAULTS.controls : undefined))),
|
|
342
|
+
};
|
|
343
|
+
if (drawing.kind === 'card') {
|
|
344
|
+
const stateColors = words.colors('state_colors', 4, 4, 'must list exactly 4 colours (ok, armed, fired, error)');
|
|
345
|
+
if (stateColors !== undefined && words.has('accent_color'))
|
|
346
|
+
words.refuse('accent_color and state_colors are exclusive');
|
|
347
|
+
// A card has a state only when an output drives it (B16): without one the engine would print "ok" and frame
|
|
348
|
+
// the card in the ok teal.
|
|
349
|
+
const stateless = drawing.state_by === undefined;
|
|
350
|
+
const presetShowState = plain
|
|
351
|
+
? WRUN_CHROME_PLAIN_DEFAULTS.show_state
|
|
352
|
+
: stateless
|
|
353
|
+
? WRUN_CARD_STATELESS_DEFAULTS.show_state
|
|
354
|
+
: undefined;
|
|
355
|
+
Object.assign(style, {
|
|
356
|
+
...keyed('showState', words.boolean('show_state') ?? presetShowState),
|
|
357
|
+
...keyed('stateColors', stateColors),
|
|
358
|
+
...keyed('rule', words.boolean('rule')),
|
|
359
|
+
...keyed('ruleColor', words.color('rule_color')),
|
|
360
|
+
});
|
|
361
|
+
if (stateless && !plain && stateColors === undefined && !words.has('accent_color')) {
|
|
362
|
+
style.stripe ??= WRUN_CARD_STATELESS_DEFAULTS.stripe;
|
|
363
|
+
style.borderColor ??= WRUN_CARD_STATELESS_DEFAULTS.border_color;
|
|
364
|
+
}
|
|
365
|
+
// D30, C39: a card is never see-through by default.
|
|
366
|
+
if (style.background === undefined && style.backgroundGradient === undefined) {
|
|
367
|
+
style.background = WRUN_CARD_DEFAULT_BACKGROUND;
|
|
368
|
+
}
|
|
369
|
+
checkCardWords(drawing, words);
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
if (plain)
|
|
373
|
+
style.showState = WRUN_CHROME_PLAIN_DEFAULTS.show_state;
|
|
374
|
+
if (drawing.kind === 'feed')
|
|
375
|
+
words.word('time_format', WRUN_FEED_TIME_FORMATS);
|
|
376
|
+
else {
|
|
377
|
+
words.integer('bar_height', WRUN_METER_BAR_HEIGHT_MIN_PX, WRUN_METER_BAR_HEIGHT_MAX_PX);
|
|
378
|
+
words.color('track_color');
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return Object.keys(style).length > 0 ? { style } : {};
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* The ladder's look (DW38) as the engine's `style` block: its share of the
|
|
385
|
+
* pane, the inset from the docked side (`offset[0]`; y must be 0), the bar
|
|
386
|
+
* alpha and inks, the value text's font and the divider ink. Undefined when
|
|
387
|
+
* no look word is declared. The value-text format words are checked here
|
|
388
|
+
* too (the record patch prints them).
|
|
389
|
+
*/
|
|
390
|
+
export function wrunLadderEngineStyle(drawing, sheetId) {
|
|
391
|
+
if (drawing.kind !== 'ladder')
|
|
392
|
+
return undefined;
|
|
393
|
+
const words = widgetWords(drawing, sheetId);
|
|
394
|
+
words.word('panel', WRUN_WIDGET_PANELS);
|
|
395
|
+
words.numberFormat(false);
|
|
396
|
+
const offset = words.raw('offset');
|
|
397
|
+
let offsetX;
|
|
398
|
+
if (offset !== undefined) {
|
|
399
|
+
if (!Array.isArray(offset) || offset.length !== 2)
|
|
400
|
+
words.refuse('offset must be an [x, y] pair');
|
|
401
|
+
const [x, y] = offset;
|
|
402
|
+
if (typeof x !== 'number' || !Number.isInteger(x) || x < 0 || x > WRUN_WIDGET_OFFSET_MAX_PX) {
|
|
403
|
+
words.refuse(`offset: a ladder offset x must be an integer from 0 to ${WRUN_WIDGET_OFFSET_MAX_PX}`);
|
|
404
|
+
}
|
|
405
|
+
if (y !== 0)
|
|
406
|
+
words.refuse('offset: a ladder offset moves along x only; y must be 0');
|
|
407
|
+
offsetX = x;
|
|
408
|
+
}
|
|
409
|
+
const style = {
|
|
410
|
+
...keyed('widthFrac', words.number('width_frac', WRUN_LADDER_WIDTH_FRAC_MIN, WRUN_LADDER_WIDTH_FRAC_MAX)),
|
|
411
|
+
...keyed('offsetX', offsetX),
|
|
412
|
+
...keyed('opacity', words.number('opacity', 0, 1)),
|
|
413
|
+
...keyed('color', words.color('color')),
|
|
414
|
+
...keyed('labels', words.boolean('labels')),
|
|
415
|
+
...keyed('textColor', words.color('text_color')),
|
|
416
|
+
...keyed('fontSize', words.fontSize('font_size')),
|
|
417
|
+
...keyed('fontFamily', words.fontFamily('font_family')),
|
|
418
|
+
...keyed('fontWeight', words.fontWeight('font_weight')),
|
|
419
|
+
...keyed('dividerColor', words.color('divider_color')),
|
|
420
|
+
};
|
|
421
|
+
return Object.keys(style).length > 0 ? style : undefined;
|
|
422
|
+
}
|
|
423
|
+
/** The headline the selection resolved (`{ text, color? }`), read off the record. */
|
|
424
|
+
function selectedHeadline(props) {
|
|
425
|
+
return isRecord(props.headline) && typeof props.headline.text === 'string' ? props.headline : undefined;
|
|
426
|
+
}
|
|
427
|
+
/** The headline's font fields (DW01) over the selection's `{ text, color? }`:
|
|
428
|
+
* 24 px bold left-aligned unless declared. */
|
|
429
|
+
function headlineRecord(headline, selected, words) {
|
|
430
|
+
const fields = words.nested('headline', headline);
|
|
431
|
+
return {
|
|
432
|
+
...selected,
|
|
433
|
+
fontSize: fields.fontSize('font_size') ?? WRUN_CARD_HEADLINE_FONT_SIZE_PX,
|
|
434
|
+
fontWeight: fields.fontWeight('font_weight') ?? WRUN_CARD_HEADLINE_FONT_WEIGHT,
|
|
435
|
+
align: fields.word('align', WRUN_TEXT_ALIGNS) ?? WRUN_CARD_HEADLINE_ALIGN,
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
/** The ladder rows' pre-formatted value texts (DW38): every row's value
|
|
439
|
+
* through the declared number format at the chart's digits; absent unless
|
|
440
|
+
* one of `format`, `decimals`, `signed`, `unit` is declared. */
|
|
441
|
+
function ladderValueTexts(props, words, priceDigits) {
|
|
442
|
+
const spec = words.numberFormat(false);
|
|
443
|
+
if (spec === undefined || !Array.isArray(props.rows))
|
|
444
|
+
return undefined;
|
|
445
|
+
return props.rows.map((row) => {
|
|
446
|
+
const value = Array.isArray(row) ? row[1] : undefined;
|
|
447
|
+
return typeof value === 'number' ? formatWrunNumber(value, { ...spec, priceDigits }) : '';
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* The record props beside a widget's style: a card's headline font fields
|
|
452
|
+
* (DW01), `layer: 'top'` for `above_drawings` (DW05), `safeArea` (DW06), a
|
|
453
|
+
* feed's `timeFormat`, a meter's `barHeight` and `trackColor`, a ladder's
|
|
454
|
+
* `valueTexts` (DW38). `props` is the record the selection produced; the
|
|
455
|
+
* returned patch is assigned over it by the run-result adapter. `ctx.offchart`
|
|
456
|
+
* is the overlay side the record lands on (the adapter routes the pane by
|
|
457
|
+
* it; no patch key depends on it today); `ctx.sheetId` names the sheet in a
|
|
458
|
+
* refusal (the style doors above have refused the same words already).
|
|
459
|
+
*/
|
|
460
|
+
export function wrunWidgetRecordPatch(drawing, props, ctx) {
|
|
461
|
+
if (drawing.kind !== 'card' && drawing.kind !== 'feed' && drawing.kind !== 'meter' && drawing.kind !== 'ladder') {
|
|
462
|
+
return {};
|
|
463
|
+
}
|
|
464
|
+
const words = widgetWords(drawing, ctx.sheetId ?? '');
|
|
465
|
+
const patch = {};
|
|
466
|
+
if (drawing.kind === 'ladder') {
|
|
467
|
+
const valueTexts = ladderValueTexts(props, words, ctx.priceDigits);
|
|
468
|
+
if (valueTexts !== undefined)
|
|
469
|
+
patch.valueTexts = valueTexts;
|
|
470
|
+
return patch;
|
|
471
|
+
}
|
|
472
|
+
if (words.boolean('above_drawings') === true)
|
|
473
|
+
patch.layer = 'top';
|
|
474
|
+
if (words.boolean('safe_area') === true)
|
|
475
|
+
patch.safeArea = true;
|
|
476
|
+
if (drawing.kind === 'card') {
|
|
477
|
+
const selected = selectedHeadline(props);
|
|
478
|
+
if (drawing.headline !== undefined && selected !== undefined) {
|
|
479
|
+
patch.headline = headlineRecord(drawing.headline, selected, words);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
else if (drawing.kind === 'feed') {
|
|
483
|
+
const timeFormat = words.word('time_format', WRUN_FEED_TIME_FORMATS);
|
|
484
|
+
if (timeFormat !== undefined)
|
|
485
|
+
patch.timeFormat = timeFormat;
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
const barHeight = words.integer('bar_height', WRUN_METER_BAR_HEIGHT_MIN_PX, WRUN_METER_BAR_HEIGHT_MAX_PX);
|
|
489
|
+
if (barHeight !== undefined)
|
|
490
|
+
patch.barHeight = barHeight;
|
|
491
|
+
const trackColor = words.color('track_color');
|
|
492
|
+
if (trackColor !== undefined)
|
|
493
|
+
patch.trackColor = trackColor;
|
|
494
|
+
}
|
|
495
|
+
return patch;
|
|
496
|
+
}
|
|
497
|
+
/** The number format a ladder declares for its value texts (DW38), for
|
|
498
|
+
* callers that print a ladder value themselves; undefined when none. */
|
|
499
|
+
export function wrunLadderValueFormat(drawing, sheetId) {
|
|
500
|
+
return widgetWords(drawing, sheetId).numberFormat(false);
|
|
501
|
+
}
|
|
502
|
+
/** The widget style words a card, feed or meter declaration may carry (the
|
|
503
|
+
* g3 surface + chrome keys), for callers that need the list. */
|
|
504
|
+
export const WRUN_WIDGET_STYLE_KEYS = [
|
|
505
|
+
'chrome',
|
|
506
|
+
'stripe',
|
|
507
|
+
'controls',
|
|
508
|
+
'accent_color',
|
|
509
|
+
'title_text_color',
|
|
510
|
+
'title_font_size',
|
|
511
|
+
'title_font_weight',
|
|
512
|
+
'background_color',
|
|
513
|
+
'background_opacity',
|
|
514
|
+
'background_gradient',
|
|
515
|
+
'gradient_direction',
|
|
516
|
+
'border_color',
|
|
517
|
+
'border_width',
|
|
518
|
+
'border_style',
|
|
519
|
+
'corner_radius',
|
|
520
|
+
'padding',
|
|
521
|
+
'width',
|
|
522
|
+
'opacity',
|
|
523
|
+
'font_size',
|
|
524
|
+
'font_family',
|
|
525
|
+
'font_weight',
|
|
526
|
+
'text_color',
|
|
527
|
+
'label_text_color',
|
|
528
|
+
'above_drawings',
|
|
529
|
+
'safe_area',
|
|
530
|
+
'panel',
|
|
531
|
+
];
|
|
532
|
+
/** The card-only words (DW01, DW04) beside the shared style keys. */
|
|
533
|
+
export const WRUN_CARD_STYLE_KEYS = [
|
|
534
|
+
'headline',
|
|
535
|
+
'rule',
|
|
536
|
+
'rule_color',
|
|
537
|
+
'show_state',
|
|
538
|
+
'state_colors',
|
|
539
|
+
];
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chart's own context for a WRUN run (KITS-ROUND-2-PLAN, "Chart host
|
|
3
|
+
* fills" and "Chart-name placeholders"), the FE host side:
|
|
4
|
+
*
|
|
5
|
+
* - The chart host fills (`chart.interval_sec()`, `chart.bg_color()`,
|
|
6
|
+
* `chart.fg_color()`): the bar interval in seconds (the same milliseconds
|
|
7
|
+
* the run's clock uses, / 1000) and the chart's effective background and
|
|
8
|
+
* text colour as the kit's packed colour `(r<<24)|(g<<16)|(b<<8)|a` read
|
|
9
|
+
* as a SIGNED 32-bit integer (white = -1), the exact inverse of
|
|
10
|
+
* `wrunRgbaFromI32`. A value the host cannot read stays absent, and the
|
|
11
|
+
* param reads its declared 0 (unavailable).
|
|
12
|
+
* - The chart-name placeholders `{{symbol}}`, `{{exchange}}` and
|
|
13
|
+
* `{{timeframe}}` in run text, replaced at display time with the names the
|
|
14
|
+
* chart header shows (resolved per chart in wrun-chart-context-names.util).
|
|
15
|
+
* Every other `{{...}}` stays as written; the module never sees the names.
|
|
16
|
+
*
|
|
17
|
+
* Pure (the colour helpers, the interval table and the frame parsers only);
|
|
18
|
+
* the name resolution, which reads the store and the header formatters,
|
|
19
|
+
* lives in wrun-chart-context-names.util so the hosted-lane modules never
|
|
20
|
+
* pull it, and the theme-switch rerun in wrun-chart-context-theme.util.
|
|
21
|
+
*/
|
|
22
|
+
import type { WrunIndicatorMetadata, WrunOutputRow } from '../../interfaces/wrun-runtime.interface.js';
|
|
23
|
+
import type { WrunHandleRecord } from './wrun-handles.util.js';
|
|
24
|
+
import type { WrunHostFillContext } from './wrun-script-inputs.util.js';
|
|
25
|
+
import { type WrunChartNames } from './wrun-chart-names.util.js';
|
|
26
|
+
/** The chart half of a host-fill context (the market half is the caller's). */
|
|
27
|
+
export type WrunChartContextHostFill = Pick<WrunHostFillContext, 'intervalSec' | 'bgColor' | 'fgColor' | 'upColor' | 'downColor' | 'gridColor'>;
|
|
28
|
+
/** A CSS colour (the engine theme's `#rrggbb`, `#rgb`, `rgba(...)`) as the
|
|
29
|
+
* kit's packed signed i32 `(r<<24)|(g<<16)|(b<<8)|a` (white = -1), the
|
|
30
|
+
* inverse of `wrunRgbaFromI32`. Not a colour: undefined. Never the colour
|
|
31
|
+
* PARAM packing (`packWrunColor`), which is a different encoding. */
|
|
32
|
+
export declare function wrunPackChartColor(css: unknown): number | undefined;
|
|
33
|
+
/** A bar interval in milliseconds as the seconds `chart.interval_sec()`
|
|
34
|
+
* reads; anything but a positive finite number is absent. */
|
|
35
|
+
export declare function wrunChartIntervalSec(intervalMs: unknown): number | undefined;
|
|
36
|
+
/** A chart interval word ('15m', '1h') in milliseconds off the interval
|
|
37
|
+
* table; a word the table does not hold is undefined (the hosted lanes
|
|
38
|
+
* leave the param absent, the browser run's clock has its own fallback). */
|
|
39
|
+
export declare function wrunChartIntervalMsOf(interval: unknown): number | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* The chart host fills off the pane's engine and the run's bar interval:
|
|
42
|
+
* `bgColor` = the engine theme's `backgroundColor` (the custom chart
|
|
43
|
+
* background is already merged in, useChartTheme), `fgColor` = its
|
|
44
|
+
* `xAxis.fontColor` (the chart's text colour), `upColor` / `downColor` = its
|
|
45
|
+
* `bullishCandleColor` / `bearishCandleColor`, `gridColor` = its
|
|
46
|
+
* `grid.color` (WRUN-STYLE TH-candle-colors), `intervalSec` = `intervalMs`
|
|
47
|
+
* / 1000. Feature-detected: a bare test double or a pin without a theme
|
|
48
|
+
* yields no colour, an unknown interval no seconds. Shared by the browser
|
|
49
|
+
* run (wrunHostFillContextFor) and the hosted lanes
|
|
50
|
+
* (wrunHostedLaneHostFillContext).
|
|
51
|
+
*/
|
|
52
|
+
export declare function wrunChartContextHostFill(engine: unknown, intervalMs: unknown): WrunChartContextHostFill;
|
|
53
|
+
export { substituteWrunChartNames, substituteWrunChartNamesJson, type WrunChartNames } from './wrun-chart-names.util.js';
|
|
54
|
+
/** The text a run carries: the rows' string slots, the handle set's label
|
|
55
|
+
* text and the run-level frames (the last two are read off the rows' own
|
|
56
|
+
* WeakMap attachments by the caller, since a substituted rows array is a
|
|
57
|
+
* new array those attachments do not follow). */
|
|
58
|
+
export interface WrunRunText {
|
|
59
|
+
rows: ReadonlyArray<WrunOutputRow>;
|
|
60
|
+
handles?: ReadonlyArray<WrunHandleRecord>;
|
|
61
|
+
frames?: ReadonlyArray<string | undefined>;
|
|
62
|
+
}
|
|
63
|
+
/** The sheet slice the frame guard reads: the frame slots and every consumer of one. */
|
|
64
|
+
export type WrunFrameSheet = Pick<WrunIndicatorMetadata, 'frames' | 'levels' | 'panels' | 'drawings'>;
|
|
65
|
+
/**
|
|
66
|
+
* True when every consumer of frame slot `at` in `sheet` (a levels ladder, a
|
|
67
|
+
* panel, a ladder, feed or minicharts drawing) accepts `json`, through the
|
|
68
|
+
* SAME parsers the run's selection uses (wrun-frame-host). A substituted name
|
|
69
|
+
* can push a text past its grammar cap (a ladder divider label holds 24
|
|
70
|
+
* characters, a feed line 80, a tile value 64, a mini-chart grid title 40),
|
|
71
|
+
* and a refused frame fails the whole run, so the substitution checks before
|
|
72
|
+
* it commits. Fail-closed: a drawing that reads the slot through a parser
|
|
73
|
+
* this guard does not know refuses the substitution (its frame rides as the
|
|
74
|
+
* module wrote it). A slot nothing consumes cannot fail a run and is
|
|
75
|
+
* accepted as is.
|
|
76
|
+
*/
|
|
77
|
+
export declare function wrunFrameAccepted(sheet: WrunFrameSheet, at: number, json: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* A run's text with the chart names substituted, once, for every route
|
|
80
|
+
* (the full run, the reseed and the live tick all funnel through
|
|
81
|
+
* buildWrunOverlayRunResult): string slots on every row, the `text` of each
|
|
82
|
+
* label handle, and the frame JSON (values JSON-escaped, and only when the
|
|
83
|
+
* sheet's frame consumers still accept the result; see wrunFrameAccepted).
|
|
84
|
+
* Every piece without a placeholder keeps its identity (the same rows array,
|
|
85
|
+
* the same row objects, the same handle records), so a run without
|
|
86
|
+
* placeholders is byte-identical to the host's answer and its WeakMap
|
|
87
|
+
* attachments still resolve. No names: the run as is.
|
|
88
|
+
*/
|
|
89
|
+
export declare function substituteWrunRunText(run: WrunRunText, names: WrunChartNames | undefined, sheet?: WrunFrameSheet): WrunRunText;
|