@363045841yyt/klinechart 0.6.8 → 0.6.10

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 (58) hide show
  1. package/README.md +1 -0
  2. package/dist/index.cjs +5 -20
  3. package/dist/index.js +6046 -11120
  4. package/dist/klinechart.css +1 -1
  5. package/dist/schema-CzmPW09E.cjs +1 -0
  6. package/dist/schema-DBMGp6Af.js +437 -0
  7. package/dist/src/api/data/baostock.d.ts +4 -0
  8. package/dist/src/components/IndicatorSelector.vue.d.ts +0 -9
  9. package/dist/src/components/KLineChart.vue.d.ts +5 -5
  10. package/dist/src/components/LeftToolbar.vue.d.ts +3 -3
  11. package/dist/src/config/chartSettings.d.ts +15 -10
  12. package/dist/src/core/chart.d.ts +38 -5
  13. package/dist/src/core/controller/interaction.d.ts +2 -30
  14. package/dist/src/core/controller/markerInteraction.d.ts +28 -0
  15. package/dist/src/core/controller/pinchTracker.d.ts +18 -0
  16. package/dist/src/core/controller/tooltipPosition.d.ts +21 -0
  17. package/dist/src/core/indicators/atrState.d.ts +16 -0
  18. package/dist/src/core/indicators/calculators.d.ts +67 -0
  19. package/dist/src/core/indicators/demaState.d.ts +16 -0
  20. package/dist/src/core/indicators/donchianState.d.ts +23 -0
  21. package/dist/src/core/indicators/hmaState.d.ts +16 -0
  22. package/dist/src/core/indicators/indicatorRuntime.d.ts +20 -0
  23. package/dist/src/core/indicators/kamaState.d.ts +20 -0
  24. package/dist/src/core/indicators/keltnerState.d.ts +27 -0
  25. package/dist/src/core/indicators/sarState.d.ts +26 -0
  26. package/dist/src/core/indicators/scheduler.d.ts +55 -3
  27. package/dist/src/core/indicators/stateComposer.d.ts +30 -0
  28. package/dist/src/core/indicators/supertrendState.d.ts +22 -0
  29. package/dist/src/core/indicators/temaState.d.ts +16 -0
  30. package/dist/src/core/indicators/wmaState.d.ts +16 -0
  31. package/dist/src/core/indicators/workerProtocol.d.ts +111 -1
  32. package/dist/src/core/paneRenderer.d.ts +3 -1
  33. package/dist/src/core/renderers/Indicator/atr.d.ts +17 -0
  34. package/dist/src/core/renderers/Indicator/dema.d.ts +5 -0
  35. package/dist/src/core/renderers/Indicator/donchian.d.ts +5 -0
  36. package/dist/src/core/renderers/Indicator/hma.d.ts +5 -0
  37. package/dist/src/core/renderers/Indicator/index.d.ts +2 -1
  38. package/dist/src/core/renderers/Indicator/indicatorData.d.ts +13 -0
  39. package/dist/src/core/renderers/Indicator/kama.d.ts +5 -0
  40. package/dist/src/core/renderers/Indicator/keltner.d.ts +5 -0
  41. package/dist/src/core/renderers/Indicator/sar.d.ts +5 -0
  42. package/dist/src/core/renderers/Indicator/scale/atr_scale.d.ts +11 -0
  43. package/dist/src/core/renderers/Indicator/subPaneConfig.d.ts +9 -0
  44. package/dist/src/core/renderers/Indicator/supertrend.d.ts +5 -0
  45. package/dist/src/core/renderers/Indicator/tema.d.ts +5 -0
  46. package/dist/src/core/renderers/Indicator/wma.d.ts +5 -0
  47. package/dist/src/core/renderers/lastPrice.d.ts +5 -1
  48. package/dist/src/core/renderers/webgl/candleSurface.d.ts +19 -6
  49. package/dist/src/core/renderers/webgl/sharedWebGLSurface.d.ts +33 -0
  50. package/dist/src/core/subPaneManager.d.ts +22 -0
  51. package/dist/src/semantic/types.d.ts +36 -0
  52. package/dist/src/semantic/validator.d.ts +3 -2
  53. package/dist/src/test-setup.d.ts +6 -0
  54. package/dist/src/utils/http.d.ts +14 -0
  55. package/package.json +2 -3
  56. package/dist/favicon.ico +0 -0
  57. package/dist/mock-stock-data.json +0 -1
  58. /package/dist/src/api/data/{baostock.test.d.ts → baostock.integration.test.d.ts} +0 -0
