hortimagic 1.0.3 → 1.0.5

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.
package/dist/index.d.ts CHANGED
@@ -4,12 +4,13 @@
4
4
  /// <reference path="../src/components/type.d.ts"/>
5
5
  import { CSSResult } from 'lit';
6
6
  import { LitElement } from 'lit';
7
+ import { proxy } from 'valtio/vanilla';
8
+ import { snapshot } from 'valtio/vanilla';
9
+ import { subscribe } from 'valtio/vanilla';
7
10
  import { TemplateResult } from 'lit-html';
8
- import { TinyEmitter } from 'tiny-emitter';
9
11
 
10
- /**
11
- * 向列表加入一个脚本,具有唯一性,名字或链接一样的话就覆盖
12
- * @param script 要添加的脚本对象
12
+ /** 添加脚本到列表
13
+ * @param script 脚本对象
13
14
  * @returns 是否添加成功
14
15
  */
15
16
  declare function addScriptToList(script: Script): boolean;
@@ -24,20 +25,10 @@ declare function afterOnmessage(message: string): Promise<string>;
24
25
 
25
26
  declare function afterSend(message: string): string;
26
27
 
27
- export declare namespace app_tools {
28
- export {
29
- notice,
30
- confirm_2 as confirm
31
- }
32
- }
33
-
34
28
  declare namespace apps {
35
29
  export {
36
30
  main_app,
37
- example_app,
38
- dialog_app,
39
- script_app,
40
- app_tools
31
+ dialog_app
41
32
  }
42
33
  }
43
34
  export { apps }
@@ -52,6 +43,8 @@ declare function beforeSend(message: string): Promise<string | null>;
52
43
  */
53
44
  declare function changeRoom(roomId: string): void;
54
45
 
