@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,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The live tick's build memo (wrun-live-patch.util `wrunLiveBuildMemoOf`,
|
|
3
|
+
* read by wrun-run-result.util `buildWrunRunResult` and the renderables
|
|
4
|
+
* selection, wrun-render-select.util).
|
|
5
|
+
*
|
|
6
|
+
* A live block re-sends the forming bar: it changes the newest row and nothing
|
|
7
|
+
* before it, and most blocks change only a few of its values (a swing level, a
|
|
8
|
+
* VWAP and its bands, a sweep flag). A roll closes that bar and opens the
|
|
9
|
+
* next: the rows before it stay. The run result is still built over the
|
|
10
|
+
* session's whole window (displacement, ladders, omitted outputs and the last
|
|
11
|
+
* ready row derive from all rows), which made every update cost every
|
|
12
|
+
* output's every row. The memo keeps what each build unit did (one output's
|
|
13
|
+
* mount, one band's, one box's, one renderer's selection and mount, ...) and
|
|
14
|
+
* the next build reuses it:
|
|
15
|
+
*
|
|
16
|
+
* - Replay. On the memo's rows but the newest (every row before it the same
|
|
17
|
+
* values array, the newest at the same stamp and equally ready) under the
|
|
18
|
+
* same options (`key`), a unit none of whose inputs changed on the newest
|
|
19
|
+
* row replays what it did: the same records, in its own turn, so the
|
|
20
|
+
* outputs keep the key order a full build gives them (titan's legend and
|
|
21
|
+
* paint order). A unit reads the columns and string slots its declaration
|
|
22
|
+
* names (`wrunBuildUnitReads`): every output or slot a key of it names
|
|
23
|
+
* (`color_by`, `width_by`, a band's edges, a renderer's `text`, a template's
|
|
24
|
+
* `{{name}}`, ...) plus what the builder adds (its own column, its stack's
|
|
25
|
+
* and candle group's members). A unit whose inputs did not change reads
|
|
26
|
+
* exactly what it read before, so it does exactly what it did.
|
|
27
|
+
* - Row prefixes. A unit whose rows are each a function of their own bar (a
|
|
28
|
+
* line, a band, a per-row renderer's selection) made the same row for every
|
|
29
|
+
* bar the memo's rows share: every bar before the memo's newest. It takes
|
|
30
|
+
* those rows back (`rowPrefix`, a selection with the budget bytes they
|
|
31
|
+
* charged) and makes the rest, on a same-bar block and across a roll alike;
|
|
32
|
+
* a packed colour ladder starts from the palette those bars interned in
|
|
33
|
+
* first-seen order (`prefixPalette`).
|
|
34
|
+
*
|
|
35
|
+
* A unit that wrote over or removed an earlier output key, or wrote a key that
|
|
36
|
+
* orders by number, is not kept (it runs every build).
|
|
37
|
+
*/
|
|
38
|
+
import type { WrunIndicatorMetadata, WrunOutputRow } from '../../interfaces/wrun-runtime.interface.js';
|
|
39
|
+
/** A unit's per-bar rows: the rows it made and how many of them the bars before its newest made (and, for a
|
|
40
|
+
* selection, the render budget bytes those rows charged). */
|
|
41
|
+
interface WrunBuildRowPrefix {
|
|
42
|
+
rows: ReadonlyArray<unknown>;
|
|
43
|
+
count: number;
|
|
44
|
+
bytes?: number;
|
|
45
|
+
}
|
|
46
|
+
/** What one unit did: the output keys it wrote (in order, with the records), the pane homes it asked for, the
|
|
47
|
+
* output it claimed as the sheet's barcolor, its per-bar rows by slot and its own payload. */
|
|
48
|
+
interface WrunBuildUnitRecord {
|
|
49
|
+
writes: ReadonlyArray<readonly [string, unknown]>;
|
|
50
|
+
homes: ReadonlyArray<ReadonlyArray<unknown>>;
|
|
51
|
+
barcolor: unknown;
|
|
52
|
+
prefixes: ReadonlyMap<string, WrunBuildRowPrefix>;
|
|
53
|
+
payload?: unknown;
|
|
54
|
+
}
|
|
55
|
+
interface WrunBuildMemoState {
|
|
56
|
+
metadata: WrunIndicatorMetadata;
|
|
57
|
+
key: ReadonlyArray<unknown>;
|
|
58
|
+
rows: ReadonlyArray<WrunOutputRow>;
|
|
59
|
+
units: Map<string, WrunBuildUnitRecord>;
|
|
60
|
+
/** Per packed colour column: the colours the bars before the newest intern, in first-seen order. */
|
|
61
|
+
palettes: Map<number, ReadonlyArray<string>>;
|
|
62
|
+
/** Per handle (its id on its pane): the record the build adapted and the drawing it made. */
|
|
63
|
+
handles: Map<string, {
|
|
64
|
+
record: unknown;
|
|
65
|
+
drawing: unknown;
|
|
66
|
+
}>;
|
|
67
|
+
/** Per column set: the first row carrying a value in every column, -1 when none does. */
|
|
68
|
+
carries: Map<string, number>;
|
|
69
|
+
}
|
|
70
|
+
/** One overlay's memo: the units of its last completed live build. */
|
|
71
|
+
export interface WrunBuildMemo {
|
|
72
|
+
state: WrunBuildMemoState | undefined;
|
|
73
|
+
/** Units the last build replayed and ran (spec inspection). */
|
|
74
|
+
replayed: number;
|
|
75
|
+
ran: number;
|
|
76
|
+
}
|
|
77
|
+
export declare function createWrunBuildMemo(): WrunBuildMemo;
|
|
78
|
+
/** The builder's side of a unit: the outputs it writes into, its pane homes and its barcolor claim. */
|
|
79
|
+
export interface WrunBuildUnitSink {
|
|
80
|
+
outputs: Record<string, unknown>;
|
|
81
|
+
home(...args: unknown[]): void;
|
|
82
|
+
barcolor(): unknown;
|
|
83
|
+
claimBarcolor(output: unknown): void;
|
|
84
|
+
}
|
|
85
|
+
/** One build through the memo. */
|
|
86
|
+
export interface WrunBuildMemoSession {
|
|
87
|
+
/** The builder's outputs, homes and barcolor claim (bound once the builder holds them). */
|
|
88
|
+
bindSink(sink: WrunBuildUnitSink): void;
|
|
89
|
+
/** Replay the unit when nothing it reads changed since the memo's build, else run it, keeping what it wrote to
|
|
90
|
+
* the outputs (the sink). */
|
|
91
|
+
unit(id: string, reads: ReadonlySet<number>, run: () => void): void;
|
|
92
|
+
/** The same for a unit whose work is a value: replayed, it hands `replay` the value its last run returned. */
|
|
93
|
+
payloadUnit<T>(id: string, reads: ReadonlySet<number>, run: () => T, replay: (payload: T) => void): void;
|
|
94
|
+
/** Record a pane home the running unit asked for (the builder's homeKey calls it). */
|
|
95
|
+
noteHome(args: ReadonlyArray<unknown>): void;
|
|
96
|
+
/** The running unit's rows of `slot` for the bars before `from`, as its last build made them (the loop then
|
|
97
|
+
* makes the bars from `from` on); undefined when it has none to take back. `reachesForward`: a row reads a
|
|
98
|
+
* later bar's stamp (a forward displacement), so the rows stand only on the same bar count. */
|
|
99
|
+
rowPrefix(slot: string, reachesForward?: boolean): (WrunBuildRowPrefix & {
|
|
100
|
+
from: number;
|
|
101
|
+
}) | undefined;
|
|
102
|
+
/** The running unit made `rows` for `slot`, `count` of them from the bars before the newest (charging `bytes`
|
|
103
|
+
* of the render budget, for a selection). */
|
|
104
|
+
notePrefix(slot: string, rows: ReadonlyArray<unknown>, count: number, bytes?: number): void;
|
|
105
|
+
/** The colours the bars before the newest intern for a packed colour column, in first-seen order (`decode`
|
|
106
|
+
* reads one bar's value; undefined = no colour). */
|
|
107
|
+
prefixPalette(column: number, decode: (rung: unknown) => string | undefined): ReadonlyArray<string>;
|
|
108
|
+
/** A handle's drawing: the one the memo's build made when its record (`key`: its id on its pane) reads the
|
|
109
|
+
* same, else `adapt`'s (a handle's drawing is its record's alone, whatever the rows). */
|
|
110
|
+
handle<T>(key: string, record: unknown, adapt: () => T): T;
|
|
111
|
+
/** Whether a row carries a value in every one of `columns` (`carriesAt` tests one row): a carrying row among
|
|
112
|
+
* the memo's bars answers without a scan, and none there scans only the bars after them. */
|
|
113
|
+
carries(columns: ReadonlyArray<number>, carriesAt: (rowAt: number) => boolean): boolean;
|
|
114
|
+
/** The build completed: the memo now holds its units. */
|
|
115
|
+
commit(): void;
|
|
116
|
+
}
|
|
117
|
+
/** A string slot's place among a unit's reads (columns are 0 and up). */
|
|
118
|
+
export declare function wrunBuildSlotRead(slot: number): number;
|
|
119
|
+
/**
|
|
120
|
+
* Open a build through the memo: `key` is every option the units read beside
|
|
121
|
+
* the sheet and the rows (the pane side, the colour overrides, the params and
|
|
122
|
+
* texts, the interval, the selection context), compared by value.
|
|
123
|
+
*/
|
|
124
|
+
export declare function openWrunBuildMemo(memo: WrunBuildMemo, metadata: WrunIndicatorMetadata, key: ReadonlyArray<unknown>, rows: ReadonlyArray<WrunOutputRow>): WrunBuildMemoSession;
|
|
125
|
+
/**
|
|
126
|
+
* The columns and string slots (`wrunBuildSlotRead`) a build unit reads (the
|
|
127
|
+
* module note): every output and slot its declaration names anywhere (a name
|
|
128
|
+
* that is also a label or a word reads one input more, never one less), plus
|
|
129
|
+
* `extra` (what the builder adds: the output's own column, its stack's and
|
|
130
|
+
* candle group's members). Kept per sheet and unit.
|
|
131
|
+
*/
|
|
132
|
+
export declare function wrunBuildUnitReads(metadata: WrunIndicatorMetadata, id: string, declaration: unknown, extra?: Iterable<number>): ReadonlySet<number>;
|
|
133
|
+
export {};
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
export function createWrunBuildMemo() {
|
|
2
|
+
return { state: undefined, replayed: 0, ran: 0 };
|
|
3
|
+
}
|
|
4
|
+
function sameKey(a, b) {
|
|
5
|
+
if (a.length !== b.length)
|
|
6
|
+
return false;
|
|
7
|
+
for (let index = 0; index < a.length; index += 1)
|
|
8
|
+
if (!sameValue(a[index], b[index]))
|
|
9
|
+
return false;
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
/** Plain-data equality for the memo key (Object.is leaves, arrays and plain records by content). */
|
|
13
|
+
function sameValue(a, b) {
|
|
14
|
+
if (Object.is(a, b))
|
|
15
|
+
return true;
|
|
16
|
+
if (Array.isArray(a))
|
|
17
|
+
return Array.isArray(b) && sameKey(a, b);
|
|
18
|
+
if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null || Array.isArray(b))
|
|
19
|
+
return false;
|
|
20
|
+
const keys = Object.keys(a);
|
|
21
|
+
if (keys.length !== Object.keys(b).length)
|
|
22
|
+
return false;
|
|
23
|
+
for (const key of keys) {
|
|
24
|
+
if (!Object.prototype.hasOwnProperty.call(b, key))
|
|
25
|
+
return false;
|
|
26
|
+
if (!sameValue(a[key], b[key]))
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
/** A string slot's place among a unit's reads (columns are 0 and up). */
|
|
32
|
+
export function wrunBuildSlotRead(slot) {
|
|
33
|
+
return -(slot + 1);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* How the rows relate to the memo's: `prefix` bars (the memo's every bar
|
|
37
|
+
* before its newest) are the memo's own, 0 when none is (another sheet, other
|
|
38
|
+
* options, an older row replaced); `changed` (the columns and string slots the
|
|
39
|
+
* newest row changed) only when the rows are the memo's but the newest, at the
|
|
40
|
+
* same stamp and equally ready (a same-bar block), else null.
|
|
41
|
+
*/
|
|
42
|
+
function compareRows(state, metadata, key, rows) {
|
|
43
|
+
const none = { prefix: 0, changed: null };
|
|
44
|
+
if (state === undefined || state.metadata !== metadata || !sameKey(state.key, key))
|
|
45
|
+
return none;
|
|
46
|
+
const prefix = state.rows.length - 1;
|
|
47
|
+
if (prefix < 1 || rows.length < state.rows.length)
|
|
48
|
+
return none;
|
|
49
|
+
// Every older row is the one the memo's units read (a chart-name substitution copies a row, never its values).
|
|
50
|
+
for (let at = 0; at < prefix; at += 1) {
|
|
51
|
+
const was = state.rows[at];
|
|
52
|
+
const is = rows[at];
|
|
53
|
+
if (was !== is && (was.outputs !== is.outputs || was.ts !== is.ts))
|
|
54
|
+
return none;
|
|
55
|
+
}
|
|
56
|
+
if (rows.length !== state.rows.length)
|
|
57
|
+
return { prefix, changed: null };
|
|
58
|
+
const was = state.rows[prefix];
|
|
59
|
+
const is = rows[prefix];
|
|
60
|
+
if (was.ts !== is.ts || (was.outputs === null) !== (is.outputs === null))
|
|
61
|
+
return { prefix, changed: null };
|
|
62
|
+
const changed = new Set();
|
|
63
|
+
if (was.outputs !== null && is.outputs !== null && was.outputs !== is.outputs) {
|
|
64
|
+
if (was.outputs.length !== is.outputs.length)
|
|
65
|
+
return { prefix, changed: null };
|
|
66
|
+
for (let index = 0; index < is.outputs.length; index += 1) {
|
|
67
|
+
if (!Object.is(was.outputs[index], is.outputs[index]))
|
|
68
|
+
changed.add(index);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const wasStrings = was.strings ?? [];
|
|
72
|
+
const isStrings = is.strings ?? [];
|
|
73
|
+
if (wasStrings !== isStrings) {
|
|
74
|
+
for (let slot = 0; slot < Math.max(wasStrings.length, isStrings.length); slot += 1) {
|
|
75
|
+
if (wasStrings[slot] !== isStrings[slot])
|
|
76
|
+
changed.add(wrunBuildSlotRead(slot));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return { prefix, changed };
|
|
80
|
+
}
|
|
81
|
+
/** A key a record orders by number (an array index): the build's key order would not be its write order. */
|
|
82
|
+
const INDEX_KEY = /^(?:0|[1-9]\d*)$/;
|
|
83
|
+
/**
|
|
84
|
+
* Open a build through the memo: `key` is every option the units read beside
|
|
85
|
+
* the sheet and the rows (the pane side, the colour overrides, the params and
|
|
86
|
+
* texts, the interval, the selection context), compared by value.
|
|
87
|
+
*/
|
|
88
|
+
export function openWrunBuildMemo(memo, metadata, key, rows) {
|
|
89
|
+
const previous = memo.state;
|
|
90
|
+
const { prefix, changed } = compareRows(previous, metadata, key, rows);
|
|
91
|
+
const sameSheet = previous !== undefined && previous.metadata === metadata && sameKey(previous.key, key);
|
|
92
|
+
const handles = new Map();
|
|
93
|
+
const carries = new Map();
|
|
94
|
+
// A build that throws leaves no memo behind: the next one runs every unit.
|
|
95
|
+
memo.state = undefined;
|
|
96
|
+
memo.replayed = 0;
|
|
97
|
+
memo.ran = 0;
|
|
98
|
+
const units = new Map();
|
|
99
|
+
const palettes = new Map();
|
|
100
|
+
let sink;
|
|
101
|
+
// The running unit: the homes it asks for, its last build's per-bar rows and the ones it makes.
|
|
102
|
+
let running = null;
|
|
103
|
+
/** The unit's last record (it stands for its row prefixes whenever the bars before the memo's newest are the
|
|
104
|
+
* memo's) and whether it replays (a same-bar block that changed none of its inputs). */
|
|
105
|
+
const lookup = (id, reads) => {
|
|
106
|
+
const recorded = prefix > 0 ? previous?.units.get(id) : undefined;
|
|
107
|
+
let replays = recorded !== undefined && changed !== null;
|
|
108
|
+
if (replays)
|
|
109
|
+
for (const read of reads)
|
|
110
|
+
if (changed.has(read))
|
|
111
|
+
replays = false;
|
|
112
|
+
return { recorded, replays };
|
|
113
|
+
};
|
|
114
|
+
const runUnit = (recorded, run) => {
|
|
115
|
+
memo.ran += 1;
|
|
116
|
+
running = { homes: [], previous: recorded?.prefixes, prefixes: new Map() };
|
|
117
|
+
let unit;
|
|
118
|
+
let value;
|
|
119
|
+
try {
|
|
120
|
+
value = run();
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
unit = running;
|
|
124
|
+
running = null;
|
|
125
|
+
}
|
|
126
|
+
return { value, unit };
|
|
127
|
+
};
|
|
128
|
+
return {
|
|
129
|
+
bindSink(next) {
|
|
130
|
+
sink = next;
|
|
131
|
+
},
|
|
132
|
+
unit(id, reads, run) {
|
|
133
|
+
const target = sink;
|
|
134
|
+
if (target === undefined)
|
|
135
|
+
throw new Error('wrun build memo: a unit ran before the sink was bound');
|
|
136
|
+
const { recorded, replays } = lookup(id, reads);
|
|
137
|
+
if (replays && recorded !== undefined) {
|
|
138
|
+
for (const [outputKey, record] of recorded.writes)
|
|
139
|
+
target.outputs[outputKey] = record;
|
|
140
|
+
for (const args of recorded.homes)
|
|
141
|
+
target.home(...args);
|
|
142
|
+
if (recorded.barcolor !== undefined)
|
|
143
|
+
target.claimBarcolor(recorded.barcolor);
|
|
144
|
+
units.set(id, recorded);
|
|
145
|
+
memo.replayed += 1;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const keysBefore = Object.keys(target.outputs);
|
|
149
|
+
const recordsBefore = keysBefore.map((outputKey) => target.outputs[outputKey]);
|
|
150
|
+
const barcolorBefore = target.barcolor();
|
|
151
|
+
const { unit } = runUnit(recorded, run);
|
|
152
|
+
const keysAfter = Object.keys(target.outputs);
|
|
153
|
+
// Kept only when it added keys after every earlier one and touched none of them.
|
|
154
|
+
if (keysAfter.length < keysBefore.length)
|
|
155
|
+
return;
|
|
156
|
+
for (let index = 0; index < keysBefore.length; index += 1) {
|
|
157
|
+
if (keysAfter[index] !== keysBefore[index] || target.outputs[keysBefore[index]] !== recordsBefore[index]) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const written = keysAfter.slice(keysBefore.length);
|
|
162
|
+
if (written.some((outputKey) => INDEX_KEY.test(outputKey)))
|
|
163
|
+
return;
|
|
164
|
+
const barcolor = target.barcolor();
|
|
165
|
+
units.set(id, {
|
|
166
|
+
writes: written.map((outputKey) => [outputKey, target.outputs[outputKey]]),
|
|
167
|
+
homes: unit.homes,
|
|
168
|
+
barcolor: barcolor !== barcolorBefore ? barcolor : undefined,
|
|
169
|
+
prefixes: unit.prefixes,
|
|
170
|
+
});
|
|
171
|
+
},
|
|
172
|
+
payloadUnit(id, reads, run, replay) {
|
|
173
|
+
const { recorded, replays } = lookup(id, reads);
|
|
174
|
+
if (replays && recorded !== undefined) {
|
|
175
|
+
replay(recorded.payload);
|
|
176
|
+
units.set(id, recorded);
|
|
177
|
+
memo.replayed += 1;
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const { value, unit } = runUnit(recorded, run);
|
|
181
|
+
units.set(id, { writes: [], homes: [], barcolor: undefined, prefixes: unit.prefixes, payload: value });
|
|
182
|
+
},
|
|
183
|
+
noteHome(args) {
|
|
184
|
+
running?.homes.push([...args]);
|
|
185
|
+
},
|
|
186
|
+
rowPrefix(slot, reachesForward = false) {
|
|
187
|
+
// Only over the memo's bars does a bar's row stand (and a row that reads a later bar's stamp only while
|
|
188
|
+
// the bar count holds: past the newest bar a stamp is extrapolated, inside it it is the bar's own).
|
|
189
|
+
if (prefix === 0 || running === null)
|
|
190
|
+
return undefined;
|
|
191
|
+
if (reachesForward && rows.length !== prefix + 1)
|
|
192
|
+
return undefined;
|
|
193
|
+
const recorded = running.previous?.get(slot);
|
|
194
|
+
return recorded === undefined ? undefined : { ...recorded, from: prefix };
|
|
195
|
+
},
|
|
196
|
+
notePrefix(slot, prefixRows, count, bytes) {
|
|
197
|
+
running?.prefixes.set(slot, { rows: prefixRows, count, ...(bytes !== undefined ? { bytes } : {}) });
|
|
198
|
+
},
|
|
199
|
+
prefixPalette(column, decode) {
|
|
200
|
+
const kept = palettes.get(column);
|
|
201
|
+
if (kept !== undefined)
|
|
202
|
+
return kept;
|
|
203
|
+
// The bars before the newest: the memo's (its palette, when it holds one) and the ones after them.
|
|
204
|
+
const known = prefix > 0 ? previous?.palettes.get(column) : undefined;
|
|
205
|
+
const seen = new Set(known);
|
|
206
|
+
const colors = known === undefined ? [] : [...known];
|
|
207
|
+
for (let at = known === undefined ? 0 : prefix; at < rows.length - 1; at += 1) {
|
|
208
|
+
const color = decode(rows[at].outputs?.[column]);
|
|
209
|
+
if (color !== undefined && !seen.has(color)) {
|
|
210
|
+
seen.add(color);
|
|
211
|
+
colors.push(color);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
palettes.set(column, colors);
|
|
215
|
+
return colors;
|
|
216
|
+
},
|
|
217
|
+
handle(handleKey, record, adapt) {
|
|
218
|
+
const known = sameSheet ? previous?.handles.get(handleKey) : undefined;
|
|
219
|
+
const drawing = known !== undefined && sameValue(known.record, record) ? known.drawing : adapt();
|
|
220
|
+
handles.set(handleKey, { record, drawing });
|
|
221
|
+
return drawing;
|
|
222
|
+
},
|
|
223
|
+
carries(columns, carriesAt) {
|
|
224
|
+
const carryKey = columns.join(',');
|
|
225
|
+
let first = carries.get(carryKey);
|
|
226
|
+
if (first === undefined) {
|
|
227
|
+
// The memo's first carrying row stands when it is one of the bars the rows share; none among them (-1, or
|
|
228
|
+
// only its newest bar) leaves the bars from there on to scan.
|
|
229
|
+
const known = prefix > 0 ? previous?.carries.get(carryKey) : undefined;
|
|
230
|
+
if (known !== undefined && known >= 0 && known < prefix)
|
|
231
|
+
first = known;
|
|
232
|
+
else {
|
|
233
|
+
first = -1;
|
|
234
|
+
for (let at = known === undefined ? 0 : prefix; at < rows.length; at += 1) {
|
|
235
|
+
if (carriesAt(at)) {
|
|
236
|
+
first = at;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
carries.set(carryKey, first);
|
|
242
|
+
}
|
|
243
|
+
return first >= 0;
|
|
244
|
+
},
|
|
245
|
+
commit() {
|
|
246
|
+
memo.state = { metadata, key, rows, units, palettes, handles, carries };
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
/** Every string a declaration holds, at any depth (its keys' values, arrays and records alike), and every name a
|
|
251
|
+
* `{{name}}` / `{{name:format}}` template in one of them reads. */
|
|
252
|
+
function collectStrings(value, into, depth = 0) {
|
|
253
|
+
if (depth > 8)
|
|
254
|
+
return;
|
|
255
|
+
if (typeof value === 'string') {
|
|
256
|
+
into.add(value);
|
|
257
|
+
if (value.includes('{{')) {
|
|
258
|
+
for (const match of value.matchAll(/\{\{\s*([^}:\s]+)\s*(?::[^}]*)?\}\}/g))
|
|
259
|
+
into.add(match[1]);
|
|
260
|
+
}
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (Array.isArray(value)) {
|
|
264
|
+
for (const item of value)
|
|
265
|
+
collectStrings(item, into, depth + 1);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (typeof value === 'object' && value !== null) {
|
|
269
|
+
for (const item of Object.values(value))
|
|
270
|
+
collectStrings(item, into, depth + 1);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const unitReads = new WeakMap();
|
|
274
|
+
/**
|
|
275
|
+
* The columns and string slots (`wrunBuildSlotRead`) a build unit reads (the
|
|
276
|
+
* module note): every output and slot its declaration names anywhere (a name
|
|
277
|
+
* that is also a label or a word reads one input more, never one less), plus
|
|
278
|
+
* `extra` (what the builder adds: the output's own column, its stack's and
|
|
279
|
+
* candle group's members). Kept per sheet and unit.
|
|
280
|
+
*/
|
|
281
|
+
export function wrunBuildUnitReads(metadata, id, declaration, extra = []) {
|
|
282
|
+
let bySheet = unitReads.get(metadata);
|
|
283
|
+
if (bySheet === undefined) {
|
|
284
|
+
bySheet = new Map();
|
|
285
|
+
unitReads.set(metadata, bySheet);
|
|
286
|
+
}
|
|
287
|
+
const known = bySheet.get(id);
|
|
288
|
+
if (known !== undefined)
|
|
289
|
+
return known;
|
|
290
|
+
const names = new Set();
|
|
291
|
+
collectStrings(declaration, names);
|
|
292
|
+
const reads = new Set(extra);
|
|
293
|
+
for (const output of metadata.outputs)
|
|
294
|
+
if (names.has(output.name))
|
|
295
|
+
reads.add(output.index);
|
|
296
|
+
for (const slot of metadata.string_slots ?? [])
|
|
297
|
+
if (names.has(slot.name))
|
|
298
|
+
reads.add(wrunBuildSlotRead(slot.index));
|
|
299
|
+
bySheet.set(id, reads);
|
|
300
|
+
return reads;
|
|
301
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the pre-candle path knows of the twins join (wrun-twins.util, wrun-twins.json): the
|
|
3
|
+
* `@om-core` package each shipped built-in's port is published under, and how a port's params
|
|
4
|
+
* name its template's inputs. The alert doors and the alert words (alert-overlay-target.util,
|
|
5
|
+
* indicator-alert-name.util) ride that path and judge a port by its package where no stamp names
|
|
6
|
+
* its built-in (`builtinTwinOf`, wrun-builtin-twin.util): a port added outside the proven route,
|
|
7
|
+
* and every alert doc, which never carries one. The join itself (the proven pins, the doc-id
|
|
8
|
+
* officials, the route) stays off it (tests/utility/wrun/wrun-twins.closure.spec.ts).
|
|
9
|
+
*
|
|
10
|
+
* The table is the join's rows keyed to a built-in, proven or not
|
|
11
|
+
* (wrunBuiltInKeyOfPackage), held in lockstep with the join by the roster spec
|
|
12
|
+
* (tests/constants/wrun-twins.roster.spec.ts): a port the join gains lands here in the same change.
|
|
13
|
+
*/
|
|
14
|
+
/** Each built-in's port: its package -> the built-in's registry key. */
|
|
15
|
+
export declare const BUILTIN_TWIN_PORTS: ReadonlyMap<string, string>;
|
|
16
|
+
/** The shipped built-in a registry package ports (`RSI` for `@om-core/rsi`), or undefined. Whether
|
|
17
|
+
* the port is proven, and at which version, stays the join's (provenBuiltInKeyOf). */
|
|
18
|
+
export declare function builtinTwinOfPackage(packageName: string): string | undefined;
|
|
19
|
+
/** The setting a twin row of `builtInKey` holds, as a match key: the template input it maps to (its name, through
|
|
20
|
+
* the built-in's alias), case and separators dropped. The proven add's template-keyed values
|
|
21
|
+
* (wrun-proven-twin-add.util), a saved package's move to the version it follows (wrun-twin-pin-move.util) and an
|
|
22
|
+
* alert's legend settings (indicator-alert-name.util) pair rows by it, so Volume's `currency` (0.2.0) and
|
|
23
|
+
* `volume_unit` (0.3.0) are one setting. Without a built-in (an official following the registry's latest) the name
|
|
24
|
+
* alone. */
|
|
25
|
+
export declare function builtinTwinRowKey(builtInKey: string | undefined, name: string): string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the pre-candle path knows of the twins join (wrun-twins.util, wrun-twins.json): the
|
|
3
|
+
* `@om-core` package each shipped built-in's port is published under, and how a port's params
|
|
4
|
+
* name its template's inputs. The alert doors and the alert words (alert-overlay-target.util,
|
|
5
|
+
* indicator-alert-name.util) ride that path and judge a port by its package where no stamp names
|
|
6
|
+
* its built-in (`builtinTwinOf`, wrun-builtin-twin.util): a port added outside the proven route,
|
|
7
|
+
* and every alert doc, which never carries one. The join itself (the proven pins, the doc-id
|
|
8
|
+
* officials, the route) stays off it (tests/utility/wrun/wrun-twins.closure.spec.ts).
|
|
9
|
+
*
|
|
10
|
+
* The table is the join's rows keyed to a built-in, proven or not
|
|
11
|
+
* (wrunBuiltInKeyOfPackage), held in lockstep with the join by the roster spec
|
|
12
|
+
* (tests/constants/wrun-twins.roster.spec.ts): a port the join gains lands here in the same change.
|
|
13
|
+
*/
|
|
14
|
+
/** Each built-in's port: its package -> the built-in's registry key. */
|
|
15
|
+
export const BUILTIN_TWIN_PORTS = new Map([
|
|
16
|
+
['@om-core/adl', 'ADL'],
|
|
17
|
+
['@om-core/adx', 'ADX'],
|
|
18
|
+
['@om-core/aroon', 'AROON'],
|
|
19
|
+
['@om-core/atr', 'ATR'],
|
|
20
|
+
['@om-core/awesome-oscillator', 'AO'],
|
|
21
|
+
['@om-core/bar-statistics', 'BAR_STATISTICS'],
|
|
22
|
+
['@om-core/big-trades', 'BIG_TRADES'],
|
|
23
|
+
['@om-core/bollinger-bands', 'BOLLINGER_BANDS'],
|
|
24
|
+
['@om-core/cci', 'CCI'],
|
|
25
|
+
['@om-core/chaikin-money-flow', 'CMF'],
|
|
26
|
+
['@om-core/cvd-flow-dominance', 'CVD_FLOW_DOMINANCE'],
|
|
27
|
+
['@om-core/donchian-channels', 'DONCHIAN'],
|
|
28
|
+
['@om-core/ema', 'EMA'],
|
|
29
|
+
['@om-core/hma', 'HMA'],
|
|
30
|
+
['@om-core/ichimoku-cloud', 'ICHI_CLOUD'],
|
|
31
|
+
['@om-core/keltner-channels', 'KELTNER'],
|
|
32
|
+
['@om-core/macd', 'MACD'],
|
|
33
|
+
['@om-core/mfi', 'MFI'],
|
|
34
|
+
['@om-core/momentum', 'MOMENTUM'],
|
|
35
|
+
['@om-core/obv', 'OBV'],
|
|
36
|
+
['@om-core/pivot-points-standard', 'PIVOT_POINTS'],
|
|
37
|
+
['@om-core/psar', 'PSAR'],
|
|
38
|
+
['@om-core/rate-of-change', 'ROC'],
|
|
39
|
+
['@om-core/rsi', 'RSI'],
|
|
40
|
+
['@om-core/sma-official', 'SMA'],
|
|
41
|
+
['@om-core/stochastic-oscillator', 'STOCH'],
|
|
42
|
+
['@om-core/stochastic-rsi', 'STOCH_RSI'],
|
|
43
|
+
['@om-core/supertrend', 'SUPERTREND'],
|
|
44
|
+
['@om-core/volume-bar', 'VOLUME_BAR'],
|
|
45
|
+
['@om-core/volume-bubbles', 'VOLUME_BUBBLES'],
|
|
46
|
+
['@om-core/vwma', 'VWMA'],
|
|
47
|
+
['@om-core/williams-r', 'WILLIAMS_R'],
|
|
48
|
+
['@om-core/wma', 'WMA'],
|
|
49
|
+
['@om-core/zig-zag', 'ZIGZAG'],
|
|
50
|
+
]);
|
|
51
|
+
/** The shipped built-in a registry package ports (`RSI` for `@om-core/rsi`), or undefined. Whether
|
|
52
|
+
* the port is proven, and at which version, stays the join's (provenBuiltInKeyOf). */
|
|
53
|
+
export function builtinTwinOfPackage(packageName) {
|
|
54
|
+
return BUILTIN_TWIN_PORTS.get(packageName);
|
|
55
|
+
}
|
|
56
|
+
/** A twin param whose name differs from its template input beyond case and separators, per
|
|
57
|
+
* built-in: Volume's unit select is `volume_unit` from 0.3.0 on because om reserves `currency`
|
|
58
|
+
* (a chart refetch field kept beside script settings), while the template's input stays
|
|
59
|
+
* `currency`. A twin mounted at 0.2.0 still carries `currency` and matches by name. */
|
|
60
|
+
const TWIN_PARAM_ALIASES = {
|
|
61
|
+
VOLUME_BAR: { volume_unit: 'currency' },
|
|
62
|
+
};
|
|
63
|
+
/** An input name with case and separators dropped: `wait_for_close` and `waitForClose` alike. */
|
|
64
|
+
function inputNameKey(name) {
|
|
65
|
+
return name.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
66
|
+
}
|
|
67
|
+
/** The setting a twin row of `builtInKey` holds, as a match key: the template input it maps to (its name, through
|
|
68
|
+
* the built-in's alias), case and separators dropped. The proven add's template-keyed values
|
|
69
|
+
* (wrun-proven-twin-add.util), a saved package's move to the version it follows (wrun-twin-pin-move.util) and an
|
|
70
|
+
* alert's legend settings (indicator-alert-name.util) pair rows by it, so Volume's `currency` (0.2.0) and
|
|
71
|
+
* `volume_unit` (0.3.0) are one setting. Without a built-in (an official following the registry's latest) the name
|
|
72
|
+
* alone. */
|
|
73
|
+
export function builtinTwinRowKey(builtInKey, name) {
|
|
74
|
+
return inputNameKey((builtInKey ? TWIN_PARAM_ALIASES[builtInKey]?.[name] : undefined) ?? name);
|
|
75
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The settings key of the stamp. */
|
|
2
|
+
export declare const BUILTIN_TWIN_OF_SETTING = "builtinTwinOf";
|
|
3
|
+
/** The built-in a registry overlay stands for (its `builtinTwinOf`
|
|
4
|
+
* stamp), or undefined: no registry identity beside it, a stamp that names
|
|
5
|
+
* no built-in (isBuiltInTwinKey: a template or a native), or a stamp beside a
|
|
6
|
+
* package that is not that built-in's port (BUILTIN_TWIN_PORTS). The stamp is
|
|
7
|
+
* a settings value: read alone, any package could claim a built-in's saved
|
|
8
|
+
* values, guide, one-per-chart rule and theme by carrying it. */
|
|
9
|
+
export declare function builtinTwinOf(settings: unknown): string | undefined;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The persisted stamp of a PROVEN wrun twin (option A, wrun-twins.util): when
|
|
3
|
+
* the proven route mounts a built-in's twin (the Indicators section's built-in
|
|
4
|
+
* row, or its super search row), the overlay records which built-in it
|
|
5
|
+
* stands for as `settings.builtinTwinOf` ("RSI", "CVD_FLOW_DOMINANCE", ...), beside its
|
|
6
|
+
* registry identity (`wrunRegistryRef`). Persisted through the settings
|
|
7
|
+
* whitelist and every settings rebuild, so the record names its built-in on
|
|
8
|
+
* any chart that restores it, whoever views it.
|
|
9
|
+
*
|
|
10
|
+
* Readers: the theme (builtin-script-theme-palette.util builtinThemeKey: the
|
|
11
|
+
* twin wears its built-in's palette), the boot seam and the loader's
|
|
12
|
+
* rehydrator (wrun-registry-boot.util, wrun-registry-loader.service: a twin
|
|
13
|
+
* follows its built-in's pin; one that cannot compute for the viewer stays a
|
|
14
|
+
* twin in the unavailable state any package takes, never its built-in's
|
|
15
|
+
* kScript template).
|
|
16
|
+
*
|
|
17
|
+
* Deliberately tiny and free of the twins join (wrun-twins.json): the theme
|
|
18
|
+
* and the boot seam sit on the pre-candle path, and the stamp is all they need.
|
|
19
|
+
*/
|
|
20
|
+
import { isBuiltInTwinKey } from '../../constants/scriptEditor/technicalIndicatorScriptKeys.constants.js';
|
|
21
|
+
import { builtinTwinOfPackage } from './wrun-builtin-twin-ports.util.js';
|
|
22
|
+
/** The settings key of the stamp. */
|
|
23
|
+
export const BUILTIN_TWIN_OF_SETTING = 'builtinTwinOf';
|
|
24
|
+
/** The built-in a registry overlay stands for (its `builtinTwinOf`
|
|
25
|
+
* stamp), or undefined: no registry identity beside it, a stamp that names
|
|
26
|
+
* no built-in (isBuiltInTwinKey: a template or a native), or a stamp beside a
|
|
27
|
+
* package that is not that built-in's port (BUILTIN_TWIN_PORTS). The stamp is
|
|
28
|
+
* a settings value: read alone, any package could claim a built-in's saved
|
|
29
|
+
* values, guide, one-per-chart rule and theme by carrying it. */
|
|
30
|
+
export function builtinTwinOf(settings) {
|
|
31
|
+
if (!settings || typeof settings !== 'object')
|
|
32
|
+
return undefined;
|
|
33
|
+
const { wrunRegistryRef: ref, [BUILTIN_TWIN_OF_SETTING]: stamp } = settings;
|
|
34
|
+
const packageName = ref && typeof ref === 'object' ? ref.package : undefined;
|
|
35
|
+
if (typeof packageName !== 'string' || packageName === '')
|
|
36
|
+
return undefined;
|
|
37
|
+
if (!isBuiltInTwinKey(stamp))
|
|
38
|
+
return undefined;
|
|
39
|
+
return builtinTwinOfPackage(packageName) === stamp ? stamp : undefined;
|
|
40
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The price canvases' fold memo (WRUN guardrails G3b): what a host fold of a
|
|
3
|
+
* canvas child (today the TPO, `buildWrunTpoRows` with a `cacheKey`) keeps
|
|
4
|
+
* between runs and ticks so a live tick folds only what changed (the forming
|
|
5
|
+
* period) instead of every loaded bar on the main thread. The entries are
|
|
6
|
+
* opaque here: each builder owns its own entry shape and its validation.
|
|
7
|
+
*
|
|
8
|
+
* Keys are `<overlayId>::<kind>:<name>` (the TPO's `<overlayId>::tpo:<name>`),
|
|
9
|
+
* so forgetWrunCanvasCache with the prefix `<overlayId>::` drops every canvas
|
|
10
|
+
* of one overlay: the live tick lane calls it from its teardown hook (overlay
|
|
11
|
+
* removed, found unmounted, chart torn down). The store is also bounded: past
|
|
12
|
+
* WRUN_CANVAS_CACHE_MAX_KEYS the least recently used key goes, so an overlay
|
|
13
|
+
* that leaves without a teardown never pins its rows.
|
|
14
|
+
*/
|
|
15
|
+
/** The most canvas keys held at once (least recently used evicted first). */
|
|
16
|
+
export declare const WRUN_CANVAS_CACHE_MAX_KEYS = 64;
|
|
17
|
+
/** The entry under `key` (marked most recently used), undefined when none. */
|
|
18
|
+
export declare function readWrunCanvasCache<T>(key: string): T | undefined;
|
|
19
|
+
/** Store `entry` under `key` as the most recently used, evicting the least recently used past the bound. */
|
|
20
|
+
export declare function writeWrunCanvasCache<T>(key: string, entry: T): void;
|
|
21
|
+
/** Drop the entry under `key`, if any. */
|
|
22
|
+
export declare function dropWrunCanvasCache(key: string): void;
|
|
23
|
+
/** Drop every entry whose key starts with `prefix` (an overlay's canvases: `${overlayId}::`). */
|
|
24
|
+
export declare function forgetWrunCanvasCache(prefix: string): void;
|
|
25
|
+
/** Spec probe: the held keys, least recently used first. */
|
|
26
|
+
export declare function wrunCanvasCacheKeys(): string[];
|
|
27
|
+
/** Spec reset: drop every entry. */
|
|
28
|
+
export declare function __resetWrunCanvasCacheForTests(): void;
|