@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
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @orangecharts/wrun-chart-host
|
|
2
|
+
|
|
3
|
+
The wrun chart-host layer the kiyotaka web app and the mobile app share: the wrun result reader and painter model.
|
|
4
|
+
The web app is the reference implementation and consumes this package from source; the mobile app installs the
|
|
5
|
+
packed tarball. The guide is `docs/features/kscript/wrun/wrun-chart-host.md` in the web repo.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Peers, pinned exactly (install them beside the package):
|
|
10
|
+
|
|
11
|
+
| Peer | Version | Why |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| `@orangecharts/indicator-kit` | 0.78.1 | the shared host's types (`@orangecharts/indicator-kit/host`); the host module itself comes through the env |
|
|
14
|
+
| `dayjs` | 1.11.23 | sessions and trading days (the `utc`, `timezone` and `isoWeek` plugins) |
|
|
15
|
+
| `lodash-es` | 4.18.1 | the color settings |
|
|
16
|
+
|
|
17
|
+
The dist is ES modules (`"type": "module"`) with declarations. Import the entry or any module by its subpath:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { setWrunChartHostEnv, readWrunHostedWire } from '@orangecharts/wrun-chart-host';
|
|
21
|
+
import { WRUN_FRAME_MAX_SLOTS } from '@orangecharts/wrun-chart-host/utility/wrun/wrun-frames';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Four modules are reachable by subpath only (an export name of theirs resolves to another declaration in the entry):
|
|
25
|
+
`utility/chart/om-widget.util`, `utility/wrun/wrun-frames`, `utility/wrun/wrun-pane-format.util`,
|
|
26
|
+
`utility/wrun/wrun-style-words.util`.
|
|
27
|
+
|
|
28
|
+
## The host env (ports)
|
|
29
|
+
|
|
30
|
+
Set it once per realm (the page and each wrun worker), at the realm's entry and before any package code runs:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import * as KitHost from '@orangecharts/indicator-kit/host';
|
|
34
|
+
import { setWrunChartHostEnv } from '@orangecharts/wrun-chart-host';
|
|
35
|
+
|
|
36
|
+
setWrunChartHostEnv({
|
|
37
|
+
t: (key, params) => translate(key, params),
|
|
38
|
+
te: (key) => hasTranslation(key),
|
|
39
|
+
loadSharedHost: () => Promise.resolve(KitHost),
|
|
40
|
+
sharedHost: () => KitHost,
|
|
41
|
+
poolDexName: (exchange, symbol) => poolDexNameOf(exchange, symbol),
|
|
42
|
+
diagnostics: {
|
|
43
|
+
debug: (event, details) => debugRing(event, details),
|
|
44
|
+
publishCapNotice: (batch) => writeCellsCappedRows(batch),
|
|
45
|
+
publishCanvasCostNotice: (notice) => writeCanvasCostRow(notice),
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
| Port | Read by slab 1 | What the host answers |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `loadSharedHost()` | the hosted wire reader | the kit's host module, loaded once (a failed load is not cached) |
|
|
53
|
+
| `sharedHost()` | the pack, frames, box segments, render select, the run result's strategy bytes | the loaded host module; before the load it throws `wrunChartHostUnloadedError()` (`wrun_chart_host_unloaded`) |
|
|
54
|
+
| `diagnostics.publishCapNotice(batch)` | the cells cap notice | write each `batch.take()` notice as the Indicator's "Cells capped" row when ready, or `batch.drop()` |
|
|
55
|
+
| `t`, `te` | reserved | a user-facing string by its locale key, and whether the key exists |
|
|
56
|
+
| `poolDexName(exchange, symbol)` | reserved | the pool's DEX name, if any |
|
|
57
|
+
| `diagnostics.debug`, `diagnostics.publishCanvasCostNotice` | reserved | the debug ring; the canvas cost row |
|
|
58
|
+
|
|
59
|
+
A read before the set throws `wrun_chart_host_env_unset`. The env lives on the realm's global object under
|
|
60
|
+
`Symbol.for('@orangecharts/wrun-chart-host/env')`, so every copy of the package in a realm reads the same one.
|
|
61
|
+
|
|
62
|
+
## Build and check
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pnpm -F @orangecharts/wrun-chart-host build
|
|
66
|
+
pnpm pack --pack-destination <dir>
|
|
67
|
+
pnpm -F @orangecharts/wrun-chart-host consumer-check <tarball> <empty directory outside any workspace>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`build` compiles with tsc, then `scripts/esm-dist.mjs` gives every specifier the file Node's ESM loader needs.
|
|
71
|
+
`consumer-check` installs the tarball with only the peers, compiles `consumer-check/consumer.ts` (skipLibCheck off,
|
|
72
|
+
Bundler and NodeNext resolution) and runs `consumer-check/run.mjs` under Node.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The governed exchange codes the trading-day and venue checks read, copied byte for byte from the web app's
|
|
3
|
+
* realtime interfaces (src/interfaces/cme-realtime.interface.ts `CME_GOVERNED_EXCHANGES`, derived there from the CME
|
|
4
|
+
* exchange catalog, and src/interfaces/opra-realtime.interface.ts `OPRA_GOVERNED_EXCHANGES`), which this package
|
|
5
|
+
* does not carry (they hold the worker socket-slot and billing types). tests/packages/wrun-chart-host/
|
|
6
|
+
* narrowed-constants.spec.ts pins each copy equal to the web constant.
|
|
7
|
+
*/
|
|
8
|
+
/** Every governed CME-family code (the purchasable DCMs plus the GLOBEX alias), in the catalog's stable order. */
|
|
9
|
+
export declare const CME_GOVERNED_EXCHANGES: readonly string[];
|
|
10
|
+
/** Every OPRA-governed exchange code (one consolidated venue by design). */
|
|
11
|
+
export declare const OPRA_GOVERNED_EXCHANGES: readonly string[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The governed exchange codes the trading-day and venue checks read, copied byte for byte from the web app's
|
|
3
|
+
* realtime interfaces (src/interfaces/cme-realtime.interface.ts `CME_GOVERNED_EXCHANGES`, derived there from the CME
|
|
4
|
+
* exchange catalog, and src/interfaces/opra-realtime.interface.ts `OPRA_GOVERNED_EXCHANGES`), which this package
|
|
5
|
+
* does not carry (they hold the worker socket-slot and billing types). tests/packages/wrun-chart-host/
|
|
6
|
+
* narrowed-constants.spec.ts pins each copy equal to the web constant.
|
|
7
|
+
*/
|
|
8
|
+
/** Every governed CME-family code (the purchasable DCMs plus the GLOBEX alias), in the catalog's stable order. */
|
|
9
|
+
export const CME_GOVERNED_EXCHANGES = ['CME', 'CBOT', 'NYMEX', 'COMEX', 'GLOBEX'];
|
|
10
|
+
/** Every OPRA-governed exchange code (one consolidated venue by design). */
|
|
11
|
+
export const OPRA_GOVERNED_EXCHANGES = ['OPRA'];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in indicator sets the result reader reads, copied byte for byte from the web app's constants
|
|
3
|
+
* (src/constants/indicator.constants.ts), which this package never imports: that file reaches the locale plugin
|
|
4
|
+
* and the app's theme tables. tests/packages/wrun-chart-host/narrowed-constants.spec.ts pins each copy equal to
|
|
5
|
+
* the web constant, so the two cannot drift.
|
|
6
|
+
*/
|
|
7
|
+
/** The built-ins whose values are volume-scaled: their twin's pane formats volumes, not prices. */
|
|
8
|
+
export declare const VOLUME_BASED_INDICATORS: readonly ["OBV", "VOLUME_BAR"];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in indicator sets the result reader reads, copied byte for byte from the web app's constants
|
|
3
|
+
* (src/constants/indicator.constants.ts), which this package never imports: that file reaches the locale plugin
|
|
4
|
+
* and the app's theme tables. tests/packages/wrun-chart-host/narrowed-constants.spec.ts pins each copy equal to
|
|
5
|
+
* the web constant, so the two cannot drift.
|
|
6
|
+
*/
|
|
7
|
+
/** The built-ins whose values are volume-scaled: their twin's pane formats volumes, not prices. */
|
|
8
|
+
export const VOLUME_BASED_INDICATORS = ['OBV', 'VOLUME_BAR'];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const Intervals: {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Tape's key in the interval track. Tape is a RUNG of the interval ladder (the
|
|
6
|
+
* one finer than 1s: 1s draws a bar a second, tape draws every print), but it
|
|
7
|
+
* is not an interval VALUE — the chart still needs a candle interval
|
|
8
|
+
* underneath it, and leaving tape lands back on the one it left. The sliding
|
|
9
|
+
* thumb keys off `data-interval`, so the rung needs a key that can never
|
|
10
|
+
* collide with a real interval.
|
|
11
|
+
*/
|
|
12
|
+
export declare const TAPE_RUNG_KEY = "__tape__";
|
|
13
|
+
/**
|
|
14
|
+
* Fixed interval order for the number-row keyboard shortcuts. Each interval is
|
|
15
|
+
* matched to a top-row number key by position: index 0 → `1`, … index 8 → `9`,
|
|
16
|
+
* index 9 → `0` (the tenth slot). This order is the single source of truth shared
|
|
17
|
+
* by the digit handler (`chart.vue`), the shortcuts dialog, and the settings page,
|
|
18
|
+
* so what's displayed always matches what the keys actually do.
|
|
19
|
+
*/
|
|
20
|
+
export declare const KEYBOARD_SHORTCUT_INTERVAL_ORDER: readonly ["1s", "1m", "5m", "15m", "30m", "1h", "4h", "1d", "1w", "1M"];
|
|
21
|
+
/** Number-row key label for a shortcut index: 0→`'1'`, … 8→`'9'`, 9→`'0'`. */
|
|
22
|
+
export declare const shortcutKeyForIndex: (index: number) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Intervals beyond the number-row set, shown in the shortcuts UI as bindable but
|
|
25
|
+
* UNBOUND by default (the 1–0 keys are taken by KEYBOARD_SHORTCUT_INTERVAL_ORDER).
|
|
26
|
+
* Each gets a keymap command `select<interval>Interval` that users can assign a
|
|
27
|
+
* combo to. Keep in sync with DEFAULT_KEYMAP and the chart.vue action registration.
|
|
28
|
+
*/
|
|
29
|
+
export declare const BINDABLE_INTERVAL_ORDER: readonly ["3M", "1Y"];
|
|
30
|
+
export declare const POLLING_INTERVAL = 25000;
|
|
31
|
+
export declare const HEALTH_POLLING_INTERVAL = 60000;
|
|
32
|
+
export declare const TOKEN_POLLING_INTERVAL = 60000;
|
|
33
|
+
export declare const NOTIFICATION_POLLING_INTERVAL = 60000;
|
|
34
|
+
export declare const WEBSOCKET_PING_INTERVAL_MS = 10000;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export const Intervals = {
|
|
2
|
+
SECOND: 1000,
|
|
3
|
+
SECOND5: 5000,
|
|
4
|
+
SECOND15: 15000,
|
|
5
|
+
MINUTE: 60000,
|
|
6
|
+
MINUTE3: 180000,
|
|
7
|
+
MINUTE5: 300000,
|
|
8
|
+
MINUTE15: 900000,
|
|
9
|
+
MINUTE30: 1800000,
|
|
10
|
+
HOUR: 3600000,
|
|
11
|
+
HOUR4: 14400000,
|
|
12
|
+
HOUR12: 43200000,
|
|
13
|
+
DAY: 86400000,
|
|
14
|
+
DAY3: 259200000,
|
|
15
|
+
DAY6: 518400000,
|
|
16
|
+
DAY12: 1036800000,
|
|
17
|
+
DAY30: 2592000000,
|
|
18
|
+
DAY300: 25920000000,
|
|
19
|
+
DAY950: 82080000000,
|
|
20
|
+
WEEK: 604800000,
|
|
21
|
+
WEEK4: 2419200000,
|
|
22
|
+
WEEK7: 4233600000,
|
|
23
|
+
WEEK12: 7257600000,
|
|
24
|
+
MONTH: 2629800000, // 1 month (avg 30.4375 days)
|
|
25
|
+
MONTH3: 7889400000, // 3 months (avg 91.3125 days)
|
|
26
|
+
YEAR: 31557600000, // 1 year (avg 365.25 days)
|
|
27
|
+
MONTHMAP: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
|
28
|
+
TIMESCALES: [
|
|
29
|
+
315576000000, 157788000000, 94672800000, 63115200000, 31557600000, 15778800000, 10519200000, 7889400000, 5259600000,
|
|
30
|
+
2629800000, 1296000000, 864000000, 604800000, 432000000, 259200000, 172800000, 86400000, 43200000, 21600000,
|
|
31
|
+
10800000, 5400000, 3600000, 1800000, 900000, 600000, 300000, 120000, 60000,
|
|
32
|
+
],
|
|
33
|
+
$SCALES: [0.05, 0.1, 0.2, 0.25, 0.5, 0.8, 1, 2, 5],
|
|
34
|
+
ChartConfig: {
|
|
35
|
+
SBMIN: 60,
|
|
36
|
+
TOOLBAR: 57,
|
|
37
|
+
TB_ICON: 25,
|
|
38
|
+
TB_ITEM_M: 6,
|
|
39
|
+
TB_ICON_BRI: 1.9,
|
|
40
|
+
TB_BORDER: 1,
|
|
41
|
+
TB_B_STYLE: 'dotted',
|
|
42
|
+
TOOL_COLL: 7,
|
|
43
|
+
EXPAND: 0.15,
|
|
44
|
+
CANDLEW: 0.6,
|
|
45
|
+
GRIDX: 100,
|
|
46
|
+
GRIDY: 47,
|
|
47
|
+
BOTBAR: 28,
|
|
48
|
+
PANHEIGHT: 22,
|
|
49
|
+
DEFAULT_LEN: 50,
|
|
50
|
+
MINIMUM_LEN: 5,
|
|
51
|
+
MIN_ZOOM: 25,
|
|
52
|
+
MAX_ZOOM: 1000,
|
|
53
|
+
VOLSCALE: 0.15,
|
|
54
|
+
UX_OPACITY: 0.9,
|
|
55
|
+
FONT: '11px -apple-system,BlinkMacSystemFont,\n Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,\n Fira Sans,Droid Sans,Helvetica Neue,\n sans-serif',
|
|
56
|
+
},
|
|
57
|
+
map_unit: {
|
|
58
|
+
'1s': 1000,
|
|
59
|
+
'5s': 5000,
|
|
60
|
+
'10s': 10000,
|
|
61
|
+
'15s': 15000,
|
|
62
|
+
'20s': 20000,
|
|
63
|
+
'30s': 30000,
|
|
64
|
+
'1m': 60000,
|
|
65
|
+
'2m': 120000,
|
|
66
|
+
'3m': 180000,
|
|
67
|
+
'4m': 240000,
|
|
68
|
+
'5m': 300000,
|
|
69
|
+
'10m': 600000,
|
|
70
|
+
'15m': 900000,
|
|
71
|
+
'30m': 1800000,
|
|
72
|
+
'45m': 2700000,
|
|
73
|
+
'1h': 3600000,
|
|
74
|
+
'2h': 7200000,
|
|
75
|
+
'3h': 10800000,
|
|
76
|
+
'4h': 14400000,
|
|
77
|
+
'6h': 21600000,
|
|
78
|
+
'8h': 28800000,
|
|
79
|
+
'12h': 43200000,
|
|
80
|
+
'1d': 86400000,
|
|
81
|
+
'3d': 259200000,
|
|
82
|
+
'1w': 604800000,
|
|
83
|
+
'1mm': 2419200000,
|
|
84
|
+
'1M': 2629800000, // 1 month (avg 30.4375 days) = (3*365 + 1*366)/4/12 * 86400000
|
|
85
|
+
'3M': 7889400000, // 3 months (avg 91.3125 days) = 3 * 2629800000
|
|
86
|
+
'6M': 15778800000, // 6 months (avg 182.625 days) = 6 * 2629800000
|
|
87
|
+
'1Y': 31557600000, // 1 year (avg 365.25 days) = 12 * 2629800000
|
|
88
|
+
},
|
|
89
|
+
INTERVAL_ORDER: ['1s', '1m', '5m', '15m', '30m', '1h', '4h', '1d', '1w', '1M', '3M', '1Y'],
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Tape's key in the interval track. Tape is a RUNG of the interval ladder (the
|
|
93
|
+
* one finer than 1s: 1s draws a bar a second, tape draws every print), but it
|
|
94
|
+
* is not an interval VALUE — the chart still needs a candle interval
|
|
95
|
+
* underneath it, and leaving tape lands back on the one it left. The sliding
|
|
96
|
+
* thumb keys off `data-interval`, so the rung needs a key that can never
|
|
97
|
+
* collide with a real interval.
|
|
98
|
+
*/
|
|
99
|
+
export const TAPE_RUNG_KEY = '__tape__';
|
|
100
|
+
/**
|
|
101
|
+
* Fixed interval order for the number-row keyboard shortcuts. Each interval is
|
|
102
|
+
* matched to a top-row number key by position: index 0 → `1`, … index 8 → `9`,
|
|
103
|
+
* index 9 → `0` (the tenth slot). This order is the single source of truth shared
|
|
104
|
+
* by the digit handler (`chart.vue`), the shortcuts dialog, and the settings page,
|
|
105
|
+
* so what's displayed always matches what the keys actually do.
|
|
106
|
+
*/
|
|
107
|
+
export const KEYBOARD_SHORTCUT_INTERVAL_ORDER = ['1s', '1m', '5m', '15m', '30m', '1h', '4h', '1d', '1w', '1M'];
|
|
108
|
+
/** Number-row key label for a shortcut index: 0→`'1'`, … 8→`'9'`, 9→`'0'`. */
|
|
109
|
+
export const shortcutKeyForIndex = (index) => String((index + 1) % 10);
|
|
110
|
+
/**
|
|
111
|
+
* Intervals beyond the number-row set, shown in the shortcuts UI as bindable but
|
|
112
|
+
* UNBOUND by default (the 1–0 keys are taken by KEYBOARD_SHORTCUT_INTERVAL_ORDER).
|
|
113
|
+
* Each gets a keymap command `select<interval>Interval` that users can assign a
|
|
114
|
+
* combo to. Keep in sync with DEFAULT_KEYMAP and the chart.vue action registration.
|
|
115
|
+
*/
|
|
116
|
+
export const BINDABLE_INTERVAL_ORDER = ['3M', '1Y'];
|
|
117
|
+
export const POLLING_INTERVAL = 25000; // 25 seconds
|
|
118
|
+
export const HEALTH_POLLING_INTERVAL = 60000; // 60 seconds while visible; parked while hidden (backend caches the verdict 15s)
|
|
119
|
+
export const TOKEN_POLLING_INTERVAL = 60000; // 60 seconds while visible; parked while hidden
|
|
120
|
+
export const NOTIFICATION_POLLING_INTERVAL = 60000; // 60 seconds
|
|
121
|
+
export const WEBSOCKET_PING_INTERVAL_MS = 10000; // 10 seconds
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The registry keys of the built-in technical-indicator scripts, as a plain
|
|
3
|
+
* i18n-free module. `technicalIndicatorScripts.constants.ts` owns the full
|
|
4
|
+
* definitions (names/descriptions resolve through the i18n plugin, which pulls
|
|
5
|
+
* Vue), so worker-safe consumers (the kScript venue-policy decider) key off
|
|
6
|
+
* this list instead. A spec pins the two modules in lockstep
|
|
7
|
+
* (tests/constants/scriptEditor/technical-indicator-script-keys.spec.ts).
|
|
8
|
+
*/
|
|
9
|
+
export declare const TECHNICAL_INDICATOR_SCRIPT_KEYS: readonly ["VOLUME_BUBBLES", "BIG_TRADES", "BAR_STATISTICS", "VOLUME_BAR", "RSI", "EMA", "SMA", "BOLLINGER_BANDS", "MACD", "ICHI_CLOUD", "STOCH", "CCI", "MFI", "OBV", "ADL", "ADX", "PSAR", "ATR", "SUPERTREND", "KELTNER", "DONCHIAN", "WMA", "HMA", "VWMA", "STOCH_RSI", "WILLIAMS_R", "CMF", "AROON", "MOMENTUM", "ROC", "AO", "ZIGZAG", "PIVOT_POINTS"];
|
|
10
|
+
export declare const TECHNICAL_INDICATOR_SCRIPT_KEY_SET: ReadonlySet<string>;
|
|
11
|
+
/**
|
|
12
|
+
* The NATIVE officials (a control of their own, no kScript template) whose proven wrun twin routes the way a
|
|
13
|
+
* shipped template's does: the twins join (src/constants/wrun-twins.json) keys the twin by the native's
|
|
14
|
+
* registry key, its new adds mount the twin at the pin, a saved twin follows the pin, and the restore converts
|
|
15
|
+
* a saved native row into the twin (kscript-twin-convert.util, its settings through native-twin-settings.util).
|
|
16
|
+
* Kept here, beside the template keys, rather than read off the join: the pre-candle readers of a twin's stamp
|
|
17
|
+
* (wrun-builtin-twin.util) must stay off the join (tests/utility/wrun/wrun-twins.closure.spec.ts).
|
|
18
|
+
*/
|
|
19
|
+
export declare const NATIVE_OFFICIAL_TWIN_KEYS: ReadonlySet<string>;
|
|
20
|
+
/** Whether `key` names a built-in a proven twin can stand in for: a shipped template or a native official above. */
|
|
21
|
+
export declare function isBuiltInTwinKey(key: unknown): key is string;
|
|
22
|
+
/**
|
|
23
|
+
* The built-ins whose template draws batched plots (`plotBatches`: several bubbles or levels on one
|
|
24
|
+
* bar). Titan hides a batched overlay's legend readout, so the template prints none, and its proven
|
|
25
|
+
* twin wears that shape (the technical-script legend). Pinned against the template sources
|
|
26
|
+
* (tests/constants/scriptEditor/technical-indicator-script-keys.spec.ts).
|
|
27
|
+
*/
|
|
28
|
+
export declare const TECHNICAL_INDICATOR_SCRIPT_BATCHED_KEYS: ReadonlySet<string>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The registry keys of the built-in technical-indicator scripts, as a plain
|
|
3
|
+
* i18n-free module. `technicalIndicatorScripts.constants.ts` owns the full
|
|
4
|
+
* definitions (names/descriptions resolve through the i18n plugin, which pulls
|
|
5
|
+
* Vue), so worker-safe consumers (the kScript venue-policy decider) key off
|
|
6
|
+
* this list instead. A spec pins the two modules in lockstep
|
|
7
|
+
* (tests/constants/scriptEditor/technical-indicator-script-keys.spec.ts).
|
|
8
|
+
*/
|
|
9
|
+
export const TECHNICAL_INDICATOR_SCRIPT_KEYS = [
|
|
10
|
+
'VOLUME_BUBBLES',
|
|
11
|
+
'BIG_TRADES',
|
|
12
|
+
'BAR_STATISTICS',
|
|
13
|
+
'VOLUME_BAR',
|
|
14
|
+
'RSI',
|
|
15
|
+
'EMA',
|
|
16
|
+
'SMA',
|
|
17
|
+
'BOLLINGER_BANDS',
|
|
18
|
+
'MACD',
|
|
19
|
+
'ICHI_CLOUD',
|
|
20
|
+
'STOCH',
|
|
21
|
+
'CCI',
|
|
22
|
+
'MFI',
|
|
23
|
+
'OBV',
|
|
24
|
+
'ADL',
|
|
25
|
+
'ADX',
|
|
26
|
+
'PSAR',
|
|
27
|
+
// The TradingView staples (2026-10): trend and volatility, oscillators, drawn.
|
|
28
|
+
'ATR',
|
|
29
|
+
'SUPERTREND',
|
|
30
|
+
'KELTNER',
|
|
31
|
+
'DONCHIAN',
|
|
32
|
+
'WMA',
|
|
33
|
+
'HMA',
|
|
34
|
+
'VWMA',
|
|
35
|
+
'STOCH_RSI',
|
|
36
|
+
'WILLIAMS_R',
|
|
37
|
+
'CMF',
|
|
38
|
+
'AROON',
|
|
39
|
+
'MOMENTUM',
|
|
40
|
+
'ROC',
|
|
41
|
+
'AO',
|
|
42
|
+
'ZIGZAG',
|
|
43
|
+
'PIVOT_POINTS',
|
|
44
|
+
];
|
|
45
|
+
export const TECHNICAL_INDICATOR_SCRIPT_KEY_SET = new Set(TECHNICAL_INDICATOR_SCRIPT_KEYS);
|
|
46
|
+
/**
|
|
47
|
+
* The NATIVE officials (a control of their own, no kScript template) whose proven wrun twin routes the way a
|
|
48
|
+
* shipped template's does: the twins join (src/constants/wrun-twins.json) keys the twin by the native's
|
|
49
|
+
* registry key, its new adds mount the twin at the pin, a saved twin follows the pin, and the restore converts
|
|
50
|
+
* a saved native row into the twin (kscript-twin-convert.util, its settings through native-twin-settings.util).
|
|
51
|
+
* Kept here, beside the template keys, rather than read off the join: the pre-candle readers of a twin's stamp
|
|
52
|
+
* (wrun-builtin-twin.util) must stay off the join (tests/utility/wrun/wrun-twins.closure.spec.ts).
|
|
53
|
+
*/
|
|
54
|
+
export const NATIVE_OFFICIAL_TWIN_KEYS = new Set(['CVD_FLOW_DOMINANCE']);
|
|
55
|
+
/** Whether `key` names a built-in a proven twin can stand in for: a shipped template or a native official above. */
|
|
56
|
+
export function isBuiltInTwinKey(key) {
|
|
57
|
+
return typeof key === 'string' && (TECHNICAL_INDICATOR_SCRIPT_KEY_SET.has(key) || NATIVE_OFFICIAL_TWIN_KEYS.has(key));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The built-ins whose template draws batched plots (`plotBatches`: several bubbles or levels on one
|
|
61
|
+
* bar). Titan hides a batched overlay's legend readout, so the template prints none, and its proven
|
|
62
|
+
* twin wears that shape (the technical-script legend). Pinned against the template sources
|
|
63
|
+
* (tests/constants/scriptEditor/technical-indicator-script-keys.spec.ts).
|
|
64
|
+
*/
|
|
65
|
+
export const TECHNICAL_INDICATOR_SCRIPT_BATCHED_KEYS = new Set(['VOLUME_BUBBLES', 'BIG_TRADES']);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The TPO colour schemes the wrun canvases paint with, copied byte for byte from the web app's chart colour table
|
|
3
|
+
* (src/constants/chartColors.constants.ts), which this package does not carry (it is the app's whole theme table).
|
|
4
|
+
* tests/packages/wrun-chart-host/narrowed-constants.spec.ts pins the copy equal to the web constant.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_TPO_COLOR_SCHEMES: {
|
|
7
|
+
Kiyotaka: string[];
|
|
8
|
+
Sourgum: string[];
|
|
9
|
+
Neon: string[];
|
|
10
|
+
Classic: string[];
|
|
11
|
+
Sepia: string[];
|
|
12
|
+
Oceanic: string[];
|
|
13
|
+
Bubblegum: string[];
|
|
14
|
+
Retro: string[];
|
|
15
|
+
Cheesecake: string[];
|
|
16
|
+
Afterglow: string[];
|
|
17
|
+
CarbonCore: string[];
|
|
18
|
+
Percept: string[];
|
|
19
|
+
Seoul: string[];
|
|
20
|
+
Shanghai: string[];
|
|
21
|
+
Retrowave: string[];
|
|
22
|
+
Cyberpunk: string[];
|
|
23
|
+
Nordic: string[];
|
|
24
|
+
Quartz: string[];
|
|
25
|
+
Sunset: string[];
|
|
26
|
+
Ocean: string[];
|
|
27
|
+
Aurora: string[];
|
|
28
|
+
Luxe: string[];
|
|
29
|
+
Flow: string[];
|
|
30
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The TPO colour schemes the wrun canvases paint with, copied byte for byte from the web app's chart colour table
|
|
3
|
+
* (src/constants/chartColors.constants.ts), which this package does not carry (it is the app's whole theme table).
|
|
4
|
+
* tests/packages/wrun-chart-host/narrowed-constants.spec.ts pins the copy equal to the web constant.
|
|
5
|
+
*/
|
|
6
|
+
export const DEFAULT_TPO_COLOR_SCHEMES = {
|
|
7
|
+
// Theme-synced colors: [bearish60%, bearish90%, bullish60%, bullish90%]
|
|
8
|
+
Kiyotaka: ['#FF003C99', '#FF003CE6', '#CCFF0099', '#CCFF00E6'],
|
|
9
|
+
Sourgum: ['#FF6A0099', '#FF6A00E6', '#FFC30099', '#FFC300E6'],
|
|
10
|
+
Neon: ['#ff323299', '#ff3232E6', '#00d1b599', '#00d1b5E6'],
|
|
11
|
+
Classic: ['#F0535199', '#F05351E6', '#27A69A99', '#27A69AE6'],
|
|
12
|
+
Sepia: ['#F34E4E99', '#F34E4EE6', '#5EC16999', '#5EC169E6'],
|
|
13
|
+
Oceanic: ['#F4433699', '#F44336E6', '#00AEFF99', '#00AEFFE6'],
|
|
14
|
+
Bubblegum: ['#fc1c6699', '#fc1c66E6', '#00bdba99', '#00bdbaE6'],
|
|
15
|
+
Retro: ['#DD574799', '#DD5747E6', '#69C7C099', '#69C7C0E6'],
|
|
16
|
+
Cheesecake: ['#D4973A99', '#D4973AE6', '#D8555599', '#D85555E6'],
|
|
17
|
+
Afterglow: ['#FFAE0099', '#FFAE00E6', '#00D9FF99', '#00D9FFE6'],
|
|
18
|
+
CarbonCore: ['#40404099', '#404040E6', '#E0E0E099', '#E0E0E0E6'],
|
|
19
|
+
Percept: ['#CECECE99', '#CECECEE6', '#D9775799', '#D97757E6'],
|
|
20
|
+
Seoul: ['#3485FA99', '#3485FAE6', '#F0445299', '#F04452E6'],
|
|
21
|
+
Shanghai: ['#2EBD8599', '#2EBD85E6', '#F6465D99', '#F6465DE6'],
|
|
22
|
+
Retrowave: ['#FC586C99', '#FC586CE6', '#3DDC9799', '#3DDC97E6'],
|
|
23
|
+
Cyberpunk: ['#FF007F99', '#FF007FE6', '#00E5FF99', '#00E5FFE6'],
|
|
24
|
+
Nordic: ['#40404099', '#404040E6', '#E0E0E099', '#E0E0E0E6'],
|
|
25
|
+
Quartz: ['#AF687099', '#AF6870E6', '#A7BE9499', '#A7BE94E6'],
|
|
26
|
+
// Custom presets
|
|
27
|
+
Sunset: ['#33001A', '#CC0033', '#FF6600', '#FFD966'],
|
|
28
|
+
Ocean: ['#003366', '#006699', '#33CCFF', '#99FFFF'],
|
|
29
|
+
Aurora: ['#0B3D91', '#2E8B57', '#ADFF2F', '#FF69B4'],
|
|
30
|
+
Luxe: ['#111111', '#333333', '#777777', '#DDDDDD'],
|
|
31
|
+
Flow: ['#FF6B35', '#FFD166', '#06D6A0', '#118AB2'],
|
|
32
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host env: everything the wrun chart-host layer reads from the app that hosts it
|
|
3
|
+
* (docs/features/kscript/wrun/wrun-chart-host.md in the web repo, "Ports"). An app sets it once per realm, at the
|
|
4
|
+
* realm's entry and before any package code runs: web on the main thread (src/main.ts, through
|
|
5
|
+
* src/utility/wrun/wrun-chart-host-env.ts) and in the wrun sandbox worker's entry; the mobile app at its page boot and
|
|
6
|
+
* in its wrun worker. Package code reads it when it runs (`wrunChartHostEnv()`), never at module load, and a read
|
|
7
|
+
* before the set throws `wrun_chart_host_env_unset`.
|
|
8
|
+
*
|
|
9
|
+
* The env lives on the realm's global object under a registry symbol, so every copy of the package in one realm (a
|
|
10
|
+
* bundle that splits it, a spec that resets its module registry) reads the one the realm's entry set.
|
|
11
|
+
*/
|
|
12
|
+
import type * as WrunKitHost from '@orangecharts/indicator-kit/host';
|
|
13
|
+
/** The members of the kit's shared host (`@orangecharts/indicator-kit/host`) package code reads at run time. Web
|
|
14
|
+
* hands its host seam (src/utility/wrun/wrun-shared-host.ts), the mobile app the kit's host entry itself. */
|
|
15
|
+
export type WrunSharedHostModule = Pick<typeof WrunKitHost, 'decodeWrunHostedWire' | 'WRUN_HOST_CELL_TUPLE_WIDTHS' | 'WRUN_MAX_SHAPE_OFFSET_BARS' | 'WRUN_MINICHARTS_LABEL_MAX_CHARS' | 'WRUN_MINICHARTS_MAX_BARS' | 'WRUN_MINICHARTS_MAX_PANELS' | 'WRUN_MINICHARTS_TITLE_MAX_CHARS' | 'WRUN_STRATEGY_SHEET_FIELDS' | 'wrunMiniChartGridPayload' | 'wrunShapeEdgeTs' | 'wrunStrategyWireBytes'>;
|
|
16
|
+
/** The chart a cells notice belongs to: any engine instance whose mounted overlays carry their ids. */
|
|
17
|
+
export interface WrunCapNoticeChart {
|
|
18
|
+
metadata: ReadonlyArray<{
|
|
19
|
+
id: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
/** An Indicator's heatmap and batched-mark cells as the one "Cells capped" row sums them: the mounted total, and
|
|
23
|
+
* the capped numbers while a child holds fewer cells than it asked for. */
|
|
24
|
+
export interface WrunCellsCapSummary {
|
|
25
|
+
mounted: number;
|
|
26
|
+
capped: {
|
|
27
|
+
total: number;
|
|
28
|
+
drawn: number;
|
|
29
|
+
cap: number;
|
|
30
|
+
bars: number;
|
|
31
|
+
drawnBars: number;
|
|
32
|
+
} | null;
|
|
33
|
+
}
|
|
34
|
+
/** The run's retained range on the same row (a run budget kept fewer bars than the chart asked for). */
|
|
35
|
+
export interface WrunCapNoticeRetained {
|
|
36
|
+
/** The most rows a run of the session may hold. */
|
|
37
|
+
cap: number;
|
|
38
|
+
/** The bars the session calculated. */
|
|
39
|
+
calculatedBars: number;
|
|
40
|
+
/** The older bars the budget left out. */
|
|
41
|
+
droppedBars: number;
|
|
42
|
+
}
|
|
43
|
+
/** One Indicator's owed cells notice, read at the moment the host publishes it. */
|
|
44
|
+
export interface WrunCapNotice {
|
|
45
|
+
chart: WrunCapNoticeChart;
|
|
46
|
+
overlayId: string;
|
|
47
|
+
summary: WrunCellsCapSummary;
|
|
48
|
+
retained: WrunCapNoticeRetained | undefined;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* One chart's batch of owed cells notices (one publish per chart per batch of seams). The host takes it once it is
|
|
52
|
+
* ready to write: `take()` hands the batch's Indicators, each notice read when it is reached (the last seam's
|
|
53
|
+
* numbers, never a stale snapshot); `drop()` gives the batch up when the host cannot write (the notice is advisory).
|
|
54
|
+
*/
|
|
55
|
+
export interface WrunCapNoticeBatch {
|
|
56
|
+
take(): Iterable<WrunCapNotice>;
|
|
57
|
+
drop(): void;
|
|
58
|
+
}
|
|
59
|
+
/** A canvas child's cost rows for one Indicator: they replace that Indicator's rows of `ownedCodes`, every other
|
|
60
|
+
* row kept (web: wrun-canvas-cost-notice.util's publish port). Reserved: no slab 1 module publishes one. */
|
|
61
|
+
export interface WrunCanvasCostNotice {
|
|
62
|
+
chartIndex: number;
|
|
63
|
+
indicatorId: string;
|
|
64
|
+
ownedCodes: ReadonlySet<string>;
|
|
65
|
+
rows: ReadonlyArray<Readonly<Record<string, unknown>>>;
|
|
66
|
+
}
|
|
67
|
+
/** Where the layer's advisory output goes: the debug ring and the Indicator's notice rows. */
|
|
68
|
+
export interface WrunChartHostDiagnostics {
|
|
69
|
+
/** One debug-ring event (web: lazy-load-debug.util `logLazyLoadDebug`). Reserved: no slab 1 module logs. */
|
|
70
|
+
debug(event: string, details?: Record<string, unknown>): void;
|
|
71
|
+
/** Publish a batch of cells notices on the Indicator's legend rows. Never throws into the caller. */
|
|
72
|
+
publishCapNotice(batch: WrunCapNoticeBatch): void;
|
|
73
|
+
/** Publish a canvas cost notice. Reserved: no slab 1 module publishes one. */
|
|
74
|
+
publishCanvasCostNotice(notice: WrunCanvasCostNotice): void;
|
|
75
|
+
}
|
|
76
|
+
/** What the layer reads from its host. */
|
|
77
|
+
export interface WrunChartHostEnv {
|
|
78
|
+
/** A user-facing string by its locale key (web: the i18n plugin). Reserved: no slab 1 module translates. */
|
|
79
|
+
t(key: string, params?: Record<string, unknown>): string;
|
|
80
|
+
/** Whether the locale holds `key`. Reserved with `t`. */
|
|
81
|
+
te(key: string): boolean;
|
|
82
|
+
/** Load the shared host once (later calls answer the same module; a failed load is not cached). Package code
|
|
83
|
+
* that reaches the host asynchronously awaits this before its first synchronous use. */
|
|
84
|
+
loadSharedHost(): Promise<WrunSharedHostModule>;
|
|
85
|
+
/** The loaded shared host, for synchronous code a run reaches after `loadSharedHost()` resolved. Throws by name
|
|
86
|
+
* before the load (a new host throws `wrunChartHostUnloadedError()`; web keeps its loader's own message). */
|
|
87
|
+
sharedHost(): WrunSharedHostModule;
|
|
88
|
+
/** The DEX that runs a Solana pool market, undefined for every other venue and until its lookup lands
|
|
89
|
+
* (web: src/store/asset-names.ts `poolDexName`). Reserved: no slab 1 module names a pool. */
|
|
90
|
+
poolDexName(exchange: string | undefined, symbol: string | undefined): string | undefined;
|
|
91
|
+
diagnostics: WrunChartHostDiagnostics;
|
|
92
|
+
}
|
|
93
|
+
/** Set the realm's env (the realm's entry, before any package code runs; a later set replaces it). */
|
|
94
|
+
export declare function setWrunChartHostEnv(env: WrunChartHostEnv): void;
|
|
95
|
+
/** The realm's env. Throws `wrun_chart_host_env_unset` before the realm's entry set it. */
|
|
96
|
+
export declare function wrunChartHostEnv(): WrunChartHostEnv;
|
|
97
|
+
/** Whether the realm's env is set (an entry that may run twice sets it once). */
|
|
98
|
+
export declare function hasWrunChartHostEnv(): boolean;
|
|
99
|
+
/** The error a host's `sharedHost()` throws before its load. */
|
|
100
|
+
export declare function wrunChartHostUnloadedError(): Error;
|
|
101
|
+
/** Clear the realm's env, returning the one it held, so a spec can prove a cold read throws (specs only). */
|
|
102
|
+
export declare function __clearWrunChartHostEnvForTests(): WrunChartHostEnv | undefined;
|
package/dist/host-env.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const ENV_KEY = Symbol.for('@orangecharts/wrun-chart-host/env');
|
|
2
|
+
/** Set the realm's env (the realm's entry, before any package code runs; a later set replaces it). */
|
|
3
|
+
export function setWrunChartHostEnv(env) {
|
|
4
|
+
globalThis[ENV_KEY] = env;
|
|
5
|
+
}
|
|
6
|
+
/** The realm's env. Throws `wrun_chart_host_env_unset` before the realm's entry set it. */
|
|
7
|
+
export function wrunChartHostEnv() {
|
|
8
|
+
const env = globalThis[ENV_KEY];
|
|
9
|
+
if (env === undefined)
|
|
10
|
+
throw new Error('wrun_chart_host_env_unset');
|
|
11
|
+
return env;
|
|
12
|
+
}
|
|
13
|
+
/** Whether the realm's env is set (an entry that may run twice sets it once). */
|
|
14
|
+
export function hasWrunChartHostEnv() {
|
|
15
|
+
return globalThis[ENV_KEY] !== undefined;
|
|
16
|
+
}
|
|
17
|
+
/** The error a host's `sharedHost()` throws before its load. */
|
|
18
|
+
export function wrunChartHostUnloadedError() {
|
|
19
|
+
return new Error('wrun_chart_host_unloaded');
|
|
20
|
+
}
|
|
21
|
+
/** Clear the realm's env, returning the one it held, so a spec can prove a cold read throws (specs only). */
|
|
22
|
+
export function __clearWrunChartHostEnvForTests() {
|
|
23
|
+
const env = globalThis[ENV_KEY];
|
|
24
|
+
delete globalThis[ENV_KEY];
|
|
25
|
+
return env;
|
|
26
|
+
}
|