@zhongguo168a/yxeditor-common 0.0.53 → 0.0.55

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
@@ -1010,6 +1010,136 @@ declare class Route {
1010
1010
  declare class RouteList extends List<Route> {
1011
1011
  }
1012
1012
 
1013
+ declare class MapObject extends Dictionary<string, MapValue> {
1014
+ object: {};
1015
+ constructor(object: {});
1016
+ getValue(key: string): MapValue;
1017
+ }
1018
+ declare class MapValue {
1019
+ obj: {};
1020
+ key: any;
1021
+ constructor(obj: {}, key: any);
1022
+ isUndefined(): boolean;
1023
+ toNumber(): number;
1024
+ toString(): string;
1025
+ toBoolean(): boolean;
1026
+ toAny(): any;
1027
+ }
1028
+ declare class MapUtil {
1029
+ /**
1030
+ * 获取所欲的值
1031
+ */
1032
+ values<T = any>(m: {
1033
+ [key: string]: T;
1034
+ }): T[];
1035
+ /**
1036
+ * 获取所有的键
1037
+ */
1038
+ keys(m: {
1039
+ [key: string]: any;
1040
+ }): string[];
1041
+ /**
1042
+ * 以字符串数字作为键值的map,转化成数组
1043
+ */
1044
+ toList<T = any>(m: {
1045
+ [key: string]: T;
1046
+ }): T[];
1047
+ /**
1048
+ * 以字符串数字作为键值的map,转化成数组
1049
+ */
1050
+ listToMap(list: any[]): any;
1051
+ /**
1052
+ * 转换成数字, 如果原值无效, 返回0
1053
+ * @constructor
1054
+ */
1055
+ has(m: any, key: string): boolean;
1056
+ /**
1057
+ * 转换成数字, 如果原值无效, 返回0
1058
+ * @constructor
1059
+ */
1060
+ number(m: any, key: string, dflt?: number): number;
1061
+ /**
1062
+ * 转换成字符串, 如果原值无效, 返回""
1063
+ * @constructor
1064
+ */
1065
+ string(m: any, key: string, dflt?: string): string;
1066
+ /**
1067
+ * 转换成布尔值, 如果原值无效, 返回false
1068
+ * @constructor
1069
+ */
1070
+ boolean(m: any, key: string, dflt?: boolean): boolean;
1071
+ /**
1072
+ * 转换成{}, 如果原值无效, 返回{}
1073
+ * @constructor
1074
+ */
1075
+ map(m: any, key: string, dflt?: boolean | Object): any;
1076
+ /**
1077
+ * 转换成[], 如果原值无效, 返回[]
1078
+ * @constructor
1079
+ */
1080
+ array(m: any, key: string, dflt?: boolean | Array<any>): any[];
1081
+ /**
1082
+ * 返回第一个符合条件的key
1083
+ * @param m
1084
+ * @param conf
1085
+ */
1086
+ keyOfConf(m: any, conf: (key: string, item: any) => boolean): string;
1087
+ /**
1088
+ * 比较对象,并返回包含差异的对象
1089
+ * 如果返回 undefined 表示没有差异
1090
+ * @param obj
1091
+ * @param parent
1092
+ * @param removeDefault
1093
+ */
1094
+ diff(obj: any, parent: any, removeDefault?: boolean): any;
1095
+ /**
1096
+ * 克隆对象
1097
+ * @param obj
1098
+ */
1099
+ clone(obj: any): any;
1100
+ /**
1101
+ * 通过path设置属性,创建不存在的路径对象
1102
+ * @param obj
1103
+ * @param path "/key1/key2"
1104
+ * @param data
1105
+ */
1106
+ setByPath(obj: any, path: string, data: any): void;
1107
+ /**
1108
+ * 通过path删除
1109
+ * @param obj
1110
+ * @param path "/key1/key2"
1111
+ */
1112
+ removeByPath(obj: any, path: string): void;
1113
+ /**
1114
+ * 通过path获取属性
1115
+ * @param obj
1116
+ * @param path
1117
+ */
1118
+ getByPath(obj: any, path: string): any;
1119
+ flat(obj: any, split?: string): any;
1120
+ _flat(obj: any, result: any, path: string, split?: string): any;
1121
+ /**
1122
+ * 比较两个对象,包括基础类型
1123
+ * @param a
1124
+ * @param b
1125
+ */
1126
+ compare(a: any, b: any): boolean;
1127
+ /**
1128
+ * 从[from]对象复制到 [to]对象
1129
+ * 如果from字段为object并且等于null,则设置to字段为null
1130
+ * 如果from字段为undefined, 则不覆盖
1131
+ * @param from
1132
+ * @param to
1133
+ * @param tokey 如果[to]存在key才进行拷贝
1134
+ */
1135
+ copy(from: any, to: any, tokey?: boolean): void;
1136
+ /**
1137
+ * 去掉兼职
1138
+ */
1139
+ flatString(target: any): string;
1140
+ }
1141
+ declare const maputil: MapUtil;
1142
+
1013
1143
  declare enum ViewState {
1014
1144
  /**
1015
1145
  * 关闭
@@ -1071,8 +1201,8 @@ declare class RouteView extends EventDispatcher {
1071
1201
  onStop(value: (ctx: this) => void): this;
1072
1202
  get reason(): LinkError;
1073
1203
  node: Node;
1074
- datas: {};
1075
- tags: {};
1204
+ datas: MapObject;
1205
+ tags: MapObject;
1076
1206
  enableHistory: boolean;
1077
1207
  layer: string;
1078
1208
  state: ViewState;
@@ -1358,7 +1488,10 @@ declare class AssetLoader extends Dispatcher {
1358
1488
  onComplete?: (err: any, asset: any) => void;
1359
1489
  preload?: boolean;
1360
1490
  }): this;
1361
- loadConfig(uri: string): this;
1491
+ loadJson(uri: string, otherConfig?: {
1492
+ onComplete?: (err: any, asset: any) => void;
1493
+ preload?: boolean;
1494
+ }): this;
1362
1495
  loadSpriteFrame(uri: string, otherConfig?: {
1363
1496
  onComplete?: (err: any, asset: any) => void;
1364
1497
  uuid?: string;
@@ -1687,121 +1820,6 @@ declare class IdentUtil {
1687
1820
  }
1688
1821
  declare const identutil: IdentUtil;
1689
1822
 
1690
- declare class MapUtil {
1691
- /**
1692
- * 获取所欲的值
1693
- */
1694
- values<T = any>(m: {
1695
- [key: string]: T;
1696
- }): T[];
1697
- /**
1698
- * 获取所有的键
1699
- */
1700
- keys(m: {
1701
- [key: string]: any;
1702
- }): string[];
1703
- /**
1704
- * 以字符串数字作为键值的map,转化成数组
1705
- */
1706
- toList<T = any>(m: {
1707
- [key: string]: T;
1708
- }): T[];
1709
- /**
1710
- * 以字符串数字作为键值的map,转化成数组
1711
- */
1712
- listToMap(list: any[]): any;
1713
- /**
1714
- * 转换成数字, 如果原值无效, 返回0
1715
- * @constructor
1716
- */
1717
- has(m: any, key: string): boolean;
1718
- /**
1719
- * 转换成数字, 如果原值无效, 返回0
1720
- * @constructor
1721
- */
1722
- number(m: any, key: string, dflt?: number): number;
1723
- /**
1724
- * 转换成字符串, 如果原值无效, 返回""
1725
- * @constructor
1726
- */
1727
- string(m: any, key: string, dflt?: string): string;
1728
- /**
1729
- * 转换成布尔值, 如果原值无效, 返回false
1730
- * @constructor
1731
- */
1732
- boolean(m: any, key: string, dflt?: boolean): boolean;
1733
- /**
1734
- * 转换成{}, 如果原值无效, 返回{}
1735
- * @constructor
1736
- */
1737
- map(m: any, key: string, dflt?: boolean | Object): any;
1738
- /**
1739
- * 转换成[], 如果原值无效, 返回[]
1740
- * @constructor
1741
- */
1742
- array(m: any, key: string, dflt?: boolean | Array<any>): any[];
1743
- /**
1744
- * 返回第一个符合条件的key
1745
- * @param m
1746
- * @param conf
1747
- */
1748
- keyOfConf(m: any, conf: (key: string, item: any) => boolean): string;
1749
- /**
1750
- * 比较对象,并返回包含差异的对象
1751
- * 如果返回 undefined 表示没有差异
1752
- * @param obj
1753
- * @param parent
1754
- * @param removeDefault
1755
- */
1756
- diff(obj: any, parent: any, removeDefault?: boolean): any;
1757
- /**
1758
- * 克隆对象
1759
- * @param obj
1760
- */
1761
- clone(obj: any): any;
1762
- /**
1763
- * 通过path设置属性,创建不存在的路径对象
1764
- * @param obj
1765
- * @param path "/key1/key2"
1766
- * @param data
1767
- */
1768
- setByPath(obj: any, path: string, data: any): void;
1769
- /**
1770
- * 通过path删除
1771
- * @param obj
1772
- * @param path "/key1/key2"
1773
- */
1774
- removeByPath(obj: any, path: string): void;
1775
- /**
1776
- * 通过path获取属性
1777
- * @param obj
1778
- * @param path
1779
- */
1780
- getByPath(obj: any, path: string): any;
1781
- flat(obj: any, split?: string): any;
1782
- _flat(obj: any, result: any, path: string, split?: string): any;
1783
- /**
1784
- * 比较两个对象,包括基础类型
1785
- * @param a
1786
- * @param b
1787
- */
1788
- compare(a: any, b: any): boolean;
1789
- /**
1790
- * 从[from]对象复制到 [to]对象
1791
- * 如果from字段为object并且等于null,则设置to字段为null
1792
- * 如果from字段为undefined, 则不覆盖
1793
- * @param from
1794
- * @param to
1795
- * @param tokey 如果[to]存在key才进行拷贝
1796
- */
1797
- copy(from: any, to: any, tokey?: boolean): void;
1798
- /**
1799
- * 去掉兼职
1800
- */
1801
- flatString(target: any): string;
1802
- }
1803
- declare const maputil: MapUtil;
1804
-
1805
1823
  declare class MathUtil {
1806
1824
  version: number;
1807
1825
  TempVec2: Vec2;
@@ -2044,5 +2062,5 @@ declare class WidgetUtil {
2044
2062
  }
2045
2063
  declare var widgetutil: WidgetUtil;
2046
2064
 
2047
- export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapUtil, MathUtil, Model, NetUtil, PathUtil, Pool, RandUtil, Route, RouteController, RouteList, RouteView, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewRepo, ViewState, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, ctrlrepo, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, treeutil, uimgr, uirepo, uiutil, viewhistorys, viewrepo, widgetutil };
2065
+ export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapObject, MapUtil, MapValue, MathUtil, Model, NetUtil, PathUtil, Pool, RandUtil, Route, RouteController, RouteList, RouteView, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewRepo, ViewState, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, ctrlrepo, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, treeutil, uimgr, uirepo, uiutil, viewhistorys, viewrepo, widgetutil };
2048
2066
  export type { CreatorFunction, DisposeFunction, IController, IError, IEventDispatcher, IExtend, IListItem, IModel, IModule, ITreeListItem, RecycleFunction };
