@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,439 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app half of the wrun styling vocabulary (WRUN-STYLE freeze, section
|
|
3
|
+
* 2.3): the colour words and theme tokens every colour key accepts and their
|
|
4
|
+
* paint-time resolution against the chart's theme, the font words with their
|
|
5
|
+
* CSS stacks, the one number formatter every surface prints a declared number
|
|
6
|
+
* with (the freeze's 2.2 text, pinned by
|
|
7
|
+
* tests/fixtures/wrun/wrun-value-format-corpus.json, byte-identical to the om
|
|
8
|
+
* corpus), and the theme-token packing every host restates (the draw ABI
|
|
9
|
+
* sentinel, the wire text, the packed f64 form).
|
|
10
|
+
*
|
|
11
|
+
* Imports nothing (no vue, no DOM, no titan, no kit): main-thread and worker
|
|
12
|
+
* safe. The om twin is packages/sdk/src/wrun-style-words.ts and
|
|
13
|
+
* wrun-value-format.ts; the two sides must agree on every word and byte.
|
|
14
|
+
*
|
|
15
|
+
* Theme tokens ride sheets, wire props and run outputs unresolved; they
|
|
16
|
+
* resolve at the mount doors with `resolveWrunColorWord(word,
|
|
17
|
+
* wrunColorThemeOf(tc))` and re-resolve on a theme switch without a rerun
|
|
18
|
+
* (`onWrunThemeChange`).
|
|
19
|
+
*/
|
|
20
|
+
// Colour words
|
|
21
|
+
/** The seven theme colour tokens a colour key may name as `theme.<token>`.
|
|
22
|
+
* Token k of the packed forms below is `index + 1` in this order. */
|
|
23
|
+
export const WRUN_THEME_COLOR_TOKENS = ['up', 'down', 'text', 'muted', 'bg', 'grid', 'accent'];
|
|
24
|
+
const WRUN_THEME_TOKEN_PREFIX = 'theme.';
|
|
25
|
+
/** The sheet colour word: `#rrggbb` or `#rrggbbaa` (alpha in the last byte). */
|
|
26
|
+
const WRUN_HEX_COLOR_WORD_RE = /^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/;
|
|
27
|
+
/** `theme.<token>` (a sheet word) or `theme.<token>/aa` (the wire form). */
|
|
28
|
+
const WRUN_THEME_TOKEN_RE = /^theme\.([a-z]+)(?:\/([0-9a-fA-F]{2}))?$/;
|
|
29
|
+
function wrunTokenOf(name) {
|
|
30
|
+
return WRUN_THEME_COLOR_TOKENS.includes(name) ? name : undefined;
|
|
31
|
+
}
|
|
32
|
+
function wrunTokenK(token) {
|
|
33
|
+
return WRUN_THEME_COLOR_TOKENS.indexOf(token) + 1;
|
|
34
|
+
}
|
|
35
|
+
function wrunTokenAlpha(alpha) {
|
|
36
|
+
return Number.isFinite(alpha) ? Math.min(1, Math.max(0, alpha)) : 1;
|
|
37
|
+
}
|
|
38
|
+
/** True for the convention-2 colour word: `#rrggbb`, `#rrggbbaa` or one of
|
|
39
|
+
* the seven tokens spelled exactly (`theme.up`); the `/aa` wire form, any
|
|
40
|
+
* other `theme.` word and every non-string are not colour words. */
|
|
41
|
+
export function isWrunColorWord(value) {
|
|
42
|
+
if (typeof value !== 'string')
|
|
43
|
+
return false;
|
|
44
|
+
if (WRUN_HEX_COLOR_WORD_RE.test(value))
|
|
45
|
+
return true;
|
|
46
|
+
return (value.startsWith(WRUN_THEME_TOKEN_PREFIX) && wrunTokenOf(value.slice(WRUN_THEME_TOKEN_PREFIX.length)) !== undefined);
|
|
47
|
+
}
|
|
48
|
+
/** The token a string names: `theme.<t>` (alpha 1) or the wire's
|
|
49
|
+
* `theme.<t>/aa` (alpha = the byte / 255); null for anything else. */
|
|
50
|
+
export function parseWrunThemeToken(value) {
|
|
51
|
+
if (typeof value !== 'string')
|
|
52
|
+
return null;
|
|
53
|
+
const match = WRUN_THEME_TOKEN_RE.exec(value);
|
|
54
|
+
if (!match)
|
|
55
|
+
return null;
|
|
56
|
+
const token = wrunTokenOf(match[1]);
|
|
57
|
+
if (token === undefined)
|
|
58
|
+
return null;
|
|
59
|
+
return { token, alpha: match[2] === undefined ? 1 : parseInt(match[2], 16) / 255 };
|
|
60
|
+
}
|
|
61
|
+
/** The wire word of a token: `theme.<t>` when its alpha byte is 255, else
|
|
62
|
+
* `theme.<t>/aa` (two lowercase hex digits). Alpha is clamped to 0..1; a
|
|
63
|
+
* non-finite alpha reads as 1. */
|
|
64
|
+
export function wrunThemeTokenWord(ref) {
|
|
65
|
+
const byte = Math.round(wrunTokenAlpha(ref.alpha) * 255);
|
|
66
|
+
const word = `${WRUN_THEME_TOKEN_PREFIX}${ref.token}`;
|
|
67
|
+
return byte === 255 ? word : `${word}/${byte.toString(16).padStart(2, '0')}`;
|
|
68
|
+
}
|
|
69
|
+
/** REPLACES a token's alpha with `alpha` (the `withOpacity` rule, the
|
|
70
|
+
* kScript opacity() convention): `theme.up/80` at 0.2 is `theme.up/33`.
|
|
71
|
+
* Alpha is clamped to 0..1. A non-token string and a non-finite alpha come
|
|
72
|
+
* back unchanged. */
|
|
73
|
+
export function wrunThemeTokenWithAlpha(value, alpha) {
|
|
74
|
+
const ref = parseWrunThemeToken(value);
|
|
75
|
+
if (ref === null || typeof alpha !== 'number' || !Number.isFinite(alpha))
|
|
76
|
+
return value;
|
|
77
|
+
return wrunThemeTokenWord({ token: ref.token, alpha });
|
|
78
|
+
}
|
|
79
|
+
/** MULTIPLIES a token's alpha by `factor` (the `multiplyWrunOpacity` rule,
|
|
80
|
+
* conventions 3): `theme.up` at 0.5 is `theme.up/80`, `theme.up/80` at 0.5
|
|
81
|
+
* is `theme.up/40`. The product is clamped to 0..1. A non-token string and
|
|
82
|
+
* a non-finite factor come back unchanged. */
|
|
83
|
+
export function wrunThemeTokenScaleAlpha(value, factor) {
|
|
84
|
+
const ref = parseWrunThemeToken(value);
|
|
85
|
+
if (ref === null || typeof factor !== 'number' || !Number.isFinite(factor))
|
|
86
|
+
return value;
|
|
87
|
+
return wrunThemeTokenWord({ token: ref.token, alpha: ref.alpha * factor });
|
|
88
|
+
}
|
|
89
|
+
/** The dark-chart defaults a bare chart (no theme, no recorded accent)
|
|
90
|
+
* answers with. */
|
|
91
|
+
const WRUN_THEME_FALLBACK = {
|
|
92
|
+
up: '#26a69a',
|
|
93
|
+
down: '#ef5350',
|
|
94
|
+
text: '#d1d4dc',
|
|
95
|
+
bg: '#131722',
|
|
96
|
+
grid: '#2a2e39',
|
|
97
|
+
accent: '#ff4608',
|
|
98
|
+
};
|
|
99
|
+
/** `muted` is the text colour at this fraction of its own alpha (X8). */
|
|
100
|
+
const WRUN_MUTED_ALPHA = 0.55;
|
|
101
|
+
function wrunChannel(text) {
|
|
102
|
+
const value = Number(text);
|
|
103
|
+
return Number.isFinite(value) && value >= 0 && value <= 255 ? Math.round(value) : undefined;
|
|
104
|
+
}
|
|
105
|
+
/** A palette colour parsed: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`,
|
|
106
|
+
* `rgb(r, g, b)` or `rgba(r, g, b, a)` (the forms the chart theme writes).
|
|
107
|
+
* Anything else is no colour. */
|
|
108
|
+
function parseWrunCssColor(value) {
|
|
109
|
+
if (typeof value !== 'string')
|
|
110
|
+
return undefined;
|
|
111
|
+
const text = value.trim().toLowerCase();
|
|
112
|
+
const hex = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(text);
|
|
113
|
+
if (hex) {
|
|
114
|
+
let digits = hex[1];
|
|
115
|
+
if (digits.length <= 4)
|
|
116
|
+
digits = [...digits].map((digit) => digit + digit).join('');
|
|
117
|
+
return {
|
|
118
|
+
r: parseInt(digits.slice(0, 2), 16),
|
|
119
|
+
g: parseInt(digits.slice(2, 4), 16),
|
|
120
|
+
b: parseInt(digits.slice(4, 6), 16),
|
|
121
|
+
a: digits.length === 8 ? parseInt(digits.slice(6, 8), 16) / 255 : 1,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const rgb = /^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/.exec(text);
|
|
125
|
+
if (!rgb)
|
|
126
|
+
return undefined;
|
|
127
|
+
const r = wrunChannel(rgb[1]);
|
|
128
|
+
const g = wrunChannel(rgb[2]);
|
|
129
|
+
const b = wrunChannel(rgb[3]);
|
|
130
|
+
const a = rgb[4] === undefined ? 1 : Number(rgb[4]);
|
|
131
|
+
if (r === undefined || g === undefined || b === undefined || !(a >= 0 && a <= 1))
|
|
132
|
+
return undefined;
|
|
133
|
+
return { r, g, b, a };
|
|
134
|
+
}
|
|
135
|
+
function wrunByteHex(value) {
|
|
136
|
+
return value.toString(16).padStart(2, '0');
|
|
137
|
+
}
|
|
138
|
+
/** The engine's `rgba(r, g, b, a)` spelling, alpha at three decimals. */
|
|
139
|
+
function wrunRgbaText(parts, alpha) {
|
|
140
|
+
return `rgba(${parts.r}, ${parts.g}, ${parts.b}, ${Number(alpha.toFixed(3))})`;
|
|
141
|
+
}
|
|
142
|
+
/** A resolved colour: `#rrggbb` (lowercase) when the alpha rounds to 1, else
|
|
143
|
+
* `rgba(r, g, b, a)`. */
|
|
144
|
+
function wrunCssColorText(parts, alpha) {
|
|
145
|
+
if (Number(alpha.toFixed(3)) >= 1)
|
|
146
|
+
return `#${wrunByteHex(parts.r)}${wrunByteHex(parts.g)}${wrunByteHex(parts.b)}`;
|
|
147
|
+
return wrunRgbaText(parts, alpha);
|
|
148
|
+
}
|
|
149
|
+
function wrunRecordAt(value) {
|
|
150
|
+
return value !== null && typeof value === 'object' ? value : undefined;
|
|
151
|
+
}
|
|
152
|
+
function wrunColorField(value) {
|
|
153
|
+
return typeof value === 'string' && value.trim() !== '' ? value : undefined;
|
|
154
|
+
}
|
|
155
|
+
/** The text colour at alpha x 0.55 as `rgba(r, g, b, a)`; a text colour
|
|
156
|
+
* that does not parse stays as it is. */
|
|
157
|
+
function wrunMutedOf(text) {
|
|
158
|
+
const parts = parseWrunCssColor(text);
|
|
159
|
+
return parts === undefined ? text : wrunRgbaText(parts, parts.a * WRUN_MUTED_ALPHA);
|
|
160
|
+
}
|
|
161
|
+
/** The accent `noteWrunThemeApplied` recorded per chart (X9: the theme's
|
|
162
|
+
* warm line colour, handed over by applyChartTheme; the foundation reads
|
|
163
|
+
* no DOM and imports no theme module). */
|
|
164
|
+
const wrunAccentByChart = new WeakMap();
|
|
165
|
+
const wrunThemeListeners = new Set();
|
|
166
|
+
/** The palette of a chart (`tc`, feature-detected: a bare test double or a
|
|
167
|
+
* pin without a theme answers the dark defaults): up and down from the
|
|
168
|
+
* candle colours, text from the x axis font colour, muted = text at alpha
|
|
169
|
+
* x 0.55, bg and grid from the theme, accent from `noteWrunThemeApplied`
|
|
170
|
+
* (fallback '#ff4608'). */
|
|
171
|
+
export function wrunColorThemeOf(tc) {
|
|
172
|
+
const chart = wrunRecordAt(tc);
|
|
173
|
+
const theme = wrunRecordAt(chart?.theme);
|
|
174
|
+
const text = wrunColorField(wrunRecordAt(theme?.xAxis)?.fontColor) ?? WRUN_THEME_FALLBACK.text;
|
|
175
|
+
const accent = chart === undefined ? undefined : wrunAccentByChart.get(chart);
|
|
176
|
+
return {
|
|
177
|
+
up: wrunColorField(theme?.bullishCandleColor) ?? WRUN_THEME_FALLBACK.up,
|
|
178
|
+
down: wrunColorField(theme?.bearishCandleColor) ?? WRUN_THEME_FALLBACK.down,
|
|
179
|
+
text,
|
|
180
|
+
muted: wrunMutedOf(text),
|
|
181
|
+
bg: wrunColorField(theme?.backgroundColor) ?? WRUN_THEME_FALLBACK.bg,
|
|
182
|
+
grid: wrunColorField(wrunRecordAt(theme?.grid)?.color) ?? WRUN_THEME_FALLBACK.grid,
|
|
183
|
+
accent: wrunColorField(accent) ?? WRUN_THEME_FALLBACK.accent,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/** Records the accent colour of a theme apply for `tc` (a WeakMap, so a
|
|
187
|
+
* disposed chart leaves nothing behind), then tells every
|
|
188
|
+
* `onWrunThemeChange` listener the chart's palette may have moved. Called
|
|
189
|
+
* by applyChartTheme after every apply; a listener that throws is logged
|
|
190
|
+
* and never stops the others or the apply. */
|
|
191
|
+
export function noteWrunThemeApplied(tc, accent) {
|
|
192
|
+
if (tc === null || (typeof tc !== 'object' && typeof tc !== 'function'))
|
|
193
|
+
return;
|
|
194
|
+
wrunAccentByChart.set(tc, accent);
|
|
195
|
+
for (const listener of [...wrunThemeListeners]) {
|
|
196
|
+
try {
|
|
197
|
+
listener(tc);
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
console.warn('[wrun] theme change listener failed:', error);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/** Subscribes to theme applies (the HUD re-resolves its tokens here); the
|
|
205
|
+
* returned function unsubscribes. */
|
|
206
|
+
export function onWrunThemeChange(listener) {
|
|
207
|
+
wrunThemeListeners.add(listener);
|
|
208
|
+
return () => {
|
|
209
|
+
wrunThemeListeners.delete(listener);
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/** Resolves a colour word against a palette: a token (with or without the
|
|
213
|
+
* `/aa` alpha) becomes the palette colour with alpha = palette alpha x
|
|
214
|
+
* token alpha, `#rrggbb` (lowercase) when that rounds to 1, else
|
|
215
|
+
* `rgba(r, g, b, a)`. A palette colour the parser cannot read comes back
|
|
216
|
+
* as the palette wrote it; any non-token string comes back unchanged. */
|
|
217
|
+
export function resolveWrunColorWord(word, theme) {
|
|
218
|
+
const ref = parseWrunThemeToken(word);
|
|
219
|
+
if (ref === null)
|
|
220
|
+
return word;
|
|
221
|
+
const palette = theme?.[ref.token];
|
|
222
|
+
if (typeof palette !== 'string')
|
|
223
|
+
return word;
|
|
224
|
+
const parts = parseWrunCssColor(palette);
|
|
225
|
+
if (parts === undefined)
|
|
226
|
+
return palette;
|
|
227
|
+
return wrunCssColorText(parts, parts.a * ref.alpha);
|
|
228
|
+
}
|
|
229
|
+
/** `#rrggbbaa` as `rgba(r, g, b, a)` (a = the byte / 255 at three decimals)
|
|
230
|
+
* for consumers that cannot read 8-digit hex (the domain panes); every
|
|
231
|
+
* other string comes back unchanged. */
|
|
232
|
+
export function wrunHex8ToRgba(color) {
|
|
233
|
+
if (typeof color !== 'string')
|
|
234
|
+
return color;
|
|
235
|
+
const match = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color);
|
|
236
|
+
if (!match)
|
|
237
|
+
return color;
|
|
238
|
+
const parts = { r: parseInt(match[1], 16), g: parseInt(match[2], 16), b: parseInt(match[3], 16), a: 1 };
|
|
239
|
+
return wrunRgbaText(parts, parseInt(match[4], 16) / 255);
|
|
240
|
+
}
|
|
241
|
+
// Font words (D2, D11, X14: the engine never sees a font word)
|
|
242
|
+
/** The four font families; each maps to a system stack below, never a
|
|
243
|
+
* downloaded font (`ui` is the app font). */
|
|
244
|
+
export const WRUN_FONT_FAMILIES = ['ui', 'mono', 'serif', 'rounded'];
|
|
245
|
+
export const WRUN_FONT_WEIGHTS = ['normal', 'medium', 'bold'];
|
|
246
|
+
/** The CSS stack of each font word (frozen, 2.3). */
|
|
247
|
+
export const WRUN_FONT_FAMILY_CSS = {
|
|
248
|
+
ui: "Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
249
|
+
mono: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
|
|
250
|
+
serif: "ui-serif, 'Iowan Old Style', Charter, Georgia, 'Times New Roman', serif",
|
|
251
|
+
rounded: "ui-rounded, 'SF Pro Rounded', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
252
|
+
};
|
|
253
|
+
const WRUN_FONT_WEIGHT_CSS = {
|
|
254
|
+
normal: 400,
|
|
255
|
+
medium: 500,
|
|
256
|
+
bold: 700,
|
|
257
|
+
};
|
|
258
|
+
/** A font word's CSS stack; anything that is not one of the four words is
|
|
259
|
+
* undefined (the caller keeps its default). */
|
|
260
|
+
export function wrunFontFamilyCss(word) {
|
|
261
|
+
return typeof word === 'string' && WRUN_FONT_FAMILIES.includes(word)
|
|
262
|
+
? WRUN_FONT_FAMILY_CSS[word]
|
|
263
|
+
: undefined;
|
|
264
|
+
}
|
|
265
|
+
/** A weight word's CSS weight: normal 400, medium 500, bold 700; anything
|
|
266
|
+
* else is undefined. */
|
|
267
|
+
export function wrunFontWeightCss(word) {
|
|
268
|
+
return typeof word === 'string' && WRUN_FONT_WEIGHTS.includes(word)
|
|
269
|
+
? WRUN_FONT_WEIGHT_CSS[word]
|
|
270
|
+
: undefined;
|
|
271
|
+
}
|
|
272
|
+
// Number formats (conventions 8, X1..X6)
|
|
273
|
+
/** Value formats for legend entries, tooltips, HUD tiles, hover blocks,
|
|
274
|
+
* panels, levels, panes and widgets: "price" (the market's precision),
|
|
275
|
+
* "%" (percent), "si" (K / M / B / T suffixes), "int", a fixed decimal
|
|
276
|
+
* count, "usd" (compact with a $ sign) or "auto" (6 significant digits
|
|
277
|
+
* with "," thousands). */
|
|
278
|
+
export const WRUN_VALUE_FORMATS = ['price', '%', 'si', 'int', '0', '0.0', '0.00', '0.000', 'usd', 'auto'];
|
|
279
|
+
/** Card rows and the card headline also take "pct" (the value x 100 as a
|
|
280
|
+
* percent). */
|
|
281
|
+
export const WRUN_CARD_VALUE_FORMATS = [...WRUN_VALUE_FORMATS, 'pct'];
|
|
282
|
+
/** Bounds on the format companions: `decimals` 0..8, `unit` 0..8 chars. */
|
|
283
|
+
export const WRUN_MAX_VALUE_DECIMALS = 8;
|
|
284
|
+
export const WRUN_MAX_VALUE_UNIT_CHARS = 8;
|
|
285
|
+
// The frozen text of FREEZE.md section 2.2, verbatim (prettier is off on
|
|
286
|
+
// each statement so the quotes and line breaks stay the freeze's). The om
|
|
287
|
+
// twin carries the same statements; the corpus pins both.
|
|
288
|
+
// prettier-ignore
|
|
289
|
+
const WRUN_FIXED_FORMAT_DIGITS = { int: 0, "0": 0, "0.0": 1, "0.00": 2, "0.000": 3 };
|
|
290
|
+
// prettier-ignore
|
|
291
|
+
const WRUN_COMPACT_UNITS = [[1e12, "T"], [1e9, "B"], [1e6, "M"], [1e3, "K"]];
|
|
292
|
+
// prettier-ignore
|
|
293
|
+
function wrunCompact(abs, digits) {
|
|
294
|
+
for (let i = 0; i < WRUN_COMPACT_UNITS.length; i++) {
|
|
295
|
+
const [unit, suffix] = WRUN_COMPACT_UNITS[i];
|
|
296
|
+
if (abs >= unit) {
|
|
297
|
+
const text = (abs / unit).toFixed(digits);
|
|
298
|
+
if (Number(text) >= 1000 && i > 0) {
|
|
299
|
+
const [bigger, biggerSuffix] = WRUN_COMPACT_UNITS[i - 1];
|
|
300
|
+
return (abs / bigger).toFixed(digits) + biggerSuffix;
|
|
301
|
+
}
|
|
302
|
+
return text + suffix;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return abs.toFixed(digits);
|
|
306
|
+
}
|
|
307
|
+
// prettier-ignore
|
|
308
|
+
function wrunGrouped(fixed) {
|
|
309
|
+
const dot = fixed.indexOf(".");
|
|
310
|
+
const int = dot < 0 ? fixed : fixed.slice(0, dot);
|
|
311
|
+
const frac = dot < 0 ? "" : fixed.slice(dot);
|
|
312
|
+
return int.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + frac;
|
|
313
|
+
}
|
|
314
|
+
// prettier-ignore
|
|
315
|
+
function wrunAuto(abs, decimals) {
|
|
316
|
+
if (decimals !== undefined)
|
|
317
|
+
return wrunGrouped(abs.toFixed(decimals));
|
|
318
|
+
if (abs === 0)
|
|
319
|
+
return "0";
|
|
320
|
+
const exp = abs.toExponential(5);
|
|
321
|
+
const e = Number(exp.slice(exp.indexOf("e") + 1));
|
|
322
|
+
const p = Number(exp);
|
|
323
|
+
if (e < -9 || e >= 21)
|
|
324
|
+
return String(p);
|
|
325
|
+
const fixed = p.toFixed(Math.max(0, 5 - e));
|
|
326
|
+
return wrunGrouped(fixed.indexOf(".") < 0 ? fixed : fixed.replace(/\.?0+$/, ""));
|
|
327
|
+
}
|
|
328
|
+
// prettier-ignore
|
|
329
|
+
function wrunScaled(abs, decimals) {
|
|
330
|
+
const small = abs.toFixed(decimals ?? 2);
|
|
331
|
+
return Number(small) < 1000 ? small : wrunCompact(Math.max(abs, 1000), decimals ?? 1);
|
|
332
|
+
}
|
|
333
|
+
/** Prints one number the way its surface declared (format, decimals,
|
|
334
|
+
* signed, unit, priceDigits). Without a format: today's card text
|
|
335
|
+
* (`String(Number(value.toPrecision(6)))`) when no companion is declared,
|
|
336
|
+
* else "auto". Non-finite prints "" (the caller prints its own hole mark).
|
|
337
|
+
* Byte-identical to the om twin: tests/fixtures/wrun/wrun-value-format-corpus.json. */
|
|
338
|
+
// prettier-ignore
|
|
339
|
+
export function formatWrunNumber(value, spec = {}) {
|
|
340
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
341
|
+
return "";
|
|
342
|
+
const decimals = typeof spec.decimals === "number" && Number.isInteger(spec.decimals) && spec.decimals >= 0 && spec.decimals <= 8
|
|
343
|
+
? spec.decimals
|
|
344
|
+
: undefined;
|
|
345
|
+
const unit = typeof spec.unit === "string" ? spec.unit : "";
|
|
346
|
+
const signed = spec.signed === true;
|
|
347
|
+
let format = typeof spec.format === "string" ? spec.format : undefined;
|
|
348
|
+
if (format === undefined) {
|
|
349
|
+
if (decimals === undefined && !signed && unit === "")
|
|
350
|
+
return String(Number(value.toPrecision(6)));
|
|
351
|
+
format = "auto";
|
|
352
|
+
}
|
|
353
|
+
const abs = Math.abs(value);
|
|
354
|
+
let body;
|
|
355
|
+
let prefix = "";
|
|
356
|
+
let suffix = "";
|
|
357
|
+
switch (format) {
|
|
358
|
+
case "price": {
|
|
359
|
+
const pd = spec.priceDigits;
|
|
360
|
+
const digits = typeof pd === "number" && Number.isInteger(pd) && pd >= 0 && pd <= 14 ? pd : 2;
|
|
361
|
+
body = abs.toFixed(decimals ?? digits);
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
case "%":
|
|
365
|
+
body = abs.toFixed(decimals ?? 2);
|
|
366
|
+
suffix = "%";
|
|
367
|
+
break;
|
|
368
|
+
case "pct":
|
|
369
|
+
body = (abs * 100).toFixed(decimals ?? 2);
|
|
370
|
+
suffix = "%";
|
|
371
|
+
break;
|
|
372
|
+
case "si":
|
|
373
|
+
body = wrunScaled(abs, decimals);
|
|
374
|
+
break;
|
|
375
|
+
case "usd":
|
|
376
|
+
prefix = "$";
|
|
377
|
+
body = wrunScaled(abs, decimals);
|
|
378
|
+
break;
|
|
379
|
+
case "auto":
|
|
380
|
+
body = wrunAuto(abs, decimals);
|
|
381
|
+
break;
|
|
382
|
+
default: {
|
|
383
|
+
const fixed = WRUN_FIXED_FORMAT_DIGITS[format];
|
|
384
|
+
body = fixed === undefined ? wrunAuto(abs, decimals) : abs.toFixed(decimals ?? fixed);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
const nonzero = /[1-9]/.test(body);
|
|
388
|
+
const sign = value < 0 && nonzero ? "-" : signed && value > 0 && nonzero ? "+" : "";
|
|
389
|
+
return sign + prefix + body + suffix + unit;
|
|
390
|
+
}
|
|
391
|
+
// Theme token packing (the ABI and colour-param forms, as 2.1)
|
|
392
|
+
/** The draw ABI's theme token sentinel: a `wrun_draw_color` rgba whose
|
|
393
|
+
* alpha byte is 0x00, red byte 0x7e and green byte k in 1..7 is token k of
|
|
394
|
+
* {@link WRUN_THEME_COLOR_TOKENS} with its alpha in the blue byte. Every
|
|
395
|
+
* other value is a plain colour. */
|
|
396
|
+
export const WRUN3_THEME_TOKEN_MARKER = 0x7e;
|
|
397
|
+
/** Decodes the draw ABI sentinel (`0xRRGGBBAA` as an i32 or u32): a token
|
|
398
|
+
* when the alpha byte is 0, the red byte the marker and the green byte in
|
|
399
|
+
* 1..7, else null (a plain colour, exactly as before the sentinel). */
|
|
400
|
+
export function wrunThemeTokenOfI32(rgba) {
|
|
401
|
+
if ((rgba & 0xff) !== 0 || rgba >>> 24 !== WRUN3_THEME_TOKEN_MARKER)
|
|
402
|
+
return null;
|
|
403
|
+
const k = (rgba >>> 16) & 0xff;
|
|
404
|
+
const token = k >= 1 ? WRUN_THEME_COLOR_TOKENS[k - 1] : undefined;
|
|
405
|
+
if (token === undefined)
|
|
406
|
+
return null;
|
|
407
|
+
return { token, alpha: ((rgba >>> 8) & 0xff) / 255 };
|
|
408
|
+
}
|
|
409
|
+
/** The wire colour of a `wrun_draw_color` rgba: a token's word, else
|
|
410
|
+
* today's `rgba(r,g,b,a)` text (no spaces, alpha at three decimals). */
|
|
411
|
+
export function wrunDrawColorWire(rgba) {
|
|
412
|
+
const ref = wrunThemeTokenOfI32(rgba);
|
|
413
|
+
if (ref !== null)
|
|
414
|
+
return wrunThemeTokenWord(ref);
|
|
415
|
+
const r = rgba >>> 24;
|
|
416
|
+
const g = (rgba >>> 16) & 0xff;
|
|
417
|
+
const b = (rgba >>> 8) & 0xff;
|
|
418
|
+
const a = rgba & 0xff;
|
|
419
|
+
return `rgba(${r},${g},${b},${Number((a / 255).toFixed(3))})`;
|
|
420
|
+
}
|
|
421
|
+
/** The packed f64 form of a token (`*_packed_by` outputs, colour params):
|
|
422
|
+
* `-(k * 1024 + round(alpha * 1000))`, a negative integer no colour ever
|
|
423
|
+
* packed to. Alpha is clamped to 0..1. */
|
|
424
|
+
export function wrunPackedThemeToken(ref) {
|
|
425
|
+
return -(wrunTokenK(ref.token) * 1024 + Math.round(wrunTokenAlpha(ref.alpha) * 1000));
|
|
426
|
+
}
|
|
427
|
+
/** Decodes a packed colour: a finite negative integer whose k lands in 1..7
|
|
428
|
+
* and whose alpha part is at most 1000 is a token, anything else null. */
|
|
429
|
+
export function wrunThemeTokenOfPacked(value) {
|
|
430
|
+
if (!Number.isInteger(value) || value >= 0)
|
|
431
|
+
return null;
|
|
432
|
+
const n = -value;
|
|
433
|
+
const k = Math.floor(n / 1024);
|
|
434
|
+
const alphaPart = n % 1024;
|
|
435
|
+
const token = k >= 1 ? WRUN_THEME_COLOR_TOKENS[k - 1] : undefined;
|
|
436
|
+
if (token === undefined || alphaPart > 1000)
|
|
437
|
+
return null;
|
|
438
|
+
return { token, alpha: alphaPart / 1000 };
|
|
439
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The styled-table surface of a `render.table` sheet renderer (kit scaffold 37, the capability
|
|
3
|
+
* round): the words and bounds the sheet schema admits, mirrored from the kit
|
|
4
|
+
* (`WRUN_TABLE_*`, pinned by `tests/utility/wrun/wrun-table-look.kit-mirror.spec.ts`), and the
|
|
5
|
+
* readers that turn the declared snake_case keys into the engine's camelCase plotTable payload
|
|
6
|
+
* keys, refused by name when a value is outside the vocabulary. The run-result adapter
|
|
7
|
+
* (`wrun-run-result.util.ts`, the table case) owns the ladders and the snapshot lifecycle; this
|
|
8
|
+
* module owns only the static look, so a sheet the kit validated and a hand-written sheet read
|
|
9
|
+
* through one rule. Every reader takes the refusal label the adapter builds (`WRUN <sheet>:
|
|
10
|
+
* table renderer '<name>'`) and returns undefined for an absent key, so an absent key never
|
|
11
|
+
* reaches the payload (a legacy payload stays byte-identical).
|
|
12
|
+
*/
|
|
13
|
+
export declare const WRUN_TABLE_ALIGNS: readonly ["left", "center", "right"];
|
|
14
|
+
export declare const WRUN_TABLE_VALIGNS: readonly ["top", "middle", "bottom"];
|
|
15
|
+
export declare const WRUN_TABLE_FONT_WEIGHTS: readonly ["normal", "bold"];
|
|
16
|
+
export declare const WRUN_TABLE_LINE_STYLES: readonly ["solid", "dashed", "dotted"];
|
|
17
|
+
export declare const WRUN_TABLE_GRID_LINES: readonly ["all", "rows", "cols", "none"];
|
|
18
|
+
export declare const WRUN_TABLE_GRADIENT_DIRECTIONS: readonly ["vertical", "horizontal"];
|
|
19
|
+
/** The px bounds: a table or column width (0 = measured), the anchor nudge (the card offset's
|
|
20
|
+
* bound), a line width (the box handle's border bound) and the frame's corner radius. */
|
|
21
|
+
export declare const WRUN_MAX_TABLE_WIDTH_PX = 4096;
|
|
22
|
+
export declare const WRUN_MAX_TABLE_OFFSET_PX = 200;
|
|
23
|
+
export declare const WRUN_MAX_TABLE_LINE_WIDTH_PX = 10;
|
|
24
|
+
export declare const WRUN_MAX_TABLE_CORNER_RADIUS_PX = 32;
|
|
25
|
+
/** A gradient's stop count, the range gradient's bounds. */
|
|
26
|
+
export declare const WRUN_MIN_TABLE_GRADIENT_STOPS = 2;
|
|
27
|
+
export declare const WRUN_MAX_TABLE_GRADIENT_STOPS = 8;
|
|
28
|
+
export type WrunTableAlign = (typeof WRUN_TABLE_ALIGNS)[number];
|
|
29
|
+
export type WrunTableValign = (typeof WRUN_TABLE_VALIGNS)[number];
|
|
30
|
+
export type WrunTableFontWeight = (typeof WRUN_TABLE_FONT_WEIGHTS)[number];
|
|
31
|
+
export type WrunTableLineStyle = (typeof WRUN_TABLE_LINE_STYLES)[number];
|
|
32
|
+
export type WrunTableGridLines = (typeof WRUN_TABLE_GRID_LINES)[number];
|
|
33
|
+
export type WrunTableGradientDirection = (typeof WRUN_TABLE_GRADIENT_DIRECTIONS)[number];
|
|
34
|
+
/** The declared table-level styled keys, as the sheet spells them (the colour keys and their
|
|
35
|
+
* ladders stay with the adapter). */
|
|
36
|
+
export interface WrunTableSurfaceDeclaration {
|
|
37
|
+
offset?: unknown;
|
|
38
|
+
width?: unknown;
|
|
39
|
+
column_widths?: unknown;
|
|
40
|
+
header_rows?: unknown;
|
|
41
|
+
background_opacity?: unknown;
|
|
42
|
+
background_gradient?: unknown;
|
|
43
|
+
gradient_direction?: unknown;
|
|
44
|
+
border_style?: unknown;
|
|
45
|
+
corner_radius?: unknown;
|
|
46
|
+
grid_width?: unknown;
|
|
47
|
+
grid_style?: unknown;
|
|
48
|
+
grid_lines?: unknown;
|
|
49
|
+
font_weight?: unknown;
|
|
50
|
+
align?: unknown;
|
|
51
|
+
valign?: unknown;
|
|
52
|
+
}
|
|
53
|
+
/** The table-level styled payload keys (the engine's plotTable names), each present only when
|
|
54
|
+
* the sheet declared it. */
|
|
55
|
+
export interface WrunTableSurfaceStyle {
|
|
56
|
+
offset?: [number, number];
|
|
57
|
+
headerRows?: number;
|
|
58
|
+
backgroundOpacity?: number;
|
|
59
|
+
backgroundGradient?: string[];
|
|
60
|
+
gradientDirection?: WrunTableGradientDirection;
|
|
61
|
+
borderStyle?: WrunTableLineStyle;
|
|
62
|
+
gridWidth?: number;
|
|
63
|
+
gridStyle?: WrunTableLineStyle;
|
|
64
|
+
gridLines?: WrunTableGridLines;
|
|
65
|
+
cornerRadius?: number;
|
|
66
|
+
fontWeight?: WrunTableFontWeight;
|
|
67
|
+
align?: WrunTableAlign;
|
|
68
|
+
valign?: WrunTableValign;
|
|
69
|
+
width?: number;
|
|
70
|
+
columnWidths?: number[];
|
|
71
|
+
}
|
|
72
|
+
/** The declared per-cell styled keys, as the sheet spells them under `cell_styles`. */
|
|
73
|
+
export interface WrunTableCellSurfaceDeclaration {
|
|
74
|
+
colspan?: unknown;
|
|
75
|
+
rowspan?: unknown;
|
|
76
|
+
valign?: unknown;
|
|
77
|
+
font_size?: unknown;
|
|
78
|
+
font_weight?: unknown;
|
|
79
|
+
opacity?: unknown;
|
|
80
|
+
gradient?: unknown;
|
|
81
|
+
gradient_direction?: unknown;
|
|
82
|
+
}
|
|
83
|
+
/** The per-cell styled payload keys (the engine's rich-cell names). */
|
|
84
|
+
export interface WrunTableCellSurfaceStyle {
|
|
85
|
+
colspan?: number;
|
|
86
|
+
rowspan?: number;
|
|
87
|
+
valign?: WrunTableValign;
|
|
88
|
+
fontSize?: number;
|
|
89
|
+
fontWeight?: WrunTableFontWeight;
|
|
90
|
+
opacity?: number;
|
|
91
|
+
gradient?: string[];
|
|
92
|
+
gradientDirection?: WrunTableGradientDirection;
|
|
93
|
+
}
|
|
94
|
+
/** A span (`colspan` / `rowspan`): an integer >= 1; absent = 1. */
|
|
95
|
+
export declare function readWrunTableSpan(label: string, key: string, value: unknown): number;
|
|
96
|
+
/** The table-level styled keys, validated and spelled as the engine reads them. `rows` and `cols`
|
|
97
|
+
* bound `header_rows` and `column_widths` (one width per column, 0 = measured). */
|
|
98
|
+
export declare function readWrunTableSurfaceStyle(label: string, table: WrunTableSurfaceDeclaration, grid: {
|
|
99
|
+
rows: number;
|
|
100
|
+
cols: number;
|
|
101
|
+
}): WrunTableSurfaceStyle;
|
|
102
|
+
/** One cell's styled keys, validated and spelled as the engine's rich cell reads them. The spans
|
|
103
|
+
* are integers >= 1 here; whether they fit the grid is judged where the slot occurs
|
|
104
|
+
* (`wrunTableSpanCoverage`), since a slot may be listed at more than one grid cell. */
|
|
105
|
+
export declare function readWrunTableCellSurfaceStyle(label: string, style: WrunTableCellSurfaceDeclaration): WrunTableCellSurfaceStyle;
|
|
106
|
+
/** The grid cells the spans hide, walked in grid order the way the engine lays the rows out: a
|
|
107
|
+
* cell that mounts (not under an earlier span) extends coverage over its block, judged against
|
|
108
|
+
* its own place (a span past the grid refuses by name), and a covered cell's own span is
|
|
109
|
+
* ignored. So a slot listed at several grid cells spans at each occurrence, two spanning cells
|
|
110
|
+
* never share a row, and a cell under another span never hides a third one. `spans` maps a
|
|
111
|
+
* slot to its colspan / rowspan (absent = 1); `cells` is the table's slot per grid cell. */
|
|
112
|
+
export declare function wrunTableSpanCoverage(label: string, cells: ReadonlyArray<string>, spans: ReadonlyMap<string, {
|
|
113
|
+
colspan?: number;
|
|
114
|
+
rowspan?: number;
|
|
115
|
+
}>, grid: {
|
|
116
|
+
rows: number;
|
|
117
|
+
cols: number;
|
|
118
|
+
}): Set<number>;
|
|
119
|
+
/** The grid indexes a spanning cell covers besides its own (the next colspan - 1 cells of its
|
|
120
|
+
* row and the rowspan - 1 rows below, as a block): the engine's row carries only the spanning
|
|
121
|
+
* cell, so they never mount. Indexes past the grid are never produced (the spans were checked). */
|
|
122
|
+
export declare function wrunTableCoveredCells(at: number, span: {
|
|
123
|
+
colspan?: number;
|
|
124
|
+
rowspan?: number;
|
|
125
|
+
}, cols: number): number[];
|