46
+ declare function clearScriptList(): void;
47
+
55
48
  declare namespace components {
56
49
  export {
57
50
  hm_move_panel,
@@ -60,6 +53,7 @@ declare namespace components {
60
53
  hm_notification,
61
54
  hm_button,
62
55
  hm_cell,
56
+ hm_select,
63
57
  hm_swipe_cell,
64
58
  hm_switch,
65
59
  hm_accordion,
@@ -90,42 +84,47 @@ declare function compressHTML(html: string): string;
90
84
  * @param cancelCallback 选择取消时的回调函数
91
85
  * @param closeCallback 关闭弹窗时的回调函数
92
86
  * @example ```javascript
93
- * hortimagic.apps.app_tools.confirm('hhhhhhhhhhhhhh',()=>{console.log('qqqqqqqqqqq')},()=>{console.log('cccccccccccc')})
87
+ * hortimagic.easy_tools.confirm('hhhhhhhhhhhhhh',()=>{console.log('qqqqqqqqqqq')},()=>{console.log('cccccccccccc')})
94
88
  * ```
95
89
  */
96
90
  declare function confirm_2(message: string, confirmCallback?: Function, cancelCallback?: Function, closeCallback?: Function): void;
91
+ export { confirm_2 as confirm }
97
92
 
98
93
  declare namespace core {
99
94
  export {
100
95
  tools,
101
- iirose_socket,
102
- event_emitter,
103
96
  Message,
97
+ socket_tools,
104
98
  encoder,
105
99
  decoder,
106
100
  elements_hooks,
101
+ Emitter,
102
+ log_tools,
103
+ store,
107
104
  script_tools
108
105
  }
109
106
  }
110
107
  export { core }
111
108
 
109
+ /**
110
+ * 弹幕消息类
111
+ * 用于表示弹幕类型的消息
112
+ */
112
113
  declare class Danmu {
113
- /** */
114
+ /** 用户名 */
114
115
  username: string;
115
- /** */
116
+ /** 头像链接 */
116
117
  avatar: string;
117
- /** */
118
+ /** 消息 */
118
119
  message: string;
119
- /** */
120
+ /** 消息颜色 */
120
121
  color: string;
121
- /** */
122
+ /** 性别 */
122
123
  gender: string;
123
- /** */
124
+ /** 时间戳 */
124
125
  timeStamp: string;
125
- /** */
126
+ /** 唯一id */
126
127
  uid: string;
127
- /** 消息类型 */
128
- readonly messageClass = "danmu";
129
128
  }
130
129
 
131
130
  /**
@@ -137,12 +136,17 @@ declare class Danmu {
137
136
  */
138
137
  declare function danmu(message: string, color: string, v?: string): string;
139
138
 
139
+ /**
140
+ * 解析消息字符串并将对应的消息对象添加到消息列表中
141
+ * @param message 原消息字符串
142
+ */
140
143
  declare function decodeMessage(message: string): void;
141
144
 
142
- declare namespace decoder {
145
+ export declare namespace decoder {
143
146
  export {
144
- messageObjList,
145
- decodeMessage
147
+ judegMessageClass,
148
+ decodeMessage,
149
+ messageObjList
146
150
  }
147
151
  }
148
152
 
@@ -155,16 +159,28 @@ export declare namespace dialog {
155
159
 
156
160
  export declare namespace dialog_app {
157
161
  export {
158
- dialogApp,
159
- initDialogApp
162
+ initDialogApp,
163
+ HmDialogApp,
164
+ dialogApp
160
165
  }
161
166
  }
162
167
 
163
- declare let dialogApp: HmDialogApp;
168
+ /**
169
+ * 默认的对话框模块
170
+ */
171
+ declare const dialogApp: HmDialogApp;
164
172
 
165
- /** 移动面板容器 */
173
+ /** 弹窗容器 */
166
174
  declare let dialogHolder: HTMLDivElement;
167
175
 
176
+ declare namespace easy_tools {
177
+ export {
178
+ confirm_2 as confirm,
179
+ notice
180
+ }
181
+ }
182
+ export { easy_tools }
183
+
168
184
  /** 原来界面的元素 */
169
185
  declare let elements: {
170
186
  /** 移动窗口父元素,移动窗口容器 */
@@ -189,21 +205,80 @@ declare let elements: {
189
205
  moveinputSendBtnSend: Element | null;
190
206
  };
191
207
 
192
- declare namespace elements_hooks {
208
+ export declare namespace elements_hooks {
193
209
  export {
194
- elements,
195
210
  refreshAll,
196
- Hooks,
197
- initHooks
211
+ initHooks,
212
+ elements,
213
+ Hooks
198
214
  }
199
215
  }
200
216
 
201
217
  /**
202
- * 事件触发器
218
+ * Emitter 类提供事件驱动的编程模式,允许对象间通过事件进行通信
219
+ * 支持事件监听、取消监听、一次性监听和事件触发功能
203
220
  */
204
- declare let emitter: TinyEmitter;
221
+ declare class Emitter {
222
+ /**
223
+ * 存储事件名称和对应监听器数组的映射
224
+ * @private
225
+ */
226
+ private events;
227
+ /**
228
+ * 为指定事件添加监听器
229
+ * @param eventName 事件名称
230
+ * @param listener 事件触发时要调用的回调函数
231
+ * @example
232
+ * ```ts
233
+ * const emitter = new Emitter();
234
+ * emitter.on('test', (data) => console.log('接收到数据:', data));
235
+ * emitter.emit('test', { message: 'Hello' }); // 输出: 接收到数据: { message: 'Hello' }
236
+ * ```
237
+ */
238
+ on(eventName: string, listener: Listener): void;
239
+ /**
240
+ * 移除指定事件的监听器
241
+ * @param eventName 事件名称
242
+ * @param listener 要移除的监听器函数,如果未提供则移除该事件的所有监听器
243
+ * @example
244
+ * ```ts
245
+ * const emitter = new Emitter();
246
+ * const listener = (data) => console.log(data);
247
+ * emitter.on('test', listener);
248
+ * emitter.off('test', listener); // 移除特定监听器
249
+ * emitter.off('test'); // 移除所有 'test' 事件的监听器
250
+ * ```
251
+ */
252
+ off(eventName: string, listener?: Listener): void;
253
+ /**
254
+ * 为指定事件添加一次性监听器,监听器在第一次触发后将被移除
255
+ * @param eventName 事件名称
256
+ * @param listener 事件触发时要调用的回调函数,只执行一次
257
+ * @example
258
+ * ```ts
259
+ * const emitter = new Emitter();
260
+ * emitter.once('start', () => console.log('仅执行一次'));
261
+ * emitter.emit('start'); // 输出: 仅执行一次
262
+ * emitter.emit('start'); // 没有输出,因为监听器已被移除
263
+ * ```
264
+ */
265
+ once(eventName: string, listener: Listener): void;
266
+ /**
267
+ * 触发指定事件,并传递参数给监听器
268
+ * @param eventName 事件名称
269
+ * @param args 传递给监听器的参数
270
+ * @returns 如果至少有一个监听器被调用则返回 true,否则返回 false
271
+ * @example
272
+ * ```ts
273
+ * const emitter = new Emitter();
274
+ * emitter.on('greet', (name, age) => console.log(`你好 ${name}, 你 ${age} 岁了`));
275
+ * emitter.emit('greet', '小明', 25); // 输出: 你好 小明, 你 25 岁了
276
+ * ```
277
+ */
278
+ emit(eventName: string, ...args: any[]): boolean;
279
+ }
205
280
 
206
- declare namespace encoder {
281
+ export declare namespace encoder {
207
282
  export {
208
283
  publicChat,
209
284
  privateChat,
@@ -217,18 +292,9 @@ declare namespace encoder {
217
292
  }
218
293
  }
219
294
 
220
- declare namespace event_emitter {
221
- export {
222
- TinyEmitter,
223
- emitter
224
- }
225
- }
295
+ declare function findScriptByName(name: string): number;
226
296
 
227
- export declare namespace example_app {
228
- export {
229
- initExampleApp
230
- }
231
- }
297
+ declare function findScriptByUrl(url: string): number;
232
298
 
233
299
  /**
234
300
  * 创造一个新的私聊气泡,搭配静默发送私聊消息才能和“正常一样使用。
@@ -251,6 +317,7 @@ declare function getAllOnlineUserInfo(): {
251
317
  personalizedSignature: any;
252
318
  }[] | null;
253
319
 
320
+ /** 获取svg代码 */
254
321
  declare function getIcon(name: string): string;
255
322
 
256
323
  /**
@@ -304,18 +371,16 @@ declare function getUserInputColor(): string | null;
304
371
  */
305
372
  declare function getUserName(): string | null;
306
373
 
307
- /**
308
- * 获取用户蔷薇头像url
309
- * @returns {string}
310
- */
311
- declare function getUserProfilePictureUrl(): string | null;
312
-
313
374
  /**
314
375
  * 获取当前用户的UID
315
376
  * @returns 返回当前用户的UID,没找到返回null
316
377
  */
317
378
  declare function getUserUid(): string | null;
318
379
 
380
+ /**
381
+ * 隐藏消息类
382
+ * 用于表示隐藏类型的消息
383
+ */
319
384
  declare class Hidden {
320
385
  /** 消息的标题,名字?主题 */
321
386
  messageName: string;
@@ -323,8 +388,6 @@ declare class Hidden {
323
388
  uid: string;
324
389
  /** 数据 */
325
390
  data: string;
326
- /** 消息类型 */
327
- readonly messageClass = "hidden";
328
391
  }
329
392
 
330
393
  /**
@@ -364,6 +427,7 @@ export declare namespace hm_icon {
364
427
  export {
365
428
  registerIcon,
366
429
  getIcon,
430
+ iconMap,
367
431
  HmIcon
368
432
  }
369
433
  }
@@ -394,6 +458,12 @@ export declare namespace hm_notification {
394
458
  }
395
459
  }
396
460
 
461
+ export declare namespace hm_select {
462
+ export {
463
+ HmSelect
464
+ }
465
+ }
466
+
397
467
  export declare namespace hm_swipe_cell {
398
468
  export {
399
469
  HmSwipeCell
@@ -407,8 +477,10 @@ export declare namespace hm_switch {
407
477
  }
408
478
 
409
479
  /**
480
+ * 折叠面板
410
481
  * @example
411
- * <hm-accordion>
482
+ * <hm-accordion title-content="标题内容"></hm-accordion>
483
+ * <hm-accordion>
412
484
  <span slot="header">我的折叠面板</span>
413
485
  <div>内容项 1</div>
414
486
  <div>内容项 2</div>
@@ -416,7 +488,10 @@ export declare namespace hm_switch {
416
488
  */
417
489
  declare class HmAccordion extends LitElement {
418
490
  maxHeight: string;
491
+ /** 折叠项 */
419
492
  items: any[];
493
+ /** 标题内容 */
494
+ titleContent: string;
420
495
  /** 是否展开 */
421
496
  expanded: boolean;
422
497
  static styles: CSSResult;
@@ -489,36 +564,7 @@ declare class HmButton extends LitElement {
489
564
  * @cssprop --hm-cell-background - 背景颜色
490
565
  *
491
566
  * @example
492
- * ```html
493
- * <!-- 基础用法 -->
494
- * <hm-cell
495
- * titleName="单元格标题"
496
- * descripthion="这是描述信息"
497
- * content="内容区域">
498
- * </hm-cell>
499
- *
500
- * <!-- 使用插槽自定义内容 -->
501
- * <hm-cell>
502
- * <div slot="title">自定义标题</div>
503
- * <div slot="description">自定义描述</div>
504
- * <div slot="content">自定义内容</div>
505
- * </hm-cell>
506
- *
507
- * <!-- 带点击事件 -->
508
- * <hm-cell
509
- * titleName="可点击标题"
510
- * content="点击查看详情"
511
- * .titleClickCallback="${() => console.log('标题被点击')}"
512
- * .contentClickCallback="${() => console.log('内容被点击')}">
513
- * </hm-cell>
514
- *
515
- * <!-- 自定义样式 -->
516
- * <hm-cell
517
- * titleName="自定义样式"
518
- * content="特殊样式"
519
- * style="--hm-cell-background: #f0f8ff; --hm-cell-title-color: #1890ff;">
520
- * </hm-cell>
521
- * ```
567
+ * <hm-cell title-name="标题" descripthion="描述信息" content="内容"></hm-cell>
522
568
  */
523
569
  declare class HmCell extends LitElement {
524
570
  /** 标题,使用slot后失效 */
@@ -566,6 +612,10 @@ declare class HmDialog extends LitElement {
566
612
  render(): TemplateResult<1>;
567
613
  }
568
614
 
615
+ /**
616
+ * 对话框模块
617
+ * @slot - 默认slot
618
+ */
569
619
  declare class HmDialogApp extends LitElement {
570
620
  dialogOpen: boolean;
571
621
  message: string;
@@ -578,7 +628,15 @@ declare class HmDialogApp extends LitElement {
578
628
  render(): TemplateResult<1>;
579
629
  }
580
630
 
631
+ /** 图标组件
632
+ * @example
633
+ * <hm-icon icon="magic-wand"></hm-icon>
634
+ * <hm-icon icon="close"></hm-icon>
635
+ * <hm-icon icon="open"></hm-icon>
636
+ * <hm-icon icon="arrow-up"></hm-icon>
637
+ */
581
638
  declare class HmIcon extends LitElement {
639
+ /** 图标名称 */
582
640
  icon: string;
583
641
  size: string;
584
642
  /** 触发点击事件 */
@@ -619,9 +677,13 @@ declare class HmInput extends LitElement {
619
677
  }
620
678
 
621
679
  declare class HmMenu extends LitElement {
680
+ /** 图标 */
622
681
  icon: string;
682
+ /** 内容 */
623
683
  content: string;
684
+ /** 标记 */
624
685
  flag: boolean;
686
+ /** 是否是菜单项(二级菜单) */
625
687
  isMenuItem: boolean;
626
688
  static styles: CSSResult;
627
689
  /** 触发点击事件 */
@@ -640,25 +702,25 @@ declare class HmMovePanel extends LitElement {
640
702
  bodyBackgroundColor: string;
641
703
  bodyColor: string;
642
704
  footerBackgroundColor: string;
643
- buttonBackgroundColor: string;
705
+ /** 按钮背景 */
706
+ buttonBackground: string;
707
+ /** 按钮文字色 */
644
708
  buttonColor: string;
645
709
  /** 标题 */
646
710
  titleContent: string;
647
711
  leftButtonText: string;
648
712
  rightButtonText: string;
649
- /** 显示状态,不建议直接修改,请使用show()和hide()方法,否则无法触发对应事件 */
713
+ /** 显示状态,不建议直接修改,请使用showMovePanel()和hideMovePanel()方法,否则无法触发对应事件 */
650
714
  isDisplay: boolean;
651
715
  zIndex: number;
652
716
  /** 左上角图标 */
653
717
  icon: string;
718
+ /** 左下角图标 */
719
+ leftIcon: string;
720
+ /** 右下角图标 */
721
+ rightIcon: string;
654
722
  left: number;
655
723
  top: number;
656
- handleLeftClick(): void;
657
- handleRightClick(): void;
658
- /**
659
- * 组件内部的body元素
660
- */
661
- body: Promise<HTMLDivElement>;
662
724
  static styles: CSSResult;
663
725
  constructor();
664
726
  /** 关闭移动窗口 */
@@ -680,8 +742,8 @@ declare class HmMovePanel extends LitElement {
680
742
  putTopToggel(): void;
681
743
  render(): TemplateResult<1>;
682
744
  _handleClose(): void;
683
- _handleLeftButtonClick(): void;
684
- _handleRightButtonClick(): void;
745
+ handleLeftButtonClick(): void;
746
+ handleRightButtonClick(): void;
685
747
  }
686
748
 
687
749
  /** 通知消息组件
@@ -728,6 +790,80 @@ declare class HmNotification extends LitElement {
728
790
  render(): TemplateResult<1>;
729
791
  }
730
792
 
793
+ /**
794
+ * HmSelect 是一个可自定义的下拉选择组件,基于 LitElement 构建
795
+ *
796
+ * @example
797
+ * 基本用法:
798
+ * ```html
799
+ * <hm-select .labelList="${[['选项1', 'value1'], ['选项2', 'value2']]}" @change="${(e) => logger.log('hm-select',e.detail)}"></hm-select>
800
+ * ```
801
+ *
802
+ * @example
803
+ * 禁用状态:
804
+ * ```html
805
+ * <hm-select .labelList="${[['选项1', 'value1'], ['选项2', 'value2']]}" disabled></hm-select>
806
+ * ```
807
+ *
808
+ * @example
809
+ * 带默认选中项:
810
+ * ```html
811
+ * <hm-select .labelList="${[['选项1', 'value1'], ['选项2', 'value2']]}" .index="${1}"></hm-select>
812
+ * ```
813
+ *
814
+ * @example
815
+ * 使用数字值:
816
+ * ```html
817
+ * <hm-select .labelList="${[['一', 1], ['二', 2], ['三', 3]]}" .index="${0}"></hm-select>
818
+ * ```
819
+ *
820
+ * @slot - 默认插槽,用于放置额外内容
821
+ * @fires change - 当选择项改变时触发,携带 { value, label, index } 信息
822
+ */
823
+ declare class HmSelect extends LitElement {
824
+ /**
825
+ * 当前选中项的索引,默认为 0
826
+ * @type {number}
827
+ */
828
+ index: number;
829
+ /**
830
+ * 当前选中项的值
831
+ * @type {any}
832
+ */
833
+ value: any;
834
+ /**
835
+ * 选择项列表,每个项为 [label, value] 的数组格式
836
+ * @type {Array<Array<string | any>>}
837
+ */
838
+ labelList: (string | any)[][];
839
+ /**
840
+ * 是否禁用选择器
841
+ * @type {boolean}
842
+ */
843
+ disabled: boolean;
844
+ private selectRef;
845
+ static styles: CSSResult;
846
+ constructor();
847
+ connectedCallback(): void;
848
+ render(): TemplateResult<1>;
849
+ /**
850
+ * 处理选择项改变事件
851
+ * @param {Event} e - change 事件
852
+ * @private
853
+ */
854
+ private _handleChange;
855
+ /**
856
+ * 获取当前选中的值
857
+ * @returns {any} 当前选中的值,返回labelList中对应项的实际值类型
858
+ */
859
+ getValue(): any;
860
+ /**
861
+ * 设置选中值
862
+ * @param {any} value - 要设置的值,可以是字符串或数字等类型
863
+ */
864
+ setValue(value: any): void;
865
+ }
866
+
731
867
  /**
732
868
  * 滑动单元格组件
733
869
  * 实现左右滑动显示操作按钮的交互效果
@@ -811,7 +947,7 @@ declare class HmSwipeCell extends LitElement {
811
947
  * <hm-switch openIcon="check" closeIcon="close"></hm-switch>
812
948
  *
813
949
  * <!-- 监听状态变化 -->
814
- * <hm-switch @hm-switch-change="${(e) => console.log('开关状态:', e.detail.checked)}"></hm-switch>
950
+ * <hm-switch @hm-switch-change="${(e) => logger.log('hm-switch','开关状态:', e.detail.checked)}"></hm-switch>
815
951
  * ```
816
952
  */
817
953
  declare class HmSwitch extends LitElement {
@@ -868,6 +1004,33 @@ declare let Hooks: {
868
1004
  replaceButtonProcesser: () => void;
869
1005
  };
870
1006
 
1007
+ /**
1008
+ * hortiMagicStore存储库
1009
+ */
1010
+ declare const HortimagicStore: {
1011
+ /** 是否自动保存 */
1012
+ autoSave: boolean;
1013
+ /** 日志是否开启 */
1014
+ logFlag: {
1015
+ log: boolean;
1016
+ info: boolean;
1017
+ debug: boolean;
1018
+ warn: boolean;
1019
+ error: boolean;
1020
+ };
1021
+ /** 消息日志是否开启 */
1022
+ messageLogFlag: {
1023
+ send: boolean;
1024
+ decode: boolean;
1025
+ emit: boolean;
1026
+ receive: boolean;
1027
+ };
1028
+ /** 日志列表最大长度 */
1029
+ logListLength: number;
1030
+ /** 脚本列表 */
1031
+ scriptList: Script[];
1032
+ };
1033
+
871
1034
  /**
872
1035
  * html特殊符号反转义
873
1036
  * @param {string} e
@@ -882,12 +1045,14 @@ declare function htmlSpecialCharsDecode(e: string): string;
882
1045
  */
883
1046
  declare function htmlSpecialCharsEscape(e: string): string;
884
1047
 
885
- declare namespace iirose_socket {
886
- export {
887
- sockets,
888
- initSocket
889
- }
890
- }
1048
+ /** 存储图标的map类型数据
1049
+ * key: 图标名称
1050
+ * value: 图标svg代码
1051
+ * 遍历图标名称的方式如下:
1052
+ * @example
1053
+ * for (const [iconName, iconSvg] of iconMap) {}
1054
+ */
1055
+ declare const iconMap: Map<string, string>;
891
1056
 
892
1057
  /** package配置信息 */
893
1058
  export declare const information: {
@@ -914,26 +1079,29 @@ export declare const information: {
914
1079
  ingected: boolean;
915
1080
  };
916
1081
 
917
- /**
918
- * 读取本地脚本列表并注入
1082
+ declare const ingectedUrlList: string[];
1083
+
1084
+ /** 注入脚本,不论它是否使能
1085
+ * @param script 脚本对象
919
1086
  */
920
- declare function ingectlocalScript(): void;
1087
+ declare function ingecteScript(script: Script): boolean;
1088
+
1089
+ declare function ingecteScriptList(): void;
921
1090
 
922
1091
  declare function init(): Promise<void>;
923
1092
 
924
1093
  /** 初始化对话框模块 */
925
1094
  declare function initDialogApp(): Promise<void>;
926
1095
 
927
- /** 初始化移动面板容器 */
1096
+ /** 初始化弹窗容器 */
928
1097
  declare function initDialogHolder(): void;
929
1098
 
930
- declare function initExampleApp(): Promise<HmMenu>;
931
-
932
1099
  /**
933
1100
  * 注入钩子函数
934
1101
  */
935
1102
  declare function initHooks(): void;
936
1103
 
1104
+ /** 初始化菜单容器 */
937
1105
  declare function initMenuHolder(): void;
938
1106
 
939
1107
  /** 初始化移动面板容器 */
@@ -942,21 +1110,15 @@ declare function initMovePanelHolder(): void;
942
1110
  /** 初始化通知容器 */
943
1111
  declare function initNotificationHolder(): void;
944
1112
 
945
- declare function initScriptApp(): Promise<HmMenu>;
946
-
947
1113
  declare function initSocket(): Promise<void>;
948
1114
 
949
- /**
950
- * 注入一个JS脚本
951
- * @param script 要注入的脚本对象
952
- */
953
- declare function injectScript(script: Script): boolean;
1115
+ declare function initStore(): void;
954
1116
 
955
1117
  /**
956
- * 注入一组JS脚本
957
- * @param list 脚本列表
1118
+ * 判断消息类型并返回对应的类型字符串
1119
+ * @param message
958
1120
  */
959
- declare function injectScriptList(list: Script[]): void;
1121
+ declare function judegMessageClass(messageObj: MessageClass): "hidden" | "public" | "private" | "danmu" | "withdrawn" | "system" | "stock" | "unknown";
960
1122
 
961
1123
  /**
962
1124
  * 编码点赞消息
@@ -966,6 +1128,67 @@ declare function injectScriptList(list: Script[]): void;
966
1128
  */
967
1129
  declare function like(targetUid: string, content?: string): string;
968
1130
 
1131
+ /**
1132
+ * 事件监听器类型定义,表示一个可以接收任意参数的函数
1133
+ */
1134
+ declare type Listener = (...args: any[]) => void;
1135
+
1136
+ /**
1137
+ * 加载store
1138
+ */
1139
+ declare function loadStore(): void;
1140
+
1141
+ export declare namespace log_tools {
1142
+ export {
1143
+ logEmitter,
1144
+ logger
1145
+ }
1146
+ }
1147
+
1148
+ /**
1149
+ * 日志事件发射器
1150
+ * 每次日志输出时都会触发'log'事件
1151
+ */
1152
+ declare const logEmitter: Emitter;
1153
+
1154
+ /**
1155
+ * 日志记录器
1156
+ * 根据配置中的日志级别来决定是否输出日志
1157
+ * 只有当配置的日志级别与当前输出的日志级别匹配时才会输出日志
1158
+ */
1159
+ export declare const logger: {
1160
+ /**
1161
+ * 记录普通日志
1162
+ * 只有在配置的日志级小于等于DEBUG时才会输出
1163
+ * @param args 要输出的参数
1164
+ */
1165
+ log(tag: string, ...args: any[]): void;
1166
+ /**
1167
+ * 输出调试日志
1168
+ * 仅在配置的日志级别小于等于DEBUG时才会输出
1169
+ * @param args 要输出的参数
1170
+ */
1171
+ debug(tag: string, ...args: any[]): void;
1172
+ /**
1173
+ * 输出信息日志
1174
+ * 仅在配置的日志级别小于等于INFO时才会输出
1175
+ * @param args 要输出的参数
1176
+ */
1177
+ info(tag: string, ...args: any[]): void;
1178
+ /**
1179
+ * 输出警告日志
1180
+ * 仅在配置的日志级别小于等于WARN时才会输出
1181
+ * @param args 要输出的参数
1182
+ */
1183
+ warn(tag: string, ...args: any[]): void;
1184
+ /**
1185
+ * 输出错误日志
1186
+ * 仅在配置的日志级别小于等于ERROR时才会输出
1187
+ * @param args 要输出的参数
1188
+ */
1189
+ error(tag: string, ...args: any[]): void;
1190
+ };
1191
+
969
1192
  export declare namespace main_app {
970
1193
  export {
971
1194
  init
@@ -979,10 +1202,12 @@ export declare namespace menu {
979
1202
  }
980
1203
  }
981
1204
 
1205
+ /** 菜单容器 */
982
1206
  declare let menuHolder: HTMLDivElement;
983
1207
 
984
- declare namespace Message {
1208
+ export declare namespace Message {
985
1209
  export {
1210
+ MessageClass,
986
1211
  Public,
987
1212
  Private,
988
1213
  Hidden,
@@ -994,8 +1219,16 @@ declare namespace Message {
994
1219
  }
995
1220
  }
996
1221
 
1222
+ /**
1223
+ * 所有消息类型的联合类型
1224
+ * 用于类型检查和类型安全
1225
+ */
1226
+ declare type MessageClass = Public | Private | Hidden | Danmu | Withdrawn | System | Stock | Unkonw;
1227
+
1228
+ declare const messageEmitter: Emitter;
1229
+
997
1230
  /** 解析好后的消息列表 */
998
- declare let messageObjList: (Public | Private | Hidden | Danmu | Withdrawn | System | Stock | Unkonw)[];
1231
+ declare let messageObjList: MessageClass[];
999
1232
 
1000
1233
  export declare namespace move_panel {
1001
1234
  export {
@@ -1026,11 +1259,57 @@ declare function musicCard(typeId: string, title: string, singerName: string, co
1026
1259
 
1027
1260
  /**
1028
1261
  * 消失通知函数
1262
+ * @example
1263
+ * ```javascript
1264
+ * // 显示成功通知
1265
+ * hortimagic.easy_tools.notice.success('操作成功', '您的操作已成功完成');
1266
+ *
1267
+ * // 显示警告通知
1268
+ * hortimagic.easy_tools.notice.warning('警告', '请注意检查输入信息', 5000);
1269
+ *
1270
+ * // 显示错误通知
1271
+ * hortimagic.easy_tools.notice.error('错误', '操作失败,请重试');
1272
+ *
1273
+ * // 显示普通通知
1274
+ * hortimagic.easy_tools.notice.normal('提示', '这是一条普通提示信息');
1275
+ * ```
1029
1276
  */
1030
- declare let notice: {
1277
+ export declare const notice: {
1278
+ /**
1279
+ * 显示成功通知
1280
+ * 创建并显示一个成功状态的通知组件
1281
+ * @param title - 通知的标题文本
1282
+ * @param content - 通知的内容文本
1283
+ * @param displayTime - 通知显示的时间(毫秒),默认为3000毫秒
1284
+ * @returns 无返回值
1285
+ */
1031
1286
  success(title: string, content: string, displayTime?: number): void;
1287
+ /**
1288
+ * 显示警告通知
1289
+ * 创建并显示一个警告状态的通知组件
1290
+ * @param title - 通知的标题文本
1291
+ * @param content - 通知的内容文本
1292
+ * @param displayTime - 通知显示的时间(毫秒),默认为3000毫秒
1293
+ * @returns 无返回值
1294
+ */
1032
1295
  warning(title: string, content: string, displayTime?: number): void;
1296
+ /**
1297
+ * 显示错误通知
1298
+ * 创建并显示一个错误状态的通知组件
1299
+ * @param title - 通知的标题文本
1300
+ * @param content - 通知的内容文本
1301
+ * @param displayTime - 通知显示的时间(毫秒),默认为3000毫秒
1302
+ * @returns 无返回值
1303
+ */
1033
1304
  error(title: string, content: string, displayTime?: number): void;
1305
+ /**
1306
+ * 显示普通通知
1307
+ * 创建并显示一个普通状态的通知组件
1308
+ * @param title - 通知的标题文本
1309
+ * @param content - 通知的内容文本
1310
+ * @param displayTime - 通知显示的时间(毫秒),默认为3000毫秒
1311
+ * @returns 无返回值
1312
+ */
1034
1313
  normal(title: string, content: string, displayTime?: number): void;
1035
1314
  };
1036
1315
 
@@ -1050,6 +1329,10 @@ declare function originalOnmessage(message: string): string;
1050
1329
 
1051
1330
  declare function originalSend(message: string): string;
1052
1331
 
1332
+ /**
1333
+ * 私聊消息类
1334
+ * 用于表示私聊消息
1335
+ */
1053
1336
  declare class Private {
1054
1337
  /** 时间戳 */
1055
1338
  timeStamp: string;
@@ -1067,8 +1350,6 @@ declare class Private {
1067
1350
  uid: string;
1068
1351
  /** 消息唯一标识 */
1069
1352
  messageUid: string;
1070
- /** 消息类型 */
1071
- readonly messageClass = "private";
1072
1353
  }
1073
1354
 
1074
1355
  /**
@@ -1080,6 +1361,10 @@ declare class Private {
1080
1361
  */
1081
1362
  declare function privateChat(uid: string, message: string, color: string): string;
1082
1363
 
1364
+ /**
1365
+ * 公共消息类
1366
+ * 用于表示公共频道中的消息
1367
+ */
1083
1368
  declare class Public {
1084
1369
  /** 时间戳 */
1085
1370
  timeStamp: string;
@@ -1099,8 +1384,6 @@ declare class Public {
1099
1384
  designation: string;
1100
1385
  /** 消息UID */
1101
1386
  messageUid: string;
1102
- /** 消息类别 */
1103
- readonly messageClass = "public";
1104
1387
  }
1105
1388
 
1106
1389
  /**
@@ -1112,30 +1395,68 @@ declare class Public {
1112
1395
  declare function publicChat(message: string, color: string): string;
1113
1396
 
1114
1397
  /**
1115
- * 读取本地存储的脚本列表
1398
+ * 导出valtio响应式状态管理库常用方法
1399
+ * @example
1400
+ * // 创建响应式状态
1401
+ * const state = reactive.proxy({ count: 0 })
1402
+ *
1403
+ * // 订阅状态变化
1404
+ * reactive.subscribe(state, () => {
1405
+ * console.log('state has changed to', state)
1406
+ * })
1407
+ *
1408
+ * // 获取状态快照
1409
+ * const snap = reactive.snapshot(state)
1410
+ *
1411
+ * // 在组件中使用(注意:snapshot返回的是只读快照,不能直接修改)
1412
+ * // 需要通过原始proxy对象进行修改
1413
+ * const updateState = () => {
1414
+ * state.count++ // 直接修改原始proxy对象
1415
+ * }
1416
+ *
1417
+ * // 无React环境使用示例:
1418
+ * // 1. 创建状态
1419
+ * const counterStore = proxy({ count: 0 });
1420
+ *
1421
+ * // 2. 修改状态
1422
+ * counterStore.count++;
1423
+ *
1424
+ * // 3. 获取快照(用于显示)
1425
+ * const snap = snapshot(counterStore);
1426
+ * console.log(snap.count); // 输出当前值
1427
+ *
1428
+ * // 4. 订阅变化
1429
+ * subscribe(counterStore, () => {
1430
+ * console.log('counter changed');
1431
+ * });
1116
1432
  */
1117
- declare function readScriptList(): void;
1433
+ declare const reactive: {
1434
+ proxy: typeof proxy;
1435
+ subscribe: typeof subscribe;
1436
+ /**
1437
+ * 获取快照
1438
+ * @param {object} store
1439
+ * @returns {object} 一个静态的快照
1440
+ */
1441
+ snapshot: typeof snapshot;
1442
+ };
1118
1443
 
1119
1444
  /**
1120
1445
  * 更新一些element
1121
1446
  */
1122
1447
  declare function refreshAll(): void;
1123
1448
 
1449
+ /** 提供静态方法用于外部注册图标 */
1124
1450
  declare function registerIcon(name: string, svgContent: string): void;
1125
1451
 
1126
- /** 从列表中移除一个脚本
1127
- * @param script 要移除的脚本对象
1128
- */
1129
- declare function removeScriptFromList(script: Script): void;
1452
+ declare function removeScriptFromList(script: Script): boolean;
1130
1453
 
1131
1454
  /**
1132
- * 保存脚本列表到本地存储
1455
+ * 保存store
1133
1456
  */
1134
- declare function saveScriptList(): void;
1457
+ declare function saveStore(): void;
1135
1458
 
1136
- /**
1137
- * 脚本类
1138
- */
1459
+ /** 脚本类 */
1139
1460
  declare class Script {
1140
1461
  /** 名字 */
1141
1462
  name: string;
@@ -1143,34 +1464,24 @@ declare class Script {
1143
1464
  url: string;
1144
1465
  /** 是否启用,默认启用 */
1145
1466
  enable: boolean;
1146
- /** 是否已经注入,手动修改 */
1147
- ingected: boolean;
1148
- constructor(name: string, url: string, enable?: boolean, ingected?: boolean);
1467
+ constructor(name: string, url: string, enable?: boolean);
1149
1468
  }
1150
1469
 
1151
- export declare namespace script_app {
1470
+ export declare namespace script_tools {
1152
1471
  export {
1153
- initScriptApp
1154
- }
1155
- }
1156
-
1157
- declare namespace script_tools {
1158
- export {
1159
- Script,
1160
- scriptList,
1161
1472
  addScriptToList,
1473
+ updateScriptInList,
1162
1474
  removeScriptFromList,
1163
- injectScript,
1164
- injectScriptList,
1165
- readScriptList,
1166
- saveScriptList,
1167
- ingectlocalScript
1475
+ findScriptByUrl,
1476
+ findScriptByName,
1477
+ clearScriptList,
1478
+ ingecteScript,
1479
+ ingecteScriptList,
1480
+ ingectedUrlList,
1481
+ Script
1168
1482
  }
1169
1483
  }
1170
1484
 
1171
- /** 脚本列表 */
1172
- declare let scriptList: Script[];
1173
-
1174
1485
  declare function send(message: string): Promise<void>;
1175
1486
 
1176
1487
  /**
@@ -1179,7 +1490,15 @@ declare function send(message: string): Promise<void>;
1179
1490
  */
1180
1491
  declare function sleep(ms: number): Promise<unknown>;
1181
1492
 
1182
- declare const sockets: {
1493
+ export declare namespace socket_tools {
1494
+ export {
1495
+ initSocket,
1496
+ messageEmitter,
1497
+ socketTools
1498
+ }
1499
+ }
1500
+
1501
+ declare const socketTools: {
1183
1502
  beforeSend: typeof beforeSend;
1184
1503
  originalSend: typeof originalSend;
1185
1504
  afterSend: typeof afterSend;
@@ -1191,6 +1510,10 @@ declare const sockets: {
1191
1510
  initSocket: typeof initSocket;
1192
1511
  };
1193
1512
 
1513
+ /**
1514
+ * 股票消息类
1515
+ * 用于表示股票相关数据消息
1516
+ */
1194
1517
  declare class Stock {
1195
1518
  /**
1196
1519
  * '*' 表示股价过低无法买股票
@@ -1209,8 +1532,6 @@ declare class Stock {
1209
1532
  totalEquity: number;
1210
1533
  /** 账户余额 */
1211
1534
  balance: number;
1212
- /** 消息类型 */
1213
- readonly messageClass = "stock";
1214
1535
  }
1215
1536
 
1216
1537
  /**
@@ -1220,20 +1541,32 @@ declare class Stock {
1220
1541
  */
1221
1542
  declare function stockRequest(count: number | undefined): string;
1222
1543
 
1544
+ export declare namespace store {
1545
+ export {
1546
+ saveStore,
1547
+ loadStore,
1548
+ initStore,
1549
+ reactive,
1550
+ HortimagicStore
1551
+ }
1552
+ }
1553
+
1223
1554
  /**
1224
1555
  * 切换房间
1225
1556
  * @param {string} roomId
1226
1557
  */
1227
1558
  declare function switchRoom(roomId: string): void;
1228
1559
 
1560
+ /**
1561
+ * 系统消息类
1562
+ * 用于表示系统通知类消息
1563
+ */
1229
1564
  declare class System {
1230
1565
  /** 消息列表 */
1231
1566
  userMessageList: string[];
1232
- /** 消息类型 */
1233
- readonly messageClass = "system";
1234
1567
  }
1235
1568
 
1236
- declare namespace tools {
1569
+ export declare namespace tools {
1237
1570
  export {
1238
1571
  sleep,
1239
1572
  compressHTML,
@@ -1248,20 +1581,23 @@ declare namespace tools {
1248
1581
  getOnlineUserInfoById,
1249
1582
  getAllOnlineUserInfo,
1250
1583
  changeRoom,
1251
- getUserProfilePictureUrl,
1252
1584
  getUserInputColor,
1253
1585
  generatePrivateMessageBubble,
1254
1586
  switchRoom
1255
1587
  }
1256
1588
  }
1257
1589
 
1590
+ /**
1591
+ * 未知消息类
1592
+ * 用于表示无法识别的消息类型
1593
+ */
1258
1594
  declare class Unkonw {
1259
1595
  /** 未知消息的原型 */
1260
1596
  message: string;
1261
- /** 消息类型 */
1262
- readonly messageClass = "unkonw";
1263
1597
  }
1264
1598
 
1599
+ declare function updateScriptInList(script: Script): boolean;
1600
+
1265
1601
  /**
1266
1602
  * 生成一个视频卡片消息
1267
1603
  * @param typeId 视频平台从0开始
@@ -1273,6 +1609,10 @@ declare class Unkonw {
1273
1609
  */
1274
1610
  declare function videoCard(typeId: string, title: string, singerName: string, coverUrl: string, color: string, resolutionRatio: string, time: string): string;
1275
1611
 
1612
+ /**
1613
+ * 撤回消息类
1614
+ * 用于表示撤回操作的消息
1615
+ */
1276
1616
  declare class Withdrawn {
1277
1617
  /** 可选的,撤回私聊对象窗口的UID */
1278
1618
  privateUID: string;
@@ -1282,8 +1622,6 @@ declare class Withdrawn {
1282
1622
  messageUid: string;
1283
1623
  /** 数据唯一标识,上面两个组合在一起 */
1284
1624
  dataUid: string;
1285
- /** 消息类型 */
1286
- readonly messageClass = "withdrawn";
1287
1625
  }
1288
1626
 
1289
1627
  /**