@@ -10,6 +10,16 @@ import { WMSRRenderState } from './wmsrState';
10
10
  import { KSTRenderState } from './kstState';
11
11
  import { FASTKRenderState } from './fastkState';
12
12
  import { MACDRenderState } from './macdState';
13
+ import { ATRRenderState } from './atrState';
14
+ import { WMARenderState } from './wmaState';
15
+ import { DEMARenderState } from './demaState';
16
+ import { TEMARenderState } from './temaState';
17
+ import { HMARenderState } from './hmaState';
18
+ import { KAMARenderState } from './kamaState';
19
+ import { SARRenderState } from './sarState';
20
+ import { SuperTrendRenderState } from './supertrendState';
21
+ import { KeltnerRenderState } from './keltnerState';
22
+ import { DonchianRenderState } from './donchianState';
13
23
  import { IndicatorSeriesBundle } from './workerProtocol';
14
24
  /**
15
25
  * 可见范围
@@ -27,6 +37,16 @@ type VisibleSubIndicatorStates = {
27
37
  kst: KSTRenderState;
28
38
  fastk: FASTKRenderState;
29
39
  macd: MACDRenderState;
40
+ atr: ATRRenderState;
41
+ wma: WMARenderState;
42
+ dema: DEMARenderState;
43
+ tema: TEMARenderState;
44
+ hma: HMARenderState;
45
+ kama: KAMARenderState;
46
+ sar: SARRenderState;
47
+ supertrend: SuperTrendRenderState;
48
+ keltner: KeltnerRenderState;
49
+ donchian: DonchianRenderState;
30
50
  };
31
51
  type VisibleSubIndicatorMask = {
32
52
  rsi?: boolean;
@@ -37,6 +57,16 @@ type VisibleSubIndicatorMask = {
37
57
  kst?: boolean;
38
58
  fastk?: boolean;
39
59
  macd?: boolean;
60
+ atr?: boolean;
61
+ wma?: boolean;
62
+ dema?: boolean;
63
+ tema?: boolean;
64
+ hma?: boolean;
65
+ kama?: boolean;
66
+ sar?: boolean;
67
+ supertrend?: boolean;
68
+ keltner?: boolean;
69
+ donchian?: boolean;
40
70
  };
41
71
  type ComposedRenderStates = VisibleSubIndicatorStates & {
42
72
  ma: MARenderState;
@@ -0,0 +1,22 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface SuperTrendPoint {
3
+ value: number;
4
+ trend: 'up' | 'down';
5
+ }
6
+ export interface SuperTrendRenderState extends BaseIndicatorState {
7
+ timestamp: number;
8
+ series: (SuperTrendPoint | undefined)[];
9
+ params: {
10
+ atrPeriod: number;
11
+ multiplier: number;
12
+ showSuperTrend: boolean;
13
+ };
14
+ valueMin: number;
15
+ valueMax: number;
16
+ visibleMin: number;
17
+ visibleMax: number;
18
+ }
19
+ export declare const createSuperTrendStateKey: (paneId: string) => `indicator:${string}:${string}`;
20
+ export declare const DEFAULT_SUPERTREND_ATR_PERIOD = 10;
21
+ export declare const DEFAULT_SUPERTREND_MULTIPLIER = 3;
22
+ export declare const EMPTY_SUPERTREND_STATE: SuperTrendRenderState;
@@ -0,0 +1,16 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface TEMARenderState extends BaseIndicatorState {
3
+ timestamp: number;
4
+ series: (number | undefined)[];
5
+ params: {
6
+ period: number;
7
+ showTEMA: boolean;
8
+ };
9
+ valueMin: number;
10
+ valueMax: number;
11
+ visibleMin: number;
12
+ visibleMax: number;
13
+ }
14
+ export declare const createTEMAStateKey: (paneId: string) => `indicator:${string}:${string}`;
15
+ export declare const DEFAULT_TEMA_PERIOD = 20;
16
+ export declare const EMPTY_TEMA_STATE: TEMARenderState;
@@ -0,0 +1,16 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface WMARenderState extends BaseIndicatorState {
3
+ timestamp: number;
4
+ series: (number | undefined)[];
5
+ params: {
6
+ period: number;
7
+ showWMA: boolean;
8
+ };
9
+ valueMin: number;
10
+ valueMax: number;
11
+ visibleMin: number;
12
+ visibleMax: number;
13
+ }
14
+ export declare const createWMAStateKey: (paneId: string) => `indicator:${string}:${string}`;
15
+ export declare const DEFAULT_WMA_PERIOD = 9;
16
+ export declare const EMPTY_WMA_STATE: WMARenderState;
@@ -1,5 +1,5 @@
1
1
  import { KLineData } from '../../types/price';
2
- import { MAFlags, BOLLPoint, EXPMAPoint, ENEPoint, STOCHPoint, KSTPoint, MACDPoint } from './calculators';
2
+ import { MAFlags, BOLLPoint, EXPMAPoint, ENEPoint, STOCHPoint, KSTPoint, MACDPoint, SARPoint, SuperTrendPoint, KeltnerPoint, DonchianPoint } from './calculators';
3
3
  export interface BOLLSchedulerConfig {
4
4
  period: number;
5
5
  multiplier: number;
@@ -63,6 +63,56 @@ export interface MACDSchedulerConfig {
63
63
  showDEA: boolean;
64
64
  showBAR: boolean;
65
65
  }
66
+ export interface ATRSchedulerConfig {
67
+ period: number;
68
+ showATR: boolean;
69
+ }
70
+ export interface WMASchedulerConfig {
71
+ period: number;
72
+ showWMA: boolean;
73
+ }
74
+ export interface DEMASchedulerConfig {
75
+ period: number;
76
+ showDEMA: boolean;
77
+ }
78
+ export interface TEMASchedulerConfig {
79
+ period: number;
80
+ showTEMA: boolean;
81
+ }
82
+ export interface HMASchedulerConfig {
83
+ period: number;
84
+ showHMA: boolean;
85
+ }
86
+ export interface KAMASchedulerConfig {
87
+ period: number;
88
+ fastPeriod: number;
89
+ slowPeriod: number;
90
+ showKAMA: boolean;
91
+ }
92
+ export interface SARSchedulerConfig {
93
+ step: number;
94
+ maxStep: number;
95
+ showSAR: boolean;
96
+ }
97
+ export interface SuperTrendSchedulerConfig {
98
+ atrPeriod: number;
99
+ multiplier: number;
100
+ showSuperTrend: boolean;
101
+ }
102
+ export interface KeltnerSchedulerConfig {
103
+ emaPeriod: number;
104
+ atrPeriod: number;
105
+ multiplier: number;
106
+ showUpper: boolean;
107
+ showMiddle: boolean;
108
+ showLower: boolean;
109
+ }
110
+ export interface DonchianSchedulerConfig {
111
+ period: number;
112
+ showUpper: boolean;
113
+ showMiddle: boolean;
114
+ showLower: boolean;
115
+ }
66
116
  export interface InitRequest {
67
117
  type: 'init';
68
118
  protocolVersion: number;
@@ -123,6 +173,16 @@ export interface IndicatorConfigSnapshot {
123
173
  kst: KSTSchedulerConfig;
124
174
  fastk: FASTKSchedulerConfig;
125
175
  macd: MACDSchedulerConfig;
176
+ atr: ATRSchedulerConfig;
177
+ wma: WMASchedulerConfig;
178
+ dema: DEMASchedulerConfig;
179
+ tema: TEMASchedulerConfig;
180
+ hma: HMASchedulerConfig;
181
+ kama: KAMASchedulerConfig;
182
+ sar: SARSchedulerConfig;
183
+ supertrend: SuperTrendSchedulerConfig;
184
+ keltner: KeltnerSchedulerConfig;
185
+ donchian: DonchianSchedulerConfig;
126
186
  rsiPaneId: string;
127
187
  cciPaneId: string;
128
188
  stochPaneId: string;
@@ -131,6 +191,16 @@ export interface IndicatorConfigSnapshot {
131
191
  kstPaneId: string;
132
192
  fastkPaneId: string;
133
193
  macdPaneId: string;
194
+ atrPaneId: string;
195
+ wmaPaneId: string;
196
+ demaPaneId: string;
197
+ temaPaneId: string;
198
+ hmaPaneId: string;
199
+ kamaPaneId: string;
200
+ sarPaneId: string;
201
+ supertrendPaneId: string;
202
+ keltnerPaneId: string;
203
+ donchianPaneId: string;
134
204
  }
135
205
  export interface IndicatorSeriesBundle {
136
206
  ma: {
@@ -182,6 +252,46 @@ export interface IndicatorSeriesBundle {
182
252
  series: MACDPoint[];
183
253
  params: MACDSchedulerConfig;
184
254
  };
255
+ atr: {
256
+ series: (number | undefined)[];
257
+ params: ATRSchedulerConfig;
258
+ };
259
+ wma: {
260
+ series: (number | undefined)[];
261
+ params: WMASchedulerConfig;
262
+ };
263
+ dema: {
264
+ series: (number | undefined)[];
265
+ params: DEMASchedulerConfig;
266
+ };
267
+ tema: {
268
+ series: (number | undefined)[];
269
+ params: TEMASchedulerConfig;
270
+ };
271
+ hma: {
272
+ series: (number | undefined)[];
273
+ params: HMASchedulerConfig;
274
+ };
275
+ kama: {
276
+ series: (number | undefined)[];
277
+ params: KAMASchedulerConfig;
278
+ };
279
+ sar: {
280
+ series: (SARPoint | undefined)[];
281
+ params: SARSchedulerConfig;
282
+ };
283
+ supertrend: {
284
+ series: (SuperTrendPoint | undefined)[];
285
+ params: SuperTrendSchedulerConfig;
286
+ };
287
+ keltner: {
288
+ series: (KeltnerPoint | undefined)[];
289
+ params: KeltnerSchedulerConfig;
290
+ };
291
+ donchian: {
292
+ series: (DonchianPoint | undefined)[];
293
+ params: DonchianSchedulerConfig;
294
+ };
185
295
  /** 本次计算中实际变更的指标列表 */
