@eva/plugin-evax 1.2.2-alpha.1 → 1.2.2-alpha.2
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/miniprogram.js +287 -0
- package/dist/plugin-evax.cjs.js +305 -0
- package/dist/plugin-evax.cjs.prod.js +1 -0
- package/dist/plugin-evax.esm.js +293 -0
- package/package.json +2 -2
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { __extends, __values, __spread, __decorate } from 'tslib';
|
|
2
|
+
import { Component, OBSERVER_TYPE, decorators, System } from '@eva/eva.js/dist/miniprogram';
|
|
3
|
+
import EventEmitter from 'eventemitter3';
|
|
4
|
+
import cloneDeep from 'lodash-es/cloneDeep';
|
|
5
|
+
import isObject from 'lodash-es/isObject';
|
|
6
|
+
|
|
7
|
+
var EvaXComponent = function (_super) {
|
|
8
|
+
__extends(EvaXComponent, _super);
|
|
9
|
+
|
|
10
|
+
function EvaXComponent(gameObject) {
|
|
11
|
+
var _this = _super.call(this, gameObject) || this;
|
|
12
|
+
|
|
13
|
+
_this.events = {};
|
|
14
|
+
return _this;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
EvaXComponent.prototype.init = function (option) {
|
|
18
|
+
if (option === void 0) {
|
|
19
|
+
option = {
|
|
20
|
+
events: {}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var events = option.events;
|
|
25
|
+
this.events = events || {};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
EvaXComponent.componentName = 'EvaX';
|
|
29
|
+
return EvaXComponent;
|
|
30
|
+
}(Component);
|
|
31
|
+
|
|
32
|
+
var EvaXComponent$1 = EvaXComponent;
|
|
33
|
+
|
|
34
|
+
var _defineCache = new Map();
|
|
35
|
+
|
|
36
|
+
function defineProperty(key, deep, store, originKey, originStore, callback) {
|
|
37
|
+
if (!_defineCache.has(store)) {
|
|
38
|
+
_defineCache.set(store, []);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (_defineCache.get(store).indexOf(key) > -1) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
_defineCache.get(store).push(key);
|
|
46
|
+
|
|
47
|
+
var props = key.split('.');
|
|
48
|
+
var obj = store;
|
|
49
|
+
var length = props.length;
|
|
50
|
+
|
|
51
|
+
for (var i = 0; i < length - 1; i++) {
|
|
52
|
+
if (obj[props[i]] === undefined) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
obj = obj[props[i]];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
var value = obj[props[length - 1]];
|
|
60
|
+
|
|
61
|
+
if (deep && isObject(value)) {
|
|
62
|
+
for (var key_1 in value) {
|
|
63
|
+
defineProperty(key_1, deep, value, originKey, originStore, callback);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var _key = "_" + props[length - 1];
|
|
68
|
+
|
|
69
|
+
obj[_key] = value;
|
|
70
|
+
Object.defineProperty(obj, _key, {
|
|
71
|
+
enumerable: false
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(obj, props[length - 1], {
|
|
74
|
+
set: function set(val) {
|
|
75
|
+
var oldStore = cloneDeep(originStore);
|
|
76
|
+
obj["_" + props[length - 1]] = val;
|
|
77
|
+
callback(originKey, oldStore);
|
|
78
|
+
|
|
79
|
+
if (deep && isObject(val)) {
|
|
80
|
+
_defineCache.delete(obj);
|
|
81
|
+
|
|
82
|
+
for (var key_2 in val) {
|
|
83
|
+
defineProperty(key_2, deep, val, originKey, originStore, callback);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
get: function get() {
|
|
88
|
+
return obj["_" + props[length - 1]];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function updateStore(store, newStore, force) {
|
|
94
|
+
for (var key in store) {
|
|
95
|
+
if (!(key in newStore)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (typeof store[key] === 'object') {
|
|
100
|
+
updateStore(store[key], newStore[key], force);
|
|
101
|
+
} else {
|
|
102
|
+
if (force || store[key] !== newStore[key]) {
|
|
103
|
+
store[key] = newStore[key];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
var EvaXSystem = function (_super) {
|
|
110
|
+
__extends(EvaXSystem, _super);
|
|
111
|
+
|
|
112
|
+
function EvaXSystem() {
|
|
113
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
114
|
+
|
|
115
|
+
_this.changeList = [];
|
|
116
|
+
return _this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
EvaXSystem.prototype.init = function (_a) {
|
|
120
|
+
var _b = (_a === void 0 ? {
|
|
121
|
+
store: {}
|
|
122
|
+
} : _a).store,
|
|
123
|
+
store = _b === void 0 ? {} : _b;
|
|
124
|
+
this.ee = new EventEmitter();
|
|
125
|
+
this.store = store;
|
|
126
|
+
this.bindDefaultListener();
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
EvaXSystem.prototype.bindDefaultListener = function () {
|
|
130
|
+
var _this = this;
|
|
131
|
+
|
|
132
|
+
this.ee.on('evax.updateStore', function (store) {
|
|
133
|
+
_this.updateStore(store);
|
|
134
|
+
});
|
|
135
|
+
this.ee.on('evax.forceUpdateStore', function (store) {
|
|
136
|
+
_this.forceUpdateStore(store);
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
EvaXSystem.prototype.changeCallback = function (key, oldStore) {
|
|
141
|
+
this.changeList.push({
|
|
142
|
+
key: key,
|
|
143
|
+
oldStore: oldStore
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
EvaXSystem.prototype.updateStore = function (store) {
|
|
148
|
+
updateStore(this.store, store, false);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
EvaXSystem.prototype.forceUpdateStore = function (store) {
|
|
152
|
+
updateStore(this.store, store, true);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
EvaXSystem.prototype.bindListener = function (key, deep) {
|
|
156
|
+
var _this = this;
|
|
157
|
+
|
|
158
|
+
if (key.indexOf('store.') === -1) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
var realKey = key.split('.').slice(1).join('.');
|
|
163
|
+
defineProperty(realKey, deep, this.store, key, this.store, function (key, oldStore) {
|
|
164
|
+
return _this.changeCallback(key, oldStore);
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
EvaXSystem.prototype.update = function () {
|
|
169
|
+
var e_1, _a;
|
|
170
|
+
|
|
171
|
+
var changes = this.componentObserver.clear();
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
for (var changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
|
|
175
|
+
var changed = changes_1_1.value;
|
|
176
|
+
|
|
177
|
+
switch (changed.type) {
|
|
178
|
+
case OBSERVER_TYPE.ADD:
|
|
179
|
+
this.add(changed);
|
|
180
|
+
break;
|
|
181
|
+
|
|
182
|
+
case OBSERVER_TYPE.REMOVE:
|
|
183
|
+
this.remove(changed);
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
} catch (e_1_1) {
|
|
188
|
+
e_1 = {
|
|
189
|
+
error: e_1_1
|
|
190
|
+
};
|
|
191
|
+
} finally {
|
|
192
|
+
try {
|
|
193
|
+
if (changes_1_1 && !changes_1_1.done && (_a = changes_1.return)) _a.call(changes_1);
|
|
194
|
+
} finally {
|
|
195
|
+
if (e_1) throw e_1.error;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
EvaXSystem.prototype.lateUpdate = function () {
|
|
201
|
+
var e_2, _a;
|
|
202
|
+
|
|
203
|
+
try {
|
|
204
|
+
for (var _b = __values(this.changeList), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
205
|
+
var item = _c.value;
|
|
206
|
+
this.ee.emit(item.key, this.store, item.oldStore);
|
|
207
|
+
}
|
|
208
|
+
} catch (e_2_1) {
|
|
209
|
+
e_2 = {
|
|
210
|
+
error: e_2_1
|
|
211
|
+
};
|
|
212
|
+
} finally {
|
|
213
|
+
try {
|
|
214
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
215
|
+
} finally {
|
|
216
|
+
if (e_2) throw e_2.error;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this.changeList = [];
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
EvaXSystem.prototype.add = function (changed) {
|
|
224
|
+
var component = changed.component;
|
|
225
|
+
component.evax = this;
|
|
226
|
+
|
|
227
|
+
for (var key in component.events) {
|
|
228
|
+
if (component.events[key]) {
|
|
229
|
+
this.bindListener(key, !!component.events[key].deep);
|
|
230
|
+
var func = void 0;
|
|
231
|
+
|
|
232
|
+
if (component.events[key] instanceof Function) {
|
|
233
|
+
func = component.events[key];
|
|
234
|
+
} else {
|
|
235
|
+
func = component.events[key].handler;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
this.ee.on(key, func.bind(component));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
EvaXSystem.prototype.remove = function (changed) {
|
|
244
|
+
var component = changed.component;
|
|
245
|
+
|
|
246
|
+
for (var key in component.events) {
|
|
247
|
+
if (component.events[key] instanceof Function) {
|
|
248
|
+
this.ee.off(key, component.events[key].bind(component));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
EvaXSystem.prototype.on = function (eventName, func) {
|
|
254
|
+
return this.ee.on(eventName, func, this);
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
EvaXSystem.prototype.off = function (eventName, func) {
|
|
258
|
+
return this.ee.off(eventName, func);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
EvaXSystem.prototype.emit = function (eventName) {
|
|
262
|
+
var _a;
|
|
263
|
+
|
|
264
|
+
var args = [];
|
|
265
|
+
|
|
266
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
267
|
+
args[_i - 1] = arguments[_i];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return (_a = this.ee).emit.apply(_a, __spread([eventName], args));
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
EvaXSystem.prototype.onDestroy = function () {};
|
|
274
|
+
|
|
275
|
+
EvaXSystem.systemName = 'EvaX';
|
|
276
|
+
EvaXSystem = __decorate([decorators.componentObserver({
|
|
277
|
+
EvaX: []
|
|
278
|
+
})], EvaXSystem);
|
|
279
|
+
return EvaXSystem;
|
|
280
|
+
}(System);
|
|
281
|
+
|
|
282
|
+
var EvaXSystem$1 = EvaXSystem;
|
|
283
|
+
var index = {
|
|
284
|
+
Components: [EvaXComponent$1],
|
|
285
|
+
Systems: [EvaXSystem$1]
|
|
286
|
+
};
|
|
287
|
+
export { EvaXComponent$1 as EvaX, EvaXSystem$1 as EvaXSystem, index as default };
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var eva_js = require('@eva/eva.js');
|
|
6
|
+
var EventEmitter = require('eventemitter3');
|
|
7
|
+
var cloneDeep = require('lodash-es/cloneDeep');
|
|
8
|
+
var isObject = require('lodash-es/isObject');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
11
|
+
|
|
12
|
+
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
13
|
+
var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
|
|
14
|
+
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
15
|
+
|
|
16
|
+
/*! *****************************************************************************
|
|
17
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
18
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
19
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
20
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
|
|
22
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
23
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
24
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
25
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
26
|
+
|
|
27
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
28
|
+
and limitations under the License.
|
|
29
|
+
***************************************************************************** */
|
|
30
|
+
/* global Reflect, Promise */
|
|
31
|
+
|
|
32
|
+
var extendStatics = function(d, b) {
|
|
33
|
+
extendStatics = Object.setPrototypeOf ||
|
|
34
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
35
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
36
|
+
return extendStatics(d, b);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function __extends(d, b) {
|
|
40
|
+
extendStatics(d, b);
|
|
41
|
+
function __() { this.constructor = d; }
|
|
42
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function __decorate(decorators, target, key, desc) {
|
|
46
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
47
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
48
|
+
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;
|
|
49
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function __values(o) {
|
|
53
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
54
|
+
if (m) return m.call(o);
|
|
55
|
+
return {
|
|
56
|
+
next: function () {
|
|
57
|
+
if (o && i >= o.length) o = void 0;
|
|
58
|
+
return { value: o && o[i++], done: !o };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function __read(o, n) {
|
|
64
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
65
|
+
if (!m) return o;
|
|
66
|
+
var i = m.call(o), r, ar = [], e;
|
|
67
|
+
try {
|
|
68
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
69
|
+
}
|
|
70
|
+
catch (error) { e = { error: error }; }
|
|
71
|
+
finally {
|
|
72
|
+
try {
|
|
73
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
74
|
+
}
|
|
75
|
+
finally { if (e) throw e.error; }
|
|
76
|
+
}
|
|
77
|
+
return ar;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function __spread() {
|
|
81
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
82
|
+
ar = ar.concat(__read(arguments[i]));
|
|
83
|
+
return ar;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var EvaXComponent = (function (_super) {
|
|
87
|
+
__extends(EvaXComponent, _super);
|
|
88
|
+
function EvaXComponent(gameObject) {
|
|
89
|
+
var _this = _super.call(this, gameObject) || this;
|
|
90
|
+
_this.events = {};
|
|
91
|
+
return _this;
|
|
92
|
+
}
|
|
93
|
+
EvaXComponent.prototype.init = function (option) {
|
|
94
|
+
if (option === void 0) { option = { events: {} }; }
|
|
95
|
+
var events = option.events;
|
|
96
|
+
this.events = events || {};
|
|
97
|
+
};
|
|
98
|
+
EvaXComponent.componentName = 'EvaX';
|
|
99
|
+
return EvaXComponent;
|
|
100
|
+
}(eva_js.Component));
|
|
101
|
+
var EvaXComponent$1 = EvaXComponent;
|
|
102
|
+
|
|
103
|
+
var _defineCache = new Map();
|
|
104
|
+
function defineProperty(key, deep, store, originKey, originStore, callback) {
|
|
105
|
+
if (!_defineCache.has(store)) {
|
|
106
|
+
_defineCache.set(store, []);
|
|
107
|
+
}
|
|
108
|
+
if (_defineCache.get(store).indexOf(key) > -1) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
_defineCache.get(store).push(key);
|
|
112
|
+
var props = key.split('.');
|
|
113
|
+
var obj = store;
|
|
114
|
+
var length = props.length;
|
|
115
|
+
for (var i = 0; i < length - 1; i++) {
|
|
116
|
+
if (obj[props[i]] === undefined) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
obj = obj[props[i]];
|
|
120
|
+
}
|
|
121
|
+
var value = obj[props[length - 1]];
|
|
122
|
+
if (deep && isObject__default(value)) {
|
|
123
|
+
for (var key_1 in value) {
|
|
124
|
+
defineProperty(key_1, deep, value, originKey, originStore, callback);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
var _key = "_" + props[length - 1];
|
|
128
|
+
obj[_key] = value;
|
|
129
|
+
Object.defineProperty(obj, _key, {
|
|
130
|
+
enumerable: false,
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(obj, props[length - 1], {
|
|
133
|
+
set: function (val) {
|
|
134
|
+
var oldStore = cloneDeep__default(originStore);
|
|
135
|
+
obj["_" + props[length - 1]] = val;
|
|
136
|
+
callback(originKey, oldStore);
|
|
137
|
+
if (deep && isObject__default(val)) {
|
|
138
|
+
_defineCache.delete(obj);
|
|
139
|
+
for (var key_2 in val) {
|
|
140
|
+
defineProperty(key_2, deep, val, originKey, originStore, callback);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
get: function () {
|
|
145
|
+
return obj["_" + props[length - 1]];
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function updateStore(store, newStore, force) {
|
|
150
|
+
for (var key in store) {
|
|
151
|
+
if (!(key in newStore)) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (typeof store[key] === 'object') {
|
|
155
|
+
updateStore(store[key], newStore[key], force);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
if (force || store[key] !== newStore[key]) {
|
|
159
|
+
store[key] = newStore[key];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
var EvaXSystem = (function (_super) {
|
|
166
|
+
__extends(EvaXSystem, _super);
|
|
167
|
+
function EvaXSystem() {
|
|
168
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
169
|
+
_this.changeList = [];
|
|
170
|
+
return _this;
|
|
171
|
+
}
|
|
172
|
+
EvaXSystem.prototype.init = function (_a) {
|
|
173
|
+
var _b = (_a === void 0 ? { store: {} } : _a).store, store = _b === void 0 ? {} : _b;
|
|
174
|
+
this.ee = new EventEmitter__default();
|
|
175
|
+
this.store = store;
|
|
176
|
+
this.bindDefaultListener();
|
|
177
|
+
};
|
|
178
|
+
EvaXSystem.prototype.bindDefaultListener = function () {
|
|
179
|
+
var _this = this;
|
|
180
|
+
this.ee.on('evax.updateStore', function (store) {
|
|
181
|
+
_this.updateStore(store);
|
|
182
|
+
});
|
|
183
|
+
this.ee.on('evax.forceUpdateStore', function (store) {
|
|
184
|
+
_this.forceUpdateStore(store);
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
EvaXSystem.prototype.changeCallback = function (key, oldStore) {
|
|
188
|
+
this.changeList.push({
|
|
189
|
+
key: key,
|
|
190
|
+
oldStore: oldStore,
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
EvaXSystem.prototype.updateStore = function (store) {
|
|
194
|
+
updateStore(this.store, store, false);
|
|
195
|
+
};
|
|
196
|
+
EvaXSystem.prototype.forceUpdateStore = function (store) {
|
|
197
|
+
updateStore(this.store, store, true);
|
|
198
|
+
};
|
|
199
|
+
EvaXSystem.prototype.bindListener = function (key, deep) {
|
|
200
|
+
var _this = this;
|
|
201
|
+
if (key.indexOf('store.') === -1) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
var realKey = key.split('.').slice(1).join('.');
|
|
205
|
+
defineProperty(realKey, deep, this.store, key, this.store, function (key, oldStore) { return _this.changeCallback(key, oldStore); });
|
|
206
|
+
};
|
|
207
|
+
EvaXSystem.prototype.update = function () {
|
|
208
|
+
var e_1, _a;
|
|
209
|
+
var changes = this.componentObserver.clear();
|
|
210
|
+
try {
|
|
211
|
+
for (var changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
|
|
212
|
+
var changed = changes_1_1.value;
|
|
213
|
+
switch (changed.type) {
|
|
214
|
+
case eva_js.OBSERVER_TYPE.ADD:
|
|
215
|
+
this.add(changed);
|
|
216
|
+
break;
|
|
217
|
+
case eva_js.OBSERVER_TYPE.REMOVE:
|
|
218
|
+
this.remove(changed);
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
224
|
+
finally {
|
|
225
|
+
try {
|
|
226
|
+
if (changes_1_1 && !changes_1_1.done && (_a = changes_1.return)) _a.call(changes_1);
|
|
227
|
+
}
|
|
228
|
+
finally { if (e_1) throw e_1.error; }
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
EvaXSystem.prototype.lateUpdate = function () {
|
|
232
|
+
var e_2, _a;
|
|
233
|
+
try {
|
|
234
|
+
for (var _b = __values(this.changeList), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
235
|
+
var item = _c.value;
|
|
236
|
+
this.ee.emit(item.key, this.store, item.oldStore);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
240
|
+
finally {
|
|
241
|
+
try {
|
|
242
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
243
|
+
}
|
|
244
|
+
finally { if (e_2) throw e_2.error; }
|
|
245
|
+
}
|
|
246
|
+
this.changeList = [];
|
|
247
|
+
};
|
|
248
|
+
EvaXSystem.prototype.add = function (changed) {
|
|
249
|
+
var component = changed.component;
|
|
250
|
+
component.evax = this;
|
|
251
|
+
for (var key in component.events) {
|
|
252
|
+
if (component.events[key]) {
|
|
253
|
+
this.bindListener(key, !!component.events[key].deep);
|
|
254
|
+
var func = void 0;
|
|
255
|
+
if (component.events[key] instanceof Function) {
|
|
256
|
+
func = component.events[key];
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
func = component.events[key].handler;
|
|
260
|
+
}
|
|
261
|
+
this.ee.on(key, func.bind(component));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
EvaXSystem.prototype.remove = function (changed) {
|
|
266
|
+
var component = changed.component;
|
|
267
|
+
for (var key in component.events) {
|
|
268
|
+
if (component.events[key] instanceof Function) {
|
|
269
|
+
this.ee.off(key, component.events[key].bind(component));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
EvaXSystem.prototype.on = function (eventName, func) {
|
|
274
|
+
return this.ee.on(eventName, func, this);
|
|
275
|
+
};
|
|
276
|
+
EvaXSystem.prototype.off = function (eventName, func) {
|
|
277
|
+
return this.ee.off(eventName, func);
|
|
278
|
+
};
|
|
279
|
+
EvaXSystem.prototype.emit = function (eventName) {
|
|
280
|
+
var _a;
|
|
281
|
+
var args = [];
|
|
282
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
283
|
+
args[_i - 1] = arguments[_i];
|
|
284
|
+
}
|
|
285
|
+
return (_a = this.ee).emit.apply(_a, __spread([eventName], args));
|
|
286
|
+
};
|
|
287
|
+
EvaXSystem.prototype.onDestroy = function () { };
|
|
288
|
+
EvaXSystem.systemName = 'EvaX';
|
|
289
|
+
EvaXSystem = __decorate([
|
|
290
|
+
eva_js.decorators.componentObserver({
|
|
291
|
+
EvaX: [],
|
|
292
|
+
})
|
|
293
|
+
], EvaXSystem);
|
|
294
|
+
return EvaXSystem;
|
|
295
|
+
}(eva_js.System));
|
|
296
|
+
var EvaXSystem$1 = EvaXSystem;
|
|
297
|
+
|
|
298
|
+
var index = {
|
|
299
|
+
Components: [EvaXComponent$1],
|
|
300
|
+
Systems: [EvaXSystem$1],
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
exports.EvaX = EvaXComponent$1;
|
|
304
|
+
exports.EvaXSystem = EvaXSystem$1;
|
|
305
|
+
exports['default'] = index;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("eventemitter3"),n=require("lodash-es/cloneDeep"),r=require("lodash-es/isObject");function o(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var i=o(t),a=o(n),s=o(r),c=function(e,t){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function f(e,t){function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function u(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function p(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function v(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(p(arguments[t]));return e}var l=function(e){function t(t){var n=e.call(this,t)||this;return n.events={},n}return f(t,e),t.prototype.init=function(e){void 0===e&&(e={events:{}});var t=e.events;this.events=t||{}},t.componentName="EvaX",t}(e.Component),h=new Map;function y(e,t,n,r,o,i){if(h.has(n)||h.set(n,[]),!(h.get(n).indexOf(e)>-1)){h.get(n).push(e);for(var c=e.split("."),f=n,u=c.length,p=0;p<u-1;p++){if(void 0===f[c[p]])return;f=f[c[p]]}var v=f[c[u-1]];if(t&&s(v))for(var l in v)y(l,t,v,r,o,i);var d="_"+c[u-1];f[d]=v,Object.defineProperty(f,d,{enumerable:!1}),Object.defineProperty(f,c[u-1],{set:function(e){var n=a(o);if(f["_"+c[u-1]]=e,i(r,n),t&&s(e))for(var p in h.delete(f),e)y(p,t,e,r,o,i)},get:function(){return f["_"+c[u-1]]}})}}function d(e,t,n){for(var r in e)r in t&&("object"==typeof e[r]?d(e[r],t[r],n):(n||e[r]!==t[r])&&(e[r]=t[r]))}var b=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.changeList=[],e}return f(n,t),n.prototype.init=function(e){var t=(void 0===e?{store:{}}:e).store,n=void 0===t?{}:t;this.ee=new i,this.store=n,this.bindDefaultListener()},n.prototype.bindDefaultListener=function(){var e=this;this.ee.on("evax.updateStore",(function(t){e.updateStore(t)})),this.ee.on("evax.forceUpdateStore",(function(t){e.forceUpdateStore(t)}))},n.prototype.changeCallback=function(e,t){this.changeList.push({key:e,oldStore:t})},n.prototype.updateStore=function(e){d(this.store,e,!1)},n.prototype.forceUpdateStore=function(e){d(this.store,e,!0)},n.prototype.bindListener=function(e,t){var n=this;-1!==e.indexOf("store.")&&y(e.split(".").slice(1).join("."),t,this.store,e,this.store,(function(e,t){return n.changeCallback(e,t)}))},n.prototype.update=function(){var t,n,r=this.componentObserver.clear();try{for(var o=u(r),i=o.next();!i.done;i=o.next()){var a=i.value;switch(a.type){case e.OBSERVER_TYPE.ADD:this.add(a);break;case e.OBSERVER_TYPE.REMOVE:this.remove(a)}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}},n.prototype.lateUpdate=function(){var e,t;try{for(var n=u(this.changeList),r=n.next();!r.done;r=n.next()){var o=r.value;this.ee.emit(o.key,this.store,o.oldStore)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.changeList=[]},n.prototype.add=function(e){var t=e.component;for(var n in t.evax=this,t.events)if(t.events[n]){this.bindListener(n,!!t.events[n].deep);var r=void 0;r=t.events[n]instanceof Function?t.events[n]:t.events[n].handler,this.ee.on(n,r.bind(t))}},n.prototype.remove=function(e){var t=e.component;for(var n in t.events)t.events[n]instanceof Function&&this.ee.off(n,t.events[n].bind(t))},n.prototype.on=function(e,t){return this.ee.on(e,t,this)},n.prototype.off=function(e,t){return this.ee.off(e,t)},n.prototype.emit=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return(t=this.ee).emit.apply(t,v([e],n))},n.prototype.onDestroy=function(){},n.systemName="EvaX",n=function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}([e.decorators.componentObserver({EvaX:[]})],n)}(e.System),m={Components:[l],Systems:[b]};exports.EvaX=l,exports.EvaXSystem=b,exports.default=m;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { Component, OBSERVER_TYPE, decorators, System } from '@eva/eva.js';
|
|
2
|
+
import EventEmitter from 'eventemitter3';
|
|
3
|
+
import cloneDeep from 'lodash-es/cloneDeep';
|
|
4
|
+
import isObject from 'lodash-es/isObject';
|
|
5
|
+
|
|
6
|
+
/*! *****************************************************************************
|
|
7
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
9
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
10
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
13
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
14
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
15
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
16
|
+
|
|
17
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
18
|
+
and limitations under the License.
|
|
19
|
+
***************************************************************************** */
|
|
20
|
+
/* global Reflect, Promise */
|
|
21
|
+
|
|
22
|
+
var extendStatics = function(d, b) {
|
|
23
|
+
extendStatics = Object.setPrototypeOf ||
|
|
24
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
25
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
26
|
+
return extendStatics(d, b);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function __extends(d, b) {
|
|
30
|
+
extendStatics(d, b);
|
|
31
|
+
function __() { this.constructor = d; }
|
|
32
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function __decorate(decorators, target, key, desc) {
|
|
36
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
37
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
38
|
+
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;
|
|
39
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function __values(o) {
|
|
43
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
44
|
+
if (m) return m.call(o);
|
|
45
|
+
return {
|
|
46
|
+
next: function () {
|
|
47
|
+
if (o && i >= o.length) o = void 0;
|
|
48
|
+
return { value: o && o[i++], done: !o };
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function __read(o, n) {
|
|
54
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
55
|
+
if (!m) return o;
|
|
56
|
+
var i = m.call(o), r, ar = [], e;
|
|
57
|
+
try {
|
|
58
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
59
|
+
}
|
|
60
|
+
catch (error) { e = { error: error }; }
|
|
61
|
+
finally {
|
|
62
|
+
try {
|
|
63
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
64
|
+
}
|
|
65
|
+
finally { if (e) throw e.error; }
|
|
66
|
+
}
|
|
67
|
+
return ar;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function __spread() {
|
|
71
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
72
|
+
ar = ar.concat(__read(arguments[i]));
|
|
73
|
+
return ar;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var EvaXComponent = (function (_super) {
|
|
77
|
+
__extends(EvaXComponent, _super);
|
|
78
|
+
function EvaXComponent(gameObject) {
|
|
79
|
+
var _this = _super.call(this, gameObject) || this;
|
|
80
|
+
_this.events = {};
|
|
81
|
+
return _this;
|
|
82
|
+
}
|
|
83
|
+
EvaXComponent.prototype.init = function (option) {
|
|
84
|
+
if (option === void 0) { option = { events: {} }; }
|
|
85
|
+
var events = option.events;
|
|
86
|
+
this.events = events || {};
|
|
87
|
+
};
|
|
88
|
+
EvaXComponent.componentName = 'EvaX';
|
|
89
|
+
return EvaXComponent;
|
|
90
|
+
}(Component));
|
|
91
|
+
var EvaXComponent$1 = EvaXComponent;
|
|
92
|
+
|
|
93
|
+
var _defineCache = new Map();
|
|
94
|
+
function defineProperty(key, deep, store, originKey, originStore, callback) {
|
|
95
|
+
if (!_defineCache.has(store)) {
|
|
96
|
+
_defineCache.set(store, []);
|
|
97
|
+
}
|
|
98
|
+
if (_defineCache.get(store).indexOf(key) > -1) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
_defineCache.get(store).push(key);
|
|
102
|
+
var props = key.split('.');
|
|
103
|
+
var obj = store;
|
|
104
|
+
var length = props.length;
|
|
105
|
+
for (var i = 0; i < length - 1; i++) {
|
|
106
|
+
if (obj[props[i]] === undefined) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
obj = obj[props[i]];
|
|
110
|
+
}
|
|
111
|
+
var value = obj[props[length - 1]];
|
|
112
|
+
if (deep && isObject(value)) {
|
|
113
|
+
for (var key_1 in value) {
|
|
114
|
+
defineProperty(key_1, deep, value, originKey, originStore, callback);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
var _key = "_" + props[length - 1];
|
|
118
|
+
obj[_key] = value;
|
|
119
|
+
Object.defineProperty(obj, _key, {
|
|
120
|
+
enumerable: false,
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(obj, props[length - 1], {
|
|
123
|
+
set: function (val) {
|
|
124
|
+
var oldStore = cloneDeep(originStore);
|
|
125
|
+
obj["_" + props[length - 1]] = val;
|
|
126
|
+
callback(originKey, oldStore);
|
|
127
|
+
if (deep && isObject(val)) {
|
|
128
|
+
_defineCache.delete(obj);
|
|
129
|
+
for (var key_2 in val) {
|
|
130
|
+
defineProperty(key_2, deep, val, originKey, originStore, callback);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
get: function () {
|
|
135
|
+
return obj["_" + props[length - 1]];
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function updateStore(store, newStore, force) {
|
|
140
|
+
for (var key in store) {
|
|
141
|
+
if (!(key in newStore)) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (typeof store[key] === 'object') {
|
|
145
|
+
updateStore(store[key], newStore[key], force);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
if (force || store[key] !== newStore[key]) {
|
|
149
|
+
store[key] = newStore[key];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
var EvaXSystem = (function (_super) {
|
|
156
|
+
__extends(EvaXSystem, _super);
|
|
157
|
+
function EvaXSystem() {
|
|
158
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
159
|
+
_this.changeList = [];
|
|
160
|
+
return _this;
|
|
161
|
+
}
|
|
162
|
+
EvaXSystem.prototype.init = function (_a) {
|
|
163
|
+
var _b = (_a === void 0 ? { store: {} } : _a).store, store = _b === void 0 ? {} : _b;
|
|
164
|
+
this.ee = new EventEmitter();
|
|
165
|
+
this.store = store;
|
|
166
|
+
this.bindDefaultListener();
|
|
167
|
+
};
|
|
168
|
+
EvaXSystem.prototype.bindDefaultListener = function () {
|
|
169
|
+
var _this = this;
|
|
170
|
+
this.ee.on('evax.updateStore', function (store) {
|
|
171
|
+
_this.updateStore(store);
|
|
172
|
+
});
|
|
173
|
+
this.ee.on('evax.forceUpdateStore', function (store) {
|
|
174
|
+
_this.forceUpdateStore(store);
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
EvaXSystem.prototype.changeCallback = function (key, oldStore) {
|
|
178
|
+
this.changeList.push({
|
|
179
|
+
key: key,
|
|
180
|
+
oldStore: oldStore,
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
EvaXSystem.prototype.updateStore = function (store) {
|
|
184
|
+
updateStore(this.store, store, false);
|
|
185
|
+
};
|
|
186
|
+
EvaXSystem.prototype.forceUpdateStore = function (store) {
|
|
187
|
+
updateStore(this.store, store, true);
|
|
188
|
+
};
|
|
189
|
+
EvaXSystem.prototype.bindListener = function (key, deep) {
|
|
190
|
+
var _this = this;
|
|
191
|
+
if (key.indexOf('store.') === -1) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
var realKey = key.split('.').slice(1).join('.');
|
|
195
|
+
defineProperty(realKey, deep, this.store, key, this.store, function (key, oldStore) { return _this.changeCallback(key, oldStore); });
|
|
196
|
+
};
|
|
197
|
+
EvaXSystem.prototype.update = function () {
|
|
198
|
+
var e_1, _a;
|
|
199
|
+
var changes = this.componentObserver.clear();
|
|
200
|
+
try {
|
|
201
|
+
for (var changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
|
|
202
|
+
var changed = changes_1_1.value;
|
|
203
|
+
switch (changed.type) {
|
|
204
|
+
case OBSERVER_TYPE.ADD:
|
|
205
|
+
this.add(changed);
|
|
206
|
+
break;
|
|
207
|
+
case OBSERVER_TYPE.REMOVE:
|
|
208
|
+
this.remove(changed);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
214
|
+
finally {
|
|
215
|
+
try {
|
|
216
|
+
if (changes_1_1 && !changes_1_1.done && (_a = changes_1.return)) _a.call(changes_1);
|
|
217
|
+
}
|
|
218
|
+
finally { if (e_1) throw e_1.error; }
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
EvaXSystem.prototype.lateUpdate = function () {
|
|
222
|
+
var e_2, _a;
|
|
223
|
+
try {
|
|
224
|
+
for (var _b = __values(this.changeList), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
225
|
+
var item = _c.value;
|
|
226
|
+
this.ee.emit(item.key, this.store, item.oldStore);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
230
|
+
finally {
|
|
231
|
+
try {
|
|
232
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
233
|
+
}
|
|
234
|
+
finally { if (e_2) throw e_2.error; }
|
|
235
|
+
}
|
|
236
|
+
this.changeList = [];
|
|
237
|
+
};
|
|
238
|
+
EvaXSystem.prototype.add = function (changed) {
|
|
239
|
+
var component = changed.component;
|
|
240
|
+
component.evax = this;
|
|
241
|
+
for (var key in component.events) {
|
|
242
|
+
if (component.events[key]) {
|
|
243
|
+
this.bindListener(key, !!component.events[key].deep);
|
|
244
|
+
var func = void 0;
|
|
245
|
+
if (component.events[key] instanceof Function) {
|
|
246
|
+
func = component.events[key];
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
func = component.events[key].handler;
|
|
250
|
+
}
|
|
251
|
+
this.ee.on(key, func.bind(component));
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
EvaXSystem.prototype.remove = function (changed) {
|
|
256
|
+
var component = changed.component;
|
|
257
|
+
for (var key in component.events) {
|
|
258
|
+
if (component.events[key] instanceof Function) {
|
|
259
|
+
this.ee.off(key, component.events[key].bind(component));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
EvaXSystem.prototype.on = function (eventName, func) {
|
|
264
|
+
return this.ee.on(eventName, func, this);
|
|
265
|
+
};
|
|
266
|
+
EvaXSystem.prototype.off = function (eventName, func) {
|
|
267
|
+
return this.ee.off(eventName, func);
|
|
268
|
+
};
|
|
269
|
+
EvaXSystem.prototype.emit = function (eventName) {
|
|
270
|
+
var _a;
|
|
271
|
+
var args = [];
|
|
272
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
273
|
+
args[_i - 1] = arguments[_i];
|
|
274
|
+
}
|
|
275
|
+
return (_a = this.ee).emit.apply(_a, __spread([eventName], args));
|
|
276
|
+
};
|
|
277
|
+
EvaXSystem.prototype.onDestroy = function () { };
|
|
278
|
+
EvaXSystem.systemName = 'EvaX';
|
|
279
|
+
EvaXSystem = __decorate([
|
|
280
|
+
decorators.componentObserver({
|
|
281
|
+
EvaX: [],
|
|
282
|
+
})
|
|
283
|
+
], EvaXSystem);
|
|
284
|
+
return EvaXSystem;
|
|
285
|
+
}(System));
|
|
286
|
+
var EvaXSystem$1 = EvaXSystem;
|
|
287
|
+
|
|
288
|
+
var index = {
|
|
289
|
+
Components: [EvaXComponent$1],
|
|
290
|
+
Systems: [EvaXSystem$1],
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export { EvaXComponent$1 as EvaX, EvaXSystem$1 as EvaXSystem, index as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-evax",
|
|
3
|
-
"version": "1.2.2-alpha.
|
|
3
|
+
"version": "1.2.2-alpha.2",
|
|
4
4
|
"description": "@eva/plugin-evax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-evax.esm.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/eva.js": "1.2.2-alpha.
|
|
21
|
+
"@eva/eva.js": "1.2.2-alpha.2",
|
|
22
22
|
"eventemitter3": "^3.1.2",
|
|
23
23
|
"lodash-es": "^4.17.21"
|
|
24
24
|
}
|