@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,476 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The kScript run-result normalizer for TitanCharts (the frontend adapter's row and plot normalization): pure, it
|
|
3
|
+
* reads only its arguments. Split out of kscript-run-result.util.ts (which re-exports it beside the stateful
|
|
4
|
+
* mount-admission rules that read the degradation registry) so the wrun integration budget counts rows the way the
|
|
5
|
+
* adapter mounts them without reaching that registry. It rides the `@orangecharts/wrun-chart-host` package
|
|
6
|
+
* (docs/features/kscript/wrun/wrun-chart-host.md).
|
|
7
|
+
*/
|
|
8
|
+
import { isKScriptDeclaredMarkerPlotType } from './kscript-output-role.util.js';
|
|
9
|
+
/**
|
|
10
|
+
* Foreign-domain pane kinds emitted by kScript and panel hosts.
|
|
11
|
+
* Their rows live in a pane-private domain,
|
|
12
|
+
* NOT the shared time axis: slot 0 is a row/tile index or a numeric X, and
|
|
13
|
+
* null cells are legitimate series gaps. Every host-side transform that
|
|
14
|
+
* assumes time rows (timestamp validation, index-domain rewrites, row-merge,
|
|
15
|
+
* unsafe-row filtering) must treat these as opaque: the engine's ingestion
|
|
16
|
+
* door (`foreignPaneContract.ts`) owns their sanitization.
|
|
17
|
+
*/
|
|
18
|
+
export const KSCRIPT_FOREIGN_PANE_PLOT_TYPES = new Set([
|
|
19
|
+
'matrix',
|
|
20
|
+
'curve',
|
|
21
|
+
'tiles',
|
|
22
|
+
'bars',
|
|
23
|
+
'scatter',
|
|
24
|
+
'piePane',
|
|
25
|
+
]);
|
|
26
|
+
export function isKScriptForeignPanePlotType(plotType) {
|
|
27
|
+
return typeof plotType === 'string' && KSCRIPT_FOREIGN_PANE_PLOT_TYPES.has(plotType);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Engine plot names -> titan-charts addOverlay plot kinds. The engine and the
|
|
31
|
+
* server script contract speak ENGINE names: the generic plot() declaration
|
|
32
|
+
* lane defaults to 'line' when the call name is not in its PLOT_TYPE_MAP and
|
|
33
|
+
* no plotType argument overrides it (extractPlotInfo), and the engine's own
|
|
34
|
+
* wasm renderer treats line and spline as the same kind. titan's addOverlay
|
|
35
|
+
* registry has no 'line' plot kind ('spline' is its line renderer), so an
|
|
36
|
+
* unmapped engine name mounts an overlay with no extractors that renders
|
|
37
|
+
* nothing ("Unknown overlay plot type" warn). Shared by BOTH titan-bound
|
|
38
|
+
* lanes: the run-result normalizer below and the technical-script mount-config
|
|
39
|
+
* meta (see kscript-titancharts-output-contract.md).
|
|
40
|
+
*/
|
|
41
|
+
const ENGINE_TO_TITAN_PLOT_TYPE = new Map([['line', 'spline']]);
|
|
42
|
+
/**
|
|
43
|
+
* Maps an engine/server-contract plot name to the titan plot kind. Valid
|
|
44
|
+
* titan/frontend plot names pass through unchanged; nullish, non-string, and
|
|
45
|
+
* empty values stay nullish so callers' || fallback chains still apply.
|
|
46
|
+
*/
|
|
47
|
+
export function mapEnginePlotTypeToTitanPlotType(value) {
|
|
48
|
+
if (typeof value !== 'string' || !value.trim())
|
|
49
|
+
return undefined;
|
|
50
|
+
return ENGINE_TO_TITAN_PLOT_TYPE.get(value.trim()) ?? value;
|
|
51
|
+
}
|
|
52
|
+
function isObject(value) {
|
|
53
|
+
return typeof value === 'object' && value !== null;
|
|
54
|
+
}
|
|
55
|
+
function rowHasDrawableCell(row) {
|
|
56
|
+
if (!Array.isArray(row))
|
|
57
|
+
return false;
|
|
58
|
+
return row.slice(1).some((cell) => {
|
|
59
|
+
if (typeof cell === 'number')
|
|
60
|
+
return Number.isFinite(cell);
|
|
61
|
+
return isObject(cell);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export function rowsHaveDrawableCells(rows) {
|
|
65
|
+
return Array.isArray(rows) && rows.some((row) => rowHasDrawableCell(row));
|
|
66
|
+
}
|
|
67
|
+
export const MAX_KSCRIPT_META_VISITS = 1_000;
|
|
68
|
+
function hasFinitePositiveStyleDataOffset(value) {
|
|
69
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 1;
|
|
70
|
+
}
|
|
71
|
+
function inferMultiValueStyleDataOffset(data, styleProperties) {
|
|
72
|
+
const stylePropertyCount = Array.isArray(styleProperties) ? styleProperties.length : 0;
|
|
73
|
+
if (stylePropertyCount === 0)
|
|
74
|
+
return null;
|
|
75
|
+
if (!Array.isArray(data))
|
|
76
|
+
return null;
|
|
77
|
+
for (const candidateRow of data) {
|
|
78
|
+
if (!Array.isArray(candidateRow) || candidateRow.length <= 2)
|
|
79
|
+
continue;
|
|
80
|
+
const valueEndFromStyles = candidateRow.length - stylePropertyCount;
|
|
81
|
+
if (valueEndFromStyles >= 2)
|
|
82
|
+
return valueEndFromStyles;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
function isDefaultFilledSplineOutput(output) {
|
|
87
|
+
const plot = output.plotType ?? output.plot;
|
|
88
|
+
const fill = output.fill;
|
|
89
|
+
return (plot === 'spline' || plot === 'line') && (fill === true || fill === 'default');
|
|
90
|
+
}
|
|
91
|
+
function hasStyleColumns(output) {
|
|
92
|
+
return Array.isArray(output.styleProperties) && output.styleProperties.length > 0;
|
|
93
|
+
}
|
|
94
|
+
function plotTypeOf(output) {
|
|
95
|
+
const plotType = output.plotType ?? output.plot;
|
|
96
|
+
return typeof plotType === 'string' ? plotType : undefined;
|
|
97
|
+
}
|
|
98
|
+
function finitePositiveRowOffset(value, rowLength) {
|
|
99
|
+
return typeof value === 'number' && Number.isInteger(value) && value > 1 && value <= rowLength ? value : null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The FE-side payload boundary for packed style rows (see titan's
|
|
103
|
+
* STYLE_ROW_CONTRACT.md). Unlike titan's strict reader, this keeps the
|
|
104
|
+
* documented inference branches because the FE normalizes transitional wire
|
|
105
|
+
* shapes (flat parents seed styleDataOffset 0; multiValue arrivals can lack
|
|
106
|
+
* the field until normalization reconstructs it).
|
|
107
|
+
*/
|
|
108
|
+
export function kScriptPlottedValueEnd(row, output) {
|
|
109
|
+
const explicitOffset = finitePositiveRowOffset(output.styleDataOffset, row.length);
|
|
110
|
+
if (explicitOffset !== null)
|
|
111
|
+
return explicitOffset;
|
|
112
|
+
const styleCount = Array.isArray(output.styleProperties) ? output.styleProperties.length : 0;
|
|
113
|
+
if (styleCount > 0 && row.length - styleCount > 1)
|
|
114
|
+
return row.length - styleCount;
|
|
115
|
+
return row.length;
|
|
116
|
+
}
|
|
117
|
+
const plottedValueEnd = kScriptPlottedValueEnd;
|
|
118
|
+
function isSafeRendererPayloadCell(cell) {
|
|
119
|
+
if (cell == null)
|
|
120
|
+
return false;
|
|
121
|
+
if (typeof cell === 'number')
|
|
122
|
+
return Number.isFinite(cell);
|
|
123
|
+
if (typeof cell === 'string' || typeof cell === 'boolean')
|
|
124
|
+
return true;
|
|
125
|
+
if (Array.isArray(cell))
|
|
126
|
+
return cell.length > 0 && cell.every(isSafeRendererPayloadCell);
|
|
127
|
+
return isObject(cell);
|
|
128
|
+
}
|
|
129
|
+
function isSparseMarkerPlaceholderCell(cell) {
|
|
130
|
+
return cell == null || (typeof cell === 'number' && Number.isNaN(cell));
|
|
131
|
+
}
|
|
132
|
+
/** A marker whose NaN rows are its plotShape skeleton: the engine's marker role, or `markerSkeleton: true`, which
|
|
133
|
+
* the wrun adapter stamps on a mark that carries no marker role (its one NaN row ends the series on the last run
|
|
134
|
+
* row, wrun-run-result.util markEndRow; the engine never emits the field). */
|
|
135
|
+
function isDeclaredMarkerOutput(output) {
|
|
136
|
+
const declared = (typeof output.outputRole === 'string' && output.outputRole.toLowerCase() === 'marker') ||
|
|
137
|
+
output.markerSkeleton === true;
|
|
138
|
+
return declared && isKScriptDeclaredMarkerPlotType(plotTypeOf(output));
|
|
139
|
+
}
|
|
140
|
+
function hasSafeStylePayload(row, output) {
|
|
141
|
+
const valueEnd = plottedValueEnd(row, output);
|
|
142
|
+
if (valueEnd >= row.length)
|
|
143
|
+
return true;
|
|
144
|
+
if (!hasStyleColumns(output))
|
|
145
|
+
return false;
|
|
146
|
+
return row.slice(valueEnd).every(isSafeRendererPayloadCell);
|
|
147
|
+
}
|
|
148
|
+
function isSafeSparseMarkerSkeletonRow(row, output, plottedPayload) {
|
|
149
|
+
return (isDeclaredMarkerOutput(output) &&
|
|
150
|
+
plottedPayload.length > 0 &&
|
|
151
|
+
plottedPayload.every(isSparseMarkerPlaceholderCell) &&
|
|
152
|
+
hasSafeStylePayload(row, output));
|
|
153
|
+
}
|
|
154
|
+
function isSafeRendererDataRow(row, output) {
|
|
155
|
+
if (!Array.isArray(row))
|
|
156
|
+
return row != null;
|
|
157
|
+
if (row.length <= 1)
|
|
158
|
+
return false;
|
|
159
|
+
const time = row[0];
|
|
160
|
+
if (typeof time === 'number' && !Number.isFinite(time))
|
|
161
|
+
return true;
|
|
162
|
+
const payload = row.slice(1, plottedValueEnd(row, output));
|
|
163
|
+
if (payload.length === 0)
|
|
164
|
+
return false;
|
|
165
|
+
if (payload.every(isSafeRendererPayloadCell))
|
|
166
|
+
return true;
|
|
167
|
+
return isSafeSparseMarkerSkeletonRow(row, output, payload);
|
|
168
|
+
}
|
|
169
|
+
function filterUnsafeRendererRows(rows, output) {
|
|
170
|
+
if (!Array.isArray(rows))
|
|
171
|
+
return rows;
|
|
172
|
+
const plotType = plotTypeOf(output);
|
|
173
|
+
// Table and foreign-pane rows skip the plotted-value checks below (a null
|
|
174
|
+
// CELL in a foreign-pane row is a legitimate series gap, curve `na`; the
|
|
175
|
+
// engine door sanitizes those). A null or undefined ENTRY is still never a
|
|
176
|
+
// row: titan's processData indexes row[0] on every nested output it folds,
|
|
177
|
+
// and a hole there throws mid-pass and strands the chart's viewport at its
|
|
178
|
+
// empty sentinel (RST's blank NQ1! chart, 2026-10-07). Drop holes only.
|
|
179
|
+
if (plotType === 'table' || isKScriptForeignPanePlotType(plotType)) {
|
|
180
|
+
const compact = rows.filter((row) => row != null);
|
|
181
|
+
return compact.length === rows.length ? rows : compact;
|
|
182
|
+
}
|
|
183
|
+
let changed = false;
|
|
184
|
+
const filtered = rows.filter((row) => {
|
|
185
|
+
const keep = isSafeRendererDataRow(row, output);
|
|
186
|
+
changed ||= !keep;
|
|
187
|
+
return keep;
|
|
188
|
+
});
|
|
189
|
+
return changed ? filtered : rows;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Drawing outputs (`plotRange`, `plotText`, `plotPriceLabel`) are emitted per
|
|
193
|
+
* bar: a script that keeps a live box open re-emits it on every bar with a
|
|
194
|
+
* growing right edge, and a label it wants to keep visible is re-emitted on
|
|
195
|
+
* every bar at the same price. TitanCharts draws every row, so those emissions
|
|
196
|
+
* pile up on the same pixels and their alphas stack (a 12% fill re-emitted on
|
|
197
|
+
* eight bars renders solid; field report 2026-09-03, session boxes).
|
|
198
|
+
*
|
|
199
|
+
* One logical drawing therefore collapses to one row before TitanCharts sees
|
|
200
|
+
* it. A box is identified by its left anchor plus its colours (two boxes that
|
|
201
|
+
* start on the same bar keep their own colours) and keeps its LAST emission,
|
|
202
|
+
* the widest extent. A label is identified by its text, price and colour and
|
|
203
|
+
* keeps its FIRST emission, the bar the event happened on: a label folds only
|
|
204
|
+
* into the same label on its own bar or on the run bar right before it (the
|
|
205
|
+
* label re-emitted bar after bar), never into one drawn earlier with bars
|
|
206
|
+
* between, which is another drawing that reads the same (two Volume Bubbles
|
|
207
|
+
* bubbles of "$24.8M" at 84,013.5 eighteen bars apart lost the later one's
|
|
208
|
+
* label: the parity recheck's N3, 2026-10-15). Which bar comes right before
|
|
209
|
+
* another is the run's to say (`KScriptRunBars`); a caller that does not know
|
|
210
|
+
* folds a label on its own bar only. Rows that are not `[ts, payload-object]`
|
|
211
|
+
* pass through untouched, as does every other plot type.
|
|
212
|
+
*/
|
|
213
|
+
const COLLAPSE_LAST_PLOT_TYPES = new Set(['range']);
|
|
214
|
+
const COLLAPSE_FIRST_PLOT_TYPES = new Set(['text', 'priceLabel']);
|
|
215
|
+
function drawingRowCollapseKey(plotType, payload) {
|
|
216
|
+
if (COLLAPSE_LAST_PLOT_TYPES.has(plotType)) {
|
|
217
|
+
if (typeof payload.time1 !== 'number')
|
|
218
|
+
return null;
|
|
219
|
+
return `${payload.time1}|${String(payload.color ?? '')}|${String(payload.fillColor ?? '')}`;
|
|
220
|
+
}
|
|
221
|
+
if (COLLAPSE_FIRST_PLOT_TYPES.has(plotType)) {
|
|
222
|
+
if (typeof payload.price !== 'number')
|
|
223
|
+
return null;
|
|
224
|
+
return `${String(payload.text ?? '')}|${payload.price}|${String(payload.color ?? '')}`;
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The key a drawing row collapses by (`collapseRepeatedKScriptDrawingRows`):
|
|
230
|
+
* null for a row that is not `[ts, payload-object]`, for a payload without
|
|
231
|
+
* the key's anchor, and for every plot type that does not collapse. Exported
|
|
232
|
+
* for the live tail patch, which must know when a key crosses its window.
|
|
233
|
+
*/
|
|
234
|
+
export function kScriptDrawingRowCollapseKey(plotType, row) {
|
|
235
|
+
if (!isKScriptCollapsedDrawingPlotType(plotType))
|
|
236
|
+
return null;
|
|
237
|
+
const payload = Array.isArray(row) && row.length >= 2 ? row[1] : null;
|
|
238
|
+
return isObject(payload) ? drawingRowCollapseKey(plotType, payload) : null;
|
|
239
|
+
}
|
|
240
|
+
/** Whether a plot's drawing rows collapse by key (`kScriptDrawingRowCollapseKey`). */
|
|
241
|
+
export function isKScriptCollapsedDrawingPlotType(plotType) {
|
|
242
|
+
return plotType !== undefined && (COLLAPSE_LAST_PLOT_TYPES.has(plotType) || COLLAPSE_FIRST_PLOT_TYPES.has(plotType));
|
|
243
|
+
}
|
|
244
|
+
/** The index of `ts` in ascending `times`, -1 when absent. */
|
|
245
|
+
function sortedIndexOf(times, ts) {
|
|
246
|
+
let low = 0;
|
|
247
|
+
let high = times.length - 1;
|
|
248
|
+
while (low <= high) {
|
|
249
|
+
const mid = (low + high) >>> 1;
|
|
250
|
+
if (times[mid] === ts)
|
|
251
|
+
return mid;
|
|
252
|
+
if (times[mid] < ts)
|
|
253
|
+
low = mid + 1;
|
|
254
|
+
else
|
|
255
|
+
high = mid - 1;
|
|
256
|
+
}
|
|
257
|
+
return -1;
|
|
258
|
+
}
|
|
259
|
+
/** Whether `ts` is the run bar right after `previousTs`: no bar of the run lies between them. */
|
|
260
|
+
function isNextRunBar(bars, previousTs, ts) {
|
|
261
|
+
if (bars === undefined || !(ts > previousTs))
|
|
262
|
+
return false;
|
|
263
|
+
if (bars.barMs !== undefined && bars.barMs > 0 && ts - previousTs <= bars.barMs)
|
|
264
|
+
return true;
|
|
265
|
+
const times = bars.barTimes?.();
|
|
266
|
+
if (!times)
|
|
267
|
+
return false;
|
|
268
|
+
const at = sortedIndexOf(times, previousTs);
|
|
269
|
+
return at >= 0 && times[at + 1] === ts;
|
|
270
|
+
}
|
|
271
|
+
function collapseRepeatedKScriptDrawingRows(rows, output, runBars) {
|
|
272
|
+
const plotType = plotTypeOf(output);
|
|
273
|
+
if (!isKScriptCollapsedDrawingPlotType(plotType))
|
|
274
|
+
return rows;
|
|
275
|
+
if (!Array.isArray(rows) || rows.length < 2)
|
|
276
|
+
return rows;
|
|
277
|
+
if (COLLAPSE_LAST_PLOT_TYPES.has(plotType)) {
|
|
278
|
+
const chosen = new Map();
|
|
279
|
+
const passthrough = [];
|
|
280
|
+
rows.forEach((row, index) => {
|
|
281
|
+
const payload = Array.isArray(row) && row.length >= 2 ? row[1] : null;
|
|
282
|
+
const key = isObject(payload) ? drawingRowCollapseKey(plotType, payload) : null;
|
|
283
|
+
if (key === null)
|
|
284
|
+
passthrough.push(index);
|
|
285
|
+
else
|
|
286
|
+
chosen.set(key, index);
|
|
287
|
+
});
|
|
288
|
+
const keptIndices = [...chosen.values(), ...passthrough].sort((a, b) => a - b);
|
|
289
|
+
if (keptIndices.length === rows.length)
|
|
290
|
+
return rows;
|
|
291
|
+
return keptIndices.map((index) => rows[index]);
|
|
292
|
+
}
|
|
293
|
+
// A label: each key remembers the bar it last showed on, a fold or not, so a label re-emitted bar after
|
|
294
|
+
// bar keeps only its first row however long it runs, and the same label after a gap starts again.
|
|
295
|
+
const lastShownAt = new Map();
|
|
296
|
+
let kept = null;
|
|
297
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
298
|
+
const row = rows[index];
|
|
299
|
+
const ts = Array.isArray(row) ? row[0] : undefined;
|
|
300
|
+
const payload = Array.isArray(row) && row.length >= 2 ? row[1] : null;
|
|
301
|
+
const key = isObject(payload) ? drawingRowCollapseKey(plotType, payload) : null;
|
|
302
|
+
if (key !== null && typeof ts === 'number' && Number.isFinite(ts)) {
|
|
303
|
+
const previous = lastShownAt.get(key);
|
|
304
|
+
lastShownAt.set(key, ts);
|
|
305
|
+
if (previous !== undefined && (previous === ts || isNextRunBar(runBars, previous, ts))) {
|
|
306
|
+
kept ??= rows.slice(0, index);
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
kept?.push(row);
|
|
311
|
+
}
|
|
312
|
+
return kept ?? rows;
|
|
313
|
+
}
|
|
314
|
+
function isZeroishValue(value) {
|
|
315
|
+
return value == null || value === 0 || (typeof value === 'number' && Number.isNaN(value));
|
|
316
|
+
}
|
|
317
|
+
function hasFillGradientStops(output) {
|
|
318
|
+
const gradient = output.fillGradient;
|
|
319
|
+
if (typeof gradient !== 'object' || gradient === null)
|
|
320
|
+
return false;
|
|
321
|
+
const stops = gradient.stops;
|
|
322
|
+
return Array.isArray(stops) && stops.length >= 2;
|
|
323
|
+
}
|
|
324
|
+
function isZeroBaselineMultiValueFill(output) {
|
|
325
|
+
if (!Array.isArray(output.data))
|
|
326
|
+
return false;
|
|
327
|
+
let hasMultiValueRow = false;
|
|
328
|
+
for (const row of output.data) {
|
|
329
|
+
if (!Array.isArray(row) || row.length <= 2)
|
|
330
|
+
continue;
|
|
331
|
+
hasMultiValueRow = true;
|
|
332
|
+
for (let index = 2; index < row.length; index += 1) {
|
|
333
|
+
if (!isZeroishValue(row[index]))
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return hasMultiValueRow;
|
|
338
|
+
}
|
|
339
|
+
// Engines below 3.0.47 can emit color literals with non-finite components
|
|
340
|
+
// (`opacity(color, NaN)` on a NaN data edge -> "rgba(153, 255, 228, NaN)").
|
|
341
|
+
// Those are not CSS colors: canvas silently keeps the previous fillStyle and
|
|
342
|
+
// palette classification cannot see them. Rewrite a non-finite ALPHA to 0
|
|
343
|
+
// (renders nothing, matching the engine-side fix); any other non-finite
|
|
344
|
+
// component makes the whole color unknown -> transparent black.
|
|
345
|
+
const NON_FINITE_COLOR_COMPONENT_PATTERN = /\bNaN\b|\bInfinity\b/i;
|
|
346
|
+
const NON_FINITE_ALPHA_ONLY_PATTERN = /^(rgba?\(\s*\d+(?:\.\d+)?\s*,\s*\d+(?:\.\d+)?\s*,\s*\d+(?:\.\d+)?\s*,\s*)(?:NaN|-?Infinity)\s*\)$/i;
|
|
347
|
+
function sanitizeKScriptColorLiteral(value) {
|
|
348
|
+
if (typeof value !== 'string' || !NON_FINITE_COLOR_COMPONENT_PATTERN.test(value))
|
|
349
|
+
return value;
|
|
350
|
+
const alphaOnly = value.match(NON_FINITE_ALPHA_ONLY_PATTERN);
|
|
351
|
+
if (alphaOnly)
|
|
352
|
+
return `${alphaOnly[1]}0)`;
|
|
353
|
+
return 'rgba(0, 0, 0, 0)';
|
|
354
|
+
}
|
|
355
|
+
function sanitizeKScriptColorList(value) {
|
|
356
|
+
if (typeof value === 'string')
|
|
357
|
+
return sanitizeKScriptColorLiteral(value);
|
|
358
|
+
if (!Array.isArray(value))
|
|
359
|
+
return value;
|
|
360
|
+
let changed = false;
|
|
361
|
+
const sanitized = value.map((entry) => {
|
|
362
|
+
const next = sanitizeKScriptColorLiteral(entry);
|
|
363
|
+
changed ||= next !== entry;
|
|
364
|
+
return next;
|
|
365
|
+
});
|
|
366
|
+
return changed ? sanitized : value;
|
|
367
|
+
}
|
|
368
|
+
function normalizeKScriptPlotContainerForTitanCharts(container, options = {}) {
|
|
369
|
+
if (!isObject(container))
|
|
370
|
+
return container;
|
|
371
|
+
let normalized = container;
|
|
372
|
+
const clone = () => {
|
|
373
|
+
if (normalized === container)
|
|
374
|
+
normalized = { ...container };
|
|
375
|
+
return normalized;
|
|
376
|
+
};
|
|
377
|
+
// titan-charts has no 'histogram' plot kind. The registered 'bar' plot is
|
|
378
|
+
// the single-value baseline-anchored renderer that reads kScript styled rows
|
|
379
|
+
// ([ts, value, ...styleIndices] via styledRowReader) and colors by sign
|
|
380
|
+
// (palette[0] above base, palette[1] below). 'columns' looks tempting but
|
|
381
|
+
// consumes candle-shaped [ts,o,h,l,c] rows and always drops to the pane
|
|
382
|
+
// floor, so histogram rows render nothing there; 'stem' draws a 1px lollipop
|
|
383
|
+
// line and ignores bar width. Only the kind string is rewritten: styling
|
|
384
|
+
// fields and the engine's output-level `base` ride along untouched.
|
|
385
|
+
if (plotTypeOf(container) === 'histogram') {
|
|
386
|
+
const next = clone();
|
|
387
|
+
if (next.plotType === 'histogram')
|
|
388
|
+
next.plotType = 'bar';
|
|
389
|
+
if (next.plot === 'histogram')
|
|
390
|
+
next.plot = 'bar';
|
|
391
|
+
}
|
|
392
|
+
// Engine name -> titan kind rewrite (mapEnginePlotTypeToTitanPlotType owns
|
|
393
|
+
// the 'line' -> 'spline' mapping and its rationale). Kind string only,
|
|
394
|
+
// styling untouched. NESTED entries are deliberately exempt: nested kScript
|
|
395
|
+
// series ride titan's styled-row nested lane (which accepts 'line'), and
|
|
396
|
+
// the protected render-field sync matches nested entries by their wire
|
|
397
|
+
// identity, so rewriting there breaks style sync (pinned by the Stoch RSI
|
|
398
|
+
// integration spec).
|
|
399
|
+
if (!options.nestedEntry && plotTypeOf(container) === 'line') {
|
|
400
|
+
const next = clone();
|
|
401
|
+
if (next.plotType === 'line')
|
|
402
|
+
next.plotType = mapEnginePlotTypeToTitanPlotType(next.plotType);
|
|
403
|
+
if (next.plot === 'line')
|
|
404
|
+
next.plot = mapEnginePlotTypeToTitanPlotType(next.plot);
|
|
405
|
+
}
|
|
406
|
+
for (const key of ['colors', 'color']) {
|
|
407
|
+
const sanitized = sanitizeKScriptColorList(normalized[key]);
|
|
408
|
+
if (sanitized !== normalized[key])
|
|
409
|
+
clone()[key] = sanitized;
|
|
410
|
+
}
|
|
411
|
+
if (container.multiValue === true && !hasFinitePositiveStyleDataOffset(container.styleDataOffset)) {
|
|
412
|
+
const inferredStyleDataOffset = inferMultiValueStyleDataOffset(container.data, container.styleProperties);
|
|
413
|
+
if (inferredStyleDataOffset !== null) {
|
|
414
|
+
clone().styleDataOffset = inferredStyleDataOffset;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (container.multiValue === true && isDefaultFilledSplineOutput(container)) {
|
|
418
|
+
const next = clone();
|
|
419
|
+
// A zero-baseline pair with an EXPLICIT fillGradient is unambiguous author
|
|
420
|
+
// intent to area-fill down to zero (the plotLine fillGradient kwarg), so it
|
|
421
|
+
// keeps its fill; so does a wrun area's own fill ladder output, which the
|
|
422
|
+
// adapter stamps `areaFill: true` (WRUN-STYLE OT31: a per-bar colour table
|
|
423
|
+
// instead of a gradient). The legacy downgrade below only guards pairs
|
|
424
|
+
// where the trailing zero column is an artifact, which predates the kwarg.
|
|
425
|
+
if (isZeroBaselineMultiValueFill(container) && !hasFillGradientStops(container) && container.areaFill !== true) {
|
|
426
|
+
next.fill = false;
|
|
427
|
+
delete next.styleDataOffset;
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
delete next.multiValue;
|
|
431
|
+
if (!hasStyleColumns(next))
|
|
432
|
+
delete next.styleDataOffset;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
for (const key of ['data', 'rawData', 'activeData']) {
|
|
436
|
+
const filteredRows = filterUnsafeRendererRows(normalized[key], normalized);
|
|
437
|
+
const collapsedRows = collapseRepeatedKScriptDrawingRows(filteredRows, normalized, options.runBars);
|
|
438
|
+
if (collapsedRows !== normalized[key])
|
|
439
|
+
clone()[key] = collapsedRows;
|
|
440
|
+
}
|
|
441
|
+
if (isObject(normalized.outputs)) {
|
|
442
|
+
let normalizedOutputs = normalized.outputs;
|
|
443
|
+
let outputsChanged = false;
|
|
444
|
+
Object.entries(normalized.outputs).forEach(([key, output]) => {
|
|
445
|
+
const normalizedOutput = normalizeKScriptPlotContainerForTitanCharts(output, { runBars: options.runBars });
|
|
446
|
+
if (normalizedOutput !== output) {
|
|
447
|
+
if (!outputsChanged) {
|
|
448
|
+
normalizedOutputs = { ...normalizedOutputs };
|
|
449
|
+
outputsChanged = true;
|
|
450
|
+
}
|
|
451
|
+
normalizedOutputs[key] = normalizedOutput;
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
if (outputsChanged)
|
|
455
|
+
clone().outputs = normalizedOutputs;
|
|
456
|
+
}
|
|
457
|
+
if (Array.isArray(normalized.nestedMeta)) {
|
|
458
|
+
let nestedChanged = false;
|
|
459
|
+
const nestedMeta = normalized.nestedMeta.map((nested) => {
|
|
460
|
+
const normalizedNested = normalizeKScriptPlotContainerForTitanCharts(nested, {
|
|
461
|
+
nestedEntry: true,
|
|
462
|
+
runBars: options.runBars,
|
|
463
|
+
});
|
|
464
|
+
nestedChanged ||= normalizedNested !== nested;
|
|
465
|
+
return normalizedNested;
|
|
466
|
+
});
|
|
467
|
+
if (nestedChanged)
|
|
468
|
+
clone().nestedMeta = nestedMeta;
|
|
469
|
+
}
|
|
470
|
+
return normalized;
|
|
471
|
+
}
|
|
472
|
+
/** `runBars`: the run's bars as far as the caller knows them, which tell the label collapse the bar right before a
|
|
473
|
+
* label's; without them a label folds into the same label on its own bar alone. */
|
|
474
|
+
export function normalizeKScriptRunResultForTitanCharts(runResult, runBars) {
|
|
475
|
+
return normalizeKScriptPlotContainerForTitanCharts(runResult, { runBars });
|
|
476
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
2
|
+
export declare function hasOwnRecordKey(record: Record<string, unknown>, key: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* The engine output a nested meta was mounted from. Titan keeps the applied
|
|
5
|
+
* run result on the parent (`meta.runResult`) and keys each child by the
|
|
6
|
+
* output it came from; fields titan does not copy onto the child meta (the
|
|
7
|
+
* `label=` column `labels`, the adapter's FE-only `legend`, `format`,
|
|
8
|
+
* `priceMarkers`) are read off that output.
|
|
9
|
+
*/
|
|
10
|
+
export declare function kScriptRunOutputFor(meta: Record<string, unknown>, nested: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
11
|
+
export declare function outputHasRenderableRows(output: unknown): boolean;
|
|
12
|
+
export declare function isOffchartMetadataRunResult(runResult: unknown, meta: Record<string, unknown> | null | undefined): boolean;
|
|
13
|
+
export declare function isOnchartMetadataRunResult(runResult: unknown, meta: Record<string, unknown> | null | undefined): boolean;
|
|
14
|
+
export declare function isAxislessOnchartMetadataRunResult(runResult: unknown, meta: Record<string, unknown> | null | undefined): boolean;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export function isRecord(value) {
|
|
2
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
export function hasOwnRecordKey(record, key) {
|
|
5
|
+
return Object.prototype.hasOwnProperty.call(record, key);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The engine output a nested meta was mounted from. Titan keeps the applied
|
|
9
|
+
* run result on the parent (`meta.runResult`) and keys each child by the
|
|
10
|
+
* output it came from; fields titan does not copy onto the child meta (the
|
|
11
|
+
* `label=` column `labels`, the adapter's FE-only `legend`, `format`,
|
|
12
|
+
* `priceMarkers`) are read off that output.
|
|
13
|
+
*/
|
|
14
|
+
export function kScriptRunOutputFor(meta, nested) {
|
|
15
|
+
const runResult = isRecord(meta.runResult) ? meta.runResult : undefined;
|
|
16
|
+
const outputs = runResult && isRecord(runResult.outputs) ? runResult.outputs : undefined;
|
|
17
|
+
if (!outputs)
|
|
18
|
+
return undefined;
|
|
19
|
+
for (const key of [nested.outputKey, nested.plotKey, nested.plotId]) {
|
|
20
|
+
if (typeof key !== 'string')
|
|
21
|
+
continue;
|
|
22
|
+
const output = outputs[key];
|
|
23
|
+
if (isRecord(output))
|
|
24
|
+
return output;
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
export function outputHasRenderableRows(output) {
|
|
29
|
+
if (!isRecord(output))
|
|
30
|
+
return false;
|
|
31
|
+
for (const candidate of [output.data, output.rawData, output.activeData]) {
|
|
32
|
+
if (Array.isArray(candidate) && candidate.length > 0)
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
export function isOffchartMetadataRunResult(runResult, meta) {
|
|
38
|
+
const define = isRecord(runResult) && isRecord(runResult.define) ? runResult.define : null;
|
|
39
|
+
if (define?.position === 'offchart')
|
|
40
|
+
return true;
|
|
41
|
+
if (define?.position === 'onchart')
|
|
42
|
+
return false;
|
|
43
|
+
return meta?.type === 'offchart';
|
|
44
|
+
}
|
|
45
|
+
export function isOnchartMetadataRunResult(runResult, meta) {
|
|
46
|
+
const define = isRecord(runResult) && isRecord(runResult.define) ? runResult.define : null;
|
|
47
|
+
if (define?.position === 'onchart')
|
|
48
|
+
return true;
|
|
49
|
+
if (define?.position === 'offchart')
|
|
50
|
+
return false;
|
|
51
|
+
return meta?.type === 'onchart';
|
|
52
|
+
}
|
|
53
|
+
export function isAxislessOnchartMetadataRunResult(runResult, meta) {
|
|
54
|
+
const define = isRecord(runResult) && isRecord(runResult.define) ? runResult.define : null;
|
|
55
|
+
if (define?.position === 'offchart')
|
|
56
|
+
return false;
|
|
57
|
+
if (define?.position === 'onchart' && define.axis === false)
|
|
58
|
+
return true;
|
|
59
|
+
if (define?.position === 'onchart' && define.axis === true)
|
|
60
|
+
return false;
|
|
61
|
+
if (!isOnchartMetadataRunResult(runResult, meta))
|
|
62
|
+
return false;
|
|
63
|
+
const metaDefine = meta && isRecord(meta.define) ? meta.define : null;
|
|
64
|
+
const settings = meta && isRecord(meta.settings) ? meta.settings : null;
|
|
65
|
+
return meta?.axis === false || metaDefine?.axis === false || settings?.axis === false;
|
|
66
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const KSCRIPT_CONTAINER_OUTPUT_KEY = "__kiyoKScriptContainer";
|
|
2
|
+
/**
|
|
3
|
+
* The key of the output whose rows seed the container: the most rows, ties to
|
|
4
|
+
* the better seed rank, then declaration order; undefined when no output
|
|
5
|
+
* carries timestamped rows. Exported for the live tail patch, which proves the
|
|
6
|
+
* densest output of a whole result from its outputs' whole rows.
|
|
7
|
+
*/
|
|
8
|
+
export declare function densestKScriptOutputKey(outputs: Record<string, unknown>): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* A run result whose container spans its run: the wrun adapter's mark (`containerSpansRun`). A
|
|
11
|
+
* kScript container spans its engine timeline by itself (scalar series and marker skeletons keep a
|
|
12
|
+
* row on every bar the script ran); a wrun output reaches the preparation as [ts, value] rows whose
|
|
13
|
+
* NaN rows it drops, so its container only mirrors the densest output's finite rows.
|
|
14
|
+
*/
|
|
15
|
+
export declare function kScriptContainerSpansRun(runResult: unknown): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Lay a spanning container (kScriptContainerSpansRun) over the chart's bars of its run: the rows it
|
|
18
|
+
* mirrors stay as they are, and every chart bar from its first row (`span.fromMs`, else the chart's
|
|
19
|
+
* first bar, for a container that holds none: a frame-only parent) through the run's last bar
|
|
20
|
+
* (`span.toMs`) that holds no row gains an empty one at the row's width ([ts, NaN, ...]). The
|
|
21
|
+
* legend's hovered row (the exact-bar match) and its resting row (the newest one) then sit on the
|
|
22
|
+
* bar they name, as on a kScript overlay: a seed that stops before the newest bar no longer hands
|
|
23
|
+
* every legend cell its own last bar. Anything else, or a container with no gap, is returned as is.
|
|
24
|
+
*/
|
|
25
|
+
export declare function withKScriptContainerSpanningRun(runResult: unknown, chartTimes: readonly number[], span: {
|
|
26
|
+
fromMs?: number;
|
|
27
|
+
toMs: number;
|
|
28
|
+
}): unknown;
|
|
29
|
+
export declare function withKScriptContainerOutput(runResult: unknown): unknown;
|