@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,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Packed WRUN row transport: turns runtime rows `{ ts, values, cellBlocks? }`
|
|
3
|
+
* into the transferable request buffers the sandbox worker drives from, and
|
|
4
|
+
* unpacks the packed response back into per-row outputs and strings.
|
|
5
|
+
*
|
|
6
|
+
* The layout mirrors the om daemon's packed protocol byte for byte (see
|
|
7
|
+
* `wrun-runtime.interface.ts`), so absent-slot scalar semantics
|
|
8
|
+
* (`wrun_arg_count`, NaN past a row's original argument count), the -1
|
|
9
|
+
* missing-block convention, and the string table's absent (-1) vs
|
|
10
|
+
* present-empty (0) distinction all survive the worker hop.
|
|
11
|
+
*
|
|
12
|
+
* Cell enforcement runs HERE, during packing and before any worker is
|
|
13
|
+
* involved: a block on an input not declared `cellType: "array"` and a block
|
|
14
|
+
* over the input's `max_cells` (counted in TUPLES) both refuse the whole
|
|
15
|
+
* evaluation by name, never truncate. One exception (frozen authoring
|
|
16
|
+
* contract C1.2b): an input declaring `missing: "empty"` reads an oversize
|
|
17
|
+
* block as a PRESENT EMPTY block (0 cells) on that bar alone and the run
|
|
18
|
+
* goes on, the way the same input reads a lane that answered nothing; the
|
|
19
|
+
* block is still never truncated.
|
|
20
|
+
*/
|
|
21
|
+
import { abiAtLeast } from '../../interfaces/wrun-runtime.interface.js';
|
|
22
|
+
import { WRUN_FRAME_DEFAULT_MAX_BYTES, WRUN_FRAME_MAX_SLOTS } from './wrun-frames.js';
|
|
23
|
+
import { wrunChartHostEnv } from '../../host-env.js';
|
|
24
|
+
import { wrunPlainText } from './wrun-text-params.util.js';
|
|
25
|
+
/** Cell tuple widths per celled source class (f64 cells per source tuple), the shared host's table
|
|
26
|
+
* (`WRUN_HOST_CELL_TUPLE_WIDTHS`): `volume_profile` = [low, high, buy, sell]; `book` = [price,
|
|
27
|
+
* abs(size), side]; `tape` = [offset_ms, price, size, side]; `trade_volume_by_size` = [bucket,
|
|
28
|
+
* buy_usd, sell_usd, buy_count, sell_count]; `intrabar` and `candles` = [offset_ms, open, high,
|
|
29
|
+
* low, close, volume]; `options_chain` = [strike, expiry_ms, side, oi, gamma, delta, mark_iv,
|
|
30
|
+
* underlying, multiplier, vega]. Read at pack time: a run loaded the host first. `max_cells`
|
|
31
|
+
* counts tuples; the packed byte math counts f64s. */
|
|
32
|
+
export function wrunCellTupleWidths() {
|
|
33
|
+
return wrunChartHostEnv().sharedHost().WRUN_HOST_CELL_TUPLE_WIDTHS;
|
|
34
|
+
}
|
|
35
|
+
/** The frozen refusal for a block over its input's `max_cells` (the om contract's code, every
|
|
36
|
+
* host): the evaluation is refused, the block never truncated. An input declaring
|
|
37
|
+
* `missing: "empty"` (C1.2b) reads that bar as an empty block instead. */
|
|
38
|
+
export const WRUN_CELL_BLOCK_TOO_LARGE_CODE = 'wrun_cell_block_too_large';
|
|
39
|
+
export function wrunAbiVersion(metadata) {
|
|
40
|
+
if (metadata.abi_version === 'wrun-6')
|
|
41
|
+
return 'wrun-6';
|
|
42
|
+
if (metadata.abi_version === 'wrun-5')
|
|
43
|
+
return 'wrun-5';
|
|
44
|
+
if (metadata.abi_version === 'wrun-4')
|
|
45
|
+
return 'wrun-4';
|
|
46
|
+
if (metadata.abi_version === 'wrun-3')
|
|
47
|
+
return 'wrun-3';
|
|
48
|
+
return metadata.abi_version === 'wrun-2' ? 'wrun-2' : 'wrun-1';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Pack the rows (and init()'s argument block) for the sheet's ABI.
|
|
52
|
+
* `textParams` is the wrun-5 text channel (wrun-text-params.util
|
|
53
|
+
* `wrunTextParamsForRun`: every text param's plain UTF-8 bytes by init slot);
|
|
54
|
+
* it rides the request structured-cloned, never transferred, because the
|
|
55
|
+
* live session seed keeps the same buffers for every reseed. A sheet that
|
|
56
|
+
* declares a text param under an older ABI refuses here by name, the way
|
|
57
|
+
* celled inputs and frames do.
|
|
58
|
+
*/
|
|
59
|
+
export function packWrunRows(metadata, rows, initArgs, textParams) {
|
|
60
|
+
const abi = wrunAbiVersion(metadata);
|
|
61
|
+
const outputCount = metadata.outputs.length;
|
|
62
|
+
const rowCount = rows.length;
|
|
63
|
+
const celledInputs = metadata.inputs.filter((input) => input.cellType === 'array');
|
|
64
|
+
if (!abiAtLeast(abi, 'wrun-2') && celledInputs.length > 0) {
|
|
65
|
+
throw new Error(`WRUN ${metadata.id}: celled inputs require abi_version "wrun-2" (declared: ` +
|
|
66
|
+
`${celledInputs.map((input) => input.name).join(', ')})`);
|
|
67
|
+
}
|
|
68
|
+
const textParamNames = metadata.params.filter((param) => param.type === 'text').map((param) => param.name);
|
|
69
|
+
if (!abiAtLeast(abi, 'wrun-5') && textParamNames.length > 0) {
|
|
70
|
+
throw new Error(`WRUN ${metadata.id}: text params require abi_version "wrun-5" (declared: ${textParamNames.join(', ')}); ` +
|
|
71
|
+
`a param.text declaration derives it`);
|
|
72
|
+
}
|
|
73
|
+
const cellIndexes = new Int32Array(celledInputs.map((input) => input.index));
|
|
74
|
+
const cellColumnByIndex = new Map();
|
|
75
|
+
celledInputs.forEach((input, column) => cellColumnByIndex.set(input.index, column));
|
|
76
|
+
const tupleWidthByIndex = new Map();
|
|
77
|
+
const maxCellsByIndex = new Map();
|
|
78
|
+
// The inputs that read an oversize block as an empty one (C1.2b `missing: "empty"`).
|
|
79
|
+
const emptyWhenOversize = new Set();
|
|
80
|
+
const tupleWidths = celledInputs.length > 0 ? wrunCellTupleWidths() : {};
|
|
81
|
+
for (const input of celledInputs) {
|
|
82
|
+
const source = metadata.inputSources[input.name];
|
|
83
|
+
const sourceClass = source?.source ?? '';
|
|
84
|
+
tupleWidthByIndex.set(input.index, Object.hasOwn(tupleWidths, sourceClass) ? (tupleWidths[sourceClass] ?? 1) : 1);
|
|
85
|
+
maxCellsByIndex.set(input.index, input.max_cells ?? Number.POSITIVE_INFINITY);
|
|
86
|
+
if (source?.missing === 'empty')
|
|
87
|
+
emptyWhenOversize.add(input.index);
|
|
88
|
+
}
|
|
89
|
+
let stride = 1;
|
|
90
|
+
for (const row of rows)
|
|
91
|
+
stride = Math.max(stride, row.values.length);
|
|
92
|
+
const ts = new Float64Array(rowCount);
|
|
93
|
+
const argCounts = new Int32Array(rowCount);
|
|
94
|
+
const values = new Float64Array(rowCount * stride).fill(Number.NaN);
|
|
95
|
+
const cellLens = new Int32Array(rowCount * celledInputs.length).fill(-1);
|
|
96
|
+
const cellOffsets = new Int32Array(rowCount * celledInputs.length);
|
|
97
|
+
let totalCells = 0;
|
|
98
|
+
rows.forEach((row, rowIdx) => {
|
|
99
|
+
ts[rowIdx] = row.ts;
|
|
100
|
+
argCounts[rowIdx] = row.values.length;
|
|
101
|
+
for (let idx = 0; idx < row.values.length; idx += 1) {
|
|
102
|
+
values[rowIdx * stride + idx] = row.values[idx];
|
|
103
|
+
}
|
|
104
|
+
if (!row.cellBlocks)
|
|
105
|
+
return;
|
|
106
|
+
for (const [inputIndex, block] of row.cellBlocks) {
|
|
107
|
+
const column = cellColumnByIndex.get(inputIndex);
|
|
108
|
+
if (column === undefined) {
|
|
109
|
+
throw new Error(`WRUN ${metadata.id}: row at ts ${row.ts} carries a cell block for input ${inputIndex}, ` +
|
|
110
|
+
`which is not declared cellType "array" in metadata`);
|
|
111
|
+
}
|
|
112
|
+
const tupleWidth = tupleWidthByIndex.get(inputIndex) ?? 1;
|
|
113
|
+
const maxCells = maxCellsByIndex.get(inputIndex) ?? Number.POSITIVE_INFINITY;
|
|
114
|
+
if (block.length % tupleWidth !== 0) {
|
|
115
|
+
throw new Error(`WRUN ${metadata.id}: cell block for input ${inputIndex} at ts ${row.ts} has ` +
|
|
116
|
+
`${block.length} f64 cells, which does not divide into ${tupleWidth}-cell tuples`);
|
|
117
|
+
}
|
|
118
|
+
const tuples = block.length / tupleWidth;
|
|
119
|
+
if (tuples > maxCells && emptyWhenOversize.has(inputIndex)) {
|
|
120
|
+
// C1.2b: this bar reads a present empty block; every other bar keeps its own.
|
|
121
|
+
cellLens[rowIdx * celledInputs.length + column] = 0;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (tuples > maxCells) {
|
|
125
|
+
throw new Error(`WRUN ${metadata.id}: ${WRUN_CELL_BLOCK_TOO_LARGE_CODE}: input ${inputIndex} bar at ts ${row.ts} has ` +
|
|
126
|
+
`${tuples} cells; max_cells is ${maxCells}, so the evaluation is refused (a block is never truncated)`);
|
|
127
|
+
}
|
|
128
|
+
cellLens[rowIdx * celledInputs.length + column] = block.length;
|
|
129
|
+
totalCells += block.length;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
const cells = new Float64Array(totalCells);
|
|
133
|
+
let cellCursor = 0;
|
|
134
|
+
rows.forEach((row, rowIdx) => {
|
|
135
|
+
if (!row.cellBlocks)
|
|
136
|
+
return;
|
|
137
|
+
for (const [inputIndex, block] of row.cellBlocks) {
|
|
138
|
+
const column = cellColumnByIndex.get(inputIndex);
|
|
139
|
+
if (column === undefined)
|
|
140
|
+
continue;
|
|
141
|
+
const at = rowIdx * celledInputs.length + column;
|
|
142
|
+
cellOffsets[at] = cellCursor;
|
|
143
|
+
// A block packed empty (C1.2b) copies nothing; every other block copies whole.
|
|
144
|
+
if (cellLens[at] === 0)
|
|
145
|
+
continue;
|
|
146
|
+
cells.set(block, cellCursor);
|
|
147
|
+
cellCursor += block.length;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const stringSlots = validateStringSlots(metadata, abi);
|
|
151
|
+
// Contiguity is validated above, so writing at slot.index into an array
|
|
152
|
+
// sized by slot count is exact: the ABI host reads stringMaxBytes[slot]
|
|
153
|
+
// positionally and derives the declared slot count from its length.
|
|
154
|
+
const stringMaxBytes = stringSlots.length > 0 ? new Int32Array(stringSlots.length) : undefined;
|
|
155
|
+
if (stringMaxBytes) {
|
|
156
|
+
for (const slot of stringSlots)
|
|
157
|
+
stringMaxBytes[slot.index] = slot.max_bytes;
|
|
158
|
+
}
|
|
159
|
+
const frameMaxBytes = packWrunFrameSlots(metadata, abi);
|
|
160
|
+
const request = {
|
|
161
|
+
abi,
|
|
162
|
+
outputCount,
|
|
163
|
+
rowCount,
|
|
164
|
+
stride,
|
|
165
|
+
initArgs: [...initArgs],
|
|
166
|
+
ts,
|
|
167
|
+
argCounts,
|
|
168
|
+
values,
|
|
169
|
+
cellIndexes,
|
|
170
|
+
cellLens,
|
|
171
|
+
cellOffsets,
|
|
172
|
+
cells,
|
|
173
|
+
...(stringMaxBytes ? { stringMaxBytes } : {}),
|
|
174
|
+
...(frameMaxBytes ? { frameMaxBytes } : {}),
|
|
175
|
+
...(textParams !== undefined && textParamNames.length > 0 ? { textParams } : {}),
|
|
176
|
+
};
|
|
177
|
+
const transfer = [
|
|
178
|
+
ts.buffer,
|
|
179
|
+
argCounts.buffer,
|
|
180
|
+
values.buffer,
|
|
181
|
+
cellIndexes.buffer,
|
|
182
|
+
cellLens.buffer,
|
|
183
|
+
cellOffsets.buffer,
|
|
184
|
+
cells.buffer,
|
|
185
|
+
...(stringMaxBytes ? [stringMaxBytes.buffer] : []),
|
|
186
|
+
...(frameMaxBytes ? [frameMaxBytes.buffer] : []),
|
|
187
|
+
];
|
|
188
|
+
return { request, transfer };
|
|
189
|
+
}
|
|
190
|
+
// String-slot declaration caps, mirroring the om reference runtime's
|
|
191
|
+
// validateStringSlotSpecs (runtime.ts) and the metadata schema.
|
|
192
|
+
const MAX_STRING_SLOTS = 64;
|
|
193
|
+
const MAX_STRING_SLOT_BYTES = 4096;
|
|
194
|
+
/** Validate `metadata.string_slots` before packing, mirroring the om
|
|
195
|
+
* reference runtime: wrun-2 or later, at most 64 slots, indices contiguous from
|
|
196
|
+
* 0 (unique by construction), each max_bytes an integer 1..4096. Refusing
|
|
197
|
+
* non-contiguous indices here is what makes the positional
|
|
198
|
+
* `stringMaxBytes[slot.index]` write below exact; a silent out-of-range
|
|
199
|
+
* write would hand the ABI host caps of 0 for the unwritten positions. */
|
|
200
|
+
function validateStringSlots(metadata, abi) {
|
|
201
|
+
const stringSlots = metadata.string_slots ?? [];
|
|
202
|
+
if (stringSlots.length === 0)
|
|
203
|
+
return stringSlots;
|
|
204
|
+
if (!abiAtLeast(abi, 'wrun-2')) {
|
|
205
|
+
throw new Error(`WRUN ${metadata.id}: string_slots declared under ${abi}: the string channel needs wrun-2 or later ` +
|
|
206
|
+
`(declare metadata abi_version "wrun-2"; wrun-1 is frozen)`);
|
|
207
|
+
}
|
|
208
|
+
if (stringSlots.length > MAX_STRING_SLOTS) {
|
|
209
|
+
throw new Error(`WRUN ${metadata.id}: declares ${stringSlots.length} string slots; the cap is ${MAX_STRING_SLOTS}`);
|
|
210
|
+
}
|
|
211
|
+
const byIndex = [...stringSlots].sort((a, b) => a.index - b.index);
|
|
212
|
+
byIndex.forEach((slot, at) => {
|
|
213
|
+
if (slot.index !== at) {
|
|
214
|
+
throw new Error(`WRUN ${metadata.id}: string slots must be contiguous from 0 ` +
|
|
215
|
+
`(position ${at} is declared as slot ${slot.index})`);
|
|
216
|
+
}
|
|
217
|
+
if (!Number.isInteger(slot.max_bytes) || slot.max_bytes < 1 || slot.max_bytes > MAX_STRING_SLOT_BYTES) {
|
|
218
|
+
throw new Error(`WRUN ${metadata.id}: string slot ${slot.index} max_bytes ${slot.max_bytes} must be an ` +
|
|
219
|
+
`integer from 1 to ${MAX_STRING_SLOT_BYTES}`);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
return stringSlots;
|
|
223
|
+
}
|
|
224
|
+
function packWrunFrameSlots(metadata, abi) {
|
|
225
|
+
const frames = metadata.frames;
|
|
226
|
+
if (frames === undefined)
|
|
227
|
+
return undefined;
|
|
228
|
+
if (!abiAtLeast(abi, 'wrun-4')) {
|
|
229
|
+
throw new Error(`WRUN ${metadata.id}: frames require abi_version "wrun-4"`);
|
|
230
|
+
}
|
|
231
|
+
if (!Array.isArray(frames) || frames.length > WRUN_FRAME_MAX_SLOTS) {
|
|
232
|
+
throw new Error(`WRUN ${metadata.id}: frames must declare at most ${WRUN_FRAME_MAX_SLOTS} slots`);
|
|
233
|
+
}
|
|
234
|
+
const names = new Set();
|
|
235
|
+
const caps = frames.map((frame, slot) => {
|
|
236
|
+
if (!frame || typeof frame.name !== 'string' || frame.name.length === 0 || names.has(frame.name)) {
|
|
237
|
+
throw new Error(`WRUN ${metadata.id}: frame slot ${slot} needs a unique nonempty name`);
|
|
238
|
+
}
|
|
239
|
+
names.add(frame.name);
|
|
240
|
+
const cap = frame.max_bytes ?? WRUN_FRAME_DEFAULT_MAX_BYTES;
|
|
241
|
+
if (!Number.isInteger(cap) || cap < 1 || cap > 0x7fffffff) {
|
|
242
|
+
throw new Error(`WRUN ${metadata.id}: frame slot ${slot} max_bytes must be a positive i32 byte count`);
|
|
243
|
+
}
|
|
244
|
+
return cap;
|
|
245
|
+
});
|
|
246
|
+
return new Int32Array(caps);
|
|
247
|
+
}
|
|
248
|
+
const framesByRows = new WeakMap();
|
|
249
|
+
/** Frames belong to the run, keeping each transported row byte-compatible. */
|
|
250
|
+
export function attachWrunFrames(rows, frames) {
|
|
251
|
+
framesByRows.set(rows, frames);
|
|
252
|
+
}
|
|
253
|
+
export function wrunFramesOf(rows) {
|
|
254
|
+
return framesByRows.get(rows);
|
|
255
|
+
}
|
|
256
|
+
const UTF8_DECODER = new TextDecoder('utf-8');
|
|
257
|
+
/** Unpack a successful worker response against the request's row axis.
|
|
258
|
+
* Non-ready rows carry `outputs: null` and no strings key; on ready rows a
|
|
259
|
+
* string slot decodes to undefined when ABSENT (-1) and '' when present
|
|
260
|
+
* empty, preserving the ABI distinction. */
|
|
261
|
+
export function unpackWrunResponse(response, ts, outputCount, stringSlotCount) {
|
|
262
|
+
const rowCount = response.ready.length;
|
|
263
|
+
const rows = new Array(rowCount);
|
|
264
|
+
for (let row = 0; row < rowCount; row += 1) {
|
|
265
|
+
if (response.ready[row] !== 1) {
|
|
266
|
+
rows[row] = { ts: ts[row], outputs: null };
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const outputs = new Array(outputCount);
|
|
270
|
+
for (let idx = 0; idx < outputCount; idx += 1) {
|
|
271
|
+
outputs[idx] = response.outputs[row * outputCount + idx];
|
|
272
|
+
}
|
|
273
|
+
const unpacked = { ts: ts[row], outputs };
|
|
274
|
+
if (stringSlotCount > 0 &&
|
|
275
|
+
response.stringLens !== undefined &&
|
|
276
|
+
response.stringOffsets !== undefined &&
|
|
277
|
+
response.stringBytes !== undefined) {
|
|
278
|
+
const strings = new Array(stringSlotCount);
|
|
279
|
+
for (let slot = 0; slot < stringSlotCount; slot += 1) {
|
|
280
|
+
const at = row * stringSlotCount + slot;
|
|
281
|
+
const len = response.stringLens[at];
|
|
282
|
+
if (len < 0) {
|
|
283
|
+
strings[slot] = undefined;
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
// The no-disguises rule at the decode (guard G2): every reader of a slot
|
|
287
|
+
// (labels, text marks, tables, HUD tiles, the debug lane) inherits it;
|
|
288
|
+
// newlines survive, the bidi controls, zero-width and control characters do not.
|
|
289
|
+
strings[slot] =
|
|
290
|
+
len === 0
|
|
291
|
+
? ''
|
|
292
|
+
: wrunPlainText(UTF8_DECODER.decode(response.stringBytes.subarray(response.stringOffsets[at], response.stringOffsets[at] + len)), { multiline: true });
|
|
293
|
+
}
|
|
294
|
+
unpacked.strings = strings;
|
|
295
|
+
}
|
|
296
|
+
rows[row] = unpacked;
|
|
297
|
+
}
|
|
298
|
+
if (response.frames !== undefined)
|
|
299
|
+
attachWrunFrames(rows, response.frames);
|
|
300
|
+
return rows;
|
|
301
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Number formatting for browser-run Indicator (wrun) overlays: the axis
|
|
3
|
+
* ticks of a wrun lower pane and the legend values of a wrun overlay.
|
|
4
|
+
*
|
|
5
|
+
* The native path this rides (lane fix round 2, R6): a volume-based
|
|
6
|
+
* technical script installs a meta-level `getYLabel` of
|
|
7
|
+
* `partiallyFormatNumbers(price, digits, undefined, true)` (the app's
|
|
8
|
+
* K/M/B formatter from 1K, chart.add-indicator.ts), which titan's axis
|
|
9
|
+
* consults before its own digit default; every other technical script
|
|
10
|
+
* falls through to the chart-level formatter, which prints the MAIN pane's
|
|
11
|
+
* precision as a raw float ("60000000.00" for USD liquidations,
|
|
12
|
+
* "-1730005" for CVD). A wrun lower pane gets the same meta-level hook: a
|
|
13
|
+
* magnitude from 1K reads through the app's K/M/B formatter, a smaller one
|
|
14
|
+
* at the pane's OWN step precision (titan's digits for that scale, what the
|
|
15
|
+
* engine would print by itself). The main price axis is never touched.
|
|
16
|
+
*
|
|
17
|
+
* Legend values: an on-price wrun output is a price, so it prints at the
|
|
18
|
+
* chart's price precision (the main legend's own formatter, 0.1412 on a
|
|
19
|
+
* sub-dollar symbol instead of "0.14"); a lower-pane value prints K/M/B from
|
|
20
|
+
* 1K like its axis and, below that, the built-in legend rule
|
|
21
|
+
* (formatTechnicalScriptLegendValue), byte for byte the kScript original's.
|
|
22
|
+
* Never the axis digits: titan derives them from the tick step, which grows
|
|
23
|
+
* as the pane gets shorter, so the same value read "59" on a 60 px pane and
|
|
24
|
+
* "59.36" on a tall one (QA 204), and "0" for 0.43 (TEMPLATE-QA B15 C38).
|
|
25
|
+
* An output's `unit` prints after the value even when it declares no
|
|
26
|
+
* `format` (the suffix units wrun-output-style stamps). No surface prints a
|
|
27
|
+
* negative zero: a value that rounds to zero at the printed decimals carries
|
|
28
|
+
* no sign ("0.00", never "-0" or "-0.00%").
|
|
29
|
+
*
|
|
30
|
+
* Declared formats (WRUN-INPUTS-PLAN 1.3, the output `format` key and the
|
|
31
|
+
* `{{name:format}}` placeholder): one frozen word list, one formatter
|
|
32
|
+
* (`formatWrunValue`), shared by the legend, the hover card, the HUD tiles
|
|
33
|
+
* and every template placeholder, so a value reads the same on every
|
|
34
|
+
* surface. A declared word overrides the placement rule above.
|
|
35
|
+
*
|
|
36
|
+
* WRUN-STYLE (OT19 OT32, DW23, X1 X2): the word list grows `usd` and `auto`
|
|
37
|
+
* and every word takes the companions `decimals`, `signed` and `unit`. The
|
|
38
|
+
* eight legacy words without a companion keep today's text byte for byte;
|
|
39
|
+
* `usd`, `auto` and any companion print through the shared
|
|
40
|
+
* `formatWrunNumber` (wrun-style-words.util, the kit's twin). A declared
|
|
41
|
+
* pane's axis (`define.paneAxis`) prints its ticks the same way.
|
|
42
|
+
*
|
|
43
|
+
* Proven twins (`builtinTwinOf`, wrun-builtin-twin.util): a twin stands in
|
|
44
|
+
* for a shipped built-in at parity (look, maths, labels), so it prints
|
|
45
|
+
* exactly like that built-in instead of by the rules above. Its values take
|
|
46
|
+
* the built-in legend rule (formatTechnicalScriptLegendValue: at least 2
|
|
47
|
+
* decimals, two significant digits below 1, the chart's price digits for a
|
|
48
|
+
* price-pane line of a built-in that is not volume-scaled), ahead of any
|
|
49
|
+
* declared word, K/M/B from 1M like the built-in (an OBV twin reads
|
|
50
|
+
* "457500.00", never the pane's "458K"), and its pane keeps the built-in's
|
|
51
|
+
* own axis label (wrunBuiltinTwinYLabel).
|
|
52
|
+
*/
|
|
53
|
+
import { WRUN_VALUE_FORMATS, type WrunValueFormat } from './wrun-style-words.util.js';
|
|
54
|
+
/** The frozen format words an output, a block, a pane axis or a
|
|
55
|
+
* `{{name:format}}` placeholder may declare: the foundation's list (the
|
|
56
|
+
* eight legacy words plus `usd` and `auto`), re-exported. */
|
|
57
|
+
export { WRUN_VALUE_FORMATS, type WrunValueFormat };
|
|
58
|
+
/** The format companions a surface declares beside `format` (conventions
|
|
59
|
+
* 8): `decimals` (0..8) overrides the word's digits, `signed` forces a +
|
|
60
|
+
* on positives, `unit` prints after the value. */
|
|
61
|
+
export interface WrunValueFormatOptions {
|
|
62
|
+
decimals?: number;
|
|
63
|
+
signed?: boolean;
|
|
64
|
+
unit?: string;
|
|
65
|
+
}
|
|
66
|
+
/** The magnitude from which a wrun lower pane reads K/M/B: the app's own
|
|
67
|
+
* volume-axis threshold (`partiallyFormatNumbers(..., isRoundFromThousand)`). */
|
|
68
|
+
export declare const WRUN_PANE_COMPACT_FROM = 1000;
|
|
69
|
+
/** Decimals a wrun pane prints when its own scale is not known yet (titan's
|
|
70
|
+
* default digit count for a fresh scale, and the natives' `digits`). */
|
|
71
|
+
export declare const WRUN_PANE_DEFAULT_DIGITS = 2;
|
|
72
|
+
/** The slice of a titan chart the pane formatter reads: each price scale
|
|
73
|
+
* controller's id (the overlay it scales) and the digits its ladder wants,
|
|
74
|
+
* and the mounted metas (a declared pane's axis format rides the applied
|
|
75
|
+
* run result's `define.paneAxis`, OT19). */
|
|
76
|
+
export interface WrunPaneFormatChart {
|
|
77
|
+
priceScaleControllers?: ReadonlyArray<{
|
|
78
|
+
id?: unknown;
|
|
79
|
+
digits?: unknown;
|
|
80
|
+
}>;
|
|
81
|
+
metadata?: ReadonlyArray<{
|
|
82
|
+
id?: unknown;
|
|
83
|
+
runResult?: unknown;
|
|
84
|
+
}>;
|
|
85
|
+
}
|
|
86
|
+
/** A declared pane's axis number format (OT19): `format` plus the
|
|
87
|
+
* companions, as the run result's `define.paneAxis` carries it. */
|
|
88
|
+
export interface WrunPaneAxisFormat extends WrunValueFormatOptions {
|
|
89
|
+
format: string;
|
|
90
|
+
}
|
|
91
|
+
/** A lower-pane number: K/M/B from 1K through the app's formatter (the
|
|
92
|
+
* volume-based technical scripts' own axis path), else `digits` decimals
|
|
93
|
+
* (a value rounding to zero prints unsigned). */
|
|
94
|
+
export declare function formatWrunPaneNumber(value: number, digits: number): string;
|
|
95
|
+
/** The pane's own step precision: titan's `digits` on the price scale that
|
|
96
|
+
* scales `overlayId`, the default when the scale is not built yet. */
|
|
97
|
+
export declare function wrunPaneDigits(chart: WrunPaneFormatChart | null | undefined, overlayId: string): number;
|
|
98
|
+
/** The axis format a mounted wrun pane declares (OT19): the `paneAxis` of
|
|
99
|
+
* the run result applied to the overlay `overlayId` (`meta.runResult.define
|
|
100
|
+
* .paneAxis`, stamped by the adapter from a declared `pane(name, {
|
|
101
|
+
* format, ... })`); undefined when the pane declares none or the overlay
|
|
102
|
+
* is not mounted yet. Read per call: a rerun that drops the words drops
|
|
103
|
+
* the format with the next tick. */
|
|
104
|
+
export declare function wrunPaneAxisOf(chart: WrunPaneFormatChart | null | undefined, overlayId: string): WrunPaneAxisFormat | undefined;
|
|
105
|
+
/** The meta-level `getYLabel` a wrun lower pane installs (the parent of an
|
|
106
|
+
* offchart package, the series child of an on-price one). The chart is
|
|
107
|
+
* resolved per call: the hook outlives chart rebuilds and the scale is
|
|
108
|
+
* built after the overlay is added. A pane that declares an axis format
|
|
109
|
+
* (OT19, `define.paneAxis`) prints its ticks through `formatWrunValue`
|
|
110
|
+
* with the declared companions, "price" at the pane's own step digits;
|
|
111
|
+
* without one, today's rule (K/M/B from 1K, the step digits below). */
|
|
112
|
+
export declare function wrunPaneYLabel(chart: () => WrunPaneFormatChart | null | undefined, overlayId: string): (price: number) => string;
|
|
113
|
+
/** The built-in a proven twin stands in for, as the formatters read it. */
|
|
114
|
+
export interface WrunBuiltinTwin {
|
|
115
|
+
/** The built-in is volume-scaled (VOLUME_BASED_INDICATORS): its lines
|
|
116
|
+
* never take the chart's price digits and its pane keeps its K/M/B axis
|
|
117
|
+
* label. */
|
|
118
|
+
volumeBased: boolean;
|
|
119
|
+
}
|
|
120
|
+
/** The built-in an overlay's settings stand in for (its `builtinTwinOf`
|
|
121
|
+
* stamp beside a registry identity), or undefined: not a template's twin. */
|
|
122
|
+
export declare function wrunBuiltinTwin(settings: unknown): WrunBuiltinTwin | undefined;
|
|
123
|
+
/** The meta-level `getYLabel` a proven twin's pane installs: the one its
|
|
124
|
+
* built-in keeps (chart.add-indicator). A volume-based built-in keeps its
|
|
125
|
+
* template's digits label (K/M/B from 1K); every other built-in deletes it
|
|
126
|
+
* so titan's own formatting applies (ticks by step, pills with decimals),
|
|
127
|
+
* and the twin installs none (undefined). */
|
|
128
|
+
export declare function wrunBuiltinTwinYLabel(twin: WrunBuiltinTwin): ((price: number) => string) | undefined;
|
|
129
|
+
export declare function isWrunValueFormat(value: unknown): value is WrunValueFormat;
|
|
130
|
+
/** A companion that changes the text: `decimals`, `signed` or a non-empty `unit`. */
|
|
131
|
+
export declare function hasWrunValueFormatOptions(options: WrunValueFormatOptions | undefined): boolean;
|
|
132
|
+
/** One value through one declared format word: `price` at the chart's price
|
|
133
|
+
* precision (`priceDigits`, the default decimals when the caller has no
|
|
134
|
+
* chart), `%` as a percent with two decimals (the value already IS a
|
|
135
|
+
* percent), `si` as K/M/B from 1K (the lower-pane axis rule), `int` and
|
|
136
|
+
* the fixed-point words at their decimals. No word: the app's own
|
|
137
|
+
* partial formatter (two decimals, K/M/B from 1M). A hole reads '-'.
|
|
138
|
+
* `usd`, `auto` and any word beside a companion (`decimals`, `signed`,
|
|
139
|
+
* `unit`) print through the shared `formatWrunNumber` (OT32, DW23: "$1.2M",
|
|
140
|
+
* "65,432.1", "+5.0x"); a companion without a word prints the "auto" rule.
|
|
141
|
+
* A value rounding to zero prints unsigned ("0", never "-0"). */
|
|
142
|
+
export declare function formatWrunValue(value: number, format?: string, placement?: {
|
|
143
|
+
priceDigits?: number;
|
|
144
|
+
}, options?: WrunValueFormatOptions): string;
|
|
145
|
+
/** A signed value (a delta): the formatted magnitude behind an explicit
|
|
146
|
+
* sign, `+0.00` for zero (a negative value rounding to zero included); a
|
|
147
|
+
* hole reads '-'. The companions print the magnitude (`signed` is this
|
|
148
|
+
* function's own sign). */
|
|
149
|
+
export declare function formatWrunSignedValue(value: number, format?: string, placement?: {
|
|
150
|
+
priceDigits?: number;
|
|
151
|
+
}, options?: WrunValueFormatOptions): string;
|
|
152
|
+
/** A wrun legend value: the output's declared format word when it carries
|
|
153
|
+
* one (`price` at the chart's precision), else a price at the chart's
|
|
154
|
+
* price precision on the price pane, the lower-pane legend rule otherwise
|
|
155
|
+
* (formatWrunPaneLegendNumber); a hole reads '-'. A proven twin
|
|
156
|
+
* (`builtinTwin`) prints by its built-in's legend rule instead, ahead of
|
|
157
|
+
* any declared word (the built-in has none).
|
|
158
|
+
* `projectPrice` is how a price prints while the pane's labels are
|
|
159
|
+
* projected (a memecoin pane reading in market cap, pulse-value-mode.util):
|
|
160
|
+
* it takes over exactly where the value is a price on the price pane (a
|
|
161
|
+
* twin's price line, a `price` word, the undeclared price-pane default), so
|
|
162
|
+
* the lower pane, a volume-scaled twin and every other declared word keep
|
|
163
|
+
* their rule. `options` are the output's declared companions (OT32,
|
|
164
|
+
* `formatOptions` on the mounted output): `decimals` or `signed` print the
|
|
165
|
+
* value through the shared formatter even without a word. A `unit` alone
|
|
166
|
+
* (an output's unit declared without a `format`, B15) keeps the placement's
|
|
167
|
+
* digits (the built-in legend decimals on a lower pane), grouped instead of
|
|
168
|
+
* K/M/B (a magnitude letter would land between the number and the unit),
|
|
169
|
+
* the unit after: "1.07%", "1,250.00M". Never a negative zero. */
|
|
170
|
+
export declare function formatWrunLegendValue(value: number, placement: {
|
|
171
|
+
onPrice: boolean;
|
|
172
|
+
priceDigits: number;
|
|
173
|
+
/** The instrument tick a price on the price pane rounds to (the engine's main-scale tick,
|
|
174
|
+
* CME today), so the legend reads the number the line's axis pill prints; null or absent
|
|
175
|
+
* prints the value as it is. Only where the value IS a price on the price pane (a twin's
|
|
176
|
+
* price line, a `price` word, the undeclared price-pane default), never a projected one. */
|
|
177
|
+
priceTick?: number | null;
|
|
178
|
+
builtinTwin?: WrunBuiltinTwin;
|
|
179
|
+
projectPrice?: (price: number) => string;
|
|
180
|
+
}, format?: string, options?: WrunValueFormatOptions): string;
|