@363045841yyt/klinechart 0.4.0 → 0.4.1

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 (67) hide show
  1. package/README.md +6 -0
  2. package/dist/index.cjs +9 -9
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +2028 -1593
  5. package/dist/klinechart.css +1 -1
  6. package/dist/src/api/data/baostock.d.ts +1 -1
  7. package/dist/src/api/data/kLine.d.ts +1 -1
  8. package/dist/src/api/data/types.d.ts +1 -1
  9. package/dist/src/api/data/unified.d.ts +1 -1
  10. package/dist/src/components/IndicatorSelector.vue.d.ts +2 -0
  11. package/dist/src/components/KLineChart.vue.d.ts +2 -2
  12. package/dist/src/components/KLineTooltip.vue.d.ts +1 -1
  13. package/dist/src/components/MarkerTooltip.vue.d.ts +1 -1
  14. package/dist/src/core/chart.d.ts +26 -9
  15. package/dist/src/core/controller/interaction.d.ts +12 -6
  16. package/dist/src/core/layout/pane.d.ts +4 -4
  17. package/dist/src/core/renderers/Indicator/boll.d.ts +2 -2
  18. package/dist/src/core/renderers/Indicator/cci.d.ts +7 -3
  19. package/dist/src/core/renderers/Indicator/ene.d.ts +2 -2
  20. package/dist/src/core/renderers/Indicator/expma.d.ts +2 -2
  21. package/dist/src/core/renderers/Indicator/fastk.d.ts +7 -3
  22. package/dist/src/core/renderers/Indicator/index.d.ts +1 -1
  23. package/dist/src/core/renderers/Indicator/kst.d.ts +7 -3
  24. package/dist/src/core/renderers/Indicator/ma.d.ts +1 -1
  25. package/dist/src/core/renderers/Indicator/macd.d.ts +2 -2
  26. package/dist/src/core/renderers/Indicator/macdLegend.d.ts +1 -1
  27. package/dist/src/core/renderers/Indicator/mainIndicatorLegend.d.ts +1 -1
  28. package/dist/src/core/renderers/Indicator/mom.d.ts +7 -3
  29. package/dist/src/core/renderers/Indicator/rsi.d.ts +7 -3
  30. package/dist/src/core/renderers/Indicator/scale/cci_scale.d.ts +5 -0
  31. package/dist/src/core/renderers/Indicator/scale/fastk_scale.d.ts +5 -0
  32. package/dist/src/core/renderers/Indicator/scale/indicator_scale.d.ts +23 -0
  33. package/dist/src/core/renderers/Indicator/scale/kst_scale.d.ts +5 -0
  34. package/dist/src/core/renderers/Indicator/scale/macd_scale.d.ts +1 -1
  35. package/dist/src/core/renderers/Indicator/scale/mom_scale.d.ts +5 -0
  36. package/dist/src/core/renderers/Indicator/scale/rsi_scale.d.ts +5 -0
  37. package/dist/src/core/renderers/Indicator/scale/stoch_scale.d.ts +5 -0
  38. package/dist/src/core/renderers/Indicator/scale/wmsr_scale.d.ts +5 -0
  39. package/dist/src/core/renderers/Indicator/stoch.d.ts +7 -3
  40. package/dist/src/core/renderers/Indicator/wmsr.d.ts +7 -3
  41. package/dist/src/core/renderers/candle.d.ts +3 -3
  42. package/dist/src/core/renderers/crosshair.d.ts +1 -1
  43. package/dist/src/core/renderers/customMarkers.d.ts +1 -1
  44. package/dist/src/core/renderers/extremaMarkers.d.ts +1 -1
  45. package/dist/src/core/renderers/gridLines.d.ts +1 -1
  46. package/dist/src/core/renderers/lastPrice.d.ts +1 -1
  47. package/dist/src/core/renderers/paneTitle.d.ts +1 -1
  48. package/dist/src/core/renderers/subVolume.d.ts +1 -1
  49. package/dist/src/core/renderers/timeAxis.d.ts +1 -1
  50. package/dist/src/core/renderers/yAxis.d.ts +2 -2
  51. package/dist/src/core/viewport/viewport.d.ts +2 -2
  52. package/dist/src/plugin/HookSystem.d.ts +3 -3
  53. package/dist/src/plugin/PluginHost.d.ts +6 -5
  54. package/dist/src/plugin/rendererPluginManager.d.ts +4 -0
  55. package/dist/src/plugin/types.d.ts +12 -2
  56. package/dist/src/semantic/controller.d.ts +1 -1
  57. package/dist/src/utils/kLineDraw/MA.d.ts +1 -1
  58. package/dist/src/utils/kLineDraw/axis.d.ts +1 -1
  59. package/dist/src/utils/kLineDraw/grid.d.ts +1 -1
  60. package/dist/src/utils/kLineDraw/kLine.d.ts +1 -1
  61. package/dist/src/utils/kline/format.d.ts +2 -2
  62. package/dist/src/utils/kline/ma.d.ts +1 -1
  63. package/dist/src/utils/kline/viewport.d.ts +1 -1
  64. package/dist/src/utils/mock/genRandomPriceData.d.ts +1 -1
  65. package/dist/src/utils/volumePrice.d.ts +2 -2
  66. package/package.json +1 -1
  67. /package/dist/{semantic → src/semantic}/schema.json.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { RendererPlugin } from '../../../plugin';
