@zhongguo168a/yxeditor-common 0.0.10 → 0.0.12
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 +31 -1
- package/dist/index.esm.js +106 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -205,6 +205,7 @@ declare class Timer {
|
|
|
205
205
|
recycle(): void;
|
|
206
206
|
dispose(): void;
|
|
207
207
|
}
|
|
208
|
+
declare const timer: Timer;
|
|
208
209
|
|
|
209
210
|
declare class ControllerSet {
|
|
210
211
|
constructor(mod: IModule);
|
|
@@ -1289,6 +1290,35 @@ declare class Dispatcher implements ISchedulable {
|
|
|
1289
1290
|
protected typeToList: Dictionary<string, CallbackList<any>>;
|
|
1290
1291
|
}
|
|
1291
1292
|
|
|
1293
|
+
declare class CallbackItem {
|
|
1294
|
+
listener: Function;
|
|
1295
|
+
caller: any;
|
|
1296
|
+
once: boolean;
|
|
1297
|
+
}
|
|
1298
|
+
declare class SampleCallbackList {
|
|
1299
|
+
constructor();
|
|
1300
|
+
dispose(): void;
|
|
1301
|
+
has(caller: any, listener: Function): boolean;
|
|
1302
|
+
protected getItem(caller: any, listener: Function): CallbackItem;
|
|
1303
|
+
/**
|
|
1304
|
+
* 监听事件,如果监听已经存在则返回
|
|
1305
|
+
* @param caller
|
|
1306
|
+
* @param listener 为了性能考虑, event使用了对象池处理。因此处理函数不应该保存event的引用。如有需要,可通过新建对象或Event.Clone()实现
|
|
1307
|
+
*/
|
|
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;
|
|
1314
|
+
/**
|
|
1315
|
+
* 派发事件
|
|
1316
|
+
* @param params 事件参数
|
|
1317
|
+
*/
|
|
1318
|
+
dispatch(params?: any): void;
|
|
1319
|
+
protected _callbackItems: CallbackItem[];
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1292
1322
|
declare class AssetURI {
|
|
1293
1323
|
name: string;
|
|
1294
1324
|
constructor(name: string);
|
|
@@ -1849,5 +1879,5 @@ declare const pathutil: PathUtil;
|
|
|
1849
1879
|
declare function parsePlist(plist: any, texture: any): SpriteAtlas;
|
|
1850
1880
|
declare function loadAtlas(url: any, callback: any): void;
|
|
1851
1881
|
|
|
1852
|
-
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, Controller, ControllerDict, ControllerSet, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, ErrorUtil, EventItem, EventManager, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LinkError, List, ListIterator, ListNode, ListSource, Listener, MapUtil, MathUtil, Model, Module, NetUtil, Page, PageController, PageEvent, PageLayer, PageList, PageRepo, PageState, PathUtil, Pool, RandUtil, Route, SamplePool, 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, maputil, mathutil, netutil, pagerepo, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timeutil, uidict, uimgr, uiutil };
|
|
1882
|
+
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, Controller, ControllerDict, ControllerSet, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, ErrorUtil, EventItem, EventManager, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LinkError, List, ListIterator, ListNode, ListSource, Listener, MapUtil, MathUtil, Model, Module, NetUtil, Page, PageController, PageEvent, PageLayer, PageList, PageRepo, PageState, PathUtil, Pool, RandUtil, Route, SampleCallbackList, SamplePool, 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, maputil, mathutil, netutil, pagerepo, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, uidict, uimgr, uiutil };
|
|
1853
1883
|
export type { CreatorFunction, DisposeFunction, IController, IEventManager, IExtend, IListItem, IModel, IModule, IModuleSample, ITreeListItem, RecycleFunction, error };
|
package/dist/index.esm.js
CHANGED
|
@@ -428,6 +428,7 @@ class Timer {
|
|
|
428
428
|
this._scheduler = null;
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
+
const timer = new Timer();
|
|
431
432
|
|
|
432
433
|
class ControllerSet {
|
|
433
434
|
constructor(mod) {
|
|
@@ -4327,6 +4328,110 @@ class Dispatcher {
|
|
|
4327
4328
|
}
|
|
4328
4329
|
}
|
|
4329
4330
|
|
|
4331
|
+
class CallbackItem {
|
|
4332
|
+
}
|
|
4333
|
+
class SampleCallbackList {
|
|
4334
|
+
constructor() {
|
|
4335
|
+
this._callbackItems = [];
|
|
4336
|
+
}
|
|
4337
|
+
dispose() {
|
|
4338
|
+
this._callbackItems = null;
|
|
4339
|
+
}
|
|
4340
|
+
has(caller, listener) {
|
|
4341
|
+
return !!this.getItem(caller, listener);
|
|
4342
|
+
}
|
|
4343
|
+
getItem(caller, listener) {
|
|
4344
|
+
let items = this._callbackItems;
|
|
4345
|
+
for (const item of items) {
|
|
4346
|
+
if (item.caller == caller && item.listener == listener) {
|
|
4347
|
+
return item;
|
|
4348
|
+
}
|
|
4349
|
+
}
|
|
4350
|
+
return null;
|
|
4351
|
+
}
|
|
4352
|
+
/**
|
|
4353
|
+
* 监听事件,如果监听已经存在则返回
|
|
4354
|
+
* @param caller
|
|
4355
|
+
* @param listener 为了性能考虑, event使用了对象池处理。因此处理函数不应该保存event的引用。如有需要,可通过新建对象或Event.Clone()实现
|
|
4356
|
+
*/
|
|
4357
|
+
on(caller, listener) {
|
|
4358
|
+
if (!listener) {
|
|
4359
|
+
throw new Error("listerner is null");
|
|
4360
|
+
}
|
|
4361
|
+
if (this.has(caller, listener)) {
|
|
4362
|
+
return;
|
|
4363
|
+
}
|
|
4364
|
+
let existed = this.getItem(caller, listener);
|
|
4365
|
+
if (existed) {
|
|
4366
|
+
return existed;
|
|
4367
|
+
}
|
|
4368
|
+
let item = new CallbackItem();
|
|
4369
|
+
item.caller = caller;
|
|
4370
|
+
item.listener = listener;
|
|
4371
|
+
let items = this._callbackItems;
|
|
4372
|
+
items.push(item);
|
|
4373
|
+
return item;
|
|
4374
|
+
}
|
|
4375
|
+
once(caller, listener) {
|
|
4376
|
+
if (!listener) {
|
|
4377
|
+
throw new Error("listerner is null");
|
|
4378
|
+
}
|
|
4379
|
+
if (this.has(caller, listener)) {
|
|
4380
|
+
return;
|
|
4381
|
+
}
|
|
4382
|
+
let item = new CallbackItem();
|
|
4383
|
+
item.caller = caller;
|
|
4384
|
+
item.listener = listener;
|
|
4385
|
+
item.once = true;
|
|
4386
|
+
let items = this._callbackItems;
|
|
4387
|
+
items.push(item);
|
|
4388
|
+
return item;
|
|
4389
|
+
}
|
|
4390
|
+
offItem(item) {
|
|
4391
|
+
this.off(item.caller, item.listener);
|
|
4392
|
+
}
|
|
4393
|
+
off(caller, listener) {
|
|
4394
|
+
let items = this._callbackItems;
|
|
4395
|
+
for (let i = 0; i < items.length; i++) {
|
|
4396
|
+
let item = items[i];
|
|
4397
|
+
if (item.caller !== caller) {
|
|
4398
|
+
continue;
|
|
4399
|
+
}
|
|
4400
|
+
if (listener !== listener) {
|
|
4401
|
+
continue;
|
|
4402
|
+
}
|
|
4403
|
+
items.splice(i, 1);
|
|
4404
|
+
return;
|
|
4405
|
+
}
|
|
4406
|
+
}
|
|
4407
|
+
offAll(type) {
|
|
4408
|
+
let items = this._callbackItems;
|
|
4409
|
+
if (!type) {
|
|
4410
|
+
items.length = 0;
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4413
|
+
offAllCaller(caller) {
|
|
4414
|
+
let items = this._callbackItems;
|
|
4415
|
+
items = items.filter((value, index, array) => {
|
|
4416
|
+
return value.caller !== caller;
|
|
4417
|
+
});
|
|
4418
|
+
this._callbackItems = items;
|
|
4419
|
+
}
|
|
4420
|
+
/**
|
|
4421
|
+
* 派发事件
|
|
4422
|
+
* @param params 事件参数
|
|
4423
|
+
*/
|
|
4424
|
+
dispatch(params) {
|
|
4425
|
+
let items = this._callbackItems;
|
|
4426
|
+
if (items.length == 0) {
|
|
4427
|
+
return;
|
|
4428
|
+
}
|
|
4429
|
+
for (let on of items) {
|
|
4430
|
+
on.listener.call(on.caller, this, params);
|
|
4431
|
+
}
|
|
4432
|
+
}
|
|
4433
|
+
}
|
|
4434
|
+
|
|
4330
4435
|
function parseAtlas(name, plist, texture) {
|
|
4331
4436
|
plist.meta;
|
|
4332
4437
|
let frames = plist.frames;
|
|
@@ -5994,5 +6099,5 @@ class PathUtil {
|
|
|
5994
6099
|
}
|
|
5995
6100
|
const pathutil = new PathUtil();
|
|
5996
6101
|
|
|
5997
|
-
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, Controller, ControllerDict, ControllerSet, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, ErrorUtil, EventItem, EventManager, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LinkError, List, ListIterator, ListNode, ListSource, Listener, MapUtil, MathUtil, Model, Module, NetUtil, Page, PageController, PageEvent, PageLayer, PageList, PageRepo, PageState, PathUtil, Pool, RandUtil, Route, SamplePool, 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, maputil, mathutil, netutil, pagerepo, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timeutil, uidict, uimgr, uiutil };
|
|
6102
|
+
export { ArrayUtil, AssetLoader, AssetURI, BitUtil, CallbackList, Controller, ControllerDict, ControllerSet, ConvertUtil, DictIterator, DictNode, DictSource, Dictionary, Dispatcher, ErrorUtil, EventItem, EventManager, EventUtil, Factory, FloatUtil, GeometryUtil, IdentUtil, LinkError, List, ListIterator, ListNode, ListSource, Listener, MapUtil, MathUtil, Model, Module, NetUtil, Page, PageController, PageEvent, PageLayer, PageList, PageRepo, PageState, PathUtil, Pool, RandUtil, Route, SampleCallbackList, SamplePool, 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, maputil, mathutil, netutil, pagerepo, parseAtlas, parsePlist, pathutil, randutil, resutil, scaleutil, stringutil, timer, timeutil, uidict, uimgr, uiutil };
|
|
5998
6103
|
//# sourceMappingURL=index.esm.js.map
|