@orangecharts/wrun-chart-host 0.8.0 → 0.9.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 +2 -1
- package/dist/constants/feature-flags.constants.d.ts +4 -0
- package/dist/constants/feature-flags.constants.js +27 -0
- package/dist/constants/marketCapabilities.constants.d.ts +14 -9
- package/dist/constants/marketCapabilities.constants.js +36 -13
- package/dist/constants/opra-compliance.constants.d.ts +14 -0
- package/dist/constants/opra-compliance.constants.js +14 -0
- package/dist/constants/option-venues.constants.d.ts +11 -6
- package/dist/constants/option-venues.constants.js +5 -2
- package/dist/host-env.d.ts +10 -4
- package/dist/host-ports.types.d.ts +39 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
- package/dist/interfaces/opra-realtime.interface.js +10 -10
- package/dist/interfaces/wrun-runtime.interface.d.ts +34 -13
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +53 -10
- package/dist/kscript-data/controls/live-trades-merge.util.js +81 -16
- package/dist/market-data/billing.interface.d.ts +138 -17
- package/dist/market-data/billing.interface.js +25 -8
- package/dist/market-data/venues/index.d.ts +3 -3
- package/dist/market-data/venues/opra.contract.copy.json +5 -3
- package/dist/market-data/venues/opra.d.ts +3 -3
- package/dist/market-data/venues/opra.js +5 -4
- package/dist/replay/replayLadder.js +3 -1
- package/dist/utility/chart/crypto-index.leaf.d.ts +2 -2
- package/dist/utility/chart/crypto-index.leaf.js +2 -2
- package/dist/utility/chart/index-mode-admission.util.js +9 -1
- package/dist/utility/chart/index-mode.util.d.ts +5 -2
- package/dist/utility/chart/index-mode.util.js +23 -13
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +28 -21
- package/dist/utility/chart/kscript-venue-policy.util.js +30 -24
- package/dist/utility/chart/marketKind.util.d.ts +12 -10
- package/dist/utility/chart/marketKind.util.js +17 -7
- package/dist/utility/chart/om-panel-push-style.util.d.ts +7 -7
- package/dist/utility/chart/om-panel-push-style.util.js +17 -15
- package/dist/utility/chart/om-panel.util.js +6 -6
- package/dist/utility/chart/profile-block-size.util.d.ts +16 -0
- package/dist/utility/chart/profile-block-size.util.js +7 -0
- package/dist/utility/chart/quote-perp.leaf.d.ts +17 -0
- package/dist/utility/chart/quote-perp.leaf.js +20 -0
- package/dist/utility/chart/wrun-run-result.util.d.ts +5 -0
- package/dist/utility/chart/wrun-run-result.util.js +4 -1
- package/dist/utility/common/transformations.util.d.ts +7 -0
- package/dist/utility/common/transformations.util.js +11 -0
- package/dist/utility/options/option-venue.util.d.ts +3 -3
- package/dist/utility/options/option-venue.util.js +3 -3
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +1 -1
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +2 -2
- package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +2 -2
- package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +5 -1
- package/dist/utility/wrun/sources/row-lane-registry.js +3 -2
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +9 -3
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +13 -5
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +11 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +63 -9
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +8 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +12 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +5 -2
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +5 -2
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +11 -5
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +31 -10
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +33 -1
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +95 -6
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +25 -5
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +55 -18
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +146 -40
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +16 -3
- package/dist/utility/wrun/wrun-batched-marks.util.js +30 -19
- package/dist/utility/wrun/wrun-batched-readout.util.d.ts +37 -9
- package/dist/utility/wrun/wrun-batched-readout.util.js +61 -15
- package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-cell-capacity.leaf.d.ts +66 -0
- package/dist/utility/wrun/wrun-cell-capacity.leaf.js +86 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +147 -9
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +345 -11
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +19 -9
- package/dist/utility/wrun/wrun-color-facts.util.js +24 -14
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +15 -4
- package/dist/utility/wrun/wrun-color-settings.util.js +31 -12
- package/dist/utility/wrun/wrun-dollar-unit-port.leaf.d.ts +17 -0
- package/dist/utility/wrun/wrun-dollar-unit-port.leaf.js +9 -0
- package/dist/utility/wrun/wrun-download-meter.util.d.ts +92 -0
- package/dist/utility/wrun/wrun-download-meter.util.js +122 -0
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-draft-overlay.util.js +23 -3
- package/dist/utility/wrun/wrun-frames.js +5 -5
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +7 -0
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +33 -17
- package/dist/utility/wrun/wrun-hud-looks.util.js +30 -16
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +8 -6
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +8 -6
- package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -2
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +6 -2
- package/dist/utility/wrun/wrun-live-intake.util.js +136 -21
- package/dist/utility/wrun/wrun-live-tick.util.js +91 -38
- package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.d.ts +53 -0
- package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.js +162 -0
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +166 -48
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +216 -33
- package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +51 -7
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +314 -56
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +41 -2
- package/dist/utility/wrun/wrun-option-prints.util.js +80 -13
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +3 -0
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +3 -0
- package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-option-strike-flow.util.js +55 -0
- package/dist/utility/wrun/wrun-option-views.util.d.ts +51 -7
- package/dist/utility/wrun/wrun-option-views.util.js +151 -28
- package/dist/utility/wrun/wrun-options-stop.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-options-stop.util.js +3 -2
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +31 -14
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +22 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +7 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +25 -1
- package/dist/utility/wrun/wrun-overlay-result.util.d.ts +7 -1
- package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +34 -6
- package/dist/utility/wrun/wrun-overlay-run.util.js +416 -171
- package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +4 -4
- package/dist/utility/wrun/wrun-pack-widths.leaf.js +4 -4
- package/dist/utility/wrun/wrun-pack.util.d.ts +7 -3
- package/dist/utility/wrun/wrun-pack.util.js +20 -9
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +27 -15
- package/dist/utility/wrun/wrun-panel-style.util.js +42 -20
- package/dist/utility/wrun/wrun-param-map.util.d.ts +7 -6
- package/dist/utility/wrun/wrun-param-map.util.js +8 -5
- package/dist/utility/wrun/wrun-param-values.util.d.ts +10 -2
- package/dist/utility/wrun/wrun-param-values.util.js +2 -0
- package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
- package/dist/utility/wrun/wrun-refusal.util.js +10 -1
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +7 -0
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-source-rows.util.js +92 -40
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +126 -50
- package/dist/utility/wrun/wrun-tape-source.util.js +193 -68
- package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +7 -5
- package/dist/utility/wrun/wrun-volume-profile-lane.util.js +8 -6
- package/dist/workers/utils/volume-profile.worker.util.d.ts +4 -1
- package/dist/workers/utils/volume-profile.worker.util.js +5 -2
- package/dist/workers/wrun/wrun-abi-host.js +3 -2
- package/package.json +11 -11
|
@@ -47,7 +47,10 @@
|
|
|
47
47
|
* om WRUN_OPTION_FACT_FILLS, which only the chart's browser lane fills): the US
|
|
48
48
|
* dollars one price unit times one size unit of an option on the chart's options
|
|
49
49
|
* chain is worth, 100 on OPRA, the CME root's point value, 1 on a crypto chart,
|
|
50
|
-
* else 0 (wrunChartOptionMultiplier).
|
|
50
|
+
* else 0 (wrunChartOptionMultiplier); and `market.dollar_multiplier()` (kit 0.95.0):
|
|
51
|
+
* the US dollars one size unit of the market's own trades at one price unit is
|
|
52
|
+
* worth, the market's proven dollar unit (wrunMarketDollarUnit: the CME
|
|
53
|
+
* registry's point value, NQ 20; 1 on a market quoted in dollars), else 0.
|
|
51
54
|
*
|
|
52
55
|
* The 0 rule: a fact the chart does not know is 0, never a guess. Main thread
|
|
53
56
|
* only (the directory read goes through the markets service); the hosted lanes
|
|
@@ -56,11 +59,15 @@
|
|
|
56
59
|
import { AssetClass, Category, Exchange } from '@orangecharts/orange-v2-pb-common';
|
|
57
60
|
import { wrunChartHostEnv } from '../../host-env.js';
|
|
58
61
|
import { isCmeGoverned } from '../chart/cme-realtime.util.js';
|
|
62
|
+
import { isContinuousSymbol } from '../chart/continuous-contracts.util.js';
|
|
59
63
|
import { governedContractCoin } from '../chart/governed-contract-coin.util.js';
|
|
60
64
|
import { checkIsEconomic, getMarketKind } from '../chart/marketKind.util.js';
|
|
61
65
|
import { optionVenueForExchange, optionVenueForUnderlyingExchange } from '../options/option-venue.util.js';
|
|
62
66
|
import { WRUN_LANE_CURRENCY_AUTO, WRUN_MARKET_FACT_FILLS, WRUN_MARKET_KINDS, WRUN_MARKET_QUOTE_IS_USD, WRUN_MARKET_SESSION_OPEN_CME, wrunLaneCurrency, wrunMarketSizeUnit, wrunMarketZoneCode, wrunCoinLegSource, wrunFollowsCoin, wrunRowVisibleHere, wrunVisibleByNeedsKind, } from './wrun-market-facts.util.js';
|
|
63
67
|
import { isWrunLegStreamClass } from './wrun-leg-stream-classes.js';
|
|
68
|
+
import { isTradesDollarQuoteAsset } from '../../kscript-data/controls/live-trades-merge.util.js';
|
|
69
|
+
import { getExchangeFromSymbol } from '../../helpers/data.helpers.js';
|
|
70
|
+
import { bindWrunDollarUnitReader } from './wrun-dollar-unit-port.leaf.js';
|
|
64
71
|
// ---------------------------------------------------------------------------
|
|
65
72
|
// om's venue tables, mirrored (each names its om source): the chart must
|
|
66
73
|
// answer every market om knows the way om does.
|
|
@@ -345,6 +352,11 @@ export function wrunChartMarketFacts(market, row) {
|
|
|
345
352
|
const sessionOpen = cme ? WRUN_MARKET_SESSION_OPEN_CME : 0;
|
|
346
353
|
return { kind: kindCode(kind), pointValue, zone, quoteIsUsd: quoteCode(quote), sessionOpen };
|
|
347
354
|
}
|
|
355
|
+
/** The host_fill word of `market.dollar_multiplier()` (kit 0.95.0). */
|
|
356
|
+
export const WRUN_DOLLAR_MULTIPLIER_FILL = 'dollar_multiplier';
|
|
357
|
+
/** A sheet reading `market.dollar_multiplier()` on a market whose dollar unit is not proven (wrunMarketDollarUnit):
|
|
358
|
+
* the run head's refusal by name, before any fetch (no trade could be valued). */
|
|
359
|
+
export const WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE = 'wrun_dollar_multiplier_unproven';
|
|
348
360
|
/** An OPRA chain's multiplier: US listed options are priced per share and sized in contracts of 100 shares. */
|
|
349
361
|
const OPRA_OPTION_MULTIPLIER = 100;
|
|
350
362
|
/** A crypto chain's multiplier, on every venue: prices in US dollars per coin, sizes in coin. */
|
|
@@ -405,20 +417,37 @@ export function wrunChartOptionMultiplier(market) {
|
|
|
405
417
|
return isCryptoChartVenue(venue) ? CRYPTO_OPTION_MULTIPLIER : 0;
|
|
406
418
|
}
|
|
407
419
|
/** The host_fill words whose values the host fill carries off the chart's market (wrunMarketFactsFor): the five
|
|
408
|
-
* market facts
|
|
409
|
-
* 0.87.0, which the kit exports no runtime list for). */
|
|
420
|
+
* market facts, the option multiplier (om WRUN_OPTION_FACT_FILLS, a word of the kit's WrunParamHostFill since
|
|
421
|
+
* 0.87.0, which the kit exports no runtime list for) and the dollar multiplier (kit 0.95.0). */
|
|
410
422
|
const WRUN_CHART_MARKET_FILLS = new Set([
|
|
411
423
|
...WRUN_MARKET_FACT_FILLS,
|
|
412
424
|
'option_multiplier',
|
|
425
|
+
WRUN_DOLLAR_MULTIPLIER_FILL,
|
|
413
426
|
]);
|
|
414
427
|
/** True when the sheet declares one of the market's facts (a host-filled
|
|
415
|
-
* param on `kind`, `point_value`, `zone`, `quote_is_usd`, `session_open
|
|
416
|
-
* `option_multiplier`): the runs whose host fill
|
|
417
|
-
* Only a sheet that declares a directory fact
|
|
418
|
-
* (wrunMarketFactsNeedDirectory). */
|
|
428
|
+
* param on `kind`, `point_value`, `zone`, `quote_is_usd`, `session_open`,
|
|
429
|
+
* `option_multiplier` or `dollar_multiplier`): the runs whose host fill
|
|
430
|
+
* carries the market's facts. Only a sheet that declares a directory fact
|
|
431
|
+
* waits for the read (wrunMarketFactsNeedDirectory). */
|
|
419
432
|
export function wrunReadsMarketFacts(metadata) {
|
|
420
433
|
return (metadata?.params ?? []).some((param) => param.host_fill !== undefined && WRUN_CHART_MARKET_FILLS.has(param.host_fill));
|
|
421
434
|
}
|
|
435
|
+
/** True when the sheet reads the market's dollar multiplier (a host-filled param on `dollar_multiplier`, kit
|
|
436
|
+
* 0.95.0): its run proves the market's dollar unit at its head before any fetch (wrun-overlay-run.util), so its
|
|
437
|
+
* module, its batched captions and its dollar tape read one number. */
|
|
438
|
+
export function wrunReadsDollarMultiplier(metadata) {
|
|
439
|
+
return (metadata?.params ?? []).some((param) => param.host_fill === WRUN_DOLLAR_MULTIPLIER_FILL);
|
|
440
|
+
}
|
|
441
|
+
/** The hidden param the kit generates for the dollar multiplier (`market_dollar_multiplier`). */
|
|
442
|
+
const WRUN_DOLLAR_MULTIPLIER_PARAM_NAME = `market_${WRUN_DOLLAR_MULTIPLIER_FILL}`;
|
|
443
|
+
/** wrunReadsDollarMultiplier over an overlay's declared inputs (`settings.scriptInputs`), for a lane that holds no
|
|
444
|
+
* sheet (the cloud payload): a row under the fact's generated name. */
|
|
445
|
+
export function wrunDeclaresDollarMultiplier(declarations) {
|
|
446
|
+
return (Array.isArray(declarations) &&
|
|
447
|
+
declarations.some((row) => row !== null &&
|
|
448
|
+
typeof row === 'object' &&
|
|
449
|
+
row.name === WRUN_DOLLAR_MULTIPLIER_PARAM_NAME));
|
|
450
|
+
}
|
|
422
451
|
/** The facts the directory row answers: wrunChartMarketFacts reads the row for
|
|
423
452
|
* `kind` (its asset class) and `quote_is_usd` (its quote) alone. The other
|
|
424
453
|
* three are the venue tables' (`point_value` the CME root's or the venue's
|
|
@@ -715,17 +744,322 @@ export function wrunMarketFactsSettled(market) {
|
|
|
715
744
|
return settledRows.has(key) || Date.now() < (retryAfter.get(key) ?? 0);
|
|
716
745
|
}
|
|
717
746
|
/** The facts the chart fills for `market` now (synchronous): the five over the
|
|
718
|
-
* directory row once warmWrunMarketFacts settled it, else without one,
|
|
719
|
-
*
|
|
720
|
-
* venue tables alone, no read)
|
|
747
|
+
* directory row once warmWrunMarketFacts settled it, else without one, the
|
|
748
|
+
* option multiplier of its options chain (wrunChartOptionMultiplier: the
|
|
749
|
+
* venue tables alone, no read) and the dollar multiplier of its own trades
|
|
750
|
+
* (wrunMarketDollarUnit over the reads warmWrunMarketDollarFacts settled; 0
|
|
751
|
+
* while it is not proven). */
|
|
721
752
|
export function wrunMarketFactsFor(market) {
|
|
722
753
|
const parts = marketKeyParts(market);
|
|
723
754
|
const row = parts === undefined ? undefined : settledRows.get(directoryKey(parts.venue, parts.symbol));
|
|
724
|
-
|
|
755
|
+
const dollars = wrunMarketDollarUnit(market);
|
|
756
|
+
return {
|
|
757
|
+
...wrunChartMarketFacts(market, row ?? undefined),
|
|
758
|
+
optionMultiplier: wrunChartOptionMultiplier(market),
|
|
759
|
+
dollarMultiplier: dollars.kind === 'dollars' ? dollars.unit : 0,
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
/** A registry field that is a finite number above zero, else null (absent, zero, negative or unreadable). */
|
|
763
|
+
function positiveUnit(value) {
|
|
764
|
+
const number = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : Number.NaN;
|
|
765
|
+
return Number.isFinite(number) && number > 0 ? number : null;
|
|
766
|
+
}
|
|
767
|
+
/** The trade units of one registry record (a `getSymbolMetadata` answer), null for no record. Pure. */
|
|
768
|
+
export function wrunMarketTradeUnitsOf(record) {
|
|
769
|
+
if (!isRecordLike(record))
|
|
770
|
+
return null;
|
|
771
|
+
const normalized = upperText(record.normalizedSymbol);
|
|
772
|
+
return {
|
|
773
|
+
pointValue: positiveUnit(record.pointValue),
|
|
774
|
+
quote: normalized === undefined ? undefined : /^[A-Z0-9.]+-([A-Z0-9]+)$/.exec(normalized)?.[1],
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
function isRecordLike(value) {
|
|
778
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
779
|
+
}
|
|
780
|
+
/** The registry's units by market (the chart market's `venue\0SYMBOL`) for the session: a record's units, or null
|
|
781
|
+
* for a market the registry holds no record of (or a host that reads none). */
|
|
782
|
+
const settledUnits = new Map();
|
|
783
|
+
/** Registry reads in flight by market. */
|
|
784
|
+
const pendingUnits = new Map();
|
|
785
|
+
/** When a market whose read failed (or whose continuous lead was not known yet) may be asked again (epoch ms). */
|
|
786
|
+
const unitsRetryAfter = new Map();
|
|
787
|
+
/** A read that cannot settle yet: retried after the window (a failed read, a continuous chart's lead not known). */
|
|
788
|
+
class TradeUnitsUnsettled extends Error {
|
|
789
|
+
}
|
|
790
|
+
/** The instrument a market's prints are of: the chart's own symbol, or a continuous CME chart's lead contract (the
|
|
791
|
+
* chart's stamp, else the continuous contracts service's answer). Throws when a continuous chart's lead is not known
|
|
792
|
+
* yet (retried). */
|
|
793
|
+
async function wrunTradeUnitsInstrument(venue, symbol, resolvedContract) {
|
|
794
|
+
if (!isCmeFamily(venue) || !isContinuousSymbol(symbol))
|
|
795
|
+
return symbol;
|
|
796
|
+
const stamped = typeof resolvedContract === 'string' ? resolvedContract.trim() : '';
|
|
797
|
+
if (stamped !== '')
|
|
798
|
+
return stamped;
|
|
799
|
+
const { default: contracts } = await wrunChartHostEnv().market.loadContinuousContracts();
|
|
800
|
+
const lead = await contracts.getResolvedLead(venue, symbol);
|
|
801
|
+
if (lead === null || typeof lead.symbol !== 'string' || lead.symbol === '') {
|
|
802
|
+
throw new TradeUnitsUnsettled(`${venue}:${symbol}`);
|
|
803
|
+
}
|
|
804
|
+
return lead.symbol;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Ask the instrument registry for `market`'s trade units: once per market for the session, a definite answer (the
|
|
808
|
+
* record's units, or none) kept; concurrent callers share one read; a failed read, or a continuous chart whose lead is
|
|
809
|
+
* not known yet, is asked again a minute later. A host whose metadata service reads no registry record
|
|
810
|
+
* (`getSymbolMetadata` unbound) settles none. Never rejects. The read is fresh (`{ fresh: true }`, as the option units
|
|
811
|
+
* read is): a cached record can predate the registry's point value fill.
|
|
812
|
+
*/
|
|
813
|
+
export function warmWrunMarketTradeUnits(market) {
|
|
814
|
+
const parts = marketKeyParts(market);
|
|
815
|
+
if (parts === undefined)
|
|
816
|
+
return Promise.resolve();
|
|
817
|
+
const key = directoryKey(parts.venue, parts.symbol);
|
|
818
|
+
if (settledUnits.has(key))
|
|
819
|
+
return Promise.resolve();
|
|
820
|
+
if (Date.now() < (unitsRetryAfter.get(key) ?? 0))
|
|
821
|
+
return Promise.resolve();
|
|
822
|
+
let read = pendingUnits.get(key);
|
|
823
|
+
if (read === undefined) {
|
|
824
|
+
read = (async () => {
|
|
825
|
+
const instrument = await wrunTradeUnitsInstrument(parts.venue, parts.symbol, market?.resolvedContract);
|
|
826
|
+
const { default: metadataService } = await wrunChartHostEnv().market.loadMetadataService();
|
|
827
|
+
if (typeof metadataService.getSymbolMetadata !== 'function')
|
|
828
|
+
return null;
|
|
829
|
+
return wrunMarketTradeUnitsOf(await metadataService.getSymbolMetadata(parts.venue, instrument, { fresh: true }));
|
|
830
|
+
})()
|
|
831
|
+
.then((units) => {
|
|
832
|
+
settledUnits.set(key, units);
|
|
833
|
+
unitsRetryAfter.delete(key);
|
|
834
|
+
})
|
|
835
|
+
.catch(() => {
|
|
836
|
+
unitsRetryAfter.set(key, Date.now() + DIRECTORY_RETRY_MS);
|
|
837
|
+
})
|
|
838
|
+
.finally(() => pendingUnits.delete(key));
|
|
839
|
+
pendingUnits.set(key, read);
|
|
840
|
+
}
|
|
841
|
+
return read;
|
|
842
|
+
}
|
|
843
|
+
/** The registry's units of `market` once a read settled them: the units, null for no record, undefined while the
|
|
844
|
+
* registry can still answer (not asked yet, in flight, or a failed read that is retried). Synchronous. */
|
|
845
|
+
export function wrunMarketTradeUnitsNow(market) {
|
|
846
|
+
const parts = marketKeyParts(market);
|
|
847
|
+
if (parts === undefined)
|
|
848
|
+
return null;
|
|
849
|
+
const key = directoryKey(parts.venue, parts.symbol);
|
|
850
|
+
return settledUnits.has(key) ? (settledUnits.get(key) ?? null) : undefined;
|
|
851
|
+
}
|
|
852
|
+
/** Warm everything a market's dollar unit and stored unit read (C-DOLLAR): the directory row (a crypto market's quote)
|
|
853
|
+
* and the instrument registry's units. Never rejects. */
|
|
854
|
+
export function warmWrunMarketDollarFacts(market) {
|
|
855
|
+
return Promise.all([warmWrunMarketFacts(market), warmWrunMarketTradeUnits(market)]).then(() => undefined);
|
|
856
|
+
}
|
|
857
|
+
/** True when a read of `market`'s dollar unit now would wait on nothing (warmWrunMarketDollarFacts): the directory row
|
|
858
|
+
* (wrunMarketFactsSettled) and the registry's units each answered, failed recently, or are never asked. */
|
|
859
|
+
export function wrunMarketDollarFactsSettled(market) {
|
|
860
|
+
if (!wrunMarketFactsSettled(market))
|
|
861
|
+
return false;
|
|
862
|
+
const parts = marketKeyParts(market);
|
|
863
|
+
if (parts === undefined)
|
|
864
|
+
return true;
|
|
865
|
+
const key = directoryKey(parts.venue, parts.symbol);
|
|
866
|
+
return settledUnits.has(key) || Date.now() < (unitsRetryAfter.get(key) ?? 0);
|
|
867
|
+
}
|
|
868
|
+
/** The quote asset a crypto venue's raw symbol spells after its separator (`BTC_USDT`, `BTC-USDT-SWAP`): positive
|
|
869
|
+
* evidence only (a tail that is no dollar asset, `BTC-PERPETUAL`, proves nothing). */
|
|
870
|
+
function separatedQuote(symbol) {
|
|
871
|
+
const parts = symbol.trim().toUpperCase().split(/[_-]/);
|
|
872
|
+
return parts.length >= 2 && parts[0] !== '' ? parts[1] : undefined;
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Whether a market off the CME family is quoted in US dollars, a dollar stablecoin included (the gateway writer's
|
|
876
|
+
* pegged quotes, `isTradesDollarQuoteAsset`): US listings and POLYGON_INDICES yes; else the registry record's quote
|
|
877
|
+
* (its normalized symbol), then the directory row's quote, then the chart's own spelling of the pair
|
|
878
|
+
* (`spelledQuote`), then a raw symbol's separated quote when it is a dollar asset. Undefined when nothing says.
|
|
879
|
+
*/
|
|
880
|
+
function wrunMarketQuoteInDollars(market, venue, row, units) {
|
|
881
|
+
if (US_LISTING_EXCHANGES.has(venue) || INDEX_EXCHANGES.has(venue))
|
|
882
|
+
return true;
|
|
883
|
+
if (units?.quote !== undefined)
|
|
884
|
+
return isTradesDollarQuoteAsset(units.quote);
|
|
885
|
+
const rowQuoteWord = row === undefined ? undefined : (upperText(row.quoteAssetId) ?? upperText(row.quoteCoinName));
|
|
886
|
+
if (rowQuoteWord !== undefined)
|
|
887
|
+
return isTradesDollarQuoteAsset(rowQuoteWord);
|
|
888
|
+
const spelled = spelledQuote(venue, market);
|
|
889
|
+
if (spelled !== undefined)
|
|
890
|
+
return isTradesDollarQuoteAsset(spelled);
|
|
891
|
+
const separated = typeof market.symbol === 'string' ? separatedQuote(market.symbol) : undefined;
|
|
892
|
+
return separated !== undefined && isTradesDollarQuoteAsset(separated) ? true : undefined;
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* The US dollars one price unit times one live-feed COIN-arm size unit is worth on `market` (C-DOLLAR's unit value).
|
|
896
|
+
* ONE rule for every market, read off the server's facts and never off a venue list or a table of ours:
|
|
897
|
+
*
|
|
898
|
+
* - A CME Group contract counts contracts on the COIN arm (live-feed never multiplies a point-valued product), so its
|
|
899
|
+
* unit is the instrument registry's point value, in US dollars per point (`warmWrunMarketTradeUnits`: ES 50, 6A
|
|
900
|
+
* 100,000, a cents-quoted grain per cent, ZC 50 and ZL 600), the number the large-print writer prices the table's
|
|
901
|
+
* copies with. An option contract, or a contract the registry holds no point value for, cannot be priced.
|
|
902
|
+
* - Every other market counts its base asset on the COIN arm (live-feed applied each instrument's contract multiplier
|
|
903
|
+
* and its inverse flag), so its unit is the market facts' point value (1, `market.point_value()`; 0 on ICE and
|
|
904
|
+
* PLATTS, whose multipliers no one serves) on a market quoted in dollars (`wrunMarketQuoteInDollars`).
|
|
905
|
+
*
|
|
906
|
+
* A candle's volume times its close times the unit is that candle's dollar volume (the dollar default,
|
|
907
|
+
* wrun-market-size-defaults), and a live print's price times its COIN-arm size times the unit is the print's dollar
|
|
908
|
+
* value (the tape's live fold). A fact that cannot be proven is a named reason, never a guess; `transient` while a read
|
|
909
|
+
* can still answer it. Synchronous: the reads are taken once `warmWrunMarketDollarFacts` settled them.
|
|
910
|
+
*/
|
|
911
|
+
export function wrunMarketDollarUnit(market) {
|
|
912
|
+
const parts = marketKeyParts(market);
|
|
913
|
+
if (market === undefined || parts === undefined)
|
|
914
|
+
return { kind: 'unproven', reason: 'quote', transient: false };
|
|
915
|
+
const key = directoryKey(parts.venue, parts.symbol);
|
|
916
|
+
const units = wrunMarketTradeUnitsNow(market);
|
|
917
|
+
if (isCmeFamily(parts.venue)) {
|
|
918
|
+
if (isOptionContract(market.category))
|
|
919
|
+
return { kind: 'unproven', reason: 'point-value', transient: false };
|
|
920
|
+
if (units === undefined)
|
|
921
|
+
return { kind: 'unproven', reason: 'point-value', transient: true };
|
|
922
|
+
return units?.pointValue != null
|
|
923
|
+
? { kind: 'dollars', unit: units.pointValue }
|
|
924
|
+
: { kind: 'unproven', reason: 'point-value', transient: false };
|
|
925
|
+
}
|
|
926
|
+
const row = settledRows.get(key) ?? undefined;
|
|
927
|
+
const { pointValue } = wrunChartMarketFacts(market, row);
|
|
928
|
+
if (!(Number.isFinite(pointValue) && pointValue > 0)) {
|
|
929
|
+
return { kind: 'unproven', reason: 'point-value', transient: false };
|
|
930
|
+
}
|
|
931
|
+
const dollars = wrunMarketQuoteInDollars(market, parts.venue, row, units);
|
|
932
|
+
if (dollars === true)
|
|
933
|
+
return { kind: 'dollars', unit: pointValue };
|
|
934
|
+
// Unknown while a read can still answer the quote (the registry record or the directory row: not asked yet, or a
|
|
935
|
+
// failed read that is retried); a quote an answer or the market's own spelling names is no dollar quote for good.
|
|
936
|
+
const answered = units !== undefined && (!directoryAnswers(parts.venue) || settledRows.has(key));
|
|
937
|
+
return { kind: 'unproven', reason: 'quote', transient: dollars === undefined && !answered };
|
|
938
|
+
}
|
|
939
|
+
/** The writer's dollars per stored unit by market for the session: a number, or null for a market with no large print
|
|
940
|
+
* in any window (or a host that reads no series). */
|
|
941
|
+
const settledStoredUnits = new Map();
|
|
942
|
+
/** Stored unit reads in flight by market. */
|
|
943
|
+
const pendingStoredUnits = new Map();
|
|
944
|
+
/** When a market whose stored unit read failed may be asked again (epoch ms). */
|
|
945
|
+
const storedUnitsRetryAfter = new Map();
|
|
946
|
+
/** How far back the newest large print is looked for: the large table's own retention (a week). The read asks one
|
|
947
|
+
* row, newest first, so a busy market answers one print, not a week of them (measured 2026-10-22: one row on
|
|
948
|
+
* BINANCE_FUTURES BTCUSDT, gate.io futures BTC_USDT and CME ESZ6 and ES1!). */
|
|
949
|
+
const STORED_UNIT_WINDOW_SEC = 7 * 86_400;
|
|
950
|
+
const STORED_UNIT_TIMEOUT_MS = 20_000;
|
|
951
|
+
/**
|
|
952
|
+
* The large-print writer's dollars per STORED unit off a TRADE_LARGE answer (decoded series frames, the TRADES
|
|
953
|
+
* columns): `quoteAmount / amount` of the newest row whose both are finite and above zero, undefined when no row is.
|
|
954
|
+
* The writer prices each copy per instrument (contracts times the contract multiplier times the price on a linear
|
|
955
|
+
* market, the contract's dollar face on an inverse one, contracts times the price times the point value on CME), so the
|
|
956
|
+
* ratio is what one stored unit was worth at that print, on every venue, with no unit of ours. Pure.
|
|
957
|
+
*/
|
|
958
|
+
export function wrunStoredUnitDollarsOfRows(frames) {
|
|
959
|
+
let newestTs = Number.NEGATIVE_INFINITY;
|
|
960
|
+
let perUnit;
|
|
961
|
+
for (const frame of frames) {
|
|
962
|
+
const records = frame?.records;
|
|
963
|
+
const length = Number(records?.length);
|
|
964
|
+
if (records === undefined || !(length > 0) || !records.ts || !records.volume || !records.quoteAmount)
|
|
965
|
+
continue;
|
|
966
|
+
for (let at = 0; at < length; at += 1) {
|
|
967
|
+
const ts = Number(records.ts[at]);
|
|
968
|
+
const amount = Number(records.volume[at]);
|
|
969
|
+
const quote = Number(records.quoteAmount[at]);
|
|
970
|
+
if (!Number.isFinite(ts) || !(Number.isFinite(amount) && amount > 0) || !(Number.isFinite(quote) && quote > 0)) {
|
|
971
|
+
continue;
|
|
972
|
+
}
|
|
973
|
+
if (ts > newestTs) {
|
|
974
|
+
newestTs = ts;
|
|
975
|
+
perUnit = quote / amount;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
return perUnit;
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Read what one STORED unit of `market` is worth in dollars off the large-print writer's own rows: the market's newest
|
|
983
|
+
* TRADE_LARGE print (`wrunStoredUnitDollarsOfRows`), through the host's series read on the K_TRADES history's own wire
|
|
984
|
+
* (the chart's market, its wire venue as the K_TRADES worker spells it; TRADE_LARGE is a v2-only read, never the /v3
|
|
985
|
+
* catalog, whose crypto rows carry no unit): one row, newest first, over the table's week. Once per market for the
|
|
986
|
+
* session; concurrent callers share one read; a failed read is asked again a minute later. A host whose v2 service
|
|
987
|
+
* reads no series (`sendSeriesOneShot` unbound) settles none. Never rejects. Only a run head with a raw floor to carry
|
|
988
|
+
* asks it (wrun-market-size-defaults.util).
|
|
989
|
+
*/
|
|
990
|
+
export function warmWrunMarketStoredUnit(market) {
|
|
991
|
+
const parts = marketKeyParts(market);
|
|
992
|
+
if (parts === undefined)
|
|
993
|
+
return Promise.resolve();
|
|
994
|
+
const key = directoryKey(parts.venue, parts.symbol);
|
|
995
|
+
if (settledStoredUnits.has(key))
|
|
996
|
+
return Promise.resolve();
|
|
997
|
+
if (Date.now() < (storedUnitsRetryAfter.get(key) ?? 0))
|
|
998
|
+
return Promise.resolve();
|
|
999
|
+
let read = pendingStoredUnits.get(key);
|
|
1000
|
+
if (read === undefined) {
|
|
1001
|
+
read = (async () => {
|
|
1002
|
+
const { default: v2 } = await wrunChartHostEnv().transport.loadV2Service();
|
|
1003
|
+
if (typeof v2.sendSeriesOneShot !== 'function')
|
|
1004
|
+
return null;
|
|
1005
|
+
const toUnixS = Math.floor(Date.now() / 1000);
|
|
1006
|
+
const descriptor = {
|
|
1007
|
+
domain: 'CRYPTO',
|
|
1008
|
+
metric: 'TRADES',
|
|
1009
|
+
ref: { exchange: getExchangeFromSymbol(parts.venue, parts.symbol), symbol: parts.symbol },
|
|
1010
|
+
window: { fromUnixS: toUnixS - STORED_UNIT_WINDOW_SEC, toUnixS },
|
|
1011
|
+
paging: { limit: 1, direction: 'DESC' },
|
|
1012
|
+
v2Only: { type: 'TRADE_LARGE' },
|
|
1013
|
+
};
|
|
1014
|
+
const frames = await v2.sendSeriesOneShot(descriptor, { timeoutMs: STORED_UNIT_TIMEOUT_MS });
|
|
1015
|
+
return wrunStoredUnitDollarsOfRows(frames) ?? null;
|
|
1016
|
+
})()
|
|
1017
|
+
.then((perUnit) => {
|
|
1018
|
+
settledStoredUnits.set(key, perUnit);
|
|
1019
|
+
storedUnitsRetryAfter.delete(key);
|
|
1020
|
+
})
|
|
1021
|
+
.catch(() => {
|
|
1022
|
+
storedUnitsRetryAfter.set(key, Date.now() + DIRECTORY_RETRY_MS);
|
|
1023
|
+
})
|
|
1024
|
+
.finally(() => pendingStoredUnits.delete(key));
|
|
1025
|
+
pendingStoredUnits.set(key, read);
|
|
1026
|
+
}
|
|
1027
|
+
return read;
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* The US dollars one unit of `market`'s STORED trade amount is worth (the large-print table's `amount`, the unit a
|
|
1031
|
+
* 0.5.0 Big Trades Min size floored by: contracts of 0.0001 BTC on gate.io futures BTC_USDT, of 0.01 BTC on an OKX
|
|
1032
|
+
* swap, $100 contracts on Binance delivery BTCUSD_PERP, contracts on CME): the writer's own price of one, read off the
|
|
1033
|
+
* market's newest large print (`warmWrunMarketStoredUnit`), on a market whose dollar unit is proven (its quote
|
|
1034
|
+
* amounts are dollars). ONE rule for every venue, linear, inverse and CME alike, no venue list and no multiplier of
|
|
1035
|
+
* ours; a fact that cannot be proven is a named reason, `transient` while a read can still answer it. Synchronous over
|
|
1036
|
+
* `warmWrunMarketDollarFacts` and `warmWrunMarketStoredUnit`.
|
|
1037
|
+
*/
|
|
1038
|
+
export function wrunMarketStoredUnitDollars(market) {
|
|
1039
|
+
const unit = wrunMarketDollarUnit(market);
|
|
1040
|
+
if (unit.kind === 'unproven')
|
|
1041
|
+
return unit;
|
|
1042
|
+
const parts = marketKeyParts(market);
|
|
1043
|
+
const key = parts === undefined ? undefined : directoryKey(parts.venue, parts.symbol);
|
|
1044
|
+
if (key === undefined || !settledStoredUnits.has(key))
|
|
1045
|
+
return { kind: 'unproven', reason: 'rows', transient: true };
|
|
1046
|
+
const perUnit = settledStoredUnits.get(key);
|
|
1047
|
+
return perUnit === null || perUnit === undefined
|
|
1048
|
+
? { kind: 'unproven', reason: 'rows', transient: false }
|
|
1049
|
+
: { kind: 'dollars', perUnit };
|
|
725
1050
|
}
|
|
726
1051
|
/** Forget every kept answer (spec isolation). */
|
|
727
1052
|
export function clearWrunMarketFactsMemo() {
|
|
728
1053
|
settledRows.clear();
|
|
729
1054
|
pendingRows.clear();
|
|
730
1055
|
retryAfter.clear();
|
|
1056
|
+
settledUnits.clear();
|
|
1057
|
+
pendingUnits.clear();
|
|
1058
|
+
unitsRetryAfter.clear();
|
|
1059
|
+
settledStoredUnits.clear();
|
|
1060
|
+
pendingStoredUnits.clear();
|
|
1061
|
+
storedUnitsRetryAfter.clear();
|
|
731
1062
|
}
|
|
1063
|
+
// The live intake reads the dollar unit through its port (wrun-dollar-unit-port.leaf), so this module stays off the
|
|
1064
|
+
// pre-candle closure live-feed loads the intake in.
|
|
1065
|
+
bindWrunDollarUnitReader({ unit: wrunMarketDollarUnit, warm: warmWrunMarketDollarFacts });
|
|
@@ -10,24 +10,34 @@ export interface WrunRgba {
|
|
|
10
10
|
* renderer, heatmap, profile or levels declaration (C1, parseWrunStyleTarget). */
|
|
11
11
|
export declare const WRUN_STYLE_ROW_PREFIX = "__style__";
|
|
12
12
|
/** True for a Style page row key (never a sheet param, never sent to a host):
|
|
13
|
-
* an output property row or a viewer row (a HUD's
|
|
14
|
-
*
|
|
13
|
+
* an output property row or a viewer row (a HUD's rows, a heatmap's
|
|
14
|
+
* Sensitivity). */
|
|
15
15
|
export declare function isWrunStyleRowKey(key: string): boolean;
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
/** A HUD's viewer rows, `hud:<name>:<row>`: the Look pick (g3 addendum LK09),
|
|
17
|
+
* the place (the card moved by its title) and the dismissable HUD's collapsed
|
|
18
|
+
* and shown flags (C3), stored on the overlay beside the per-output style
|
|
19
|
+
* rows and never written into the sheet. The one list the key builder and
|
|
20
|
+
* every reader derive from: a row added here persists with the workspace row,
|
|
21
|
+
* rides a template and a twin conversion, and saves without a rerun. */
|
|
22
|
+
export declare const WRUN_HUD_VIEWER_ROWS: readonly ["look", "place", "collapsed", "shown"];
|
|
23
|
+
export type WrunHudViewerRow = (typeof WRUN_HUD_VIEWER_ROWS)[number];
|
|
19
24
|
export declare const WRUN_HUD_LOOK_ROW_PREFIX = "hud:";
|
|
20
|
-
export declare
|
|
25
|
+
export declare function wrunHudViewerRowKey(name: string, row: WrunHudViewerRow): string;
|
|
26
|
+
/** A HUD viewer row key read back: its HUD and its row; undefined for any other key. */
|
|
27
|
+
export declare function parseWrunHudViewerRowKey(key: string): {
|
|
28
|
+
name: string;
|
|
29
|
+
row: WrunHudViewerRow;
|
|
30
|
+
} | undefined;
|
|
21
31
|
export declare function isWrunHudLookRowKey(key: string): boolean;
|
|
22
32
|
export declare function isWrunHudPlaceRowKey(key: string): boolean;
|
|
23
|
-
/** A HUD's viewer rows (
|
|
33
|
+
/** A HUD's viewer rows (WRUN_HUD_VIEWER_ROWS): overlay settings that persist by key. */
|
|
24
34
|
export declare function isWrunHudViewerRowKey(key: string): boolean;
|
|
25
35
|
/** The viewer's Sensitivity for one heatmap (`heatmap:<name>:sensitivity`,
|
|
26
36
|
* wrunHeatmapSensitivityRowKey), stored on the overlay beside the HUD rows. */
|
|
27
37
|
export declare const WRUN_HEATMAP_SENSITIVITY_ROW_RE: RegExp;
|
|
28
38
|
export declare function isWrunHeatmapSensitivityRowKey(key: string): boolean;
|
|
29
|
-
/** Every viewer row of a browser-run Indicator (a HUD's
|
|
30
|
-
*
|
|
39
|
+
/** Every viewer row of a browser-run Indicator (a HUD's rows, a heatmap's
|
|
40
|
+
* Sensitivity, a child the reader hid on its own legend row):
|
|
31
41
|
* overlay settings that persist by key and are never a sheet param, an alert
|
|
32
42
|
* param or a host param. */
|
|
33
43
|
export declare function isWrunViewerRowKey(key: string): boolean;
|
|
@@ -13,27 +13,37 @@ import { isWrunChildHiddenRowKey } from './wrun-child-overlay-id.util.js';
|
|
|
13
13
|
* renderer, heatmap, profile or levels declaration (C1, parseWrunStyleTarget). */
|
|
14
14
|
export const WRUN_STYLE_ROW_PREFIX = '__style__';
|
|
15
15
|
/** True for a Style page row key (never a sheet param, never sent to a host):
|
|
16
|
-
* an output property row or a viewer row (a HUD's
|
|
17
|
-
*
|
|
16
|
+
* an output property row or a viewer row (a HUD's rows, a heatmap's
|
|
17
|
+
* Sensitivity). */
|
|
18
18
|
export function isWrunStyleRowKey(key) {
|
|
19
19
|
return key.startsWith(WRUN_STYLE_ROW_PREFIX) || isWrunViewerRowKey(key);
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
/** A HUD's viewer rows, `hud:<name>:<row>`: the Look pick (g3 addendum LK09),
|
|
22
|
+
* the place (the card moved by its title) and the dismissable HUD's collapsed
|
|
23
|
+
* and shown flags (C3), stored on the overlay beside the per-output style
|
|
24
|
+
* rows and never written into the sheet. The one list the key builder and
|
|
25
|
+
* every reader derive from: a row added here persists with the workspace row,
|
|
26
|
+
* rides a template and a twin conversion, and saves without a rerun. */
|
|
27
|
+
export const WRUN_HUD_VIEWER_ROWS = ['look', 'place', 'collapsed', 'shown'];
|
|
24
28
|
export const WRUN_HUD_LOOK_ROW_PREFIX = 'hud:';
|
|
25
|
-
|
|
29
|
+
const WRUN_HUD_VIEWER_ROW_RE = new RegExp(`^hud:(.+):(${WRUN_HUD_VIEWER_ROWS.join('|')})$`);
|
|
30
|
+
export function wrunHudViewerRowKey(name, row) {
|
|
31
|
+
return `${WRUN_HUD_LOOK_ROW_PREFIX}${name}:${row}`;
|
|
32
|
+
}
|
|
33
|
+
/** A HUD viewer row key read back: its HUD and its row; undefined for any other key. */
|
|
34
|
+
export function parseWrunHudViewerRowKey(key) {
|
|
35
|
+
const match = WRUN_HUD_VIEWER_ROW_RE.exec(key);
|
|
36
|
+
return match ? { name: match[1], row: match[2] } : undefined;
|
|
37
|
+
}
|
|
26
38
|
export function isWrunHudLookRowKey(key) {
|
|
27
|
-
return
|
|
39
|
+
return parseWrunHudViewerRowKey(key)?.row === 'look';
|
|
28
40
|
}
|
|
29
|
-
/** The viewer's own place for one HUD (`hud:<name>:place`, wrunHudPlaceRowKey). */
|
|
30
|
-
const WRUN_HUD_PLACE_ROW_RE = /^hud:(.+):place$/;
|
|
31
41
|
export function isWrunHudPlaceRowKey(key) {
|
|
32
|
-
return
|
|
42
|
+
return parseWrunHudViewerRowKey(key)?.row === 'place';
|
|
33
43
|
}
|
|
34
|
-
/** A HUD's viewer rows (
|
|
44
|
+
/** A HUD's viewer rows (WRUN_HUD_VIEWER_ROWS): overlay settings that persist by key. */
|
|
35
45
|
export function isWrunHudViewerRowKey(key) {
|
|
36
|
-
return
|
|
46
|
+
return WRUN_HUD_VIEWER_ROW_RE.test(key);
|
|
37
47
|
}
|
|
38
48
|
/** The viewer's Sensitivity for one heatmap (`heatmap:<name>:sensitivity`,
|
|
39
49
|
* wrunHeatmapSensitivityRowKey), stored on the overlay beside the HUD rows. */
|
|
@@ -41,8 +51,8 @@ export const WRUN_HEATMAP_SENSITIVITY_ROW_RE = /^heatmap:(.+):sensitivity$/;
|
|
|
41
51
|
export function isWrunHeatmapSensitivityRowKey(key) {
|
|
42
52
|
return WRUN_HEATMAP_SENSITIVITY_ROW_RE.test(key);
|
|
43
53
|
}
|
|
44
|
-
/** Every viewer row of a browser-run Indicator (a HUD's
|
|
45
|
-
*
|
|
54
|
+
/** Every viewer row of a browser-run Indicator (a HUD's rows, a heatmap's
|
|
55
|
+
* Sensitivity, a child the reader hid on its own legend row):
|
|
46
56
|
* overlay settings that persist by key and are never a sheet param, an alert
|
|
47
57
|
* param or a host param. */
|
|
48
58
|
export function isWrunViewerRowKey(key) {
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
import type { WrunIndicatorMetadata, WrunMetadataParam, WrunParamStyleBinding } from '../../interfaces/wrun-runtime.interface.js';
|
|
91
91
|
import { type WrunVisibilityPrefix, type WrunVisibilitySheet } from './wrun-visibility-table.js';
|
|
92
92
|
import { type WrunRgba } from './wrun-color-facts.util.js';
|
|
93
|
-
export { isWrunHeatmapSensitivityRowKey, isWrunHudLookRowKey, isWrunHudPlaceRowKey, isWrunHudViewerRowKey, isWrunStyleRowKey, isWrunViewerRowKey, packWrunColor, parseWrunColor, WRUN_HUD_LOOK_ROW_PREFIX, WRUN_STYLE_ROW_PREFIX, type WrunRgba, } from './wrun-color-facts.util.js';
|
|
93
|
+
export { isWrunHeatmapSensitivityRowKey, isWrunHudLookRowKey, isWrunHudPlaceRowKey, isWrunHudViewerRowKey, isWrunStyleRowKey, isWrunViewerRowKey, packWrunColor, parseWrunColor, parseWrunHudViewerRowKey, WRUN_HUD_LOOK_ROW_PREFIX, WRUN_HUD_VIEWER_ROWS, WRUN_STYLE_ROW_PREFIX, wrunHudViewerRowKey, type WrunHudViewerRow, type WrunRgba, } from './wrun-color-facts.util.js';
|
|
94
94
|
declare const WRUN_LINE_STYLES: readonly ["solid", "dashed", "dotted"];
|
|
95
95
|
export type WrunLineStyle = (typeof WRUN_LINE_STYLES)[number];
|
|
96
96
|
/** The frozen `param.source` field list (plan 1.7, the kit's
|
|
@@ -156,6 +156,7 @@ export declare function parseWrunStyleTarget(target: string): {
|
|
|
156
156
|
* `visible: false`): it mounts nothing, the stats-row rule. Absent or true
|
|
157
157
|
* draws. */
|
|
158
158
|
export declare function isWrunStyleTargetHidden(declaration: unknown): boolean;
|
|
159
|
+
/** A HUD's Look row (`hud:<name>:look`; every HUD viewer row's key and reader in wrun-color-facts.util). */
|
|
159
160
|
export declare function wrunHudLookRowKey(name: string): string;
|
|
160
161
|
/** A HUD Look row key read back: the HUD it belongs to. */
|
|
161
162
|
export declare function parseWrunHudLookRowKey(key: string): {
|
|
@@ -192,15 +193,25 @@ export declare function wrunHeatmapSensitivitySetting(settings: unknown, name: s
|
|
|
192
193
|
/** True when a save moves the Sensitivity any heatmap draws with (a value set,
|
|
193
194
|
* changed or cleared, read as wrunHeatmapSensitivitySetting reads it). */
|
|
194
195
|
export declare function wrunHeatmapSensitivityChanged(prev: unknown, next: unknown): boolean;
|
|
195
|
-
/** A save whose every change is a HUD's viewer row (its Look pick, its place
|
|
196
|
-
* card reads, so no run, canvas paint or legend row depends on them.
|
|
197
|
-
* sends; its keys are compared with the overlay's current settings (`current`). */
|
|
196
|
+
/** A save whose every change is a HUD's viewer row (its Look pick, its place, its collapsed or shown
|
|
197
|
+
* flag): rows only the FE-drawn card reads, so no run, canvas paint or legend row depends on them.
|
|
198
|
+
* `patch` is what the save sends; its keys are compared with the overlay's current settings (`current`). */
|
|
198
199
|
export declare function onlyWrunHudViewerRowsChanged(current: unknown, patch: unknown): boolean;
|
|
199
200
|
/** A stored place read back; anything malformed reads as "where the script puts it". */
|
|
200
201
|
export declare function parseWrunHudPlace(raw: unknown): WrunHudPlaceSetting | undefined;
|
|
201
202
|
export declare function formatWrunHudPlace(place: WrunHudPlaceSetting): string;
|
|
202
203
|
/** The viewer's place for one HUD under the overlay's settings, or undefined (the script's place). */
|
|
203
204
|
export declare function wrunHudPlaceSetting(settings: unknown, name: string): WrunHudPlaceSetting | undefined;
|
|
205
|
+
/** The dismissable HUD (C3): the viewer folds one card to its chip (`hud:<name>:collapsed`, true) or hides
|
|
206
|
+
* it (`hud:<name>:shown`, false; the Style page's Show row brings it back), viewer rows of the one list
|
|
207
|
+
* (WRUN_HUD_VIEWER_ROWS). Each holds a boolean; absent, null or anything else reads as unset: an expanded
|
|
208
|
+
* card that is shown. */
|
|
209
|
+
export declare function wrunHudCollapsedRowKey(name: string): string;
|
|
210
|
+
export declare function wrunHudShownRowKey(name: string): string;
|
|
211
|
+
/** The viewer's collapsed flag for one HUD under the overlay's settings: the stored boolean, or undefined (expanded). */
|
|
212
|
+
export declare function wrunHudCollapsedSetting(settings: unknown, name: string): boolean | undefined;
|
|
213
|
+
/** The viewer's shown flag for one HUD under the overlay's settings: the stored boolean, or undefined (shown). */
|
|
214
|
+
export declare function wrunHudShownSetting(settings: unknown, name: string): boolean | undefined;
|
|
204
215
|
/** A packed colour (the `color_packed_by` wire) as the engine's own
|
|
205
216
|
* `rgba(r, g, b, a)` spelling. A non-finite, negative, fractional or
|
|
206
217
|
* out-of-range value (alpha thousandths past 1000) decodes to no colour. */
|