@zhongguo168a/yxeditor-common 0.0.15 → 0.0.17

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
@@ -1,4 +1,4 @@
1
- import { HorizontalTextAlignment, VerticalTextAlignment, Scheduler, Prefab, Node, Component, ISchedulable, AssetManager, Asset, SpriteAtlas, Vec2, Vec3, Vec4 } from 'cc';
1
+ import { HorizontalTextAlignment, VerticalTextAlignment, Scheduler, Prefab, Node, ISchedulable, AssetManager, Asset, SpriteAtlas, Camera, Canvas, Vec2, Vec3, Vec4, Widget, UITransform, math } from 'cc';
2
2
 
3
3
  interface IError {
4
4
  isCancel(): boolean;
@@ -483,856 +483,858 @@ declare class Route {
483
483
  protected _route: string;
484
484
  }
485
485
 
486
- declare class TreeIterator {
486
+ declare class DictIterator {
487
487
  break(): void;
488
488
  isBreak(): boolean;
489
489
  protected _isBreak: any;
490
490
  }
491
- interface ITreeListItem {
492
- /**
493
- * 路径
494
- */
495
- path: string;
491
+ declare class Dictionary<K = string, V = any> {
492
+ constructor(data?: any);
493
+ reset(data: any): void;
494
+ protected _reset(data: any, size?: number): void;
495
+ getData(): any;
496
496
  /**
497
- * 自定义数据
497
+ * 如果使用了 onSet or onDelete,需要注意清理
498
498
  */
499
- data?: any;
499
+ clear(): void;
500
500
  /**
501
- * 功能性标签,用于开发组件时,记录组件的状态。例如title, icon, 显示树的组件,需要 expanded,selected标签
501
+ * 克隆自身所有项到【target】对象,并返回【target】对象
502
+ * @param target
502
503
  */
503
- tags?: {
504
- [key: string]: any;
505
- };
504
+ clone(target: this): this;
505
+ resetByDict(dict: Dictionary): void;
506
+ onSet(caller: any, handler: (key: K, value: V) => void): void;
507
+ onDelete(caller: any, handler: (key: K, value: V) => void): void;
506
508
  /**
507
- * 是否树叶
509
+ * 设置键值对,如果没有发生变化,不会触发onSet函数
510
+ * @param key
511
+ * @param value
508
512
  */
509
- isLeaf: boolean;
510
- }
511
- declare class TreeNode<T = any> {
512
- get root(): TreeRoot;
513
+ set(key: K, value: V): void;
514
+ private setData;
515
+ setByMap(m: any): void;
516
+ addDictionary(other: Dictionary<K, V>): void;
517
+ deleteDictionary(other: Dictionary<K, V>): void;
513
518
  /**
514
- * 根节点
519
+ * 如果不存在,返回 undefined
520
+ * @param key
515
521
  */
516
- protected _root: TreeRoot;
522
+ get(key: K): V;
523
+ exist(key: K): boolean;
524
+ delete(key: K): void;
525
+ private deleteData;
526
+ exists(key: K): boolean;
527
+ length(): number;
528
+ pop(key: K): [V, boolean];
529
+ isEmpty(): boolean;
530
+ items(): V[];
531
+ keys(): K[];
517
532
  /**
518
- * 编号
533
+ *
534
+ * @param handler 可以使用【iterator】中断遍历
535
+ * @return iterator 获取是否中断了
519
536
  */
520
- uuid: string;
537
+ forEach(handler: (key: K, val: V, iterator: DictIterator) => void): DictIterator;
521
538
  /**
522
- * 编号
523
539
  */
524
- id: string;
540
+ first(): V | undefined;
525
541
  /**
526
- * 自定义数据
542
+ * @param handler 返回true结束迭代
527
543
  */
528
- data: T;
544
+ firstByCondition(handler: (key: K, val: V) => boolean): V | undefined;
529
545
  /**
530
- * 是否树叶
546
+ * 移除符合条件的项
547
+ * @param cond 可以使用【iterator】中断遍历
531
548
  */
532
- isLeaf: boolean;
549
+ removeByCondition(cond: (key: K, val: V, iterator: DictIterator) => boolean): void;
533
550
  /**
534
- * 功能性标签,用于开发组件时,记录组件的状态。例如title, icon, 显示树的组件,需要 expanded,selected标签
551
+ * 查找符合条件的项保存到【target】对象中,并返回【target】对象
552
+ * @param cond 可以使用【iterator】中断遍历
553
+ * @param target 存到目标对象中
535
554
  */
536
- tags: {
555
+ findByCondition(cond: (key: K, val: V, iterator: DictIterator) => boolean, target: Dictionary): this;
556
+ groupByCondition(createKey: (key: K, val: V) => string, ITEM_CLASS?: any): {
537
557
  [key: string]: any;
538
558
  };
559
+ protected size: number;
560
+ private _data;
561
+ private _onSet;
562
+ private _onDelete;
563
+ private _onSetCaller;
564
+ private _onDeleteCaller;
565
+ }
566
+
567
+ declare class ListIterator {
568
+ break(): void;
569
+ isBreak(): boolean;
570
+ protected _isBreak: any;
571
+ }
572
+ declare class List<T = any> {
573
+ constructor();
574
+ onSet(caller: any, handler: (value: T) => void): void;
575
+ onDelete(caller: any, handler: (value: T) => void): void;
576
+ firstByCondition(conf: (index: number, item: T) => boolean): [number, T];
577
+ lastByCondition(conf: (index: number, item: T) => boolean): [number, T];
578
+ forEach(handler: (index: number, item: T, iterator: ListIterator) => void): ListIterator;
539
579
  /**
540
- * 深度
580
+ * 移除符合条件的项, 从后往前遍历
581
+ * @param cond 可以使用【iterator】中断遍历
582
+ * @param removedList 设置后,可获得被移除的项
541
583
  */
542
- get depth(): number;
543
- private _depth;
584
+ removeByCondition(cond: (index: number, val: T, iterator: ListIterator) => boolean, removedList?: List): this;
544
585
  /**
545
- * 父节点
586
+ * 查找符合条件的项保存到【target】对象中,并返回【target】对象
587
+ * @param cond 可以使用【iterator】中断遍历
588
+ * @param target 存到目标对象中
546
589
  */
547
- parent: TreeNode;
590
+ findByCondition(cond: (index: number, val: T, iterator: ListIterator) => boolean, target: List): this;
591
+ pop(): T;
592
+ shift(): T;
593
+ first(): T;
594
+ last(): T;
595
+ removeAt(index: number): void;
596
+ remove(item: T): void;
548
597
  /**
549
- * 子节点
598
+ * 把【other】的项合并到自身
599
+ * @param other
550
600
  */
551
- children: TreeNode[];
601
+ removeList(other: List<T>): void;
602
+ sort(compareFn?: (a: T, b: T) => number): void;
603
+ reverse(): void;
604
+ clear(): void;
552
605
  /**
553
- * 设置根
554
- * @param val
606
+ * 克隆自身所有项到【target】对象,并返回【target】对象
607
+ * @param target
555
608
  */
556
- setRoot(val: TreeRoot): void;
557
- getTags(): {
558
- [key: string]: any;
559
- };
560
- getTag(name: string): any;
561
- removeTag(name: string): void;
562
- setTag(name: string, value: any): void;
563
- constructor(id: string, isLeaf?: boolean);
564
- addChild(val: TreeNode): void;
565
- getChildIndex(val: TreeNode): number;
566
- insertChild(val: TreeNode, index: number): void;
567
- removeChild(val: TreeNode): void;
568
- removeChildren(): void;
569
- get name(): string;
570
- setDepth(val: number): void;
571
- containsById(id: string): boolean;
609
+ clone(target: this): this;
610
+ get length(): number;
611
+ insertAt(index: number, ...item: T[]): void;
572
612
  /**
573
- * 通过编号获取子节点
574
- * @param id
613
+ * @param beforeItem
614
+ * @param item
575
615
  */
576
- getChildById(id: string): TreeNode;
616
+ insertBefore(beforeItem: T, ...item: T[]): void;
577
617
  /**
578
- * 返回相邻的上一个节点
618
+ * @param afterItem
619
+ * @param item
579
620
  */
580
- prevNode(): TreeNode;
621
+ insertAfter(afterItem: T, ...item: T[]): void;
622
+ at(index: number): T;
623
+ set(index: number, item: T): void;
624
+ indexOf(item: T): number;
625
+ has(item: T): boolean;
626
+ push(item: T): void;
581
627
  /**
582
- * 返回相邻的下一个节点
628
+ * 把【other】的项合并到自身
629
+ * @param other
583
630
  */
584
- nextNode(): TreeNode;
631
+ pushList(other: List<T>): void;
632
+ getData(): T[];
633
+ resetData(val: T[]): void;
585
634
  /**
586
- * 如果返回true则删除节点,包含当前节点
587
- * @param f
635
+ * 随机获取【count】个项,并返回【target】对象
636
+ * @param count
637
+ * @param enableRepeat 允许重复
638
+ * @param target
588
639
  */
589
- walkRemove(f: (node: TreeNode) => boolean): void;
590
- private _walkRemove;
640
+ random(count: number, enableRepeat?: boolean, target?: List<T>): List<T>;
641
+ protected callPush(value: any): void;
642
+ protected callRemove(value: any): void;
643
+ protected _data: any[];
644
+ private _onSet;
645
+ private _onDelete;
646
+ private _onSetCaller;
647
+ private _onDeleteCaller;
648
+ }
649
+
650
+ declare class UIObjectDict extends Dictionary<string, any | List> {
591
651
  /**
592
- * 如果返回true则继续,包含当前节点
593
- * @param f
594
- * @param inChild
652
+ * 获取唯一的
653
+ * @param prefab
595
654
  */
596
- walk(f: (node: TreeNode) => boolean, inChild?: (node: TreeNode) => boolean): void;
597
- private _walk;
655
+ uniqueObject(prefab: Prefab): Node;
656
+ removeObject(prefab: Prefab): void;
657
+ popObject(prefab: Prefab): any;
658
+ backObject(object: Node): void;
659
+ protected getList(key: any): List;
660
+ }
661
+ declare var uidict: UIObjectDict;
662
+
663
+ declare class ViewController {
664
+ constructor(name: string);
665
+ open(...args: any[]): void;
666
+ close(): void;
667
+ get objectDict(): UIObjectDict;
668
+ get name(): string;
669
+ protected _objectDict: UIObjectDict;
670
+ private _name;
671
+ }
672
+
673
+ declare class PageController extends ViewController {
674
+ constructor(routeName: string, config?: {
675
+ layer?: string;
676
+ tags?: string[];
677
+ enableHistory?: boolean;
678
+ });
679
+ protected onOpening(page: Page): void;
680
+ protected onOpened(page: Page): void;
681
+ protected onClosing(page: Page): void;
682
+ protected onClosed(page: Page): void;
683
+ protected onRefresh(page: Page): void;
684
+ openByRoute(route: Route): Page;
685
+ private openPage;
686
+ openComplete(page: Page): void;
687
+ closeByRoute(route?: Route): Page;
688
+ private closePage;
689
+ closeComplete(page: Page): void;
690
+ refresh(): void;
691
+ get layer(): string;
692
+ hasTags(tags: string[]): boolean;
693
+ setLayer(name: string): this;
694
+ setTags(tags: string[]): this;
695
+ get lastPage(): Page;
696
+ get route(): Route;
697
+ get enableHistory(): boolean;
698
+ protected _enableHistory: boolean;
699
+ protected _route: Route;
700
+ protected _lastPage: Page;
701
+ protected _tags: {};
702
+ protected _layer: string;
703
+ }
704
+ declare class PageControllerDict extends Dictionary<string, PageController> {
705
+ getByName(name: string): PageController;
706
+ }
707
+
708
+ declare enum PageState {
598
709
  /**
599
- * 从当前节点(包括)遍历父节点链,包含当前节点
600
- * @param f
710
+ * 关闭
601
711
  */
602
- walkParent(f: (node: TreeNode) => boolean): boolean;
712
+ Closed = 0,
603
713
  /**
604
- * 从当前节点往前遍历(深度),包含当前节点
605
- * @param f
606
- * @param inChild
714
+ * 正在打开
607
715
  */
608
- walkPrev(f: (node: TreeNode) => boolean, inChild?: (node: TreeNode) => boolean): any;
609
- private _walkPrev;
610
- dump(): void;
716
+ Opening = 1,
611
717
  /**
612
- * 遍历节点,查找指定编号的节点
718
+ * 已打开
613
719
  */
614
- findById(id: string): TreeNode;
720
+ Opened = 2,
615
721
  /**
616
- * 如果返回true则继续
617
- * @param f
722
+ * 正在关闭
618
723
  */
619
- findOne(f: (node: TreeNode) => boolean): TreeNode;
620
- private _findOne;
724
+ Closeing = 3
725
+ }
726
+ declare enum PageEvent {
727
+ Opening = "opening",
728
+ Opened = "opened",
729
+ Closeing = "closeing",
730
+ Closed = "closed",
731
+ Stop = "stop"
732
+ }
733
+ declare class Page extends EventManager {
734
+ constructor(controller: PageController, route: Route);
621
735
  /**
622
- * 通过路径获取节点
623
- * 格式为 /path1/path2/...
624
- * 如果 path == "/",则返回自身
625
- * @param path
736
+ * 等待打开完成指令
626
737
  */
627
- getNodeByPath(path: string): TreeNode;
628
- protected getNodeByPathArr(pathArr: string[]): TreeNode;
629
- getName(): string;
630
- getPath(): string;
738
+ waitOpenComplete(): void;
739
+ waitCloseComplete(): void;
740
+ openComplete(): void;
741
+ closeComplete(): void;
742
+ stop(reason: LinkError): void;
631
743
  /**
632
- * 如果返回true则继续
633
- * @param f
744
+ * 等待发送的结果
745
+ * 如果返回 null,表示主动取消 [cancel]
634
746
  */
635
- find(f: (node: TreeNode) => boolean): TreeNode[];
636
- private _find;
637
- toRoot(): TreeRoot;
638
- clone(): TreeNode;
639
- protected cloneChildrenTo(node: TreeNode): void;
640
- fixDepthAndRoot(depth: number, root: TreeRoot): void;
747
+ wait(): Promise<this>;
641
748
  toString(): string;
749
+ get objectDict(): UIObjectDict;
750
+ protected _objectDict: UIObjectDict;
751
+ protected _waitOpenComplete: boolean;
752
+ protected _waitCloseComplete: boolean;
753
+ get controller(): PageController;
754
+ get route(): Route;
755
+ cache: {};
756
+ tags: {};
757
+ layer: string;
758
+ state: PageState;
759
+ protected _controller: PageController;
760
+ protected _route: Route;
642
761
  }
643
- declare class TreeRoot<NODE = any> extends EventManager {
762
+
763
+ /**
764
+ * 视图管理器
765
+ * 打开一个视图的时候,可能会听过加载资源,读取数据,调整布局,切换特效等处理,所以使用视图模式封装视图打开关闭的逻辑
766
+ */
767
+ declare class PageLayer {
768
+ name: string;
769
+ constructor(name: string);
770
+ close(): void;
644
771
  /**
645
- * 添加数据节点
646
- * dispatchParams = {node:TreeNode, parent:TreeNode|TreeRoot}
772
+ * 当前的页面
647
773
  */
648
- static EVENT_ADD: string;
774
+ currentPage: Page;
775
+ }
776
+
777
+ declare class PageList extends List<Page> {
778
+ }
779
+ declare class PageRepo extends PageList {
780
+ constructor();
781
+ openByString(route: string): Page;
649
782
  /**
650
- * 移除数据节点
651
- * dispatchParams = {node:TreeNode, parent:TreeNode|TreeRoot}
783
+ * 打开页面
784
+ * 一个路由代表一个页面
785
+ * @param route
652
786
  */
653
- static EVENT_REMOVE: string;
787
+ open(route: Route): Page;
788
+ close(route: Route): void;
654
789
  /**
655
- * 插入数据节点
656
- * dispatchParams = {node:TreeNode, before:TreeNode}
790
+ * 如果页面存在,则刷新
791
+ * @param route
657
792
  */
658
- static EVENT_INSERT: string;
793
+ refresh(route: Route): void;
659
794
  /**
660
- * 刷新数据节点
661
- * dispatchParams = {node:TreeNode}
795
+ * 历史记录
662
796
  */
663
- static EVENT_REFRESH: string;
797
+ getHistory(): Route[];
798
+ back(): void;
799
+ getByRoute(route: Route): Page;
800
+ listByTags(tags: string[]): PageList;
801
+ getLayerMain(): PageLayer;
664
802
  /**
665
- * 设置数据时触发
666
- * dispatchParams = {node:TreeNode}
803
+ * @param name
667
804
  */
668
- static EVENT_DATA_SET: string;
805
+ getLayer(name: string): PageLayer;
806
+ protected getOrNewLayer(name: string): PageLayer;
807
+ getController(route: Route): PageController;
808
+ registerController(ctrl: PageController): void;
809
+ get objectDict(): UIObjectDict;
810
+ protected _objectDict: UIObjectDict;
811
+ protected _indexLayer: {};
812
+ protected _indexRoute: {};
813
+ protected _history: Route[];
814
+ protected _ctrlDict: PageControllerDict;
815
+ }
816
+ declare const pagerepo: PageRepo;
817
+
818
+ /**
819
+ * 事件字符串分隔符
820
+ */
821
+
822
+ /**
823
+ * 回调列表
824
+ */
825
+ declare class CallbackList<PARAMS = any> {
826
+ constructor();
827
+ addListener(listener: Listener): void;
828
+ removeListener(listener: Listener): void;
669
829
  /**
670
- * 设置数据时触发
671
- * dispatchParams = {node:TreeNode, tag:string, value:any}
672
830
  */
673
- static EVENT_TAGS_SET: string;
674
- static create(): TreeRoot<any>;
831
+ create(): Listener<PARAMS>;
675
832
  /**
676
- * 通过列表生成一个树结构
677
- * @param items
678
- * @param existed 列表将添加的已经存在的树结构
833
+ * 如果监听器已经不存在,则创建
834
+ * @param ident
679
835
  */
680
- static createByList(items: ITreeListItem[], existed?: TreeRoot): TreeRoot;
681
- static sortChildrenByName(node: TreeNode, des?: boolean): void;
682
- constructor();
683
- setNodeData(node: TreeNode, data: any): void;
684
- setNodeTags(node: TreeNode, tag: string, value: any, force?: boolean): void;
685
- getNodeByPath(path: string): TreeNode;
686
- makeNodeByPath(path: string): TreeNode;
836
+ createByIdent(ident: any): Listener<PARAMS>;
837
+ removeByIdent(ident: any): void;
838
+ removeByCaller(caller: any): void;
839
+ getByIdent(ident: any): Listener;
687
840
  /**
688
- * 添加节点,按照 node.path 添加到正确的位置
689
- * @param node
690
- * @param parentPath 如果父节点路径为 "", 则添加到起源节点
691
- * @param autoCreateParent 如果父节点不存在,自动创建
841
+ * 派发事件
842
+ * @param params 事件参数
843
+ * @param subIdent
692
844
  */
693
- addNode(node: TreeNode, parentPath?: string, autoCreateParent?: boolean): void;
694
- removeNode(node: TreeNode): void;
695
- removeChildren(node: TreeNode): void;
696
- insertNode(node: TreeNode, before: TreeNode, resetId?: boolean): void;
697
- walk(f: (node: TreeNode) => boolean, inChild?: (node: TreeNode) => boolean): void;
698
- walkPrev(f: (node: TreeNode) => boolean, inChild?: (node: TreeNode) => boolean): void;
845
+ dispatch(params?: PARAMS, subIdent?: string): void;
846
+ protected _data: List<Listener<any>>;
847
+ protected _indexIdent: {};
848
+ }
849
+
850
+ declare class Listener<PARAMS = any> {
851
+ static create(ident?: string): Listener<any>;
852
+ constructor(ident?: string);
853
+ getCaller(): any;
854
+ setCaller(caller: any): this;
855
+ setSubIdent(val: string): this;
856
+ setCondition(condition: (listener: Listener<PARAMS>) => boolean): this;
857
+ setHandler(handler: (listener: Listener<PARAMS>) => void): this;
858
+ setOnParams(val: any): this;
859
+ getIdent(): string;
860
+ on(): this;
861
+ off(): this;
862
+ isOn(): boolean;
863
+ remove(): void;
699
864
  /**
700
- * 派发 refresh 消息
701
- * @param node
865
+ * 内部使用
866
+ * @param params
867
+ * @param subIdent 子编号
702
868
  */
703
- refresh(node: TreeNode): void;
869
+ _dispatch(params: PARAMS, subIdent?: string): void;
870
+ getOnParams(): any;
871
+ getParams(): PARAMS;
872
+ protected onParams: any;
873
+ protected params: PARAMS;
874
+ protected ident: string;
875
+ protected _subIdent: string;
876
+ protected source: CallbackList;
877
+ protected _handler: (any: any) => void;
878
+ protected _condition: (any: any) => boolean;
879
+ protected caller: any;
880
+ protected _isOn: boolean;
881
+ }
882
+
883
+ /**
884
+ * 事件字符串分隔符
885
+ */
886
+
887
+ /**
888
+ * 事件派发器
889
+ */
890
+ declare class Dispatcher implements ISchedulable {
891
+ constructor(name?: string);
892
+ dispose(): void;
893
+ create(type: string, listener: Listener): void;
894
+ remove(type: string, listener: Listener): void;
895
+ getByIdent(type: string, ident: string): Listener;
704
896
  /**
705
- * 克隆当前的树结
706
- * * 新的tags克隆旧的data
707
- * * 新的data指向旧的data
897
+ * @param type
898
+ * @param ident
708
899
  */
709
- clone(): TreeRoot;
710
- toString(): string;
711
- createNode(id: string, isLeaf?: boolean): TreeNode;
900
+ createByIdent(type: string, ident: string): Listener;
712
901
  /**
713
- * origin的第一个child
902
+ * 派发事件
903
+ * @param eventType 事件类型
904
+ * @param params 事件参数
714
905
  */
715
- get firstNode(): TreeNode;
716
- origin: TreeNode;
717
- }
718
- declare class TreeRootPlugin {
719
- root: TreeRoot;
720
- }
721
- declare class TreeNodePlugin {
722
- node: TreeNode;
906
+ dispatch(eventType: string, params?: any): void;
907
+ protected getList(type: string): CallbackList;
908
+ id?: string;
909
+ uuid?: string;
910
+ name: string;
911
+ protected isDispose: boolean;
912
+ protected typeToList: Dictionary<string, CallbackList<any>>;
723
913
  }
724
914
 
725
- interface IListItem {
726
- /**
727
- * 编号
728
- */
729
- id: string;
915
+ declare class CallbackItem {
916
+ listener: Function;
917
+ caller: any;
918
+ once: boolean;
919
+ }
920
+ declare class SampleCallbackList {
921
+ constructor();
922
+ dispose(): void;
923
+ has(caller: any, listener: Function): boolean;
924
+ protected getItem(caller: any, listener: Function): CallbackItem;
730
925
  /**
731
- * 自定义数据
926
+ * 监听事件,如果监听已经存在则返回
927
+ * @param caller
928
+ * @param listener 为了性能考虑, event使用了对象池处理。因此处理函数不应该保存event的引用。如有需要,可通过新建对象或Event.Clone()实现
732
929
  */
733
- data?: any;
930
+ on(caller: any, listener: (ctx: this, params?: any) => void): CallbackItem;
931
+ once(caller: any, listener: (ctx: this, params?: any) => void): CallbackItem;
932
+ protected offItem(item: CallbackItem): void;
933
+ off(caller: any, listener: Function): void;
934
+ offAll(type?: string): void;
935
+ offAllCaller(caller: any): void;
734
936
  /**
735
- * 功能性标签,用于开发组件时,记录组件的状态。例如title, icon, 显示树的组件,需要 expanded,selected标签
937
+ * 派发事件
938
+ * @param params 事件参数
736
939
  */
737
- tags?: {
738
- [key: string]: any;
739
- };
940
+ dispatch(params?: any): void;
941
+ protected _callbackItems: CallbackItem[];
740
942
  }
741
- declare class ListNode {
742
- static create(id: string, data?: any): ListNode;
743
- constructor();
744
- root: ListSource;
943
+
944
+ declare class AssetURI {
945
+ name: string;
946
+ constructor(name: string);
947
+ loadType: number;
745
948
  uuid: string;
746
- id: string;
747
- data: any;
748
- tags: {};
749
- getTags(): {
750
- [key: string]: any;
751
- };
752
- setTags(tags: {
753
- [key: string]: any;
754
- }): void;
755
- getTag(name: string): any;
756
- setTag(name: string, value: any): void;
949
+ path: string;
950
+ bundle: string;
757
951
  }
758
- declare class ListSource extends EventManager {
952
+ declare class XAssetManager {
953
+ getAsset(uri: string): any;
954
+ getAssetByUUID(uuid: string): any;
955
+ getRoot(): AssetManager;
956
+ }
957
+ declare let assetx: XAssetManager;
958
+
959
+ declare class TreeIterator {
960
+ break(): void;
961
+ isBreak(): boolean;
962
+ protected _isBreak: any;
963
+ }
964
+ interface ITreeListItem {
759
965
  /**
760
- * 通过数组创建 ListSource。ListSource的id自动生成。如果需要指定编号,可设置 idCreator
761
- * @param arr
762
- * @param idCreator
966
+ * 路径
763
967
  */
764
- static createByArray(arr: any[], idCreator?: (item: any) => string): ListSource;
765
- static createByListItem(arr: IListItem[], target?: ListSource): any;
968
+ path: string;
766
969
  /**
767
- * 设置数据时触发
768
- * dispatchParams = {node:ListNode}
970
+ * 自定义数据
971
+ */
972
+ data?: any;
973
+ /**
974
+ * 功能性标签,用于开发组件时,记录组件的状态。例如title, icon, 显示树的组件,需要 expanded,selected标签
769
975
  */
770
- static EVENT_ADD: string;
976
+ tags?: {
977
+ [key: string]: any;
978
+ };
771
979
  /**
772
- * 设置数据时触发
773
- * dispatchParams = {node:ListNode, index:number}
980
+ * 是否树叶
774
981
  */
775
- static EVENT_REMOVE: string;
982
+ isLeaf: boolean;
983
+ }
984
+ declare class TreeNode<T = any> {
985
+ get root(): TreeRoot;
776
986
  /**
777
- * 设置数据时触发
987
+ * 根节点
778
988
  */
779
- static EVENT_REMOVE_ALL: string;
989
+ protected _root: TreeRoot;
780
990
  /**
781
- * 刷新数据节点
782
- * dispatchParams = {node:ListNode}
991
+ * 编号
783
992
  */
784
- static EVENT_REFRESH: string;
993
+ uuid: string;
785
994
  /**
786
- * 设置数据时触发
787
- * dispatchParams = nodes: [ListNode], indexs: [number]
995
+ * 编号
788
996
  */
789
- static EVENT_SWAP: string;
997
+ id: string;
790
998
  /**
791
- * 设置数据时触发
792
- * dispatchParams = {node:ListNode, data:any}
999
+ * 自定义数据
793
1000
  */
794
- static EVENT_DATA_SET: string;
1001
+ data: T;
795
1002
  /**
796
- * 设置数据时触发
797
- * dispatchParams = {node:ListNode, tag:string, value:any}
1003
+ * 是否树叶
798
1004
  */
799
- static EVENT_TAGS_SET: string;
800
- protected _identFunc: (node: ListNode) => boolean;
801
- at(index: number): ListNode;
802
- first(): ListNode;
803
- last(): ListNode;
804
- length(): number;
1005
+ isLeaf: boolean;
805
1006
  /**
806
- * 添加项,无法添加相同的项
807
- * @param node
808
- * @param enableDispatch 默认为true
1007
+ * 功能性标签,用于开发组件时,记录组件的状态。例如title, icon, 显示树的组件,需要 expanded,selected标签
809
1008
  */
810
- add(node: ListNode, enableDispatch?: boolean): void;
811
- getById(id: string): ListNode;
812
- remove(node: ListNode): void;
813
- removeAll(): void;
814
- swap(a: ListNode, b: ListNode): void;
815
- contains(node: ListNode): boolean;
816
- containsById(id: string): boolean;
817
- indexOf(node: ListNode): number;
818
- indexOfById(id: string): number;
819
- setData(node: ListNode, data: any): void;
820
- setNodeTags(node: ListNode, tag: string, value: any): void;
1009
+ tags: {
1010
+ [key: string]: any;
1011
+ };
821
1012
  /**
822
- * 派发 refresh 消息
823
- * @param node
1013
+ * 深度
824
1014
  */
825
- refresh(node: ListNode): void;
826
- walk(f: (node: ListNode) => boolean): boolean;
827
- walkPrev(node: ListNode, f: (node: ListNode) => boolean): boolean;
828
- get data(): any[];
829
- private _data;
830
- }
831
-
832
- declare class DictIterator {
833
- break(): void;
834
- isBreak(): boolean;
835
- protected _isBreak: any;
836
- }
837
- declare class Dictionary<K = string, V = any> {
838
- constructor(data?: any);
839
- reset(data: any): void;
840
- protected _reset(data: any, size?: number): void;
841
- getData(): any;
1015
+ get depth(): number;
1016
+ private _depth;
842
1017
  /**
843
- * 如果使用了 onSet or onDelete,需要注意清理
1018
+ * 父节点
844
1019
  */
845
- clear(): void;
1020
+ parent: TreeNode;
846
1021
  /**
847
- * 克隆自身所有项到【target】对象,并返回【target】对象
848
- * @param target
1022
+ * 子节点
849
1023
  */
850
- clone(target: this): this;
851
- resetByDict(dict: Dictionary): void;
852
- onSet(caller: any, handler: (key: K, value: V) => void): void;
853
- onDelete(caller: any, handler: (key: K, value: V) => void): void;
1024
+ children: TreeNode[];
854
1025
  /**
855
- * 设置键值对,如果没有发生变化,不会触发onSet函数
856
- * @param key
857
- * @param value
1026
+ * 设置根
1027
+ * @param val
858
1028
  */
859
- set(key: K, value: V): void;
860
- private setData;
861
- setByMap(m: any): void;
862
- addDictionary(other: Dictionary<K, V>): void;
863
- deleteDictionary(other: Dictionary<K, V>): void;
1029
+ setRoot(val: TreeRoot): void;
1030
+ getTags(): {
1031
+ [key: string]: any;
1032
+ };
1033
+ getTag(name: string): any;
1034
+ removeTag(name: string): void;
1035
+ setTag(name: string, value: any): void;
1036
+ constructor(id: string, isLeaf?: boolean);
1037
+ addChild(val: TreeNode): void;
1038
+ getChildIndex(val: TreeNode): number;
1039
+ insertChild(val: TreeNode, index: number): void;
1040
+ removeChild(val: TreeNode): void;
1041
+ removeChildren(): void;
1042
+ get name(): string;
1043
+ setDepth(val: number): void;
1044
+ containsById(id: string): boolean;
864
1045
  /**
865
- * 如果不存在,返回 undefined
866
- * @param key
1046
+ * 通过编号获取子节点
1047
+ * @param id
867
1048
  */
868
- get(key: K): V;
869
- exist(key: K): boolean;
870
- delete(key: K): void;
871
- private deleteData;
872
- exists(key: K): boolean;
873
- length(): number;
874
- pop(key: K): [V, boolean];
875
- isEmpty(): boolean;
876
- items(): V[];
877
- keys(): K[];
1049
+ getChildById(id: string): TreeNode;
878
1050
  /**
879
- *
880
- * @param handler 可以使用【iterator】中断遍历
881
- * @return iterator 获取是否中断了
1051
+ * 返回相邻的上一个节点
882
1052
  */
883
- forEach(handler: (key: K, val: V, iterator: DictIterator) => void): DictIterator;
1053
+ prevNode(): TreeNode;
884
1054
  /**
1055
+ * 返回相邻的下一个节点
885
1056
  */
886
- first(): V | undefined;
1057
+ nextNode(): TreeNode;
887
1058
  /**
888
- * @param handler 返回true结束迭代
1059
+ * 如果返回true则删除节点,包含当前节点
1060
+ * @param f
889
1061
  */
890
- firstByCondition(handler: (key: K, val: V) => boolean): V | undefined;
1062
+ walkRemove(f: (node: TreeNode) => boolean): void;
1063
+ private _walkRemove;
891
1064
  /**
892
- * 移除符合条件的项
893
- * @param cond 可以使用【iterator】中断遍历
1065
+ * 如果返回true则继续,包含当前节点
1066
+ * @param f
1067
+ * @param inChild
894
1068
  */
895
- removeByCondition(cond: (key: K, val: V, iterator: DictIterator) => boolean): void;
1069
+ walk(f: (node: TreeNode) => boolean, inChild?: (node: TreeNode) => boolean): void;
1070
+ private _walk;
896
1071
  /**
897
- * 查找符合条件的项保存到【target】对象中,并返回【target】对象
898
- * @param cond 可以使用【iterator】中断遍历
899
- * @param target 存到目标对象中
1072
+ * 从当前节点(包括)遍历父节点链,包含当前节点
1073
+ * @param f
900
1074
  */
901
- findByCondition(cond: (key: K, val: V, iterator: DictIterator) => boolean, target: Dictionary): this;
902
- groupByCondition(createKey: (key: K, val: V) => string, ITEM_CLASS?: any): {
903
- [key: string]: any;
904
- };
905
- protected size: number;
906
- private _data;
907
- private _onSet;
908
- private _onDelete;
909
- private _onSetCaller;
910
- private _onDeleteCaller;
911
- }
912
-
913
- declare class DictNode {
914
- static create(id: string, data?: any): DictNode;
915
- constructor();
916
- uuid: string;
917
- id: string;
918
- data: any;
919
- tags: {};
920
- getTags(): {
921
- [key: string]: any;
922
- };
923
- getTag(name: string): any;
924
- setTag(name: string, value: any): void;
1075
+ walkParent(f: (node: TreeNode) => boolean): boolean;
925
1076
  /**
926
- * 清理【data】和【tags】
1077
+ * 从当前节点往前遍历(深度),包含当前节点
1078
+ * @param f
1079
+ * @param inChild
927
1080
  */
928
- clean(): void;
929
- }
930
- declare class DictSource extends Dictionary<string, DictNode> {
1081
+ walkPrev(f: (node: TreeNode) => boolean, inChild?: (node: TreeNode) => boolean): any;
1082
+ private _walkPrev;
1083
+ dump(): void;
931
1084
  /**
932
- * 刷新数据节点
933
- * dispatchParams = {node:ListNode}
1085
+ * 遍历节点,查找指定编号的节点
934
1086
  */
935
- static EVENT_REFRESH: string;
1087
+ findById(id: string): TreeNode;
936
1088
  /**
937
- * 设置数据时触发
938
- * dispatchParams = {node:ListNode, tag:string, value:any}
1089
+ * 如果返回true则继续
1090
+ * @param f
939
1091
  */
940
- static EVENT_TAGS_SET: string;
941
- setNodeTags(node: DictNode, tag: string, value: any): void;
942
- refreshNode(node: DictNode): void;
943
- get dispatcher(): EventManager;
944
- protected _dispatcher: EventManager;
945
- }
946
-
947
- declare class ListIterator {
948
- break(): void;
949
- isBreak(): boolean;
950
- protected _isBreak: any;
951
- }
952
- declare class List<T = any> {
953
- constructor();
954
- onSet(caller: any, handler: (value: T) => void): void;
955
- onDelete(caller: any, handler: (value: T) => void): void;
956
- firstByCondition(conf: (index: number, item: T) => boolean): [number, T];
957
- lastByCondition(conf: (index: number, item: T) => boolean): [number, T];
958
- forEach(handler: (index: number, item: T, iterator: ListIterator) => void): ListIterator;
1092
+ findOne(f: (node: TreeNode) => boolean): TreeNode;
1093
+ private _findOne;
959
1094
  /**
960
- * 移除符合条件的项, 从后往前遍历
961
- * @param cond 可以使用【iterator】中断遍历
962
- * @param removedList 设置后,可获得被移除的项
1095
+ * 通过路径获取节点
1096
+ * 格式为 /path1/path2/...
1097
+ * 如果 path == "/",则返回自身
1098
+ * @param path
963
1099
  */
964
- removeByCondition(cond: (index: number, val: T, iterator: ListIterator) => boolean, removedList?: List): this;
1100
+ getNodeByPath(path: string): TreeNode;
1101
+ protected getNodeByPathArr(pathArr: string[]): TreeNode;
1102
+ getName(): string;
1103
+ getPath(): string;
965
1104
  /**
966
- * 查找符合条件的项保存到【target】对象中,并返回【target】对象
967
- * @param cond 可以使用【iterator】中断遍历
968
- * @param target 存到目标对象中
1105
+ * 如果返回true则继续
1106
+ * @param f
969
1107
  */
970
- findByCondition(cond: (index: number, val: T, iterator: ListIterator) => boolean, target: List): this;
971
- pop(): T;
972
- shift(): T;
973
- first(): T;
974
- last(): T;
975
- removeAt(index: number): void;
976
- remove(item: T): void;
1108
+ find(f: (node: TreeNode) => boolean): TreeNode[];
1109
+ private _find;
1110
+ toRoot(): TreeRoot;
1111
+ clone(): TreeNode;
1112
+ protected cloneChildrenTo(node: TreeNode): void;
1113
+ fixDepthAndRoot(depth: number, root: TreeRoot): void;
1114
+ toString(): string;
1115
+ }
1116
+ declare class TreeRoot<NODE = any> extends EventManager {
977
1117
  /**
978
- * 把【other】的项合并到自身
979
- * @param other
1118
+ * 添加数据节点
1119
+ * dispatchParams = {node:TreeNode, parent:TreeNode|TreeRoot}
980
1120
  */
981
- removeList(other: List<T>): void;
982
- sort(compareFn?: (a: T, b: T) => number): void;
983
- reverse(): void;
984
- clear(): void;
1121
+ static EVENT_ADD: string;
985
1122
  /**
986
- * 克隆自身所有项到【target】对象,并返回【target】对象
987
- * @param target
1123
+ * 移除数据节点
1124
+ * dispatchParams = {node:TreeNode, parent:TreeNode|TreeRoot}
988
1125
  */
989
- clone(target: this): this;
990
- get length(): number;
991
- insertAt(index: number, ...item: T[]): void;
1126
+ static EVENT_REMOVE: string;
992
1127
  /**
993
- * @param beforeItem
994
- * @param item
1128
+ * 插入数据节点
1129
+ * dispatchParams = {node:TreeNode, before:TreeNode}
995
1130
  */
996
- insertBefore(beforeItem: T, ...item: T[]): void;
1131
+ static EVENT_INSERT: string;
997
1132
  /**
998
- * @param afterItem
999
- * @param item
1133
+ * 刷新数据节点
1134
+ * dispatchParams = {node:TreeNode}
1000
1135
  */
1001
- insertAfter(afterItem: T, ...item: T[]): void;
1002
- at(index: number): T;
1003
- set(index: number, item: T): void;
1004
- indexOf(item: T): number;
1005
- has(item: T): boolean;
1006
- push(item: T): void;
1136
+ static EVENT_REFRESH: string;
1007
1137
  /**
1008
- * 把【other】的项合并到自身
1009
- * @param other
1138
+ * 设置数据时触发
1139
+ * dispatchParams = {node:TreeNode}
1010
1140
  */
1011
- pushList(other: List<T>): void;
1012
- getData(): T[];
1013
- resetData(val: T[]): void;
1141
+ static EVENT_DATA_SET: string;
1014
1142
  /**
1015
- * 随机获取【count】个项,并返回【target】对象
1016
- * @param count
1017
- * @param enableRepeat 允许重复
1018
- * @param target
1143
+ * 设置数据时触发
1144
+ * dispatchParams = {node:TreeNode, tag:string, value:any}
1019
1145
  */
1020
- random(count: number, enableRepeat?: boolean, target?: List<T>): List<T>;
1021
- protected callPush(value: any): void;
1022
- protected callRemove(value: any): void;
1023
- protected _data: any[];
1024
- private _onSet;
1025
- private _onDelete;
1026
- private _onSetCaller;
1027
- private _onDeleteCaller;
1028
- }
1029
-
1030
- declare class UIObjectDict extends Dictionary<string, any | List> {
1146
+ static EVENT_TAGS_SET: string;
1147
+ static create(): TreeRoot<any>;
1031
1148
  /**
1032
- * 获取唯一的
1033
- * @param prefab
1149
+ * 通过列表生成一个树结构
1150
+ * @param items
1151
+ * @param existed 列表将添加的已经存在的树结构
1034
1152
  */
1035
- uniqueObject(prefab: Prefab): Node;
1036
- removeObject(prefab: Prefab): void;
1037
- popObject(prefab: Prefab): any;
1038
- backObject(object: Node): void;
1039
- protected getList(key: any): List;
1040
- }
1041
- declare var uidict: UIObjectDict;
1042
-
1043
- declare class ViewController extends Component {
1044
- constructor(name: string);
1045
- open(...args: any[]): void;
1046
- close(): void;
1047
- get objectDict(): UIObjectDict;
1048
- protected _objectDict: UIObjectDict;
1049
- }
1050
- declare class ControllerDict extends Dictionary<string, ViewController> {
1051
- getByName(name: string): ViewController;
1052
- register(controller: ViewController): void;
1053
- }
1054
- declare var ctrlrepo: ControllerDict;
1055
-
1056
- declare class PageController extends ViewController {
1057
- constructor(routeName: string, config?: {
1058
- layer?: string;
1059
- tags?: string[];
1060
- enableHistory?: boolean;
1061
- });
1062
- protected onOpening(page: Page): void;
1063
- protected onOpened(page: Page): void;
1064
- protected onClosing(page: Page): void;
1065
- protected onClosed(page: Page): void;
1066
- protected onRefresh(page: Page): void;
1067
- openByRoute(route: Route): Page;
1068
- private openPage;
1069
- openComplete(page: Page): void;
1070
- closeByRoute(route?: Route): Page;
1071
- private closePage;
1072
- closeComplete(page: Page): void;
1073
- refresh(): void;
1074
- get layer(): string;
1075
- hasTags(tags: string[]): boolean;
1076
- setLayer(name: string): this;
1077
- setTags(tags: string[]): this;
1078
- get lastPage(): Page;
1079
- get route(): Route;
1080
- get enableHistory(): boolean;
1081
- protected _enableHistory: boolean;
1082
- protected _route: Route;
1083
- protected _lastPage: Page;
1084
- protected _tags: {};
1085
- protected _layer: string;
1086
- }
1087
-
1088
- declare enum PageState {
1153
+ static createByList(items: ITreeListItem[], existed?: TreeRoot): TreeRoot;
1154
+ static sortChildrenByName(node: TreeNode, des?: boolean): void;
1155
+ constructor();
1156
+ setNodeData(node: TreeNode, data: any): void;
1157
+ setNodeTags(node: TreeNode, tag: string, value: any, force?: boolean): void;
1158
+ getNodeByPath(path: string): TreeNode;
1159
+ makeNodeByPath(path: string): TreeNode;
1089
1160
  /**
1090
- * 关闭
1161
+ * 添加节点,按照 node.path 添加到正确的位置
1162
+ * @param node
1163
+ * @param parentPath 如果父节点路径为 "", 则添加到起源节点
1164
+ * @param autoCreateParent 如果父节点不存在,自动创建
1091
1165
  */
1092
- Closed = 0,
1166
+ addNode(node: TreeNode, parentPath?: string, autoCreateParent?: boolean): void;
1167
+ removeNode(node: TreeNode): void;
1168
+ removeChildren(node: TreeNode): void;
1169
+ insertNode(node: TreeNode, before: TreeNode, resetId?: boolean): void;
1170
+ walk(f: (node: TreeNode) => boolean, inChild?: (node: TreeNode) => boolean): void;
1171
+ walkPrev(f: (node: TreeNode) => boolean, inChild?: (node: TreeNode) => boolean): void;
1093
1172
  /**
1094
- * 正在打开
1173
+ * 派发 refresh 消息
1174
+ * @param node
1095
1175
  */
1096
- Opening = 1,
1176
+ refresh(node: TreeNode): void;
1097
1177
  /**
1098
- * 已打开
1178
+ * 克隆当前的树结
1179
+ * * 新的tags克隆旧的data
1180
+ * * 新的data指向旧的data
1099
1181
  */
1100
- Opened = 2,
1182
+ clone(): TreeRoot;
1183
+ toString(): string;
1184
+ createNode(id: string, isLeaf?: boolean): TreeNode;
1101
1185
  /**
1102
- * 正在关闭
1186
+ * origin的第一个child
1103
1187
  */
1104
- Closeing = 3
1188
+ get firstNode(): TreeNode;
1189
+ origin: TreeNode;
1105
1190
  }
1106
- declare enum PageEvent {
1107
- Opening = "opening",
1108
- Opened = "opened",
1109
- Closeing = "closeing",
1110
- Closed = "closed",
1111
- Stop = "stop"
1191
+ declare class TreeRootPlugin {
1192
+ root: TreeRoot;
1112
1193
  }
1113
- declare class Page extends EventManager {
1114
- constructor(controller: PageController, route: Route);
1194
+ declare class TreeNodePlugin {
1195
+ node: TreeNode;
1196
+ }
1197
+
1198
+ interface IListItem {
1115
1199
  /**
1116
- * 等待打开完成指令
1200
+ * 编号
1117
1201
  */
1118
- waitOpenComplete(): void;
1119
- waitCloseComplete(): void;
1120
- openComplete(): void;
1121
- closeComplete(): void;
1122
- stop(reason: LinkError): void;
1202
+ id: string;
1123
1203
  /**
1124
- * 等待发送的结果
1125
- * 如果返回 null,表示主动取消 [cancel]
1204
+ * 自定义数据
1126
1205
  */
1127
- wait(): Promise<this>;
1128
- toString(): string;
1129
- get objectDict(): UIObjectDict;
1130
- protected _objectDict: UIObjectDict;
1131
- protected _waitOpenComplete: boolean;
1132
- protected _waitCloseComplete: boolean;
1133
- get controller(): PageController;
1134
- get route(): Route;
1135
- cache: {};
1136
- tags: {};
1137
- layer: string;
1138
- state: PageState;
1139
- protected _controller: PageController;
1140
- protected _route: Route;
1141
- }
1142
-
1143
- /**
1144
- * 视图管理器
1145
- * 打开一个视图的时候,可能会听过加载资源,读取数据,调整布局,切换特效等处理,所以使用视图模式封装视图打开关闭的逻辑
1146
- */
1147
- declare class PageLayer {
1148
- name: string;
1149
- constructor(name: string);
1150
- close(): void;
1206
+ data?: any;
1151
1207
  /**
1152
- * 当前的页面
1208
+ * 功能性标签,用于开发组件时,记录组件的状态。例如title, icon, 显示树的组件,需要 expanded,selected标签
1153
1209
  */
1154
- currentPage: Page;
1155
- }
1156
-
1157
- declare class PageList extends List<Page> {
1210
+ tags?: {
1211
+ [key: string]: any;
1212
+ };
1158
1213
  }
1159
- declare class PageRepo extends PageList {
1214
+ declare class ListNode {
1215
+ static create(id: string, data?: any): ListNode;
1160
1216
  constructor();
1161
- openByString(route: string): Page;
1217
+ root: ListSource;
1218
+ uuid: string;
1219
+ id: string;
1220
+ data: any;
1221
+ tags: {};
1222
+ getTags(): {
1223
+ [key: string]: any;
1224
+ };
1225
+ setTags(tags: {
1226
+ [key: string]: any;
1227
+ }): void;
1228
+ getTag(name: string): any;
1229
+ setTag(name: string, value: any): void;
1230
+ }
1231
+ declare class ListSource extends EventManager {
1162
1232
  /**
1163
- * 打开页面
1164
- * 一个路由代表一个页面
1165
- * @param route
1233
+ * 通过数组创建 ListSource。ListSource的id自动生成。如果需要指定编号,可设置 idCreator
1234
+ * @param arr
1235
+ * @param idCreator
1166
1236
  */
1167
- open(route: Route): Page;
1168
- close(route: Route): void;
1237
+ static createByArray(arr: any[], idCreator?: (item: any) => string): ListSource;
1238
+ static createByListItem(arr: IListItem[], target?: ListSource): any;
1169
1239
  /**
1170
- * 如果页面存在,则刷新
1171
- * @param route
1240
+ * 设置数据时触发
1241
+ * dispatchParams = {node:ListNode}
1172
1242
  */
1173
- refresh(route: Route): void;
1243
+ static EVENT_ADD: string;
1174
1244
  /**
1175
- * 历史记录
1245
+ * 设置数据时触发
1246
+ * dispatchParams = {node:ListNode, index:number}
1176
1247
  */
1177
- getHistory(): Route[];
1178
- back(): void;
1179
- getByRoute(route: Route): Page;
1180
- listByTags(tags: string[]): PageList;
1181
- getLayerMain(): PageLayer;
1248
+ static EVENT_REMOVE: string;
1182
1249
  /**
1183
- * @param name
1250
+ * 设置数据时触发
1184
1251
  */
1185
- getLayer(name: string): PageLayer;
1186
- protected getOrNewLayer(name: string): PageLayer;
1187
- getController(route: Route): PageController;
1188
- get objectDict(): UIObjectDict;
1189
- protected _objectDict: UIObjectDict;
1190
- protected _indexLayer: {};
1191
- protected _indexRoute: {};
1192
- protected _history: Route[];
1193
- }
1194
- declare const pagerepo: PageRepo;
1195
-
1196
- /**
1197
- * 事件字符串分隔符
1198
- */
1199
-
1200
- /**
1201
- * 回调列表
1202
- */
1203
- declare class CallbackList<PARAMS = any> {
1204
- constructor();
1205
- addListener(listener: Listener): void;
1206
- removeListener(listener: Listener): void;
1252
+ static EVENT_REMOVE_ALL: string;
1207
1253
  /**
1254
+ * 刷新数据节点
1255
+ * dispatchParams = {node:ListNode}
1208
1256
  */
1209
- create(): Listener<PARAMS>;
1257
+ static EVENT_REFRESH: string;
1210
1258
  /**
1211
- * 如果监听器已经不存在,则创建
1212
- * @param ident
1259
+ * 设置数据时触发
1260
+ * dispatchParams = nodes: [ListNode], indexs: [number]
1213
1261
  */
1214
- createByIdent(ident: any): Listener<PARAMS>;
1215
- removeByIdent(ident: any): void;
1216
- removeByCaller(caller: any): void;
1217
- getByIdent(ident: any): Listener;
1262
+ static EVENT_SWAP: string;
1218
1263
  /**
1219
- * 派发事件
1220
- * @param params 事件参数
1221
- * @param subIdent
1264
+ * 设置数据时触发
1265
+ * dispatchParams = {node:ListNode, data:any}
1222
1266
  */
1223
- dispatch(params?: PARAMS, subIdent?: string): void;
1224
- protected _data: List<Listener<any>>;
1225
- protected _indexIdent: {};
1226
- }
1227
-
1228
- declare class Listener<PARAMS = any> {
1229
- static create(ident?: string): Listener<any>;
1230
- constructor(ident?: string);
1231
- getCaller(): any;
1232
- setCaller(caller: any): this;
1233
- setSubIdent(val: string): this;
1234
- setCondition(condition: (listener: Listener<PARAMS>) => boolean): this;
1235
- setHandler(handler: (listener: Listener<PARAMS>) => void): this;
1236
- setOnParams(val: any): this;
1237
- getIdent(): string;
1238
- on(): this;
1239
- off(): this;
1240
- isOn(): boolean;
1241
- remove(): void;
1267
+ static EVENT_DATA_SET: string;
1242
1268
  /**
1243
- * 内部使用
1244
- * @param params
1245
- * @param subIdent 子编号
1269
+ * 设置数据时触发
1270
+ * dispatchParams = {node:ListNode, tag:string, value:any}
1246
1271
  */
1247
- _dispatch(params: PARAMS, subIdent?: string): void;
1248
- getOnParams(): any;
1249
- getParams(): PARAMS;
1250
- protected onParams: any;
1251
- protected params: PARAMS;
1252
- protected ident: string;
1253
- protected _subIdent: string;
1254
- protected source: CallbackList;
1255
- protected _handler: (any: any) => void;
1256
- protected _condition: (any: any) => boolean;
1257
- protected caller: any;
1258
- protected _isOn: boolean;
1259
- }
1260
-
1261
- /**
1262
- * 事件字符串分隔符
1263
- */
1264
-
1265
- /**
1266
- * 事件派发器
1267
- */
1268
- declare class Dispatcher implements ISchedulable {
1269
- constructor(name?: string);
1270
- dispose(): void;
1271
- create(type: string, listener: Listener): void;
1272
- remove(type: string, listener: Listener): void;
1273
- getByIdent(type: string, ident: string): Listener;
1272
+ static EVENT_TAGS_SET: string;
1273
+ protected _identFunc: (node: ListNode) => boolean;
1274
+ at(index: number): ListNode;
1275
+ first(): ListNode;
1276
+ last(): ListNode;
1277
+ length(): number;
1274
1278
  /**
1275
- * @param type
1276
- * @param ident
1279
+ * 添加项,无法添加相同的项
1280
+ * @param node
1281
+ * @param enableDispatch 默认为true
1277
1282
  */
1278
- createByIdent(type: string, ident: string): Listener;
1283
+ add(node: ListNode, enableDispatch?: boolean): void;
1284
+ getById(id: string): ListNode;
1285
+ remove(node: ListNode): void;
1286
+ removeAll(): void;
1287
+ swap(a: ListNode, b: ListNode): void;
1288
+ contains(node: ListNode): boolean;
1289
+ containsById(id: string): boolean;
1290
+ indexOf(node: ListNode): number;
1291
+ indexOfById(id: string): number;
1292
+ setData(node: ListNode, data: any): void;
1293
+ setNodeTags(node: ListNode, tag: string, value: any): void;
1279
1294
  /**
1280
- * 派发事件
1281
- * @param eventType 事件类型
1282
- * @param params 事件参数
1295
+ * 派发 refresh 消息
1296
+ * @param node
1283
1297
  */
1284
- dispatch(eventType: string, params?: any): void;
1285
- protected getList(type: string): CallbackList;
1286
- id?: string;
1287
- uuid?: string;
1288
- name: string;
1289
- protected isDispose: boolean;
1290
- protected typeToList: Dictionary<string, CallbackList<any>>;
1298
+ refresh(node: ListNode): void;
1299
+ walk(f: (node: ListNode) => boolean): boolean;
1300
+ walkPrev(node: ListNode, f: (node: ListNode) => boolean): boolean;
1301
+ get data(): any[];
1302
+ private _data;
1291
1303
  }
1292
1304
 
1293
- declare class CallbackItem {
1294
- listener: Function;
1295
- caller: any;
1296
- once: boolean;
1297
- }
1298
- declare class SampleCallbackList {
1305
+ declare class DictNode {
1306
+ static create(id: string, data?: any): DictNode;
1299
1307
  constructor();
1300
- dispose(): void;
1301
- has(caller: any, listener: Function): boolean;
1302
- protected getItem(caller: any, listener: Function): CallbackItem;
1308
+ uuid: string;
1309
+ id: string;
1310
+ data: any;
1311
+ tags: {};
1312
+ getTags(): {
1313
+ [key: string]: any;
1314
+ };
1315
+ getTag(name: string): any;
1316
+ setTag(name: string, value: any): void;
1303
1317
  /**
1304
- * 监听事件,如果监听已经存在则返回
1305
- * @param caller
1306
- * @param listener 为了性能考虑, event使用了对象池处理。因此处理函数不应该保存event的引用。如有需要,可通过新建对象或Event.Clone()实现
1318
+ * 清理【data】和【tags】
1307
1319
  */
1308
- on(caller: any, listener: (ctx: this, params?: any) => void): CallbackItem;
1309
- once(caller: any, listener: (ctx: this, params?: any) => void): CallbackItem;
1310
- protected offItem(item: CallbackItem): void;
1311
- off(caller: any, listener: Function): void;
1312
- offAll(type?: string): void;
1313
- offAllCaller(caller: any): void;
1320
+ clean(): void;
1321
+ }
1322
+ declare class DictSource extends Dictionary<string, DictNode> {
1314
1323
  /**
1315
- * 派发事件
1316
- * @param params 事件参数
1324
+ * 刷新数据节点
1325
+ * dispatchParams = {node:ListNode}
1317
1326
  */
1318
- dispatch(params?: any): void;
1319
- protected _callbackItems: CallbackItem[];
1320
- }
1321
-
1322
- declare class AssetURI {
1323
- name: string;
1324
- constructor(name: string);
1325
- loadType: number;
1326
- uuid: string;
1327
- path: string;
1328
- bundle: string;
1329
- }
1330
- declare class XAssetManager {
1331
- getAsset(uri: string): any;
1332
- getAssetByUUID(uuid: string): any;
1333
- getRoot(): AssetManager;
1327
+ static EVENT_REFRESH: string;
1328
+ /**
1329
+ * 设置数据时触发
1330
+ * dispatchParams = {node:ListNode, tag:string, value:any}
1331
+ */
1332
+ static EVENT_TAGS_SET: string;
1333
+ setNodeTags(node: DictNode, tag: string, value: any): void;
1334
+ refreshNode(node: DictNode): void;
1335
+ get dispatcher(): EventManager;
1336
+ protected _dispatcher: EventManager;
1334
1337
  }
1335
- declare let assetx: XAssetManager;
1336
1338
 
1337
1339
  declare class LoaderItem {
1338
1340
  onComplete?: (err: any, asset: any) => void;
@@ -1507,34 +1509,91 @@ declare class Pool {
1507
1509
  */
1508
1510
  disposeObject(obj: any): void;
1509
1511
  /**
1510
- * 释放对象池
1512
+ * 释放对象池
1513
+ */
1514
+ dispose(): void;
1515
+ }
1516
+ /**
1517
+ * 对象池
1518
+ */
1519
+ declare class SamplePool {
1520
+ list: any[];
1521
+ constructor();
1522
+ /**
1523
+ * 获取一个对象
1524
+ */
1525
+ get(): any;
1526
+ /**
1527
+ * 回收一个对象
1528
+ * @param obj
1529
+ */
1530
+ put(obj: any): void;
1531
+ }
1532
+ /**
1533
+ * 对象池
1534
+ */
1535
+ declare class SamplePoolSet {
1536
+ get(name: string): any;
1537
+ put(name: string, item: any): void;
1538
+ protected pools: {};
1539
+ }
1540
+
1541
+ declare class ArrayUtil {
1542
+ lastItem(array: any[]): any;
1543
+ unique(array: any[]): any[];
1544
+ removeSelf(arr: any[], item: any): void;
1545
+ /**
1546
+ *
1547
+ * @param arr
1548
+ * @param desc 降序
1549
+ */
1550
+ sortNumber(arr: any[], desc?: boolean): any[];
1551
+ sortString(arr: any[], desc?: boolean): any[];
1552
+ getByPath(target: any, key: string): any;
1553
+ sortObject(arr: any[], desc: boolean, ...paths: string[]): any[];
1554
+ sortBySeq(arr: any[], desc: boolean, seq: {
1555
+ [key: string]: number;
1556
+ }, key?: string): any[];
1557
+ indexOfConf(arr: any[], caller: any, f: (item: any) => boolean): number;
1558
+ }
1559
+ declare const arrayutil: ArrayUtil;
1560
+
1561
+ declare class BitUtil {
1562
+ getState(state: number, key: number): boolean;
1563
+ setState(state: number, key: number, value: boolean): number;
1564
+ /**
1565
+ * @param state
1566
+ * @param key
1511
1567
  */
1512
- dispose(): void;
1513
- }
1514
- /**
1515
- * 对象池
1516
- */
1517
- declare class SamplePool {
1518
- list: any[];
1519
- constructor();
1568
+ getStateBig(state: bigint, key: bigint): boolean;
1569
+ setStateBig(state: bigint, key: bigint, value: boolean): bigint;
1520
1570
  /**
1521
- * 获取一个对象
1571
+ * key从0开始
1572
+ * @param val
1522
1573
  */
1523
- get(): any;
1574
+ convertToState(val: {
1575
+ [key: string]: boolean;
1576
+ }): number;
1524
1577
  /**
1525
- * 回收一个对象
1526
- * @param obj
1578
+ * 判断是否匹配
1579
+ * @param target
1580
+ * @param match 0-返回true
1527
1581
  */
1528
- put(obj: any): void;
1582
+ match(target: number, match: number): boolean;
1529
1583
  }
1530
- /**
1531
- * 对象池
1532
- */
1533
- declare class SamplePoolSet {
1534
- get(name: string): any;
1535
- put(name: string, item: any): void;
1536
- protected pools: {};
1584
+ declare const bitutil: BitUtil;
1585
+
1586
+ declare class CameraUtil {
1587
+ getUICamera(): Camera;
1588
+ }
1589
+ declare let camerautil: CameraUtil;
1590
+
1591
+ declare class CanvasUtil {
1592
+ getCanvas(): Canvas;
1593
+ protected onSceneDestroyed(event: any): void;
1594
+ _canvas: Canvas;
1537
1595
  }
1596
+ declare let canvasutil: CanvasUtil;
1538
1597
 
1539
1598
  declare class ConvertUtil {
1540
1599
  anyToBoolean(val: any, defaultValue?: boolean): boolean;
@@ -1550,6 +1609,97 @@ declare class ConvertUtil {
1550
1609
  }
1551
1610
  declare const convertutil: ConvertUtil;
1552
1611
 
1612
+ declare class DocUtil {
1613
+ copyToClip(value: string): boolean;
1614
+ selectText(textbox: any, startIndex: any, stopIndex: any): void;
1615
+ }
1616
+ declare var docutil: DocUtil;
1617
+
1618
+ declare class EventUtil {
1619
+ }
1620
+ /**
1621
+ * 框架的事件
1622
+ */
1623
+ declare const eventutil: EventUtil;
1624
+
1625
+ declare class FloatUtil {
1626
+ epsilon: number;
1627
+ neq(a: number, b: number, threshold?: number): boolean;
1628
+ eq(a: number, b: number, threshold?: number): boolean;
1629
+ gt(a: number, b: number, threshold?: number): boolean;
1630
+ lt(a: number, b: number, threshold?: number): boolean;
1631
+ geq(a: number, b: number, threshold?: number): boolean;
1632
+ leq(a: number, b: number, threshold?: number): boolean;
1633
+ }
1634
+ declare let floatutil: FloatUtil;
1635
+
1636
+ declare namespace formatutil {
1637
+ /**
1638
+ * 格式化数字
1639
+ * @param format 第nn天
1640
+ * @param val
1641
+ */
1642
+ function toChinese(formatter: string, val: number): string;
1643
+ /**
1644
+ * 转换为 x亿x万
1645
+ * @param val
1646
+ */
1647
+ function format数字使用万亿(val: number | string): string;
1648
+ /**
1649
+ * 格式化货币,每N位增加一个逗号识别
1650
+ * @param val
1651
+ * @param N
1652
+ */
1653
+ function format数字使用逗号(val: number | string, N?: number): string;
1654
+ }
1655
+
1656
+ declare enum GeometryDirection {
1657
+ East = 0,
1658
+ SouthEast = 1,
1659
+ South = 2,
1660
+ SouthWest = 3,
1661
+ West = 4,
1662
+ NorthWest = 5,
1663
+ North = 6,
1664
+ NorthEast = 7
1665
+ }
1666
+ declare class GeometryUtil {
1667
+ /**
1668
+ * mode,8表示八方向,2表示二方向(左右),4表示4方向
1669
+ * @param dot
1670
+ * @param mode
1671
+ */
1672
+ angleToDirection(dot: number, mode?: number): GeometryDirection;
1673
+ }
1674
+ declare let geoutil: GeometryUtil;
1675
+
1676
+ declare class IdentUtil {
1677
+ /**
1678
+ * 设置时间的基线,通过减去已经过去的时间,可缩短id长度
1679
+ * 注:同一个项目必须拥有同样的基线,否则有几率出现相同的id!
1680
+ * 注2:基线必须与精度符合
1681
+ * @param time
1682
+ */
1683
+ setTimeBaseline(time: number): void;
1684
+ protected _baseline: number;
1685
+ /**
1686
+ * 设置时间的精度
1687
+ * @param precision
1688
+ */
1689
+ setTimePrecision(precision: "ms" | "s"): void;
1690
+ protected _precision: string;
1691
+ /**
1692
+ * 设置随机数的长度
1693
+ * @param value
1694
+ */
1695
+ setRandLength(value?: number): void;
1696
+ protected _randLength: number;
1697
+ genOne(): string;
1698
+ protected _count: number;
1699
+ protected _lastTime: number;
1700
+ }
1701
+ declare const identutil: IdentUtil;
1702
+
1553
1703
  declare class MapUtil {
1554
1704
  /**
1555
1705
  * 获取所欲的值
@@ -1607,212 +1757,94 @@ declare class MapUtil {
1607
1757
  * 返回第一个符合条件的key
1608
1758
  * @param m
1609
1759
  * @param conf
1610
- */
1611
- keyOfConf(m: any, conf: (key: string, item: any) => boolean): string;
1612
- /**
1613
- * 比较对象,并返回包含差异的对象
1614
- * 如果返回 undefined 表示没有差异
1615
- * @param obj
1616
- * @param parent
1617
- * @param removeDefault
1618
- */
1619
- diff(obj: any, parent: any, removeDefault?: boolean): any;
1620
- /**
1621
- * 克隆对象
1622
- * @param obj
1623
- */
1624
- clone(obj: any): any;
1625
- /**
1626
- * 通过path设置属性,创建不存在的路径对象
1627
- * @param obj
1628
- * @param path "/key1/key2"
1629
- * @param data
1630
- */
1631
- setByPath(obj: any, path: string, data: any): void;
1632
- /**
1633
- * 通过path删除
1634
- * @param obj
1635
- * @param path "/key1/key2"
1636
- */
1637
- removeByPath(obj: any, path: string): void;
1638
- /**
1639
- * 通过path获取属性
1640
- * @param obj
1641
- * @param path
1642
- */
1643
- getByPath(obj: any, path: string): any;
1644
- flat(obj: any, split?: string): any;
1645
- _flat(obj: any, result: any, path: string, split?: string): any;
1646
- /**
1647
- * 比较两个对象,包括基础类型
1648
- * @param a
1649
- * @param b
1650
- */
1651
- compare(a: any, b: any): boolean;
1652
- /**
1653
- * 从[from]对象复制到 [to]对象
1654
- * 如果from字段为object并且等于null,则设置to字段为null
1655
- * 如果from字段为undefined, 则不覆盖
1656
- * @param from
1657
- * @param to
1658
- * @param tokey 如果[to]存在key才进行拷贝
1659
- */
1660
- copy(from: any, to: any, tokey?: boolean): void;
1661
- /**
1662
- * 去掉兼职
1663
- */
1664
- flatString(target: any): string;
1665
- }
1666
- declare const maputil: MapUtil;
1667
-
1668
- declare class UIUtil {
1669
- /**
1670
- * 格式化节点的uuid,用于树结构
1671
- * 树结构的路径的反斜杠与uuid有冲突
1672
- * @param uuid
1673
- */
1674
- formatUUIDForTree(uuid: string): string;
1675
- /**
1676
- * x, y 使用 鼠标点击事件产生的 event.getLocation()坐标
1677
- * @param target
1678
- * @param x
1679
- * @param y
1680
- */
1681
- hitTest(target: Node, x: number, y: number): boolean;
1682
- findNode(node: Node, name: string): Node;
1683
- walk(node: Node, f: (target: Node) => boolean): void;
1684
- _walk(node: Node, f: (target: Node) => boolean): boolean;
1685
- }
1686
- declare const uiutil: UIUtil;
1687
-
1688
- declare class EventUtil {
1689
- }
1690
- /**
1691
- * 框架的事件
1692
- */
1693
- declare const eventutil: EventUtil;
1694
-
1695
- declare class NetUtil {
1696
- decodeLocationSearch(search: string): any;
1697
- encodeLocationSearch(params: any, firstChat?: "" | "?" | "&"): string;
1698
- getLocation(): Location;
1699
- /**
1700
- * 获取Loation的参数
1701
- */
1702
- getLocationParams(): any;
1703
- }
1704
- declare const netutil: NetUtil;
1705
-
1706
- declare class ArrayUtil {
1707
- lastItem(array: any[]): any;
1708
- unique(array: any[]): any[];
1709
- removeSelf(arr: any[], item: any): void;
1710
- /**
1711
- *
1712
- * @param arr
1713
- * @param desc 降序
1714
- */
1715
- sortNumber(arr: any[], desc?: boolean): any[];
1716
- sortString(arr: any[], desc?: boolean): any[];
1717
- getByPath(target: any, key: string): any;
1718
- sortObject(arr: any[], desc: boolean, ...paths: string[]): any[];
1719
- sortBySeq(arr: any[], desc: boolean, seq: {
1720
- [key: string]: number;
1721
- }, key?: string): any[];
1722
- indexOfConf(arr: any[], caller: any, f: (item: any) => boolean): number;
1723
- }
1724
- declare const arrayutil: ArrayUtil;
1725
-
1726
- declare class ScaleUtil {
1727
- tenToAny: string[];
1728
- allstr: string;
1729
- randString(size: number, n: number): string;
1730
- decimalTo(num: number, n: number): string;
1731
- findkey(instr: string): number;
1732
- toDecimal(num: string, n: number): number;
1733
- }
1734
- declare const scaleutil: ScaleUtil;
1735
-
1736
- declare class BitUtil {
1737
- getState(state: number, key: number): boolean;
1738
- setState(state: number, key: number, value: boolean): number;
1760
+ */
1761
+ keyOfConf(m: any, conf: (key: string, item: any) => boolean): string;
1739
1762
  /**
1740
- * @param state
1741
- * @param key
1763
+ * 比较对象,并返回包含差异的对象
1764
+ * 如果返回 undefined 表示没有差异
1765
+ * @param obj
1766
+ * @param parent
1767
+ * @param removeDefault
1742
1768
  */
1743
- getStateBig(state: bigint, key: bigint): boolean;
1744
- setStateBig(state: bigint, key: bigint, value: boolean): bigint;
1769
+ diff(obj: any, parent: any, removeDefault?: boolean): any;
1745
1770
  /**
1746
- * key从0开始
1747
- * @param val
1771
+ * 克隆对象
1772
+ * @param obj
1748
1773
  */
1749
- convertToState(val: {
1750
- [key: string]: boolean;
1751
- }): number;
1774
+ clone(obj: any): any;
1752
1775
  /**
1753
- * 判断是否匹配
1754
- * @param target
1755
- * @param match 0-返回true
1776
+ * 通过path设置属性,创建不存在的路径对象
1777
+ * @param obj
1778
+ * @param path "/key1/key2"
1779
+ * @param data
1756
1780
  */
1757
- match(target: number, match: number): boolean;
1758
- }
1759
- declare const bitutil: BitUtil;
1760
-
1761
- declare class StringUtil {
1762
- lowerFirst(key: string): string;
1763
- upperFirst(key: string): string;
1764
- cjkEncode(text: any): string;
1765
- replaceFormat(format: string, source: any): string;
1781
+ setByPath(obj: any, path: string, data: any): void;
1766
1782
  /**
1767
- *
1768
- * @param format
1769
- * @param source
1783
+ * 通过path删除
1784
+ * @param obj
1785
+ * @param path "/key1/key2"
1770
1786
  */
1771
- evalFormat(format: string, source: any): string;
1772
- splitLast(val: string, separator: string): string;
1787
+ removeByPath(obj: any, path: string): void;
1773
1788
  /**
1774
- * 从最后一个分隔符截断字符串,返回截断的左右字符串
1775
- * @param val
1776
- * @param separator
1789
+ * 通过path获取属性
1790
+ * @param obj
1791
+ * @param path
1777
1792
  */
1778
- splitLastArray(val: string, separator: string): [string, string];
1793
+ getByPath(obj: any, path: string): any;
1794
+ flat(obj: any, split?: string): any;
1795
+ _flat(obj: any, result: any, path: string, split?: string): any;
1779
1796
  /**
1780
- * 截断字符串
1781
- * @param val
1782
- * @param separator
1783
- * @return [最终的字符串, 被截断的字符串]
1797
+ * 比较两个对象,包括基础类型
1798
+ * @param a
1799
+ * @param b
1784
1800
  */
1785
- truncateLast(val: string, separator: string): [string, string];
1786
- fill(str: string, char: string, length: number): string;
1787
- }
1788
- declare const stringutil: StringUtil;
1789
-
1790
- declare class IdentUtil {
1801
+ compare(a: any, b: any): boolean;
1791
1802
  /**
1792
- * 设置时间的基线,通过减去已经过去的时间,可缩短id长度
1793
- * 注:同一个项目必须拥有同样的基线,否则有几率出现相同的id!
1794
- * 注2:基线必须与精度符合
1795
- * @param time
1803
+ * 从[from]对象复制到 [to]对象
1804
+ * 如果from字段为object并且等于null,则设置to字段为null
1805
+ * 如果from字段为undefined, 则不覆盖
1806
+ * @param from
1807
+ * @param to
1808
+ * @param tokey 如果[to]存在key才进行拷贝
1796
1809
  */
1797
- setTimeBaseline(time: number): void;
1798
- protected _baseline: number;
1810
+ copy(from: any, to: any, tokey?: boolean): void;
1799
1811
  /**
1800
- * 设置时间的精度
1801
- * @param precision
1812
+ * 去掉兼职
1802
1813
  */
1803
- setTimePrecision(precision: "ms" | "s"): void;
1804
- protected _precision: string;
1814
+ flatString(target: any): string;
1815
+ }
1816
+ declare const maputil: MapUtil;
1817
+
1818
+ declare class MathUtil {
1819
+ version: number;
1820
+ TempVec2: Vec2;
1821
+ TempVec3: Vec3;
1822
+ TempVec4: Vec4;
1823
+ convertVec2to3(vec2: Vec2, useTemp?: boolean): Vec3;
1824
+ convertVec3to2(vec3: Vec3, useTemp?: boolean): Vec2;
1825
+ isOdd(value: number): boolean;
1826
+ }
1827
+ declare const mathutil: MathUtil;
1828
+
1829
+ declare class NetUtil {
1830
+ decodeLocationSearch(search: string): any;
1831
+ encodeLocationSearch(params: any, firstChat?: "" | "?" | "&"): string;
1832
+ getLocation(): Location;
1805
1833
  /**
1806
- * 设置随机数的长度
1807
- * @param value
1834
+ * 获取Loation的参数
1808
1835
  */
1809
- setRandLength(value?: number): void;
1810
- protected _randLength: number;
1811
- genOne(): string;
1812
- protected _count: number;
1813
- protected _lastTime: number;
1836
+ getLocationParams(): any;
1814
1837
  }
1815
- declare const identutil: IdentUtil;
1838
+ declare const netutil: NetUtil;
1839
+
1840
+ declare class PathUtil {
1841
+ getDir(path: string): string;
1842
+ getRelativePath(fromPath: string, toPath: string): string;
1843
+ getSamePath(fromPath: string, toPath: string): string;
1844
+ protected validatePath(path: string): void;
1845
+ protected splitPath(path: string): string[];
1846
+ }
1847
+ declare const pathutil: PathUtil;
1816
1848
 
1817
1849
  declare class RandUtil {
1818
1850
  /**
@@ -1844,17 +1876,6 @@ declare class RandUtil {
1844
1876
  }
1845
1877
  declare const randutil: RandUtil;
1846
1878
 
1847
- declare class MathUtil {
1848
- version: number;
1849
- TempVec2: Vec2;
1850
- TempVec3: Vec3;
1851
- TempVec4: Vec4;
1852
- convertVec2to3(vec2: Vec2, useTemp?: boolean): Vec3;
1853
- convertVec3to2(vec3: Vec3, useTemp?: boolean): Vec2;
1854
- isOdd(value: number): boolean;
1855
- }
1856
- declare const mathutil: MathUtil;
1857
-
1858
1879
  declare class ResUtil {
1859
1880
  loadResource(path: string): Promise<[any, IError]>;
1860
1881
  preloadResource(path: string): Promise<[any, IError]>;
@@ -1867,6 +1888,48 @@ declare class ResUtil {
1867
1888
  }
1868
1889
  declare var resutil: ResUtil;
1869
1890
 
1891
+ declare function parsePlist(plist: any, texture: any): SpriteAtlas;
1892
+ declare function loadAtlas(url: any, callback: any): void;
1893
+
1894
+ declare class ScaleUtil {
1895
+ tenToAny: string[];
1896
+ allstr: string;
1897
+ randString(size: number, n: number): string;
1898
+ decimalTo(num: number, n: number): string;
1899
+ findkey(instr: string): number;
1900
+ toDecimal(num: string, n: number): number;
1901
+ }
1902
+ declare const scaleutil: ScaleUtil;
1903
+
1904
+ declare class StringUtil {
1905
+ lowerFirst(key: string): string;
1906
+ upperFirst(key: string): string;
1907
+ cjkEncode(text: any): string;
1908
+ replaceFormat(format: string, source: any): string;
1909
+ /**
1910
+ *
1911
+ * @param format
1912
+ * @param source
1913
+ */
1914
+ evalFormat(format: string, source: any): string;
1915
+ splitLast(val: string, separator: string): string;
1916
+ /**
1917
+ * 从最后一个分隔符截断字符串,返回截断的左右字符串
1918
+ * @param val
1919
+ * @param separator
1920
+ */
1921
+ splitLastArray(val: string, separator: string): [string, string];
1922
+ /**
1923
+ * 截断字符串
1924
+ * @param val
1925
+ * @param separator
1926
+ * @return [最终的字符串, 被截断的字符串]
1927
+ */
1928
+ truncateLast(val: string, separator: string): [string, string];
1929
+ fill(str: string, char: string, length: number): string;
1930
+ }
1931
+ declare const stringutil: StringUtil;
1932
+
1870
1933
  declare class TimeUtil {
1871
1934
  sleep(time: number): Promise<void>;
1872
1935
  /**
@@ -1883,68 +1946,104 @@ declare class TimeUtil {
1883
1946
  }
1884
1947
  declare const timeutil: TimeUtil;
1885
1948
 
1886
- declare enum GeometryDirection {
1887
- East = 0,
1888
- SouthEast = 1,
1889
- South = 2,
1890
- SouthWest = 3,
1891
- West = 4,
1892
- NorthWest = 5,
1893
- North = 6,
1894
- NorthEast = 7
1895
- }
1896
- declare class GeometryUtil {
1949
+ declare class TreeUtil {
1897
1950
  /**
1898
- * mode,8表示八方向,2表示二方向(左右),4表示4方向
1899
- * @param dot
1900
- * @param mode
1951
+ * 保存指定标签[tag]的值等于[value]的节点
1952
+ * @param root
1953
+ * @param key 存储的键
1954
+ * @param tag
1955
+ * @param value
1901
1956
  */
1902
- angleToDirection(dot: number, mode?: number): GeometryDirection;
1903
- }
1904
- declare let geoutil: GeometryUtil;
1905
-
1906
- declare namespace formatutil {
1957
+ saveTagToLocalStorage(root: TreeRoot, key: string, tag: string, value: any): void;
1907
1958
  /**
1908
- * 格式化数字
1909
- * @param format 第nn天
1910
- * @param val
1959
+ * 从ls中加载指定标签[tag]的值还原到[root]。
1960
+ * 返回localStorage是否存在键值
1961
+ * @param root
1962
+ * @param key
1963
+ * @param tag
1964
+ * @param value
1911
1965
  */
1912
- function toChinese(formatter: string, val: number): string;
1966
+ loadTagFromLocalStorage(root: TreeRoot, key: string, tag: string, value: any): boolean;
1967
+ }
1968
+ declare var treeutil: TreeUtil;
1969
+
1970
+ declare class UIUtil {
1913
1971
  /**
1914
- * 转换为 x亿x万
1915
- * @param val
1972
+ * 格式化节点的uuid,用于树结构
1973
+ * 树结构的路径的反斜杠与uuid有冲突
1974
+ * @param uuid
1916
1975
  */
1917
- function format数字使用万亿(val: number | string): string;
1976
+ formatUUIDForTree(uuid: string): string;
1918
1977
  /**
1919
- * 格式化货币,每N位增加一个逗号识别
1920
- * @param val
1921
- * @param N
1978
+ * x, y 使用 鼠标点击事件产生的 event.getLocation()坐标
1979
+ * @param target
1980
+ * @param x
1981
+ * @param y
1922
1982
  */
1923
- function format数字使用逗号(val: number | string, N?: number): string;
1924
- }
1925
-
1926
- declare class FloatUtil {
1927
- epsilon: number;
1928
- neq(a: number, b: number, threshold?: number): boolean;
1929
- eq(a: number, b: number, threshold?: number): boolean;
1930
- gt(a: number, b: number, threshold?: number): boolean;
1931
- lt(a: number, b: number, threshold?: number): boolean;
1932
- geq(a: number, b: number, threshold?: number): boolean;
1933
- leq(a: number, b: number, threshold?: number): boolean;
1983
+ hitTest(target: Node, x: number, y: number): boolean;
1984
+ findNode(node: Node, name: string): Node;
1985
+ walk(node: Node, f: (target: Node) => boolean): void;
1986
+ _walk(node: Node, f: (target: Node) => boolean): boolean;
1934
1987
  }
1935
- declare let floatutil: FloatUtil;
1988
+ declare const uiutil: UIUtil;
1936
1989
 
1937
- declare class PathUtil {
1938
- getDir(path: string): string;
1939
- getRelativePath(fromPath: string, toPath: string): string;
1940
- getSamePath(fromPath: string, toPath: string): string;
1941
- protected validatePath(path: string): void;
1942
- protected splitPath(path: string): string[];
1990
+ declare class WidgetAlign {
1991
+ node: Node;
1992
+ targetNode: Node;
1993
+ protected nodeWidget: Widget;
1994
+ protected parentTransform: UITransform;
1995
+ protected targetTransform: UITransform;
1996
+ protected uipos: math.Vec3;
1997
+ constructor(node: Node, targetNode: Node);
1998
+ topTop(distance?: number): void;
1999
+ topBottom(distance?: number): void;
2000
+ leftleft(distance?: number): void;
2001
+ leftRight(distance?: number): void;
2002
+ }
2003
+ declare class WidgetUtil {
2004
+ /**
2005
+ * 与目标顶对齐
2006
+ * @param node 需要修改的节点
2007
+ * @param parent 对齐的父节点
2008
+ * @param distance
2009
+ */
2010
+ alignTop(node: Node, parent: Node, distance?: number): void;
2011
+ /**
2012
+ * 与目标顶对齐,node和target都必须在渲染树中
2013
+ * @param node 需要修改的节点
2014
+ * @param target 对齐目标
2015
+ * @param distance
2016
+ */
2017
+ alignTopWorld(node: Node, target: Node, distance?: number): void;
2018
+ /**
2019
+ * 与目标顶对齐,node和target都必须在渲染树中
2020
+ * @param node 需要修改的节点
2021
+ * @param target 对齐目标
2022
+ * @param distance
2023
+ */
2024
+ alignBottomWorld(node: Node, target: Node, distance?: number): void;
2025
+ /**
2026
+ * 调整【node】的widget,对齐【targetNode】
2027
+ * @param node
2028
+ * @param targetNode
2029
+ */
2030
+ align(node: Node, targetNode: Node): WidgetAlign;
2031
+ /**
2032
+ * 与目标右对齐
2033
+ * @param node 需要修改的节点
2034
+ * @param parent 对齐的父节点
2035
+ * @param distance
2036
+ */
2037
+ alignLeft(node: Node, parent: Node, distance?: number): void;
2038
+ /**
2039
+ * 与目标右对齐
2040
+ * @param node 需要修改的节点
2041
+ * @param target 对齐目标
2042
+ * @param distance
2043
+ */
2044
+ alignLeftWorld(node: Node, target: Node, distance?: number): void;
1943
2045
  }
1944
- declare const pathutil: PathUtil;
1945
-
1946
- declare function parsePlist(plist: any, texture: any): SpriteAtlas;
1947
- declare function loadAtlas(url: any, callback: any): void;
2046
+ declare var widgetutil: WidgetUtil;
1948
2047
 
1949
- export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, Controller, ControllerDict, ControllerSet, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, ErrorUtil, EventItem, EventManager, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapUtil, MathUtil, Model, Module, NetUtil, Page, PageController, PageEvent, PageLayer, PageList, PageRepo, PageState, PathUtil, Pool, RandUtil, Route, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, UIManager, UIObjectDict, UIPoolConfig, UISingleConfig, UIUtil, ViewController, XAssetManager, XEvent, arrayutil, assetx, bitutil, convertutil, ctrlrepo, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, pagerepo, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, uidict, uimgr, uiutil };
2048
+ export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerSet, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil, EventItem, EventManager, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapUtil, MathUtil, Model, Module, NetUtil, Page, PageController, PageControllerDict, PageEvent, PageLayer, PageList, PageRepo, PageState, PathUtil, Pool, RandUtil, Route, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectDict, UIPoolConfig, UISingleConfig, UIUtil, ViewController, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, pagerepo, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, treeutil, uidict, uimgr, uiutil, widgetutil };
1950
2049
  export type { CreatorFunction, DisposeFunction, IController, IError, IEventManager, IExtend, IListItem, IModel, IModule, IModuleSample, ITreeListItem, RecycleFunction };