@tidal-ts/terminal 0.24.0 → 0.25.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/dist/terminalMachine.d.ts +3 -2
- package/dist/terminalMachine.js +23 -22
- package/package.json +3 -3
|
@@ -620,9 +620,10 @@ export declare function swapAllowed(configs: readonly SeriesConfig[], id: string
|
|
|
620
620
|
* Whether `other` can be wired by hand as `target`'s compare other side
|
|
621
621
|
* ({@link SeriesConfig.compareWith}): the target must be able to carry a
|
|
622
622
|
* compare at all ({@link compareFnAllowed}), and the other side must be a
|
|
623
|
-
* different config with
|
|
623
|
+
* different config with ONE line to read — its only line, or the one
|
|
624
|
+
* `output` names when it draws several ({@link compareWithInput}).
|
|
624
625
|
*/
|
|
625
|
-
export declare function compareWithAllowed(target: SeriesConfig, other: SeriesConfig): boolean;
|
|
626
|
+
export declare function compareWithAllowed(target: SeriesConfig, other: SeriesConfig, output?: string): boolean;
|
|
626
627
|
/**
|
|
627
628
|
* Whether a seated config can carry a compare function
|
|
628
629
|
* ({@link SeriesConfig.compareFn}) or a hand-wired other side
|
package/dist/terminalMachine.js
CHANGED
|
@@ -32,7 +32,7 @@ function hidesPointer(context, toggledId, pointer) {
|
|
|
32
32
|
return cascade.has(pointer);
|
|
33
33
|
}
|
|
34
34
|
import { axisRangeIsEmpty, logAllowed, isStudySeries, readsFrom, sourcesOf, fanIsBand, offersOutputBars, publishedColumns, } from '@tidal-ts/chart';
|
|
35
|
-
import { configAxisId, seriesAxisId, sharedAxisId, } from '@tidal-ts/chart';
|
|
35
|
+
import { configAxisId, seriesAxisId, sharedAxisId, compareWithInput, } from '@tidal-ts/chart';
|
|
36
36
|
import { axisForAdd, canAddUnit } from './axisPolicy.js';
|
|
37
37
|
export const PRESET_SETS = ['plain', 'compare'];
|
|
38
38
|
/** Slots in each preset set. */
|
|
@@ -1114,7 +1114,7 @@ function keepCompareWithValid(rows) {
|
|
|
1114
1114
|
if (!c.compareWith)
|
|
1115
1115
|
return true;
|
|
1116
1116
|
const other = byId.get(c.compareWith.id);
|
|
1117
|
-
return !!other && compareWithAllowed(c, other);
|
|
1117
|
+
return !!other && compareWithAllowed(c, other, c.compareWith.output);
|
|
1118
1118
|
};
|
|
1119
1119
|
if (flatConfigs(rows).every(holds))
|
|
1120
1120
|
return rows;
|
|
@@ -1835,27 +1835,19 @@ function comparableMetric(c) {
|
|
|
1835
1835
|
* Whether `other` can be wired by hand as `target`'s compare other side
|
|
1836
1836
|
* ({@link SeriesConfig.compareWith}): the target must be able to carry a
|
|
1837
1837
|
* compare at all ({@link compareFnAllowed}), and the other side must be a
|
|
1838
|
-
* different config with
|
|
1838
|
+
* different config with ONE line to read — its only line, or the one
|
|
1839
|
+
* `output` names when it draws several ({@link compareWithInput}).
|
|
1839
1840
|
*/
|
|
1840
|
-
export function compareWithAllowed(target, other) {
|
|
1841
|
+
export function compareWithAllowed(target, other, output) {
|
|
1841
1842
|
if (!compareFnAllowed(target) || other.id === target.id)
|
|
1842
1843
|
return false;
|
|
1843
|
-
//
|
|
1844
|
-
//
|
|
1845
|
-
// against its own SMA).
|
|
1844
|
+
// Read from its own spec: the same refusals as a function's metric, except
|
|
1845
|
+
// that a study is a fine other side (price against its own SMA).
|
|
1846
1846
|
if (other.group || other.column.startsWith(COMPARE_PREFIX))
|
|
1847
1847
|
return false;
|
|
1848
|
-
if (other.
|
|
1848
|
+
if (other.derive && (hasPairOp(other.derive) || usesCompare(other.derive)))
|
|
1849
1849
|
return false;
|
|
1850
|
-
|
|
1851
|
-
return false;
|
|
1852
|
-
if (other.derive) {
|
|
1853
|
-
if (hasPairOp(other.derive) || usesCompare(other.derive))
|
|
1854
|
-
return false;
|
|
1855
|
-
if (opIsMulti(other.derive.op) || opIsBand(other.derive.op))
|
|
1856
|
-
return false;
|
|
1857
|
-
}
|
|
1858
|
-
return true;
|
|
1850
|
+
return compareWithInput(other, output) !== null;
|
|
1859
1851
|
}
|
|
1860
1852
|
/**
|
|
1861
1853
|
* Whether a seated config can carry a compare function
|
|
@@ -1960,7 +1952,11 @@ export function canonRows(rows) {
|
|
|
1960
1952
|
...(c.compareWith
|
|
1961
1953
|
? [
|
|
1962
1954
|
...(c.compareFn ? [] : [null]),
|
|
1963
|
-
[
|
|
1955
|
+
[
|
|
1956
|
+
columnOf.get(c.compareWith.id) ?? null,
|
|
1957
|
+
c.compareWith.side,
|
|
1958
|
+
...(c.compareWith.output ? [c.compareWith.output] : []),
|
|
1959
|
+
],
|
|
1964
1960
|
]
|
|
1965
1961
|
: []),
|
|
1966
1962
|
]),
|
|
@@ -2161,8 +2157,12 @@ export const terminalMachine = setup({
|
|
|
2161
2157
|
return true;
|
|
2162
2158
|
if (event.with.side !== 'primary' && event.with.side !== 'comparison')
|
|
2163
2159
|
return false;
|
|
2160
|
+
const output = event.with.output;
|
|
2161
|
+
// A name, or none: an empty name would be stored as none.
|
|
2162
|
+
if (output !== undefined && (typeof output !== 'string' || output === ''))
|
|
2163
|
+
return false;
|
|
2164
2164
|
const other = all.find((c) => c.id === event.with.id);
|
|
2165
|
-
return !!other && compareWithAllowed(target, other);
|
|
2165
|
+
return !!other && compareWithAllowed(target, other, output);
|
|
2166
2166
|
},
|
|
2167
2167
|
canSetStudyParam: ({ context, event }) => event.type === 'series.setStudyParam' &&
|
|
2168
2168
|
respecAllowed(context, event.id, event.name, event.value),
|
|
@@ -2712,9 +2712,10 @@ export const terminalMachine = setup({
|
|
|
2712
2712
|
return c;
|
|
2713
2713
|
// Automatic again by REMOVING the key, as for the function.
|
|
2714
2714
|
const { compareWith: _drop, ...rest } = c;
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2715
|
+
if (!event.with)
|
|
2716
|
+
return rest;
|
|
2717
|
+
const { id, side, output } = event.with;
|
|
2718
|
+
return { ...rest, compareWith: { id, side, ...(output ? { output } : {}) } };
|
|
2718
2719
|
}),
|
|
2719
2720
|
}
|
|
2720
2721
|
: r);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tidal-ts/terminal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The terminal machine — an XState v5 statechart that owns a chart's configuration (rows, series, studies, pairs, axes, presets) and never its data.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"xstate": "^5.28.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@tidal-ts/chart": "0.
|
|
40
|
-
"@tidal-ts/core": "0.
|
|
39
|
+
"@tidal-ts/chart": "0.25.0",
|
|
40
|
+
"@tidal-ts/core": "0.25.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@pond-ts/charts": "^0.78.0",
|