@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,213 @@
|
|
|
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 { Intervals } from '../../constants/interval.constants.js';
|
|
23
|
+
import { parseWrunColor } from './wrun-color-facts.util.js';
|
|
24
|
+
import { substituteWrunChartNames, substituteWrunChartNamesJson } from './wrun-chart-names.util.js';
|
|
25
|
+
import { parseWrunFeedFrame, parseWrunLadderFrame, parseWrunLevelsFrame, parseWrunMiniChartsFrame, parseWrunPanelFrame, } from './wrun-frames.js';
|
|
26
|
+
/** A CSS colour (the engine theme's `#rrggbb`, `#rgb`, `rgba(...)`) as the
|
|
27
|
+
* kit's packed signed i32 `(r<<24)|(g<<16)|(b<<8)|a` (white = -1), the
|
|
28
|
+
* inverse of `wrunRgbaFromI32`. Not a colour: undefined. Never the colour
|
|
29
|
+
* PARAM packing (`packWrunColor`), which is a different encoding. */
|
|
30
|
+
export function wrunPackChartColor(css) {
|
|
31
|
+
const rgba = parseWrunColor(css);
|
|
32
|
+
if (rgba === undefined)
|
|
33
|
+
return undefined;
|
|
34
|
+
return (((rgba.r & 0xff) << 24) | ((rgba.g & 0xff) << 16) | ((rgba.b & 0xff) << 8) | (Math.round(rgba.a * 255) & 0xff) | 0);
|
|
35
|
+
}
|
|
36
|
+
/** A bar interval in milliseconds as the seconds `chart.interval_sec()`
|
|
37
|
+
* reads; anything but a positive finite number is absent. */
|
|
38
|
+
export function wrunChartIntervalSec(intervalMs) {
|
|
39
|
+
return typeof intervalMs === 'number' && Number.isFinite(intervalMs) && intervalMs > 0
|
|
40
|
+
? intervalMs / 1000
|
|
41
|
+
: undefined;
|
|
42
|
+
}
|
|
43
|
+
/** A chart interval word ('15m', '1h') in milliseconds off the interval
|
|
44
|
+
* table; a word the table does not hold is undefined (the hosted lanes
|
|
45
|
+
* leave the param absent, the browser run's clock has its own fallback). */
|
|
46
|
+
export function wrunChartIntervalMsOf(interval) {
|
|
47
|
+
if (typeof interval !== 'string')
|
|
48
|
+
return undefined;
|
|
49
|
+
const ms = Intervals.map_unit[interval];
|
|
50
|
+
return typeof ms === 'number' && Number.isFinite(ms) && ms > 0 ? ms : undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The chart host fills off the pane's engine and the run's bar interval:
|
|
54
|
+
* `bgColor` = the engine theme's `backgroundColor` (the custom chart
|
|
55
|
+
* background is already merged in, useChartTheme), `fgColor` = its
|
|
56
|
+
* `xAxis.fontColor` (the chart's text colour), `upColor` / `downColor` = its
|
|
57
|
+
* `bullishCandleColor` / `bearishCandleColor`, `gridColor` = its
|
|
58
|
+
* `grid.color` (WRUN-STYLE TH-candle-colors), `intervalSec` = `intervalMs`
|
|
59
|
+
* / 1000. Feature-detected: a bare test double or a pin without a theme
|
|
60
|
+
* yields no colour, an unknown interval no seconds. Shared by the browser
|
|
61
|
+
* run (wrunHostFillContextFor) and the hosted lanes
|
|
62
|
+
* (wrunHostedLaneHostFillContext).
|
|
63
|
+
*/
|
|
64
|
+
export function wrunChartContextHostFill(engine, intervalMs) {
|
|
65
|
+
let theme;
|
|
66
|
+
try {
|
|
67
|
+
theme = engine?.theme;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
theme = undefined;
|
|
71
|
+
}
|
|
72
|
+
const intervalSec = wrunChartIntervalSec(intervalMs);
|
|
73
|
+
const bgColor = wrunPackChartColor(theme?.backgroundColor);
|
|
74
|
+
const fgColor = wrunPackChartColor(theme?.xAxis?.fontColor);
|
|
75
|
+
const upColor = wrunPackChartColor(theme?.bullishCandleColor);
|
|
76
|
+
const downColor = wrunPackChartColor(theme?.bearishCandleColor);
|
|
77
|
+
const gridColor = wrunPackChartColor(theme?.grid?.color);
|
|
78
|
+
return {
|
|
79
|
+
...(intervalSec !== undefined ? { intervalSec } : {}),
|
|
80
|
+
...(bgColor !== undefined ? { bgColor } : {}),
|
|
81
|
+
...(fgColor !== undefined ? { fgColor } : {}),
|
|
82
|
+
...(upColor !== undefined ? { upColor } : {}),
|
|
83
|
+
...(downColor !== undefined ? { downColor } : {}),
|
|
84
|
+
...(gridColor !== undefined ? { gridColor } : {}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
// Chart-name placeholders
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// The placeholders are a thin fact the window header reads synchronously (wrun-chart-names.util);
|
|
91
|
+
// this module keeps exporting them for the run lanes.
|
|
92
|
+
export { substituteWrunChartNames, substituteWrunChartNamesJson } from './wrun-chart-names.util.js';
|
|
93
|
+
function substituteRows(rows, names) {
|
|
94
|
+
let copy;
|
|
95
|
+
for (let at = 0; at < rows.length; at += 1) {
|
|
96
|
+
const row = rows[at];
|
|
97
|
+
const strings = row.strings;
|
|
98
|
+
if (strings === undefined)
|
|
99
|
+
continue;
|
|
100
|
+
let rowCopy;
|
|
101
|
+
for (let slot = 0; slot < strings.length; slot += 1) {
|
|
102
|
+
const text = strings[slot];
|
|
103
|
+
if (typeof text !== 'string')
|
|
104
|
+
continue;
|
|
105
|
+
const replaced = substituteWrunChartNames(text, names);
|
|
106
|
+
if (replaced === text)
|
|
107
|
+
continue;
|
|
108
|
+
rowCopy ??= [...strings];
|
|
109
|
+
rowCopy[slot] = replaced;
|
|
110
|
+
}
|
|
111
|
+
if (rowCopy === undefined)
|
|
112
|
+
continue;
|
|
113
|
+
copy ??= [...rows];
|
|
114
|
+
copy[at] = { ...row, strings: rowCopy };
|
|
115
|
+
}
|
|
116
|
+
return copy ?? rows;
|
|
117
|
+
}
|
|
118
|
+
function substituteHandles(handles, names) {
|
|
119
|
+
if (handles === undefined)
|
|
120
|
+
return undefined;
|
|
121
|
+
let copy;
|
|
122
|
+
handles.forEach((handle, at) => {
|
|
123
|
+
if (handle.kind !== 'label' || typeof handle.props.text !== 'string')
|
|
124
|
+
return;
|
|
125
|
+
const text = substituteWrunChartNames(handle.props.text, names);
|
|
126
|
+
if (text === handle.props.text)
|
|
127
|
+
return;
|
|
128
|
+
copy ??= [...handles];
|
|
129
|
+
copy[at] = { ...handle, props: { ...handle.props, text } };
|
|
130
|
+
});
|
|
131
|
+
return copy ?? handles;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* True when every consumer of frame slot `at` in `sheet` (a levels ladder, a
|
|
135
|
+
* panel, a ladder, feed or minicharts drawing) accepts `json`, through the
|
|
136
|
+
* SAME parsers the run's selection uses (wrun-frame-host). A substituted name
|
|
137
|
+
* can push a text past its grammar cap (a ladder divider label holds 24
|
|
138
|
+
* characters, a feed line 80, a tile value 64, a mini-chart grid title 40),
|
|
139
|
+
* and a refused frame fails the whole run, so the substitution checks before
|
|
140
|
+
* it commits. Fail-closed: a drawing that reads the slot through a parser
|
|
141
|
+
* this guard does not know refuses the substitution (its frame rides as the
|
|
142
|
+
* module wrote it). A slot nothing consumes cannot fail a run and is
|
|
143
|
+
* accepted as is.
|
|
144
|
+
*/
|
|
145
|
+
export function wrunFrameAccepted(sheet, at, json) {
|
|
146
|
+
const slot = sheet.frames?.[at]?.name;
|
|
147
|
+
if (typeof slot !== 'string')
|
|
148
|
+
return true;
|
|
149
|
+
try {
|
|
150
|
+
for (const level of sheet.levels ?? [])
|
|
151
|
+
if (level.frame === slot)
|
|
152
|
+
parseWrunLevelsFrame(json, slot);
|
|
153
|
+
for (const panel of sheet.panels ?? [])
|
|
154
|
+
if (panel.frame === slot)
|
|
155
|
+
parseWrunPanelFrame(json, slot, panel);
|
|
156
|
+
for (const drawing of sheet.drawings ?? []) {
|
|
157
|
+
if (!('frame' in drawing) || drawing.frame !== slot)
|
|
158
|
+
continue;
|
|
159
|
+
if (drawing.kind === 'ladder')
|
|
160
|
+
parseWrunLadderFrame(json, slot);
|
|
161
|
+
else if (drawing.kind === 'feed')
|
|
162
|
+
parseWrunFeedFrame(json, slot);
|
|
163
|
+
else if (drawing.kind === 'minicharts')
|
|
164
|
+
parseWrunMiniChartsFrame(json, slot);
|
|
165
|
+
else
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function substituteFrames(frames, names, sheet) {
|
|
175
|
+
if (frames === undefined)
|
|
176
|
+
return undefined;
|
|
177
|
+
let copy;
|
|
178
|
+
frames.forEach((frame, at) => {
|
|
179
|
+
if (typeof frame !== 'string')
|
|
180
|
+
return;
|
|
181
|
+
const replaced = substituteWrunChartNamesJson(frame, names);
|
|
182
|
+
if (replaced === frame)
|
|
183
|
+
return;
|
|
184
|
+
// A substitution the frame grammar refuses keeps the module's own text
|
|
185
|
+
// (the placeholders show as written) rather than failing the run.
|
|
186
|
+
if (sheet !== undefined && !wrunFrameAccepted(sheet, at, replaced))
|
|
187
|
+
return;
|
|
188
|
+
copy ??= [...frames];
|
|
189
|
+
copy[at] = replaced;
|
|
190
|
+
});
|
|
191
|
+
return copy ?? frames;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* A run's text with the chart names substituted, once, for every route
|
|
195
|
+
* (the full run, the reseed and the live tick all funnel through
|
|
196
|
+
* buildWrunOverlayRunResult): string slots on every row, the `text` of each
|
|
197
|
+
* label handle, and the frame JSON (values JSON-escaped, and only when the
|
|
198
|
+
* sheet's frame consumers still accept the result; see wrunFrameAccepted).
|
|
199
|
+
* Every piece without a placeholder keeps its identity (the same rows array,
|
|
200
|
+
* the same row objects, the same handle records), so a run without
|
|
201
|
+
* placeholders is byte-identical to the host's answer and its WeakMap
|
|
202
|
+
* attachments still resolve. No names: the run as is.
|
|
203
|
+
*/
|
|
204
|
+
export function substituteWrunRunText(run, names, sheet) {
|
|
205
|
+
if (names === undefined)
|
|
206
|
+
return run;
|
|
207
|
+
const rows = substituteRows(run.rows, names);
|
|
208
|
+
const handles = substituteHandles(run.handles, names);
|
|
209
|
+
const frames = substituteFrames(run.frames, names, sheet);
|
|
210
|
+
if (rows === run.rows && handles === run.handles && frames === run.frames)
|
|
211
|
+
return run;
|
|
212
|
+
return { rows, handles, frames };
|
|
213
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chart-name placeholders `{{symbol}}`, `{{exchange}}` and `{{timeframe}}` in run text
|
|
3
|
+
* (KITS-ROUND-2-PLAN, "Chart-name placeholders"), replaced at display time with the names the
|
|
4
|
+
* chart header shows (resolved per chart in wrun-chart-context-names.util). Every other `{{...}}`
|
|
5
|
+
* stays as written. A thin fact: the window header (window-cell-guards.util) substitutes an
|
|
6
|
+
* owner's name synchronously on any chart, so it reads the substitution here, without the run
|
|
7
|
+
* context's frame parsers behind it (wrun-chart-context.util re-exports it for the run lanes;
|
|
8
|
+
* docs/features/kscript/wrun/wrun-browser-runtime.md, "Boot doors").
|
|
9
|
+
*/
|
|
10
|
+
/** The names the chart header shows: the display symbol, the display
|
|
11
|
+
* exchange name and the short interval label of the interval button. */
|
|
12
|
+
export interface WrunChartNames {
|
|
13
|
+
symbol: string;
|
|
14
|
+
exchange: string;
|
|
15
|
+
timeframe: string;
|
|
16
|
+
}
|
|
17
|
+
/** `text` with the chart-name placeholders replaced; text without one (or
|
|
18
|
+
* no names at hand) is returned as is, the same string. */
|
|
19
|
+
export declare function substituteWrunChartNames(text: string, names: WrunChartNames | undefined): string;
|
|
20
|
+
/** The same substitution inside a JSON document (a wrun-4 frame): each value
|
|
21
|
+
* rides JSON-escaped, so a quote or a backslash in a name keeps the frame
|
|
22
|
+
* parseable. A placeholder can only sit inside a JSON string. */
|
|
23
|
+
export declare function substituteWrunChartNamesJson(json: string, names: WrunChartNames | undefined): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chart-name placeholders `{{symbol}}`, `{{exchange}}` and `{{timeframe}}` in run text
|
|
3
|
+
* (KITS-ROUND-2-PLAN, "Chart-name placeholders"), replaced at display time with the names the
|
|
4
|
+
* chart header shows (resolved per chart in wrun-chart-context-names.util). Every other `{{...}}`
|
|
5
|
+
* stays as written. A thin fact: the window header (window-cell-guards.util) substitutes an
|
|
6
|
+
* owner's name synchronously on any chart, so it reads the substitution here, without the run
|
|
7
|
+
* context's frame parsers behind it (wrun-chart-context.util re-exports it for the run lanes;
|
|
8
|
+
* docs/features/kscript/wrun/wrun-browser-runtime.md, "Boot doors").
|
|
9
|
+
*/
|
|
10
|
+
/** Exactly `{{symbol}}`, `{{exchange}}`, `{{timeframe}}`: case-sensitive, no
|
|
11
|
+
* spaces inside the braces. Any other `{{...}}` is not a placeholder. */
|
|
12
|
+
const CHART_NAME_PLACEHOLDER_RE = /\{\{(symbol|exchange|timeframe)\}\}/g;
|
|
13
|
+
function hasChartNamePlaceholder(text) {
|
|
14
|
+
if (!text.includes('{{'))
|
|
15
|
+
return false;
|
|
16
|
+
CHART_NAME_PLACEHOLDER_RE.lastIndex = 0;
|
|
17
|
+
return CHART_NAME_PLACEHOLDER_RE.test(text);
|
|
18
|
+
}
|
|
19
|
+
/** `text` with the chart-name placeholders replaced; text without one (or
|
|
20
|
+
* no names at hand) is returned as is, the same string. */
|
|
21
|
+
export function substituteWrunChartNames(text, names) {
|
|
22
|
+
if (names === undefined || !hasChartNamePlaceholder(text))
|
|
23
|
+
return text;
|
|
24
|
+
return text.replace(CHART_NAME_PLACEHOLDER_RE, (_, key) => names[key]);
|
|
25
|
+
}
|
|
26
|
+
/** The same substitution inside a JSON document (a wrun-4 frame): each value
|
|
27
|
+
* rides JSON-escaped, so a quote or a backslash in a name keeps the frame
|
|
28
|
+
* parseable. A placeholder can only sit inside a JSON string. */
|
|
29
|
+
export function substituteWrunChartNamesJson(json, names) {
|
|
30
|
+
if (names === undefined || !hasChartNamePlaceholder(json))
|
|
31
|
+
return json;
|
|
32
|
+
return json.replace(CHART_NAME_PLACEHOLDER_RE, (_, key) => JSON.stringify(names[key]).slice(1, -1));
|
|
33
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A time as the chart's wrun cards print it (the hover card's bar time, a timed spans or rays record's `{{start}}`
|
|
3
|
+
* and `{{end}}`, WRUN-MARKS-CONTRACT F2): the time axis's own month abbreviations (the engine's axis and crosshair
|
|
4
|
+
* labels are not localized; the card reads like them), minute precision, seconds only for a time off the minute. The
|
|
5
|
+
* caller shifts the time by the chart's display offset first (chart-display-timezone.util: the hover card's subtitle
|
|
6
|
+
* in wrun-legend-hover, the offset the mount door hands a timed readout in wrun-batched-marks.util), so this leaf
|
|
7
|
+
* imports nothing and the batched readout stays off the store. No per-call Intl formatter: this sits on the hover
|
|
8
|
+
* path.
|
|
9
|
+
*/
|
|
10
|
+
/** `shifted` (an epoch ms whose UTC wall time is the chart's displayed wall time) as the chart prints it ("Sep 12 ·
|
|
11
|
+
* 14:00", "Jan 3 · 09:05:30"); undefined for a time that is not a finite number. */
|
|
12
|
+
export declare function wrunChartTimeText(shifted: number | undefined): string | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A time as the chart's wrun cards print it (the hover card's bar time, a timed spans or rays record's `{{start}}`
|
|
3
|
+
* and `{{end}}`, WRUN-MARKS-CONTRACT F2): the time axis's own month abbreviations (the engine's axis and crosshair
|
|
4
|
+
* labels are not localized; the card reads like them), minute precision, seconds only for a time off the minute. The
|
|
5
|
+
* caller shifts the time by the chart's display offset first (chart-display-timezone.util: the hover card's subtitle
|
|
6
|
+
* in wrun-legend-hover, the offset the mount door hands a timed readout in wrun-batched-marks.util), so this leaf
|
|
7
|
+
* imports nothing and the batched readout stays off the store. No per-call Intl formatter: this sits on the hover
|
|
8
|
+
* path.
|
|
9
|
+
*/
|
|
10
|
+
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
11
|
+
/** `shifted` (an epoch ms whose UTC wall time is the chart's displayed wall time) as the chart prints it ("Sep 12 ·
|
|
12
|
+
* 14:00", "Jan 3 · 09:05:30"); undefined for a time that is not a finite number. */
|
|
13
|
+
export function wrunChartTimeText(shifted) {
|
|
14
|
+
if (shifted === undefined || !Number.isFinite(shifted))
|
|
15
|
+
return undefined;
|
|
16
|
+
const date = new Date(shifted);
|
|
17
|
+
if (Number.isNaN(date.getTime()))
|
|
18
|
+
return undefined;
|
|
19
|
+
const two = (value) => String(value).padStart(2, '0');
|
|
20
|
+
const seconds = date.getUTCSeconds();
|
|
21
|
+
const clock = `${two(date.getUTCHours())}:${two(date.getUTCMinutes())}${seconds === 0 ? '' : `:${two(seconds)}`}`;
|
|
22
|
+
return `${MONTHS[date.getUTCMonth()]} ${date.getUTCDate()} · ${clock}`;
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The owning Indicator of a child overlay id, null for any other id. A
|
|
2
|
+
* child's legend X removes its parent: the child is the parent's furniture
|
|
3
|
+
* and the next run would mount it again. */
|
|
4
|
+
export declare function wrunChildOverlayParentId(id: string): string | null;
|
|
5
|
+
/** The viewer row that keeps the eye a reader moved on a child's own legend
|
|
6
|
+
* row (an inset strip's): `<kind>:<name>:hidden` on the OWNING Indicator's
|
|
7
|
+
* settings (`inset:cumulative:hidden`), true while the reader keeps the
|
|
8
|
+
* child hidden. A child has no workspace row, so the visibility door writes
|
|
9
|
+
* its eye there and the child mount reads it whenever it mounts the child or
|
|
10
|
+
* the owner's eye moves. Null for any id that is no child's. */
|
|
11
|
+
export declare function wrunChildHiddenRowKey(id: string): string | null;
|
|
12
|
+
/** True for a key wrunChildHiddenRowKey mints (a viewer row, never a param). */
|
|
13
|
+
export declare function isWrunChildHiddenRowKey(key: string): boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Child overlay ids of a browser-lane Indicator (wrun-panel-mount.util):
|
|
2
|
+
* `<parent>::panel:<name>`, `<parent>::series:<name>`, `<parent>::levels:<name>`,
|
|
3
|
+
* `<parent>::inset:<name>`, the price canvases of WRUN-STYLE g6
|
|
4
|
+
* `<parent>::heatmap:<name>`, `<parent>::profile:<name>`, `<parent>::matrix:<name>`, and the
|
|
5
|
+
* batched marks of WRUN-BATCHED-MARKS `<parent>::marks:<name>`, `<parent>::spans:<name>`,
|
|
6
|
+
* `<parent>::rays:<name>`: one word per child kind the run result builds, checked against its
|
|
7
|
+
* union, so a new child kind fails typecheck here until its id is one the store can read back.
|
|
8
|
+
* A leaf module: the store reads it on every removal, so it imports nothing at run time. */
|
|
9
|
+
const CHILD_KIND_WORDS = {
|
|
10
|
+
panel: true,
|
|
11
|
+
series: true,
|
|
12
|
+
levels: true,
|
|
13
|
+
inset: true,
|
|
14
|
+
heatmap: true,
|
|
15
|
+
profile: true,
|
|
16
|
+
matrix: true,
|
|
17
|
+
marks: true,
|
|
18
|
+
spans: true,
|
|
19
|
+
rays: true,
|
|
20
|
+
};
|
|
21
|
+
const CHILD_KINDS = `(?:${Object.keys(CHILD_KIND_WORDS).join('|')})`;
|
|
22
|
+
const CHILD_ID_PATTERN = new RegExp(`^(.+)::${CHILD_KINDS}:`);
|
|
23
|
+
const CHILD_ID_PARTS = new RegExp(`^.+::(${CHILD_KINDS}:.+)$`);
|
|
24
|
+
const CHILD_HIDDEN_ROW_PATTERN = new RegExp(`^${CHILD_KINDS}:.+:hidden$`);
|
|
25
|
+
/** The owning Indicator of a child overlay id, null for any other id. A
|
|
26
|
+
* child's legend X removes its parent: the child is the parent's furniture
|
|
27
|
+
* and the next run would mount it again. */
|
|
28
|
+
export function wrunChildOverlayParentId(id) {
|
|
29
|
+
return CHILD_ID_PATTERN.exec(id)?.[1] ?? null;
|
|
30
|
+
}
|
|
31
|
+
/** The viewer row that keeps the eye a reader moved on a child's own legend
|
|
32
|
+
* row (an inset strip's): `<kind>:<name>:hidden` on the OWNING Indicator's
|
|
33
|
+
* settings (`inset:cumulative:hidden`), true while the reader keeps the
|
|
34
|
+
* child hidden. A child has no workspace row, so the visibility door writes
|
|
35
|
+
* its eye there and the child mount reads it whenever it mounts the child or
|
|
36
|
+
* the owner's eye moves. Null for any id that is no child's. */
|
|
37
|
+
export function wrunChildHiddenRowKey(id) {
|
|
38
|
+
const child = CHILD_ID_PARTS.exec(id)?.[1];
|
|
39
|
+
return child === undefined ? null : `${child}:hidden`;
|
|
40
|
+
}
|
|
41
|
+
/** True for a key wrunChildHiddenRowKey mints (a viewer row, never a param). */
|
|
42
|
+
export function isWrunChildHiddenRowKey(key) {
|
|
43
|
+
return CHILD_HIDDEN_ROW_PATTERN.test(key);
|
|
44
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface WrunRgba {
|
|
2
|
+
r: number;
|
|
3
|
+
g: number;
|
|
4
|
+
b: number;
|
|
5
|
+
/** 0..1 */
|
|
6
|
+
a: number;
|
|
7
|
+
}
|
|
8
|
+
/** The Style page row key of one output property (frozen, plan 1.7):
|
|
9
|
+
* `__style__<output>__<property>`; the target may also name a text
|
|
10
|
+
* renderer, heatmap, profile or levels declaration (C1, parseWrunStyleTarget). */
|
|
11
|
+
export declare const WRUN_STYLE_ROW_PREFIX = "__style__";
|
|
12
|
+
/** True for a Style page row key (never a sheet param, never sent to a host):
|
|
13
|
+
* an output property row or a viewer row (a HUD's Look pick or place, a
|
|
14
|
+
* heatmap's Sensitivity). */
|
|
15
|
+
export declare function isWrunStyleRowKey(key: string): boolean;
|
|
16
|
+
/** The Style page row key of a HUD's Look pick (g3 addendum LK09):
|
|
17
|
+
* `hud:<name>:look`, a viewer setting stored on the overlay beside the
|
|
18
|
+
* per-output style rows, never written into the sheet. */
|
|
19
|
+
export declare const WRUN_HUD_LOOK_ROW_PREFIX = "hud:";
|
|
20
|
+
export declare const WRUN_HUD_LOOK_ROW_RE: RegExp;
|
|
21
|
+
export declare function isWrunHudLookRowKey(key: string): boolean;
|
|
22
|
+
export declare function isWrunHudPlaceRowKey(key: string): boolean;
|
|
23
|
+
/** A HUD's viewer rows (the Look pick and the place): overlay settings that persist by key. */
|
|
24
|
+
export declare function isWrunHudViewerRowKey(key: string): boolean;
|
|
25
|
+
/** The viewer's Sensitivity for one heatmap (`heatmap:<name>:sensitivity`,
|
|
26
|
+
* wrunHeatmapSensitivityRowKey), stored on the overlay beside the HUD rows. */
|
|
27
|
+
export declare const WRUN_HEATMAP_SENSITIVITY_ROW_RE: RegExp;
|
|
28
|
+
export declare function isWrunHeatmapSensitivityRowKey(key: string): boolean;
|
|
29
|
+
/** Every viewer row of a browser-run Indicator (a HUD's Look pick and place, a
|
|
30
|
+
* heatmap's Sensitivity, a child the reader hid on its own legend row):
|
|
31
|
+
* overlay settings that persist by key and are never a sheet param, an alert
|
|
32
|
+
* param or a host param. */
|
|
33
|
+
export declare function isWrunViewerRowKey(key: string): boolean;
|
|
34
|
+
/** `((r * 256 + g) * 256 + b) * 1024 + round(alpha * 1000)`, arithmetic
|
|
35
|
+
* (the value outgrows 32-bit bitwise ops). */
|
|
36
|
+
export declare function packWrunColor(rgba: WrunRgba): number;
|
|
37
|
+
/** A colour setting parsed: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa` (the
|
|
38
|
+
* settings dialog's picker writes these), `rgb(r, g, b)` or
|
|
39
|
+
* `rgba(r, g, b, a)`. Anything else is no colour. */
|
|
40
|
+
export declare function parseWrunColor(value: unknown): WrunRgba | undefined;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The thin facts of the wrun colour settings (wrun-color-settings.util) that boot-path readers
|
|
3
|
+
* need synchronously: which settings keys are a browser-run Indicator's Style or viewer rows (the
|
|
4
|
+
* indicator defaults, the alert script's param map, a twin's compute inputs) and how a colour
|
|
5
|
+
* setting parses and packs (the panel parse, the alert params, the chart host fills). Pure, with no
|
|
6
|
+
* import but the child-id leaf, so these readers never pull the settings seam behind them
|
|
7
|
+
* (docs/features/kscript/wrun/wrun-browser-runtime.md, "Boot doors"); the colour settings module
|
|
8
|
+
* re-exports every name here for its own readers.
|
|
9
|
+
*/
|
|
10
|
+
import { isWrunChildHiddenRowKey } from './wrun-child-overlay-id.util.js';
|
|
11
|
+
/** The Style page row key of one output property (frozen, plan 1.7):
|
|
12
|
+
* `__style__<output>__<property>`; the target may also name a text
|
|
13
|
+
* renderer, heatmap, profile or levels declaration (C1, parseWrunStyleTarget). */
|
|
14
|
+
export const WRUN_STYLE_ROW_PREFIX = '__style__';
|
|
15
|
+
/** True for a Style page row key (never a sheet param, never sent to a host):
|
|
16
|
+
* an output property row or a viewer row (a HUD's Look pick or place, a
|
|
17
|
+
* heatmap's Sensitivity). */
|
|
18
|
+
export function isWrunStyleRowKey(key) {
|
|
19
|
+
return key.startsWith(WRUN_STYLE_ROW_PREFIX) || isWrunViewerRowKey(key);
|
|
20
|
+
}
|
|
21
|
+
/** The Style page row key of a HUD's Look pick (g3 addendum LK09):
|
|
22
|
+
* `hud:<name>:look`, a viewer setting stored on the overlay beside the
|
|
23
|
+
* per-output style rows, never written into the sheet. */
|
|
24
|
+
export const WRUN_HUD_LOOK_ROW_PREFIX = 'hud:';
|
|
25
|
+
export const WRUN_HUD_LOOK_ROW_RE = /^hud:(.+):look$/;
|
|
26
|
+
export function isWrunHudLookRowKey(key) {
|
|
27
|
+
return WRUN_HUD_LOOK_ROW_RE.test(key);
|
|
28
|
+
}
|
|
29
|
+
/** The viewer's own place for one HUD (`hud:<name>:place`, wrunHudPlaceRowKey). */
|
|
30
|
+
const WRUN_HUD_PLACE_ROW_RE = /^hud:(.+):place$/;
|
|
31
|
+
export function isWrunHudPlaceRowKey(key) {
|
|
32
|
+
return WRUN_HUD_PLACE_ROW_RE.test(key);
|
|
33
|
+
}
|
|
34
|
+
/** A HUD's viewer rows (the Look pick and the place): overlay settings that persist by key. */
|
|
35
|
+
export function isWrunHudViewerRowKey(key) {
|
|
36
|
+
return isWrunHudLookRowKey(key) || isWrunHudPlaceRowKey(key);
|
|
37
|
+
}
|
|
38
|
+
/** The viewer's Sensitivity for one heatmap (`heatmap:<name>:sensitivity`,
|
|
39
|
+
* wrunHeatmapSensitivityRowKey), stored on the overlay beside the HUD rows. */
|
|
40
|
+
export const WRUN_HEATMAP_SENSITIVITY_ROW_RE = /^heatmap:(.+):sensitivity$/;
|
|
41
|
+
export function isWrunHeatmapSensitivityRowKey(key) {
|
|
42
|
+
return WRUN_HEATMAP_SENSITIVITY_ROW_RE.test(key);
|
|
43
|
+
}
|
|
44
|
+
/** Every viewer row of a browser-run Indicator (a HUD's Look pick and place, a
|
|
45
|
+
* heatmap's Sensitivity, a child the reader hid on its own legend row):
|
|
46
|
+
* overlay settings that persist by key and are never a sheet param, an alert
|
|
47
|
+
* param or a host param. */
|
|
48
|
+
export function isWrunViewerRowKey(key) {
|
|
49
|
+
return isWrunHudViewerRowKey(key) || isWrunHeatmapSensitivityRowKey(key) || isWrunChildHiddenRowKey(key);
|
|
50
|
+
}
|
|
51
|
+
/** `((r * 256 + g) * 256 + b) * 1024 + round(alpha * 1000)`, arithmetic
|
|
52
|
+
* (the value outgrows 32-bit bitwise ops). */
|
|
53
|
+
export function packWrunColor(rgba) {
|
|
54
|
+
return ((rgba.r * 256 + rgba.g) * 256 + rgba.b) * 1024 + Math.round(rgba.a * 1000);
|
|
55
|
+
}
|
|
56
|
+
function channel(text) {
|
|
57
|
+
const value = Number(text);
|
|
58
|
+
return Number.isFinite(value) && value >= 0 && value <= 255 ? Math.round(value) : undefined;
|
|
59
|
+
}
|
|
60
|
+
/** A colour setting parsed: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa` (the
|
|
61
|
+
* settings dialog's picker writes these), `rgb(r, g, b)` or
|
|
62
|
+
* `rgba(r, g, b, a)`. Anything else is no colour. */
|
|
63
|
+
export function parseWrunColor(value) {
|
|
64
|
+
if (typeof value !== 'string')
|
|
65
|
+
return undefined;
|
|
66
|
+
const text = value.trim().toLowerCase();
|
|
67
|
+
const hex = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(text);
|
|
68
|
+
if (hex) {
|
|
69
|
+
let digits = hex[1];
|
|
70
|
+
if (digits.length <= 4)
|
|
71
|
+
digits = [...digits].map((digit) => digit + digit).join('');
|
|
72
|
+
const a = digits.length === 8 ? parseInt(digits.slice(6, 8), 16) / 255 : 1;
|
|
73
|
+
return {
|
|
74
|
+
r: parseInt(digits.slice(0, 2), 16),
|
|
75
|
+
g: parseInt(digits.slice(2, 4), 16),
|
|
76
|
+
b: parseInt(digits.slice(4, 6), 16),
|
|
77
|
+
a: Math.round(a * 1000) / 1000,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const rgb = /^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/.exec(text);
|
|
81
|
+
if (!rgb)
|
|
82
|
+
return undefined;
|
|
83
|
+
const [r, g, b] = [channel(rgb[1]), channel(rgb[2]), channel(rgb[3])];
|
|
84
|
+
const a = rgb[4] === undefined ? 1 : Number(rgb[4]);
|
|
85
|
+
if (r === undefined || g === undefined || b === undefined || !(a >= 0 && a <= 1))
|
|
86
|
+
return undefined;
|
|
87
|
+
return { r, g, b, a };
|
|
88
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chart store's door to the wrun colour settings seam (`wrun-color-settings.util`,
|
|
3
|
+
* `wrunSheetWithSettings`: the sheet repainted with an overlay's settings): the CME wall reads a
|
|
4
|
+
* package overlay's effective sheet through here for its way out (store/chart.ts), so the store
|
|
5
|
+
* holds no static edge to the seam (docs/features/kscript/wrun/wrun-browser-runtime.md,
|
|
6
|
+
* "Boot doors").
|
|
7
|
+
*
|
|
8
|
+
* The door's contract:
|
|
9
|
+
* - Bound: the seam binds itself as it evaluates (`bindWrunColorSettings`); every lane that
|
|
10
|
+
* remembers a package's sheet (the loaders' run pass, the hosted lanes, the settings dialog)
|
|
11
|
+
* evaluates it first, so the wall reads it in its own turn.
|
|
12
|
+
* - Not mine: an overlay with no remembered sheet never reaches the door (the wall's way out is
|
|
13
|
+
* then the works-on list, as before).
|
|
14
|
+
* - A sheet before the seam: the wall paints the works-on list (its own fallback for a sheet it
|
|
15
|
+
* cannot read), and the store loads the seam once and paints the wall again when it lands
|
|
16
|
+
* (ring `wrun-color-settings-late`).
|
|
17
|
+
*
|
|
18
|
+
* Pure on purpose (no import, no dynamic import): the seam rides two worker graphs; the store holds
|
|
19
|
+
* the late load.
|
|
20
|
+
*/
|
|
21
|
+
import type * as WrunColorSettings from './wrun-color-settings.util.js';
|
|
22
|
+
export type WrunColorSettingsRuntime = Pick<typeof WrunColorSettings, 'wrunSheetWithSettings'>;
|
|
23
|
+
/** Hand the seam over: it calls this as it evaluates. */
|
|
24
|
+
export declare function bindWrunColorSettings(loaded: WrunColorSettingsRuntime): void;
|
|
25
|
+
/** The seam when bound, else undefined (the caller degrades and loads it). */
|
|
26
|
+
export declare function wrunColorSettingsRuntime(): WrunColorSettingsRuntime | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
let runtime;
|
|
2
|
+
/** Hand the seam over: it calls this as it evaluates. */
|
|
3
|
+
export function bindWrunColorSettings(loaded) {
|
|
4
|
+
runtime = loaded;
|
|
5
|
+
}
|
|
6
|
+
/** The seam when bound, else undefined (the caller degrades and loads it). */
|
|
7
|
+
export function wrunColorSettingsRuntime() {
|
|
8
|
+
return runtime;
|
|
9
|
+
}
|