wickchart 1.7.0 → 2.0.2

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/src/wick-feed.js CHANGED
@@ -19,7 +19,6 @@
19
19
  * streaming. Status is reflected in the `status` attribute and via
20
20
  * `wick-feed:status` events (loading / live / polling / fallback / loaded /
21
21
  * waiting / idle). `wick-feed:fallback` fires when a live source degrades.
22
- * (The 0.x event names `hab-feed:*` still fire as deprecated aliases.)
23
22
  * ========================================================================== */
24
23
 
25
24
  import './wick-chart.js';
@@ -41,6 +40,7 @@ import {
41
40
  normalizeTrades,
42
41
  } from './feeds.js';
43
42
 
43
+
44
44
  const LIVE_TICK_MS = 650;
45
45
 
46
46
  const HTMLElementBase = typeof HTMLElement !== 'undefined' ? HTMLElement : class {};
@@ -99,21 +99,19 @@ class WickFeed extends HTMLElementBase {
99
99
  this._fire('status', { status, ...detail });
100
100
  }
101
101
 
102
- /** Dispatch `wick-feed:name` plus the deprecated `hab-feed:name` alias. */
102
+ /** Dispatch `wick-feed:name`. */
103
103
  _fire(name, detail) {
104
104
  this.dispatchEvent(new CustomEvent('wick-feed:' + name, { detail }));
105
- this.dispatchEvent(new CustomEvent('hab-feed:' + name, { detail }));
106
105
  }
107
-
108
106
  /** Resolve the target chart (by `for` id, else the first chart element —
109
- * <wick-chart> or the deprecated <hab-chart>). */
107
+ * <wick-chart>). */
110
108
  _resolveChart() {
111
109
  const id = this.getAttribute('for');
112
110
  if (id) {
113
111
  const el = document.getElementById(id);
114
112
  return el && (el.tagName === 'WICK-CHART' || el.tagName === 'HAB-CHART') ? el : null;
115
113
  }
116
- return document.querySelector('wick-chart') || document.querySelector('hab-chart');
114
+ return document.querySelector('wick-chart');
117
115
  }
118
116
 
