@zhongguo168a/yxeditor-common 0.0.166 → 0.0.167

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
@@ -671,8 +671,8 @@ declare class List<T = any> {
671
671
  * @param other
672
672
  */
673
673
  pushList(other: List<T>): void;
674
- getData(): T[];
675
- resetData(val: T[]): void;
674
+ array(): T[];
675
+ resetArray(val: T[]): void;
676
676
  /**
677
677
  * 随机获取【count】个项,并返回【target】对象
678
678
  * @param count
@@ -689,7 +689,7 @@ declare class List<T = any> {
689
689
  randomOne(): T;
690
690
  protected callPush(value: any): void;
691
691
  protected callRemove(value: any): void;
692
- protected _data: any[];
692
+ protected _array: any[];
693
693
  private _onSet;
694
694
  private _onDelete;
695
695
  private _onSetCaller;
@@ -736,7 +736,7 @@ declare class ListSource extends EventDispatcher {
736
736
  * @param idCreator
737
737
  */
738
738
  static createByArray(arr: any[], target?: ListSource, idCreator?: (item: any) => string): ListSource;
739
- static createByListItem(arr: IListItem[], target?: ListSource): any;
739
+ static createByListItem(arr: IListItem[], target?: ListSource): ListSource;
740
740
  /**
741
741
  * 设置数据时触发
742
742
  * dispatchParams = {node:ListNode}
@@ -799,8 +799,8 @@ declare class ListSource extends EventDispatcher {
799
799
  refresh(node: ListNode): void;
800
800
  walk(f: (node: ListNode) => boolean): boolean;
801
801
  walkPrev(node: ListNode, f: (node: ListNode) => boolean): boolean;
802
- get data(): List<ListNode>;
803
- private _data;
802
+ get list(): List<ListNode>;
803
+ private _list;
804
804
  }
805
805
 
806
806
  declare class DictIterator {
package/dist/index.esm.js CHANGED
@@ -2603,7 +2603,7 @@ class ListIterator {
2603
2603
  }
2604
2604
  class List {
2605
2605
  constructor() {
2606
- this._data = [];
2606
+ this._array = [];
2607
2607
  this._onSet = null;
2608
2608
  this._onDelete = null;
2609
2609
  }
@@ -2616,7 +2616,7 @@ class List {
2616
2616
  this._onDeleteCaller = caller;
2617
2617
  }
2618
2618
  firstByCondition(conf) {
2619
- let data = this._data;
2619
+ let data = this._array;
2620
2620
  for (let i = 0; i < data.length; i++) {
2621
2621
  let item = data[i];
2622
2622
  if (conf(i, item)) {
@@ -2626,7 +2626,7 @@ class List {
2626
2626
  return [-1, null];
2627
2627
  }
2628
2628
  lastByCondition(conf) {
2629
- let data = this._data;
2629
+ let data = this._array;
2630
2630
  for (let i = data.length - 1; i >= 0; i--) {
2631
2631
  let item = data[i];
2632
2632
  if (conf(i, item)) {
@@ -2637,7 +2637,7 @@ class List {
2637
2637
  }
2638
2638
  forEach(handler) {
2639
2639
  let iterator = new ListIterator();
2640
- let data = this._data;
2640
+ let data = this._array;
2641
2641
  for (let i = 0; i < data.length; i++) {
2642
2642
  let item = data[i];
2643
2643
  handler(i, item, iterator);
@@ -2654,7 +2654,7 @@ class List {
2654
2654
  */
2655
2655
  removeByCondition(cond, removedList) {
2656
2656
  let iterator = new ListIterator();
2657
- let data = this._data;
2657
+ let data = this._array;
2658
2658
  for (let i = data.length - 1; i >= 0; i--) {
2659
2659
  let item = data[i];
2660
2660
  if (cond(i, item, iterator)) {
@@ -2679,7 +2679,7 @@ class List {
2679
2679
  throw new Error("需要设置目标对象");
2680
2680
  }
2681
2681
  let iterator = new ListIterator();
2682
- let data = this._data;
2682
+ let data = this._array;
2683
2683
  for (let i = 0; i < data.length; i++) {
2684
2684
  let item = data[i];
2685
2685
  if (cond(i, item, iterator)) ;
@@ -2690,29 +2690,29 @@ class List {
2690
2690
  return target;
2691
2691
  }
2692
2692
  pop() {
2693
- let item = this._data.pop();
2693
+ let item = this._array.pop();
2694
2694
  this.callRemove(item);
2695
2695
  return item;
2696
2696
  }
2697
2697
  shift() {
2698
- let item = this._data.shift();
2698
+ let item = this._array.shift();
2699
2699
  this.callRemove(item);
2700
2700
  return item;
2701
2701
  }
2702
2702
  first() {
2703
- return this._data[0];
2703
+ return this._array[0];
2704
2704
  }
2705
2705
  last() {
2706
- return this._data[this._data.length - 1];
2706
+ return this._array[this._array.length - 1];
2707
2707
  }
2708
2708
  removeAt(index) {
2709
2709
  if (index >= 0) {
2710
- let removed = this._data.splice(index, 1);
2710
+ let removed = this._array.splice(index, 1);
2711
2711
  this.callRemove(removed[0]);
2712
2712
  }
2713
2713
  }
2714
2714
  remove(item) {
2715
- let data = this._data;
2715
+ let data = this._array;
2716
2716
  let index = data.indexOf(item);
2717
2717
  if (index != -1) {
2718
2718
  data.splice(index, 1);
@@ -2724,22 +2724,22 @@ class List {
2724
2724
  * @param other
2725
2725
  */
2726
2726
  removeList(other) {
2727
- for (const item of other._data) {
2727
+ for (const item of other._array) {
2728
2728
  this.remove(item);
2729
2729
  }
2730
2730
  }
2731
2731
  sort(compareFn) {
2732
- this._data.sort(compareFn);
2732
+ this._array.sort(compareFn);
2733
2733
  }
2734
2734
  reverse() {
2735
- this._data.reverse();
2735
+ this._array.reverse();
2736
2736
  }
2737
2737
  /**
2738
2738
  * useIter默认为true,因为如果是false的话,没有触发onSet,导致数据污染
2739
2739
  * @param useIter 使用遍历的方式可以触发onSet
2740
2740
  */
2741
2741
  clear(useIter = true) {
2742
- let data = this._data;
2742
+ let data = this._array;
2743
2743
  if (useIter) {
2744
2744
  for (let i = 0; i < data.length; i++) {
2745
2745
  const item = data[i];
@@ -2747,7 +2747,7 @@ class List {
2747
2747
  }
2748
2748
  }
2749
2749
  else {
2750
- this._data.length = 0;
2750
+ this._array.length = 0;
2751
2751
  }
2752
2752
  }
2753
2753
  /**
@@ -2756,7 +2756,7 @@ class List {
2756
2756
  * @param useIter 使用遍历的方式可以触发onSet
2757
2757
  */
2758
2758
  clone(target, useIter = true) {
2759
- let data = this._data;
2759
+ let data = this._array;
2760
2760
  if (useIter) {
2761
2761
  for (let i = 0; i < data.length; i++) {
2762
2762
  const item = data[i];
@@ -2764,16 +2764,16 @@ class List {
2764
2764
  }
2765
2765
  }
2766
2766
  else {
2767
- let newdata = target.getData().concat(data);
2768
- target.resetData(newdata);
2767
+ let newdata = target.array().concat(data);
2768
+ target.resetArray(newdata);
2769
2769
  }
2770
2770
  return target;
2771
2771
  }
2772
2772
  get length() {
2773
- return this._data.length;
2773
+ return this._array.length;
2774
2774
  }
2775
2775
  insertAt(index, ...item) {
2776
- this._data.splice(index, 0, ...item);
2776
+ this._array.splice(index, 0, ...item);
2777
2777
  this.callPush(item);
2778
2778
  }
2779
2779
  /**
@@ -2781,7 +2781,7 @@ class List {
2781
2781
  * @param item
2782
2782
  */
2783
2783
  insertBefore(beforeItem, ...item) {
2784
- let data = this._data;
2784
+ let data = this._array;
2785
2785
  let index = data.indexOf(beforeItem);
2786
2786
  if (index == -1) {
2787
2787
  data.push(item);
@@ -2796,7 +2796,7 @@ class List {
2796
2796
  * @param item
2797
2797
  */
2798
2798
  insertAfter(afterItem, ...item) {
2799
- let data = this._data;
2799
+ let data = this._array;
2800
2800
  let index = data.indexOf(afterItem);
2801
2801
  if (index == -1) {
2802
2802
  data.push(item);
@@ -2807,33 +2807,33 @@ class List {
2807
2807
  this.callPush(item);
2808
2808
  }
2809
2809
  at(index) {
2810
- return this._data[index];
2810
+ return this._array[index];
2811
2811
  }
2812
2812
  set(index, item) {
2813
- let existed = this._data[index];
2813
+ let existed = this._array[index];
2814
2814
  if (existed) {
2815
2815
  if (existed == item) {
2816
2816
  return;
2817
2817
  }
2818
2818
  this.callRemove(existed);
2819
2819
  }
2820
- this._data[index] = item;
2820
+ this._array[index] = item;
2821
2821
  this.callPush(item);
2822
2822
  }
2823
2823
  swap(a, b) {
2824
2824
  let aidx = this.indexOf(a);
2825
2825
  let bidx = this.indexOf(b);
2826
- let d = this._data;
2826
+ let d = this._array;
2827
2827
  [d[aidx], d[bidx]] = [d[bidx], a[aidx]];
2828
2828
  }
2829
2829
  indexOf(item) {
2830
- return this._data.indexOf(item);
2830
+ return this._array.indexOf(item);
2831
2831
  }
2832
2832
  has(item) {
2833
- return this._data.indexOf(item) != -1;
2833
+ return this._array.indexOf(item) != -1;
2834
2834
  }
2835
2835
  push(item) {
2836
- this._data.push(item);
2836
+ this._array.push(item);
2837
2837
  this.callPush(item);
2838
2838
  }
2839
2839
  /**
@@ -2841,15 +2841,15 @@ class List {
2841
2841
  * @param other
2842
2842
  */
2843
2843
  pushList(other) {
2844
- for (const item of other._data) {
2844
+ for (const item of other._array) {
2845
2845
  this.push(item);
2846
2846
  }
2847
2847
  }
2848
- getData() {
2849
- return this._data;
2848
+ array() {
2849
+ return this._array;
2850
2850
  }
2851
- resetData(val) {
2852
- this._data = val;
2851
+ resetArray(val) {
2852
+ this._array = val;
2853
2853
  }
2854
2854
  /**
2855
2855
  * 随机获取【count】个项,并返回【target】对象
@@ -2861,11 +2861,11 @@ class List {
2861
2861
  if (!target) {
2862
2862
  target = new List();
2863
2863
  }
2864
- let data = this._data;
2864
+ let data = this._array;
2865
2865
  if (data.length <= 0) {
2866
2866
  return target;
2867
2867
  }
2868
- const copyItems = [...this._data]; // 创建副本以避免修改原数组
2868
+ const copyItems = [...this._array]; // 创建副本以避免修改原数组
2869
2869
  for (let i = 0; i < count && copyItems.length > 0; i++) {
2870
2870
  const randomIndex = Math.floor(Math.random() * copyItems.length);
2871
2871
  target.push(copyItems[randomIndex]);
@@ -2882,7 +2882,7 @@ class List {
2882
2882
  * @param target
2883
2883
  */
2884
2884
  randomOne() {
2885
- let data = this._data;
2885
+ let data = this._array;
2886
2886
  if (data.length <= 0) {
2887
2887
  return null;
2888
2888
  }
@@ -2934,7 +2934,7 @@ class ListNode {
2934
2934
  class ListSource extends EventDispatcher {
2935
2935
  constructor() {
2936
2936
  super(...arguments);
2937
- this._data = new List();
2937
+ this._list = new List();
2938
2938
  }
2939
2939
  /**
2940
2940
  * 通过数组创建 ListSource。ListSource的id自动生成。如果需要指定编号,可设置 idCreator
@@ -2975,16 +2975,16 @@ class ListSource extends EventDispatcher {
2975
2975
  return target;
2976
2976
  }
2977
2977
  at(index) {
2978
- return this._data.at(index);
2978
+ return this._list.at(index);
2979
2979
  }
2980
2980
  first() {
2981
- return this._data.first();
2981
+ return this._list.first();
2982
2982
  }
2983
2983
  last() {
2984
- return this._data.last();
2984
+ return this._list.last();
2985
2985
  }
2986
2986
  get length() {
2987
- return this._data.length;
2987
+ return this._list.length;
2988
2988
  }
2989
2989
  /**
2990
2990
  * 添加项,无法添加相同的项
@@ -2995,15 +2995,15 @@ class ListSource extends EventDispatcher {
2995
2995
  if (this.contains(node)) {
2996
2996
  return;
2997
2997
  }
2998
- this._data.push(node);
2998
+ this._list.push(node);
2999
2999
  node.root = this;
3000
3000
  if (enableDispatch) {
3001
3001
  this.dispatch(ListSource.EVENT_ADD, { node: node });
3002
3002
  }
3003
3003
  }
3004
3004
  getById(id) {
3005
- for (let i = 0; i < this._data.length; i++) {
3006
- let node = this._data.at(i);
3005
+ for (let i = 0; i < this._list.length; i++) {
3006
+ let node = this._list.at(i);
3007
3007
  if (node.id == id) {
3008
3008
  return node;
3009
3009
  }
@@ -3011,20 +3011,20 @@ class ListSource extends EventDispatcher {
3011
3011
  return null;
3012
3012
  }
3013
3013
  remove(node) {
3014
- let index = this._data.indexOf(node);
3014
+ let index = this._list.indexOf(node);
3015
3015
  if (index == -1) {
3016
3016
  return;
3017
3017
  }
3018
3018
  node.root = null;
3019
- this._data.removeAt(index);
3019
+ this._list.removeAt(index);
3020
3020
  this.dispatch(ListSource.EVENT_REMOVE, { node: node, index: index });
3021
3021
  }
3022
3022
  removeAll() {
3023
- this._data.clear();
3023
+ this._list.clear();
3024
3024
  this.dispatch(ListSource.EVENT_REMOVE_ALL);
3025
3025
  }
3026
3026
  swap(a, b) {
3027
- this._data.swap(a, b);
3027
+ this._list.swap(a, b);
3028
3028
  this.dispatch(ListSource.EVENT_SWAP, { nodes: [a, b] });
3029
3029
  }
3030
3030
  contains(node) {
@@ -3034,8 +3034,8 @@ class ListSource extends EventDispatcher {
3034
3034
  return this.indexOfById(id) != -1;
3035
3035
  }
3036
3036
  indexOf(node) {
3037
- for (let i = 0; i < this._data.length; i++) {
3038
- let item = this._data.at(i);
3037
+ for (let i = 0; i < this._list.length; i++) {
3038
+ let item = this._list.at(i);
3039
3039
  if (item.id == node.id) {
3040
3040
  return i;
3041
3041
  }
@@ -3043,8 +3043,8 @@ class ListSource extends EventDispatcher {
3043
3043
  return -1;
3044
3044
  }
3045
3045
  indexOfById(id) {
3046
- for (let i = 0; i < this._data.length; i++) {
3047
- let item = this._data.at(i);
3046
+ for (let i = 0; i < this._list.length; i++) {
3047
+ let item = this._list.at(i);
3048
3048
  if (item.id == id) {
3049
3049
  return i;
3050
3050
  }
@@ -3075,7 +3075,7 @@ class ListSource extends EventDispatcher {
3075
3075
  }
3076
3076
  walk(f) {
3077
3077
  for (let i = 0; i < this.length; i++) {
3078
- let item = this._data.at(i);
3078
+ let item = this._list.at(i);
3079
3079
  if (!f(item)) {
3080
3080
  return false;
3081
3081
  }
@@ -3087,14 +3087,14 @@ class ListSource extends EventDispatcher {
3087
3087
  return;
3088
3088
  }
3089
3089
  for (let i = index; i >= 0; i--) {
3090
- let item = this._data.at(i);
3090
+ let item = this._list.at(i);
3091
3091
  if (!f(item)) {
3092
3092
  return false;
3093
3093
  }
3094
3094
  }
3095
3095
  }
3096
- get data() {
3097
- return this._data;
3096
+ get list() {
3097
+ return this._list;
3098
3098
  }
3099
3099
  }
3100
3100
  /**
@@ -4735,7 +4735,7 @@ class CallbackList {
4735
4735
  if (this._data.length == 0) {
4736
4736
  return;
4737
4737
  }
4738
- let data = this._data.getData();
4738
+ let data = this._data.array();
4739
4739
  for (let listener of data) {
4740
4740
  if (listener.isOn()) {
4741
4741
  listener._dispatch(params, subIdent);