1
+ import { RendererPlugin } from '../../plugin';
2
2
  /**
3
3
  * 创建可视区最高/最低价标注渲染器插件
4
4
  */
@@ -1,4 +1,4 @@
1
- import { RendererPlugin } from '../../../plugin';
1
+ import { RendererPlugin } from '../../plugin';
2
2
  /**
3
3
  * 创建网格线渲染器插件
4
4
  * 横向按像素均分铺满整个绘图区高度,纵向按月分割(使用预计算的月边界,网格线对齐到K线实体中部)
@@ -1,4 +1,4 @@
1
- import { RendererPlugin } from '../../../plugin';
1
+ import { RendererPlugin } from '../../plugin';
2
2
  /**
3
3
  * 创建最新价虚线渲染器插件
4
4
  */
@@ -1,4 +1,4 @@
1
- import { RendererPlugin } from '../../../plugin';
1
+ import { RendererPlugin } from '../../plugin';
2
2
  /**
3
3
  * 单个数值项
4
4
  */
@@ -1,4 +1,4 @@
1
- import { RendererPlugin } from '../../../plugin';
1
+ import { RendererPlugin } from '../../plugin';
2
2
  export interface VolumeRendererOptions {
3
3
  /** 目标 pane ID(默认 'sub') */
4
4
  paneId?: string;
@@ -1,4 +1,4 @@
1
- import { RendererPlugin } from '../../../plugin';
1
+ import { RendererPlugin } from '../../plugin';
2
2
  /** 时间轴面板 ID(特殊标识,用于单独渲染) */
3
3
  export declare const TIME_AXIS_PANE_ID: unique symbol;
4
4
  /**
@@ -1,7 +1,7 @@
1
- import { RendererPlugin } from '../../../plugin';
1
+ import { RendererPlugin } from '../../plugin';
2
2
  /**
3
3
  * 创建 Y 轴渲染器插件
4
- * 渲染到所有面板的 Y 轴区域
4
+ * 仅渲染主图价格刻度;副图刻度由指标刻度插件负责
5
5
  */
6
6
  export declare function createYAxisRendererPlugin(options: {
7
7
  axisWidth: number;
@@ -1,5 +1,5 @@
1
- import { KLineData } from '../../../types/price';
2
- import { PriceRange } from '../../../core/scale/price';
1
+ import { KLineData } from '../../types/price';
2
+ import { PriceRange } from '../scale/price';
3
3
  /**
4
4
  * 计算当前视口可见的 K 线索引范围(使用物理像素对齐)。
5
5
  *
@@ -1,4 +1,4 @@
1
- import { HookFn } from './types';
1
+ import { HookCallOptions, HookFn } from './types';
2
2
  export declare class HookSystem {
3
3
  private hooks;
4
4
  /**
@@ -12,11 +12,11 @@ export declare class HookSystem {
12
12
  /**
13
13
  * 触发钩子(异步)
14
14
  */
15
- call<T = unknown, R = unknown>(hookName: string, context: T): Promise<R[]>;
15
+ call<T = unknown, R = unknown>(hookName: string, context: T, options?: HookCallOptions): Promise<R[]>;
16
16
  /**
17
17
  * 触发钩子(同步)
18
18
  */
19
- callSync<T = unknown, R = unknown>(hookName: string, context: T): R[];
19
+ callSync<T = unknown, R = unknown>(hookName: string, context: T, options?: HookCallOptions): R[];
20
20
  /**
21
21
  * 清除所有钩子
22
22
  */
@@ -1,4 +1,4 @@
1
- import { Plugin, PluginConfig, PluginHost, PluginState, BaseIndicatorState } from './types';
1
+ import { Plugin, PluginConfig, PluginHost, PluginState, BaseIndicatorState, PluginLogger, HookCallOptions } from './types';
2
2
  export declare class PluginHostImpl implements PluginHost {
3
3
  private registry;
4
4
  private eventBus;
@@ -6,7 +6,8 @@ export declare class PluginHostImpl implements PluginHost {
6
6
  private configManager;
7
7
  private stateStore;
8
8
  private isDestroyed;
9
- constructor();
9
+ private logger;
10
+ constructor(logger?: PluginLogger);
10
11
  readonly events: {
11
12
  on: <T = unknown>(event: string, handler: (data: T) => void) => void;
12
13
  off: <T = unknown>(event: string, handler: (data: T) => void) => void;
@@ -16,8 +17,8 @@ export declare class PluginHostImpl implements PluginHost {
16
17
  readonly hooks: {
17
18
  tap: <T = unknown, R = unknown>(hookName: string, fn: (context: T) => R | Promise<R>, priority?: number) => void;
18
19
  untap: (hookName: string, fn: (context: unknown) => unknown) => void;
19
- call: <T = unknown, R = unknown>(hookName: string, context: T) => Promise<R[]>;
20
- callSync: <T = unknown, R = unknown>(hookName: string, context: T) => R[];
20
+ call: <T = unknown, R = unknown>(hookName: string, context: T, options?: HookCallOptions) => Promise<R[]>;
21
+ callSync: <T = unknown, R = unknown>(hookName: string, context: T, options?: HookCallOptions) => R[];
21
22
  };
22
23
  getConfig<K = unknown>(pluginName: string, key: string, defaultValue?: K): K;
23
24
  setConfig(pluginName: string, key: string, value: unknown): void;
@@ -50,4 +51,4 @@ export declare class PluginHostImpl implements PluginHost {
50
51
  destroy(): Promise<void>;
51
52
  private ensureNotDestroyed;
52
53
  }
53
- export declare function createPluginHost(): PluginHostImpl;
54
+ export declare function createPluginHost(logger?: PluginLogger): PluginHostImpl;
@@ -49,6 +49,10 @@ export declare class RendererPluginManager {
49
49
  private mergeSorted;
50
50
  /** 重建缓存(统一管理所有缓存逻辑) */
51
51
  private rebuildCache;
52
+ /** 判断渲染器是否启用 */
53
+ private isRendererEnabled;
54
+ /** 获取指定 pane 的合并渲染器(包含 system 渲染器) */
55
+ private getMergedRenderers;
52
56
  /** 获取指定 pane 的渲染器(已缓存,无穿透) */
53
57
  getRenderers(paneId: string): RendererPlugin[];
54
58
  /** 渲染指定 pane(带错误隔离) */
@@ -36,6 +36,10 @@ export interface PluginDescriptor {
36
36
  }
37
37
  /** Hook 函数类型 */
38
38
  export type HookFn<T = unknown, R = unknown> = (context: T) => R | Promise<R>;
39
+ /** Hook 调用选项 */
40
+ export interface HookCallOptions {
41
+ throwOnError?: boolean;
42
+ }
39
43
  /** Hook 描述符 */
40
44
  export interface HookDescriptor<T = unknown, R = unknown> {
41
45
  name: string;
@@ -44,6 +48,12 @@ export interface HookDescriptor<T = unknown, R = unknown> {
44
48
  }
45
49
  /** 事件处理器 */
46
50
  export type EventHandler<T = unknown> = (data: T) => void;
51
+ /** 插件日志器 */
52
+ export interface PluginLogger {
53
+ info(message?: unknown, ...optionalParams: unknown[]): void;
54
+ warn(message?: unknown, ...optionalParams: unknown[]): void;
55
+ error(message?: unknown, ...optionalParams: unknown[]): void;
56
+ }
47
57
  /** 插件宿主接口(暴露给插件使用的 API) */
48
58
  export interface PluginHost {
49
59
  /** 事件总线 */
@@ -57,8 +67,8 @@ export interface PluginHost {
57
67
  readonly hooks: {
58
68
  tap<T = unknown, R = unknown>(hookName: string, fn: HookFn<T, R>, priority?: number): void;
59
69
  untap(hookName: string, fn: HookFn): void;
60
- call<T = unknown, R = unknown>(hookName: string, context: T): Promise<R[]>;
61
- callSync<T = unknown, R = unknown>(hookName: string, context: T): R[];
70
+ call<T = unknown, R = unknown>(hookName: string, context: T, options?: HookCallOptions): Promise<R[]>;
71
+ callSync<T = unknown, R = unknown>(hookName: string, context: T, options?: HookCallOptions): R[];
62
72
  };
63
73
  /** 获取配置 */
64
74
  getConfig<K = unknown>(pluginName: string, key: string, defaultValue?: K): K;
@@ -1,4 +1,4 @@
1
- import { Chart } from '../../core/chart';
1
+ import { Chart } from '../core/chart';
2
2
  import { SemanticChartConfig, ApplyResult } from './types';
3
3
  /** 状态事件类型 */
4
4
  export type SemanticEventType = 'config:loading' | 'config:ready' | 'config:error';
@@ -1,4 +1,4 @@
1
- import { KLineData } from '../../../types/price';
1
+ import { KLineData } from '../../types/price';
2
2
  import { drawOption, PriceRange } from './kLine';
3
3
  export declare const MA5_COLOR: "rgba(255, 193, 37, 1)";
4
4
  export declare const MA10_COLOR: "rgba(190, 131, 12, 1)";
@@ -1,4 +1,4 @@
1
- import { KLineData } from '../../../types/price';
1
+ import { KLineData } from '../../types/price';
2
2
  export interface PriceAxisOptions {
3
3
  x: number;
4
4
  y: number;
@@ -1,4 +1,4 @@
1
- import { KLineData } from '../../../types/price';
1
+ import { KLineData } from '../../types/price';
2
2
  import { drawOption, PriceRange } from './kLine';
3
3
  export interface GridOption {
4
4
  /** 网格线颜色 */
@@ -1,4 +1,4 @@
1
- import { KLineData } from '../../../types/price';
1
+ import { KLineData } from '../../types/price';
2
2
  export interface drawOption {
3
3
  kWidth: number;
4
4
  kGap: number;
@@ -1,5 +1,5 @@
1
- import { KLineData } from '../../../types/price';
2
- export { formatShanghaiDate } from '../../../utils/dateFormat';
1
+ import { KLineData } from '../../types/price';
2
+ export { formatShanghaiDate } from '../dateFormat';
3
3
  export declare const UP_COLOR: "rgba(214, 10, 34, 1)";
4
4
  export declare const DOWN_COLOR: "rgba(3, 123, 102, 1)";
5
5
  export declare const NEUTRAL_COLOR: "rgba(0, 0, 0, 0.78)";
@@ -1,2 +1,2 @@
1
- import { KLineData } from '../../../types/price';
1
+ import { KLineData } from '../../types/price';
2
2
  export declare function calcMAAtIndex(data: KLineData[], index: number, period: number): number | undefined;
@@ -1,4 +1,4 @@
1
- import { KLineData } from '../../../types/price';
1
+ import { KLineData } from '../../types/price';
2
2
  export type PriceRange = {
3
3
  maxPrice: number;
4
4
  minPrice: number;
@@ -1,3 +1,3 @@
1
- import { KLineData } from '../../../types/price';
1
+ import { KLineData } from '../../types/price';
2
2
  export declare function genRandomPriceData(count: number): KLineData[];
3
3
  export declare function reversalExampleData(): KLineData[];
@@ -1,5 +1,5 @@
1
- import { KLineData } from '../../types/price';
2
- import { VolumePriceRelation, VolumePriceConfig, DEFAULT_VOLUME_PRICE_CONFIG } from '../../types/volumePrice';
1
+ import { KLineData } from '../types/price';
2
+ import { VolumePriceRelation, VolumePriceConfig, DEFAULT_VOLUME_PRICE_CONFIG } from '../types/volumePrice';
3
3
  export { DEFAULT_VOLUME_PRICE_CONFIG };
4
4
  /**
5
5
  * 成交量前缀和计算器
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@363045841yyt/klinechart",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "^20.19.0 || >=22.12.0"