@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,514 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The docked levels child of a wrun run (WRUN-STYLE g2, plus g6
|
|
3
|
+
* DL-time-anchored): one `plot.levels` declaration and its parsed frame
|
|
4
|
+
* become the engine's docked `levels` record (row contract v2, the
|
|
5
|
+
* snake_case door keys), its hover rows and its mount settings.
|
|
6
|
+
*
|
|
7
|
+
* Division of labour (FREEZE 3.5.3 and 3.5.4):
|
|
8
|
+
* - `wrunLevelsChild` / `wrunLevelsSpansChild` build the child from the
|
|
9
|
+
* declaration and the frame: rows and door settings with every colour WORD
|
|
10
|
+
* unresolved (a theme token rides to the mount door) and every font word
|
|
11
|
+
* resolved to its CSS stack (X14: the engine never sees a font word). The
|
|
12
|
+
* run-result translator calls them per level, after `wrunSharedLevelsScale`
|
|
13
|
+
* once per run (DL-scale "shared").
|
|
14
|
+
* - `checkWrunLevelsFrame` restates the kit's `validateWrunLevelsFrame`
|
|
15
|
+
* cross-checks (X22) for the render selection, refused as
|
|
16
|
+
* `wrun_frame_invalid`.
|
|
17
|
+
* - `wrunLevelsMountSettings` / `wrunLevelsMountData` resolve the colour
|
|
18
|
+
* words against the chart's palette and map `beside` / `panel` to engine
|
|
19
|
+
* ids at the mount door (panel-mount's `childConfig`), which also keeps the
|
|
20
|
+
* hover rows under the child id (`rememberWrunLevelsHoverRows`) for the
|
|
21
|
+
* legend-hover surface (`wrunLevelsHoverRow`).
|
|
22
|
+
*
|
|
23
|
+
* Every new word is opt-in (conventions 10): a declaration that carries none
|
|
24
|
+
* of them builds today's rows and settings byte for byte, except that a
|
|
25
|
+
* labelled row now carries its text in cell 3 (the app writes every label it
|
|
26
|
+
* wants, `label_fallback: 'none'`), which prints exactly what the engine
|
|
27
|
+
* printed for it.
|
|
28
|
+
*/
|
|
29
|
+
import { isWrunLevelsColorPicked } from './wrun-style-flags.util.js';
|
|
30
|
+
import { formatWrunNumber, resolveWrunColorWord, wrunFontFamilyCss, } from './wrun-style-words.util.js';
|
|
31
|
+
import { invalidWrunFrame } from './wrun-frames.js';
|
|
32
|
+
/** The child id of a levels declaration (`<parent>::levels:<name>`, the id
|
|
33
|
+
* panel-mount gives every docked child). */
|
|
34
|
+
export function wrunLevelsChildId(overlayId, name) {
|
|
35
|
+
return `${overlayId}::levels:${name}`;
|
|
36
|
+
}
|
|
37
|
+
/** The lower pane an on-price package owns: the series child
|
|
38
|
+
* `<parent>::series:lower` (wrun-run-result.util's `wrunSeriesChildId` with
|
|
39
|
+
* `WRUN_LOWER_PANE_CHILD_NAME`, restated here so the builder stays a leaf;
|
|
40
|
+
* pinned by the spec). */
|
|
41
|
+
export function wrunLevelsLowerPaneId(overlayId) {
|
|
42
|
+
return `${overlayId}::series:lower`;
|
|
43
|
+
}
|
|
44
|
+
/** True for the spans shape of a parsed levels frame. */
|
|
45
|
+
export function isWrunLevelsSpansFrame(frame) {
|
|
46
|
+
return frame !== null && typeof frame === 'object' && Array.isArray(frame.spans);
|
|
47
|
+
}
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Row cells
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
/** Bar thickness (CSS px) the engine caps a sparse ladder's docked bars to. */
|
|
52
|
+
const WRUN_LEVELS_LADDER_THICKNESS_PX = 4;
|
|
53
|
+
/** The ladder rule of wrun-run-result.util's `wrunLevelsThicknessPx`
|
|
54
|
+
* (restated so the builder stays a leaf): fewer than three prices, or
|
|
55
|
+
* unequal gaps between them, are a ladder whose bars cap to thin marks; a
|
|
56
|
+
* uniform grid of three or more prices is a profile and keeps contiguous
|
|
57
|
+
* bins. A declared `thickness_px` or any row band replaces it. */
|
|
58
|
+
function ladderThicknessPx(prices) {
|
|
59
|
+
if (prices.length >= 3) {
|
|
60
|
+
const gaps = [];
|
|
61
|
+
for (let at = 1; at < prices.length; at += 1)
|
|
62
|
+
gaps.push(Math.abs(prices[at] - prices[at - 1]));
|
|
63
|
+
const step = gaps[0];
|
|
64
|
+
const uniform = step > 0 && gaps.every((gap) => Math.abs(gap - step) <= step * 1e-3);
|
|
65
|
+
if (uniform)
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
return WRUN_LEVELS_LADDER_THICKNESS_PX;
|
|
69
|
+
}
|
|
70
|
+
/** True when the declaration carries any of the four number-format words
|
|
71
|
+
* (DL-value-format): then every value text prints through the shared
|
|
72
|
+
* formatter, else today's `String(value)`. */
|
|
73
|
+
function hasValueFormat(level) {
|
|
74
|
+
return (level.format !== undefined || level.decimals !== undefined || level.signed !== undefined || level.unit !== undefined);
|
|
75
|
+
}
|
|
76
|
+
/** The text a row value prints as: the shared formatter under a declared
|
|
77
|
+
* format word (the chart's price digits for "price"), else `String(value)`;
|
|
78
|
+
* a null or non-finite value prints nothing. */
|
|
79
|
+
function valueTextOf(level, value, priceDigits) {
|
|
80
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
81
|
+
return null;
|
|
82
|
+
if (!hasValueFormat(level))
|
|
83
|
+
return String(value);
|
|
84
|
+
return formatWrunNumber(value, {
|
|
85
|
+
format: level.format,
|
|
86
|
+
decimals: level.decimals,
|
|
87
|
+
signed: level.signed,
|
|
88
|
+
unit: level.unit,
|
|
89
|
+
priceDigits,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function segmentAt(frame, series, row) {
|
|
93
|
+
const value = frame.series?.[series]?.[row];
|
|
94
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : null;
|
|
95
|
+
}
|
|
96
|
+
/** Cell 3 (DL-row-text): the frame's text for the row, `""` for no label,
|
|
97
|
+
* null (or no `labels_text`) for the value text (DL-value-format). */
|
|
98
|
+
function rowLabel(level, frame, row, priceDigits) {
|
|
99
|
+
const text = frame.labels_text?.[row];
|
|
100
|
+
if (typeof text === 'string')
|
|
101
|
+
return text === '' ? null : text;
|
|
102
|
+
return valueTextOf(level, frame.values[row], priceDigits);
|
|
103
|
+
}
|
|
104
|
+
/** Cells 4 and 5 (DL-even-grid): the frame's own band for the row, else the
|
|
105
|
+
* declared `step` around the price, else no band. */
|
|
106
|
+
function rowBand(frame, row, price, step) {
|
|
107
|
+
const low = frame.lows?.[row];
|
|
108
|
+
const high = frame.highs?.[row];
|
|
109
|
+
if (typeof low === 'number' && typeof high === 'number')
|
|
110
|
+
return [low, high];
|
|
111
|
+
if (typeof step === 'number' && Number.isFinite(step) && step > 0)
|
|
112
|
+
return [price - step / 2, price + step / 2];
|
|
113
|
+
return [null, null];
|
|
114
|
+
}
|
|
115
|
+
function hasRowBands(frame, step) {
|
|
116
|
+
return ((frame.lows !== undefined && frame.highs !== undefined) ||
|
|
117
|
+
(typeof step === 'number' && Number.isFinite(step) && step > 0));
|
|
118
|
+
}
|
|
119
|
+
/** Labels are on when declared, or when the frame carries `labels_text` and
|
|
120
|
+
* the declaration does not say `labels: false` (the om series-lane rule). */
|
|
121
|
+
function labelsOn(level, frame) {
|
|
122
|
+
return level.labels === true || (frame.labels_text !== undefined && level.labels !== false);
|
|
123
|
+
}
|
|
124
|
+
/** The rows of a pane frame on row contract v2: `[price, value, color?,
|
|
125
|
+
* label?, band_low?, band_high?, seg_0 .. seg_(k-1)]`. Every row of one
|
|
126
|
+
* child has the same width: today's two or three cells when nothing new is
|
|
127
|
+
* declared, else the cells up to the last one any row of the child can
|
|
128
|
+
* carry (absent cells are null). Cell 2 is null on a segmented record (the
|
|
129
|
+
* segments carry their series colours). */
|
|
130
|
+
function paneRows(level, frame, labelled, priceDigits) {
|
|
131
|
+
const segments = level.series?.length ?? 0;
|
|
132
|
+
const bands = hasRowBands(frame, level.step);
|
|
133
|
+
const width = segments > 0 ? 6 + segments : bands ? 6 : labelled ? 4 : frame.colors !== undefined ? 3 : 2;
|
|
134
|
+
return frame.prices.map((price, row) => {
|
|
135
|
+
const cells = [price, frame.values[row] ?? null];
|
|
136
|
+
if (width > 2)
|
|
137
|
+
cells.push(segments > 0 ? null : (frame.colors?.[row] ?? null));
|
|
138
|
+
if (width > 3)
|
|
139
|
+
cells.push(labelled ? rowLabel(level, frame, row, priceDigits) : null);
|
|
140
|
+
if (width > 4)
|
|
141
|
+
cells.push(...rowBand(frame, row, price, level.step));
|
|
142
|
+
for (let series = 0; series < segments; series += 1)
|
|
143
|
+
cells.push(segmentAt(frame, series, row));
|
|
144
|
+
return cells;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/** The hover rows of a child (DL-hover): one per frame row, in frame order
|
|
148
|
+
* (the engine reports the row's index in the sender's data). */
|
|
149
|
+
function hoverRowsOf(level, rows, priceDigits) {
|
|
150
|
+
const series = level.series ?? [];
|
|
151
|
+
return rows.map((row) => ({
|
|
152
|
+
price: row.price,
|
|
153
|
+
valueText: valueTextOf(level, row.value, priceDigits) ?? '-',
|
|
154
|
+
series: series.map((entry, at) => ({
|
|
155
|
+
name: entry.name,
|
|
156
|
+
valueText: valueTextOf(level, row.segments[at] ?? null, priceDigits) ?? '-',
|
|
157
|
+
color: entry.color,
|
|
158
|
+
})),
|
|
159
|
+
...(row.tooltip !== undefined && row.tooltip !== '' ? { tooltip: row.tooltip } : {}),
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
// ---------------------------------------------------------------------------
|
|
163
|
+
// Door settings
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
/** The paint keys shared by the pane and the spans child, each sent only
|
|
166
|
+
* when declared (every default stays the engine's): fill alpha, label ink
|
|
167
|
+
* and font (the family as a CSS stack), POC and value-area style, gradient,
|
|
168
|
+
* borders and the outline shape. A colour picked on the Style page paints
|
|
169
|
+
* the bars, as it does over the frame's row colours (style-rows audit item
|
|
170
|
+
* 5): the gradient stops, which titan lays on every row without a colour of
|
|
171
|
+
* its own, and an outline's border colour, its only stroke and drawn in
|
|
172
|
+
* place of the level colour, are not sent then; a bars-shape border only
|
|
173
|
+
* frames the picked fill and stays. */
|
|
174
|
+
function styleSettings(level) {
|
|
175
|
+
const out = {};
|
|
176
|
+
const picked = isWrunLevelsColorPicked(level);
|
|
177
|
+
if (level.behind_candles === true)
|
|
178
|
+
out.behind_candles = true;
|
|
179
|
+
if (level.opacity !== undefined)
|
|
180
|
+
out.bar_opacity = level.opacity;
|
|
181
|
+
if (level.text_color !== undefined)
|
|
182
|
+
out.label_color = level.text_color;
|
|
183
|
+
if (level.font_size !== undefined)
|
|
184
|
+
out.label_font_size = level.font_size;
|
|
185
|
+
if (level.font_weight !== undefined)
|
|
186
|
+
out.label_font_weight = level.font_weight;
|
|
187
|
+
const family = wrunFontFamilyCss(level.font_family);
|
|
188
|
+
if (family !== undefined)
|
|
189
|
+
out.label_font_family = family;
|
|
190
|
+
if (level.label_place !== undefined)
|
|
191
|
+
out.label_place = level.label_place;
|
|
192
|
+
if (level.hover === true)
|
|
193
|
+
out.hover = true;
|
|
194
|
+
if (level.poc_color !== undefined)
|
|
195
|
+
out.poc_color = level.poc_color;
|
|
196
|
+
if (level.poc_width !== undefined)
|
|
197
|
+
out.poc_width = level.poc_width;
|
|
198
|
+
if (level.poc_line_style !== undefined)
|
|
199
|
+
out.poc_line_style = level.poc_line_style;
|
|
200
|
+
if (level.poc_extend !== undefined)
|
|
201
|
+
out.poc_extend = level.poc_extend;
|
|
202
|
+
if (level.gradient !== undefined && !picked)
|
|
203
|
+
out.gradient = [...level.gradient];
|
|
204
|
+
if (level.gradient_direction !== undefined && !picked)
|
|
205
|
+
out.gradient_direction = level.gradient_direction;
|
|
206
|
+
if (level.border_color !== undefined && !(picked && level.shape === 'outline')) {
|
|
207
|
+
out.border_color = level.border_color;
|
|
208
|
+
}
|
|
209
|
+
// DL-borders: border_width defaults to 1 beside a border colour, else the
|
|
210
|
+
// engine's 0 (nothing sent).
|
|
211
|
+
const borderWidth = level.border_width ?? (level.border_color !== undefined ? 1 : undefined);
|
|
212
|
+
if (borderWidth !== undefined)
|
|
213
|
+
out.border_width = borderWidth;
|
|
214
|
+
if (level.border_style !== undefined)
|
|
215
|
+
out.border_style = level.border_style;
|
|
216
|
+
if (level.shape !== undefined)
|
|
217
|
+
out.shape = level.shape;
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
/** Today's six door keys in today's order, so an unstyled sheet keeps its
|
|
221
|
+
* bytes: dock, width_frac, thickness_px, poc, labels, color. */
|
|
222
|
+
function baseSettings(level, thickness, labels) {
|
|
223
|
+
return {
|
|
224
|
+
dock: level.dock,
|
|
225
|
+
...(level.width_frac !== undefined ? { width_frac: level.width_frac } : {}),
|
|
226
|
+
...(thickness !== undefined ? { thickness_px: thickness } : {}),
|
|
227
|
+
...(level.poc !== undefined ? { poc: level.poc } : {}),
|
|
228
|
+
...(labels !== undefined ? { labels } : {}),
|
|
229
|
+
...(level.color !== undefined ? { color: level.color } : {}),
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/** The scale denominator (DL-scale): "fixed" takes the frame's `scale_max`
|
|
233
|
+
* over the declared one, "shared" the run's largest shared extent (the
|
|
234
|
+
* level's own when the run passed none), "own" sends nothing. */
|
|
235
|
+
function scaleMaxOf(level, frame, ctx) {
|
|
236
|
+
if (level.scale === 'fixed')
|
|
237
|
+
return frame.scale_max ?? level.scale_max;
|
|
238
|
+
if (level.scale === 'shared')
|
|
239
|
+
return ctx.sharedScaleMax ?? ownExtent(level, frame);
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
/** A level's own extent: the largest value (or positive segment sum) under
|
|
243
|
+
* baseline "edge", the largest per-side sum (or |value|) under "center". */
|
|
244
|
+
function ownExtent(level, frame) {
|
|
245
|
+
const segments = level.series?.length ?? 0;
|
|
246
|
+
const center = level.baseline === 'center';
|
|
247
|
+
let extent;
|
|
248
|
+
const consider = (candidate) => {
|
|
249
|
+
if (Number.isFinite(candidate) && (extent === undefined || candidate > extent))
|
|
250
|
+
extent = candidate;
|
|
251
|
+
};
|
|
252
|
+
frame.prices.forEach((_price, row) => {
|
|
253
|
+
if (segments > 0) {
|
|
254
|
+
let positive = 0;
|
|
255
|
+
let negative = 0;
|
|
256
|
+
for (let series = 0; series < segments; series += 1) {
|
|
257
|
+
const segment = segmentAt(frame, series, row);
|
|
258
|
+
if (segment === null)
|
|
259
|
+
continue;
|
|
260
|
+
if (segment >= 0)
|
|
261
|
+
positive += segment;
|
|
262
|
+
else
|
|
263
|
+
negative -= segment;
|
|
264
|
+
}
|
|
265
|
+
consider(center ? Math.max(positive, negative) : positive);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const value = frame.values[row];
|
|
269
|
+
if (typeof value !== 'number')
|
|
270
|
+
return;
|
|
271
|
+
consider(center ? Math.abs(value) : value);
|
|
272
|
+
});
|
|
273
|
+
return extent !== undefined && extent > 0 ? extent : undefined;
|
|
274
|
+
}
|
|
275
|
+
// ---------------------------------------------------------------------------
|
|
276
|
+
// The children
|
|
277
|
+
// ---------------------------------------------------------------------------
|
|
278
|
+
/**
|
|
279
|
+
* The docked child of one `plot.levels` declaration over its pane frame
|
|
280
|
+
* (span "pane"): rows on row contract v2 and every door key of g2, colour
|
|
281
|
+
* words unresolved. Null without a frame (no snapshot written yet).
|
|
282
|
+
*/
|
|
283
|
+
export function wrunLevelsChild(level, frame, ctx) {
|
|
284
|
+
if (frame === null || frame === undefined)
|
|
285
|
+
return null;
|
|
286
|
+
// A colour picked on the Style page paints every row: the frame's own
|
|
287
|
+
// per-row colours apply only while the level keeps its declared colour
|
|
288
|
+
// (wrun-style-flags.util, set by the settings seam in wrun-color-settings.util).
|
|
289
|
+
const view = isWrunLevelsColorPicked(level) && frame.colors !== undefined ? { ...frame, colors: undefined } : frame;
|
|
290
|
+
const labelled = labelsOn(level, view);
|
|
291
|
+
const bands = hasRowBands(view, level.step);
|
|
292
|
+
// DL-thickness: a declared thickness wins; a banded row needs no ladder cap
|
|
293
|
+
// (the band is the row's own height); else today's sparse-ladder rule.
|
|
294
|
+
const thickness = level.thickness_px ?? (bands ? undefined : ladderThicknessPx(view.prices));
|
|
295
|
+
const segments = level.series ?? [];
|
|
296
|
+
const scaleMax = scaleMaxOf(level, view, ctx);
|
|
297
|
+
const valueArea = view.value_area;
|
|
298
|
+
const hasValueArea = Array.isArray(valueArea) && typeof valueArea[0] === 'number' && typeof valueArea[1] === 'number';
|
|
299
|
+
const pocLabel = level.poc_label === true || view.poc_label_text !== undefined;
|
|
300
|
+
const settings = {
|
|
301
|
+
...baseSettings(level, thickness, labelled ? true : level.labels),
|
|
302
|
+
...(level.baseline === 'center' ? { baseline: 'center' } : {}),
|
|
303
|
+
...(segments.length > 0 ? { segment_colors: segments.map((entry) => entry.color) } : {}),
|
|
304
|
+
...(labelled ? { label_fallback: 'none' } : {}),
|
|
305
|
+
...(hasValueArea
|
|
306
|
+
? {
|
|
307
|
+
value_area_low: valueArea[0],
|
|
308
|
+
value_area_high: valueArea[1],
|
|
309
|
+
...(level.outside_opacity !== undefined ? { outside_opacity: level.outside_opacity } : {}),
|
|
310
|
+
...(level.value_area_color !== undefined ? { value_area_color: level.value_area_color } : {}),
|
|
311
|
+
...(level.value_area_width !== undefined ? { value_area_width: level.value_area_width } : {}),
|
|
312
|
+
...(level.value_area_line_style !== undefined ? { value_area_line_style: level.value_area_line_style } : {}),
|
|
313
|
+
...(level.value_area_labels !== undefined ? { value_area_labels: level.value_area_labels } : {}),
|
|
314
|
+
}
|
|
315
|
+
: {}),
|
|
316
|
+
...(level.offset !== undefined && typeof level.offset[0] === 'number' ? { offset_px: level.offset[0] } : {}),
|
|
317
|
+
...(level.beside !== undefined ? { beside: level.beside } : {}),
|
|
318
|
+
...(pocLabel ? { poc_label: true } : {}),
|
|
319
|
+
...(view.poc_price !== undefined ? { poc_price: view.poc_price } : {}),
|
|
320
|
+
...(view.poc_label_text !== undefined ? { poc_label_text: view.poc_label_text } : {}),
|
|
321
|
+
...(level.width_px !== undefined ? { width_px: level.width_px } : {}),
|
|
322
|
+
...(scaleMax !== undefined ? { scale_max: scaleMax } : {}),
|
|
323
|
+
...styleSettings(level),
|
|
324
|
+
};
|
|
325
|
+
const child = {
|
|
326
|
+
kind: 'levels',
|
|
327
|
+
name: level.name,
|
|
328
|
+
data: paneRows(level, view, labelled, ctx.priceDigits),
|
|
329
|
+
settings,
|
|
330
|
+
};
|
|
331
|
+
if (level.panel === 'lower')
|
|
332
|
+
child.panel = 'lower';
|
|
333
|
+
if (level.hover === true) {
|
|
334
|
+
child.hover = hoverRowsOf(level, view.prices.map((price, row) => ({
|
|
335
|
+
price,
|
|
336
|
+
value: view.values[row] ?? null,
|
|
337
|
+
segments: segments.map((_entry, series) => segmentAt(view, series, row)),
|
|
338
|
+
...(typeof view.tooltips?.[row] === 'string' ? { tooltip: view.tooltips[row] } : {}),
|
|
339
|
+
})), ctx.priceDigits);
|
|
340
|
+
}
|
|
341
|
+
return child;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* The docked child of a span "time" declaration (DL-time-anchored): every
|
|
345
|
+
* span's rows concatenated as `[price, value, color?, label?, startMs,
|
|
346
|
+
* endMs]`, settings `span: 'time'` beside today's levels settings and the
|
|
347
|
+
* shared paint keys. Null without a frame.
|
|
348
|
+
*/
|
|
349
|
+
export function wrunLevelsSpansChild(level, frame, ctx) {
|
|
350
|
+
if (frame === null || frame === undefined)
|
|
351
|
+
return null;
|
|
352
|
+
// The pane child's rule: a colour picked on the Style page paints every
|
|
353
|
+
// span's rows, the frame's own per-row colours apply at the declared colour.
|
|
354
|
+
const view = isWrunLevelsColorPicked(level)
|
|
355
|
+
? { ...frame, spans: frame.spans.map((span) => ({ ...span, colors: undefined })) }
|
|
356
|
+
: frame;
|
|
357
|
+
const labelled = level.labels === true;
|
|
358
|
+
const thickness = level.thickness_px ??
|
|
359
|
+
(view.spans.some((span) => ladderThicknessPx(span.prices) !== undefined)
|
|
360
|
+
? WRUN_LEVELS_LADDER_THICKNESS_PX
|
|
361
|
+
: undefined);
|
|
362
|
+
const data = [];
|
|
363
|
+
const hoverRows = [];
|
|
364
|
+
for (const span of view.spans) {
|
|
365
|
+
const startMs = span.start * 1000;
|
|
366
|
+
const endMs = span.end * 1000;
|
|
367
|
+
span.prices.forEach((price, row) => {
|
|
368
|
+
const value = span.values[row] ?? null;
|
|
369
|
+
data.push([
|
|
370
|
+
price,
|
|
371
|
+
value,
|
|
372
|
+
span.colors?.[row] ?? null,
|
|
373
|
+
labelled ? valueTextOf(level, value, ctx.priceDigits) : null,
|
|
374
|
+
startMs,
|
|
375
|
+
endMs,
|
|
376
|
+
]);
|
|
377
|
+
hoverRows.push({ price, value, segments: [] });
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
const child = {
|
|
381
|
+
kind: 'levels',
|
|
382
|
+
name: level.name,
|
|
383
|
+
data,
|
|
384
|
+
settings: {
|
|
385
|
+
...baseSettings(level, thickness, level.labels),
|
|
386
|
+
span: 'time',
|
|
387
|
+
...(labelled ? { label_fallback: 'none' } : {}),
|
|
388
|
+
...styleSettings(level),
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
if (level.panel === 'lower')
|
|
392
|
+
child.panel = 'lower';
|
|
393
|
+
if (level.hover === true)
|
|
394
|
+
child.hover = hoverRowsOf(level, hoverRows, ctx.priceDigits);
|
|
395
|
+
return child;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* The run's shared scale (DL-scale): the largest own extent over the
|
|
399
|
+
* sheet's "shared" levels that have a pane frame (`frames` keyed by level
|
|
400
|
+
* name), undefined when none has one. Every "shared" level then takes it as
|
|
401
|
+
* `scale_max`, so the largest row among them fills each dock.
|
|
402
|
+
*/
|
|
403
|
+
export function wrunSharedLevelsScale(levels, frames) {
|
|
404
|
+
let largest;
|
|
405
|
+
for (const level of levels) {
|
|
406
|
+
if (level.scale !== 'shared')
|
|
407
|
+
continue;
|
|
408
|
+
const frame = frames.get(level.name);
|
|
409
|
+
if (frame === null || frame === undefined || isWrunLevelsSpansFrame(frame))
|
|
410
|
+
continue;
|
|
411
|
+
const extent = ownExtent(level, frame);
|
|
412
|
+
if (extent !== undefined && (largest === undefined || extent > largest))
|
|
413
|
+
largest = extent;
|
|
414
|
+
}
|
|
415
|
+
return largest;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* The declaration cross-checks of a parsed levels frame (the kit's
|
|
419
|
+
* `validateWrunLevelsFrame`, restated per X22 with its messages): the shape
|
|
420
|
+
* the level's `span` takes (DL-time-anchored), `series` against the declared
|
|
421
|
+
* series and `colors` beside `series` (DL-stacked), `scale_max` needing scale
|
|
422
|
+
* "fixed" (DL-scale). Throws `wrun_frame_invalid: slot '<slot>': <message>`.
|
|
423
|
+
*/
|
|
424
|
+
export function checkWrunLevelsFrame(level, frame, slot) {
|
|
425
|
+
const owner = `level '${level.name ?? '?'}'`;
|
|
426
|
+
const span = level.span === 'time' ? 'time' : 'pane';
|
|
427
|
+
if (isWrunLevelsSpansFrame(frame)) {
|
|
428
|
+
if (span !== 'time') {
|
|
429
|
+
invalidWrunFrame(slot, `${owner} has span 'pane': its frame takes prices and values, not spans`);
|
|
430
|
+
}
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
if (span === 'time') {
|
|
434
|
+
invalidWrunFrame(slot, `${owner} has span 'time': its frame takes spans, not prices and values`);
|
|
435
|
+
}
|
|
436
|
+
const view = frame;
|
|
437
|
+
const declared = level.series?.length ?? 0;
|
|
438
|
+
if (view.series !== undefined) {
|
|
439
|
+
if (declared === 0)
|
|
440
|
+
invalidWrunFrame(slot, `${owner} declares no series: the frame cannot carry series`);
|
|
441
|
+
if (view.series.length !== declared) {
|
|
442
|
+
invalidWrunFrame(slot, `${owner} declares ${declared} series: the frame must carry ${declared} series arrays, not ${view.series.length}`);
|
|
443
|
+
}
|
|
444
|
+
if (view.colors !== undefined) {
|
|
445
|
+
invalidWrunFrame(slot, 'colors and series do not mix: a segmented row takes its series colours');
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
else if (declared > 0) {
|
|
449
|
+
invalidWrunFrame(slot, `${owner} declares ${declared} series: the frame must carry series`);
|
|
450
|
+
}
|
|
451
|
+
if (view.scale_max !== undefined && level.scale !== 'fixed') {
|
|
452
|
+
invalidWrunFrame(slot, `scale_max needs scale 'fixed' on ${owner}`);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// ---------------------------------------------------------------------------
|
|
456
|
+
// The mount door
|
|
457
|
+
// ---------------------------------------------------------------------------
|
|
458
|
+
/** The door keys that carry one colour word. */
|
|
459
|
+
const WRUN_LEVELS_COLOR_KEYS = ['color', 'label_color', 'value_area_color', 'poc_color', 'border_color'];
|
|
460
|
+
/** The door keys that carry a list of colour words. */
|
|
461
|
+
const WRUN_LEVELS_COLOR_LIST_KEYS = ['segment_colors', 'gradient'];
|
|
462
|
+
/**
|
|
463
|
+
* A levels child's engine settings at the mount door: every colour word
|
|
464
|
+
* (the colour keys, `segment_colors[]`, `gradient[]`) resolved against the
|
|
465
|
+
* chart's palette, `beside` mapped to the neighbour's child id, and a
|
|
466
|
+
* lower-pane child (DL-lower-pane) docked on `pane_id`: the parent itself
|
|
467
|
+
* when it lives offchart, else the on-price package's series child.
|
|
468
|
+
*/
|
|
469
|
+
export function wrunLevelsMountSettings(child, theme, ids) {
|
|
470
|
+
const settings = { ...child.settings };
|
|
471
|
+
for (const key of WRUN_LEVELS_COLOR_KEYS) {
|
|
472
|
+
const word = settings[key];
|
|
473
|
+
if (typeof word === 'string')
|
|
474
|
+
settings[key] = resolveWrunColorWord(word, theme);
|
|
475
|
+
}
|
|
476
|
+
for (const key of WRUN_LEVELS_COLOR_LIST_KEYS) {
|
|
477
|
+
const words = settings[key];
|
|
478
|
+
if (Array.isArray(words)) {
|
|
479
|
+
settings[key] = words.map((word) => (typeof word === 'string' ? resolveWrunColorWord(word, theme) : word));
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (typeof settings.beside === 'string')
|
|
483
|
+
settings.beside = wrunLevelsChildId(ids.overlayId, settings.beside);
|
|
484
|
+
if (child.panel === 'lower') {
|
|
485
|
+
settings.pane_id = ids.parentOffchart ? ids.overlayId : wrunLevelsLowerPaneId(ids.overlayId);
|
|
486
|
+
}
|
|
487
|
+
return settings;
|
|
488
|
+
}
|
|
489
|
+
/** A levels child's rows at the mount door: row cell 2 (a colour word)
|
|
490
|
+
* resolved against the chart's palette; every other cell as built. */
|
|
491
|
+
export function wrunLevelsMountData(child, theme) {
|
|
492
|
+
return child.data.map((row) => row.map((cell, at) => (at === 2 && typeof cell === 'string' ? resolveWrunColorWord(cell, theme) : cell)));
|
|
493
|
+
}
|
|
494
|
+
// ---------------------------------------------------------------------------
|
|
495
|
+
// Hover rows (DL-hover), kept per mounted child id
|
|
496
|
+
// ---------------------------------------------------------------------------
|
|
497
|
+
const hoverRowsByChild = new Map();
|
|
498
|
+
/** Keeps a mounted child's hover rows under its id, series colours resolved
|
|
499
|
+
* against the chart's palette (the swatches paint them as given). */
|
|
500
|
+
export function rememberWrunLevelsHoverRows(childId, rows, theme) {
|
|
501
|
+
hoverRowsByChild.set(childId, rows.map((row) => ({
|
|
502
|
+
...row,
|
|
503
|
+
series: row.series.map((entry) => ({ ...entry, color: resolveWrunColorWord(entry.color, theme) })),
|
|
504
|
+
})));
|
|
505
|
+
}
|
|
506
|
+
/** Drops a child's hover rows (unmount). */
|
|
507
|
+
export function forgetWrunLevelsHoverRows(childId) {
|
|
508
|
+
hoverRowsByChild.delete(childId);
|
|
509
|
+
}
|
|
510
|
+
/** The hover row of a mounted child at the engine's row index (the row's
|
|
511
|
+
* position in the sender's data), undefined when the child keeps none. */
|
|
512
|
+
export function wrunLevelsHoverRow(childId, index) {
|
|
513
|
+
return hoverRowsByChild.get(childId)?.[index];
|
|
514
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared vocabulary of the wrun overlay lifecycle: the words every chart
|
|
3
|
+
* trigger, the lifecycle door (`wrun-overlay-lifecycle.util.ts`), the
|
|
4
|
+
* recovery ladders (`wrun-overlay-recovery.util.ts`), the executor
|
|
5
|
+
* (`wrun-overlay-drivers.util.ts`) and the run (`wrun-overlay-run.util.ts`)
|
|
6
|
+
* agree on. Types only, so any module may import it without pulling a
|
|
7
|
+
* runtime graph.
|
|
8
|
+
*/
|
|
9
|
+
/** Why a wrun run starts. The executor merges queued requests latest-wins by
|
|
10
|
+
* rank: settings > switch > theme > resume = retry > heal > live-rebuild >
|
|
11
|
+
* the range reasons (history-range, budget-lift, lazy-range-refresh,
|
|
12
|
+
* loaded-range-refresh, source-recovery). 'initial' is the loader's first
|
|
13
|
+
* run of a mount. 'replay' is the replay lane's run (wrun-replay-lane.util):
|
|
14
|
+
* the replay's completed bars while the chart replays, and it outranks every
|
|
15
|
+
* other reason, which the door holds while the chart is replay-locked. */
|
|
16
|
+
export type WrunRunReason = 'replay' | 'initial' | 'settings' | 'switch' | 'theme' | 'resume' | 'retry' | 'heal' | 'live-rebuild' | 'history-range' | 'budget-lift' | 'lazy-range-refresh' | 'loaded-range-refresh' | 'source-recovery';
|
|
17
|
+
/** A clamped compute window in epoch ms, inclusive. `partial` means narrower
|
|
18
|
+
* than the chart's loaded main range, so the integrate must keep the mounted
|
|
19
|
+
* rows outside it (rows merge, or a remount that preserves them). */
|
|
20
|
+
export interface WrunRunWindow {
|
|
21
|
+
fromMs: number;
|
|
22
|
+
toMs: number;
|
|
23
|
+
partial: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface WrunRerunOptions {
|
|
26
|
+
/** Absent means 'loaded-range-refresh'. */
|
|
27
|
+
reason?: WrunRunReason;
|
|
28
|
+
/** Absent means the whole loaded window. */
|
|
29
|
+
window?: WrunRunWindow;
|
|
30
|
+
/** Who asked: `user` for a person's own click or save (its failure is noticed once), `system`
|
|
31
|
+
* for a rerun the chart or a collaborator's apply started. Absent: the reason decides
|
|
32
|
+
* (`wrunRefusalAttemptOrigin`): retry and settings read as the user's, everything else as the
|
|
33
|
+
* chart's, because `switch` is also what every automatic refetch asks for. */
|
|
34
|
+
origin?: 'user' | 'system';
|
|
35
|
+
}
|
|
36
|
+
/** Why the lifecycle door will not run an overlay now; null means run. 'failed-deterministic': the
|
|
37
|
+
* last run of this overlay failed the row cap on the same window and settings, so a wave would
|
|
38
|
+
* only fail the same way again (the recovery's narrow latch). */
|
|
39
|
+
export type WrunOverlayHold = 'paused' | 'tripped' | 'gated' | 'collapsed' | 'replay-locked' | 'venue-blocked' | 'failed-deterministic' | null;
|
|
40
|
+
/** The signal that asked the heal ladder to look at an overlay. */
|
|
41
|
+
export type WrunHealSignal = 'poll' | 'live-frame' | 'wake' | 'show';
|
|
42
|
+
/** Synchronous answer of `healWrunOverlayIfIdle`. 'no-driver' means the id is
|
|
43
|
+
* not a wrun overlay and the caller continues on its own line; every other
|
|
44
|
+
* verdict means the wrun lifecycle owns the overlay and the caller must not
|
|
45
|
+
* run an engine branch for it. Dwell, backoff and declines happen in the
|
|
46
|
+
* asynchronous tail and report to the lazy-load debug ring. */
|
|
47
|
+
export type WrunHealVerdict = 'no-driver' | 'healthy' | 'in-flight' | 'queued';
|
|
48
|
+
/** How the heal ladder treats a failed run. */
|
|
49
|
+
export type WrunRunFailureClass = 'retryable' | 'deterministic' | 'venue' | 'paused';
|
|
50
|
+
/** What a failed run computed: the window (its first and last bar, epoch ms) and the overlay
|
|
51
|
+
* settings, as one comparable string. */
|
|
52
|
+
export interface WrunRunFailedIdentity {
|
|
53
|
+
windowFirstTs: number;
|
|
54
|
+
windowLastTs: number;
|
|
55
|
+
settingsSignature: string;
|
|
56
|
+
}
|
|
57
|
+
/** One settled executor run, as `onWrunOverlayRunSettled` reports it. */
|
|
58
|
+
export interface WrunRunSettledEvent {
|
|
59
|
+
indicatorId: string;
|
|
60
|
+
chartIndex: number;
|
|
61
|
+
reason: WrunRunReason;
|
|
62
|
+
ok: boolean;
|
|
63
|
+
error?: unknown;
|
|
64
|
+
/** A failed run's identity (its window and settings), set by the run's settle producer. */
|
|
65
|
+
failedIdentity?: WrunRunFailedIdentity;
|
|
66
|
+
}
|
|
67
|
+
/** One secondary lane a run treated as empty instead of failing the run. */
|
|
68
|
+
export interface WrunDegradedLane {
|
|
69
|
+
lane: string;
|
|
70
|
+
/** The source type name the kScript degrade registry and its chips use. */
|
|
71
|
+
kType: string;
|
|
72
|
+
label: string;
|
|
73
|
+
cause: 'budget' | 'declined' | 'empty' | 'error';
|
|
74
|
+
retryable: boolean;
|
|
75
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared vocabulary of the wrun overlay lifecycle: the words every chart
|
|
3
|
+
* trigger, the lifecycle door (`wrun-overlay-lifecycle.util.ts`), the
|
|
4
|
+
* recovery ladders (`wrun-overlay-recovery.util.ts`), the executor
|
|
5
|
+
* (`wrun-overlay-drivers.util.ts`) and the run (`wrun-overlay-run.util.ts`)
|
|
6
|
+
* agree on. Types only, so any module may import it without pulling a
|
|
7
|
+
* runtime graph.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|