@eva/eva.js 1.1.12-alpha.0 → 1.1.14

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/EVA.js CHANGED
@@ -1,7 +1,3 @@
1
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2
-
3
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
4
-
5
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
6
2
 
7
3
  var EVA = function (exports) {
@@ -933,14 +929,14 @@ var EVA = function (exports) {
933
929
  ListCache.prototype.get = listCacheGet;
934
930
  ListCache.prototype.has = listCacheHas;
935
931
  ListCache.prototype.set = listCacheSet;
936
- var Map$1 = getNative(root$1, 'Map');
937
- var Map$2 = Map$1;
932
+ var Map = getNative(root$1, 'Map');
933
+ var Map$1 = Map;
938
934
 
939
935
  function mapCacheClear() {
940
936
  this.size = 0;
941
937
  this.__data__ = {
942
938
  'hash': new Hash(),
943
- 'map': new (Map$2 || ListCache)(),
939
+ 'map': new (Map$1 || ListCache)(),
944
940
  'string': new Hash()
945
941
  };
946
942
  }
@@ -1034,7 +1030,7 @@ var EVA = function (exports) {
1034
1030
  if (data instanceof ListCache) {
1035
1031
  var pairs = data.__data__;
1036
1032
 
1037
- if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
1033
+ if (!Map$1 || pairs.length < LARGE_ARRAY_SIZE - 1) {
1038
1034
  pairs.push([key, value]);
1039
1035
  this.size = ++data.size;
1040
1036
  return this;
@@ -1117,13 +1113,13 @@ var EVA = function (exports) {
1117
1113
  weakMapTag = '[object WeakMap]';
1118
1114
  var dataViewTag$1 = '[object DataView]';
1119
1115
  var dataViewCtorString = toSource(DataView$1),
1120
- mapCtorString = toSource(Map$2),
1116
+ mapCtorString = toSource(Map$1),
1121
1117
  promiseCtorString = toSource(Promise$2),
1122
1118
  setCtorString = toSource(Set$2),
1123
1119
  weakMapCtorString = toSource(WeakMap$1);
1124
1120
  var getTag = baseGetTag;
1125
1121
 
1126
- if (DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag$1 || Map$2 && getTag(new Map$2()) != mapTag$1 || Promise$2 && getTag(Promise$2.resolve()) != promiseTag || Set$2 && getTag(new Set$2()) != setTag$1 || WeakMap$1 && getTag(new WeakMap$1()) != weakMapTag) {
1122
+ if (DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag$1 || Map$1 && getTag(new Map$1()) != mapTag$1 || Promise$2 && getTag(Promise$2.resolve()) != promiseTag || Set$2 && getTag(new Set$2()) != setTag$1 || WeakMap$1 && getTag(new WeakMap$1()) != weakMapTag) {
1127
1123
  getTag = function getTag(value) {
1128
1124
  var result = baseGetTag(value),
1129
1125
  Ctor = result == objectTag$1 ? value.constructor : undefined,
@@ -2174,6 +2170,12 @@ var EVA = function (exports) {
2174
2170
  componentName = _a.componentName;
2175
2171
 
2176
2172
  if (type === exports.OBSERVER_TYPE.REMOVE) {
2173
+ if (this.events.find(function (changed) {
2174
+ return changed.component === component && changed.type === exports.OBSERVER_TYPE.ADD;
2175
+ })) {
2176
+ return;
2177
+ }
2178
+
2177
2179
  this.events = this.events.filter(function (changed) {
2178
2180
  return changed.component !== component;
2179
2181
  });
@@ -2240,11 +2242,7 @@ var EVA = function (exports) {
2240
2242
 
2241
2243
  var System$1 = System;
2242
2244
 
2243
- function createNowTime(syncLocker) {
2244
- if (syncLocker === void 0) {
2245
- syncLocker = true;
2246
- }
2247
-
2245
+ function createNowTime() {
2248
2246
  var nowtime = null;
2249
2247
 
2250
2248
  if (Date.now) {
@@ -2258,21 +2256,6 @@ var EVA = function (exports) {
2258
2256
  return nowtime;
2259
2257
  }
2260
2258
 
2261
- function formatDelay(delay) {
2262
- if (typeof delay === 'number') {
2263
- delay = {
2264
- delay: delay
2265
- };
2266
- } else if ('entropy' in delay) {
2267
- delay = {
2268
- delay: delay.entropy,
2269
- isEntropy: true
2270
- };
2271
- }
2272
-
2273
- return delay;
2274
- }
2275
-
2276
2259
  var _nowtime = createNowTime();
2277
2260
 
2278
2261
  var defaultOptions$1 = {
@@ -2280,13 +2263,6 @@ var EVA = function (exports) {
2280
2263
  playbackRate: 1.0
2281
2264
  };
2282
2265
 
2283
- var _timeMark = Symbol('timeMark'),
2284
- _playbackRate = Symbol('playbackRate'),
2285
- _timers = Symbol('timers'),
2286
- _originTime = Symbol('originTime'),
2287
- _setTimer = Symbol('setTimer'),
2288
- _parent = Symbol('parent');
2289
-
2290
2266
  var Timeline = function () {
2291
2267
  function Timeline(options, parent) {
2292
2268
  if (options instanceof Timeline) {
@@ -2297,27 +2273,11 @@ var EVA = function (exports) {
2297
2273
  options = _extends({}, defaultOptions$1, options);
2298
2274
 
2299
2275
  if (parent) {
2300
- this[_parent] = parent;
2301
- }
2302
-
2303
- var nowtime = options.nowtime || _nowtime;
2304
-
2305
- if (!parent) {
2306
- var createTime = nowtime();
2307
- Object.defineProperty(this, 'globalTime', {
2308
- get: function get() {
2309
- return nowtime() - createTime;
2310
- }
2311
- });
2312
- } else {
2313
- Object.defineProperty(this, 'globalTime', {
2314
- get: function get() {
2315
- return parent.currentTime;
2316
- }
2317
- });
2276
+ this._parent = parent;
2318
2277
  }
2319
2278
 
2320
- this[_timeMark] = [{
2279
+ this._createTime = _nowtime();
2280
+ this._timeMark = [{
2321
2281
  globalTime: this.globalTime,
2322
2282
  localTime: -options.originTime,
2323
2283
  entropy: -options.originTime,
@@ -2325,25 +2285,43 @@ var EVA = function (exports) {
2325
2285
  globalEntropy: 0
2326
2286
  }];
2327
2287
 
2328
- if (this[_parent]) {
2329
- this[_timeMark][0].globalEntropy = this[_parent].entropy;
2288
+ if (this._parent) {
2289
+ this._timeMark[0].globalEntropy = this._parent.entropy;
2330
2290
  }
2331
2291
 
2332
- this[_originTime] = options.originTime;
2333
- this[_playbackRate] = options.playbackRate;
2334
- this[_timers] = new Map();
2292
+ this._playbackRate = options.playbackRate;
2335
2293
  }
2336
2294
 
2337
- var _proto = Timeline.prototype;
2295
+ Object.defineProperty(Timeline.prototype, "globalTime", {
2296
+ get: function get() {
2297
+ return this.parent ? this.parent.currentTime : _nowtime() - this._createTime;
2298
+ },
2299
+ enumerable: false,
2300
+ configurable: true
2301
+ });
2302
+ Object.defineProperty(Timeline.prototype, "parent", {
2303
+ get: function get() {
2304
+ return this._parent;
2305
+ },
2306
+ enumerable: false,
2307
+ configurable: true
2308
+ });
2309
+ Object.defineProperty(Timeline.prototype, "lastTimeMark", {
2310
+ get: function get() {
2311
+ return this._timeMark[this._timeMark.length - 1];
2312
+ },
2313
+ enumerable: false,
2314
+ configurable: true
2315
+ });
2338
2316
 
2339
- _proto.markTime = function markTime(_temp) {
2340
- var _ref = _temp === void 0 ? {} : _temp,
2341
- _ref$time = _ref.time,
2342
- time = _ref$time === void 0 ? this.currentTime : _ref$time,
2343
- _ref$entropy = _ref.entropy,
2344
- entropy = _ref$entropy === void 0 ? this.entropy : _ref$entropy,
2345
- _ref$playbackRate = _ref.playbackRate,
2346
- playbackRate = _ref$playbackRate === void 0 ? this.playbackRate : _ref$playbackRate;
2317
+ Timeline.prototype.markTime = function (_a) {
2318
+ var _b = _a === void 0 ? {} : _a,
2319
+ _c = _b.time,
2320
+ time = _c === void 0 ? this.currentTime : _c,
2321
+ _d = _b.entropy,
2322
+ entropy = _d === void 0 ? this.entropy : _d,
2323
+ _e = _b.playbackRate,
2324
+ playbackRate = _e === void 0 ? this.playbackRate : _e;
2347
2325
 
2348
2326
  var timeMark = {
2349
2327
  globalTime: this.globalTime,
@@ -2353,25 +2331,68 @@ var EVA = function (exports) {
2353
2331
  globalEntropy: this.globalEntropy
2354
2332
  };
2355
2333
 
2356
- this[_timeMark].push(timeMark);
2334
+ this._timeMark.push(timeMark);
2357
2335
  };
2358
2336
 
2359
- _proto.fork = function fork(options) {
2337
+ Object.defineProperty(Timeline.prototype, "currentTime", {
2338
+ get: function get() {
2339
+ var _a = this.lastTimeMark,
2340
+ localTime = _a.localTime,
2341
+ globalTime = _a.globalTime;
2342
+ return localTime + (this.globalTime - globalTime) * this.playbackRate;
2343
+ },
2344
+ set: function set(time) {
2345
+ this.markTime({
2346
+ time: time
2347
+ });
2348
+ },
2349
+ enumerable: false,
2350
+ configurable: true
2351
+ });
2352
+ Object.defineProperty(Timeline.prototype, "globalEntropy", {
2353
+ get: function get() {
2354
+ return this._parent ? this._parent.entropy : this.globalTime;
2355
+ },
2356
+ enumerable: false,
2357
+ configurable: true
2358
+ });
2359
+ Object.defineProperty(Timeline.prototype, "entropy", {
2360
+ get: function get() {
2361
+ var _a = this.lastTimeMark,
2362
+ entropy = _a.entropy,
2363
+ globalEntropy = _a.globalEntropy;
2364
+ return entropy + Math.abs((this.globalEntropy - globalEntropy) * this.playbackRate);
2365
+ },
2366
+ set: function set(entropy) {
2367
+ if (this.entropy > entropy) {
2368
+ var idx = this.seekTimeMark(entropy);
2369
+ this._timeMark.length = idx + 1;
2370
+ }
2371
+
2372
+ this.markTime({
2373
+ entropy: entropy
2374
+ });
2375
+ },
2376
+ enumerable: false,
2377
+ configurable: true
2378
+ });
2379
+
2380
+ Timeline.prototype.fork = function (options) {
2360
2381
  return new Timeline(options, this);
2361
2382
  };
2362
2383
 
2363
- _proto.seekGlobalTime = function seekGlobalTime(seekEntropy) {
2384
+ Timeline.prototype.seekGlobalTime = function (seekEntropy) {
2364
2385
  var idx = this.seekTimeMark(seekEntropy),
2365
- timeMark = this[_timeMark][idx];
2386
+ timeMark = this._timeMark[idx];
2366
2387
  var entropy = timeMark.entropy,
2367
2388
  playbackRate = timeMark.playbackRate,
2368
2389
  globalTime = timeMark.globalTime;
2369
2390
  return globalTime + (seekEntropy - entropy) / Math.abs(playbackRate);
2370
2391
  };
2371
2392
 
2372
- _proto.seekLocalTime = function seekLocalTime(seekEntropy) {
2393
+ Timeline.prototype.seekLocalTime = function (seekEntropy) {
2373
2394
  var idx = this.seekTimeMark(seekEntropy),
2374
- timeMark = this[_timeMark][idx];
2395
+ timeMark = this._timeMark[idx];
2375
2396
  var localTime = timeMark.localTime,
2376
2397
  entropy = timeMark.entropy,
2377
2398
  playbackRate = timeMark.playbackRate;
@@ -2383,8 +2404,8 @@ var EVA = function (exports) {
2383
2404
  return localTime - (seekEntropy - entropy);
2384
2405
  };
2385
2406
 
2386
- _proto.seekTimeMark = function seekTimeMark(entropy) {
2387
- var timeMark = this[_timeMark];
2407
+ Timeline.prototype.seekTimeMark = function (entropy) {
2408
+ var timeMark = this._timeMark;
2388
2409
  var l = 0,
2389
2410
  r = timeMark.length - 1;
2390
2411
 
@@ -2415,246 +2436,22 @@ var EVA = function (exports) {
2415
2436
  return l;
2416
2437
  };
2417
2438
 
2418
- _proto.updateTimers = function updateTimers() {
2419
- var _this2 = this;
2420
-
2421
- var timers = Array.from(this[_timers].entries());
2422
- timers.forEach(function (_ref2) {
2423
- var id = _ref2[0],
2424
- timer = _ref2[1];
2425
-
2426
- _this2[_setTimer](timer.handler, timer.time, id);
2427
- });
2428
- };
2429
-
2430
- _proto.clearTimeout = function (_clearTimeout) {
2431
- function clearTimeout(_x) {
2432
- return _clearTimeout.apply(this, arguments);
2433
- }
2434
-
2435
- clearTimeout.toString = function () {
2436
- return _clearTimeout.toString();
2437
- };
2438
-
2439
- return clearTimeout;
2440
- }(function (id) {
2441
- var timer = this[_timers].get(id);
2442
-
2443
- if (timer && timer.timerID != null) {
2444
- if (this[_parent]) {
2445
- this[_parent].clearTimeout(timer.timerID);
2446
- } else {
2447
- clearTimeout(timer.timerID);
2448
- }
2449
- }
2450
-
2451
- this[_timers].delete(id);
2452
- });
2453
-
2454
- _proto.clearInterval = function clearInterval(id) {
2455
- return this.clearTimeout(id);
2456
- };
2457
-
2458
- _proto.clear = function clear() {
2459
- var _this3 = this;
2460
-
2461
- var timers = this[_timers];
2462
- Array.from(Object.keys(timers)).forEach(function (id) {
2463
- _this3.clearTimeout(id);
2464
- });
2465
- };
2466
-
2467
- _proto.setTimeout = function setTimeout(handler, time) {
2468
- if (time === void 0) {
2469
- time = {
2470
- delay: 0
2471
- };
2472
- }
2473
-
2474
- return this[_setTimer](handler, time);
2475
- };
2476
-
2477
- _proto.setInterval = function setInterval(handler, time) {
2478
- if (time === void 0) {
2479
- time = {
2480
- delay: 0
2481
- };
2482
- }
2483
-
2484
- var that = this;
2485
-
2486
- var id = this[_setTimer](function step() {
2487
- that[_setTimer](step, time, id);
2488
-
2489
- handler();
2490
- }, time);
2491
-
2492
- return id;
2493
- };
2494
-
2495
- _proto[_setTimer] = function (handler, time, id) {
2496
- var _this4 = this;
2497
-
2498
- if (id === void 0) {
2499
- id = Symbol('timerID');
2500
- }
2501
-
2502
- time = formatDelay(time);
2503
-
2504
- var timer = this[_timers].get(id);
2505
-
2506
- var delay,
2507
- timerID = null,
2508
- startTime,
2509
- startEntropy;
2510
-
2511
- if (timer) {
2512
- this.clearTimeout(id);
2513
-
2514
- if (time.isEntropy) {
2515
- delay = (time.delay - (this.entropy - timer.startEntropy)) / Math.abs(this.playbackRate);
2516
- } else {
2517
- delay = (time.delay - (this.currentTime - timer.startTime)) / this.playbackRate;
2518
- }
2519
-
2520
- startTime = timer.startTime;
2521
- startEntropy = timer.startEntropy;
2522
- } else {
2523
- delay = time.delay / (time.isEntropy ? Math.abs(this.playbackRate) : this.playbackRate);
2524
- startTime = this.currentTime;
2525
- startEntropy = this.entropy;
2526
- }
2527
-
2528
- var parent = this[_parent],
2529
- globalTimeout = parent ? parent.setTimeout.bind(parent) : setTimeout;
2530
- var heading = time.heading;
2531
-
2532
- if (!parent && heading === false && delay < 0) {
2533
- delay = Infinity;
2534
- }
2535
-
2536
- if (isFinite(delay) || parent) {
2537
- delay = Math.ceil(delay);
2538
-
2539
- if (globalTimeout !== setTimeout) {
2540
- delay = {
2541
- delay: delay,
2542
- heading: heading
2543
- };
2544
- }
2545
-
2546
- timerID = globalTimeout(function () {
2547
- _this4[_timers].delete(id);
2548
-
2549
- handler();
2550
- }, delay);
2551
- }
2552
-
2553
- this[_timers].set(id, {
2554
- timerID: timerID,
2555
- handler: handler,
2556
- time: time,
2557
- startTime: startTime,
2558
- startEntropy: startEntropy
2559
- });
2560
-
2561
- return id;
2562
- };
2563
-
2564
- _createClass(Timeline, [{
2565
- key: "parent",
2566
- get: function get() {
2567
- return this[_parent];
2568
- }
2569
- }, {
2570
- key: "lastTimeMark",
2571
- get: function get() {
2572
- return this[_timeMark][this[_timeMark].length - 1];
2573
- }
2574
- }, {
2575
- key: "currentTime",
2576
- get: function get() {
2577
- var _this$lastTimeMark = this.lastTimeMark,
2578
- localTime = _this$lastTimeMark.localTime,
2579
- globalTime = _this$lastTimeMark.globalTime;
2580
- return localTime + (this.globalTime - globalTime) * this.playbackRate;
2581
- },
2582
- set: function set(time) {
2583
- var _this5 = this;
2584
-
2585
- var from = this.currentTime,
2586
- to = time,
2587
- timers = this[_timers];
2588
- this.markTime({
2589
- time: time
2590
- });
2591
- Array.from(Object.entries(timers)).forEach(function (_ref3) {
2592
- var id = _ref3[0],
2593
- timer = _ref3[1];
2594
- if (!timers.has(id)) return;
2595
- var _timer$time = timer.time,
2596
- isEntropy = _timer$time.isEntropy,
2597
- delay = _timer$time.delay,
2598
- heading = _timer$time.heading,
2599
- handler = timer.handler,
2600
- startTime = timer.startTime;
2601
-
2602
- if (!isEntropy) {
2603
- var endTime = startTime + delay;
2604
-
2605
- if (delay === 0 || heading !== false && (to - from) * delay <= 0 || from <= endTime && endTime <= to || from >= endTime && endTime >= to) {
2606
- handler();
2607
-
2608
- _this5.clearTimeout(id);
2609
- }
2610
- } else if (delay === 0) {
2611
- handler();
2612
-
2613
- _this5.clearTimeout(id);
2614
- }
2615
- });
2616
- this.updateTimers();
2617
- }
2618
- }, {
2619
- key: "entropy",
2439
+ Object.defineProperty(Timeline.prototype, "playbackRate", {
2620
2440
  get: function get() {
2621
- var _this$lastTimeMark2 = this.lastTimeMark,
2622
- entropy = _this$lastTimeMark2.entropy,
2623
- globalEntropy = _this$lastTimeMark2.globalEntropy;
2624
- return entropy + Math.abs((this.globalEntropy - globalEntropy) * this.playbackRate);
2625
- },
2626
- set: function set(entropy) {
2627
- if (this.entropy > entropy) {
2628
- var idx = this.seekTimeMark(entropy);
2629
- this[_timeMark].length = idx + 1;
2630
- }
2631
-
2632
- this.markTime({
2633
- entropy: entropy
2634
- });
2635
- this.updateTimers();
2636
- }
2637
- }, {
2638
- key: "globalEntropy",
2639
- get: function get() {
2640
- return this[_parent] ? this[_parent].entropy : this.globalTime;
2641
- }
2642
- }, {
2643
- key: "playbackRate",
2644
- get: function get() {
2645
- return this[_playbackRate];
2441
+ return this._playbackRate;
2646
2442
  },
2647
2443
  set: function set(rate) {
2648
2444
  if (rate !== this.playbackRate) {
2649
2445
  this.markTime({
2650
2446
  playbackRate: rate
2651
2447
  });
2652
- this[_playbackRate] = rate;
2653
- this.updateTimers();
2448
+ this._playbackRate = rate;
2654
2449
  }
2655
- }
2656
- }, {
2657
- key: "paused",
2450
+ },
2451
+ enumerable: false,
2452
+ configurable: true
2453
+ });
2454
+ Object.defineProperty(Timeline.prototype, "paused", {
2658
2455
  get: function get() {
2659
2456
  if (this.playbackRate === 0) return true;
2660
2457
  var parent = this.parent;
@@ -2665,9 +2462,10 @@ var EVA = function (exports) {
2665
2462
  }
2666
2463
 
2667
2464
  return false;
2668
- }
2669
- }]);
2670
-
2465
+ },
2466
+ enumerable: false,
2467
+ configurable: true
2468
+ });
2671
2469
  return Timeline;
2672
2470
  }();
2673
2471
 
@@ -5294,7 +5092,7 @@ var EVA = function (exports) {
5294
5092
  IDEProp: IDEProp,
5295
5093
  componentObserver: componentObserver
5296
5094
  };
5297
- var version = '1.1.11';
5095
+ var version = '1.1.14';
5298
5096
  console.log("Eva.js version: " + version);
5299
5097
  exports.Component = Component$1;
5300
5098
  exports.Game = Game$1;