nhanh-pure-function 3.0.6-beta.12 → 3.0.6-beta.14

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,66 +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 Get_KeyedWindowManager: symbol;
22
- /**
23
- * 初始化
24
- * @param name 窗口名称
25
- */
26
- static init(name: string): void;
27
- /**
28
- * 更新窗口管理器
29
- * @param self 最新实例
30
- */
31
- static update(self: typeof _Browser_KeyedWindowManager): void;
32
- /**
33
- * 通知所有窗口 同步所以可访问的窗口
34
- */
35
- static notify(): void;
36
- /**
37
- * 检查窗口的 opener 是否与当前页面同源
38
- * @param win 窗口对象
39
- * @returns 如果 opener 与当前页面同源则返回true,否则返回false
40
- */
41
- static isSameOrigin(url?: string | URL): boolean | "" | undefined;
42
- /**
43
- * 根据键打开或聚焦窗口
44
- * @param key 窗口的唯一键
45
- * @param url 要打开的URL
46
- * @param target 窗口的目标
47
- * @param windowFeatures 新窗口的特性
48
- * @returns 返回已打开或新打开的窗口
49
- */
50
- static open(key: string, url?: string | URL, target?: WindowTarget, windowFeatures?: string): void | Window;
51
- /**
52
- * 检查指定键的窗口是否打开
53
- * @param key 窗口的唯一键
54
- * @returns 如果窗口打开则返回true,否则返回false
55
- */
56
- static isOpen(key: string): boolean;
57
- /**
58
- * 获取与指定键关联的窗口
59
- * @param key 窗口的唯一键
60
- * @returns 返回对应的窗口,如果窗口已关闭则返回undefined
61
- */
62
- static getWindow(key: string): Window | undefined;
63
- /**
64
- * 关闭与指定键关联的窗口
65
- * @param key 窗口的唯一键
66
- */
67
- static close(key: string): void;
68
- /**
69
- * 关闭所有打开的窗口并清空Map
70
- */
71
- static closeAll(): void;
72
- }
73
13
  /**
74
14
  * 计算纸张内容可用宽高及边距(考虑设备DPI)
75
15
  * 确保:contentWidth + 2*paddingPx = 纸张宽度像素
@@ -95,3 +35,34 @@ export declare function _Browser_CalculatePrintableArea(type: PaperType, padding
95
35
  /** 纸张高度(像素) */
96
36
  paperHeightPx: number;
97
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
+ }
@@ -3,7 +3,7 @@
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 条件检查器
@@ -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(忙等待)的方式实现,它会持续执行一些无用的操作以消耗时间