186
296
  _changed: string[];
187
297
  }
@@ -1,4 +1,5 @@
1
1
  import { CandleWebGLSurface, LineWebGLSurface } from './renderers/webgl/candleSurface';
2
+ import { SharedWebGLSurface, WebGLRegion } from './renderers/webgl/sharedWebGLSurface';
2
3
  export type PaneRendererDom = {
3
4
  mainCanvas: HTMLCanvasElement;
4
5
  overlayCanvas: HTMLCanvasElement;
@@ -24,13 +25,14 @@ export declare class PaneRenderer {
24
25
  private opt;
25
26
  private contexts;
26
27
  private webgl;
27
- constructor(dom: PaneRendererDom, pane: import('./layout/pane').Pane, opt: PaneRendererOptions);
28
+ constructor(dom: PaneRendererDom, pane: import('./layout/pane').Pane, opt: PaneRendererOptions, sharedWebGLSurface: SharedWebGLSurface);
28
29
  /** 获取关联的 Pane 实例 */
29
30
  getPane(): import('./layout/pane').Pane;
30
31
  /** 获取 DOM 元素 */
31
32
  getDom(): PaneRendererDom;
32
33
  getContexts(): PaneRendererContexts;
33
34
  getWebGL(): PaneRendererWebGLHandles;
35
+ setWebGLRegion(region: WebGLRegion): void;
34
36
  /**
35
37
  * 调整 Canvas 尺寸
36
38
  * @param width pane 宽度(逻辑像素)
@@ -0,0 +1,17 @@
1
+ import { RendererPluginWithHost, PluginHost } from '../../../plugin';
2
+ export interface ATRRendererOptions {
3
+ paneId?: string;
4
+ }
5
+ export declare function createATRRendererPlugin(options?: ATRRendererOptions): RendererPluginWithHost;
6
+ /**
7
+ * 获取 ATR 标题信息(供 paneTitle 使用)
8
+ */
9
+ export declare function getATRTitleInfo(index: number, period: number, pluginHost: PluginHost, paneId?: string): {
10
+ name: string;
11
+ params: number[];
12
+ values: Array<{
13
+ label: string;
14
+ value: number;
15
+ color: string;
16
+ }>;
17
+ } | null;
@@ -0,0 +1,5 @@
1
+ import { RendererPluginWithHost } from '../../../plugin';
2
+ export interface DEMARendererOptions {
3
+ paneId?: string;
4
+ }
5
+ export declare function createDEMARendererPlugin(options?: DEMARendererOptions): RendererPluginWithHost;
@@ -0,0 +1,5 @@
1
+ import { RendererPluginWithHost } from '../../../plugin';
2
+ export interface DonchianRendererOptions {
3
+ paneId?: string;
4
+ }
5
+ export declare function createDonchianRendererPlugin(options?: DonchianRendererOptions): RendererPluginWithHost;
@@ -0,0 +1,5 @@
1
+ import { RendererPluginWithHost } from '../../../plugin';
2
+ export interface HMARendererOptions {
3
+ paneId?: string;
4
+ }
5
+ export declare function createHMARendererPlugin(options?: HMARendererOptions): RendererPluginWithHost;
@@ -13,10 +13,11 @@ export { createMOMRendererPlugin, type MOMRendererOptions, getMOMTitleInfo } fro
13
13
  export { createWMSRRendererPlugin, type WMSRRendererOptions, getWMSRTitleInfo } from './wmsr';
14
14
  export { createKSTRendererPlugin, type KSTRendererOptions, getKSTTitleInfo } from './kst';
15
15
  export { createFASTKRendererPlugin, type FASTKRendererOptions, getFASTKTitleInfo } from './fastk';
16
+ export { createATRRendererPlugin, type ATRRendererOptions, getATRTitleInfo } from './atr';
16
17
  /**
17
18
  * 副图指标类型
18
19
  */
19
- export type SubIndicatorType = 'VOLUME' | 'MACD' | 'RSI' | 'CCI' | 'STOCH' | 'MOM' | 'WMSR' | 'KST' | 'FASTK';
20
+ export type SubIndicatorType = 'VOLUME' | 'MACD' | 'RSI' | 'CCI' | 'STOCH' | 'MOM' | 'WMSR' | 'KST' | 'FASTK' | 'ATR';
20
21
  /**
21
22
  * 渲染器工厂选项
22
23
  */
@@ -0,0 +1,13 @@
1
+ import { ParamConfig } from '../../../components/IndicatorParams.vue';
2
+ export interface Indicator {
3
+ id: string;
4
+ label: string;
5
+ name: string;
6
+ pane: 'main' | 'sub';
7
+ description?: string;
8
+ params?: ParamConfig[];
9
+ }
10
+ export declare const mainIndicators: Indicator[];
11
+ export declare const subIndicators: Indicator[];
12
+ export declare function findIndicator(id: string): Indicator | undefined;
13
+ export declare function isSubIndicatorId(id: string): boolean;
@@ -0,0 +1,5 @@
1
+ import { RendererPluginWithHost } from '../../../plugin';
2
+ export interface KAMARendererOptions {
3
+ paneId?: string;
4
+ }
5
+ export declare function createKAMARendererPlugin(options?: KAMARendererOptions): RendererPluginWithHost;
@@ -0,0 +1,5 @@
1
+ import { RendererPluginWithHost } from '../../../plugin';
2
+ export interface KeltnerRendererOptions {
3
+ paneId?: string;
4
+ }
5
+ export declare function createKeltnerRendererPlugin(options?: KeltnerRendererOptions): RendererPluginWithHost;
@@ -0,0 +1,5 @@
1
+ import { RendererPluginWithHost } from '../../../plugin';
2
+ export interface SARRendererOptions {
3
+ paneId?: string;
4
+ }
5
+ export declare function createSARRendererPlugin(options?: SARRendererOptions): RendererPluginWithHost;
@@ -0,0 +1,11 @@
1
+ import { RendererPluginWithHost } from '../../../../plugin';
2
+ export declare function createAtrScaleRendererPlugin(options: {
3
+ axisWidth: number;
4
+ paneId: string;
5
+ yPaddingPx?: number;
6
+ getCrosshair?: () => {
7
+ y: number;
8
+ price: number;
9
+ activePaneId: string | null;
10
+ } | null;
11
+ }): RendererPluginWithHost;
@@ -0,0 +1,9 @@
1
+ import { TitleInfo } from '../paneTitle';
2
+ import { PluginHost } from '../../../plugin';
3
+ import { SubIndicatorType } from '.';
4
+ export interface SubPaneIndicatorConfig {
5
+ defaultParams: Record<string, number | boolean>;
6
+ getTitleInfo: (data: any[], index: number | null, params: Record<string, number | boolean>, pluginHost: PluginHost, paneId: string) => TitleInfo | null;
7
+ }
8
+ export declare const SUB_PANE_INDICATOR_CONFIGS: Record<SubIndicatorType, SubPaneIndicatorConfig>;
9
+ export declare const SUB_PANE_INDICATORS: SubIndicatorType[];
@@ -0,0 +1,5 @@
1
+ import { RendererPluginWithHost } from '../../../plugin';
2
+ export interface SuperTrendRendererOptions {
3
+ paneId?: string;
4
+ }
5
+ export declare function createSuperTrendRendererPlugin(options?: SuperTrendRendererOptions): RendererPluginWithHost;
@@ -0,0 +1,5 @@
1
+ import { RendererPluginWithHost } from '../../../plugin';
2
+ export interface TEMARendererOptions {
3
+ paneId?: string;
4
+ }
5
+ export declare function createTEMARendererPlugin(options?: TEMARendererOptions): RendererPluginWithHost;
@@ -0,0 +1,5 @@
1
+ import { RendererPluginWithHost } from '../../../plugin';
2
+ export interface WMARendererOptions {
3
+ paneId?: string;
4
+ }
5
+ export declare function createWMARendererPlugin(options?: WMARendererOptions): RendererPluginWithHost;
@@ -1,5 +1,9 @@
1
1
  import { RendererPlugin } from '../../plugin';
2
2
  /**
3
- * 创建最新价虚线渲染器插件
3
+ * 最新价 label 注册渲染器(overlay 层,确保悬停时 label 也注册到 yAxisLabels)
4
+ */
5
+ export declare function createLastPriceLabelRegistrarPlugin(): RendererPlugin;
6
+ /**
7
+ * 创建最新价虚线渲染器插件(绘制虚线)
4
8
  */
5
9
  export declare function createLastPriceLineRendererPlugin(): RendererPlugin;
@@ -1,3 +1,4 @@
1
+ import { SharedWebGLSurface, WebGLCompositeOptions, WebGLRegion } from './sharedWebGLSurface';
1
2
  type Rect = {
2
3
  x: number;
3
4
  y: number;
@@ -25,24 +26,29 @@ type FilledBand = {
25
26
  }>;
26
27
  };
27
28
  export declare class CandleWebGLSurface {
28
- private canvas;
29
+ private shared;
29
30
  private handles;
30
31
  private logicalWidth;
31
32
  private logicalHeight;
32
33
  private available;
33
34
  private rectCapacity;
34
35
  private rectScratch;
35
- constructor(canvas?: HTMLCanvasElement);
36
+ private region;
37
+ constructor(shared: SharedWebGLSurface);
36
38
  isAvailable(): boolean;
37
39
  getCanvas(): HTMLCanvasElement;
38
- resize(width: number, height: number, dpr: number): void;
40
+ setRegion(region: WebGLRegion): void;
41
+ resize(width: number, height: number, _dpr: number): void;
39
42
  clear(): void;
43
+ compositeTo(ctx: CanvasRenderingContext2D, options?: WebGLCompositeOptions): void;
44
+ /** 直接传入已打包的 Float32Array:每 4 个元素为一组 (x, y, width, height) */
45
+ drawRectBuffer(rectData: Float32Array, rectCount: number, color: string, scrollLeft: number): boolean;
40
46
  drawRects(rects: Rect[], color: string, scrollLeft: number): boolean;
41
47
  destroy(): void;
42
48
  private initRectHandles;
43
49
  }
44
50
  export declare class LineWebGLSurface {
45
- private canvas;
51
+ private shared;
46
52
  private handles;
47
53
  private logicalWidth;
48
54
  private logicalHeight;
@@ -50,18 +56,25 @@ export declare class LineWebGLSurface {
50
56
  private available;
51
57
  private vertexCapacity;
52
58
  private fillScratch;
59
+ private lineScratch;
60
+ private region;
61
+ private msaaTargets;
53
62
  private geoCache;
54
- constructor(canvas?: HTMLCanvasElement);
63
+ constructor(shared: SharedWebGLSurface);
55
64
  isAvailable(): boolean;
56
65
  getCanvas(): HTMLCanvasElement;
66
+ setRegion(region: WebGLRegion): void;
57
67
  resize(width: number, height: number, dpr: number): void;
58
68
  clear(): void;
59
- drawLineStrip(line: LineStrip, color: string, scrollLeft: number): boolean;
69
+ compositeTo(ctx: CanvasRenderingContext2D, options?: WebGLCompositeOptions): void;
60
70
  drawLineStrips(lines: ColoredLineStrip[], scrollLeft: number): boolean;
61
71
  private getThinLineVertices;
62
72
  private getLineGeometry;
63
73
  drawFilledBand(band: FilledBand, color: string, scrollLeft: number): boolean;
64
74
  destroy(): void;
75
+ private ensureLineMsaaTargets;
76
+ private destroyLineMsaaTargets;
77
+ private resolveLineMsaaToSharedRegion;
65
78
  private initLineHandles;
66
79
  }
67
80
  export {};
@@ -0,0 +1,33 @@
1
+ export type WebGLRegion = {
2
+ x: number;
3
+ y: number;
4
+ width: number;
5
+ height: number;
6
+ dpr: number;
7
+ };
8
+ export type WebGLCompositeOptions = {
9
+ alpha?: number;
10
+ imageSmoothingEnabled?: boolean;
11
+ };
12
+ export type PhysicalRegion = {
13
+ sourceX: number;
14
+ sourceY: number;
15
+ widthPx: number;
16
+ heightPx: number;
17
+ };
18
+ export declare class SharedWebGLSurface {
19
+ private canvas;
20
+ private gl;
21
+ constructor(canvas?: HTMLCanvasElement);
22
+ isAvailable(): boolean;
23
+ getGL(): WebGL2RenderingContext | null;
24
+ getCanvas(): HTMLCanvasElement;
25
+ resize(width: number, height: number, dpr: number): void;
26
+ getPhysicalRegion(region: WebGLRegion): PhysicalRegion | null;
27
+ bindRegion(region: WebGLRegion): boolean;
28
+ clearRegion(region: WebGLRegion): void;
29
+ compositeRegionTo(ctx: CanvasRenderingContext2D, region: WebGLRegion, options?: WebGLCompositeOptions): void;
30
+ destroy(): void;
31
+ private toPhysicalRegion;
32
+ private initContext;
33
+ }
@@ -0,0 +1,22 @@
1
+ import { Chart } from './chart';
2
+ import { SubIndicatorType } from './renderers/Indicator';
3
+ export interface SubPaneEntry {
4
+ paneId: string;
5
+ indicatorId: SubIndicatorType;
6
+ params: Record<string, unknown>;
7
+ rendererName: string;
8
+ scaleRendererName: string;
9
+ }
10
+ export declare class SubPaneManager {
11
+ private entries;
12
+ create(chart: Chart, paneId: string, indicatorId: SubIndicatorType, params: Record<string, unknown>): boolean;
13
+ remove(chart: Chart, paneId: string): void;
14
+ replaceIndicator(chart: Chart, paneId: string, newIndicatorId: SubIndicatorType, newParams: Record<string, unknown>): void;
15
+ updateParams(chart: Chart, paneId: string, params: Record<string, unknown>): void;
16
+ getByPaneId(paneId: string): SubPaneEntry | undefined;
17
+ getAll(): SubPaneEntry[];
18
+ getPaneIds(): string[];
19
+ clear(chart: Chart): void;
20
+ private syncSchedulerConfig;
21
+ private mountScaleRenderer;
22
+ }
@@ -104,6 +104,42 @@ export interface SubIndicatorParams {
104
104
  FASTK?: {
105
105
  period?: number;
106
106
  };
107
+ ATR?: {
108
+ period?: number;
109
+ };
110
+ WMA?: {
111
+ period?: number;
112
+ };
113
+ DEMA?: {
114
+ period?: number;
115
+ };
116
+ TEMA?: {
117
+ period?: number;
118
+ };
119
+ HMA?: {
120
+ period?: number;
121
+ };
122
+ KAMA?: {
123
+ period?: number;
124
+ fastPeriod?: number;
125
+ slowPeriod?: number;
126
+ };
127
+ SAR?: {
128
+ step?: number;
129
+ maxStep?: number;
130
+ };
131
+ SUPERTREND?: {
132
+ atrPeriod?: number;
133
+ multiplier?: number;
134
+ };
135
+ KELTNER?: {
136
+ emaPeriod?: number;
137
+ atrPeriod?: number;
138
+ multiplier?: number;
139
+ };
140
+ DONCHIAN?: {
141
+ period?: number;
142
+ };
107
143
  }
108
144
  /** 副图指标类型 */
109
145
  export type SubIndicatorType = keyof SubIndicatorParams;
@@ -1,8 +1,9 @@
1
1
  import { SemanticChartConfig, ValidationResult, SecurityResult } from './types';
2
2
  export declare class SemanticConfigValidator {
3
- private ajv;
4
3
  private limits;
4
+ private _ajv;
5
5
  constructor();
6
+ private getAjv;
6
7
  /**
7
8
  * 入口校验(在 JSON.parse 之前调用)
8
9
  * 检查原始字符串大小
@@ -11,7 +12,7 @@ export declare class SemanticConfigValidator {
11
12
  /**
12
13
  * JSON Schema 校验
13
14
  */
14
- validate(config: unknown): ValidationResult;
15
+ validate(config: unknown): Promise<ValidationResult>;
15
16
  /**
16
17
  * 安全校验(纯同步)
17
18
  */
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Vitest 测试环境 polyfill
3
+ * - jsdom 不实现 Path2D
4
+ * - jsdom 不实现 WebGL —— 给 getContext('webgl'/'webgl2') 一个最小桩,让 Chart 构造不会崩
5
+ */
6
+ export {};
@@ -0,0 +1,14 @@
1
+ interface HttpParams {
2
+ params?: Record<string, string | number | undefined>;
3
+ timeout?: number;
4
+ }
5
+ interface HttpResponse<T> {
6
+ data: T;
7
+ }
8
+ export declare class HttpError extends Error {
9
+ constructor(message: string);
10
+ static isHttpError(error: unknown): error is HttpError;
11
+ }
12
+ declare function get<T>(url: string, config?: HttpParams): Promise<HttpResponse<T>>;
13
+ export { get };
14
+ export type { HttpParams, HttpResponse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@363045841yyt/klinechart",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "description": "A lightweight financial K-line charting library with first-class AI Agent support, crisp ResizeObserver-driven rendering, and plugin-based architecture. Focused on quantitative trading scenarios with TradingView-level interaction experience.",
5
5
  "author": "363045841 <slslswbsy@qq.com>",
6
6
  "license": "MIT",
@@ -77,8 +77,7 @@
77
77
  "vue": "^3.5.0"
78
78
  },
79
79
  "dependencies": {
80
- "ajv": "^8.20.0",
81
- "axios": "^1.16.0"
80
+ "ajv": "^8.20.0"
82
81
  },
83
82
  "devDependencies": {
84
83
  "@iconify-json/tabler": "^1.2.34",
package/dist/favicon.ico DELETED
Binary file