@tony01/astroneum 0.4.1-beta.2 → 0.4.1-beta.25

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +281 -237
  2. package/LICENSE +21 -21
  3. package/README.md +250 -198
  4. package/dist/{Indicator-BBI3L_lx.d.ts → Indicator-BQQcVGGT.d.ts} +51 -227
  5. package/dist/astroneum.css +1 -1
  6. package/dist/chunk-47YGQEL5.js +399 -0
  7. package/dist/chunk-67XM5LOK.js +2 -0
  8. package/dist/{chunk-2YYGUSVX.js → chunk-DFJMDDL5.js} +1 -1
  9. package/dist/chunk-EFAS6F4C.js +59 -0
  10. package/dist/chunk-EHZN52CY.js +2 -0
  11. package/dist/chunk-HKLWNPMP.js +35 -0
  12. package/dist/chunk-ONPPQW65.js +2 -0
  13. package/dist/chunk-SCTHEM27.js +3 -0
  14. package/dist/chunk-UQXYMB6X.js +2 -0
  15. package/dist/chunk-WSIR5T2M.js +3 -0
  16. package/dist/entries/alerts.d.ts +36 -10
  17. package/dist/entries/alerts.js +1 -1
  18. package/dist/entries/datafeeds/crypto.d.ts +5 -1
  19. package/dist/entries/datafeeds/crypto.js +1 -1
  20. package/dist/entries/datafeeds/polygon.d.ts +3 -1
  21. package/dist/entries/datafeeds/polygon.js +1 -1
  22. package/dist/entries/headless.d.ts +78 -0
  23. package/dist/entries/headless.js +2 -0
  24. package/dist/entries/multichart.d.ts +12 -1
  25. package/dist/entries/multichart.js +1 -1
  26. package/dist/entries/replay.d.ts +3 -1
  27. package/dist/entries/script.d.ts +2 -68
  28. package/dist/entries/script.js +1 -1
  29. package/dist/entries/watchlist.d.ts +32 -2
  30. package/dist/entries/watchlist.js +1 -1
  31. package/dist/entries/workspace.d.ts +61 -0
  32. package/dist/entries/workspace.js +2 -0
  33. package/dist/index-BiXdqLA4.d.ts +45 -0
  34. package/dist/index-_JgHTy8X.d.ts +19 -0
  35. package/dist/index.d.ts +188 -27
  36. package/dist/index.js +1 -1
  37. package/dist/script-BU9StbN-.d.ts +120 -0
  38. package/dist/types-W6SIYQ9m.d.ts +232 -0
  39. package/dist/types-yETgeYsE.d.ts +28 -0
  40. package/dist/zh-CN-NDTUDZGZ.js +3 -0
  41. package/package.json +157 -147
  42. package/dist/chunk-4YOLQ5DC.js +0 -2
  43. package/dist/chunk-I4YQBP2M.js +0 -3
  44. package/dist/chunk-OOMZRONH.js +0 -35
  45. package/dist/chunk-PV2GAINM.js +0 -2
  46. package/dist/chunk-YW3STIPY.js +0 -653
  47. package/dist/zh-CN-Y2C6RSOI.js +0 -3
  48. package/docs/STRUCTURE.md +0 -231
  49. package/docs/TODO-DESIGN.md +0 -261
  50. package/docs/TODO.md +0 -222
  51. package/docs/api.md +0 -528
  52. package/docs/datafeed-guide.md +0 -311
  53. package/docs/design-astroneum.md +0 -479
  54. package/docs/plugin-development.md +0 -565
  55. package/docs/tv-functions-skill.md +0 -706
@@ -1,5 +1,3 @@
1
- import react__default from 'react';
2
-
3
1
  type Nullable<T> = T | null;
4
2
 
