@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,225 @@
|
|
|
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 const WRUN_TABLE_ALIGNS = ['left', 'center', 'right'];
|
|
14
|
+
export const WRUN_TABLE_VALIGNS = ['top', 'middle', 'bottom'];
|
|
15
|
+
export const WRUN_TABLE_FONT_WEIGHTS = ['normal', 'bold'];
|
|
16
|
+
export const WRUN_TABLE_LINE_STYLES = ['solid', 'dashed', 'dotted'];
|
|
17
|
+
export const WRUN_TABLE_GRID_LINES = ['all', 'rows', 'cols', 'none'];
|
|
18
|
+
export const WRUN_TABLE_GRADIENT_DIRECTIONS = ['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 const WRUN_MAX_TABLE_WIDTH_PX = 4096;
|
|
22
|
+
export const WRUN_MAX_TABLE_OFFSET_PX = 200;
|
|
23
|
+
export const WRUN_MAX_TABLE_LINE_WIDTH_PX = 10;
|
|
24
|
+
export const WRUN_MAX_TABLE_CORNER_RADIUS_PX = 32;
|
|
25
|
+
/** A gradient's stop count, the range gradient's bounds. */
|
|
26
|
+
export const WRUN_MIN_TABLE_GRADIENT_STOPS = 2;
|
|
27
|
+
export const WRUN_MAX_TABLE_GRADIENT_STOPS = 8;
|
|
28
|
+
function word(label, key, value, words) {
|
|
29
|
+
if (value === undefined)
|
|
30
|
+
return undefined;
|
|
31
|
+
if (typeof value !== 'string' || !words.includes(value)) {
|
|
32
|
+
throw new Error(`${label} ${key} must be one of ${words.join(', ')}, got ${JSON.stringify(value)}`);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
function finite(label, key, value, bounds) {
|
|
37
|
+
if (value === undefined)
|
|
38
|
+
return undefined;
|
|
39
|
+
const ok = typeof value === 'number' &&
|
|
40
|
+
Number.isFinite(value) &&
|
|
41
|
+
(bounds.integer !== true || Number.isInteger(value)) &&
|
|
42
|
+
(bounds.minExclusive === true ? value > bounds.min : value >= bounds.min) &&
|
|
43
|
+
(bounds.max === undefined || value <= bounds.max);
|
|
44
|
+
if (!ok) {
|
|
45
|
+
const low = `${bounds.minExclusive === true ? '>' : '>='} ${bounds.min}`;
|
|
46
|
+
const high = bounds.max === undefined ? '' : ` and <= ${bounds.max}`;
|
|
47
|
+
throw new Error(`${label} ${key} must be ${bounds.integer === true ? 'an integer' : 'a finite number'} ${low}${high}, got ${String(value)}`);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
/** 2..8 non-empty colour strings, the engine's gradient stop list. */
|
|
52
|
+
function gradient(label, key, value) {
|
|
53
|
+
if (value === undefined)
|
|
54
|
+
return undefined;
|
|
55
|
+
const refusal = `${label} ${key} must be an array of ${WRUN_MIN_TABLE_GRADIENT_STOPS}..${WRUN_MAX_TABLE_GRADIENT_STOPS} color strings`;
|
|
56
|
+
if (!Array.isArray(value) ||
|
|
57
|
+
value.length < WRUN_MIN_TABLE_GRADIENT_STOPS ||
|
|
58
|
+
value.length > WRUN_MAX_TABLE_GRADIENT_STOPS) {
|
|
59
|
+
throw new Error(`${refusal}: got ${Array.isArray(value) ? `${value.length} color(s)` : 'a non-array'}`);
|
|
60
|
+
}
|
|
61
|
+
for (const color of value) {
|
|
62
|
+
if (typeof color !== 'string' || color.trim().length === 0) {
|
|
63
|
+
throw new Error(`${refusal}: every entry must be a color string`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return [...value];
|
|
67
|
+
}
|
|
68
|
+
/** A span (`colspan` / `rowspan`): an integer >= 1; absent = 1. */
|
|
69
|
+
export function readWrunTableSpan(label, key, value) {
|
|
70
|
+
if (value === undefined)
|
|
71
|
+
return 1;
|
|
72
|
+
if (typeof value !== 'number' || !Number.isInteger(value) || value < 1) {
|
|
73
|
+
throw new Error(`${label} ${key} must be an integer >= 1, got ${String(value)}`);
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
/** The table-level styled keys, validated and spelled as the engine reads them. `rows` and `cols`
|
|
78
|
+
* bound `header_rows` and `column_widths` (one width per column, 0 = measured). */
|
|
79
|
+
export function readWrunTableSurfaceStyle(label, table, grid) {
|
|
80
|
+
const style = {};
|
|
81
|
+
if (table.offset !== undefined) {
|
|
82
|
+
const offset = table.offset;
|
|
83
|
+
if (!Array.isArray(offset) || offset.length !== 2) {
|
|
84
|
+
throw new Error(`${label} offset must be [x, y], got ${JSON.stringify(offset)}`);
|
|
85
|
+
}
|
|
86
|
+
style.offset = [
|
|
87
|
+
finite(label, 'offset[0]', offset[0], {
|
|
88
|
+
min: -WRUN_MAX_TABLE_OFFSET_PX,
|
|
89
|
+
max: WRUN_MAX_TABLE_OFFSET_PX,
|
|
90
|
+
}),
|
|
91
|
+
finite(label, 'offset[1]', offset[1], {
|
|
92
|
+
min: -WRUN_MAX_TABLE_OFFSET_PX,
|
|
93
|
+
max: WRUN_MAX_TABLE_OFFSET_PX,
|
|
94
|
+
}),
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
const headerRows = finite(label, 'header_rows', table.header_rows, { min: 0, max: grid.rows, integer: true });
|
|
98
|
+
if (headerRows !== undefined)
|
|
99
|
+
style.headerRows = headerRows;
|
|
100
|
+
const backgroundOpacity = finite(label, 'background_opacity', table.background_opacity, { min: 0, max: 1 });
|
|
101
|
+
if (backgroundOpacity !== undefined)
|
|
102
|
+
style.backgroundOpacity = backgroundOpacity;
|
|
103
|
+
const backgroundGradient = gradient(label, 'background_gradient', table.background_gradient);
|
|
104
|
+
if (backgroundGradient !== undefined)
|
|
105
|
+
style.backgroundGradient = backgroundGradient;
|
|
106
|
+
const gradientDirection = word(label, 'gradient_direction', table.gradient_direction, WRUN_TABLE_GRADIENT_DIRECTIONS);
|
|
107
|
+
if (gradientDirection !== undefined)
|
|
108
|
+
style.gradientDirection = gradientDirection;
|
|
109
|
+
const borderStyle = word(label, 'border_style', table.border_style, WRUN_TABLE_LINE_STYLES);
|
|
110
|
+
if (borderStyle !== undefined)
|
|
111
|
+
style.borderStyle = borderStyle;
|
|
112
|
+
const gridWidth = finite(label, 'grid_width', table.grid_width, { min: 0, max: WRUN_MAX_TABLE_LINE_WIDTH_PX });
|
|
113
|
+
if (gridWidth !== undefined)
|
|
114
|
+
style.gridWidth = gridWidth;
|
|
115
|
+
const gridStyle = word(label, 'grid_style', table.grid_style, WRUN_TABLE_LINE_STYLES);
|
|
116
|
+
if (gridStyle !== undefined)
|
|
117
|
+
style.gridStyle = gridStyle;
|
|
118
|
+
const gridLines = word(label, 'grid_lines', table.grid_lines, WRUN_TABLE_GRID_LINES);
|
|
119
|
+
if (gridLines !== undefined)
|
|
120
|
+
style.gridLines = gridLines;
|
|
121
|
+
const cornerRadius = finite(label, 'corner_radius', table.corner_radius, {
|
|
122
|
+
min: 0,
|
|
123
|
+
max: WRUN_MAX_TABLE_CORNER_RADIUS_PX,
|
|
124
|
+
});
|
|
125
|
+
if (cornerRadius !== undefined)
|
|
126
|
+
style.cornerRadius = cornerRadius;
|
|
127
|
+
const fontWeight = word(label, 'font_weight', table.font_weight, WRUN_TABLE_FONT_WEIGHTS);
|
|
128
|
+
if (fontWeight !== undefined)
|
|
129
|
+
style.fontWeight = fontWeight;
|
|
130
|
+
const align = word(label, 'align', table.align, WRUN_TABLE_ALIGNS);
|
|
131
|
+
if (align !== undefined)
|
|
132
|
+
style.align = align;
|
|
133
|
+
const valign = word(label, 'valign', table.valign, WRUN_TABLE_VALIGNS);
|
|
134
|
+
if (valign !== undefined)
|
|
135
|
+
style.valign = valign;
|
|
136
|
+
const width = finite(label, 'width', table.width, { min: 0, minExclusive: true, max: WRUN_MAX_TABLE_WIDTH_PX });
|
|
137
|
+
if (width !== undefined)
|
|
138
|
+
style.width = width;
|
|
139
|
+
if (table.column_widths !== undefined) {
|
|
140
|
+
const widths = table.column_widths;
|
|
141
|
+
if (!Array.isArray(widths) || widths.length !== grid.cols) {
|
|
142
|
+
throw new Error(`${label} column_widths must list one width per column (${grid.cols}; 0 = measured), got ${Array.isArray(widths) ? `${widths.length} width(s)` : 'a non-array'}`);
|
|
143
|
+
}
|
|
144
|
+
style.columnWidths = widths.map((entry, at) => finite(label, `column_widths[${at}]`, entry, { min: 0, max: WRUN_MAX_TABLE_WIDTH_PX }));
|
|
145
|
+
}
|
|
146
|
+
return style;
|
|
147
|
+
}
|
|
148
|
+
/** One cell's styled keys, validated and spelled as the engine's rich cell reads them. The spans
|
|
149
|
+
* are integers >= 1 here; whether they fit the grid is judged where the slot occurs
|
|
150
|
+
* (`wrunTableSpanCoverage`), since a slot may be listed at more than one grid cell. */
|
|
151
|
+
export function readWrunTableCellSurfaceStyle(label, style) {
|
|
152
|
+
const surface = {};
|
|
153
|
+
if (style.colspan !== undefined)
|
|
154
|
+
surface.colspan = readWrunTableSpan(label, 'colspan', style.colspan);
|
|
155
|
+
if (style.rowspan !== undefined)
|
|
156
|
+
surface.rowspan = readWrunTableSpan(label, 'rowspan', style.rowspan);
|
|
157
|
+
const valign = word(label, 'valign', style.valign, WRUN_TABLE_VALIGNS);
|
|
158
|
+
if (valign !== undefined)
|
|
159
|
+
surface.valign = valign;
|
|
160
|
+
const fontSize = finite(label, 'font_size', style.font_size, { min: 0, minExclusive: true });
|
|
161
|
+
if (fontSize !== undefined)
|
|
162
|
+
surface.fontSize = fontSize;
|
|
163
|
+
const fontWeight = word(label, 'font_weight', style.font_weight, WRUN_TABLE_FONT_WEIGHTS);
|
|
164
|
+
if (fontWeight !== undefined)
|
|
165
|
+
surface.fontWeight = fontWeight;
|
|
166
|
+
const opacity = finite(label, 'opacity', style.opacity, { min: 0, max: 1 });
|
|
167
|
+
if (opacity !== undefined)
|
|
168
|
+
surface.opacity = opacity;
|
|
169
|
+
const stops = gradient(label, 'gradient', style.gradient);
|
|
170
|
+
if (stops !== undefined)
|
|
171
|
+
surface.gradient = stops;
|
|
172
|
+
const gradientDirection = word(label, 'gradient_direction', style.gradient_direction, WRUN_TABLE_GRADIENT_DIRECTIONS);
|
|
173
|
+
if (gradientDirection !== undefined)
|
|
174
|
+
surface.gradientDirection = gradientDirection;
|
|
175
|
+
return surface;
|
|
176
|
+
}
|
|
177
|
+
/** The grid cells the spans hide, walked in grid order the way the engine lays the rows out: a
|
|
178
|
+
* cell that mounts (not under an earlier span) extends coverage over its block, judged against
|
|
179
|
+
* its own place (a span past the grid refuses by name), and a covered cell's own span is
|
|
180
|
+
* ignored. So a slot listed at several grid cells spans at each occurrence, two spanning cells
|
|
181
|
+
* never share a row, and a cell under another span never hides a third one. `spans` maps a
|
|
182
|
+
* slot to its colspan / rowspan (absent = 1); `cells` is the table's slot per grid cell. */
|
|
183
|
+
export function wrunTableSpanCoverage(label, cells, spans, grid) {
|
|
184
|
+
const covered = new Set();
|
|
185
|
+
const total = grid.rows * grid.cols;
|
|
186
|
+
for (let at = 0; at < cells.length && at < total; at += 1) {
|
|
187
|
+
if (covered.has(at))
|
|
188
|
+
continue;
|
|
189
|
+
const slot = cells[at];
|
|
190
|
+
const span = spans.get(slot);
|
|
191
|
+
if (span === undefined)
|
|
192
|
+
continue;
|
|
193
|
+
const colspan = span.colspan ?? 1;
|
|
194
|
+
const rowspan = span.rowspan ?? 1;
|
|
195
|
+
if (colspan === 1 && rowspan === 1)
|
|
196
|
+
continue;
|
|
197
|
+
const row = Math.floor(at / grid.cols);
|
|
198
|
+
const col = at % grid.cols;
|
|
199
|
+
if (col + colspan > grid.cols) {
|
|
200
|
+
throw new Error(`${label}.${slot} colspan ${colspan} runs past the grid from column ${col + 1} of ${grid.cols}`);
|
|
201
|
+
}
|
|
202
|
+
if (row + rowspan > grid.rows) {
|
|
203
|
+
throw new Error(`${label}.${slot} rowspan ${rowspan} runs past the grid from row ${row + 1} of ${grid.rows}`);
|
|
204
|
+
}
|
|
205
|
+
for (const index of wrunTableCoveredCells(at, span, grid.cols))
|
|
206
|
+
covered.add(index);
|
|
207
|
+
}
|
|
208
|
+
return covered;
|
|
209
|
+
}
|
|
210
|
+
/** The grid indexes a spanning cell covers besides its own (the next colspan - 1 cells of its
|
|
211
|
+
* row and the rowspan - 1 rows below, as a block): the engine's row carries only the spanning
|
|
212
|
+
* cell, so they never mount. Indexes past the grid are never produced (the spans were checked). */
|
|
213
|
+
export function wrunTableCoveredCells(at, span, cols) {
|
|
214
|
+
const covered = [];
|
|
215
|
+
const colspan = span.colspan ?? 1;
|
|
216
|
+
const rowspan = span.rowspan ?? 1;
|
|
217
|
+
for (let dr = 0; dr < rowspan; dr += 1) {
|
|
218
|
+
for (let dc = 0; dc < colspan; dc += 1) {
|
|
219
|
+
if (dr === 0 && dc === 0)
|
|
220
|
+
continue;
|
|
221
|
+
covered.push(at + dr * cols + dc);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return covered;
|
|
225
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The looks of `render.text` and `render.label` (WRUN-STYLE g4 DW26, DW27;
|
|
3
|
+
* freeze 3.5.3): the declared look keys of a text or point label renderer
|
|
4
|
+
* mapped to the engine's plotPriceLabel / plotText payload fields, and a
|
|
5
|
+
* corner label's look mapped to the engine's plotLabel payload (TextPlot
|
|
6
|
+
* Label). The run-result adapter merges the fields over its own payload
|
|
7
|
+
* (spread the look AFTER the payload: a corner label's `x` / `y` are the
|
|
8
|
+
* offset in px, never the declared point).
|
|
9
|
+
*
|
|
10
|
+
* Font words resolve here to the CSS stacks of the foundation (X14: the
|
|
11
|
+
* engine never sees a font word), weights to CSS weights. Colour words ride
|
|
12
|
+
* unresolved (tokens resolve at the mount door, TH-theme-tokens). Every key
|
|
13
|
+
* is opt-in: an absent key puts nothing on the payload, so today's look
|
|
14
|
+
* stays the default.
|
|
15
|
+
*
|
|
16
|
+
* The cross-key rules the om schema refuses are restated by name (X22): a
|
|
17
|
+
* tag key on plain text, `align` / `valign` on a tag look, `x_align` beside
|
|
18
|
+
* `align`, `offset` without a corner `position`.
|
|
19
|
+
*/
|
|
20
|
+
/** A declared text or label renderer, read as parsed JSON: the interface
|
|
21
|
+
* types the keys, the sheet on disk may carry anything. */
|
|
22
|
+
export type WrunTextLookRenderer = {
|
|
23
|
+
kind: string;
|
|
24
|
+
name: string;
|
|
25
|
+
} & Record<string, unknown>;
|
|
26
|
+
/** Bound on a corner label's `offset` nudge, px either way (DW27). */
|
|
27
|
+
export declare const WRUN_MAX_LABEL_OFFSET_PX = 200;
|
|
28
|
+
/** The plotPriceLabel (tag looks) or plotText (plain) payload fields of a
|
|
29
|
+
* `render.text` or point `render.label` declaration (DW26): a tag look
|
|
30
|
+
* (`price_label`, `box`, `knockout`, `emblem`, `pill`, `badge`, `callout`)
|
|
31
|
+
* carries the look's `type` / `shape` / `border` from `wrunTextStyleLook`,
|
|
32
|
+
* `label_position` as `position`, `background_color` as `backgroundColor`,
|
|
33
|
+
* `border_color` as `border` (a stroke colour, over the badge's text-colour
|
|
34
|
+
* stroke), `corner_radius` as `radius`, the font fields and the emblem;
|
|
35
|
+
* plain text carries `align` / `valign` as `xAlign` / `yAlign` and the font
|
|
36
|
+
* fields. The per-row ladders (`size_by`, `color_by`, `background_color_by`)
|
|
37
|
+
* stay the adapter's. A tag key on plain text, `align` / `valign` on a tag
|
|
38
|
+
* look and `x_align` / `y_align` beside `align` / `valign` refuse by name. */
|
|
39
|
+
export declare function wrunTextLookPayload(renderer: WrunTextLookRenderer, sheetId: string): Record<string, unknown>;
|
|
40
|
+
/** The plotLabel (TextPlot Label) payload fields of a corner `render.label`
|
|
41
|
+
* declaration (DW27): `x` / `y` are the `offset` in px (null without one,
|
|
42
|
+
* never the declared point, so a published sheet with a point beside the
|
|
43
|
+
* position keeps loading and sits at the corner), `style` is the look
|
|
44
|
+
* (`plain`, `box`, `knockout`, `emblem`, `pill`, `badge`; a published
|
|
45
|
+
* `price_label` or `callout` draws as `box`), `background_color` as
|
|
46
|
+
* `backgroundColor`, `corner_radius` as `radius`, `border_color` as
|
|
47
|
+
* `borderColor`, `padding`, the font fields (an absent `font_family` keeps
|
|
48
|
+
* the engine's Arial), `align` / `valign` as `xAlign` / `yAlign` over the
|
|
49
|
+
* corner defaults, the emblem. `offset` without a corner position refuses
|
|
50
|
+
* by name. */
|
|
51
|
+
export declare function wrunCornerLabelLook(renderer: WrunTextLookRenderer, sheetId: string): Record<string, unknown>;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The looks of `render.text` and `render.label` (WRUN-STYLE g4 DW26, DW27;
|
|
3
|
+
* freeze 3.5.3): the declared look keys of a text or point label renderer
|
|
4
|
+
* mapped to the engine's plotPriceLabel / plotText payload fields, and a
|
|
5
|
+
* corner label's look mapped to the engine's plotLabel payload (TextPlot
|
|
6
|
+
* Label). The run-result adapter merges the fields over its own payload
|
|
7
|
+
* (spread the look AFTER the payload: a corner label's `x` / `y` are the
|
|
8
|
+
* offset in px, never the declared point).
|
|
9
|
+
*
|
|
10
|
+
* Font words resolve here to the CSS stacks of the foundation (X14: the
|
|
11
|
+
* engine never sees a font word), weights to CSS weights. Colour words ride
|
|
12
|
+
* unresolved (tokens resolve at the mount door, TH-theme-tokens). Every key
|
|
13
|
+
* is opt-in: an absent key puts nothing on the payload, so today's look
|
|
14
|
+
* stays the default.
|
|
15
|
+
*
|
|
16
|
+
* The cross-key rules the om schema refuses are restated by name (X22): a
|
|
17
|
+
* tag key on plain text, `align` / `valign` on a tag look, `x_align` beside
|
|
18
|
+
* `align`, `offset` without a corner `position`.
|
|
19
|
+
*/
|
|
20
|
+
import { readWrunPresentationStyle, WRUN_CORNER_RADIUS_MAX, WRUN_EMBLEM_SHAPES, WRUN_LABEL_ALIGNS, WRUN_LABEL_LOOKS, WRUN_LABEL_POSITIONS, WRUN_THEME_TOKEN_MESSAGE, WRUN_VALIGNS, WRUN3_MAX_PADDING_PX, wrunTextStyleIsPriceLabel, wrunTextStyleLook, } from './wrun-handles.util.js';
|
|
21
|
+
import { isWrunColorWord, WRUN_FONT_FAMILIES, WRUN_FONT_WEIGHTS, wrunFontFamilyCss, wrunFontWeightCss, } from './wrun-style-words.util.js';
|
|
22
|
+
/** Bound on a corner label's `offset` nudge, px either way (DW27). */
|
|
23
|
+
export const WRUN_MAX_LABEL_OFFSET_PX = 200;
|
|
24
|
+
const MAX_COLOR_CHARS = 64;
|
|
25
|
+
const WRUN_THEME_TOKEN_PREFIX = 'theme.';
|
|
26
|
+
/** The keys that paint a price tag rather than plain text (DW26): on plain
|
|
27
|
+
* text they are refused by name, as the om schema refuses them. */
|
|
28
|
+
const TEXT_TAG_KEYS = [
|
|
29
|
+
'label_position',
|
|
30
|
+
'background_color',
|
|
31
|
+
'background_color_by',
|
|
32
|
+
'background_colors',
|
|
33
|
+
'border_color',
|
|
34
|
+
'corner_radius',
|
|
35
|
+
'emblem_shape',
|
|
36
|
+
'emblem_color',
|
|
37
|
+
];
|
|
38
|
+
const LABEL_TAG_KEYS = ['background_color', 'border_color', 'corner_radius', 'emblem_shape', 'emblem_color'];
|
|
39
|
+
const PLAIN_KEYS = ['align', 'valign'];
|
|
40
|
+
/** The corner looks (DW27): `price_label` and `callout` sit at a point, so a
|
|
41
|
+
* published corner label with one draws as `box`. */
|
|
42
|
+
const CORNER_POINT_LOOKS = ['price_label', 'callout'];
|
|
43
|
+
/** Field readers over one renderer; every refusal names the sheet, the
|
|
44
|
+
* renderer and the key. */
|
|
45
|
+
class WrunLookFields {
|
|
46
|
+
prefix;
|
|
47
|
+
entry;
|
|
48
|
+
constructor(prefix, entry) {
|
|
49
|
+
this.prefix = prefix;
|
|
50
|
+
this.entry = entry;
|
|
51
|
+
}
|
|
52
|
+
refuse(field, requirement) {
|
|
53
|
+
throw new Error(`${this.prefix} ${field} ${requirement}`);
|
|
54
|
+
}
|
|
55
|
+
has(field) {
|
|
56
|
+
return this.entry[field] !== undefined;
|
|
57
|
+
}
|
|
58
|
+
isNumber(field) {
|
|
59
|
+
return typeof this.entry[field] === 'number';
|
|
60
|
+
}
|
|
61
|
+
word(field, words) {
|
|
62
|
+
const value = this.entry[field];
|
|
63
|
+
if (value === undefined)
|
|
64
|
+
return undefined;
|
|
65
|
+
if (typeof value !== 'string' || !words.includes(value)) {
|
|
66
|
+
this.refuse(field, `must be one of ${words.join(', ')}`);
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
/** The handles' colour grammar made token-aware (X12). */
|
|
71
|
+
color(field) {
|
|
72
|
+
const value = this.entry[field];
|
|
73
|
+
if (value === undefined)
|
|
74
|
+
return undefined;
|
|
75
|
+
if (typeof value === 'string' && value.startsWith(WRUN_THEME_TOKEN_PREFIX)) {
|
|
76
|
+
if (!isWrunColorWord(value))
|
|
77
|
+
this.refuse(field, WRUN_THEME_TOKEN_MESSAGE);
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
if (typeof value !== 'string' || value.length === 0 || value.length > MAX_COLOR_CHARS) {
|
|
81
|
+
this.refuse(field, `must be a non-empty color string of at most ${MAX_COLOR_CHARS} chars`);
|
|
82
|
+
}
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
number(field, min, max, integer = false) {
|
|
86
|
+
const value = this.entry[field];
|
|
87
|
+
if (value === undefined)
|
|
88
|
+
return undefined;
|
|
89
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value < min || value > max) {
|
|
90
|
+
this.refuse(field, `must be a number in ${min}..${max}`);
|
|
91
|
+
}
|
|
92
|
+
if (integer && !Number.isInteger(value))
|
|
93
|
+
this.refuse(field, 'must be an integer');
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
/** `offset: [x, y]`, integers within -200..200 px (DW27). */
|
|
97
|
+
offset(field) {
|
|
98
|
+
const value = this.entry[field];
|
|
99
|
+
if (value === undefined)
|
|
100
|
+
return undefined;
|
|
101
|
+
const message = `must be [x, y], integers within -${WRUN_MAX_LABEL_OFFSET_PX}..${WRUN_MAX_LABEL_OFFSET_PX} px`;
|
|
102
|
+
if (!Array.isArray(value) || value.length !== 2)
|
|
103
|
+
this.refuse(field, message);
|
|
104
|
+
const [x, y] = value;
|
|
105
|
+
for (const part of [x, y]) {
|
|
106
|
+
if (typeof part !== 'number' ||
|
|
107
|
+
!Number.isInteger(part) ||
|
|
108
|
+
part < -WRUN_MAX_LABEL_OFFSET_PX ||
|
|
109
|
+
part > WRUN_MAX_LABEL_OFFSET_PX) {
|
|
110
|
+
this.refuse(field, message);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return [x, y];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function put(payload, key, value) {
|
|
117
|
+
if (value !== undefined)
|
|
118
|
+
payload[key] = value;
|
|
119
|
+
}
|
|
120
|
+
/** The font fields a look shares (DW08): the CSS weight and the CSS stack of
|
|
121
|
+
* the declared words. A NUMERIC `font_weight` is the price-label reader's
|
|
122
|
+
* (the run-result adapter's readWrunPriceLabelLook: the engine's clamp on a
|
|
123
|
+
* tag, refused by name on plain text), so only a string is read here. */
|
|
124
|
+
function fontPayload(fields) {
|
|
125
|
+
const payload = {};
|
|
126
|
+
if (!fields.isNumber('font_weight')) {
|
|
127
|
+
put(payload, 'fontWeight', wrunFontWeightCss(fields.word('font_weight', WRUN_FONT_WEIGHTS)));
|
|
128
|
+
}
|
|
129
|
+
put(payload, 'fontFamily', wrunFontFamilyCss(fields.word('font_family', WRUN_FONT_FAMILIES)));
|
|
130
|
+
return payload;
|
|
131
|
+
}
|
|
132
|
+
/** The box fields of a tag look shared by the tag payload and the corner
|
|
133
|
+
* label (DW07, DW26, DW27): the background, the border colour (`borderKey`
|
|
134
|
+
* names the engine field: plotPriceLabel `border`, plotLabel
|
|
135
|
+
* `borderColor`), the corner radius and the emblem. */
|
|
136
|
+
function tagPayload(fields, borderKey) {
|
|
137
|
+
const payload = {};
|
|
138
|
+
put(payload, 'backgroundColor', fields.color('background_color'));
|
|
139
|
+
put(payload, borderKey, fields.color('border_color'));
|
|
140
|
+
put(payload, 'radius', fields.number('corner_radius', 0, WRUN_CORNER_RADIUS_MAX));
|
|
141
|
+
put(payload, 'emblemShape', fields.word('emblem_shape', WRUN_EMBLEM_SHAPES));
|
|
142
|
+
put(payload, 'emblemColor', fields.color('emblem_color'));
|
|
143
|
+
return payload;
|
|
144
|
+
}
|
|
145
|
+
function refusePresent(fields, keys, requirement) {
|
|
146
|
+
for (const key of keys)
|
|
147
|
+
if (fields.has(key))
|
|
148
|
+
fields.refuse(key, requirement(key));
|
|
149
|
+
}
|
|
150
|
+
/** The plotPriceLabel (tag looks) or plotText (plain) payload fields of a
|
|
151
|
+
* `render.text` or point `render.label` declaration (DW26): a tag look
|
|
152
|
+
* (`price_label`, `box`, `knockout`, `emblem`, `pill`, `badge`, `callout`)
|
|
153
|
+
* carries the look's `type` / `shape` / `border` from `wrunTextStyleLook`,
|
|
154
|
+
* `label_position` as `position`, `background_color` as `backgroundColor`,
|
|
155
|
+
* `border_color` as `border` (a stroke colour, over the badge's text-colour
|
|
156
|
+
* stroke), `corner_radius` as `radius`, the font fields and the emblem;
|
|
157
|
+
* plain text carries `align` / `valign` as `xAlign` / `yAlign` and the font
|
|
158
|
+
* fields. The per-row ladders (`size_by`, `color_by`, `background_color_by`)
|
|
159
|
+
* stay the adapter's. A tag key on plain text, `align` / `valign` on a tag
|
|
160
|
+
* look and `x_align` / `y_align` beside `align` / `valign` refuse by name. */
|
|
161
|
+
export function wrunTextLookPayload(renderer, sheetId) {
|
|
162
|
+
const kind = renderer.kind === 'label' ? 'label' : 'text';
|
|
163
|
+
const name = String(renderer.name);
|
|
164
|
+
const fields = new WrunLookFields(`Indicator ${sheetId}: ${kind} renderer '${name}'`, renderer);
|
|
165
|
+
const style = readWrunPresentationStyle(sheetId, kind, name, renderer.style);
|
|
166
|
+
const payload = {};
|
|
167
|
+
if (wrunTextStyleIsPriceLabel(style)) {
|
|
168
|
+
refusePresent(fields, PLAIN_KEYS, () => `must sit on plain text, not on style '${style}' (a price-tag look is placed by its own keys)`);
|
|
169
|
+
const look = wrunTextStyleLook(style);
|
|
170
|
+
if (look !== undefined) {
|
|
171
|
+
payload.type = look.type;
|
|
172
|
+
put(payload, 'shape', look.shape);
|
|
173
|
+
put(payload, 'border', look.border);
|
|
174
|
+
}
|
|
175
|
+
put(payload, 'position', fields.word('label_position', WRUN_LABEL_ALIGNS));
|
|
176
|
+
Object.assign(payload, tagPayload(fields, 'border'), fontPayload(fields));
|
|
177
|
+
if (kind === 'label')
|
|
178
|
+
put(payload, 'padding', fields.number('padding', 0, WRUN3_MAX_PADDING_PX));
|
|
179
|
+
return payload;
|
|
180
|
+
}
|
|
181
|
+
refusePresent(fields, kind === 'label' ? LABEL_TAG_KEYS : TEXT_TAG_KEYS, () => 'must sit on a price-tag look (a style other than plain), not on plain text');
|
|
182
|
+
for (const [word, legacy] of [
|
|
183
|
+
['align', 'x_align'],
|
|
184
|
+
['valign', 'y_align'],
|
|
185
|
+
]) {
|
|
186
|
+
if (fields.has(word) && fields.has(legacy))
|
|
187
|
+
fields.refuse(legacy, `and ${word} are one key; declare one spelling`);
|
|
188
|
+
}
|
|
189
|
+
put(payload, 'xAlign', fields.word('align', WRUN_LABEL_ALIGNS));
|
|
190
|
+
put(payload, 'yAlign', fields.word('valign', WRUN_VALIGNS));
|
|
191
|
+
Object.assign(payload, fontPayload(fields));
|
|
192
|
+
return payload;
|
|
193
|
+
}
|
|
194
|
+
/** The plotLabel (TextPlot Label) payload fields of a corner `render.label`
|
|
195
|
+
* declaration (DW27): `x` / `y` are the `offset` in px (null without one,
|
|
196
|
+
* never the declared point, so a published sheet with a point beside the
|
|
197
|
+
* position keeps loading and sits at the corner), `style` is the look
|
|
198
|
+
* (`plain`, `box`, `knockout`, `emblem`, `pill`, `badge`; a published
|
|
199
|
+
* `price_label` or `callout` draws as `box`), `background_color` as
|
|
200
|
+
* `backgroundColor`, `corner_radius` as `radius`, `border_color` as
|
|
201
|
+
* `borderColor`, `padding`, the font fields (an absent `font_family` keeps
|
|
202
|
+
* the engine's Arial), `align` / `valign` as `xAlign` / `yAlign` over the
|
|
203
|
+
* corner defaults, the emblem. `offset` without a corner position refuses
|
|
204
|
+
* by name. */
|
|
205
|
+
export function wrunCornerLabelLook(renderer, sheetId) {
|
|
206
|
+
const name = String(renderer.name);
|
|
207
|
+
const fields = new WrunLookFields(`Indicator ${sheetId}: label renderer '${name}'`, renderer);
|
|
208
|
+
const position = fields.word('position', WRUN_LABEL_POSITIONS);
|
|
209
|
+
const offset = fields.offset('offset');
|
|
210
|
+
if (offset !== undefined && position === undefined) {
|
|
211
|
+
fields.refuse('offset', 'must sit beside a corner position (a corner label is nudged by offset)');
|
|
212
|
+
}
|
|
213
|
+
const payload = {
|
|
214
|
+
x: offset === undefined ? null : offset[0],
|
|
215
|
+
y: offset === undefined ? null : offset[1],
|
|
216
|
+
};
|
|
217
|
+
const style = fields.word('style', [...WRUN_LABEL_LOOKS, ...CORNER_POINT_LOOKS]);
|
|
218
|
+
if (style !== undefined) {
|
|
219
|
+
payload.style = CORNER_POINT_LOOKS.includes(style) ? 'box' : style;
|
|
220
|
+
}
|
|
221
|
+
Object.assign(payload, tagPayload(fields, 'borderColor'));
|
|
222
|
+
put(payload, 'padding', fields.number('padding', 0, WRUN3_MAX_PADDING_PX));
|
|
223
|
+
Object.assign(payload, fontPayload(fields));
|
|
224
|
+
put(payload, 'xAlign', fields.word('align', WRUN_LABEL_ALIGNS));
|
|
225
|
+
put(payload, 'yAlign', fields.word('valign', WRUN_VALIGNS));
|
|
226
|
+
return payload;
|
|
227
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed text settings (wrun-5, openmarket docs/WRUN5_ABI.md, the capability
|
|
3
|
+
* round's section 3): the sheet contract's plain-text rule and byte caps,
|
|
4
|
+
* mirrored from the kit package's runtime entry, the shared host
|
|
5
|
+
* (`wrunHostPlainText`, the ABI tables' two caps, the channel's import and
|
|
6
|
+
* refusal names) so the dialog, the run path, the hosted-lane maps and the
|
|
7
|
+
* sandbox worker apply ONE rule from an import-free leaf the kScript socket
|
|
8
|
+
* worker and the boot graph may read (neither loads a package).
|
|
9
|
+
* tests/utility/wrun/wrun-text-params.kit-mirror.spec.ts pins every mirrored
|
|
10
|
+
* value against the installed host entry, code point by code point.
|
|
11
|
+
*
|
|
12
|
+
* The host owns the typed value and applies the rule BEFORE it reaches the
|
|
13
|
+
* module, the dialog, a legend, an alert arm or a cloud run:
|
|
14
|
+
* 1. CRLF and CR become LF.
|
|
15
|
+
* 2. Every Unicode format character goes (the bidi controls U+202A..U+202E
|
|
16
|
+
* and U+2066..U+2069, the zero-width characters, the byte order mark, the
|
|
17
|
+
* soft hyphen, the invisible operators, the rest of Cf), and every
|
|
18
|
+
* control character but the newline (C0, DEL, C1).
|
|
19
|
+
* 3. On a one-line setting (`multiline` absent or false) every newline
|
|
20
|
+
* becomes a space.
|
|
21
|
+
* 4. The bytes are bounded by the param's `max_bytes`: a longer value is
|
|
22
|
+
* refused at the dialog and never truncated silently; a persisted value
|
|
23
|
+
* over its cap (saved under an older, wider cap) reads as the declared
|
|
24
|
+
* default.
|
|
25
|
+
* The result is plain text wherever it is shown (never HTML, markdown or a
|
|
26
|
+
* link) and is never re-read as a template.
|
|
27
|
+
*
|
|
28
|
+
* Worker-safe on purpose (types only): the sandbox worker and the kScript
|
|
29
|
+
* socket worker read it, and neither graph may reach i18n or the chart
|
|
30
|
+
* constants (tests/workers/worker-runtime-boundary.spec.ts).
|
|
31
|
+
*/
|
|
32
|
+
import type { WrunIndicatorMetadata, WrunMetadataParam } from '../../interfaces/wrun-runtime.interface.js';
|
|
33
|
+
/** The bytes one text setting may carry (the string-slot cap, so a slot can
|
|
34
|
+
* echo a setting whole) and the cap a declaration gets when it names none
|
|
35
|
+
* (the shared host's ABI tables, maxTextParamBytes / defaultTextParamBytes). */
|
|
36
|
+
export declare const WRUN_MAX_TEXT_PARAM_BYTES = 4096;
|
|
37
|
+
export declare const WRUN_DEFAULT_TEXT_PARAM_BYTES = 256;
|
|
38
|
+
/** The characters a host strips from typed text at its boundary (the kit's
|
|
39
|
+
* WRUN_TEXT_DISGUISE_PATTERN, a pattern for the `u` flag, what the shared
|
|
40
|
+
* host's wrunHostPlainText strips): every Unicode format character and every
|
|
41
|
+
* control character but the newline. */
|
|
42
|
+
export declare const WRUN_TEXT_DISGUISE_PATTERN = "[\\p{Cf}\\u0000-\\u0009\\u000b-\\u001f\\u007f-\\u009f]";
|
|
43
|
+
/** The wrun-5 text channel's two imports (the ones the shared host links under wrun-5). */
|
|
44
|
+
export declare const WRUN5_TEXT_IMPORTS: readonly ["wrun:wrun_param_len", "wrun:wrun_param_bytes"];
|
|
45
|
+
/** The refusal names a host raises on the text channel (codes of the shared
|
|
46
|
+
* host's refusal table), one per rule. */
|
|
47
|
+
export declare const WRUN5_TEXT_REFUSALS: {
|
|
48
|
+
/** A text import called outside init(). */
|
|
49
|
+
readonly phase: "wrun_text_param_phase";
|
|
50
|
+
/** The copy would land outside the module's exported memory. */
|
|
51
|
+
readonly memory: "wrun_text_param_memory";
|
|
52
|
+
};
|
|
53
|
+
/** Plain text, the way every host hands it on: CRLF and CR become LF, the
|
|
54
|
+
* disguise characters are removed, and on a one-line setting every newline
|
|
55
|
+
* becomes a space. What a module reads, a dialog shows and a legend carries. */
|
|
56
|
+
export declare function wrunPlainText(text: string, options?: {
|
|
57
|
+
multiline?: boolean;
|
|
58
|
+
}): string;
|
|
59
|
+
/** True when the text carries a character {@link wrunPlainText} would remove
|
|
60
|
+
* (or a newline on a one-line setting). */
|
|
61
|
+
export declare function wrunTextHasDisguise(text: string, options?: {
|
|
62
|
+
multiline?: boolean;
|
|
63
|
+
}): boolean;
|
|
64
|
+
/** The UTF-8 byte length of a text: the unit a text param's init slot and
|
|
65
|
+
* its `max_bytes` speak in. */
|
|
66
|
+
export declare function wrunTextByteLength(text: string): number;
|
|
67
|
+
/** A value inserted into a legend suffix as LITERAL text (guards G1 and G4):
|
|
68
|
+
* every HTML special and `$` as its entity, so the innerHTML legend shows
|
|
69
|
+
* the characters themselves, never a link, an image or a re-expanded token. */
|
|
70
|
+
export declare function wrunLegendLiteral(text: string): string;
|
|
71
|
+
/** The inverse of {@link wrunLegendLiteral} for a consumer that renders the
|
|
72
|
+
* suffix as text (the indicator menu's inputs line): the six entities back
|
|
73
|
+
* to their characters, `&` last so a literal `<` typed by a user
|
|
74
|
+
* (escaped as `&lt;`) comes back as `<`, not `<`. */
|
|
75
|
+
export declare function wrunLegendLiteralText(text: string): string;
|
|
76
|
+
/** A sheet param (or a declaration row) of the text kind. */
|
|
77
|
+
export declare function isWrunTextParam(param: Pick<WrunMetadataParam, 'type'>): boolean;
|
|
78
|
+
/** The byte cap a text param enforces: its `max_bytes` when it is an integer
|
|
79
|
+
* within the contract's bounds, else the default cap. */
|
|
80
|
+
export declare function wrunTextParamCap(param: Pick<WrunMetadataParam, 'max_bytes'>): number;
|
|
81
|
+
/** The declared words of a text param, plain (a published sheet carries none
|
|
82
|
+
* of the stripped characters; the rule is applied again so a hand-edited
|
|
83
|
+
* sheet cannot smuggle one in). */
|
|
84
|
+
export declare function wrunTextParamDefault(param: Pick<WrunMetadataParam, 'text_default' | 'multiline'>): string;
|
|
85
|
+
/** A typed value as the host hands it on: plain text within the cap, or
|
|
86
|
+
* undefined when the value is not a string or its plain bytes are over the
|
|
87
|
+
* cap (the caller decides what stands in: the dialog refuses the edit, the
|
|
88
|
+
* run path reads the declared default). */
|
|
89
|
+
export declare function wrunTextValueWithinCap(raw: unknown, options: {
|
|
90
|
+
multiline?: boolean;
|
|
91
|
+
maxBytes?: number;
|
|
92
|
+
}): string | undefined;
|
|
93
|
+
/** One text param's run value from its flat setting: the stored string plain
|
|
94
|
+
* and within the cap, else the declared default. */
|
|
95
|
+
export declare function wrunTextParamValue(param: Pick<WrunMetadataParam, 'text_default' | 'max_bytes' | 'multiline'>, raw: unknown): string;
|
|
96
|
+
/** Every text param's run value by name (the ONE derivation the init slot's
|
|
97
|
+
* byte count, the text channel's bytes, the legend title and the hosted
|
|
98
|
+
* lanes' maps all read): the overlay's flat setting plain and within the
|
|
99
|
+
* cap, else the declared default. Empty for a sheet without text params. */
|
|
100
|
+
export declare function wrunTextParamValuesFromSettings(metadata: Pick<WrunIndicatorMetadata, 'params'>, settings: unknown): Record<string, string>;
|
|
101
|
+
/** The run request's text channel: the UTF-8 bytes of every text param keyed
|
|
102
|
+
* by its init slot (the param's index in `metadata.params`, the index
|
|
103
|
+
* `wrun_param_len` takes), derived from the same values the init slots'
|
|
104
|
+
* byte counts read. Undefined for a sheet without text params, so a
|
|
105
|
+
* wrun-1..4 request stays byte-identical to before. */
|
|
106
|
+
export declare function wrunTextParamsForRun(metadata: Pick<WrunIndicatorMetadata, 'params'>, settings: unknown): Record<number, Uint8Array> | undefined;
|