@tidal-ts/terminal 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/LICENSE +21 -0
- package/dist/axisPolicy.d.ts +34 -0
- package/dist/axisPolicy.js +31 -0
- package/dist/context.d.ts +103 -0
- package/dist/context.js +229 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/terminalMachine.d.ts +683 -0
- package/dist/terminalMachine.js +2229 -0
- package/package.json +59 -0
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
import { type DeriveOp, type DeriveSpec } from '@tidal-ts/core';
|
|
2
|
+
/**
|
|
3
|
+
* The bar columns each data SOURCE carries — the one fact that decides whether a
|
|
4
|
+
* multi-column study is offerable on a series. Only the price series has bars;
|
|
5
|
+
* 54 of the adopted studies read high/low/close/volume, and on a vol series
|
|
6
|
+
* those columns name nothing. Held here, in the config-only machine, because
|
|
7
|
+
* it is a fact about the vocabulary (what a source key means), not about data —
|
|
8
|
+
* and because the menu AND the guard must agree, so there is exactly one copy.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SOURCE_COLUMNS: Readonly<Record<string, readonly string[]>>;
|
|
11
|
+
/** Whether `op` can run on `source` — every bar column it needs is carried.
|
|
12
|
+
* The menu filters on it; `canAddStudy` refuses on it. */
|
|
13
|
+
export declare function studyOfferable(source: string | undefined, op: DeriveOp): boolean;
|
|
14
|
+
import { type PairLensOp } from '@tidal-ts/chart';
|
|
15
|
+
import { type AxisRange, type SeriesAxis, type SeriesConfig } from '@tidal-ts/chart';
|
|
16
|
+
/**
|
|
17
|
+
* The terminal machine (XState migration, slice 2 — see Tidal's state-architecture note).
|
|
18
|
+
* The **headless product**: it owns the control-panel *configuration* — rows of
|
|
19
|
+
* series, the current selection, the controls-popover flag, and the preset slots
|
|
20
|
+
* — and **never touches data**. Its event union is the host-control API; its
|
|
21
|
+
* snapshot (via the module's selector hooks) is the read API. This is the
|
|
22
|
+
* extraction candidate, so it imports only `@tidal-ts/chart` types + its own
|
|
23
|
+
* `axisPolicy` — never the socket / auth / data layers, never app config
|
|
24
|
+
* directly (the series catalog arrives as `input`).
|
|
25
|
+
*
|
|
26
|
+
* Born **row-general** (Wave A of the indicator design, folded in here): the
|
|
27
|
+
* two fixed panels become `rows: RowState[]`, seeded with today's two. A config
|
|
28
|
+
* names its data `source` by key; rows are viewports. Data-filtering (dropping a
|
|
29
|
+
* series the current feed lacks) stays render-side — the machine holds every
|
|
30
|
+
* configured series regardless of what data is loaded.
|
|
31
|
+
*/
|
|
32
|
+
/** A viewport row: its committed height + the series configured in it. */
|
|
33
|
+
export interface RowState {
|
|
34
|
+
id: string;
|
|
35
|
+
/** Committed px height (updated on splitter drag-end); 0 ⇒ take the remainder. */
|
|
36
|
+
height: number;
|
|
37
|
+
configs: SeriesConfig[];
|
|
38
|
+
}
|
|
39
|
+
/** A saved control preset — the rows only (never the ticker/range, which live in
|
|
40
|
+
* the host). Migrated from the old `{ volCfg, priceCfg }` shape by the storage
|
|
41
|
+
* adapter. */
|
|
42
|
+
export interface TerminalPreset {
|
|
43
|
+
rows: RowState[];
|
|
44
|
+
}
|
|
45
|
+
/** The minimal catalog-entry shape the machine needs (host-supplied as `input`;
|
|
46
|
+
* `seriesCatalog`'s entries satisfy it structurally). Keeps the module free of
|
|
47
|
+
* an app-config import for extraction. */
|
|
48
|
+
export interface MetricEntry {
|
|
49
|
+
id: string;
|
|
50
|
+
label: string;
|
|
51
|
+
color: string;
|
|
52
|
+
unit: string;
|
|
53
|
+
/** Data-source key a config from this entry reads (`'vol'` / `'price'` today). */
|
|
54
|
+
source: string;
|
|
55
|
+
style: SeriesConfig['style'];
|
|
56
|
+
axis: SeriesAxis;
|
|
57
|
+
column?: string;
|
|
58
|
+
/** Tenor-bearing metric metadata (the ATM vols): family name + tenor, carried
|
|
59
|
+
* onto the config so the controls read it as name + params. */
|
|
60
|
+
family?: string;
|
|
61
|
+
tenor?: number;
|
|
62
|
+
/** Which censor variant this column is, for metrics that take that parameter —
|
|
63
|
+
* carried onto the config so the controls can show and edit it. */
|
|
64
|
+
censor?: string;
|
|
65
|
+
/** A **derived** metric (e.g. the realized-vol line): its column is induced from
|
|
66
|
+
* this spec by `applyDerived`, not read from the feed. Absent ⇒ raw. */
|
|
67
|
+
derive?: DeriveSpec;
|
|
68
|
+
}
|
|
69
|
+
/** Injectable persistence for the preset slots (default: the app's localStorage
|
|
70
|
+
* keys). A host brings its own storage, or none. */
|
|
71
|
+
export interface PresetStorage {
|
|
72
|
+
loadPresets(): (TerminalPreset | null)[];
|
|
73
|
+
savePresets(presets: (TerminalPreset | null)[]): void;
|
|
74
|
+
/** The persisted active-slot pointer — only used to seed `initialRows`. */
|
|
75
|
+
loadActive(): number | null;
|
|
76
|
+
saveActive(index: number | null): void;
|
|
77
|
+
}
|
|
78
|
+
export declare const PRESET_SLOTS = 5;
|
|
79
|
+
/** Max viewport rows (the control-panel spec: 1–3, capped at 3 for now). */
|
|
80
|
+
export declare const MAX_ROWS = 3;
|
|
81
|
+
export declare const mintId: (seq: number) => string;
|
|
82
|
+
interface TerminalContext {
|
|
83
|
+
/** The host's colour keys for new series, in hand-out order. */
|
|
84
|
+
palette: readonly string[];
|
|
85
|
+
rows: RowState[];
|
|
86
|
+
/** Per-axis range state, keyed by axis id (`configAxisId` — `rowId:side` for a
|
|
87
|
+
* shared axis, `rowId:side:configId` for an unlinked series' own axis). No
|
|
88
|
+
* entry ⇒ an untouched auto axis; `mode:'auto'` WITH values is the preserved
|
|
89
|
+
* manual memory. Entries are never pruned (a stale id simply never renders,
|
|
90
|
+
* and an unlink/re-add that resurrects the id gets its manual range back) —
|
|
91
|
+
* except on `preset.select`, which resets the lot: an applied preset must
|
|
92
|
+
* restore a known look, and a leftover manual range under different rows
|
|
93
|
+
* reads as a broken chart with no visible cause. */
|
|
94
|
+
axisRanges: Record<string, AxisRange>;
|
|
95
|
+
/** Monotonic counter for generated row ids — never reset on remove, so an
|
|
96
|
+
* `add → remove → add` sequence can't reuse an id (`row-2` twice). */
|
|
97
|
+
rowSeq: number;
|
|
98
|
+
/** Monotonic counter for minted CONFIG ids (see {@link mintId}). Same rule as
|
|
99
|
+
* `rowSeq`, plus one more: applying a preset re-seeds it above the ids that
|
|
100
|
+
* preset restored. */
|
|
101
|
+
cfgSeq: number;
|
|
102
|
+
/** The **app** selection — the series emphasised on the chart from a legend
|
|
103
|
+
* click. Persists under a control-panel expansion + closing the panel. */
|
|
104
|
+
selected: string | null;
|
|
105
|
+
/** The **control-panel** expansion — the row whose controls are open. While set
|
|
106
|
+
* it overrides `selected` for chart emphasis (but doesn't replace it); cleared
|
|
107
|
+
* on collapse or closing the panel, so emphasis falls back to `selected`. */
|
|
108
|
+
expanded: string | null;
|
|
109
|
+
controlsOpen: boolean;
|
|
110
|
+
presets: (TerminalPreset | null)[];
|
|
111
|
+
catalog: readonly MetricEntry[];
|
|
112
|
+
storage: PresetStorage;
|
|
113
|
+
}
|
|
114
|
+
/** Public command surface — the host-control API + the reference SeriesControls'
|
|
115
|
+
* event union (the pre-paid bus contract). */
|
|
116
|
+
export type TerminalEvent = {
|
|
117
|
+
type: 'series.add';
|
|
118
|
+
catalogId: string;
|
|
119
|
+
rowId?: string;
|
|
120
|
+
} | {
|
|
121
|
+
type: 'series.addStudy';
|
|
122
|
+
targetId: string;
|
|
123
|
+
op: DeriveOp;
|
|
124
|
+
period: number;
|
|
125
|
+
}
|
|
126
|
+
/** Add an A-vs-B spread. `rowId` names the row to seat it on — the per-row
|
|
127
|
+
* `+Pair` affordance, and an EXPLICIT choice, so it wins over the default
|
|
128
|
+
* (in front of leg A, which is only a guess about where you want it). */
|
|
129
|
+
| {
|
|
130
|
+
type: 'series.addPair';
|
|
131
|
+
a: PairLegInput;
|
|
132
|
+
b: PairLegInput;
|
|
133
|
+
op: PairLensOp;
|
|
134
|
+
rowId?: string;
|
|
135
|
+
}
|
|
136
|
+
/** Pair EVERY visible plain metric against the comparison symbol, in one
|
|
137
|
+
* gesture — the bar's bulk compare. Deliberately an ACTION and not a mode:
|
|
138
|
+
* it writes ordinary pairs and then has nothing left to remember, so there is
|
|
139
|
+
* no state to flip back and no ownership to track (Peter, 2026-08-25). */
|
|
140
|
+
| {
|
|
141
|
+
type: 'series.compareAll';
|
|
142
|
+
}
|
|
143
|
+
/** Retune ONE declared param of a study. `name` because a study is tuned by
|
|
144
|
+
* whatever its op declares — a band carries `period` AND `stdDev` — so the
|
|
145
|
+
* event names the knob rather than assuming there is only one. */
|
|
146
|
+
| {
|
|
147
|
+
type: 'series.setStudyParam';
|
|
148
|
+
id: string;
|
|
149
|
+
name: string;
|
|
150
|
+
value: number;
|
|
151
|
+
}
|
|
152
|
+
/** Draw-order (z) within the series' own row. The row's config list is
|
|
153
|
+
* **front→back** — index 0 paints on top (the render reverses for
|
|
154
|
+
* `<Layers>`), so `up` moves toward the front. */
|
|
155
|
+
| {
|
|
156
|
+
type: 'series.order';
|
|
157
|
+
id: string;
|
|
158
|
+
to: 'front' | 'up' | 'down' | 'back';
|
|
159
|
+
}
|
|
160
|
+
/** Reposition a series **to a target index** in its row (the drag gesture). */
|
|
161
|
+
| {
|
|
162
|
+
type: 'series.reindex';
|
|
163
|
+
id: string;
|
|
164
|
+
index: number;
|
|
165
|
+
}
|
|
166
|
+
/** Move a series to another row (keeping its relative front position). */
|
|
167
|
+
| {
|
|
168
|
+
type: 'series.moveToRow';
|
|
169
|
+
id: string;
|
|
170
|
+
rowId: string;
|
|
171
|
+
} | {
|
|
172
|
+
type: 'series.remove';
|
|
173
|
+
id: string;
|
|
174
|
+
}
|
|
175
|
+
/** Patch a series' INK (colour, style, width, window, visibility …). The
|
|
176
|
+
* arrangement fields are excluded by type: `axis`/`axisGroup` name the axis a
|
|
177
|
+
* series sits on, whose ids key `axisRanges`, so they move only through
|
|
178
|
+
* `axis.swapSide` / `axis.toggleLink`, which keep the pins coherent. */
|
|
179
|
+
| {
|
|
180
|
+
type: 'series.patch';
|
|
181
|
+
id: string;
|
|
182
|
+
patch: Partial<Omit<SeriesConfig, 'axis' | 'axisGroup'>>;
|
|
183
|
+
} | {
|
|
184
|
+
type: 'series.toggleVisible';
|
|
185
|
+
id: string;
|
|
186
|
+
}
|
|
187
|
+
/** The PAIR's own eye — hides both legs at once. Each leg keeps its own
|
|
188
|
+
* `visible`, so unhiding the pair restores what each leg was rather than
|
|
189
|
+
* switching everything on (Peter, 2026-08-18). */
|
|
190
|
+
| {
|
|
191
|
+
type: 'group.toggleVisible';
|
|
192
|
+
groupId: string;
|
|
193
|
+
}
|
|
194
|
+
/** Remove a whole pair — both legs and anything layered on them. */
|
|
195
|
+
| {
|
|
196
|
+
type: 'group.remove';
|
|
197
|
+
groupId: string;
|
|
198
|
+
} | {
|
|
199
|
+
type: 'select';
|
|
200
|
+
id: string | null;
|
|
201
|
+
} | {
|
|
202
|
+
type: 'expand';
|
|
203
|
+
id: string | null;
|
|
204
|
+
} | {
|
|
205
|
+
type: 'controls.open';
|
|
206
|
+
} | {
|
|
207
|
+
type: 'controls.close';
|
|
208
|
+
} | {
|
|
209
|
+
type: 'preset.select';
|
|
210
|
+
slot: number;
|
|
211
|
+
} | {
|
|
212
|
+
type: 'preset.save';
|
|
213
|
+
slot: number;
|
|
214
|
+
} | {
|
|
215
|
+
type: 'layout.setRowHeights';
|
|
216
|
+
heights: Record<string, number>;
|
|
217
|
+
} | {
|
|
218
|
+
type: 'row.add';
|
|
219
|
+
} | {
|
|
220
|
+
type: 'row.remove';
|
|
221
|
+
id: string;
|
|
222
|
+
}
|
|
223
|
+
/** Toggle a series' axis membership (the panel's chain icon): unlink to its
|
|
224
|
+
* own axis, or re-link into its side's shared axis (unit-gated). See
|
|
225
|
+
* {@link linkToggleAllowed} for the exact semantics, merge rule included. */
|
|
226
|
+
| {
|
|
227
|
+
type: 'axis.toggleLink';
|
|
228
|
+
id: string;
|
|
229
|
+
}
|
|
230
|
+
/** Pin an axis to `[min, max]` (implies MANUAL). The host seeds the values —
|
|
231
|
+
* from the preserved memory when it exists, else the current auto fit —
|
|
232
|
+
* and names the `unit` the axis reads in, so the pin suspends if the axis
|
|
233
|
+
* is later re-bound to a different unit (see `AxisRange.unit`). */
|
|
234
|
+
| {
|
|
235
|
+
type: 'axis.setRange';
|
|
236
|
+
axisId: string;
|
|
237
|
+
min: number;
|
|
238
|
+
max: number;
|
|
239
|
+
unit: string;
|
|
240
|
+
}
|
|
241
|
+
/** Back to AUTO, keeping the manual values as memory (the preserved triple). */
|
|
242
|
+
| {
|
|
243
|
+
type: 'axis.setAuto';
|
|
244
|
+
axisId: string;
|
|
245
|
+
}
|
|
246
|
+
/** REPLACE this axis's hard bound locks. Both fields are the new truth, so an
|
|
247
|
+
* omitted one CLEARS that lock — which is what lets the derived bar default
|
|
248
|
+
* (`barZeroLock`) be re-seeded wholesale when an axis's membership changes.
|
|
249
|
+
* `unit` stamps a freshly created entry, exactly as `axis.setRange` does. */
|
|
250
|
+
| {
|
|
251
|
+
type: 'axis.setLocks';
|
|
252
|
+
axisId: string;
|
|
253
|
+
lockMin?: number;
|
|
254
|
+
lockMax?: number;
|
|
255
|
+
unit: string;
|
|
256
|
+
}
|
|
257
|
+
/** The AUTO-mode options: what the fit is taken over, and whether it is
|
|
258
|
+
* mirrored about zero. Both are sent every time (the panel knows the current
|
|
259
|
+
* pair), so there is no clearing ambiguity. */
|
|
260
|
+
| {
|
|
261
|
+
type: 'axis.setAutoOpts';
|
|
262
|
+
axisId: string;
|
|
263
|
+
autoBasis: 'metric' | 'viewport';
|
|
264
|
+
centerZero: boolean;
|
|
265
|
+
unit: string;
|
|
266
|
+
}
|
|
267
|
+
/** The axis's FORMAT and SCALE. Both sent every time, as for setAutoOpts.
|
|
268
|
+
* `scaleType: 'log'` is refused while a bound is locked at 0 — the guard is
|
|
269
|
+
* `logAllowed`, and the panel disables the choice rather than relying on it. */
|
|
270
|
+
| {
|
|
271
|
+
type: 'axis.setFormat';
|
|
272
|
+
axisId: string;
|
|
273
|
+
precision?: number;
|
|
274
|
+
scaleType: 'linear' | 'log';
|
|
275
|
+
unit: string;
|
|
276
|
+
}
|
|
277
|
+
/** Move a whole AXIS to the other side of its row (the panel's ⇄): every
|
|
278
|
+
* member travels together, so the axis keeps its identity as a scale and
|
|
279
|
+
* only its gutter moves. `memberId` names any member — the axis is "the
|
|
280
|
+
* one that config sits on" (own axis, or the side's shared axis). */
|
|
281
|
+
| {
|
|
282
|
+
type: 'axis.swapSide';
|
|
283
|
+
memberId: string;
|
|
284
|
+
}
|
|
285
|
+
/** Move one member onto another axis on its side — the panel's DRAG.
|
|
286
|
+
* `axisGroup` names the destination: a group key, or undefined for the
|
|
287
|
+
* side's shared axis (which is the same thing the chain does). */
|
|
288
|
+
| {
|
|
289
|
+
type: 'axis.moveTo';
|
|
290
|
+
id: string;
|
|
291
|
+
axisGroup?: string;
|
|
292
|
+
};
|
|
293
|
+
export interface TerminalInput {
|
|
294
|
+
initialRows: RowState[];
|
|
295
|
+
catalog: readonly MetricEntry[];
|
|
296
|
+
storage: PresetStorage;
|
|
297
|
+
/** The colour keys the host hands a new series, in order — see
|
|
298
|
+
* `TerminalProviderProps.palette`. Default: none (a leg keeps its pair's). */
|
|
299
|
+
palette?: readonly string[];
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* The row's configs as **blocks** — each root with the studies layered on it,
|
|
303
|
+
* studies FIRST (a study paints over its source, and index 0 is the top).
|
|
304
|
+
*
|
|
305
|
+
* Draw order is a sequence of blocks, not of loose configs, because that is
|
|
306
|
+
* what the control tree shows: a study is a child of the metric it derives
|
|
307
|
+
* from, so moving the metric must carry its studies. Before this, ordering
|
|
308
|
+
* stepped the flat list — and since a study sits directly in front of its
|
|
309
|
+
* target, "move higher" on a metric that owned one swapped it with its own
|
|
310
|
+
* hidden study: nothing moved on screen, and the study silently fell behind
|
|
311
|
+
* its source on the canvas (PR #137 review, HIGH).
|
|
312
|
+
*
|
|
313
|
+
* A study whose target is elsewhere (another row, or removed) heads its own
|
|
314
|
+
* block, so every config appears exactly once.
|
|
315
|
+
*/
|
|
316
|
+
export declare function rowBlocks(configs: readonly SeriesConfig[]): SeriesConfig[][];
|
|
317
|
+
/**
|
|
318
|
+
* The END of `rootId`'s study chain — what `+ Study` extends.
|
|
319
|
+
*
|
|
320
|
+
* Studies are a pipeline the panel renders as a flat list, so adding one must
|
|
321
|
+
* APPEND (read the current output) rather than branch off the root. The host
|
|
322
|
+
* resolves the tail at PICK time rather than at open time: the study picker
|
|
323
|
+
* stays open across picks, and a target captured when it opened is stale the
|
|
324
|
+
* moment the first study lands — which silently built a branch the panel then
|
|
325
|
+
* printed as a pipeline (PR #143 review, HIGH).
|
|
326
|
+
*
|
|
327
|
+
* Follows the same edge the panel groups by: a study's spec input names its
|
|
328
|
+
* target's column. Returns `rootId` itself when nothing is layered on it.
|
|
329
|
+
*/
|
|
330
|
+
export declare function studyChainTail(configs: readonly SeriesConfig[], rootId: string): string;
|
|
331
|
+
/** The data column a catalog entry reads. Unlike a seated config, a catalog
|
|
332
|
+
* entry IS its computation — so its id doubles as its column name when it
|
|
333
|
+
* doesn't name one (`iv21`), and a derived entry names its folded output. */
|
|
334
|
+
export declare const entryColumn: (e: Pick<MetricEntry, "id" | "column">) => string;
|
|
335
|
+
/** One side of a pair as the PICKER states it (the two-sided grammar, TDL-PAIR
|
|
336
|
+
* stage 2): a metric, the workspace ROLE the leg reads — `'primary'` (default)
|
|
337
|
+
* or `'compare'`, re-resolving when the ticker bar changes, which is what
|
|
338
|
+
* makes a preset safe — and an optional per-leg study that smooths the leg
|
|
339
|
+
* WITHOUT seating it (a nested graph input; the engine dedupes it against a
|
|
340
|
+
* seated copy by content-addressing). A PINNED symbol (a fixed ticker) is the
|
|
341
|
+
* deferred third binding — it needs per-leg fetches (stage 2 of the picker).
|
|
342
|
+
*/
|
|
343
|
+
export interface PairLegInput {
|
|
344
|
+
metricId: string;
|
|
345
|
+
entity?: 'primary' | 'compare';
|
|
346
|
+
study?: {
|
|
347
|
+
op: 'sma' | 'ema';
|
|
348
|
+
period: number;
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* What the pure edit-permission helpers need to answer a question: the seated
|
|
353
|
+
* rows and the catalog (which declares each metric's unit). `TerminalContext`
|
|
354
|
+
* satisfies it structurally, so a **guard passes `context` itself** and the
|
|
355
|
+
* host passes its own two — one shape, no chance of the panel's disabled state
|
|
356
|
+
* and the guard disagreeing because they were handed different inputs.
|
|
357
|
+
*/
|
|
358
|
+
export interface EditScope {
|
|
359
|
+
rows: readonly RowState[];
|
|
360
|
+
/** Only what naming + units need, so the HOST's own catalog type satisfies it
|
|
361
|
+
* too — these helpers are called from the panel as well as the guards. */
|
|
362
|
+
catalog: readonly Pick<MetricEntry, 'id' | 'label' | 'unit' | 'column'>[];
|
|
363
|
+
/** The host's colour keys for a new series, in hand-out order (a split leg
|
|
364
|
+
* takes the first its row is not using). Optional: a host that edits without
|
|
365
|
+
* a palette lets a new leg keep its pair's colour. */
|
|
366
|
+
palette?: readonly string[];
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* What unit a RAW column reads in — {@link specUnit}'s leaf resolver, so a
|
|
370
|
+
* spec's unit can be recomputed from its structure alone.
|
|
371
|
+
*
|
|
372
|
+
* The catalog is the authority (it declares each metric's unit); seated configs
|
|
373
|
+
* fill in anything folded rather than fed. A `cmp_`-prefixed leaf is the same
|
|
374
|
+
* metric read for the comparison symbol, so it falls back to the bare column
|
|
375
|
+
* rather than reading unitless.
|
|
376
|
+
*/
|
|
377
|
+
export declare const columnUnits: (catalog: EditScope["catalog"], configs?: readonly SeriesConfig[]) => (column: string) => string;
|
|
378
|
+
/** A pair `SeriesConfig` — the A-vs-B spread (TDL-PAIR). The derived line is
|
|
379
|
+
* the signal (George's gauge feedback: the diff/ratio is more stable than
|
|
380
|
+
* either leg), so it inserts IN FRONT of leg A on A's row. **A spread arrives
|
|
381
|
+
* UNLINKED** (its own `axisGroup`, on the right side): its regime differs by
|
|
382
|
+
* construction (oscillates about 0 or 1), so it starts on its own scale and
|
|
383
|
+
* binds no side's unit — one re-link click away from sharing if wanted (the
|
|
384
|
+
* axis panel). Unit rules still matter for that re-link: a diff of like units
|
|
385
|
+
* reads in that unit; a ratio/log-ratio is unitless. Purple default so a
|
|
386
|
+
* spread reads distinctly from studies (amber); the user recolours. */
|
|
387
|
+
/** The spread's colour when the host supplies no palette — a plain CSS colour
|
|
388
|
+
* (a soft violet) any `resolveColor` passes through unchanged. */
|
|
389
|
+
export declare const DEFAULT_SPREAD_COLOR = "#8b7cf6";
|
|
390
|
+
/** The display name of a column — its catalog entry's, else a seated config's,
|
|
391
|
+
* else the raw column. Exported because the PANEL names pair parts too (it
|
|
392
|
+
* renders each leg as its own row), and two spellings of "what is this column
|
|
393
|
+
* called" would drift. */
|
|
394
|
+
export declare function columnLabel(scope: EditScope, column: string): string;
|
|
395
|
+
/**
|
|
396
|
+
* Whether a study's param `name` can move to `value` — shared by the guard and
|
|
397
|
+
* the host, so a refused edit renders **disabled** instead of dead-clicking (the
|
|
398
|
+
* same contract as `linkToggleAllowed` / `swapAllowed`).
|
|
399
|
+
*
|
|
400
|
+
* It has to run the whole propagation, because an edit is refusable for a
|
|
401
|
+
* reason that isn't visible on the study itself: re-speccing it rewrites
|
|
402
|
+
* everything built on it, and one of THOSE can land on a column another config
|
|
403
|
+
* already holds — two lines computing the same thing. Before this was exported,
|
|
404
|
+
* such an edit simply did nothing when clicked, with no way to find out why
|
|
405
|
+
* (PR #140 review, MEDIUM).
|
|
406
|
+
*/
|
|
407
|
+
export declare function respecAllowed(scope: EditScope, id: string, name: string, value: number): boolean;
|
|
408
|
+
export declare const groupMembers: (configs: readonly SeriesConfig[], groupId: string) => SeriesConfig[];
|
|
409
|
+
/**
|
|
410
|
+
* Whether `id` can move onto the axis keyed by `axisGroup` (undefined = the
|
|
411
|
+
* side's shared axis) — the panel's drag, gated exactly like every other
|
|
412
|
+
* membership change.
|
|
413
|
+
*
|
|
414
|
+
* A destination that already carries series must read in the SAME unit: an
|
|
415
|
+
* axis is one scale, and two units on one scale is the thing the whole axis
|
|
416
|
+
* policy exists to prevent. An EMPTY destination (or one holding only the
|
|
417
|
+
* mover) is always fine — that is just the mover keeping its own scale.
|
|
418
|
+
*/
|
|
419
|
+
export declare function axisMoveAllowed(configs: readonly SeriesConfig[], id: string, axisGroup?: string): boolean;
|
|
420
|
+
/**
|
|
421
|
+
* Whether the panel's chain toggle can act on `id` — shared by the guard and the
|
|
422
|
+
* host (the panel renders a refused toggle disabled). The semantics follow the
|
|
423
|
+
* icon exactly:
|
|
424
|
+
*
|
|
425
|
+
* - **On the side's shared axis** (LINKED, with or without company): unlink to
|
|
426
|
+
* an own axis — **always allowed**. Alone on the shared axis this is a
|
|
427
|
+
* visual no-op, but it is not a semantic one: an own axis binds no unit, so
|
|
428
|
+
* it can always ⇄ to the other side, and a later same-unit arrival joins the
|
|
429
|
+
* *shared* axis rather than silently merging with it. Refusing it here
|
|
430
|
+
* stranded a lone member whose far side was occupied — both controls
|
|
431
|
+
* disabled, no way out but delete-and-re-add (PR #136 review, HIGH).
|
|
432
|
+
* - **On an own axis** (BLINK): JOIN — allowed only when a same-unit companion
|
|
433
|
+
* exists on the side, and no different-unit series holds the side's shared
|
|
434
|
+
* axis (the axis policy, applied at link time). Joining needs something to
|
|
435
|
+
* join, so a lone series can never bind a FREE side by toggling and a spread
|
|
436
|
+
* can't accidentally claim a side's unit.
|
|
437
|
+
*/
|
|
438
|
+
export declare function linkToggleAllowed(configs: readonly SeriesConfig[], id: string): boolean;
|
|
439
|
+
/**
|
|
440
|
+
* Whether the panel's ⇄ can move `id`'s axis to the other side — shared by the
|
|
441
|
+
* guard and the host (a refused swap renders disabled).
|
|
442
|
+
*
|
|
443
|
+
* An UNLINKED axis may always swap: it binds no unit, so it just changes which
|
|
444
|
+
* gutter it occupies. A SHARED axis may swap only when the other side has **no
|
|
445
|
+
* shared axis** — otherwise the move would silently merge two scales (possibly
|
|
446
|
+
* of different units) into one, which is a link operation, and linking has its
|
|
447
|
+
* own control. Own axes already on the far side never block: they are separate
|
|
448
|
+
* gutters.
|
|
449
|
+
*/
|
|
450
|
+
export declare function swapAllowed(configs: readonly SeriesConfig[], id: string): boolean;
|
|
451
|
+
export declare function canonRows(rows: readonly RowState[]): string;
|
|
452
|
+
/** The active slot: first saved preset whose rows deep-equal the live rows, else
|
|
453
|
+
* null (custom). The single derivation behind the filled circle + the seed. */
|
|
454
|
+
export declare function activeSlot(presets: readonly (TerminalPreset | null)[], rows: readonly RowState[]): number | null;
|
|
455
|
+
export declare const terminalMachine: import("xstate").StateMachine<TerminalContext, {
|
|
456
|
+
type: "series.add";
|
|
457
|
+
catalogId: string;
|
|
458
|
+
rowId?: string;
|
|
459
|
+
} | {
|
|
460
|
+
type: "series.addStudy";
|
|
461
|
+
targetId: string;
|
|
462
|
+
op: DeriveOp;
|
|
463
|
+
period: number;
|
|
464
|
+
} | {
|
|
465
|
+
type: "series.addPair";
|
|
466
|
+
a: PairLegInput;
|
|
467
|
+
b: PairLegInput;
|
|
468
|
+
op: PairLensOp;
|
|
469
|
+
rowId?: string;
|
|
470
|
+
} | {
|
|
471
|
+
type: "series.compareAll";
|
|
472
|
+
} | {
|
|
473
|
+
type: "series.setStudyParam";
|
|
474
|
+
id: string;
|
|
475
|
+
name: string;
|
|
476
|
+
value: number;
|
|
477
|
+
} | {
|
|
478
|
+
type: "series.order";
|
|
479
|
+
id: string;
|
|
480
|
+
to: "front" | "up" | "down" | "back";
|
|
481
|
+
} | {
|
|
482
|
+
type: "series.reindex";
|
|
483
|
+
id: string;
|
|
484
|
+
index: number;
|
|
485
|
+
} | {
|
|
486
|
+
type: "series.moveToRow";
|
|
487
|
+
id: string;
|
|
488
|
+
rowId: string;
|
|
489
|
+
} | {
|
|
490
|
+
type: "series.remove";
|
|
491
|
+
id: string;
|
|
492
|
+
} | {
|
|
493
|
+
type: "series.patch";
|
|
494
|
+
id: string;
|
|
495
|
+
patch: Partial<Omit<SeriesConfig, "axis" | "axisGroup">>;
|
|
496
|
+
} | {
|
|
497
|
+
type: "series.toggleVisible";
|
|
498
|
+
id: string;
|
|
499
|
+
} | {
|
|
500
|
+
type: "group.toggleVisible";
|
|
501
|
+
groupId: string;
|
|
502
|
+
} | {
|
|
503
|
+
type: "group.remove";
|
|
504
|
+
groupId: string;
|
|
505
|
+
} | {
|
|
506
|
+
type: "select";
|
|
507
|
+
id: string | null;
|
|
508
|
+
} | {
|
|
509
|
+
type: "expand";
|
|
510
|
+
id: string | null;
|
|
511
|
+
} | {
|
|
512
|
+
type: "controls.open";
|
|
513
|
+
} | {
|
|
514
|
+
type: "controls.close";
|
|
515
|
+
} | {
|
|
516
|
+
type: "preset.select";
|
|
517
|
+
slot: number;
|
|
518
|
+
} | {
|
|
519
|
+
type: "preset.save";
|
|
520
|
+
slot: number;
|
|
521
|
+
} | {
|
|
522
|
+
type: "layout.setRowHeights";
|
|
523
|
+
heights: Record<string, number>;
|
|
524
|
+
} | {
|
|
525
|
+
type: "row.add";
|
|
526
|
+
} | {
|
|
527
|
+
type: "row.remove";
|
|
528
|
+
id: string;
|
|
529
|
+
} | {
|
|
530
|
+
type: "axis.toggleLink";
|
|
531
|
+
id: string;
|
|
532
|
+
} | {
|
|
533
|
+
type: "axis.setRange";
|
|
534
|
+
axisId: string;
|
|
535
|
+
min: number;
|
|
536
|
+
max: number;
|
|
537
|
+
unit: string;
|
|
538
|
+
} | {
|
|
539
|
+
type: "axis.setAuto";
|
|
540
|
+
axisId: string;
|
|
541
|
+
} | {
|
|
542
|
+
type: "axis.setLocks";
|
|
543
|
+
axisId: string;
|
|
544
|
+
lockMin?: number;
|
|
545
|
+
lockMax?: number;
|
|
546
|
+
unit: string;
|
|
547
|
+
} | {
|
|
548
|
+
type: "axis.setAutoOpts";
|
|
549
|
+
axisId: string;
|
|
550
|
+
autoBasis: "metric" | "viewport";
|
|
551
|
+
centerZero: boolean;
|
|
552
|
+
unit: string;
|
|
553
|
+
} | {
|
|
554
|
+
type: "axis.setFormat";
|
|
555
|
+
axisId: string;
|
|
556
|
+
precision?: number;
|
|
557
|
+
scaleType: "linear" | "log";
|
|
558
|
+
unit: string;
|
|
559
|
+
} | {
|
|
560
|
+
type: "axis.swapSide";
|
|
561
|
+
memberId: string;
|
|
562
|
+
} | {
|
|
563
|
+
type: "axis.moveTo";
|
|
564
|
+
id: string;
|
|
565
|
+
axisGroup?: string;
|
|
566
|
+
}, {}, never, {
|
|
567
|
+
type: "addStudy";
|
|
568
|
+
params: import("xstate").NonReducibleUnknown;
|
|
569
|
+
} | {
|
|
570
|
+
type: "addPair";
|
|
571
|
+
params: import("xstate").NonReducibleUnknown;
|
|
572
|
+
} | {
|
|
573
|
+
type: "setStudyParam";
|
|
574
|
+
params: import("xstate").NonReducibleUnknown;
|
|
575
|
+
} | {
|
|
576
|
+
type: "addSeries";
|
|
577
|
+
params: import("xstate").NonReducibleUnknown;
|
|
578
|
+
} | {
|
|
579
|
+
type: "toggleGroupVisible";
|
|
580
|
+
params: import("xstate").NonReducibleUnknown;
|
|
581
|
+
} | {
|
|
582
|
+
type: "removeGroup";
|
|
583
|
+
params: import("xstate").NonReducibleUnknown;
|
|
584
|
+
} | {
|
|
585
|
+
type: "moveAxis";
|
|
586
|
+
params: import("xstate").NonReducibleUnknown;
|
|
587
|
+
} | {
|
|
588
|
+
type: "removeSeries";
|
|
589
|
+
params: import("xstate").NonReducibleUnknown;
|
|
590
|
+
} | {
|
|
591
|
+
type: "orderSeries";
|
|
592
|
+
params: import("xstate").NonReducibleUnknown;
|
|
593
|
+
} | {
|
|
594
|
+
type: "moveSeriesToRow";
|
|
595
|
+
params: import("xstate").NonReducibleUnknown;
|
|
596
|
+
} | {
|
|
597
|
+
type: "patchSeries";
|
|
598
|
+
params: import("xstate").NonReducibleUnknown;
|
|
599
|
+
} | {
|
|
600
|
+
type: "toggleVisible";
|
|
601
|
+
params: import("xstate").NonReducibleUnknown;
|
|
602
|
+
} | {
|
|
603
|
+
type: "setSelected";
|
|
604
|
+
params: import("xstate").NonReducibleUnknown;
|
|
605
|
+
} | {
|
|
606
|
+
type: "setExpanded";
|
|
607
|
+
params: import("xstate").NonReducibleUnknown;
|
|
608
|
+
} | {
|
|
609
|
+
type: "openControls";
|
|
610
|
+
params: import("xstate").NonReducibleUnknown;
|
|
611
|
+
} | {
|
|
612
|
+
type: "closeControls";
|
|
613
|
+
params: import("xstate").NonReducibleUnknown;
|
|
614
|
+
} | {
|
|
615
|
+
type: "applyPreset";
|
|
616
|
+
params: import("xstate").NonReducibleUnknown;
|
|
617
|
+
} | {
|
|
618
|
+
type: "savePreset";
|
|
619
|
+
params: import("xstate").NonReducibleUnknown;
|
|
620
|
+
} | {
|
|
621
|
+
type: "setRowHeights";
|
|
622
|
+
params: import("xstate").NonReducibleUnknown;
|
|
623
|
+
} | {
|
|
624
|
+
type: "addRow";
|
|
625
|
+
params: import("xstate").NonReducibleUnknown;
|
|
626
|
+
} | {
|
|
627
|
+
type: "toggleAxisLink";
|
|
628
|
+
params: import("xstate").NonReducibleUnknown;
|
|
629
|
+
} | {
|
|
630
|
+
type: "swapAxisSide";
|
|
631
|
+
params: import("xstate").NonReducibleUnknown;
|
|
632
|
+
} | {
|
|
633
|
+
type: "setAxisRange";
|
|
634
|
+
params: import("xstate").NonReducibleUnknown;
|
|
635
|
+
} | {
|
|
636
|
+
type: "setAxisLocks";
|
|
637
|
+
params: import("xstate").NonReducibleUnknown;
|
|
638
|
+
} | {
|
|
639
|
+
type: "setAxisAutoOpts";
|
|
640
|
+
params: import("xstate").NonReducibleUnknown;
|
|
641
|
+
} | {
|
|
642
|
+
type: "setAxisFormat";
|
|
643
|
+
params: import("xstate").NonReducibleUnknown;
|
|
644
|
+
} | {
|
|
645
|
+
type: "setAxisAuto";
|
|
646
|
+
params: import("xstate").NonReducibleUnknown;
|
|
647
|
+
} | {
|
|
648
|
+
type: "removeRow";
|
|
649
|
+
params: import("xstate").NonReducibleUnknown;
|
|
650
|
+
}, {
|
|
651
|
+
type: "canAdd";
|
|
652
|
+
params: unknown;
|
|
653
|
+
} | {
|
|
654
|
+
type: "canAddRow";
|
|
655
|
+
params: unknown;
|
|
656
|
+
} | {
|
|
657
|
+
type: "canAddStudy";
|
|
658
|
+
params: unknown;
|
|
659
|
+
} | {
|
|
660
|
+
type: "canAddPair";
|
|
661
|
+
params: unknown;
|
|
662
|
+
} | {
|
|
663
|
+
type: "canSetStudyParam";
|
|
664
|
+
params: unknown;
|
|
665
|
+
} | {
|
|
666
|
+
type: "canToggleLink";
|
|
667
|
+
params: unknown;
|
|
668
|
+
} | {
|
|
669
|
+
type: "canMoveAxis";
|
|
670
|
+
params: unknown;
|
|
671
|
+
} | {
|
|
672
|
+
type: "canSwapSide";
|
|
673
|
+
params: unknown;
|
|
674
|
+
} | {
|
|
675
|
+
type: "canSetAxisRange";
|
|
676
|
+
params: unknown;
|
|
677
|
+
} | {
|
|
678
|
+
type: "canMoveToRow";
|
|
679
|
+
params: unknown;
|
|
680
|
+
}, never, {}, string, TerminalInput, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, {
|
|
681
|
+
id: "terminal";
|
|
682
|
+
}, import("xstate").MetaObject>;
|
|
683
|
+
export {};
|