5
3
  interface NeighborData<D> {
@@ -7,9 +5,9 @@ interface NeighborData<D> {
7
5
  current: D;
8
6
  next: D;
9
7
  }
10
- type Timestamp$1 = number;
8
+ type Timestamp = number;
11
9
  interface CandleData {
12
- timestamp: Timestamp$1;
10
+ timestamp: Timestamp;
13
11
  open: number;
14
12
  high: number;
15
13
  low: number;
@@ -309,21 +307,6 @@ interface Styles {
309
307
  overlay: OverlayStyle;
310
308
  }
311
309
 
312
- type Price = number & {
313
- readonly _brand: 'Price';
314
- };
315
- type Volume = number & {
316
- readonly _brand: 'Volume';
317
- };
318
- type Timestamp = number & {
319
- readonly _brand: 'Timestamp';
320
- };
321
- interface IndicatorDef {
322
- name: string;
323
- calcParams?: number[];
324
- }
325
- /** Canonical timespan identifiers — aligned with engine PeriodType */
326
- type Timespan = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
327
310
  interface SymbolInfo {
328
311
  ticker: string;
329
312
  name?: string;
@@ -337,217 +320,13 @@ interface SymbolInfo {
337
320
  logo?: string;
338
321
  [key: string]: unknown;
339
322
  }
323
+
324
+ type PeriodType = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
340
325
  interface Period {
341
326
  multiplier: number;
342
- /** Canonical timespan — maps directly to engine PeriodType */
343
- timespan: Timespan;
327
+ timespan: PeriodType;
344
328
  text: string;
345
329
  }
346
- type DatafeedSubscribeCallback = (data: CandleData) => void;
347
- interface Datafeed {
348
- searchSymbols(search?: string): Promise<SymbolInfo[]>;
349
- getHistoryData(symbol: SymbolInfo, period: Period, from: number, to: number): Promise<CandleData[]>;
350
- subscribe(symbol: SymbolInfo, period: Period, callback: DatafeedSubscribeCallback): void;
351
- unsubscribe(symbol: SymbolInfo, period: Period): void;
352
- }
353
- interface AstroneumOptions {
354
- styles?: DeepPartial<Styles>;
355
- watermark?: string | Node;
356
- theme?: string;
357
- locale?: string;
358
- drawingBarVisible?: boolean;
359
- symbol: SymbolInfo;
360
- period: Period;
361
- periods?: Period[];
362
- timezone?: string;
363
- mainIndicators?: IndicatorDef[];
364
- subIndicators?: string[];
365
- plugins?: ChartPlugin[];
366
- datafeed: Datafeed;
367
- /** Inline styles applied to the root `.astroneum` container element. */
368
- style?: react__default.CSSProperties;
369
- /** Additional class names applied to the root `.astroneum` container element. */
370
- className?: string;
371
- /**
372
- * Make the chart canvas focusable + emit an `aria-live` summary of the
373
- * crosshair OHLCV. Off by default to avoid surprising existing apps.
374
- * When `true`, the chart container gets `tabindex=0`, `role="img"`,
375
- * and an `aria-label` describing the current symbol. Cursor moves
376
- * announce OHLCV through a visually-hidden polite live region.
377
- */
378
- accessible?: boolean;
379
- /**
380
- * Optional ARIA label override for the chart canvas. Only used when
381
- * `accessible` is true. Defaults to a string built from the symbol
382
- * ticker and current period.
383
- */
384
- ariaLabel?: string;
385
- /**
386
- * Bar rendering style. Defaults to 'candle' (standard candlesticks).
387
- * 'heikin_ashi' transforms OHLC data with the Heikin-Ashi formula
388
- * before rendering — no datafeed changes required.
389
- */
390
- barStyle?: 'candle' | 'heikin_ashi';
391
- /**
392
- * Price axis scale mode. Defaults to 'linear' (absolute price).
393
- * 'log' uses logarithmic scale (useful for long-term charts).
394
- * 'percent' shows percentage change from the first visible bar.
395
- */
396
- priceScale?: 'linear' | 'log' | 'percent';
397
- initialHistory?: 'all' | 'none';
398
- }
399
- /**
400
- * Serialised chart state — drawings, indicators, and the user-facing
401
- * surface settings (theme, locale, timezone, symbol, period, styles).
402
- *
403
- * The shape is intentionally simple JSON so it can be persisted to
404
- * `localStorage`, a URL, or a backend. The `version` field lets the
405
- * library evolve the format without breaking older payloads.
406
- */
407
- interface SerializedChartState {
408
- version: 1;
409
- theme: string;
410
- locale: string;
411
- timezone: string;
412
- symbol: SymbolInfo;
413
- period: Period;
414
- styles: DeepPartial<Styles>;
415
- mainIndicators: IndicatorDef[];
416
- subIndicators: string[];
417
- overlays: Array<{
418
- name: string;
419
- points?: ReadonlyArray<{
420
- timestamp?: number;
421
- value?: number;
422
- dataIndex?: number;
423
- }>;
424
- styles?: unknown;
425
- lock?: boolean;
426
- visible?: boolean;
427
- }>;
428
- }
429
- interface AstroneumHandle {
430
- setTheme(theme: string): void;
431
- getTheme(): string;
432
- setStyles(styles: DeepPartial<Styles>): void;
433
- getStyles(): Styles;
434
- setLocale(locale: string): void;
435
- getLocale(): string;
436
- setTimezone(timezone: string): void;
437
- getTimezone(): string;
438
- setSymbol(symbol: SymbolInfo): void;
439
- getSymbol(): SymbolInfo;
440
- setPeriod(period: Period): void;
441
- getPeriod(): Period;
442
- getDataListLength(): number;
443
- getLastDataTimestamp(): number | null;
444
- /**
445
- * Capture the chart's current user-visible state as a JSON-safe object.
446
- * Includes theme, locale, timezone, symbol, period, styles, indicators,
447
- * and drawing overlays. Pair with `loadState()` to restore.
448
- */
449
- serializeState(): SerializedChartState;
450
- /**
451
- * Restore a previously-captured state. Best-effort: missing or unknown
452
- * indicator / overlay names are silently skipped, matching the engine's
453
- * behaviour for unregistered names.
454
- */
455
- loadState(state: SerializedChartState): void;
456
- /**
457
- * Subscribe to crosshair moves. Returns an unsubscribe function.
458
- * Callback receives the crosshair data (or null when it leaves the chart).
459
- * Returns a Coordinate-like object with the timestamp + price at cursor.
460
- */
461
- onCrosshairMove(callback: (data: unknown) => void): () => void;
462
- /**
463
- * Programmatically set the crosshair position on this chart.
464
- * Used internally by MultiChartLayout for crosshair sync.
465
- */
466
- setCrosshair(data: unknown): void;
467
- /** Lock or unlock ALL drawing overlays at once. */
468
- lockAllDrawings(locked: boolean): void;
469
- createIndicator(value: string | IndicatorCreate, isStack?: boolean, paneOptions?: PaneOptions): Nullable<string>;
470
- removeIndicator(filter?: IndicatorFilter): boolean;
471
- createOverlay(value: string | OverlayCreate | Array<string | OverlayCreate>): Nullable<string> | Array<Nullable<string>>;
472
- removeOverlay(filter?: OverlayFilter): boolean;
473
- getDataList(): CandleData[];
474
- resetData(): void;
475
- resize(): void;
476
- }
477
- interface Viewport {
478
- /** Minimum (bottom) visible price in canvas coordinates. */
479
- priceMin: Price;
480
- /** Maximum (top) visible price in canvas coordinates. */
481
- priceMax: Price;
482
- /** Earliest visible candle timestamp (ms). */
483
- timeMin: Timestamp;
484
- /** Latest visible candle timestamp (ms). */
485
- timeMax: Timestamp;
486
- /** Physical canvas resolution [width, height] in device pixels. */
487
- resolution: readonly [width: number, height: number];
488
- }
489
- interface IndicatorPlugin<TOutput> {
490
- /** Unique registry name — used as the indicator identifier in the engine. */
491
- name: string;
492
- /** Short display name shown in the chart legend. */
493
- shortName?: string;
494
- /** Default calculation parameters (can be overridden by the user). */
495
- calcParams?: number[];
496
- /**
497
- * Pure calculation function. Must NOT mutate `data`.
498
- * Called on every data update; keep it fast (O(n) or better).
499
- */
500
- calc(data: CandleData[], params: number[]): TOutput[];
501
- /** Canvas 2D renderer — for lightweight overlays and small datasets. */
502
- render2D?(ctx: CanvasRenderingContext2D, output: TOutput[], viewport: Viewport): void;
503
- /**
504
- * WebGL2 renderer — for high-density or GPU-accelerated rendering.
505
- * Astroneum reuses a stable per-indicator vbo and falls back to render2D when WebGL2 is unavailable.
506
- */
507
- renderGL?(gl: WebGL2RenderingContext, output: TOutput[], viewport: Viewport, vbo: WebGLBuffer): void;
508
- }
509
- interface ChartPluginContext {
510
- /** The chart instance mounted by Astroneum. */
511
- chart: Chart;
512
- /** Register a typed indicator plugin at runtime. */
513
- registerIndicatorPlugin: (plugin: IndicatorPlugin<unknown>) => void;
514
- /** Batch register typed indicator plugins at runtime. */
515
- registerIndicatorPlugins: (plugins: ReadonlyArray<IndicatorPlugin<unknown>>) => void;
516
- }
517
- interface ChartPlugin {
518
- /** Optional plugin label for diagnostics and debugging. */
519
- name?: string;
520
- /** Indicator plugins to register before this chart starts creating indicators. */
521
- indicators?: ReadonlyArray<IndicatorPlugin<unknown>>;
522
- /** Optional lifecycle hook called once after the chart is initialized. */
523
- onInit?: (context: ChartPluginContext) => void | (() => void);
524
- }
525
- interface ChartEventMap {
526
- /** Fired when the active symbol changes. */
527
- 'symbol-change': SymbolInfo;
528
- /** Fired when the active period / timeframe changes. */
529
- 'period-change': Period;
530
- /** Fired on every crosshair move; null when the crosshair leaves the chart. */
531
- 'crosshair-move': Coordinate | null;
532
- /** Fired when the user zooms the chart. */
533
- 'zoom': {
534
- scale: number;
535
- anchor: ZoomAnchor;
536
- };
537
- /** Fired when a historical data batch is loaded. */
538
- 'data-load': {
539
- type: 'init' | 'forward' | 'backward';
540
- count: number;
541
- };
542
- /** Fired when a real-time tick arrives from the datafeed subscription. */
543
- 'tick': CandleData;
544
- /** Fired when the user starts drawing an overlay (value = overlay type name). */
545
- 'drawing-start': string;
546
- /** Fired when the user finishes drawing (value = overlay id). */
547
- 'drawing-end': string;
548
- /** Fired when the active theme changes (value = theme name). */
549
- 'theme-change': string;
550
- }
551
330
 
552
331
  type DataLoadType = 'init' | 'forward' | 'backward' | 'update';
553
332
  type DataLoadMore = boolean | {
@@ -676,6 +455,30 @@ interface Formatter {
676
455
  formatBigNumber: FormatBigNumber;
677
456
  formatExtendText: FormatExtendText;
678
457
  }
458
+ interface Locales {
459
+ time: string;
460
+ open: string;
461
+ high: string;
462
+ low: string;
463
+ close: string;
464
+ volume: string;
465
+ change: string;
466
+ turnover: string;
467
+ second: string;
468
+ minute: string;
469
+ hour: string;
470
+ day: string;
471
+ week: string;
472
+ month: string;
473
+ year: string;
474
+ [key: string]: string;
475
+ }
476
+ type LayoutChildType = 'candle' | 'indicator' | 'xAxis';
477
+ interface LayoutChild {
478
+ type: LayoutChildType;
479
+ content?: Array<string | IndicatorCreate>;
480
+ options?: PaneOptions;
481
+ }
679
482
  interface DecimalFold {
680
483
  threshold: number;
681
484
  format: (value: string | number) => string;
@@ -689,6 +492,16 @@ interface ZoomAnchor {
689
492
  main: ZoomAnchorType;
690
493
  xAxis: ZoomAnchorType;
691
494
  }
495
+ interface Options {
496
+ locale?: string;
497
+ timezone?: string;
498
+ styles?: string | DeepPartial<Styles>;
499
+ formatter?: Partial<Formatter>;
500
+ thousandsSeparator?: Partial<ThousandsSeparator>;
501
+ decimalFold?: Partial<DecimalFold>;
502
+ zoomAnchor?: ZoomAnchorType | Partial<ZoomAnchor>;
503
+ layout?: LayoutChild[];
504
+ }
692
505
 
693
506
  interface YAxisTemplate extends AxisTemplate {
694
507
  /**
@@ -876,6 +689,8 @@ interface Store {
876
689
  setPeriod: (period: Period) => void;
877
690
  getPeriod: () => Nullable<Period>;
878
691
  getDataList: () => CandleData[];
692
+ replaceBars: (data: readonly CandleData[]) => void;
693
+ updateBar: (data: CandleData) => void;
879
694
  setOffsetRightDistance: (distance: number) => void;
880
695
  getOffsetRightDistance: () => number;
881
696
  setMaxOffsetLeftDistance: (distance: number) => void;
@@ -885,6 +700,7 @@ interface Store {
885
700
  setBarSpace: (space: number) => void;
886
701
  getBarSpace: () => BarSpace;
887
702
  getVisibleRange: () => VisibleRange;
703
+ setViewportState: (barSpace: number, rightOffsetBarCount: number) => void;
888
704
  setDataLoader: (dataLoader: DataLoader) => void;
889
705
  overrideIndicator: (override: IndicatorCreate) => boolean;
890
706
  removeIndicator: (filter?: IndicatorFilter) => boolean;
@@ -904,14 +720,22 @@ interface ConvertFilter {
904
720
  paneId?: string;
905
721
  absolute?: boolean;
906
722
  }
723
+ interface ChartViewportState {
724
+ readonly version: 1;
725
+ readonly barSpace: number;
726
+ readonly rightOffsetBarCount: number;
727
+ }
907
728
  interface Chart extends Store {
908
729
  id: string;
730
+ getBars: () => readonly CandleData[];
909
731
  getDom: (paneId?: string, position?: DomPosition) => Nullable<HTMLElement>;
910
732
  getSize: (paneId?: string, position?: DomPosition) => Nullable<Bounding>;
911
733
  createIndicator: (value: string | IndicatorCreate, isStack?: boolean, paneOptions?: PaneOptions) => Nullable<string>;
912
734
  getIndicators: (filter?: IndicatorFilter) => Indicator[];
913
735
  createOverlay: (value: string | OverlayCreate | Array<string | OverlayCreate>) => Nullable<string> | Array<Nullable<string>>;
914
736
  getOverlays: (filter?: OverlayFilter) => Overlay[];
737
+ getViewportState: () => ChartViewportState;
738
+ setViewportState: (state: ChartViewportState) => void;
915
739
  setPaneOptions: (options: PaneOptions) => void;
916
740
  getPaneOptions: (id?: string) => Nullable<PaneOptions> | PaneOptions[];
917
741
  scrollByDistance: (distance: number, animationDuration?: number) => void;
@@ -1178,4 +1002,4 @@ type IndicatorTemplate<D = unknown, C = unknown, E = unknown> = ExcludePickParti
1178
1002
  type IndicatorCreate<D = unknown, C = unknown, E = unknown> = ExcludePickPartial<Omit<Indicator<D, C, E>, 'result'>, 'name'>;
1179
1003
  type IndicatorFilter = Partial<Pick<Indicator, 'id' | 'paneId' | 'name'>>;
1180
1004
 
1181
- export type { AstroneumOptions as A, CandleData as C, Datafeed as D, IndicatorTemplate as I, Nullable as N, OverlayTemplate as O, Price as P, SerializedChartState as S, Timestamp as T, Volume as V, XAxisTemplate as X, YAxisTemplate as Y, AstroneumHandle as a, IndicatorPlugin as b, Chart as c, Period as d, SymbolInfo as e, ChartEventMap as f, ChartPlugin as g, ChartPluginContext as h, DatafeedSubscribeCallback as i, Viewport as j };
1005
+ export type { ActionType as A, Bounding as B, Chart as C, DeepPartial as D, IndicatorCreate as I, Locales as L, Nullable as N, OverlayCreate as O, PaneOptions as P, Styles as S, XAxisTemplate as X, YAxisTemplate as Y, ZoomAnchor as Z, CandleData as a, IndicatorFilter as b, Indicator as c, OverlayFilter as d, Coordinate as e, IndicatorTemplate as f, OverlayTemplate as g, Options as h, ChartViewportState as i, Period as j, PeriodType as k, SymbolInfo as l };