nhanh-pure-function 3.0.6-beta.8 → 3.0.6

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.
@@ -10,46 +10,6 @@ export declare function _Browser_GetFrameRate(callback: (fps: number, frameTime:
10
10
  * @param {string} text
11
11
  */
12
12
  export declare function _Browser_CopyToClipboard(text: string): Promise<void>;
13
- /**
14
- * 管理通过键值对打开的窗口
15
- */
16
- export declare class _Browser_KeyedWindowManager {
17
- private static keys;
18
- /** 请使用静态方法 */
19
- private constructor();
20
- /** 添加已有窗口 */
21
- static add(key: string, win: Window): void;
22
- /**
23
- * 根据键打开或聚焦窗口
24
- * @param key 窗口的唯一键
25
- * @param url 要打开的URL
26
- * @param target 窗口的目标
27
- * @param windowFeatures 新窗口的特性
28
- * @returns 返回已打开或新打开的窗口
29
- */
30
- static open(key: string, url?: string | URL, target?: WindowTarget, windowFeatures?: string): Window | undefined;
31
- /**
32
- * 检查指定键的窗口是否打开
33
- * @param key 窗口的唯一键
34
- * @returns 如果窗口打开则返回true,否则返回false
35
- */
36
- static isOpen(key: string): boolean;
37
- /**
38
- * 获取与指定键关联的窗口
39
- * @param key 窗口的唯一键
40
- * @returns 返回对应的窗口,如果窗口已关闭则返回undefined
41
- */
42
- static getWindow(key: string): Window | undefined;
43
- /**
44
- * 关闭与指定键关联的窗口
45
- * @param key 窗口的唯一键
46
- */
47
- static close(key: string): void;
48
- /**
49
- * 关闭所有打开的窗口并清空Map
50
- */
51
- static closeAll(): void;
52
- }
53
13
  /**
54
14
  * 计算纸张内容可用宽高及边距(考虑设备DPI)
55
15
  * 确保:contentWidth + 2*paddingPx = 纸张宽度像素
@@ -63,7 +23,7 @@ export declare class _Browser_KeyedWindowManager {
63
23
  * paperHeightPx: number; // 纸张总高度(px)
64
24
  * }
65
25
  */
66
- export declare function _Browser_CalculatePrintableArea(type: PaperType, padding: number): {
26
+ export declare function _Browser_CalculatePrintableArea(type: PaperType, padding: number): void | {
67
27
  /** 内容宽度(像素) */
68
28
  contentWidth: number;
69
29
  /** 内容高度(像素) */
@@ -75,3 +35,34 @@ export declare function _Browser_CalculatePrintableArea(type: PaperType, padding
75
35
  /** 纸张高度(像素) */
76
36
  paperHeightPx: number;
77
37
  };
38
+ /** 同源标签页管理器类 */
39
+ export declare class _Browser_SameOriginTabManager {
40
+ /** 初始化完成标志 */
41
+ private static initFinish;
42
+ /** 频道 */
43
+ private static channel;
44
+ /** 等待回执消息时间上限(上限) */
45
+ static timeout: number;
46
+ /**
47
+ * 待处理查询
48
+ * @param key 回执消息key
49
+ * @param callback 匹配标签页的回调函数
50
+ */
51
+ private static pendingQueries;
52
+ private constructor();
53
+ /** 初始化标签页管理器 */
54
+ static init(name: string): void;
55
+ /** 设置事件监听器 */
56
+ private static setupEventListeners;
57
+ /** 处理BroadcastChannel消息 */
58
+ private static handleChannelMessage;
59
+ /**
60
+ * 获取已经打开的指定名称的标签页
61
+ * @param name 标签页名称
62
+ */
63
+ static getWindow(name: string): Promise<number>;
64
+ /** 打开标签页 */
65
+ static openWindow(name: string, url: string, target?: WindowTarget, windowFeatures?: string): Promise<Window | null>;
66
+ /** 获取所有已经打开的标签页 */
67
+ static getAllWindows(): Promise<string[]>;
68
+ }
@@ -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;
@@ -2,6 +2,7 @@ import { default as _Canvas } from '../..';
2
2
  import { OverlayType } from '../index';
3
3
  import { EventHandler, default as EventController } from '../../public/eventController';
4
4
  import { _Type_DeepPartial } from '../../..';
5
+ import { BaseLineStyle, PointStyleType } from '../../common.type';
5
6
  type ConstructorOption<T, V> = ConstructorParameters<typeof EventController>[0] & {
6
7
  /** 样式 */
7
8
  style?: _Type_DeepPartial<T> | string;
@@ -12,7 +13,7 @@ type ConstructorOption<T, V> = ConstructorParameters<typeof EventController>[0]
12
13
  /** 动态点位 */
13
14
  dynamicPosition?: V;
14
15
  /** 坐标轴上的值 */
15
- value?: V;
16
+ value: V;
16
17
  /** 偏移 */
17
18
  offset?: {
18
19
  x: number;
@@ -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>[];
@@ -3,8 +3,11 @@ import { _Type_DeepPartial } from '../..';
3
3
  export default class Axis {
4
4
  /** 画布 */
5
5
  private canvas;
6
+ /** 轴画布 */
6
7
  private axis_canvas;
8
+ /** 轴画布上下文 */
7
9
  private ctx;
10
+ /** 是否重新绘制轴 */
8
11
  private isReload;
9
12
  /** 网格开关 */
10
13
  show: {
@@ -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;
@@ -9,7 +9,6 @@ export default class Draw extends Style {
9
9
  currentDrawOverlays: OverlayType[];
10
10
  /** 计算坐标所需依赖 */
11
11
  private rely;
12
- private isResizeObserverFirstRun;
13
12
  constructor(option: ConstructorOption);
14
13
  /** 更新 计算坐标所需依赖 */
15
14
  private updateRely;
@@ -4,6 +4,7 @@ import { default as Event } from './event';
4
4
  import { default as OverlayGroup, OverlayType } from '../OverlayGroup';
5
5
  import { default as LayerGroup } from '../LayerGroup';
6
6
  import { default as Layer } from '../LayerGroup/layer';
7
+ import { KnownStyleKeys, StyleType } from '../common.type';
7
8
  type NodeType = LayerGroup | Layer | OverlayGroup | OverlayType;
8
9
  type SingleOrArray<T> = T | T[];
9
10
  declare class QuickMethod_Get extends Event {
@@ -1,4 +1,5 @@
1
1
  import { _Type_DeepPartial } from '../..';
2
+ import { KnownStyleKeys, StyleType } from '../common.type';
2
3
  import { default as BaseData } from './basedata';
3
4
  type ConstructorOption = ConstructorParameters<typeof BaseData>[0] & {
4
5
  theme?: KnownStyleKeys;
@@ -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
  /** 轴线显示属性 */
@@ -58,7 +58,7 @@ export declare function _Element_IsFullscreen(element?: HTMLElement | string): b
58
58
  * @param {HTMLElement} content - 需要进入全屏的元素
59
59
  * 该函数通过检查不同浏览器的特定方法来实现全屏切换
60
60
  */
61
- export declare function _Element_Fullscreen(element?: HTMLElement | string): () => void;
61
+ export declare function _Element_Fullscreen(element?: HTMLElement | string): (() => void) | undefined;
62
62
  /**
63
63
  * 元素全屏状态观察器
64
64
  * 监听元素的全屏状态变化,并通过回调函数通知状态改变
@@ -66,7 +66,7 @@ export declare function _Element_Fullscreen(element?: HTMLElement | string): ()
66
66
  * @param selectors - 要观察的元素或元素选择器,默认为document.documentElement
67
67
  * @returns 返回一个清理函数,调用后可移除所有事件监听器
68
68
  */
69
- export declare function _Element_FullscreenObserver(notify: (isFull: boolean) => void, selectors?: HTMLElement | string): () => void;
69
+ export declare function _Element_FullscreenObserver(notify: (isFull: boolean) => void, selectors?: HTMLElement | string): (() => void) | undefined;
70
70
  /**
71
71
  * 单位转换 12** -> **px
72
72
  * @param {string} width
@@ -84,7 +84,7 @@ declare const UnitConfigs: readonly [readonly ["年", number], readonly ["月",
84
84
  type UnitName = (typeof UnitConfigs)[number][0];
85
85
  /**
86
86
  * 格式化毫秒数为易读的时间单位(基于固定换算规则)
87
- * @param ms 待格式化的毫秒数(需为非负整数)
87
+ * @param ms 待格式化的毫秒数(需为非负数)
88
88
  * @param maxUnit 最大单位限制(可选,如传入"天"则最大只显示到天,不显示年/月/周)
89
89
  * 可选值:"年"|"月"|"周"|"天"|"时"|"分"|"秒"|"毫秒"
90
90
  * @returns 格式化后的时间字符串(如 1.3秒、300毫秒、1,234年)
@@ -97,7 +97,7 @@ type UnitName = (typeof UnitConfigs)[number][0];
97
97
  * - 自动匹配不超过最大单位限制的最优单位(数值≥单位阈值时使用该单位)
98
98
  * - 非整数数值保留1位小数(如1.3秒),整数自动去除末尾.0(如1秒而非1.0秒)
99
99
  * - "年"单位数值会自动应用千分位格式化(如1,234年)
100
- * 3. 输入校验:非整数或负数会返回"0毫秒"
100
+ * 3. 输入校验:负数会返回"0毫秒"
101
101
  */
102
102
  export declare function _Format_MillisecondToReadable(ms: number, maxUnit?: UnitName): string;
103
103
  /**
@@ -3,14 +3,14 @@
3
3
  * @param callback 需执行的方法
4
4
  * @param timeout 超时时间
5
5
  */
6
- export declare function _Utility_ExecuteWhenIdle(callback: Function, timeout?: number): void;
6
+ export declare function _Utility_ExecuteWhenIdle(callback: (deadline?: IdleDeadline) => void, timeout?: number): void;
7
7
  /**
8
8
  * 等待条件满足
9
9
  * @param conditionChecker 条件检查器
10
10
  * @param timeoutMillis 超时毫秒数
11
- * @returns Promise<unknown>
11
+ * @returns Promise<number> 耗时
12
12
  */
13
- export declare function _Utility_WaitForCondition(conditionChecker: () => boolean, timeoutMillis: number): Promise<"完成" | "超时">;
13
+ export declare function _Utility_WaitForCondition(conditionChecker: () => boolean, timeoutMillis: number): Promise<number>;
14
14
  /**
15
15
  * 合并对象 注意: 本函数会直接操作 A
16
16
  * @param {Object | Array} A
@@ -74,12 +74,22 @@ export declare function _Utility_RotateList<T>(list: T[]): T[][];
74
74
  */
75
75
  export declare function _Utility_Clone<T>(val: T): T;
76
76
  /**
77
- * 函数装饰器,用于测量并记录另一个函数的执行时间
78
- * @param func 要测量执行时间的函数
79
- * @param level 耗时与颜色对应的数组,用于在控制台中着色显示
80
- * @param maxHistory 保留的最大历史记录数,默认为30
77
+ * 函数装饰器:精准测量并记录目标函数的执行耗时(单位:毫秒)
78
+ *
79
+ * @template T - 泛型参数,约束为任意函数类型,保证装饰器返回值类型与原函数一致
80
+ * @param {T} func - 待测量执行时间的目标函数
81
+ * @param {Object} [config] - 可选配置对象,用于自定义耗时测量规则
82
+ * @param {Array<[number, string]>} [config.level] - 耗时阈值(毫秒)与控制台输出颜色的映射数组
83
+ * 规则:当函数耗时(ms)≥ level[n][0] 时,使用 level[n][1] 指定的颜色输出
84
+ * @param {number} [config.maxHistory=30] - 执行耗时历史记录的最大保留条数,默认值为30
85
+ * @param {string} [config.prefix] - 控制台输出耗时日志时的自定义前缀文本(可选)
86
+ * @returns {T | void} 包装后的函数(保留原函数所有功能,新增耗时测量/记录/日志输出逻辑);若入参非法则返回 void
81
87
  */
82
- export declare function _Utility_TimeConsumption(func: Function, level: [number, string][], maxHistory?: number): void | ((...args: any[]) => any);
88
+ export declare function _Utility_TimeConsumption<T extends Function>(func: T, config?: {
89
+ level?: [number, string][];
90
+ maxHistory?: number;
91
+ prefix?: string;
92
+ }): T | void;
83
93
  /**
84
94
  * 暂停执行指定毫秒数的操作
85
95
  * 此函数通过 busy-wait(忙等待)的方式实现,它会持续执行一些无用的操作以消耗时间
@@ -91,7 +91,7 @@ export declare class _Valid_FileTypeChecker {
91
91
  static parseAddresses(url: string): {
92
92
  url: string;
93
93
  name: string;
94
- type: "audio" | "code" | "script" | "video" | "text" | "image" | "ppt" | "word" | "excel" | "pdf" | "archive" | "font" | "database" | "markup" | "configuration" | "logs" | "unknown";
94
+ type: "image" | "ppt" | "word" | "excel" | "pdf" | "text" | "audio" | "video" | "archive" | "code" | "font" | "database" | "markup" | "configuration" | "logs" | "script" | "unknown";
95
95
  }[];
96
96
  /**
97
97
  * 检查 MIME 类型是否与指定的模式匹配
@@ -121,5 +121,5 @@ export declare class _Valid_FileTypeChecker {
121
121
  * @param {string} url - 文件的URL
122
122
  * @returns {string} - 如果URL与任何已知类型匹配,则返回文件类型,否则返回"unknown"
123
123
  */
124
- static _detectFileType(url: string): "audio" | "code" | "script" | "video" | "text" | "image" | "ppt" | "word" | "excel" | "pdf" | "archive" | "font" | "database" | "markup" | "configuration" | "logs" | "unknown";
124
+ static _detectFileType(url: string): "image" | "ppt" | "word" | "excel" | "pdf" | "text" | "audio" | "video" | "archive" | "code" | "font" | "database" | "markup" | "configuration" | "logs" | "script" | "unknown";
125
125
  }