nhanh-pure-function 3.0.6-beta.7 → 3.0.6-beta.9

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.
@@ -1,6 +1,7 @@
1
1
  import { default as Overlay } from './public/overlay';
2
2
  import { OverlayType } from './index';
3
3
  import { EventHandler } from '../public/eventController';
4
+ import { ArcStyleType, PolygonStyleType } from '../common.type';
4
5
  type ConstructorOption = ConstructorParameters<typeof Overlay<ArcStyleType, [number, number]>>[0] & {
5
6
  /** 是否填充 */
6
7
  isFill?: boolean;
@@ -1,6 +1,7 @@
1
1
  import { default as Overlay } from './public/overlay';
2
2
  import { OverlayType } from './index';
3
3
  import { EventHandler } from '../public/eventController';
4
+ import { ArcToStyleType } from '../common.type';
4
5
  type ConstructorOption = ConstructorParameters<typeof Overlay<ArcToStyleType, [number, number][]>>[0] & {
5
6
  /** 是否可显示控制点 */
6
7
  isHandlePointsVisible?: boolean;
@@ -1,5 +1,6 @@
1
1
  import { OverlayType } from './index';
2
2
  import { default as GeometricBoundary } from './public/geometricBoundary';
3
+ import { LineStyleType } from '../common.type';
3
4
  type ConstructorOption = ConstructorParameters<typeof GeometricBoundary<LineStyleType>>[0] & {
4
5
  /** 是否是 两点相连向外延展的无限线 */
5
6
  isInfinite?: boolean;
@@ -1,6 +1,7 @@
1
1
  import { default as Overlay } from './public/overlay';
2
2
  import { OverlayType } from './index';
3
3
  import { EventHandler } from '../public/eventController';
4
+ import { PointStyleType } from '../common.type';
4
5
  type ConstructorOption = ConstructorParameters<typeof Overlay<PointStyleType, [number, number]>>[0];
5
6
  export default class Point extends Overlay<PointStyleType, [number, number]> {
6
7
  private angle;
@@ -1,5 +1,6 @@
1
1
  import { OverlayType } from './index';
2
2
  import { default as GeometricBoundary } from './public/geometricBoundary';
3
+ import { PolygonStyleType } from '../common.type';
3
4
  type ConstructorOption = ConstructorParameters<typeof GeometricBoundary<PolygonStyleType>>[0] & {
4
5
  /** 是否为矩形 */
5
6
  isRect?: boolean;
@@ -1,9 +1,11 @@
1
1
  import { default as _Canvas } from '../..';
2
2
  import { OverlayType } from '../index';
3
3
  import { EventHandler, default as EventController } from '../../public/eventController';
4
+ import { _Type_DeepPartial } from '../../..';
5
+ import { BaseLineStyle, PointStyleType } from '../../common.type';
4
6
  type ConstructorOption<T, V> = ConstructorParameters<typeof EventController>[0] & {
5
7
  /** 样式 */
6
- style?: DeepPartial<T> | string;
8
+ style?: _Type_DeepPartial<T> | string;
7
9
  /** 层级 */
8
10
  zIndex?: number;
9
11
  /** 坐标轴上的点位 */
@@ -69,7 +71,7 @@ export default abstract class Overlay<T, V extends [number, number] | [number, n
69
71
  value?: V;
70
72
  dynamicPosition?: V;
71
73
  zIndex?: number;
72
- style?: DeepPartial<T> | string;
74
+ style?: _Type_DeepPartial<T> | string;
73
75
  }, updateValueScope?: boolean): void;
74
76
  /** 鼠标移入时是否重新绘制 */
75
77
  redrawOnIsHoverChange: boolean;
@@ -1,6 +1,7 @@
1
1
  import { default as Overlay } from './public/overlay';
2
2
  import { OverlayType } from './index';
3
3
  import { EventHandler } from '../public/eventController';
4
+ import { TextStyleType } from '../common.type';
4
5
  type ConstructorOption = ConstructorParameters<typeof Overlay<TextStyleType, [number, number]>>[0] & {
5
6
  /** 文字 */
6
7
  text?: string;
@@ -0,0 +1,117 @@
1
+ /** 默认中心点 */
2
+ export type DefaultCenter = Partial<{
3
+ top: number | `${number}%` | "top" | "middle" | "bottom";
4
+ bottom: number | `${number}%`;
5
+ left: number | `${number}%` | "left" | "center" | "right";
6
+ right: number | `${number}%`;
7
+ }>;
8
+ export type KnownStyleKeys = "light" | "dark";
9
+ /** 文本样式 */
10
+ export type TextStyleType = {
11
+ /** 颜色 */
12
+ color: string;
13
+ /** secondary颜色 */
14
+ secondary: string;
15
+ /** 描边色 */
16
+ stroke: string;
17
+ /** 字体大小 */
18
+ size: number;
19
+ /** 字体族 */
20
+ family: string;
21
+ /** 是否加粗 */
22
+ bold: boolean;
23
+ };
24
+ /** 网格样式 */
25
+ export type GridStyleType = {
26
+ axis: string;
27
+ grid: string;
28
+ innerGrid: string;
29
+ };
30
+ /** 点位样式 */
31
+ export type PointStyleType = {
32
+ /** 半径 */
33
+ radius: number;
34
+ /** 边框颜色 */
35
+ stroke: string;
36
+ /** 边框大小 */
37
+ width: number;
38
+ /** 填充颜色 */
39
+ fill: string;
40
+ };
41
+ /** 基础线样式 */
42
+ export type BaseLineStyle = {
43
+ /** 颜色 */
44
+ color: string;
45
+ /** 颜色 - hover */
46
+ color_hover: string;
47
+ /** 宽度 */
48
+ width: number;
49
+ /** 虚线 */
50
+ dash: boolean;
51
+ /** 虚线间隔 */
52
+ dashGap: number[];
53
+ /** 偏移虚线 */
54
+ dashOffset: number;
55
+ /** 末端的形状 */
56
+ cap: "butt" | "round" | "square";
57
+ /** 路径中的相连部分的形状 */
58
+ join: "bevel" | "round" | "miter";
59
+ };
60
+ /** 线样式 */
61
+ export type LineStyleType = {
62
+ /** 描边 */
63
+ stroke: BaseLineStyle;
64
+ /** 点位样式 */
65
+ point: PointStyleType;
66
+ };
67
+ /** 圆弧样式 */
68
+ export type ArcStyleType = {
69
+ /** 填充色 */
70
+ fill: string;
71
+ /** 填充色 - hover */
72
+ fill_hover: string;
73
+ /** 描边 */
74
+ stroke: BaseLineStyle;
75
+ /** 点位样式 */
76
+ point: PointStyleType;
77
+ };
78
+ /** 圆角样式 */
79
+ export type ArcToStyleType = {
80
+ /** 描边 */
81
+ stroke: BaseLineStyle;
82
+ /** 点位样式 */
83
+ point: PointStyleType;
84
+ };
85
+ /** 面样式 */
86
+ export type PolygonStyleType = {
87
+ /** 填充色 */
88
+ fill: string;
89
+ /** 填充色 - hover */
90
+ fill_hover: string;
91
+ /** 描边 */
92
+ stroke: BaseLineStyle;
93
+ /** 点位样式 */
94
+ point: PointStyleType;
95
+ };
96
+ /** 主题样式 */
97
+ export type StyleItemType = {
98
+ /** 背景色 */
99
+ background: string;
100
+ /** 文本样式 */
101
+ text: TextStyleType;
102
+ /** 网格样式 */
103
+ grid: GridStyleType;
104
+ /** 点位样式 */
105
+ point: PointStyleType;
106
+ /** 线样式 */
107
+ line: LineStyleType;
108
+ /** 圆弧样式 */
109
+ arc: ArcStyleType;
110
+ /** 圆角样式 */
111
+ arcTo: ArcToStyleType;
112
+ /** 面样式 */
113
+ polygon: PolygonStyleType;
114
+ };
115
+ /** 主题样式 */
116
+ export type StyleType = Record<KnownStyleKeys, StyleItemType> & Record<string, StyleItemType>;
117
+ export type DeepArray<T> = T | T[] | DeepArray<T>[];
@@ -1,4 +1,5 @@
1
1
  import { default as Canvas } from '..';
2
+ import { _Type_DeepPartial } from '../..';
2
3
  export default class Axis {
3
4
  /** 画布 */
4
5
  private canvas;
@@ -18,7 +19,7 @@ export default class Axis {
18
19
  constructor(canvas: Canvas);
19
20
  private initAxisCanvas;
20
21
  /** 开关坐标轴 */
21
- toggleAxis(show?: boolean | DeepPartial<Axis["show"]>): void;
22
+ toggleAxis(show?: boolean | _Type_DeepPartial<Axis["show"]>): void;
22
23
  drawAxisAndGrid(): HTMLCanvasElement | undefined;
23
24
  private color;
24
25
  /** 绘制网格 */
@@ -1,6 +1,7 @@
1
1
  import { default as Axis } from './axis';
2
2
  import { default as LayerGroup } from '../LayerGroup';
3
3
  import { default as EventController } from '../public/eventController';
4
+ import { DefaultCenter } from '../common.type';
4
5
  type ConstructorOption = ConstructorParameters<typeof EventController>[0] & {
5
6
  /** 画布 id */
6
7
  id: string;
@@ -1,8 +1,10 @@
1
+ import { _Type_DeepPartial } from '../..';
1
2
  import { default as Axis } from './axis';
2
3
  import { default as Event } from './event';
3
4
  import { default as OverlayGroup, OverlayType } from '../OverlayGroup';
4
5
  import { default as LayerGroup } from '../LayerGroup';
5
6
  import { default as Layer } from '../LayerGroup/layer';
7
+ import { KnownStyleKeys, StyleType } from '../common.type';
6
8
  type NodeType = LayerGroup | Layer | OverlayGroup | OverlayType;
7
9
  type SingleOrArray<T> = T | T[];
8
10
  declare class QuickMethod_Get extends Event {
@@ -28,7 +30,7 @@ declare class QuickMethod_Set extends QuickMethod_Get {
28
30
  /** 缩小 */
29
31
  zoomOut(): void;
30
32
  /** 添加样式 */
31
- setStyle(style: DeepPartial<StyleType>): void;
33
+ setStyle(style: _Type_DeepPartial<StyleType>): void;
32
34
  /** 设置主题 */
33
35
  setTheme(theme: KnownStyleKeys): void;
34
36
  /** 设置坐标轴 */
@@ -80,7 +82,7 @@ declare class QuickMethod_View extends QuickMethod_Set {
80
82
  }
81
83
  declare class QuickMethod_Toggle extends QuickMethod_View {
82
84
  /** 开关坐标轴 */
83
- toggleAxis(show?: boolean | DeepPartial<Axis["show"]>): void;
85
+ toggleAxis(show?: boolean | _Type_DeepPartial<Axis["show"]>): void;
84
86
  /** 开关点位 */
85
87
  togglePoint(show?: boolean): boolean;
86
88
  /** 开关线段 */
@@ -1,3 +1,5 @@
1
+ import { _Type_DeepPartial } from '../..';
2
+ import { KnownStyleKeys, StyleType } from '../common.type';
1
3
  import { default as BaseData } from './basedata';
2
4
  type ConstructorOption = ConstructorParameters<typeof BaseData>[0] & {
3
5
  theme?: KnownStyleKeys;
@@ -15,7 +17,7 @@ export default class Style extends BaseData {
15
17
  /** 清除画布 */
16
18
  clearScreen(fillBackground?: boolean): void;
17
19
  /** 设置样式 */
18
- setStyle(style: DeepPartial<StyleType>): void;
20
+ setStyle(style: _Type_DeepPartial<StyleType>): void;
19
21
  /** 设置主题 */
20
22
  setTheme(theme: KnownStyleKeys): void;
21
23
  }
@@ -9,6 +9,7 @@ import { default as Polygon } from './OverlayGroup/polygon';
9
9
  import { default as Custom } from './OverlayGroup/custom';
10
10
  import { default as Arc } from './OverlayGroup/arc';
11
11
  import { default as ArcTo } from './OverlayGroup/arcTo';
12
+ import { DeepArray } from './common.type';
12
13
  export type * from './index.types';
13
14
  type ConstructorOption = ConstructorParameters<typeof QuickMethod>[0] & {
14
15
  /** 轴线显示属性 */
@@ -27,8 +27,13 @@ export type _Type_PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T,
27
27
  * 使所有层级的属性都变为可选。适用于需要部分更新对象且允许深层属性缺失的场景
28
28
  */
29
29
  export type _Type_DeepPartial<T> = {
30
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
30
+ [P in keyof T]?: T[P] extends object ? _Type_DeepPartial<T[P]> : T[P];
31
31
  };
32
+ /**
33
+ * @template T - 要处理的对象类型
34
+ * @description 创建一个对象类型,将所有属性变为可变(mutable)。
35
+ * 适用于需要修改对象属性的场景,但需要确保对象不会被其他地方引用
36
+ */
32
37
  export type _Type_Mutable<T> = {
33
38
  -readonly [P in keyof T]: T[P];
34
39
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nhanh-pure-function",
3
- "version": "3.0.6-beta.7",
3
+ "version": "3.0.6-beta.9",
4
4
  "description": "纯函数工具",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.es.js",
@@ -25,6 +25,7 @@
25
25
  "ts-node": "^10.9.2",
26
26
  "typescript": "^5.7.3",
27
27
  "vite": "^6.1.0",
28
+ "vite-plugin-checker": "^0.10.3",
28
29
  "vite-plugin-css-injected-by-js": "^3.5.2",
29
30
  "vite-plugin-dts": "^4.5.0",
30
31
  "vite-tsconfig-paths": "^5.1.4"