@zhongguo168a/yxeditor-common 0.0.85 → 0.0.87
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 +91 -23
- package/dist/index.esm.js +185 -160
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -775,9 +775,15 @@ declare class Dictionary<K = string, V = any> {
|
|
|
775
775
|
* @param target 存到目标对象中
|
|
776
776
|
*/
|
|
777
777
|
findByCondition(cond: (key: K, val: V, iterator: DictIterator) => boolean, target: Dictionary): this;
|
|
778
|
-
|
|
778
|
+
groupByKey(keyCreator: (key: K, val: V) => string, ITEM_CLASS?: any): {
|
|
779
779
|
[key: string]: any;
|
|
780
780
|
};
|
|
781
|
+
countByKeyList(keyCreator: (key: K, val: V) => string[]): {
|
|
782
|
+
[key: string]: number;
|
|
783
|
+
};
|
|
784
|
+
countByKey(keyCreator: (key: K, val: V) => string): {
|
|
785
|
+
[key: string]: number;
|
|
786
|
+
};
|
|
781
787
|
protected size: number;
|
|
782
788
|
protected _data: any;
|
|
783
789
|
private _onSet;
|
|
@@ -1277,14 +1283,94 @@ declare class ViewHistory extends RouteList {
|
|
|
1277
1283
|
}
|
|
1278
1284
|
declare const viewhistorys: ViewHistory;
|
|
1279
1285
|
|
|
1286
|
+
declare class ViewModel extends EventDispatcher {
|
|
1287
|
+
/**
|
|
1288
|
+
* 视图模型的名称
|
|
1289
|
+
* @param name
|
|
1290
|
+
*/
|
|
1291
|
+
constructor(name: string);
|
|
1292
|
+
/**
|
|
1293
|
+
* 视图模型的编号
|
|
1294
|
+
* 默认为视图模型的类型,表示该模型在应用中唯一
|
|
1295
|
+
* 如果应用中,存在多个
|
|
1296
|
+
* @returns
|
|
1297
|
+
*/
|
|
1298
|
+
getIdent(): string;
|
|
1299
|
+
/**
|
|
1300
|
+
*
|
|
1301
|
+
* @param asset 通过此方法创建的节点,自动添加 RouteComponent 到节点上
|
|
1302
|
+
*/
|
|
1303
|
+
createNode(asset: Prefab): void;
|
|
1304
|
+
/**
|
|
1305
|
+
* 使用route的视图模型,可以实现通过路由,操作视图
|
|
1306
|
+
* @param route
|
|
1307
|
+
* @param controller
|
|
1308
|
+
*/
|
|
1309
|
+
useRoute(route: Route, controller: RouteController): void;
|
|
1310
|
+
open(): void;
|
|
1311
|
+
close(): void;
|
|
1312
|
+
refresh(): void;
|
|
1313
|
+
stop(reason?: LinkError): void;
|
|
1314
|
+
/**
|
|
1315
|
+
* 等待发送的结果
|
|
1316
|
+
* 如果返回 null,表示主动取消 [cancel]
|
|
1317
|
+
*/
|
|
1318
|
+
wait(): Promise<this>;
|
|
1319
|
+
toString(): string;
|
|
1320
|
+
/**
|
|
1321
|
+
* 等待打开完成指令
|
|
1322
|
+
*/
|
|
1323
|
+
waitOpenComplete(): void;
|
|
1324
|
+
openComplete(): void;
|
|
1325
|
+
waitCloseComplete(): void;
|
|
1326
|
+
closeComplete(): void;
|
|
1327
|
+
protected _waitOpenComplete: boolean;
|
|
1328
|
+
protected _waitCloseComplete: boolean;
|
|
1329
|
+
get reason(): LinkError;
|
|
1330
|
+
node: Node;
|
|
1331
|
+
datas: MapObject;
|
|
1332
|
+
tags: MapObject;
|
|
1333
|
+
enableHistory: boolean;
|
|
1334
|
+
layer: string;
|
|
1335
|
+
state: ViewState;
|
|
1336
|
+
protected _controller: RouteController;
|
|
1337
|
+
protected _route: Route;
|
|
1338
|
+
protected _reason: LinkError;
|
|
1339
|
+
protected onOpen(): void;
|
|
1340
|
+
protected onOpened(): void;
|
|
1341
|
+
protected onClose(): void;
|
|
1342
|
+
protected onClosed(): void;
|
|
1343
|
+
protected onRefresh(): void;
|
|
1344
|
+
/**
|
|
1345
|
+
* 默认执行 close();
|
|
1346
|
+
*/
|
|
1347
|
+
protected onStop(): void;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1280
1350
|
declare class ViewList extends List<RouteView> {
|
|
1281
1351
|
}
|
|
1282
1352
|
/**
|
|
1283
1353
|
* 路由唯一编号->视图
|
|
1284
1354
|
*/
|
|
1285
|
-
declare class ViewDict extends Dictionary<string,
|
|
1355
|
+
declare class ViewDict extends Dictionary<string, any> {
|
|
1356
|
+
/**
|
|
1357
|
+
* 关闭相斥的视图对象
|
|
1358
|
+
* 1. 关闭同一层的所有视图对象
|
|
1359
|
+
* 2. 关闭符合相斥规则的视图对象
|
|
1360
|
+
* @param view
|
|
1361
|
+
* @param validFunc 符合条件的视图对象会被关闭
|
|
1362
|
+
* @returns 被关闭的视图
|
|
1363
|
+
*/
|
|
1364
|
+
closeExclusion(validFunc?: (existed: RouteView) => boolean): ViewList;
|
|
1365
|
+
listByRoutePath(path: string): ViewList;
|
|
1366
|
+
listByTags(tags: string[]): ViewList;
|
|
1367
|
+
/**
|
|
1368
|
+
* 往上追踪,返回第一个包含 RouteComponent 的节点, 返回节点中的 RouteView
|
|
1369
|
+
* @param node
|
|
1370
|
+
*/
|
|
1371
|
+
tailNode(node: Node): ViewModel;
|
|
1286
1372
|
}
|
|
1287
|
-
declare class
|
|
1373
|
+
declare class RouteViewDict extends ViewDict {
|
|
1288
1374
|
constructor();
|
|
1289
1375
|
openByString(route: string): RouteView;
|
|
1290
1376
|
/**
|
|
@@ -1295,32 +1381,14 @@ declare class ViewRepo extends ViewDict {
|
|
|
1295
1381
|
open(route: Route): RouteView;
|
|
1296
1382
|
close(route: Route): void;
|
|
1297
1383
|
/**
|
|
1298
|
-
* 关闭相斥的视图对象
|
|
1299
|
-
* 1. 关闭同一层的所有视图对象
|
|
1300
|
-
* 2. 关闭符合相斥规则的视图对象
|
|
1301
|
-
* @param view
|
|
1302
|
-
* @param validFunc 符合条件的视图对象会被关闭
|
|
1303
|
-
* @returns 被关闭的视图
|
|
1304
|
-
*/
|
|
1305
|
-
closeExclusion(validFunc?: (existed: RouteView) => boolean): ViewList;
|
|
1306
|
-
/**
|
|
1307
1384
|
* 如果页面存在,则刷新
|
|
1308
1385
|
* @param route
|
|
1309
1386
|
*/
|
|
1310
1387
|
refresh(route: Route): void;
|
|
1311
1388
|
getByRoute(route: Route): RouteView;
|
|
1312
|
-
listByRoutePath(path: string): ViewList;
|
|
1313
|
-
listByTags(tags: string[]): ViewList;
|
|
1314
|
-
/**
|
|
1315
|
-
* 往上追踪,返回第一个包含 RouteComponent 的节点, 返回节点中的 RouteView
|
|
1316
|
-
* @param node
|
|
1317
|
-
*/
|
|
1318
|
-
tailNode(node: Node): RouteView;
|
|
1319
1389
|
protected getController(name: string): RouteController;
|
|
1320
|
-
protected _indexLayer: {};
|
|
1321
|
-
protected _indexRoute: {};
|
|
1322
1390
|
}
|
|
1323
|
-
declare const
|
|
1391
|
+
declare const routeviews: RouteViewDict;
|
|
1324
1392
|
|
|
1325
1393
|
/**
|
|
1326
1394
|
* 事件字符串分隔符
|
|
@@ -2112,5 +2180,5 @@ declare class WidgetUtil {
|
|
|
2112
2180
|
}
|
|
2113
2181
|
declare var widgetutil: WidgetUtil;
|
|
2114
2182
|
|
|
2115
|
-
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, DirectionMode, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryDirection, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapObject, 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,
|
|
2183
|
+
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, DirectionMode, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryDirection, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapObject, MapUtil, MathUtil, Model, NetUtil, PathUtil, Pool, RandUtil, Route, RouteController, RouteList, RouteView, RouteViewDict, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewState, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, create等距图集, ctrlrepo, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, parseAtlas, parsePlist, pathutil, randutil, resutil, routeviews, scaleutil, stringutil, timer, timeutil, treeutil, uimgr, uirepo, uiutil, viewhistorys, widgetutil };
|
|
2116
2184
|
export type { CreatorFunction, DisposeFunction, IController, IError, IEventDispatcher, IExtend, IListItem, IModel, IModule, ITreeListItem, RecycleFunction };
|
package/dist/index.esm.js
CHANGED
|
@@ -3073,12 +3073,12 @@ class Dictionary {
|
|
|
3073
3073
|
target._reset(newdata, newsize);
|
|
3074
3074
|
return target;
|
|
3075
3075
|
}
|
|
3076
|
-
|
|
3076
|
+
groupByKey(keyCreator, ITEM_CLASS) {
|
|
3077
3077
|
let newdata = {};
|
|
3078
3078
|
for (const key in this._data) {
|
|
3079
3079
|
let val = this._data[key];
|
|
3080
3080
|
// @ts-ignore
|
|
3081
|
-
let newkey =
|
|
3081
|
+
let newkey = keyCreator(key, val);
|
|
3082
3082
|
let dict = newdata[newkey];
|
|
3083
3083
|
if (!dict) {
|
|
3084
3084
|
if (ITEM_CLASS) {
|
|
@@ -3093,6 +3093,38 @@ class Dictionary {
|
|
|
3093
3093
|
}
|
|
3094
3094
|
return newdata;
|
|
3095
3095
|
}
|
|
3096
|
+
countByKeyList(keyCreator) {
|
|
3097
|
+
let newdata = {};
|
|
3098
|
+
for (const key in this._data) {
|
|
3099
|
+
let val = this._data[key];
|
|
3100
|
+
// @ts-ignore
|
|
3101
|
+
let newkeyList = keyCreator(key, val);
|
|
3102
|
+
for (const newkey of newkeyList) {
|
|
3103
|
+
let count = newdata[newkey];
|
|
3104
|
+
if (count == undefined) {
|
|
3105
|
+
count = 0;
|
|
3106
|
+
}
|
|
3107
|
+
count++;
|
|
3108
|
+
newdata[newkey] = count;
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
return newdata;
|
|
3112
|
+
}
|
|
3113
|
+
countByKey(keyCreator) {
|
|
3114
|
+
let newdata = {};
|
|
3115
|
+
for (const key in this._data) {
|
|
3116
|
+
let val = this._data[key];
|
|
3117
|
+
// @ts-ignore
|
|
3118
|
+
let newkey = keyCreator(key, val);
|
|
3119
|
+
let count = newdata[newkey];
|
|
3120
|
+
if (count == undefined) {
|
|
3121
|
+
count = 0;
|
|
3122
|
+
}
|
|
3123
|
+
count++;
|
|
3124
|
+
newdata[newkey] = count;
|
|
3125
|
+
}
|
|
3126
|
+
return newdata;
|
|
3127
|
+
}
|
|
3096
3128
|
}
|
|
3097
3129
|
|
|
3098
3130
|
class DictNode {
|
|
@@ -3791,153 +3823,6 @@ class UIObjectRepo extends Dictionary {
|
|
|
3791
3823
|
*/
|
|
3792
3824
|
var uirepo = new UIObjectRepo();
|
|
3793
3825
|
|
|
3794
|
-
/******************************************************************************
|
|
3795
|
-
Copyright (c) Microsoft Corporation.
|
|
3796
|
-
|
|
3797
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
3798
|
-
purpose with or without fee is hereby granted.
|
|
3799
|
-
|
|
3800
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
3801
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
3802
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
3803
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
3804
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
3805
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
3806
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
3807
|
-
***************************************************************************** */
|
|
3808
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
function __decorate(decorators, target, key, desc) {
|
|
3812
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3813
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3814
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3815
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3816
|
-
}
|
|
3817
|
-
|
|
3818
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
3819
|
-
var e = new Error(message);
|
|
3820
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
3821
|
-
};
|
|
3822
|
-
|
|
3823
|
-
const { ccclass, property, menu } = _decorator;
|
|
3824
|
-
let RouteComponent = class RouteComponent extends Component {
|
|
3825
|
-
};
|
|
3826
|
-
RouteComponent = __decorate([
|
|
3827
|
-
ccclass('RouteComponent')
|
|
3828
|
-
], RouteComponent);
|
|
3829
|
-
|
|
3830
|
-
class ViewList extends List {
|
|
3831
|
-
}
|
|
3832
|
-
/**
|
|
3833
|
-
* 路由唯一编号->视图
|
|
3834
|
-
*/
|
|
3835
|
-
class ViewDict extends Dictionary {
|
|
3836
|
-
}
|
|
3837
|
-
class ViewRepo extends ViewDict {
|
|
3838
|
-
constructor() {
|
|
3839
|
-
super();
|
|
3840
|
-
this._indexLayer = {};
|
|
3841
|
-
this._indexRoute = {};
|
|
3842
|
-
}
|
|
3843
|
-
openByString(route) {
|
|
3844
|
-
return this.open(new Route(route));
|
|
3845
|
-
}
|
|
3846
|
-
/**
|
|
3847
|
-
* 打开页面
|
|
3848
|
-
* 一个路由代表一个页面
|
|
3849
|
-
* @param route
|
|
3850
|
-
*/
|
|
3851
|
-
open(route) {
|
|
3852
|
-
let controller = this.getController(route.path);
|
|
3853
|
-
if (!controller) {
|
|
3854
|
-
throw new Error("view controller no register: " + route.path);
|
|
3855
|
-
}
|
|
3856
|
-
return controller.openByRoute(route);
|
|
3857
|
-
}
|
|
3858
|
-
close(route) {
|
|
3859
|
-
let controller = this.getController(route.path);
|
|
3860
|
-
if (!controller) {
|
|
3861
|
-
throw new Error("view controller no register: " + route.path);
|
|
3862
|
-
}
|
|
3863
|
-
controller.closeByRoute(route);
|
|
3864
|
-
}
|
|
3865
|
-
/**
|
|
3866
|
-
* 关闭相斥的视图对象
|
|
3867
|
-
* 1. 关闭同一层的所有视图对象
|
|
3868
|
-
* 2. 关闭符合相斥规则的视图对象
|
|
3869
|
-
* @param view
|
|
3870
|
-
* @param validFunc 符合条件的视图对象会被关闭
|
|
3871
|
-
* @returns 被关闭的视图
|
|
3872
|
-
*/
|
|
3873
|
-
closeExclusion(validFunc = undefined) {
|
|
3874
|
-
if (!validFunc) {
|
|
3875
|
-
return;
|
|
3876
|
-
}
|
|
3877
|
-
let closedList = new ViewList();
|
|
3878
|
-
this.forEach((key, item, iterator) => {
|
|
3879
|
-
if (validFunc(item)) {
|
|
3880
|
-
closedList.push(item);
|
|
3881
|
-
}
|
|
3882
|
-
});
|
|
3883
|
-
closedList.forEach((index, item) => {
|
|
3884
|
-
item.controller;
|
|
3885
|
-
item.close();
|
|
3886
|
-
});
|
|
3887
|
-
return closedList;
|
|
3888
|
-
}
|
|
3889
|
-
/**
|
|
3890
|
-
* 如果页面存在,则刷新
|
|
3891
|
-
* @param route
|
|
3892
|
-
*/
|
|
3893
|
-
refresh(route) {
|
|
3894
|
-
let view = this.getByRoute(route);
|
|
3895
|
-
if (view) {
|
|
3896
|
-
view.controller.refresh();
|
|
3897
|
-
}
|
|
3898
|
-
}
|
|
3899
|
-
getByRoute(route) {
|
|
3900
|
-
return this.get(route.key);
|
|
3901
|
-
}
|
|
3902
|
-
listByRoutePath(path) {
|
|
3903
|
-
let list = new ViewList();
|
|
3904
|
-
this.forEach((index, item) => {
|
|
3905
|
-
if (item.controller.route.path == path) {
|
|
3906
|
-
list.push(item);
|
|
3907
|
-
}
|
|
3908
|
-
});
|
|
3909
|
-
return list;
|
|
3910
|
-
}
|
|
3911
|
-
listByTags(tags) {
|
|
3912
|
-
let list = new ViewList();
|
|
3913
|
-
this.forEach((index, item) => {
|
|
3914
|
-
if (item.controller.hasTags(tags)) {
|
|
3915
|
-
list.push(item);
|
|
3916
|
-
}
|
|
3917
|
-
});
|
|
3918
|
-
return list;
|
|
3919
|
-
}
|
|
3920
|
-
/**
|
|
3921
|
-
* 往上追踪,返回第一个包含 RouteComponent 的节点, 返回节点中的 RouteView
|
|
3922
|
-
* @param node
|
|
3923
|
-
*/
|
|
3924
|
-
tailNode(node) {
|
|
3925
|
-
let current = node;
|
|
3926
|
-
while (current != null) {
|
|
3927
|
-
let com = current.getComponent(RouteComponent);
|
|
3928
|
-
if (com) {
|
|
3929
|
-
return com.routeView;
|
|
3930
|
-
}
|
|
3931
|
-
current = current.parent;
|
|
3932
|
-
}
|
|
3933
|
-
return null;
|
|
3934
|
-
}
|
|
3935
|
-
getController(name) {
|
|
3936
|
-
return ctrlrepo.get(name);
|
|
3937
|
-
}
|
|
3938
|
-
}
|
|
3939
|
-
const viewrepo = new ViewRepo();
|
|
3940
|
-
|
|
3941
3826
|
var ViewState;
|
|
3942
3827
|
(function (ViewState) {
|
|
3943
3828
|
/**
|
|
@@ -3989,11 +3874,7 @@ class RouteView extends EventDispatcher {
|
|
|
3989
3874
|
if (this.state != ViewState.Closed) {
|
|
3990
3875
|
return;
|
|
3991
3876
|
}
|
|
3992
|
-
|
|
3993
|
-
if (viewrepo.get(route.key)) {
|
|
3994
|
-
throw `视图已存在: route=${route.key}`;
|
|
3995
|
-
}
|
|
3996
|
-
viewrepo.set(route.key, this);
|
|
3877
|
+
this.route;
|
|
3997
3878
|
this.state = ViewState.Opening;
|
|
3998
3879
|
this.dispatch(ViewEvent.Opening);
|
|
3999
3880
|
//
|
|
@@ -4129,7 +4010,6 @@ class RouteView extends EventDispatcher {
|
|
|
4129
4010
|
if (this.state == ViewState.Closed) {
|
|
4130
4011
|
return;
|
|
4131
4012
|
}
|
|
4132
|
-
viewrepo.delete(this.route.key);
|
|
4133
4013
|
this._waitCloseComplete = false;
|
|
4134
4014
|
this.state = ViewState.Closed;
|
|
4135
4015
|
this.dispatch(ViewEvent.Closed);
|
|
@@ -4144,8 +4024,8 @@ class RouteView extends EventDispatcher {
|
|
|
4144
4024
|
createNode(asset) {
|
|
4145
4025
|
let node = instantiate(asset);
|
|
4146
4026
|
this.node = node;
|
|
4147
|
-
let com = node.addComponent(RouteComponent);
|
|
4148
|
-
com.
|
|
4027
|
+
// let com = node.addComponent(RouteComponent);
|
|
4028
|
+
// com.viewModel = this;
|
|
4149
4029
|
}
|
|
4150
4030
|
get controller() {
|
|
4151
4031
|
return this._controller;
|
|
@@ -4187,16 +4067,161 @@ class RouteView extends EventDispatcher {
|
|
|
4187
4067
|
}
|
|
4188
4068
|
}
|
|
4189
4069
|
|
|
4070
|
+
/******************************************************************************
|
|
4071
|
+
Copyright (c) Microsoft Corporation.
|
|
4072
|
+
|
|
4073
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4074
|
+
purpose with or without fee is hereby granted.
|
|
4075
|
+
|
|
4076
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
4077
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
4078
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
4079
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
4080
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
4081
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
4082
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
4083
|
+
***************************************************************************** */
|
|
4084
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
4085
|
+
|
|
4086
|
+
|
|
4087
|
+
function __decorate(decorators, target, key, desc) {
|
|
4088
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4089
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4090
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4091
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4092
|
+
}
|
|
4093
|
+
|
|
4094
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
4095
|
+
var e = new Error(message);
|
|
4096
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
4097
|
+
};
|
|
4098
|
+
|
|
4099
|
+
const { ccclass, property, menu } = _decorator;
|
|
4100
|
+
let ViewModelComponent = class ViewModelComponent extends Component {
|
|
4101
|
+
};
|
|
4102
|
+
ViewModelComponent = __decorate([
|
|
4103
|
+
ccclass('ViewModelComponent')
|
|
4104
|
+
], ViewModelComponent);
|
|
4105
|
+
|
|
4106
|
+
class ViewList extends List {
|
|
4107
|
+
}
|
|
4108
|
+
/**
|
|
4109
|
+
* 路由唯一编号->视图
|
|
4110
|
+
*/
|
|
4111
|
+
class ViewDict extends Dictionary {
|
|
4112
|
+
/**
|
|
4113
|
+
* 关闭相斥的视图对象
|
|
4114
|
+
* 1. 关闭同一层的所有视图对象
|
|
4115
|
+
* 2. 关闭符合相斥规则的视图对象
|
|
4116
|
+
* @param view
|
|
4117
|
+
* @param validFunc 符合条件的视图对象会被关闭
|
|
4118
|
+
* @returns 被关闭的视图
|
|
4119
|
+
*/
|
|
4120
|
+
closeExclusion(validFunc = undefined) {
|
|
4121
|
+
if (!validFunc) {
|
|
4122
|
+
return;
|
|
4123
|
+
}
|
|
4124
|
+
let closedList = new ViewList();
|
|
4125
|
+
this.forEach((key, item, iterator) => {
|
|
4126
|
+
if (validFunc(item)) {
|
|
4127
|
+
closedList.push(item);
|
|
4128
|
+
}
|
|
4129
|
+
});
|
|
4130
|
+
closedList.forEach((index, item) => {
|
|
4131
|
+
item.controller;
|
|
4132
|
+
item.close();
|
|
4133
|
+
});
|
|
4134
|
+
return closedList;
|
|
4135
|
+
}
|
|
4136
|
+
listByRoutePath(path) {
|
|
4137
|
+
let list = new ViewList();
|
|
4138
|
+
this.forEach((index, item) => {
|
|
4139
|
+
if (item.controller.route.path == path) {
|
|
4140
|
+
list.push(item);
|
|
4141
|
+
}
|
|
4142
|
+
});
|
|
4143
|
+
return list;
|
|
4144
|
+
}
|
|
4145
|
+
listByTags(tags) {
|
|
4146
|
+
let list = new ViewList();
|
|
4147
|
+
this.forEach((index, item) => {
|
|
4148
|
+
if (item.controller.hasTags(tags)) {
|
|
4149
|
+
list.push(item);
|
|
4150
|
+
}
|
|
4151
|
+
});
|
|
4152
|
+
return list;
|
|
4153
|
+
}
|
|
4154
|
+
/**
|
|
4155
|
+
* 往上追踪,返回第一个包含 RouteComponent 的节点, 返回节点中的 RouteView
|
|
4156
|
+
* @param node
|
|
4157
|
+
*/
|
|
4158
|
+
tailNode(node) {
|
|
4159
|
+
let current = node;
|
|
4160
|
+
while (current != null) {
|
|
4161
|
+
let com = current.getComponent(ViewModelComponent);
|
|
4162
|
+
if (com) {
|
|
4163
|
+
return com.viewModel;
|
|
4164
|
+
}
|
|
4165
|
+
current = current.parent;
|
|
4166
|
+
}
|
|
4167
|
+
return null;
|
|
4168
|
+
}
|
|
4169
|
+
}
|
|
4170
|
+
class RouteViewDict extends ViewDict {
|
|
4171
|
+
constructor() {
|
|
4172
|
+
super();
|
|
4173
|
+
}
|
|
4174
|
+
openByString(route) {
|
|
4175
|
+
return this.open(new Route(route));
|
|
4176
|
+
}
|
|
4177
|
+
/**
|
|
4178
|
+
* 打开页面
|
|
4179
|
+
* 一个路由代表一个页面
|
|
4180
|
+
* @param route
|
|
4181
|
+
*/
|
|
4182
|
+
open(route) {
|
|
4183
|
+
let controller = this.getController(route.path);
|
|
4184
|
+
if (!controller) {
|
|
4185
|
+
throw new Error("view controller no register: " + route.path);
|
|
4186
|
+
}
|
|
4187
|
+
return controller.openByRoute(route);
|
|
4188
|
+
}
|
|
4189
|
+
close(route) {
|
|
4190
|
+
let controller = this.getController(route.path);
|
|
4191
|
+
if (!controller) {
|
|
4192
|
+
throw new Error("view controller no register: " + route.path);
|
|
4193
|
+
}
|
|
4194
|
+
controller.closeByRoute(route);
|
|
4195
|
+
}
|
|
4196
|
+
/**
|
|
4197
|
+
* 如果页面存在,则刷新
|
|
4198
|
+
* @param route
|
|
4199
|
+
*/
|
|
4200
|
+
refresh(route) {
|
|
4201
|
+
let view = this.getByRoute(route);
|
|
4202
|
+
if (view) {
|
|
4203
|
+
view.controller.refresh();
|
|
4204
|
+
}
|
|
4205
|
+
}
|
|
4206
|
+
getByRoute(route) {
|
|
4207
|
+
return this.get(route.key);
|
|
4208
|
+
}
|
|
4209
|
+
getController(name) {
|
|
4210
|
+
return ctrlrepo.get(name);
|
|
4211
|
+
}
|
|
4212
|
+
}
|
|
4213
|
+
const routeviews = new RouteViewDict();
|
|
4214
|
+
|
|
4190
4215
|
class ViewHistory extends RouteList {
|
|
4191
4216
|
back() {
|
|
4192
4217
|
if (viewhistorys.length == 0) {
|
|
4193
4218
|
return;
|
|
4194
4219
|
}
|
|
4195
|
-
|
|
4220
|
+
routeviews.close(viewhistorys.shift());
|
|
4196
4221
|
if (viewhistorys.length == 0) {
|
|
4197
4222
|
return;
|
|
4198
4223
|
}
|
|
4199
|
-
|
|
4224
|
+
routeviews.open(viewhistorys.last());
|
|
4200
4225
|
}
|
|
4201
4226
|
}
|
|
4202
4227
|
const viewhistorys = new ViewHistory();
|
|
@@ -6613,5 +6638,5 @@ class WidgetUtil {
|
|
|
6613
6638
|
}
|
|
6614
6639
|
var widgetutil = new WidgetUtil();
|
|
6615
6640
|
|
|
6616
|
-
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, DirectionMode, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryDirection, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapObject, 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,
|
|
6641
|
+
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, CameraUtil, CanvasUtil, Controller, ControllerDict, ControllerRepo, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, DirectionMode, Dispatcher, DocUtil, ErrorUtil, EventDispatcher, EventItem, EventUtil, Factory, FloatUtil, GeometryDirection, GeometryUtil, IdentUtil, LOGGER_EVENT, LinkError, List, ListIterator, ListNode, ListSource, Listener, LogLevel, LogManager, Logger, MapObject, MapUtil, MathUtil, Model, NetUtil, PathUtil, Pool, RandUtil, Route, RouteController, RouteList, RouteView, RouteViewDict, SampleCallbackList, SamplePool, SamplePoolSet, ScaleUtil, SimpleModel, StringUtil, TimeUtil, Timer, TreeIterator, TreeNode, TreeNodePlugin, TreeRoot, TreeRootPlugin, TreeUtil, UIManager, UIObjectRepo, UIPoolConfig, UISingleConfig, UIUtil, ViewDict, ViewEvent, ViewHistory, ViewList, ViewState, WidgetAlign, WidgetUtil, XAssetManager, XEvent, arrayutil, assetx, bitutil, camerautil, canvasutil, convertutil, create等距图集, ctrlrepo, docutil, errorutil, eventmgr, eventutil, floatutil, formatutil, geoutil, identutil, loadAtlas, logmgr, maputil, mathutil, netutil, parseAtlas, parsePlist, pathutil, randutil, resutil, routeviews, scaleutil, stringutil, timer, timeutil, treeutil, uimgr, uirepo, uiutil, viewhistorys, widgetutil };
|
|
6617
6642
|
//# sourceMappingURL=index.esm.js.map
|