119
117
  _restart() {
@@ -459,12 +457,6 @@ if (typeof customElements !== 'undefined') {
459
457
  if (!customElements.get('wick-feed')) {
460
458
  customElements.define('wick-feed', WickFeed);
461
459
  }
462
- // 0.x alias: same element under its old tag name (deprecated, removed in 2.0)
463
- if (!customElements.get('hab-feed')) {
464
- /** @deprecated use <wick-feed> */
465
- class HabFeed extends WickFeed {}
466
- customElements.define('hab-feed', HabFeed);
467
- }
468
460
  }
469
461
 
470
462
  export default WickFeed;
package/types/core.d.ts CHANGED
@@ -199,6 +199,9 @@ export declare const DAY: number;
199
199
  * @returns {number} milliseconds
200
200
  */
201
201
  export declare const toMs: (t: number | Date) => number;
202
+ /** Warn once per distinct message (used by the 2.0 moved-method stubs in
203
+ * wick-chart.js — deleted with them in 3.0). */
204
+ export declare function warnDeprecatedAlias(message: any): void;
202
205
  /**
203
206
  * Milliseconds east of UTC in `zone` at the instant `at`.
204
207
  * 'utc' → 0
@@ -477,20 +480,6 @@ export declare function detectAnnotations(bars: Bar[], i0: number, i1: number, r
477
480
  i: number;
478
481
  note: string;
479
482
  }>;
480
- /**
481
- * Map a price to a sonification frequency over the visible scale.
482
- * Logarithmic scales map through log-space; result clamped to [lo, hi] Hz.
483
- * @param {number} price
484
- * @param {{min: number, max: number, useLog?: boolean}} scale
485
- * @param {number} [freqLo=180]
486
- * @param {number} [freqHi=880]
487
- * @returns {number} frequency in Hz
488
- */
489
- export declare function priceToFreq(price: number, scale: {
490
- min: number;
491
- max: number;
492
- useLog?: boolean;
493
- }, freqLo?: number, freqHi?: number): number;
494
483
  /**
495
484
  * Volume profile over a visible bar range: volume distributed into price
496
485
  * rows, with POC and the value area (greedy expansion around the POC).
@@ -826,7 +815,7 @@ export declare function evalScript(compiled: {
826
815
  /**
827
816
  * Build an indicator definition from a WickScript expression — used inline by
828
817
  * `indicators="expr:{…}"` / `pexpr:{…}"`, or register it under a name:
829
- * `HabChart.registerIndicator('myspread', scriptIndicator('close - ema(close,21)'))`.
818
+ * `WickChart.registerIndicator('myspread', scriptIndicator('close - ema(close,21)'))`.
830
819
  * @param {string} src
831
820
  * @param {{pane?: boolean}} [opts]
832
821
  * @returns {IndicatorDef}
@@ -987,24 +976,6 @@ export declare function normalizeOverlays(list: any): object[];
987
976
  * @returns {string} a concrete CSS color
988
977
  */
989
978
  export declare function resolveOverlayColor(raw: any, pal: object): string;
990
- /**
991
- * σ-cone projection from realized per-bar volatility: price bands widening
992
- * with √h (GBM-style, exp(±z·σ·√h)) over `horizon` future bars.
993
- * @param {number} lastClose anchor price (bar 0)
994
- * @param {number} volPerBar per-bar stddev of log returns (from calcRealizedVol)
995
- * @param {number} horizon future bars (clamped 1–500, default 48)
996
- * @param {number[]} [levels] σ multipliers, e.g. [1, 2] (each clamped to 0–5)
997
- * @returns {{horizon: number, levels: number[], bands: Record<string, {up: number[], down: number[]}>}}
998
- * bands[z].up/.down are arrays indexed by h = 0…horizon ([0] === lastClose)
999
- */
1000
- export declare function calcVolCone(lastClose: number, volPerBar: number, horizon: number, levels?: number[]): {
1001
- horizon: number;
1002
- levels: number[];
1003
- bands: Record<string, {
1004
- up: number[];
1005
- down: number[];
1006
- }>;
1007
- };
1008
979
  /**
1009
980
  * Validate a scenario spec: a ghost path of future prices (bars or API data)
1010
981
  * plus optional cone settings. Invalid entries are dropped, never thrown.
@@ -1061,34 +1032,6 @@ export declare function normalizeRiskPlan(spec: any): null | {
1061
1032
  maxK: number;
1062
1033
  label: string;
1063
1034
  };
1064
- /**
1065
- * Turn a bar window into an ordered story: the annotation events (pivot
1066
- * highs/lows, volume spikes, gaps, RSI divergences) plus derived **legs** —
1067
- * the move between consecutive opposite pivots ("+12.4% over 38 bars").
1068
- * The timeline drives the bar-walk player and any caption UI.
1069
- *
1070
- * @param {Bar[]} bars full dataset
1071
- * @param {number} i0 first index of the window
1072
- * @param {number} i1 last index of the window
1073
- * @param {{pivot?: number, volMult?: number, gapMult?: number, rsiPeriod?: number}} [opts]
1074
- * pivot window defaults to 8 (denser than the annotations overlay's 20)
1075
- * @returns {{i: number, time: number, type: string, side: string, note: string,
1076
- * legPct?: number, legBars?: number}[]} sorted by index, capped at 60
1077
- */
1078
- export declare function narrateWindow(bars: Bar[], i0: number, i1: number, opts?: {
1079
- pivot?: number;
1080
- volMult?: number;
1081
- gapMult?: number;
1082
- rsiPeriod?: number;
1083
- }): {
1084
- i: number;
1085
- time: number;
1086
- type: string;
1087
- side: string;
1088
- note: string;
1089
- legPct?: number;
1090
- legBars?: number;
1091
- }[];
1092
1035
  /**
1093
1036
  * Stats for a brushed bar range: net move (open of the first bar → close
1094
1037
  * of the last), extremes, and summed volume. Powers the brush-selection
@@ -1120,72 +1063,6 @@ export declare function brushStats(bars: Bar[], i0: number, i1: number): null |
1120
1063
  low: number;
1121
1064
  volume: number;
1122
1065
  };
1123
- /** Smoothest cheap easing for viewport pans: slow in, slow out. */
1124
- export declare function easeInOutCubic(t: any): number;
1125
- /**
1126
- * Validate one story scene. Every field is optional except that a scene
1127
- * must be an object; omitted fields simply don't change that aspect of
1128
- * the chart when played. `scenario`/`riskPlan` use a 'clear' sentinel for
1129
- * explicit "remove it" (null input means clear too when the KEY is present).
1130
- *
1131
- * { title: 'The breakout', note: 'What happened…',
1132
- * range: { from, to }, // times (s or ms) — the camera pans there
1133
- * indicators: 'sma:20 rsi:14', // optional indicator string
1134
- * type: 'candles', // optional series type
1135
- * overlays: [...], // optional zones/levels (normalizeOverlays)
1136
- * scenario: {...} | null, // set / clear a scenario
1137
- * riskPlan: {...} | null, // set / clear a risk plan
1138
- * dwell: 2200 } // ms to hold after the pan (500–30000)
1139
- *
1140
- * @returns {object|null} normalized scene, or null for non-objects
1141
- */
1142
- export declare function normalizeScene(scene: any): object | null;
1143
- /**
1144
- * Validate a whole story: normalize each scene, drop junk, cap at 20.
1145
- * @returns {object[]} possibly empty
1146
- */
1147
- export declare function sceneList(story: any): object[];
1148
- /**
1149
- * Tracks other charts viewing the same room: last-sighting timestamps per
1150
- * peer plus the viewport each one is looking at. Pure bookkeeping — the
1151
- * transport (BroadcastChannel, WebSocket, …) lives in the component/app.
1152
- *
1153
- * Peers expire `ttl` ms after their last sighting, so a closed tab fades
1154
- * out of the room without an explicit goodbye.
1155
- */
1156
- export declare class PresenceTracker {
1157
- ttl: number;
1158
- /** @type {Map<string, {id: string, name: string|null, range: {from:number,to:number}|null, at: number}>} */
1159
- peers: Map<string, {
1160
- id: string;
1161
- name: string | null;
1162
- range: {
1163
- from: number;
1164
- to: number;
1165
- } | null;
1166
- at: number;
1167
- }>;
1168
- /** @param {number} [ttl=12000] ms a peer survives without a sighting */
1169
- constructor(ttl?: number);
1170
- /**
1171
- * Record a sighting. `patch.range` ({from,to} times) is validated and
1172
- * normalized; a sighting without a range keeps the previous one.
1173
- * @returns {boolean} true when this sighting is a join (new peer)
1174
- */
1175
- track(id: any, patch?: {}, now?: number): boolean;
1176
- /** @returns {object|null} the removed peer entry, or null when unknown */
1177
- drop(id: any): object | null;
1178
- /** Expire peers not seen within the ttl.
1179
- * @returns {object[]} the peer entries that left */
1180
- sweep(now?: number): object[];
1181
- /** @returns {{id: string, name: string|null, range: object|null, at: number}[]} copies, oldest sighting first */
1182
- list(): {
1183
- id: string;
1184
- name: string | null;
1185
- range: object | null;
1186
- at: number;
1187
- }[];
1188
- }
1189
1066
  export declare const tfLabelOf: (dtMs: any) => string;
1190
1067
  /**
1191
1068
  * Compact, LLM-friendly summary of a bar window: structured fields plus a
@@ -1215,110 +1092,3 @@ export declare function encodeStateQuery(state: ChartState | null): string;
1215
1092
  * @returns {ChartState}
1216
1093
  */
1217
1094
  export declare function decodeStateQuery(str: string): ChartState;
1218
- /**
1219
- * Tool manifest for LLM/agent control of a chart. Tools map 1:1 onto the
1220
- * public element API; every op through applyChartOps is validated before it
1221
- * touches the chart (LLM output is untrusted input).
1222
- */
1223
- export declare const AI_TOOLS: ({
1224
- tool: string;
1225
- description: string;
1226
- args: {
1227
- indicators?: undefined;
1228
- overlays?: undefined;
1229
- from?: undefined;
1230
- to?: undefined;
1231
- type?: undefined;
1232
- enabled?: undefined;
1233
- low?: undefined;
1234
- high?: undefined;
1235
- };
1236
- } | {
1237
- tool: string;
1238
- description: string;
1239
- args: {
1240
- indicators: string;
1241
- overlays?: undefined;
1242
- from?: undefined;
1243
- to?: undefined;
1244
- type?: undefined;
1245
- enabled?: undefined;
1246
- low?: undefined;
1247
- high?: undefined;
1248
- };
1249
- } | {
1250
- tool: string;
1251
- description: string;
1252
- args: {
1253
- indicators?: undefined;
1254
- overlays: string;
1255
- from?: undefined;
1256
- to?: undefined;
1257
- type?: undefined;
1258
- enabled?: undefined;
1259
- low?: undefined;
1260
- high?: undefined;
1261
- };
1262
- } | {
1263
- tool: string;
1264
- description: string;
1265
- args: {
1266
- indicators?: undefined;
1267
- overlays?: undefined;
1268
- from: string;
1269
- to: string;
1270
- type?: undefined;
1271
- enabled?: undefined;
1272
- low?: undefined;
1273
- high?: undefined;
1274
- };
1275
- } | {
1276
- tool: string;
1277
- description: string;
1278
- args: {
1279
- indicators?: undefined;
1280
- overlays?: undefined;
1281
- from?: undefined;
1282
- to?: undefined;
1283
- type: string;
1284
- enabled?: undefined;
1285
- low?: undefined;
1286
- high?: undefined;
1287
- };
1288
- } | {
1289
- tool: string;
1290
- description: string;
1291
- args: {
1292
- indicators?: undefined;
1293
- overlays?: undefined;
1294
- from?: undefined;
1295
- to?: undefined;
1296
- type?: undefined;
1297
- enabled: string;
1298
- low: string;
1299
- high: string;
1300
- };
1301
- })[];
1302
- /**
1303
- * Compact system prompt for agent control: paste into any LLM alongside the
1304
- * tool manifest. The model answers with a JSON array of {tool, args} ops.
1305
- * @returns {string}
1306
- */
1307
- export declare function aiPromptText(): string;
1308
- /**
1309
- * Validate + apply a list of {tool, args} ops (typically LLM output) to a
1310
- * chart-like target. Ops are whitelisted and their args validated — an op
1311
- * never throws; it returns {ok: false, error} instead so the agent can
1312
- * self-correct. Target contract: getDataWindow(), setAttribute(k, v),
1313
- * setOverlays(list), clearOverlays(), addAlert(a), setVisibleRange(r),
1314
- * fit(), and (static) _registry() for indicator name checks.
1315
- * @param {object} target chart element (or test double)
1316
- * @param {any} ops
1317
- * @returns {Array<{ok: boolean, tool?: string, result?: any, error?: string}>}
1318
- */
1319
- export declare function applyChartOps(target: object, ops: any): Array<{
1320
- ok: boolean;
1321
- tool?: string;
1322
- result?: any;
1323
- error?: string;
1324
- }>;