@tidal-ts/terminal 0.6.0 → 0.8.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 +40 -0
- package/dist/terminalMachine.js +11 -3
- package/package.json +9 -9
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @tidal-ts/terminal
|
|
2
|
+
|
|
3
|
+
A state machine (XState v5) for apps where users build their own charts. It
|
|
4
|
+
holds a chart's setup (rows, series, studies, axes and up to five saved
|
|
5
|
+
presets) and never its data: no fetching, no storage of its own, no drawing.
|
|
6
|
+
Its rows are what [`@tidal-ts/chart`](https://www.npmjs.com/package/@tidal-ts/chart)'s
|
|
7
|
+
`prepareChart` takes. Part of [tidal-ts](https://github.com/tidal-app/tidal-ts).
|
|
8
|
+
|
|
9
|
+
**Pre-1.0: pin an exact version.** Every `@tidal-ts/*` package ships on one
|
|
10
|
+
version number.
|
|
11
|
+
|
|
12
|
+
- [Docs](https://tidal-app.github.io/tidal-ts/docs/packages/terminal/)
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install --save-exact @tidal-ts/terminal @tidal-ts/chart @tidal-ts/core
|
|
18
|
+
npm install xstate @xstate/react
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Plus the pond peers `@tidal-ts/chart` needs (see its README).
|
|
22
|
+
|
|
23
|
+
## The shape
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { TerminalProvider, useRows, useAddStudy } from '@tidal-ts/terminal';
|
|
27
|
+
|
|
28
|
+
<TerminalProvider initialRows={rows} catalog={metrics} storage={presetStorage} palette={colours}>
|
|
29
|
+
<YourChartAndControls />
|
|
30
|
+
</TerminalProvider>;
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The host supplies the starting rows, the metrics a user may add, where presets
|
|
34
|
+
are saved, and the colours new series take. Hooks read state (`useRows`,
|
|
35
|
+
`useAxisRanges`, …) and send one kind of change each (`useAddStudy`,
|
|
36
|
+
`useMoveToAxis`, `useSavePreset`, …). The machine's rules are exported as
|
|
37
|
+
plain functions (`allowedAxes`, `studyOfferable`, …) so your menus can grey
|
|
38
|
+
out what it would refuse.
|
|
39
|
+
|
|
40
|
+
MIT.
|
package/dist/terminalMachine.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assign, enqueueActions, setup } from 'xstate';
|
|
2
|
-
import { COMPARE_PREFIX, hasPairOp, usesCompare, deriveId, opParams, opInputs, opNeedsColumns, opIsBand, opIsMulti, opOutputs, TARGET_ROLES, opSharesSourceAxis, studyTag, inputNames, isPickedInput, isPairOp, isValidSpec, partStudyLabel, readPairParts, specUnit, studyInputOf, studyPick, substituteInput, withStudyOutput, } from '@tidal-ts/core';
|
|
2
|
+
import { COMPARE_PREFIX, hasPairOp, usesCompare, deriveId, opParams, opInputs, opNeedsColumns, opIsBand, opIsMulti, outputMark, opOutputs, TARGET_ROLES, opSharesSourceAxis, studyTag, inputNames, isPickedInput, isPairOp, isValidSpec, partStudyLabel, readPairParts, specUnit, studyInputOf, studyPick, substituteInput, withStudyOutput, } from '@tidal-ts/core';
|
|
3
3
|
/**
|
|
4
4
|
* The bar columns each data SOURCE carries — the one fact that decides whether a
|
|
5
5
|
* multi-column study is offerable on a series. Only the price series has bars;
|
|
@@ -511,8 +511,16 @@ function studyConfig(target, op, period, id, unitOf) {
|
|
|
511
511
|
// A multi-output op can only draw as a multi-output style: its `column` is
|
|
512
512
|
// a spec id naming SEVERAL columns, so every single-column style would read
|
|
513
513
|
// nothing and draw an empty layer. A band is the Middle/Upper/Lower wash;
|
|
514
|
-
// anything else is N lines off one spec, one per declared output.
|
|
515
|
-
|
|
514
|
+
// anything else is N lines off one spec, one per declared output. A
|
|
515
|
+
// single-output study whose one output is a histogram (an Awesome
|
|
516
|
+
// Oscillator) opens as bars; the user can still restyle it.
|
|
517
|
+
style: opIsBand(op)
|
|
518
|
+
? 'band'
|
|
519
|
+
: opIsMulti(op)
|
|
520
|
+
? 'lines'
|
|
521
|
+
: outputMark(op, '') === 'bar'
|
|
522
|
+
? 'bar'
|
|
523
|
+
: 'line',
|
|
516
524
|
visible: true,
|
|
517
525
|
source: target.source,
|
|
518
526
|
column: deriveId(derive),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tidal-ts/terminal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/tidal-app/tidal-ts.git",
|
|
10
10
|
"directory": "packages/terminal"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://
|
|
12
|
+
"homepage": "https://tidal-app.github.io/tidal-ts/docs/packages/terminal/",
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"xstate": "^5.28.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@tidal-ts/
|
|
40
|
-
"@tidal-ts/
|
|
39
|
+
"@tidal-ts/chart": "0.8.0",
|
|
40
|
+
"@tidal-ts/core": "0.8.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@pond-ts/charts": "^0.
|
|
44
|
-
"@pond-ts/financial": "^0.
|
|
45
|
-
"@pond-ts/process": "0.
|
|
46
|
-
"@pond-ts/react": "^0.
|
|
43
|
+
"@pond-ts/charts": "^0.72.0",
|
|
44
|
+
"@pond-ts/financial": "^0.72.0",
|
|
45
|
+
"@pond-ts/process": "0.72.0",
|
|
46
|
+
"@pond-ts/react": "^0.72.0",
|
|
47
47
|
"@types/react": "^18.3.18",
|
|
48
48
|
"@xstate/react": "^6.1.0",
|
|
49
|
-
"pond-ts": "^0.
|
|
49
|
+
"pond-ts": "^0.72.0",
|
|
50
50
|
"react": "^18.3.1",
|
|
51
51
|
"typescript": "^5.7.2",
|
|
52
52
|
"vitest": "^2.1.8",
|