@orangecharts/wrun-chart-host 0.14.0 → 0.16.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 +1 -0
- package/dist/constants/economic.constants.d.ts +2 -0
- package/dist/constants/economic.constants.js +2 -0
- package/dist/constants/feature-flags.constants.d.ts +11 -0
- package/dist/constants/feature-flags.constants.js +56 -4
- package/dist/constants/feature-limits.constants.d.ts +72 -4
- package/dist/constants/feature-limits.constants.js +98 -20
- package/dist/constants/interval.constants.js +5 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +12 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.js +14 -0
- package/dist/constants/typed-width-fold.leaf.d.ts +50 -0
- package/dist/constants/typed-width-fold.leaf.js +99 -0
- package/dist/constants/typed-width-source.leaf.d.ts +24 -0
- package/dist/constants/typed-width-source.leaf.js +126 -0
- package/dist/constants/typed-width.leaf.d.ts +57 -0
- package/dist/constants/typed-width.leaf.js +78 -0
- package/dist/host-env.d.ts +24 -0
- package/dist/host-env.js +22 -0
- package/dist/host-ports.types.d.ts +11 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +28 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +107 -4
- package/dist/interfaces/wrun-runtime.interface.js +11 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
- package/dist/market-data/billing.interface.d.ts +12 -45
- package/dist/market-data/billing.interface.js +2 -2
- package/dist/market-data/venues/index.d.ts +2 -2
- package/dist/market-data/venues/opra.js +3 -3
- package/dist/market-data/venues/stocks.contract.copy.json +3 -2
- package/dist/market-data/venues/stocks.d.ts +2 -2
- package/dist/market-data/venues/stocks.js +10 -9
- package/dist/replay/replayLadder.js +7 -4
- package/dist/settings-templates/footprint-rows.d.ts +6 -0
- package/dist/settings-templates/footprint-rows.js +6 -0
- package/dist/settings-templates/frvp-fields.js +14 -0
- package/dist/settings-templates/indicator-fields.js +46 -0
- package/dist/settings-templates/tool-tables.generated.js +19 -1
- package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
- package/dist/utility/chart/cache-alignment.util.d.ts +65 -0
- package/dist/utility/chart/cache-alignment.util.js +124 -24
- package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
- package/dist/utility/chart/calendar-interval.util.js +152 -4
- package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
- package/dist/utility/chart/candle-bar-end.util.js +17 -6
- package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
- package/dist/utility/chart/chart-time-domain.util.js +13 -4
- package/dist/utility/chart/feed-interval.util.d.ts +4 -2
- package/dist/utility/chart/feed-interval.util.js +5 -2
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
- package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
- package/dist/utility/chart/footprint-band.util.d.ts +21 -5
- package/dist/utility/chart/footprint-band.util.js +53 -14
- package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
- package/dist/utility/chart/footprint-display-mode.util.js +5 -0
- package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
- package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
- package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
- package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
- package/dist/utility/chart/history-wall.util.d.ts +13 -2
- package/dist/utility/chart/history-wall.util.js +11 -4
- package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
- package/dist/utility/chart/interval-ladder.util.js +44 -4
- package/dist/utility/chart/interval-registry.util.d.ts +22 -1
- package/dist/utility/chart/interval-registry.util.js +50 -2
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
- package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
- package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
- package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
- package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
- package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
- package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
- package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
- package/dist/utility/chart/live-bucket.util.d.ts +29 -4
- package/dist/utility/chart/live-bucket.util.js +45 -12
- package/dist/utility/chart/market-session.util.d.ts +62 -10
- package/dist/utility/chart/market-session.util.js +93 -13
- package/dist/utility/chart/marketKind.util.d.ts +1 -7
- package/dist/utility/chart/marketKind.util.js +6 -8
- package/dist/utility/chart/mixed-mode.util.d.ts +17 -0
- package/dist/utility/chart/om-target.util.js +6 -4
- package/dist/utility/chart/price-precision.util.d.ts +20 -6
- package/dist/utility/chart/price-precision.util.js +34 -7
- package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
- package/dist/utility/chart/profile-frame-window.util.js +12 -0
- package/dist/utility/chart/rth-session.util.d.ts +3 -1
- package/dist/utility/chart/rth-session.util.js +3 -1
- package/dist/utility/chart/script-source-session.util.d.ts +43 -0
- package/dist/utility/chart/script-source-session.util.js +61 -0
- package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
- package/dist/utility/chart/typed-width-grid.util.js +203 -0
- package/dist/utility/chart/wrun-run-result.util.d.ts +9 -1
- package/dist/utility/chart/wrun-run-result.util.js +8 -2
- package/dist/utility/common/transformations.util.d.ts +6 -0
- package/dist/utility/common/transformations.util.js +28 -4
- package/dist/utility/number-format.util.d.ts +14 -1
- package/dist/utility/number-format.util.js +22 -4
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +113 -0
- package/dist/utility/v2/v2-enums.leaf.js +3 -0
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +15 -5
- package/dist/utility/wrun/wrun-batched-marks.util.js +70 -20
- package/dist/utility/wrun/wrun-canvases.util.d.ts +28 -9
- package/dist/utility/wrun/wrun-canvases.util.js +99 -39
- package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
- package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
- package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-card-style.util.js +2 -2
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +8 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +13 -1
- package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
- package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
- package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
- package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
- package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
- package/dist/utility/wrun/wrun-frames.d.ts +1 -1
- package/dist/utility/wrun/wrun-frames.js +2 -2
- package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-handles.util.js +1 -1
- package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
- package/dist/utility/wrun/wrun-host.service.js +44 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
- package/dist/utility/wrun/wrun-hover.util.d.ts +8 -2
- package/dist/utility/wrun/wrun-hover.util.js +24 -13
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
- package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
- package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
- package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
- package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
- package/dist/utility/wrun/wrun-live-tick.util.js +81 -19
- package/dist/utility/wrun/wrun-output-words.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-output-words.util.js +51 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +35 -0
- package/dist/utility/wrun/wrun-overlay-result.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +23 -2
- package/dist/utility/wrun/wrun-overlay-run.util.js +305 -51
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +10 -2
- package/dist/utility/wrun/wrun-panel-mount.util.js +144 -18
- package/dist/utility/wrun/wrun-pin-venues.util.js +5 -1
- package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-refusal.util.js +102 -13
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
- package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
- package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
- package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
- package/dist/utility/wrun/wrun-run-health.util.d.ts +6 -3
- package/dist/utility/wrun/wrun-run-health.util.js +5 -2
- package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
- package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +25 -8
- package/dist/utility/wrun/wrun-script-inputs.util.js +145 -45
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
- package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
- package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
- package/dist/utility/wrun/wrun-style-names.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-style-names.util.js +74 -0
- package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
- package/dist/utility/wrun/wrun-style-words.util.js +46 -15
- package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
- package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
- package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
- package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
- package/dist/utility/wrun-display-name.util.d.ts +10 -0
- package/dist/utility/wrun-display-name.util.js +21 -0
- package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
- package/dist/utils/replay/replay-buffer-math.js +2 -0
- package/dist/workers/constants/socket-slots.d.ts +1 -1
- package/dist/workers/utils/time.worker.util.js +2 -2
- package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
- package/dist/workers/utils/volume-profile.worker.util.js +20 -0
- package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
- package/dist/workers/wrun/wrun-abi-host.js +82 -5
- package/dist/workers/wrun/wrun-engine-handler.js +53 -4
- package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
- package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
- package/package.json +11 -11
|
@@ -18,16 +18,29 @@ import { displayWallMs } from '../chart/display-offset.leaf.js';
|
|
|
18
18
|
import { WRUN_TIMEFRAME_WORDS, wrunSelectOptionValue } from './wrun-color-settings.util.js';
|
|
19
19
|
import { bindWrunSettingWords } from './wrun-setting-words.lazy.js';
|
|
20
20
|
const CHART_WORD = WRUN_TIMEFRAME_WORDS[0];
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
|
|
21
|
+
/** The platform's line style words (a Style row's `lineStyle` holds one; `WrunSettingWords.lineStyles` keys). */
|
|
22
|
+
const LINE_STYLE_WORDS = new Set(['solid', 'dashed', 'dotted']);
|
|
23
|
+
/** True when a choice is a line style choice: it has options and every one of them (its label, as the row shows
|
|
24
|
+
* it) is a line style word, case ignored. A choice that merely holds one such word among others (a mark look
|
|
25
|
+
* labelled "Solid" beside "Glass") is not. */
|
|
26
|
+
export function wrunIsLineStyleChoice(labels) {
|
|
27
|
+
return labels.length > 0 && labels.every((label) => LINE_STYLE_WORDS.has(String(label).trim().toLowerCase()));
|
|
28
|
+
}
|
|
29
|
+
/** A choice label as the viewer reads it: a platform word in the viewer's
|
|
30
|
+
* language when the surface passes its words ("chart" always; a line style
|
|
31
|
+
* word only when `lineStyleChoice` says the choice is a line style choice:
|
|
32
|
+
* `wrunIsLineStyleChoice` over its labels, or a Style row's `lineStyle`),
|
|
33
|
+
* any other label as written. A look option labelled "Solid" keeps "Solid".
|
|
34
|
+
* Display only: a stored value, a persisted label and every lookup by label
|
|
35
|
+
* keep the original word. */
|
|
36
|
+
export function wrunChoiceWord(label, words, lineStyleChoice = false) {
|
|
26
37
|
if (!words)
|
|
27
38
|
return label;
|
|
28
39
|
const word = label.trim().toLowerCase();
|
|
29
40
|
if (word === CHART_WORD)
|
|
30
41
|
return words.chart ?? label;
|
|
42
|
+
if (!lineStyleChoice)
|
|
43
|
+
return label;
|
|
31
44
|
const lineStyles = words.lineStyles;
|
|
32
45
|
return lineStyles && Object.prototype.hasOwnProperty.call(lineStyles, word) ? lineStyles[word] : label;
|
|
33
46
|
}
|
|
@@ -69,7 +82,7 @@ export function wrunSettingWords(shape, value, words) {
|
|
|
69
82
|
}
|
|
70
83
|
// A Style row's line style holds the platform word itself ("dashed").
|
|
71
84
|
if (shape.styleProperty === 'lineStyle' && typeof value === 'string')
|
|
72
|
-
return wrunChoiceWord(value, words);
|
|
85
|
+
return wrunChoiceWord(value, words, true);
|
|
73
86
|
const coded = wrunCodedWords(shape, value, words);
|
|
74
87
|
if (coded !== undefined)
|
|
75
88
|
return coded;
|
|
@@ -87,8 +100,12 @@ function choiceWords(shape, value, words) {
|
|
|
87
100
|
const picked = wrunSelectOptionValue(options, labels, value) ?? wrunSelectOptionValue(options, labels, shape.defaultValue);
|
|
88
101
|
if (picked === undefined)
|
|
89
102
|
return undefined;
|
|
90
|
-
const
|
|
91
|
-
|
|
103
|
+
const shown = (option, at) => {
|
|
104
|
+
const label = labels[at];
|
|
105
|
+
return typeof label === 'string' && label.trim() !== '' ? label : option;
|
|
106
|
+
};
|
|
107
|
+
const lineStyleChoice = shape.styleProperty === 'lineStyle' || wrunIsLineStyleChoice(options.map(shown));
|
|
108
|
+
return wrunChoiceWord(shown(picked, options.indexOf(picked)), words, lineStyleChoice);
|
|
92
109
|
}
|
|
93
110
|
function multiWords(shape, value, words) {
|
|
94
111
|
const labels = shape.optionLabels ?? [];
|
|
@@ -239,6 +239,8 @@ export declare class SocketWrunRowSource implements WrunRowSource {
|
|
|
239
239
|
/** The served tier of the OPRA rows the session holds (contract opra-server-lanes C4: the newest receipt that named a
|
|
240
240
|
* tier since the session opened), the one every merge is held to (`servedTierMoved`). */
|
|
241
241
|
private retainedTier;
|
|
242
|
+
/** The governed planes' receipts the session's rows were served at (`governedTierMoved`), reset with the session. */
|
|
243
|
+
private retainedGoverned;
|
|
242
244
|
/** A served-tier move no listener took yet (`dropSessionAtServedTier`): the next subscriber is told first. */
|
|
243
245
|
private servedTierMoveOwed;
|
|
244
246
|
constructor(deps?: WrunSocketRowSourceDeps);
|
|
@@ -247,7 +249,19 @@ export declare class SocketWrunRowSource implements WrunRowSource {
|
|
|
247
249
|
/** The session's run-level keys as a batch carries them (copies): the newest strategy output and diagnostics a
|
|
248
250
|
* result or a live frame carried, whichever merged last, the served legs' warning rows after the diagnostics, the
|
|
249
251
|
* newest result's OPRA word and the receipt of the newest OPRA rows (a result's or a marked live frame's). */
|
|
250
|
-
get sessionRunLevel(): Pick<WrunRowBatch, 'strategy' | 'diagnostics' | 'opra' | 'opraServed'>;
|
|
252
|
+
get sessionRunLevel(): Pick<WrunRowBatch, 'strategy' | 'diagnostics' | 'opra' | 'opraServed' | 'governed'>;
|
|
253
|
+
/** The overlay's sticky governed-plane mark (`governedMarks`), when its run named one. */
|
|
254
|
+
private governedMark;
|
|
255
|
+
/** Join a reply's governed-plane mark into the overlay's sticky one (`wrunGovernedMarkOf`, fail closed). */
|
|
256
|
+
private noteGoverned;
|
|
257
|
+
/** Join a mark read elsewhere (a failed ask's error frame, `wrunFailureGovernedOf`) into the overlay's sticky one. */
|
|
258
|
+
private noteGovernedMark;
|
|
259
|
+
/**
|
|
260
|
+
* A batch's run-level fields with the overlay's sticky governed-plane mark (`governed`), when its run named one. A
|
|
261
|
+
* run that read CME marks every diagnostic row the cloud answered beside its rows (`RuntimeDiagnostic.cme`: its
|
|
262
|
+
* execution errors can carry what the run computed), so every console export strips it, as the OPRA rows' mark.
|
|
263
|
+
*/
|
|
264
|
+
private withGoverned;
|
|
251
265
|
/** The session's cell rows in the shapes the price canvases read (the store's conversion), with the
|
|
252
266
|
* chart's own candles. The cells memo keeps each entry's lane rows between reads: a read after a merge
|
|
253
267
|
* converts only the rows the merge replaced (`extendWrunCellLane`), and a read with nothing merged since,
|
|
@@ -302,6 +316,17 @@ export declare class SocketWrunRowSource implements WrunRowSource {
|
|
|
302
316
|
* session whose rows never named one.
|
|
303
317
|
*/
|
|
304
318
|
private servedTierMoved;
|
|
319
|
+
/**
|
|
320
|
+
* The governed planes' twin of the OPRA rule (2026-11-11): an answer whose `wrunGoverned` receipt for a plane (CME,
|
|
321
|
+
* the US stocks tape) names another tier or delay than the receipt the session's rows were served at moves the
|
|
322
|
+
* session's served tier, so no real-time row stands beside a delayed one. Compared per plane the answer names, against
|
|
323
|
+
* the receipt the session retained for that plane (`retainedGoverned`); a plane either side does not name moves
|
|
324
|
+
* nothing. A receipt the chart could not read (no tier word or no delay) agrees with no readable one (fail closed); two
|
|
325
|
+
* equally unreadable receipts agree, so a server that never sends a readable receipt does not reseed on every frame.
|
|
326
|
+
*/
|
|
327
|
+
private governedTierMoved;
|
|
328
|
+
/** A merged answer's governed receipts join the session's (each plane it names, its newest receipt). */
|
|
329
|
+
private retainGoverned;
|
|
305
330
|
/**
|
|
306
331
|
* The served tier moved under the session: nothing it holds may stand beside rows served at the new tier (a
|
|
307
332
|
* real-time prefix under a delayed receipt, or the reverse). Its rows, coverage, owed window, cells and run-level
|
|
@@ -99,7 +99,8 @@ import { clearIndicatorInflight, scheduleIndicatorInflightFetch, } from '../char
|
|
|
99
99
|
import { readWrunWireRef } from '../chart/wrun-wire-ref.util.js';
|
|
100
100
|
import { wrunSocketPayloadSettings } from './wrun-cloud-record.util.js';
|
|
101
101
|
import { wrunErrorFrameCodeOf, wrunForeignSupersedeOf, wrunFrameRefusalOf, wrunServerAnswerOfText, } from './wrun-hosted-wire-caps.js';
|
|
102
|
-
import { readWrunHostedRunLevel, readWrunHostedWire, } from './wrun-hosted-wire.util.js';
|
|
102
|
+
import { readWrunHostedRunLevel, readWrunHostedWire, wrunGovernedMarkOf, } from './wrun-hosted-wire.util.js';
|
|
103
|
+
import { markWrunFailureGoverned, takeWrunFailureGoverned } from './wrun-cloud-cme-stamp.util.js';
|
|
103
104
|
import { WRUN_LANE_WARMUP_LOOKBACK_CAP, wrunLaneWarmupBars } from './wrun-lane-warmup.util.js';
|
|
104
105
|
import { wrunClampedLegDiagnostics } from './wrun-leg-fetch.util.js';
|
|
105
106
|
import { wrunParamValuesFromSettings } from './wrun-param-values.util.js';
|
|
@@ -348,6 +349,37 @@ export function mergeWrunSocketSpans(spans, intervalMs) {
|
|
|
348
349
|
export function wrunSocketPagePolicy(historical) {
|
|
349
350
|
return resolveFetchDedupePolicy(historical ? { lane: 'indicator', isReplayBuffer: true } : { lane: 'indicator' });
|
|
350
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* The governed-plane mark each overlay's cloud run carried (`<chartIndex>:<indicatorId>`, the reply's
|
|
354
|
+
* `output.wrunGoverned`): sticky for the run, so once any result or live frame of the overlay named a plane, every
|
|
355
|
+
* later batch and frame of it carries that plane, across paging, re-range, a settings change and a reconnect (a new
|
|
356
|
+
* create, or a new source for the same overlay). Never shed: withholding is always safe (the AI boundary never opens
|
|
357
|
+
* on CME), and the overlay's CME stamp is sticky for the mount too (wrun-cloud-cme-stamp.util).
|
|
358
|
+
*/
|
|
359
|
+
const governedMarks = new Map();
|
|
360
|
+
/** The governed planes a receipt is compared on (`governedTierMoved`). */
|
|
361
|
+
const WRUN_SOCKET_GOVERNED_PLANES = ['cme', 'stocks'];
|
|
362
|
+
/** Two marks joined: every plane either names, the newer's receipt where both name one. Undefined while neither
|
|
363
|
+
* names any. */
|
|
364
|
+
function joinWrunGovernedMarks(held, next) {
|
|
365
|
+
if (next === undefined)
|
|
366
|
+
return held;
|
|
367
|
+
const joined = { ...(held ?? {}) };
|
|
368
|
+
for (const [plane, receipt] of Object.entries(next)) {
|
|
369
|
+
if (receipt !== undefined)
|
|
370
|
+
joined[plane] = { ...receipt };
|
|
371
|
+
}
|
|
372
|
+
return Object.keys(joined).length > 0 ? joined : undefined;
|
|
373
|
+
}
|
|
374
|
+
/** A copy of a mark (a batch never shares the source's). */
|
|
375
|
+
function copyWrunGovernedMark(mark) {
|
|
376
|
+
const copy = {};
|
|
377
|
+
for (const [plane, receipt] of Object.entries(mark)) {
|
|
378
|
+
if (receipt !== undefined)
|
|
379
|
+
copy[plane] = { ...receipt };
|
|
380
|
+
}
|
|
381
|
+
return copy;
|
|
382
|
+
}
|
|
351
383
|
/** The sources following each overlay's cloud session (`<chartIndex>:<indicatorId>`): a facts-needed note
|
|
352
384
|
* reaches the ask they have waiting. */
|
|
353
385
|
const factsFollowers = new Map();
|
|
@@ -682,6 +714,8 @@ export class SocketWrunRowSource {
|
|
|
682
714
|
/** The served tier of the OPRA rows the session holds (contract opra-server-lanes C4: the newest receipt that named a
|
|
683
715
|
* tier since the session opened), the one every merge is held to (`servedTierMoved`). */
|
|
684
716
|
retainedTier;
|
|
717
|
+
/** The governed planes' receipts the session's rows were served at (`governedTierMoved`), reset with the session. */
|
|
718
|
+
retainedGoverned;
|
|
685
719
|
/** A served-tier move no listener took yet (`dropSessionAtServedTier`): the next subscriber is told first. */
|
|
686
720
|
servedTierMoveOwed;
|
|
687
721
|
constructor(deps = {}) {
|
|
@@ -710,7 +744,38 @@ export class SocketWrunRowSource {
|
|
|
710
744
|
* result or a live frame carried, whichever merged last, the served legs' warning rows after the diagnostics, the
|
|
711
745
|
* newest result's OPRA word and the receipt of the newest OPRA rows (a result's or a marked live frame's). */
|
|
712
746
|
get sessionRunLevel() {
|
|
713
|
-
return runLevelFields(this.runLevel);
|
|
747
|
+
return this.withGoverned(runLevelFields(this.runLevel));
|
|
748
|
+
}
|
|
749
|
+
/** The overlay's sticky governed-plane mark (`governedMarks`), when its run named one. */
|
|
750
|
+
governedMark() {
|
|
751
|
+
return this.identity !== undefined ? governedMarks.get(overlayKeyOf(this.identity)) : undefined;
|
|
752
|
+
}
|
|
753
|
+
/** Join a reply's governed-plane mark into the overlay's sticky one (`wrunGovernedMarkOf`, fail closed). */
|
|
754
|
+
noteGoverned(output) {
|
|
755
|
+
this.noteGovernedMark(wrunGovernedMarkOf(output));
|
|
756
|
+
}
|
|
757
|
+
/** Join a mark read elsewhere (a failed ask's error frame, `wrunFailureGovernedOf`) into the overlay's sticky one. */
|
|
758
|
+
noteGovernedMark(mark) {
|
|
759
|
+
if (this.identity === undefined || mark === undefined)
|
|
760
|
+
return;
|
|
761
|
+
const key = overlayKeyOf(this.identity);
|
|
762
|
+
const joined = joinWrunGovernedMarks(governedMarks.get(key), mark);
|
|
763
|
+
if (joined !== undefined)
|
|
764
|
+
governedMarks.set(key, joined);
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* A batch's run-level fields with the overlay's sticky governed-plane mark (`governed`), when its run named one. A
|
|
768
|
+
* run that read CME marks every diagnostic row the cloud answered beside its rows (`RuntimeDiagnostic.cme`: its
|
|
769
|
+
* execution errors can carry what the run computed), so every console export strips it, as the OPRA rows' mark.
|
|
770
|
+
*/
|
|
771
|
+
withGoverned(fields) {
|
|
772
|
+
const mark = this.governedMark();
|
|
773
|
+
if (mark === undefined)
|
|
774
|
+
return fields;
|
|
775
|
+
const diagnostics = mark.cme !== undefined && fields.diagnostics !== undefined
|
|
776
|
+
? { diagnostics: fields.diagnostics.map((row) => ({ ...row, cme: true })) }
|
|
777
|
+
: {};
|
|
778
|
+
return { ...fields, ...diagnostics, governed: copyWrunGovernedMark(mark) };
|
|
714
779
|
}
|
|
715
780
|
/** The session's cell rows in the shapes the price canvases read (the store's conversion), with the
|
|
716
781
|
* chart's own candles. The cells memo keeps each entry's lane rows between reads: a read after a merge
|
|
@@ -750,6 +815,7 @@ export class SocketWrunRowSource {
|
|
|
750
815
|
this.runLevel = {};
|
|
751
816
|
this.lossesAtOpen = undefined;
|
|
752
817
|
this.retainedTier = undefined;
|
|
818
|
+
this.retainedGoverned = undefined;
|
|
753
819
|
this.servedTierMoveOwed = undefined;
|
|
754
820
|
this.followLive();
|
|
755
821
|
return this.withLoading(async () => {
|
|
@@ -882,6 +948,7 @@ export class SocketWrunRowSource {
|
|
|
882
948
|
this.runLevel = {};
|
|
883
949
|
this.flight = undefined;
|
|
884
950
|
this.retainedTier = undefined;
|
|
951
|
+
this.retainedGoverned = undefined;
|
|
885
952
|
this.servedTierMoveOwed = undefined;
|
|
886
953
|
}
|
|
887
954
|
/**
|
|
@@ -898,7 +965,11 @@ export class SocketWrunRowSource {
|
|
|
898
965
|
enqueue(work) {
|
|
899
966
|
const run = this.queue.then(work, work);
|
|
900
967
|
this.queue = run.then(() => undefined, () => undefined);
|
|
901
|
-
|
|
968
|
+
// Every failure the source rejects with carries the overlay's sticky governed-plane mark (a failed run that read
|
|
969
|
+
// CME surfaces marked: the run pass reads it back, wrun-cloud-cme-stamp.util `wrunFailureGovernedOf`).
|
|
970
|
+
return run.catch((error) => {
|
|
971
|
+
throw markWrunFailureGoverned(error, this.governedMark());
|
|
972
|
+
});
|
|
902
973
|
}
|
|
903
974
|
nextGeneration() {
|
|
904
975
|
this.generationAbort.abort(new WrunSocketRowSourceStopped('superseded'));
|
|
@@ -1031,6 +1102,10 @@ export class SocketWrunRowSource {
|
|
|
1031
1102
|
return { output };
|
|
1032
1103
|
}
|
|
1033
1104
|
catch (error) {
|
|
1105
|
+
// The error frame's governed-plane mark (its relayed `details.wrunGoverned`, the frozen contract) joins the
|
|
1106
|
+
// overlay's sticky one before anything else of the failure is read, as a reply's does (fail closed): a refusal
|
|
1107
|
+
// batch and every later failure or batch of the overlay carry it.
|
|
1108
|
+
this.noteGovernedMark(takeWrunFailureGoverned(error));
|
|
1034
1109
|
// A superseded or torn-down ask reports the stop, whatever the transport said after it.
|
|
1035
1110
|
this.assertCurrent(generation);
|
|
1036
1111
|
// The cloud refused this ask for fact lists its payload lacked (the worker named them while it waited): once
|
|
@@ -1090,6 +1165,9 @@ export class SocketWrunRowSource {
|
|
|
1090
1165
|
throw new WrunSocketRowSourceStopped('superseded');
|
|
1091
1166
|
if (output === undefined || output === null)
|
|
1092
1167
|
throw new WrunRowSourceTransientError('no-reply');
|
|
1168
|
+
// The run's governed-plane mark joins the overlay's sticky one before anything else of the reply is read: a
|
|
1169
|
+
// reply the source refuses or cannot read still marks the run (fail closed).
|
|
1170
|
+
this.noteGoverned(output);
|
|
1093
1171
|
const read = await readWrunHostedWire(output);
|
|
1094
1172
|
this.assertCurrent(generation);
|
|
1095
1173
|
if (read.kind === 'absent')
|
|
@@ -1100,7 +1178,7 @@ export class SocketWrunRowSource {
|
|
|
1100
1178
|
this.assertCurrent(generation);
|
|
1101
1179
|
// A page (or the paging after a patch) the cloud served at another tier than the rows the session holds: none
|
|
1102
1180
|
// of them may stand beside it, so the session is dropped and the overlay reseeds; the ask settles superseded.
|
|
1103
|
-
if (freshSheet === undefined && this.servedTierMoved(level)) {
|
|
1181
|
+
if (freshSheet === undefined && this.servedTierMoved(level, output)) {
|
|
1104
1182
|
this.dropSessionAtServedTier(read.wire.window);
|
|
1105
1183
|
throw new WrunSocketRowSourceStopped('superseded');
|
|
1106
1184
|
}
|
|
@@ -1141,9 +1219,12 @@ export class SocketWrunRowSource {
|
|
|
1141
1219
|
...(level.opra !== undefined ? { opra: level.opra } : {}),
|
|
1142
1220
|
...(opraServed !== undefined ? { opraServed } : {}),
|
|
1143
1221
|
};
|
|
1144
|
-
if (freshSheet !== undefined)
|
|
1222
|
+
if (freshSheet !== undefined) {
|
|
1145
1223
|
this.retainedTier = undefined;
|
|
1224
|
+
this.retainedGoverned = undefined;
|
|
1225
|
+
}
|
|
1146
1226
|
this.retainTier(level);
|
|
1227
|
+
this.retainGoverned(output);
|
|
1147
1228
|
});
|
|
1148
1229
|
}
|
|
1149
1230
|
// ── The served tier ──────────────────────────────────────────────────────────────────────────
|
|
@@ -1158,9 +1239,34 @@ export class SocketWrunRowSource {
|
|
|
1158
1239
|
* a downgrade or an upgrade). An answer that names no tier moves nothing (its rows read no OPRA yet), nor does a
|
|
1159
1240
|
* session whose rows never named one.
|
|
1160
1241
|
*/
|
|
1161
|
-
servedTierMoved(level) {
|
|
1242
|
+
servedTierMoved(level, output) {
|
|
1162
1243
|
const tier = level.opra === true ? level.opraServed?.tier : undefined;
|
|
1163
|
-
|
|
1244
|
+
if (tier !== undefined && this.retainedTier !== undefined && tier !== this.retainedTier)
|
|
1245
|
+
return true;
|
|
1246
|
+
return output !== undefined && this.governedTierMoved(output);
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1249
|
+
* The governed planes' twin of the OPRA rule (2026-11-11): an answer whose `wrunGoverned` receipt for a plane (CME,
|
|
1250
|
+
* the US stocks tape) names another tier or delay than the receipt the session's rows were served at moves the
|
|
1251
|
+
* session's served tier, so no real-time row stands beside a delayed one. Compared per plane the answer names, against
|
|
1252
|
+
* the receipt the session retained for that plane (`retainedGoverned`); a plane either side does not name moves
|
|
1253
|
+
* nothing. A receipt the chart could not read (no tier word or no delay) agrees with no readable one (fail closed); two
|
|
1254
|
+
* equally unreadable receipts agree, so a server that never sends a readable receipt does not reseed on every frame.
|
|
1255
|
+
*/
|
|
1256
|
+
governedTierMoved(output) {
|
|
1257
|
+
const next = wrunGovernedMarkOf(output);
|
|
1258
|
+
const held = this.retainedGoverned;
|
|
1259
|
+
if (next === undefined || held === undefined)
|
|
1260
|
+
return false;
|
|
1261
|
+
return WRUN_SOCKET_GOVERNED_PLANES.some((plane) => {
|
|
1262
|
+
const was = held[plane];
|
|
1263
|
+
const now = next[plane];
|
|
1264
|
+
return was !== undefined && now !== undefined && (was.tier !== now.tier || was.delaySeconds !== now.delaySeconds);
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
/** A merged answer's governed receipts join the session's (each plane it names, its newest receipt). */
|
|
1268
|
+
retainGoverned(output) {
|
|
1269
|
+
this.retainedGoverned = joinWrunGovernedMarks(this.retainedGoverned, wrunGovernedMarkOf(output));
|
|
1164
1270
|
}
|
|
1165
1271
|
/**
|
|
1166
1272
|
* The served tier moved under the session: nothing it holds may stand beside rows served at the new tier (a
|
|
@@ -1178,6 +1284,7 @@ export class SocketWrunRowSource {
|
|
|
1178
1284
|
this.owed = undefined;
|
|
1179
1285
|
this.cells = undefined;
|
|
1180
1286
|
this.retainedTier = undefined;
|
|
1287
|
+
this.retainedGoverned = undefined;
|
|
1181
1288
|
const frame = {
|
|
1182
1289
|
window: { ...window },
|
|
1183
1290
|
asOfMs: Number.NaN,
|
|
@@ -1349,7 +1456,7 @@ export class SocketWrunRowSource {
|
|
|
1349
1456
|
frames: undefined,
|
|
1350
1457
|
handles: undefined,
|
|
1351
1458
|
refusals: [],
|
|
1352
|
-
...runLevelFields(this.runLevel),
|
|
1459
|
+
...this.withGoverned(runLevelFields(this.runLevel)),
|
|
1353
1460
|
};
|
|
1354
1461
|
}
|
|
1355
1462
|
const start = firstAtOrAfter(session.rows, window.fromMs);
|
|
@@ -1367,7 +1474,7 @@ export class SocketWrunRowSource {
|
|
|
1367
1474
|
handles: rebasedHandles(session.handles, start),
|
|
1368
1475
|
refusals: session.refusals.map((refusal) => ({ ...refusal })),
|
|
1369
1476
|
...(withSheet ? { sheet: session.sheet } : {}),
|
|
1370
|
-
...runLevelFields(this.runLevel),
|
|
1477
|
+
...this.withGoverned(runLevelFields(this.runLevel)),
|
|
1371
1478
|
...(this.lossesAtOpen !== undefined ? { sessionLosses: this.lossesAtOpen } : {}),
|
|
1372
1479
|
};
|
|
1373
1480
|
}
|
|
@@ -1397,7 +1504,11 @@ export class SocketWrunRowSource {
|
|
|
1397
1504
|
return;
|
|
1398
1505
|
const generation = this.generation;
|
|
1399
1506
|
void this.serial(async () => {
|
|
1400
|
-
if (this.closed
|
|
1507
|
+
if (this.closed)
|
|
1508
|
+
return;
|
|
1509
|
+
// A frame's governed-plane mark joins the overlay's sticky one whatever becomes of the frame (fail closed).
|
|
1510
|
+
this.noteGoverned(output);
|
|
1511
|
+
if (generation !== this.generation)
|
|
1401
1512
|
return;
|
|
1402
1513
|
const read = await readWrunHostedWire(output);
|
|
1403
1514
|
// An unreadable frame is skipped: the next result repaints.
|
|
@@ -1412,7 +1523,7 @@ export class SocketWrunRowSource {
|
|
|
1412
1523
|
return;
|
|
1413
1524
|
// A frame served at another tier than the rows the session holds never extends them: the session is dropped
|
|
1414
1525
|
// and the overlay reseeds (`dropSessionAtServedTier`).
|
|
1415
|
-
if (this.servedTierMoved(level)) {
|
|
1526
|
+
if (this.servedTierMoved(level, output)) {
|
|
1416
1527
|
this.dropSessionAtServedTier(read.wire.window);
|
|
1417
1528
|
return;
|
|
1418
1529
|
}
|
|
@@ -1434,6 +1545,7 @@ export class SocketWrunRowSource {
|
|
|
1434
1545
|
this.runLevel = { ...rest, ...(level.opraServed !== undefined ? { opraServed: level.opraServed } : {}) };
|
|
1435
1546
|
}
|
|
1436
1547
|
this.retainTier(level);
|
|
1548
|
+
this.retainGoverned(output);
|
|
1437
1549
|
this.emitFrame(read.wire, merge, level);
|
|
1438
1550
|
}).catch((error) => {
|
|
1439
1551
|
console.warn('[wrun] socket row source live frame skipped:', error);
|
|
@@ -1457,7 +1569,7 @@ export class SocketWrunRowSource {
|
|
|
1457
1569
|
frames: merge.acceptedSnapshots && wire.frames !== undefined ? session.frames : undefined,
|
|
1458
1570
|
handles: rebasedHandles(session.handles, start),
|
|
1459
1571
|
refusals: session.refusals.map((refusal) => ({ ...refusal })),
|
|
1460
|
-
...runLevelFields({ ...level, servedLegs: this.runLevel.servedLegs }),
|
|
1572
|
+
...this.withGoverned(runLevelFields({ ...level, servedLegs: this.runLevel.servedLegs })),
|
|
1461
1573
|
};
|
|
1462
1574
|
this.deliver(frame);
|
|
1463
1575
|
}
|
|
@@ -1796,6 +1908,7 @@ export function onWrunSocketRowSourceTestReset(reset) {
|
|
|
1796
1908
|
export function __resetWrunSocketRowSourceForTests() {
|
|
1797
1909
|
factsFollowers.clear();
|
|
1798
1910
|
factsAskedAgain.clear();
|
|
1911
|
+
governedMarks.clear();
|
|
1799
1912
|
for (const reset of transportStateResets)
|
|
1800
1913
|
reset();
|
|
1801
1914
|
}
|
|
@@ -658,9 +658,9 @@ export declare const WRUN_ODDS_EXCHANGE = "POLYMARKET";
|
|
|
658
658
|
* interval. */
|
|
659
659
|
export declare function wrunIntrabarLegFetchKey(intervalKey: string, market?: WrunPinnedMarket): string;
|
|
660
660
|
export { wrunPinnedIntervalOf, type WrunPinnedInterval } from './wrun-pinned-interval.util.js';
|
|
661
|
-
/** The chart's spelling of an interval span (an `Intervals.map_unit` key)
|
|
662
|
-
* else the span in ms with a unit (a
|
|
663
|
-
* grid leg's fetch falls back to the chart's own interval either way). */
|
|
661
|
+
/** The chart's spelling of an interval span (an `Intervals.map_unit` key): the resolver's own label first (28 days
|
|
662
|
+
* is 4w, never the legacy '1mm' row), else the first table row of that length, else the span in ms with a unit (a
|
|
663
|
+
* spelling `dataFetch` ignores, so a grid leg's fetch falls back to the chart's own interval either way). */
|
|
664
664
|
export declare function wrunChartIntervalKeyOf(intervalMs: number): string;
|
|
665
665
|
/** A pinned leg's fetch identity: the market (the chart's own when
|
|
666
666
|
* unpinned, so the fetch payload's placeholders) and the leg interval, the
|
|
@@ -356,7 +356,8 @@ import { wrunChartHostEnv } from '../../host-env.js';
|
|
|
356
356
|
import { packedOhlcvRowViews, unpackOhlcvRows, } from '../../instances/script-engine-worker-ohlcv-transfer.js';
|
|
357
357
|
import { FeatureFlag } from '../../constants/feature-flags.constants.js';
|
|
358
358
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
359
|
-
import {
|
|
359
|
+
import { intervalLabelForMs } from '../chart/interval-ladder.util.js';
|
|
360
|
+
import { barEndMs, calendarBarStartMs, calendarLongestBarMs, calendarMonthsOfMs, chunkFloorMs, fixedGridFloorDivMs, isCalendarIntervalMs, } from '../chart/calendar-interval.util.js';
|
|
360
361
|
import { WRUN_PINNED_INTERVALS, wrunPinnedIntervalOf } from './wrun-pinned-interval.util.js';
|
|
361
362
|
import { realMainRows } from '../chart/indicator-gap-detector.util.js';
|
|
362
363
|
import { placeRowsInHostBars, rowLastInstantMs } from '../chart/host-bar-placement.util.js';
|
|
@@ -726,12 +727,12 @@ export function wrunIntrabarLegFetchKey(intervalKey, market) {
|
|
|
726
727
|
// The interval pin vocabulary is a thin fact the alert target reads too (wrun-pinned-interval.util);
|
|
727
728
|
// this module keeps exporting it for its own readers.
|
|
728
729
|
export { wrunPinnedIntervalOf } from './wrun-pinned-interval.util.js';
|
|
729
|
-
/** The chart's spelling of an interval span (an `Intervals.map_unit` key)
|
|
730
|
-
* else the span in ms with a unit (a
|
|
731
|
-
* grid leg's fetch falls back to the chart's own interval either way). */
|
|
730
|
+
/** The chart's spelling of an interval span (an `Intervals.map_unit` key): the resolver's own label first (28 days
|
|
731
|
+
* is 4w, never the legacy '1mm' row), else the first table row of that length, else the span in ms with a unit (a
|
|
732
|
+
* spelling `dataFetch` ignores, so a grid leg's fetch falls back to the chart's own interval either way). */
|
|
732
733
|
export function wrunChartIntervalKeyOf(intervalMs) {
|
|
733
734
|
const entry = Object.entries(Intervals.map_unit).find(([, ms]) => ms === intervalMs);
|
|
734
|
-
return entry ? entry[0] : `${intervalMs}ms
|
|
735
|
+
return intervalLabelForMs(intervalMs) ?? (entry ? entry[0] : `${intervalMs}ms`);
|
|
735
736
|
}
|
|
736
737
|
/** A pinned leg's fetch identity: the market (the chart's own when
|
|
737
738
|
* unpinned, so the fetch payload's placeholders) and the leg interval, the
|
|
@@ -851,7 +852,7 @@ export function wrunWireRowPieces(fromMs, toMs, rowMs) {
|
|
|
851
852
|
}
|
|
852
853
|
const pieces = [];
|
|
853
854
|
for (let at = fromMs; at < toMs;) {
|
|
854
|
-
const edge = Math.min(toMs,
|
|
855
|
+
const edge = Math.min(toMs, chunkFloorMs(at, bucketMs, rowMs) + bucketMs);
|
|
855
856
|
pieces.push({ fromMs: at, toMs: edge });
|
|
856
857
|
at = edge;
|
|
857
858
|
}
|
|
@@ -1790,7 +1791,7 @@ export function wrunFormingBucketStart(ts, legMs) {
|
|
|
1790
1791
|
const months = calendarMonthsOfMs(legMs);
|
|
1791
1792
|
if (months !== null)
|
|
1792
1793
|
return calendarBarStartMs(ts, months);
|
|
1793
|
-
return
|
|
1794
|
+
return fixedGridFloorDivMs(ts, legMs);
|
|
1794
1795
|
}
|
|
1795
1796
|
/**
|
|
1796
1797
|
* True when the package reads a lane laid on the chart's timeline besides the chart's own
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** What the table says about one Style target: the words its line is titled by and one name per colour slot, each
|
|
2
|
+
* trimmed. A part the entry leaves out, or writes as no words, is absent (a colour list with one slot that has no
|
|
3
|
+
* words names none of its slots), and an output's or a heatmap's entry never carries a title. */
|
|
4
|
+
export interface WrunStyleNameWords {
|
|
5
|
+
label?: string;
|
|
6
|
+
colors?: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
/** The table's words for one Style target (`marks:<name>`, `text:<name>`, an output's name, `heatmap:<name>`), from
|
|
9
|
+
* the first entry that names it (a later one is never read); undefined when the sheet has no table or no entry
|
|
10
|
+
* names the target. An output's or a heatmap's entry gives no label, whatever it writes there. */
|
|
11
|
+
export declare function wrunStyleNameOf(sheet: {
|
|
12
|
+
style_names?: unknown;
|
|
13
|
+
} | null | undefined, target: string): WrunStyleNameWords | undefined;
|
|
14
|
+
/** One name per slot of a colour list of `count` colours: the target's names when the table names exactly that many,
|
|
15
|
+
* else undefined, so a swatch never takes another slot's name (a list naming fewer or more slots names none). */
|
|
16
|
+
export declare function wrunStyleSlotNames(names: WrunStyleNameWords | undefined, count: number): string[] | undefined;
|
|
17
|
+
/** A named target's title, the one order every surface titles it in: the table's label, else the target's own label
|
|
18
|
+
* (`ownLabel`: a batched section's or a heatmap's readout title, as its declaration carries it), else its name read as
|
|
19
|
+
* words (the legend's rule, wrunLegendName: `served_in_part` reads "Served in part"). A heatmap's entry gives no
|
|
20
|
+
* label, so a heatmap reads its own. */
|
|
21
|
+
export declare function wrunStyleTitle(sheet: {
|
|
22
|
+
style_names?: unknown;
|
|
23
|
+
} | null | undefined, target: string, name: string, ownLabel?: unknown): string;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { wrunLegendName } from '../chart/wrun-legend-name.util.js';
|
|
2
|
+
/** Each kind the table names: its Style target prefix, the visibility table's own (a renderer is `text:<name>`, an
|
|
3
|
+
* output its bare name), and whether its entry titles the line (`titles`: a batched section's and a renderer's; an
|
|
4
|
+
* output's and a heatmap's name colours only). A prefix the visibility table changes, a kind the table gains, or a
|
|
5
|
+
* kind's title rule the sheet type disagrees with, fails typecheck here. */
|
|
6
|
+
const STYLE_NAME_KINDS = Object.freeze({
|
|
7
|
+
marks: { prefix: 'marks', titles: true },
|
|
8
|
+
spans: { prefix: 'spans', titles: true },
|
|
9
|
+
rays: { prefix: 'rays', titles: true },
|
|
10
|
+
flags: { prefix: 'flags', titles: true },
|
|
11
|
+
renderer: { prefix: 'text', titles: true },
|
|
12
|
+
output: { prefix: '', titles: false },
|
|
13
|
+
heatmap: { prefix: 'heatmap', titles: false },
|
|
14
|
+
});
|
|
15
|
+
function isRecord(value) {
|
|
16
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
17
|
+
}
|
|
18
|
+
/** Plain words, trimmed; undefined for anything else (a number, an empty or blank string). */
|
|
19
|
+
function wordsOf(value) {
|
|
20
|
+
if (typeof value !== 'string')
|
|
21
|
+
return undefined;
|
|
22
|
+
const words = value.trim();
|
|
23
|
+
return words === '' ? undefined : words;
|
|
24
|
+
}
|
|
25
|
+
/** An entry's kind, when the table knows it. */
|
|
26
|
+
function kindOf(entry) {
|
|
27
|
+
const { kind } = entry;
|
|
28
|
+
return typeof kind === 'string' && Object.hasOwn(STYLE_NAME_KINDS, kind) ? kind : undefined;
|
|
29
|
+
}
|
|
30
|
+
/** An entry's Style target: undefined for a kind the table does not know, or an entry without a name. The name is
|
|
31
|
+
* the section's identity, compared as written (the visibility table's rule: a blank name is none). An output's
|
|
32
|
+
* target is its bare name, so an output entry whose name holds a colon names nothing: it would read as another
|
|
33
|
+
* kind's target (`marks:prints`), and no output target holds one. */
|
|
34
|
+
function targetOf(entry) {
|
|
35
|
+
if (!isRecord(entry))
|
|
36
|
+
return undefined;
|
|
37
|
+
const kind = kindOf(entry);
|
|
38
|
+
const { name } = entry;
|
|
39
|
+
if (kind === undefined || typeof name !== 'string' || name.trim() === '')
|
|
40
|
+
return undefined;
|
|
41
|
+
const { prefix } = STYLE_NAME_KINDS[kind];
|
|
42
|
+
if (prefix === '')
|
|
43
|
+
return name.includes(':') ? undefined : name;
|
|
44
|
+
return `${prefix}:${name}`;
|
|
45
|
+
}
|
|
46
|
+
/** The table's words for one Style target (`marks:<name>`, `text:<name>`, an output's name, `heatmap:<name>`), from
|
|
47
|
+
* the first entry that names it (a later one is never read); undefined when the sheet has no table or no entry
|
|
48
|
+
* names the target. An output's or a heatmap's entry gives no label, whatever it writes there. */
|
|
49
|
+
export function wrunStyleNameOf(sheet, target) {
|
|
50
|
+
const table = sheet?.style_names;
|
|
51
|
+
if (!Array.isArray(table))
|
|
52
|
+
return undefined;
|
|
53
|
+
const entry = table.find((candidate) => targetOf(candidate) === target);
|
|
54
|
+
if (!isRecord(entry))
|
|
55
|
+
return undefined;
|
|
56
|
+
const kind = kindOf(entry);
|
|
57
|
+
const label = kind !== undefined && STYLE_NAME_KINDS[kind].titles ? wordsOf(entry.label) : undefined;
|
|
58
|
+
const colors = Array.isArray(entry.colors) ? entry.colors.map(wordsOf) : [];
|
|
59
|
+
const named = colors.length > 0 && colors.every((name) => name !== undefined);
|
|
60
|
+
return { ...(label !== undefined ? { label } : {}), ...(named ? { colors: colors } : {}) };
|
|
61
|
+
}
|
|
62
|
+
/** One name per slot of a colour list of `count` colours: the target's names when the table names exactly that many,
|
|
63
|
+
* else undefined, so a swatch never takes another slot's name (a list naming fewer or more slots names none). */
|
|
64
|
+
export function wrunStyleSlotNames(names, count) {
|
|
65
|
+
return names?.colors !== undefined && names.colors.length === count ? [...names.colors] : undefined;
|
|
66
|
+
}
|
|
67
|
+
/** A named target's title, the one order every surface titles it in: the table's label, else the target's own label
|
|
68
|
+
* (`ownLabel`: a batched section's or a heatmap's readout title, as its declaration carries it), else its name read as
|
|
69
|
+
* words (the legend's rule, wrunLegendName: `served_in_part` reads "Served in part"). A heatmap's entry gives no
|
|
70
|
+
* label, so a heatmap reads its own. */
|
|
71
|
+
export function wrunStyleTitle(sheet, target, name, ownLabel) {
|
|
72
|
+
const named = wrunStyleNameOf(sheet, target)?.label;
|
|
73
|
+
return wrunLegendName(name, named ?? (typeof ownLabel === 'string' ? ownLabel : undefined));
|
|
74
|
+
}
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* corpus), and the theme-token packing every host restates (the draw ABI
|
|
9
9
|
* sentinel, the wire text, the packed f64 form).
|
|
10
10
|
*
|
|
11
|
-
* Imports
|
|
12
|
-
*
|
|
11
|
+
* Imports only the door to the mark colour maths (wrun-colour-tone.lazy,
|
|
12
|
+
* import-free; the maths stay off the pre-candle path): no vue, no DOM, no
|
|
13
|
+
* titan, no kit, main-thread and worker safe. The om twin is packages/sdk/src/wrun-style-words.ts and
|
|
13
14
|
* wrun-value-format.ts; the two sides must agree on every word and byte.
|
|
14
15
|
*
|
|
15
16
|
* Theme tokens ride sheets, wire props and run outputs unresolved; they
|
|
@@ -17,17 +18,20 @@
|
|
|
17
18
|
* wrunColorThemeOf(tc))` and re-resolve on a theme switch without a rerun
|
|
18
19
|
* (`onWrunThemeChange`).
|
|
19
20
|
*/
|
|
20
|
-
/** The
|
|
21
|
-
* Token k of the packed forms below is `index + 1` in this order
|
|
22
|
-
|
|
21
|
+
/** The nine 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: the
|
|
23
|
+
* Big Trades looks round appended `up_mark` (k 8) and `down_mark` (k 9). */
|
|
24
|
+
export declare const WRUN_THEME_COLOR_TOKENS: readonly ["up", "down", "text", "muted", "bg", "grid", "accent", "up_mark", "down_mark"];
|
|
23
25
|
export type WrunThemeColorToken = (typeof WRUN_THEME_COLOR_TOKENS)[number];
|
|
24
26
|
/** A theme token with its alpha (0..1). */
|
|
25
27
|
export interface WrunThemeTokenRef {
|
|
26
28
|
token: WrunThemeColorToken;
|
|
27
29
|
alpha: number;
|
|
28
30
|
}
|
|
31
|
+
/** The tokens as a refusal lists them: `theme.up, theme.down, ...`. */
|
|
32
|
+
export declare const WRUN_THEME_TOKEN_WORDS_TEXT: string;
|
|
29
33
|
/** True for the convention-2 colour word: `#rrggbb`, `#rrggbbaa` or one of
|
|
30
|
-
* the
|
|
34
|
+
* the nine tokens spelled exactly (`theme.up`); the `/aa` wire form, any
|
|
31
35
|
* other `theme.` word and every non-string are not colour words. */
|
|
32
36
|
export declare function isWrunColorWord(value: unknown): value is string;
|
|
33
37
|
/** The token a string names: `theme.<t>` (alpha 1) or the wire's
|
|
@@ -47,7 +51,7 @@ export declare function wrunThemeTokenWithAlpha(value: string, alpha: number): s
|
|
|
47
51
|
* is `theme.up/40`. The product is clamped to 0..1. A non-token string and
|
|
48
52
|
* a non-finite factor come back unchanged. */
|
|
49
53
|
export declare function wrunThemeTokenScaleAlpha(value: string, factor: number): string;
|
|
50
|
-
/** The
|
|
54
|
+
/** The nine palette colours a chart's theme answers a token with, as CSS
|
|
51
55
|
* colour strings. */
|
|
52
56
|
export interface WrunColorTheme {
|
|
53
57
|
up: string;
|
|
@@ -57,12 +61,30 @@ export interface WrunColorTheme {
|
|
|
57
61
|
bg: string;
|
|
58
62
|
grid: string;
|
|
59
63
|
accent: string;
|
|
64
|
+
/** The mark colour of each side: the candle colour stepped one tone away
|
|
65
|
+
* from the background (`markSideColour`). */
|
|
66
|
+
up_mark: string;
|
|
67
|
+
down_mark: string;
|
|
60
68
|
}
|
|
69
|
+
/** A parsed colour: channels 0..255, alpha 0..1. */
|
|
70
|
+
export interface WrunRgbaParts {
|
|
71
|
+
r: number;
|
|
72
|
+
g: number;
|
|
73
|
+
b: number;
|
|
74
|
+
a: number;
|
|
75
|
+
}
|
|
76
|
+
/** A palette colour parsed: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`,
|
|
77
|
+
* `rgb(r, g, b)` or `rgba(r, g, b, a)` (the forms the chart theme writes).
|
|
78
|
+
* Anything else is no colour. */
|
|
79
|
+
export declare function parseWrunCssColor(value: unknown): WrunRgbaParts | undefined;
|
|
61
80
|
/** The palette of a chart (`tc`, feature-detected: a bare test double or a
|
|
62
81
|
* pin without a theme answers the dark defaults): up and down from the
|
|
63
82
|
* candle colours, text from the x axis font colour, muted = text at alpha
|
|
64
83
|
* x 0.55, bg and grid from the theme, accent from `noteWrunThemeApplied`
|
|
65
|
-
* (fallback '#ff4608')
|
|
84
|
+
* (fallback '#ff4608'), up_mark and down_mark the candle colours stepped
|
|
85
|
+
* one tone away from bg (`markSideColour`, through its door: the up and
|
|
86
|
+
* down colours until wrun-colour-tone.util has evaluated). Read at every mount and theme
|
|
87
|
+
* change, so the mark colours follow a theme switch with no rerun. */
|
|
66
88
|
export declare function wrunColorThemeOf(tc: unknown): WrunColorTheme;
|
|
67
89
|
/** Records the accent colour of a theme apply for `tc` (a WeakMap, so a
|
|
68
90
|
* disposed chart leaves nothing behind), then tells every
|
|
@@ -143,6 +165,6 @@ export declare function wrunDrawColorWire(rgba: number): string;
|
|
|
143
165
|
* `-(k * 1024 + round(alpha * 1000))`, a negative integer no colour ever
|
|
144
166
|
* packed to. Alpha is clamped to 0..1. */
|
|
145
167
|
export declare function wrunPackedThemeToken(ref: WrunThemeTokenRef): number;
|
|
146
|
-
/** Decodes a packed colour: a finite negative integer whose k lands in 1..
|
|
168
|
+
/** Decodes a packed colour: a finite negative integer whose k lands in 1..9
|
|
147
169
|
* and whose alpha part is at most 1000 is a token, anything else null. */
|
|
148
170
|
export declare function wrunThemeTokenOfPacked(value: number): WrunThemeTokenRef | null;
|