package/dist/index.esm.js CHANGED
@@ -1121,6 +1121,41 @@ class ConvertUtil {
1121
1121
  }
1122
1122
  const convertutil = new ConvertUtil();
1123
1123
 
1124
+ class MapObject extends Dictionary {
1125
+ constructor(object) {
1126
+ super();
1127
+ this.object = object;
1128
+ }
1129
+ getValue(key) {
1130
+ let value = this.get(key);
1131
+ if (!value) {
1132
+ value = new MapValue(this, key);
1133
+ this.set(key, value);
1134
+ }
1135
+ return value;
1136
+ }
1137
+ }
1138
+ class MapValue {
1139
+ constructor(obj, key) {
1140
+ this.obj = obj;
1141
+ this.key = key;
1142
+ }
1143
+ isUndefined() {
1144
+ return this.obj[this.key] == undefined;
1145
+ }
1146
+ toNumber() {
1147
+ return maputil.number(this.obj, this.key);
1148
+ }
1149
+ toString() {
1150
+ return maputil.string(this.obj, this.key);
1151
+ }
1152
+ toBoolean() {
1153
+ return maputil.boolean(this.obj, this.key);
1154
+ }
1155
+ toAny() {
1156
+ return this.obj[this.key];
1157
+ }
1158
+ }
1124
1159
  class MapUtil {
1125
1160
  /**
1126
1161
  * 获取所欲的值
@@ -3855,8 +3890,8 @@ class RouteView extends EventDispatcher {
3855
3890
  super();
3856
3891
  this._waitOpenComplete = false;
3857
3892
  this._waitCloseComplete = false;
3858
- this.datas = {};
3859
- this.tags = {};
3893
+ this.datas = new MapObject({});
3894
+ this.tags = new MapObject({});
3860
3895
  this.enableHistory = false;
3861
3896
  this.state = 0;
3862
3897
  this._onStop = (ctx) => {
@@ -4571,10 +4606,14 @@ class AssetLoader extends Dispatcher {
4571
4606
  this._loaderList.push(item);
4572
4607
  return this;
4573
4608
  }
4574
- loadConfig(uri) {
4609
+ loadJson(uri, otherConfig) {
4575
4610
  let item = new LoaderItem();
4576
- item.type = "Config";
4611
+ item.type = "Json";
4577
4612
  item.uri = new AssetURI(uri);
4613
+ if (otherConfig) {
4614
+ item.onComplete = otherConfig.onComplete;
4615
+ item.preload = otherConfig.preload != undefined ? otherConfig.preload : false;
4616
+ }
4578
4617
  this._loaderList.push(item);
4579
4618
  return this;
4580
4619
  }
@@ -4642,7 +4681,7 @@ class AssetLoader extends Dispatcher {
4642
4681
  });
4643
4682
  break;
4644
4683
  }
4645
- case "Config": {
4684
+ case "Json": {
4646
4685
  assetManager.loadBundle(item.uri.bundle, (err, bundle) => {
4647
4686
  if (this._stop) {
4648
4687
  return;
@@ -6349,5 +6388,5 @@ class WidgetUtil {
6349
6388
  }
6350
6389
  var widgetutil = new WidgetUtil();
6351
6390
 
6352
- export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapUtil, MathUtil, Model, NetUtil, PathUtil, Pool, RandUtil, Route, RouteController, RouteList, RouteView, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewRepo, ViewState, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, ctrlrepo, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, treeutil, uimgr, uirepo, uiutil, viewhistorys, viewrepo, widgetutil };
6391
+ export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapObject, MapUtil, MapValue, MathUtil, Model, NetUtil, PathUtil, Pool, RandUtil, Route, RouteController, RouteList, RouteView, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewRepo, ViewState, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, ctrlrepo, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, treeutil, uimgr, uirepo, uiutil, viewhistorys, viewrepo, widgetutil };
6353
6392
  //# sourceMappingURL=index.esm.js.map