force-graph 1.43.4 → 1.44.0

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.
@@ -1,4 +1,4 @@
1
- // Version 1.43.4 force-graph - https://github.com/vasturiano/force-graph
1
+ // Version 1.44.0 force-graph - https://github.com/vasturiano/force-graph
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -9,7 +9,7 @@
9
9
  if ( ref === void 0 ) ref = {};
10
10
  var insertAt = ref.insertAt;
11
11
 
12
- if (!css || typeof document === 'undefined') { return; }
12
+ if (typeof document === 'undefined') { return; }
13
13
 
14
14
  var head = document.head || document.getElementsByTagName('head')[0];
15
15
  var style = document.createElement('style');
@@ -35,157 +35,129 @@
35
35
  var css_248z = ".force-graph-container canvas {\n display: block;\n user-select: none;\n outline: none;\n -webkit-tap-highlight-color: transparent;\n}\n\n.force-graph-container .graph-tooltip {\n position: absolute;\n top: 0;\n font-family: sans-serif;\n font-size: 16px;\n padding: 4px;\n border-radius: 3px;\n color: #eee;\n background: rgba(0,0,0,0.65);\n visibility: hidden; /* by default */\n}\n\n.force-graph-container .clickable {\n cursor: pointer;\n}\n\n.force-graph-container .grabbable {\n cursor: move;\n cursor: grab;\n cursor: -moz-grab;\n cursor: -webkit-grab;\n}\n\n.force-graph-container .grabbable:active {\n cursor: grabbing;\n cursor: -moz-grabbing;\n cursor: -webkit-grabbing;\n}\n";
36
36
  styleInject(css_248z);
37
37
 
38
- function _iterableToArrayLimit$2(arr, i) {
39
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
40
- if (null != _i) {
41
- var _s,
42
- _e,
43
- _x,
44
- _r,
45
- _arr = [],
46
- _n = !0,
47
- _d = !1;
38
+ function _arrayLikeToArray$3(r, a) {
39
+ (null == a || a > r.length) && (a = r.length);
40
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
41
+ return n;
42
+ }
43
+ function _arrayWithHoles$2(r) {
44
+ if (Array.isArray(r)) return r;
45
+ }
46
+ function _arrayWithoutHoles$2(r) {
47
+ if (Array.isArray(r)) return _arrayLikeToArray$3(r);
48
+ }
49
+ function _construct(t, e, r) {
50
+ if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
51
+ var o = [null];
52
+ o.push.apply(o, e);
53
+ var p = new (t.bind.apply(t, o))();
54
+ return p;
55
+ }
56
+ function _defineProperty(e, r, t) {
57
+ return (r = _toPropertyKey$2(r)) in e ? Object.defineProperty(e, r, {
58
+ value: t,
59
+ enumerable: !0,
60
+ configurable: !0,
61
+ writable: !0
62
+ }) : e[r] = t, e;
63
+ }
64
+ function _isNativeReflectConstruct() {
65
+ try {
66
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
67
+ } catch (t) {}
68
+ return (_isNativeReflectConstruct = function () {
69
+ return !!t;
70
+ })();
71
+ }
72
+ function _iterableToArray$2(r) {
73
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
74
+ }
75
+ function _iterableToArrayLimit$2(r, l) {
76
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
77
+ if (null != t) {
78
+ var e,
79
+ n,
80
+ i,
81
+ u,
82
+ a = [],
83
+ f = !0,
84
+ o = !1;
48
85
  try {
49
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
50
- if (Object(_i) !== _i) return;
51
- _n = !1;
52
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
53
- } catch (err) {
54
- _d = !0, _e = err;
86
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
87
+ } catch (r) {
88
+ o = !0, n = r;
55
89
  } finally {
56
90
  try {
57
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
91
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
58
92
  } finally {
59
- if (_d) throw _e;
93
+ if (o) throw n;
60
94
  }
61
95
  }
62
- return _arr;
96
+ return a;
63
97
  }
64
98
  }
65
- function ownKeys(object, enumerableOnly) {
66
- var keys = Object.keys(object);
99
+ function _nonIterableRest$2() {
100
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
101
+ }
102
+ function _nonIterableSpread$2() {
103
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
104
+ }
105
+ function ownKeys(e, r) {
106
+ var t = Object.keys(e);
67
107
  if (Object.getOwnPropertySymbols) {
68
- var symbols = Object.getOwnPropertySymbols(object);
69
- enumerableOnly && (symbols = symbols.filter(function (sym) {
70
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
71
- })), keys.push.apply(keys, symbols);
72
- }
73
- return keys;
74
- }
75
- function _objectSpread2(target) {
76
- for (var i = 1; i < arguments.length; i++) {
77
- var source = null != arguments[i] ? arguments[i] : {};
78
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
79
- _defineProperty(target, key, source[key]);
80
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
81
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
82
- });
108
+ var o = Object.getOwnPropertySymbols(e);
109
+ r && (o = o.filter(function (r) {
110
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
111
+ })), t.push.apply(t, o);
83
112
  }
84
- return target;
113
+ return t;
85
114
  }
86
- function _typeof$1(obj) {
87
- "@babel/helpers - typeof";
88
-
89
- return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
90
- return typeof obj;
91
- } : function (obj) {
92
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
93
- }, _typeof$1(obj);
94
- }
95
- function _defineProperty(obj, key, value) {
96
- key = _toPropertyKey$3(key);
97
- if (key in obj) {
98
- Object.defineProperty(obj, key, {
99
- value: value,
100
- enumerable: true,
101
- configurable: true,
102
- writable: true
115
+ function _objectSpread2(e) {
116
+ for (var r = 1; r < arguments.length; r++) {
117
+ var t = null != arguments[r] ? arguments[r] : {};
118
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
119
+ _defineProperty(e, r, t[r]);
120
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
121
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
103
122
  });
104
- } else {
105
- obj[key] = value;
106
123
  }
107
- return obj;
124
+ return e;
108
125
  }
109
- function _setPrototypeOf(o, p) {
110
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
111
- o.__proto__ = p;
112
- return o;
113
- };
114
- return _setPrototypeOf(o, p);
126
+ function _slicedToArray$2(r, e) {
127
+ return _arrayWithHoles$2(r) || _iterableToArrayLimit$2(r, e) || _unsupportedIterableToArray$3(r, e) || _nonIterableRest$2();
115
128
  }
116
- function _isNativeReflectConstruct() {
117
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
118
- if (Reflect.construct.sham) return false;
119
- if (typeof Proxy === "function") return true;
120
- try {
121
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
122
- return true;
123
- } catch (e) {
124
- return false;
125
- }
129
+ function _toConsumableArray$2(r) {
130
+ return _arrayWithoutHoles$2(r) || _iterableToArray$2(r) || _unsupportedIterableToArray$3(r) || _nonIterableSpread$2();
126
131
  }
127
- function _construct(Parent, args, Class) {
128
- if (_isNativeReflectConstruct()) {
129
- _construct = Reflect.construct.bind();
130
- } else {
131
- _construct = function _construct(Parent, args, Class) {
132
- var a = [null];
133
- a.push.apply(a, args);
134
- var Constructor = Function.bind.apply(Parent, a);
135
- var instance = new Constructor();
136
- if (Class) _setPrototypeOf(instance, Class.prototype);
137
- return instance;
138
- };
132
+ function _toPrimitive$2(t, r) {
133
+ if ("object" != typeof t || !t) return t;
134
+ var e = t[Symbol.toPrimitive];
135
+ if (void 0 !== e) {
136
+ var i = e.call(t, r || "default");
137
+ if ("object" != typeof i) return i;
138
+ throw new TypeError("@@toPrimitive must return a primitive value.");
139
139
  }
140
- return _construct.apply(null, arguments);
141
- }
142
- function _slicedToArray$2(arr, i) {
143
- return _arrayWithHoles$2(arr) || _iterableToArrayLimit$2(arr, i) || _unsupportedIterableToArray$3(arr, i) || _nonIterableRest$2();
140
+ return ("string" === r ? String : Number)(t);
144
141
  }
145
- function _toConsumableArray$2(arr) {
146
- return _arrayWithoutHoles$2(arr) || _iterableToArray$2(arr) || _unsupportedIterableToArray$3(arr) || _nonIterableSpread$2();
142
+ function _toPropertyKey$2(t) {
143
+ var i = _toPrimitive$2(t, "string");
144
+ return "symbol" == typeof i ? i : i + "";
147
145
  }
148
- function _arrayWithoutHoles$2(arr) {
149
- if (Array.isArray(arr)) return _arrayLikeToArray$3(arr);
150
- }
151
- function _arrayWithHoles$2(arr) {
152
- if (Array.isArray(arr)) return arr;
153
- }
154
- function _iterableToArray$2(iter) {
155
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
156
- }
157
- function _unsupportedIterableToArray$3(o, minLen) {
158
- if (!o) return;
159
- if (typeof o === "string") return _arrayLikeToArray$3(o, minLen);
160
- var n = Object.prototype.toString.call(o).slice(8, -1);
161
- if (n === "Object" && o.constructor) n = o.constructor.name;
162
- if (n === "Map" || n === "Set") return Array.from(o);
163
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen);
164
- }
165
- function _arrayLikeToArray$3(arr, len) {
166
- if (len == null || len > arr.length) len = arr.length;
167
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
168
- return arr2;
169
- }
170
- function _nonIterableSpread$2() {
171
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
172
- }
173
- function _nonIterableRest$2() {
174
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
146
+ function _typeof$1(o) {
147
+ "@babel/helpers - typeof";
148
+
149
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
150
+ return typeof o;
151
+ } : function (o) {
152
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
153
+ }, _typeof$1(o);
175
154
  }
176
- function _toPrimitive$3(input, hint) {
177
- if (typeof input !== "object" || input === null) return input;
178
- var prim = input[Symbol.toPrimitive];
179
- if (prim !== undefined) {
180
- var res = prim.call(input, hint || "default");
181
- if (typeof res !== "object") return res;
182
- throw new TypeError("@@toPrimitive must return a primitive value.");
155
+ function _unsupportedIterableToArray$3(r, a) {
156
+ if (r) {
157
+ if ("string" == typeof r) return _arrayLikeToArray$3(r, a);
158
+ var t = {}.toString.call(r).slice(8, -1);
159
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0;
183
160
  }
184
- return (hint === "string" ? String : Number)(input);
185
- }
186
- function _toPropertyKey$3(arg) {
187
- var key = _toPrimitive$3(arg, "string");
188
- return typeof key === "symbol" ? key : String(key);
189
161
  }
190
162
 
191
163
  var xhtml = "http://www.w3.org/1999/xhtml";
@@ -1052,7 +1024,7 @@
1052
1024
  }
1053
1025
  }
1054
1026
 
1055
- var root$2 = [null];
1027
+ var root$1 = [null];
1056
1028
 
1057
1029
  function Selection$1(groups, parents) {
1058
1030
  this._groups = groups;
@@ -1060,7 +1032,7 @@
1060
1032
  }
1061
1033
 
1062
1034
  function selection() {
1063
- return new Selection$1([[document.documentElement]], root$2);
1035
+ return new Selection$1([[document.documentElement]], root$1);
1064
1036
  }
1065
1037
 
1066
1038
  function selection_selection() {
@@ -1109,7 +1081,7 @@
1109
1081
  function d3Select(selector) {
1110
1082
  return typeof selector === "string"
1111
1083
  ? new Selection$1([[document.querySelector(selector)]], [document.documentElement])
1112
- : new Selection$1([[selector]], root$2);
1084
+ : new Selection$1([[selector]], root$1);
1113
1085
  }
1114
1086
 
1115
1087
  function sourceEvent(event) {
@@ -2190,7 +2162,7 @@
2190
2162
  clock = typeof performance === "object" && performance.now ? performance : Date,
2191
2163
  setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); };
2192
2164
 
2193
- function now$3() {
2165
+ function now$2() {
2194
2166
  return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
2195
2167
  }
2196
2168
 
@@ -2208,7 +2180,7 @@
2208
2180
  constructor: Timer,
2209
2181
  restart: function(callback, delay, time) {
2210
2182
  if (typeof callback !== "function") throw new TypeError("callback is not a function");
2211
- time = (time == null ? now$3() : +time) + (delay == null ? 0 : +delay);
2183
+ time = (time == null ? now$2() : +time) + (delay == null ? 0 : +delay);
2212
2184
  if (!this._next && taskTail !== this) {
2213
2185
  if (taskTail) taskTail._next = this;
2214
2186
  else taskHead = this;
@@ -2234,7 +2206,7 @@
2234
2206
  }
2235
2207
 
2236
2208
  function timerFlush() {
2237
- now$3(); // Get the current time, if not already set.
2209
+ now$2(); // Get the current time, if not already set.
2238
2210
  ++frame; // Pretend we’ve set an alarm, if we haven’t already.
2239
2211
  var t = taskHead, e;
2240
2212
  while (t) {
@@ -3149,7 +3121,7 @@
3149
3121
  if (name instanceof Transition) {
3150
3122
  id = name._id, name = name._name;
3151
3123
  } else {
3152
- id = newId(), (timing = defaultTiming).time = now$3(), name = name == null ? null : name + "";
3124
+ id = newId(), (timing = defaultTiming).time = now$2(), name = name == null ? null : name + "";
3153
3125
  }
3154
3126
 
3155
3127
  for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
@@ -3772,20 +3744,14 @@
3772
3744
  /** Detect free variable `global` from Node.js. */
3773
3745
  var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
3774
3746
 
3775
- var freeGlobal$1 = freeGlobal;
3776
-
3777
3747
  /** Detect free variable `self`. */
3778
3748
  var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
3779
3749
 
3780
3750
  /** Used as a reference to the global object. */
3781
- var root = freeGlobal$1 || freeSelf || Function('return this')();
3782
-
3783
- var root$1 = root;
3751
+ var root = freeGlobal || freeSelf || Function('return this')();
3784
3752
 
3785
3753
  /** Built-in value references. */
3786
- var Symbol$1 = root$1.Symbol;
3787
-
3788
- var Symbol$2 = Symbol$1;
3754
+ var Symbol$1 = root.Symbol;
3789
3755
 
3790
3756
  /** Used for built-in method references. */
3791
3757
  var objectProto$1 = Object.prototype;
@@ -3801,7 +3767,7 @@
3801
3767
  var nativeObjectToString$1 = objectProto$1.toString;
3802
3768
 
3803
3769
  /** Built-in value references. */
3804
- var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
3770
+ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
3805
3771
 
3806
3772
  /**
3807
3773
  * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
@@ -3856,7 +3822,7 @@
3856
3822
  undefinedTag = '[object Undefined]';
3857
3823
 
3858
3824
  /** Built-in value references. */
3859
- var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : undefined;
3825
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
3860
3826
 
3861
3827
  /**
3862
3828
  * The base implementation of `getTag` without fallbacks for buggy environments.
@@ -4067,11 +4033,9 @@
4067
4033
  * // => Logs the number of milliseconds it took for the deferred invocation.
4068
4034
  */
4069
4035
  var now$1 = function() {
4070
- return root$1.Date.now();
4036
+ return root.Date.now();
4071
4037
  };
4072
4038
 
4073
- var now$2 = now$1;
4074
-
4075
4039
  /** Error message constants. */
4076
4040
  var FUNC_ERROR_TEXT$1 = 'Expected a function';
4077
4041
 
@@ -4197,7 +4161,7 @@
4197
4161
  }
4198
4162
 
4199
4163
  function timerExpired() {
4200
- var time = now$2();
4164
+ var time = now$1();
4201
4165
  if (shouldInvoke(time)) {
4202
4166
  return trailingEdge(time);
4203
4167
  }
@@ -4226,11 +4190,11 @@
4226
4190
  }
4227
4191
 
4228
4192
  function flush() {
4229
- return timerId === undefined ? result : trailingEdge(now$2());
4193
+ return timerId === undefined ? result : trailingEdge(now$1());
4230
4194
  }
4231
4195
 
4232
4196
  function debounced() {
4233
- var time = now$2(),
4197
+ var time = now$1(),
4234
4198
  isInvoking = shouldInvoke(time);
4235
4199
 
4236
4200
  lastArgs = arguments;
@@ -4332,13 +4296,13 @@
4332
4296
  return amount;
4333
4297
  },
4334
4298
  In: function (amount) {
4335
- return this.None(amount);
4299
+ return amount;
4336
4300
  },
4337
4301
  Out: function (amount) {
4338
- return this.None(amount);
4302
+ return amount;
4339
4303
  },
4340
4304
  InOut: function (amount) {
4341
- return this.None(amount);
4305
+ return amount;
4342
4306
  },
4343
4307
  }),
4344
4308
  Quadratic: Object.freeze({
@@ -4548,33 +4512,61 @@
4548
4512
  */
4549
4513
  var Group = /** @class */ (function () {
4550
4514
  function Group() {
4515
+ var tweens = [];
4516
+ for (var _i = 0; _i < arguments.length; _i++) {
4517
+ tweens[_i] = arguments[_i];
4518
+ }
4551
4519
  this._tweens = {};
4552
4520
  this._tweensAddedDuringUpdate = {};
4521
+ this.add.apply(this, tweens);
4553
4522
  }
4554
4523
  Group.prototype.getAll = function () {
4555
4524
  var _this = this;
4556
- return Object.keys(this._tweens).map(function (tweenId) {
4557
- return _this._tweens[tweenId];
4558
- });
4525
+ return Object.keys(this._tweens).map(function (tweenId) { return _this._tweens[tweenId]; });
4559
4526
  };
4560
4527
  Group.prototype.removeAll = function () {
4561
4528
  this._tweens = {};
4562
4529
  };
4563
- Group.prototype.add = function (tween) {
4564
- this._tweens[tween.getId()] = tween;
4565
- this._tweensAddedDuringUpdate[tween.getId()] = tween;
4530
+ Group.prototype.add = function () {
4531
+ var _a;
4532
+ var tweens = [];
4533
+ for (var _i = 0; _i < arguments.length; _i++) {
4534
+ tweens[_i] = arguments[_i];
4535
+ }
4536
+ for (var _b = 0, tweens_1 = tweens; _b < tweens_1.length; _b++) {
4537
+ var tween = tweens_1[_b];
4538
+ // Remove from any other group first, a tween can only be in one group at a time.
4539
+ // @ts-expect-error library internal access
4540
+ (_a = tween._group) === null || _a === void 0 ? void 0 : _a.remove(tween);
4541
+ // @ts-expect-error library internal access
4542
+ tween._group = this;
4543
+ this._tweens[tween.getId()] = tween;
4544
+ this._tweensAddedDuringUpdate[tween.getId()] = tween;
4545
+ }
4566
4546
  };
4567
- Group.prototype.remove = function (tween) {
4568
- delete this._tweens[tween.getId()];
4569
- delete this._tweensAddedDuringUpdate[tween.getId()];
4547
+ Group.prototype.remove = function () {
4548
+ var tweens = [];
4549
+ for (var _i = 0; _i < arguments.length; _i++) {
4550
+ tweens[_i] = arguments[_i];
4551
+ }
4552
+ for (var _a = 0, tweens_2 = tweens; _a < tweens_2.length; _a++) {
4553
+ var tween = tweens_2[_a];
4554
+ // @ts-expect-error library internal access
4555
+ tween._group = undefined;
4556
+ delete this._tweens[tween.getId()];
4557
+ delete this._tweensAddedDuringUpdate[tween.getId()];
4558
+ }
4559
+ };
4560
+ /** Return true if all tweens in the group are not paused or playing. */
4561
+ Group.prototype.allStopped = function () {
4562
+ return this.getAll().every(function (tween) { return !tween.isPlaying(); });
4570
4563
  };
4571
4564
  Group.prototype.update = function (time, preserve) {
4572
4565
  if (time === void 0) { time = now(); }
4573
- if (preserve === void 0) { preserve = false; }
4566
+ if (preserve === void 0) { preserve = true; }
4574
4567
  var tweenIds = Object.keys(this._tweens);
4575
- if (tweenIds.length === 0) {
4576
- return false;
4577
- }
4568
+ if (tweenIds.length === 0)
4569
+ return;
4578
4570
  // Tweens are updated in "batches". If you add a new tween during an
4579
4571
  // update, then the new tween will be updated in the next batch.
4580
4572
  // If you remove a tween during an update, it may or may not be updated.
@@ -4585,13 +4577,11 @@
4585
4577
  for (var i = 0; i < tweenIds.length; i++) {
4586
4578
  var tween = this._tweens[tweenIds[i]];
4587
4579
  var autoStart = !preserve;
4588
- if (tween && tween.update(time, autoStart) === false && !preserve) {
4589
- delete this._tweens[tweenIds[i]];
4590
- }
4580
+ if (tween && tween.update(time, autoStart) === false && !preserve)
4581
+ this.remove(tween);
4591
4582
  }
4592
4583
  tweenIds = Object.keys(this._tweensAddedDuringUpdate);
4593
4584
  }
4594
- return true;
4595
4585
  };
4596
4586
  return Group;
4597
4587
  }());
@@ -4700,10 +4690,7 @@
4700
4690
  * Thank you all, you're awesome!
4701
4691
  */
4702
4692
  var Tween = /** @class */ (function () {
4703
- function Tween(_object, _group) {
4704
- if (_group === void 0) { _group = mainGroup; }
4705
- this._object = _object;
4706
- this._group = _group;
4693
+ function Tween(object, group) {
4707
4694
  this._isPaused = false;
4708
4695
  this._pauseStart = 0;
4709
4696
  this._valuesStart = {};
@@ -4728,6 +4715,16 @@
4728
4715
  this._isChainStopped = false;
4729
4716
  this._propertiesAreSetUp = false;
4730
4717
  this._goToEnd = false;
4718
+ this._object = object;
4719
+ if (typeof group === 'object') {
4720
+ this._group = group;
4721
+ group.add(this);
4722
+ }
4723
+ // Use "true" to restore old behavior (will be removed in future release).
4724
+ else if (group === true) {
4725
+ this._group = mainGroup;
4726
+ mainGroup.add(this);
4727
+ }
4731
4728
  }
4732
4729
  Tween.prototype.getId = function () {
4733
4730
  return this._id;
@@ -4738,18 +4735,21 @@
4738
4735
  Tween.prototype.isPaused = function () {
4739
4736
  return this._isPaused;
4740
4737
  };
4738
+ Tween.prototype.getDuration = function () {
4739
+ return this._duration;
4740
+ };
4741
4741
  Tween.prototype.to = function (target, duration) {
4742
4742
  if (duration === void 0) { duration = 1000; }
4743
4743
  if (this._isPlaying)
4744
4744
  throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
4745
4745
  this._valuesEnd = target;
4746
4746
  this._propertiesAreSetUp = false;
4747
- this._duration = duration;
4747
+ this._duration = duration < 0 ? 0 : duration;
4748
4748
  return this;
4749
4749
  };
4750
4750
  Tween.prototype.duration = function (duration) {
4751
4751
  if (duration === void 0) { duration = 1000; }
4752
- this._duration = duration;
4752
+ this._duration = duration < 0 ? 0 : duration;
4753
4753
  return this;
4754
4754
  };
4755
4755
  Tween.prototype.dynamic = function (dynamic) {
@@ -4763,8 +4763,6 @@
4763
4763
  if (this._isPlaying) {
4764
4764
  return this;
4765
4765
  }
4766
- // eslint-disable-next-line
4767
- this._group && this._group.add(this);
4768
4766
  this._repeat = this._initialRepeat;
4769
4767
  if (this._reversed) {
4770
4768
  // If we were reversed (f.e. using the yoyo feature) then we need to
@@ -4881,8 +4879,6 @@
4881
4879
  if (!this._isPlaying) {
4882
4880
  return this;
4883
4881
  }
4884
- // eslint-disable-next-line
4885
- this._group && this._group.remove(this);
4886
4882
  this._isPlaying = false;
4887
4883
  this._isPaused = false;
4888
4884
  if (this._onStopCallback) {
@@ -4892,7 +4888,7 @@
4892
4888
  };
4893
4889
  Tween.prototype.end = function () {
4894
4890
  this._goToEnd = true;
4895
- this.update(Infinity);
4891
+ this.update(this._startTime + this._duration);
4896
4892
  return this;
4897
4893
  };
4898
4894
  Tween.prototype.pause = function (time) {
@@ -4902,8 +4898,6 @@
4902
4898
  }
4903
4899
  this._isPaused = true;
4904
4900
  this._pauseStart = time;
4905
- // eslint-disable-next-line
4906
- this._group && this._group.remove(this);
4907
4901
  return this;
4908
4902
  };
4909
4903
  Tween.prototype.resume = function (time) {
@@ -4914,8 +4908,6 @@
4914
4908
  this._isPaused = false;
4915
4909
  this._startTime += time - this._pauseStart;
4916
4910
  this._pauseStart = 0;
4917
- // eslint-disable-next-line
4918
- this._group && this._group.add(this);
4919
4911
  return this;
4920
4912
  };
4921
4913
  Tween.prototype.stopChainedTweens = function () {
@@ -4925,8 +4917,19 @@
4925
4917
  return this;
4926
4918
  };
4927
4919
  Tween.prototype.group = function (group) {
4928
- if (group === void 0) { group = mainGroup; }
4929
- this._group = group;
4920
+ if (!group) {
4921
+ console.warn('tween.group() without args has been removed, use group.add(tween) instead.');
4922
+ return this;
4923
+ }
4924
+ group.add(this);
4925
+ return this;
4926
+ };
4927
+ /**
4928
+ * Removes the tween from whichever group it is in.
4929
+ */
4930
+ Tween.prototype.remove = function () {
4931
+ var _a;
4932
+ (_a = this._group) === null || _a === void 0 ? void 0 : _a.remove(this);
4930
4933
  return this;
4931
4934
  };
4932
4935
  Tween.prototype.delay = function (amount) {
@@ -4996,20 +4999,24 @@
4996
4999
  * @returns true if the tween is still playing after the update, false
4997
5000
  * otherwise (calling update on a paused tween still returns true because
4998
5001
  * it is still playing, just paused).
5002
+ *
5003
+ * @param autoStart - When true, calling update will implicitly call start()
5004
+ * as well. Note, if you stop() or end() the tween, but are still calling
5005
+ * update(), it will start again!
4999
5006
  */
5000
5007
  Tween.prototype.update = function (time, autoStart) {
5008
+ var _this = this;
5009
+ var _a;
5001
5010
  if (time === void 0) { time = now(); }
5002
- if (autoStart === void 0) { autoStart = true; }
5011
+ if (autoStart === void 0) { autoStart = Tween.autoStartOnUpdate; }
5003
5012
  if (this._isPaused)
5004
5013
  return true;
5005
5014
  var property;
5006
- var elapsed;
5007
- var endTime = this._startTime + this._duration;
5008
5015
  if (!this._goToEnd && !this._isPlaying) {
5009
- if (time > endTime)
5010
- return false;
5011
5016
  if (autoStart)
5012
5017
  this.start(time, true);
5018
+ else
5019
+ return false;
5013
5020
  }
5014
5021
  this._goToEnd = false;
5015
5022
  if (time < this._startTime) {
@@ -5027,18 +5034,37 @@
5027
5034
  }
5028
5035
  this._onEveryStartCallbackFired = true;
5029
5036
  }
5030
- elapsed = (time - this._startTime) / this._duration;
5031
- elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed;
5037
+ var elapsedTime = time - this._startTime;
5038
+ var durationAndDelay = this._duration + ((_a = this._repeatDelayTime) !== null && _a !== void 0 ? _a : this._delayTime);
5039
+ var totalTime = this._duration + this._repeat * durationAndDelay;
5040
+ var calculateElapsedPortion = function () {
5041
+ if (_this._duration === 0)
5042
+ return 1;
5043
+ if (elapsedTime > totalTime) {
5044
+ return 1;
5045
+ }
5046
+ var timesRepeated = Math.trunc(elapsedTime / durationAndDelay);
5047
+ var timeIntoCurrentRepeat = elapsedTime - timesRepeated * durationAndDelay;
5048
+ // TODO use %?
5049
+ // const timeIntoCurrentRepeat = elapsedTime % durationAndDelay
5050
+ var portion = Math.min(timeIntoCurrentRepeat / _this._duration, 1);
5051
+ if (portion === 0 && elapsedTime === _this._duration) {
5052
+ return 1;
5053
+ }
5054
+ return portion;
5055
+ };
5056
+ var elapsed = calculateElapsedPortion();
5032
5057
  var value = this._easingFunction(elapsed);
5033
5058
  // properties transformations
5034
5059
  this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
5035
5060
  if (this._onUpdateCallback) {
5036
5061
  this._onUpdateCallback(this._object, elapsed);
5037
5062
  }
5038
- if (elapsed === 1) {
5063
+ if (this._duration === 0 || elapsedTime >= this._duration) {
5039
5064
  if (this._repeat > 0) {
5065
+ var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat);
5040
5066
  if (isFinite(this._repeat)) {
5041
- this._repeat--;
5067
+ this._repeat -= completeCount;
5042
5068
  }
5043
5069
  // Reassign starting values, restart by making startTime = now
5044
5070
  for (property in this._valuesStartRepeat) {
@@ -5056,12 +5082,7 @@
5056
5082
  if (this._yoyo) {
5057
5083
  this._reversed = !this._reversed;
5058
5084
  }
5059
- if (this._repeatDelayTime !== undefined) {
5060
- this._startTime = time + this._repeatDelayTime;
5061
- }
5062
- else {
5063
- this._startTime = time + this._delayTime;
5064
- }
5085
+ this._startTime += durationAndDelay * completeCount;
5065
5086
  if (this._onRepeatCallback) {
5066
5087
  this._onRepeatCallback(this._object);
5067
5088
  }
@@ -5134,6 +5155,7 @@
5134
5155
  }
5135
5156
  this._valuesEnd[property] = tmp;
5136
5157
  };
5158
+ Tween.autoStartOnUpdate = false;
5137
5159
  return Tween;
5138
5160
  }());
5139
5161
  /**
@@ -5147,37 +5169,269 @@
5147
5169
  // Modules and CommonJS, without build hacks, and so as not to break the
5148
5170
  // existing API.
5149
5171
  // https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
5172
+ /**
5173
+ * @deprecated The global TWEEN Group will be removed in a following major
5174
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
5175
+ * group.
5176
+ *
5177
+ * Old code:
5178
+ *
5179
+ * ```js
5180
+ * import * as TWEEN from '@tweenjs/tween.js'
5181
+ *
5182
+ * //...
5183
+ *
5184
+ * const tween = new TWEEN.Tween(obj)
5185
+ * const tween2 = new TWEEN.Tween(obj2)
5186
+ *
5187
+ * //...
5188
+ *
5189
+ * requestAnimationFrame(function loop(time) {
5190
+ * TWEEN.update(time)
5191
+ * requestAnimationFrame(loop)
5192
+ * })
5193
+ * ```
5194
+ *
5195
+ * New code:
5196
+ *
5197
+ * ```js
5198
+ * import {Tween, Group} from '@tweenjs/tween.js'
5199
+ *
5200
+ * //...
5201
+ *
5202
+ * const tween = new Tween(obj)
5203
+ * const tween2 = new TWEEN.Tween(obj2)
5204
+ *
5205
+ * //...
5206
+ *
5207
+ * const group = new Group()
5208
+ * group.add(tween)
5209
+ * group.add(tween2)
5210
+ *
5211
+ * //...
5212
+ *
5213
+ * requestAnimationFrame(function loop(time) {
5214
+ * group.update(time)
5215
+ * requestAnimationFrame(loop)
5216
+ * })
5217
+ * ```
5218
+ */
5150
5219
  TWEEN.getAll.bind(TWEEN);
5220
+ /**
5221
+ * @deprecated The global TWEEN Group will be removed in a following major
5222
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
5223
+ * group.
5224
+ *
5225
+ * Old code:
5226
+ *
5227
+ * ```js
5228
+ * import * as TWEEN from '@tweenjs/tween.js'
5229
+ *
5230
+ * //...
5231
+ *
5232
+ * const tween = new TWEEN.Tween(obj)
5233
+ * const tween2 = new TWEEN.Tween(obj2)
5234
+ *
5235
+ * //...
5236
+ *
5237
+ * requestAnimationFrame(function loop(time) {
5238
+ * TWEEN.update(time)
5239
+ * requestAnimationFrame(loop)
5240
+ * })
5241
+ * ```
5242
+ *
5243
+ * New code:
5244
+ *
5245
+ * ```js
5246
+ * import {Tween, Group} from '@tweenjs/tween.js'
5247
+ *
5248
+ * //...
5249
+ *
5250
+ * const tween = new Tween(obj)
5251
+ * const tween2 = new TWEEN.Tween(obj2)
5252
+ *
5253
+ * //...
5254
+ *
5255
+ * const group = new Group()
5256
+ * group.add(tween)
5257
+ * group.add(tween2)
5258
+ *
5259
+ * //...
5260
+ *
5261
+ * requestAnimationFrame(function loop(time) {
5262
+ * group.update(time)
5263
+ * requestAnimationFrame(loop)
5264
+ * })
5265
+ * ```
5266
+ */
5151
5267
  TWEEN.removeAll.bind(TWEEN);
5268
+ /**
5269
+ * @deprecated The global TWEEN Group will be removed in a following major
5270
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
5271
+ * group.
5272
+ *
5273
+ * Old code:
5274
+ *
5275
+ * ```js
5276
+ * import * as TWEEN from '@tweenjs/tween.js'
5277
+ *
5278
+ * //...
5279
+ *
5280
+ * const tween = new TWEEN.Tween(obj)
5281
+ * const tween2 = new TWEEN.Tween(obj2)
5282
+ *
5283
+ * //...
5284
+ *
5285
+ * requestAnimationFrame(function loop(time) {
5286
+ * TWEEN.update(time)
5287
+ * requestAnimationFrame(loop)
5288
+ * })
5289
+ * ```
5290
+ *
5291
+ * New code:
5292
+ *
5293
+ * ```js
5294
+ * import {Tween, Group} from '@tweenjs/tween.js'
5295
+ *
5296
+ * //...
5297
+ *
5298
+ * const tween = new Tween(obj)
5299
+ * const tween2 = new TWEEN.Tween(obj2)
5300
+ *
5301
+ * //...
5302
+ *
5303
+ * const group = new Group()
5304
+ * group.add(tween)
5305
+ * group.add(tween2)
5306
+ *
5307
+ * //...
5308
+ *
5309
+ * requestAnimationFrame(function loop(time) {
5310
+ * group.update(time)
5311
+ * requestAnimationFrame(loop)
5312
+ * })
5313
+ * ```
5314
+ */
5152
5315
  TWEEN.add.bind(TWEEN);
5316
+ /**
5317
+ * @deprecated The global TWEEN Group will be removed in a following major
5318
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
5319
+ * group.
5320
+ *
5321
+ * Old code:
5322
+ *
5323
+ * ```js
5324
+ * import * as TWEEN from '@tweenjs/tween.js'
5325
+ *
5326
+ * //...
5327
+ *
5328
+ * const tween = new TWEEN.Tween(obj)
5329
+ * const tween2 = new TWEEN.Tween(obj2)
5330
+ *
5331
+ * //...
5332
+ *
5333
+ * requestAnimationFrame(function loop(time) {
5334
+ * TWEEN.update(time)
5335
+ * requestAnimationFrame(loop)
5336
+ * })
5337
+ * ```
5338
+ *
5339
+ * New code:
5340
+ *
5341
+ * ```js
5342
+ * import {Tween, Group} from '@tweenjs/tween.js'
5343
+ *
5344
+ * //...
5345
+ *
5346
+ * const tween = new Tween(obj)
5347
+ * const tween2 = new TWEEN.Tween(obj2)
5348
+ *
5349
+ * //...
5350
+ *
5351
+ * const group = new Group()
5352
+ * group.add(tween)
5353
+ * group.add(tween2)
5354
+ *
5355
+ * //...
5356
+ *
5357
+ * requestAnimationFrame(function loop(time) {
5358
+ * group.update(time)
5359
+ * requestAnimationFrame(loop)
5360
+ * })
5361
+ * ```
5362
+ */
5153
5363
  TWEEN.remove.bind(TWEEN);
5154
- var update = TWEEN.update.bind(TWEEN);
5155
-
5156
- function _iterableToArrayLimit$1(arr, i) {
5157
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
5158
- if (null != _i) {
5159
- var _s,
5160
- _e,
5161
- _x,
5162
- _r,
5163
- _arr = [],
5164
- _n = !0,
5165
- _d = !1;
5364
+ /**
5365
+ * @deprecated The global TWEEN Group will be removed in a following major
5366
+ * release. To migrate, create a `new Group()` instead of using `TWEEN` as a
5367
+ * group.
5368
+ *
5369
+ * Old code:
5370
+ *
5371
+ * ```js
5372
+ * import * as TWEEN from '@tweenjs/tween.js'
5373
+ *
5374
+ * //...
5375
+ *
5376
+ * const tween = new TWEEN.Tween(obj)
5377
+ * const tween2 = new TWEEN.Tween(obj2)
5378
+ *
5379
+ * //...
5380
+ *
5381
+ * requestAnimationFrame(function loop(time) {
5382
+ * TWEEN.update(time)
5383
+ * requestAnimationFrame(loop)
5384
+ * })
5385
+ * ```
5386
+ *
5387
+ * New code:
5388
+ *
5389
+ * ```js
5390
+ * import {Tween, Group} from '@tweenjs/tween.js'
5391
+ *
5392
+ * //...
5393
+ *
5394
+ * const tween = new Tween(obj)
5395
+ * const tween2 = new TWEEN.Tween(obj2)
5396
+ *
5397
+ * //...
5398
+ *
5399
+ * const group = new Group()
5400
+ * group.add(tween)
5401
+ * group.add(tween2)
5402
+ *
5403
+ * //...
5404
+ *
5405
+ * requestAnimationFrame(function loop(time) {
5406
+ * group.update(time)
5407
+ * requestAnimationFrame(loop)
5408
+ * })
5409
+ * ```
5410
+ */
5411
+ TWEEN.update.bind(TWEEN);
5412
+
5413
+ function _iterableToArrayLimit$1(r, l) {
5414
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
5415
+ if (null != t) {
5416
+ var e,
5417
+ n,
5418
+ i,
5419
+ u,
5420
+ a = [],
5421
+ f = !0,
5422
+ o = !1;
5166
5423
  try {
5167
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
5168
- if (Object(_i) !== _i) return;
5169
- _n = !1;
5170
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
5171
- } catch (err) {
5172
- _d = !0, _e = err;
5424
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
5425
+ } catch (r) {
5426
+ o = !0, n = r;
5173
5427
  } finally {
5174
5428
  try {
5175
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
5429
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
5176
5430
  } finally {
5177
- if (_d) throw _e;
5431
+ if (o) throw n;
5178
5432
  }
5179
5433
  }
5180
- return _arr;
5434
+ return a;
5181
5435
  }
5182
5436
  }
5183
5437
  function _classCallCheck$1(instance, Constructor) {
@@ -5185,18 +5439,7 @@
5185
5439
  throw new TypeError("Cannot call a class as a function");
5186
5440
  }
5187
5441
  }
5188
- function _defineProperties$1(target, props) {
5189
- for (var i = 0; i < props.length; i++) {
5190
- var descriptor = props[i];
5191
- descriptor.enumerable = descriptor.enumerable || false;
5192
- descriptor.configurable = true;
5193
- if ("value" in descriptor) descriptor.writable = true;
5194
- Object.defineProperty(target, _toPropertyKey$2(descriptor.key), descriptor);
5195
- }
5196
- }
5197
5442
  function _createClass$1(Constructor, protoProps, staticProps) {
5198
- if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
5199
- if (staticProps) _defineProperties$1(Constructor, staticProps);
5200
5443
  Object.defineProperty(Constructor, "prototype", {
5201
5444
  writable: false
5202
5445
  });
@@ -5224,20 +5467,6 @@
5224
5467
  function _nonIterableRest$1() {
5225
5468
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5226
5469
  }
5227
- function _toPrimitive$2(input, hint) {
5228
- if (typeof input !== "object" || input === null) return input;
5229
- var prim = input[Symbol.toPrimitive];
5230
- if (prim !== undefined) {
5231
- var res = prim.call(input, hint || "default");
5232
- if (typeof res !== "object") return res;
5233
- throw new TypeError("@@toPrimitive must return a primitive value.");
5234
- }
5235
- return (hint === "string" ? String : Number)(input);
5236
- }
5237
- function _toPropertyKey$2(arg) {
5238
- var key = _toPrimitive$2(arg, "string");
5239
- return typeof key === "symbol" ? key : String(key);
5240
- }
5241
5470
 
5242
5471
  var Prop = /*#__PURE__*/_createClass$1(function Prop(name, _ref) {
5243
5472
  var _ref$default = _ref["default"],
@@ -6557,66 +6786,73 @@
6557
6786
  };
6558
6787
  }
6559
6788
 
6560
- function _classCallCheck(instance, Constructor) {
6561
- if (!(instance instanceof Constructor)) {
6562
- throw new TypeError("Cannot call a class as a function");
6563
- }
6789
+ function _arrayLikeToArray$1(r, a) {
6790
+ (null == a || a > r.length) && (a = r.length);
6791
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
6792
+ return n;
6564
6793
  }
6565
- function _defineProperties(target, props) {
6566
- for (var i = 0; i < props.length; i++) {
6567
- var descriptor = props[i];
6568
- descriptor.enumerable = descriptor.enumerable || false;
6569
- descriptor.configurable = true;
6570
- if ("value" in descriptor) descriptor.writable = true;
6571
- Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
6572
- }
6794
+ function _arrayWithoutHoles$1(r) {
6795
+ if (Array.isArray(r)) return _arrayLikeToArray$1(r);
6573
6796
  }
6574
- function _createClass(Constructor, protoProps, staticProps) {
6575
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
6576
- if (staticProps) _defineProperties(Constructor, staticProps);
6577
- Object.defineProperty(Constructor, "prototype", {
6578
- writable: false
6579
- });
6580
- return Constructor;
6797
+ function _assertClassBrand(e, t, n) {
6798
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
6799
+ throw new TypeError("Private element is not present on this object");
6581
6800
  }
6582
- function _toConsumableArray$1(arr) {
6583
- return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
6801
+ function _checkPrivateRedeclaration(e, t) {
6802
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
6584
6803
  }
6585
- function _arrayWithoutHoles$1(arr) {
6586
- if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
6804
+ function _classCallCheck(a, n) {
6805
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
6587
6806
  }
6588
- function _iterableToArray$1(iter) {
6589
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
6807
+ function _classPrivateFieldGet2(s, a) {
6808
+ return s.get(_assertClassBrand(s, a));
6590
6809
  }
6591
- function _unsupportedIterableToArray$1(o, minLen) {
6592
- if (!o) return;
6593
- if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
6594
- var n = Object.prototype.toString.call(o).slice(8, -1);
6595
- if (n === "Object" && o.constructor) n = o.constructor.name;
6596
- if (n === "Map" || n === "Set") return Array.from(o);
6597
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
6810
+ function _classPrivateFieldInitSpec(e, t, a) {
6811
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
6598
6812
  }
6599
- function _arrayLikeToArray$1(arr, len) {
6600
- if (len == null || len > arr.length) len = arr.length;
6601
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
6602
- return arr2;
6813
+ function _classPrivateFieldSet2(s, a, r) {
6814
+ return s.set(_assertClassBrand(s, a), r), r;
6815
+ }
6816
+ function _defineProperties(e, r) {
6817
+ for (var t = 0; t < r.length; t++) {
6818
+ var o = r[t];
6819
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey$1(o.key), o);
6820
+ }
6821
+ }
6822
+ function _createClass(e, r, t) {
6823
+ return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
6824
+ writable: !1
6825
+ }), e;
6826
+ }
6827
+ function _iterableToArray$1(r) {
6828
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
6603
6829
  }
6604
6830
  function _nonIterableSpread$1() {
6605
6831
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6606
6832
  }
6607
- function _toPrimitive$1(input, hint) {
6608
- if (typeof input !== "object" || input === null) return input;
6609
- var prim = input[Symbol.toPrimitive];
6610
- if (prim !== undefined) {
6611
- var res = prim.call(input, hint || "default");
6612
- if (typeof res !== "object") return res;
6833
+ function _toConsumableArray$1(r) {
6834
+ return _arrayWithoutHoles$1(r) || _iterableToArray$1(r) || _unsupportedIterableToArray$1(r) || _nonIterableSpread$1();
6835
+ }
6836
+ function _toPrimitive$1(t, r) {
6837
+ if ("object" != typeof t || !t) return t;
6838
+ var e = t[Symbol.toPrimitive];
6839
+ if (void 0 !== e) {
6840
+ var i = e.call(t, r);
6841
+ if ("object" != typeof i) return i;
6613
6842
  throw new TypeError("@@toPrimitive must return a primitive value.");
6614
6843
  }
6615
- return (hint === "string" ? String : Number)(input);
6844
+ return (String )(t);
6616
6845
  }
6617
- function _toPropertyKey$1(arg) {
6618
- var key = _toPrimitive$1(arg, "string");
6619
- return typeof key === "symbol" ? key : String(key);
6846
+ function _toPropertyKey$1(t) {
6847
+ var i = _toPrimitive$1(t, "string");
6848
+ return "symbol" == typeof i ? i : i + "";
6849
+ }
6850
+ function _unsupportedIterableToArray$1(r, a) {
6851
+ if (r) {
6852
+ if ("string" == typeof r) return _arrayLikeToArray$1(r, a);
6853
+ var t = {}.toString.call(r).slice(8, -1);
6854
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0;
6855
+ }
6620
6856
  }
6621
6857
 
6622
6858
  var ENTROPY = 123; // Raise numbers to prevent collisions in lower indexes
@@ -6637,42 +6873,53 @@
6637
6873
  var checksum = function checksum(n, csBits) {
6638
6874
  return n * ENTROPY % Math.pow(2, csBits);
6639
6875
  };
6876
+ var _registry = /*#__PURE__*/new WeakMap();
6877
+ var _csBits = /*#__PURE__*/new WeakMap();
6640
6878
  var _default = /*#__PURE__*/function () {
6641
6879
  function _default() {
6642
6880
  var csBits = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 6;
6643
6881
  _classCallCheck(this, _default);
6644
- this.csBits = csBits; // How many bits to reserve for checksum. Will eat away into the usable size of the registry.
6645
- this.registry = ['__reserved for background__']; // indexed objects for rgb lookup;
6646
- }
6647
- _createClass(_default, [{
6882
+ // Internal state
6883
+ _classPrivateFieldInitSpec(this, _registry, void 0);
6884
+ // indexed objects for rgb lookup;
6885
+ _classPrivateFieldInitSpec(this, _csBits, void 0);
6886
+ _classPrivateFieldSet2(_csBits, this, csBits);
6887
+ this.reset();
6888
+ }
6889
+ return _createClass(_default, [{
6890
+ key: "reset",
6891
+ value: function reset() {
6892
+ _classPrivateFieldSet2(_registry, this, ['__reserved for background__']);
6893
+ }
6894
+ }, {
6648
6895
  key: "register",
6649
6896
  value: function register(obj) {
6650
- if (this.registry.length >= Math.pow(2, 24 - this.csBits)) {
6897
+ if (_classPrivateFieldGet2(_registry, this).length >= Math.pow(2, 24 - _classPrivateFieldGet2(_csBits, this))) {
6651
6898
  // color has 24 bits (-checksum)
6652
6899
  return null; // Registry is full
6653
6900
  }
6654
-
6655
- var idx = this.registry.length;
6656
- var cs = checksum(idx, this.csBits);
6657
- var color = int2HexColor(idx + (cs << 24 - this.csBits));
6658
- this.registry.push(obj);
6901
+ var idx = _classPrivateFieldGet2(_registry, this).length;
6902
+ var cs = checksum(idx, _classPrivateFieldGet2(_csBits, this));
6903
+ var color = int2HexColor(idx + (cs << 24 - _classPrivateFieldGet2(_csBits, this)));
6904
+ _classPrivateFieldGet2(_registry, this).push(obj);
6659
6905
  return color;
6660
6906
  }
6661
6907
  }, {
6662
6908
  key: "lookup",
6663
6909
  value: function lookup(color) {
6910
+ if (!color) return null; // invalid color
6911
+
6664
6912
  var n = typeof color === 'string' ? colorStr2Int(color) : rgb2Int.apply(void 0, _toConsumableArray$1(color));
6665
6913
  if (!n) return null; // 0 index is reserved for background
6666
6914
 
6667
- var idx = n & Math.pow(2, 24 - this.csBits) - 1; // registry index
6668
- var cs = n >> 24 - this.csBits & Math.pow(2, this.csBits) - 1; // extract bits reserved for checksum
6915
+ var idx = n & Math.pow(2, 24 - _classPrivateFieldGet2(_csBits, this)) - 1; // registry index
6916
+ var cs = n >> 24 - _classPrivateFieldGet2(_csBits, this) & Math.pow(2, _classPrivateFieldGet2(_csBits, this)) - 1; // extract bits reserved for checksum
6669
6917
 
6670
- if (checksum(idx, this.csBits) !== cs || idx >= this.registry.length) return null; // failed checksum or registry out of bounds
6918
+ if (checksum(idx, _classPrivateFieldGet2(_csBits, this)) !== cs || idx >= _classPrivateFieldGet2(_registry, this).length) return null; // failed checksum or registry out of bounds
6671
6919
 
6672
- return this.registry[idx];
6673
- }
6920
+ return _classPrivateFieldGet2(_registry, this)[idx];
6921
+ } // How many bits to reserve for checksum. Will eat away into the usable size of the registry.
6674
6922
  }]);
6675
- return _default;
6676
6923
  }();
6677
6924
 
6678
6925
  function d3ForceCenter(x, y, z) {
@@ -10464,107 +10711,96 @@
10464
10711
  }
10465
10712
  }
10466
10713
 
10467
- function _iterableToArrayLimit(arr, i) {
10468
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
10469
- if (null != _i) {
10470
- var _s,
10471
- _e,
10472
- _x,
10473
- _r,
10474
- _arr = [],
10475
- _n = !0,
10476
- _d = !1;
10714
+ function _arrayLikeToArray(r, a) {
10715
+ (null == a || a > r.length) && (a = r.length);
10716
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
10717
+ return n;
10718
+ }
10719
+ function _arrayWithHoles(r) {
10720
+ if (Array.isArray(r)) return r;
10721
+ }
10722
+ function _arrayWithoutHoles(r) {
10723
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
10724
+ }
10725
+ function _iterableToArray(r) {
10726
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
10727
+ }
10728
+ function _iterableToArrayLimit(r, l) {
10729
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
10730
+ if (null != t) {
10731
+ var e,
10732
+ n,
10733
+ i,
10734
+ u,
10735
+ a = [],
10736
+ f = !0,
10737
+ o = !1;
10477
10738
  try {
10478
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
10479
- if (Object(_i) !== _i) return;
10480
- _n = !1;
10481
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
10482
- } catch (err) {
10483
- _d = !0, _e = err;
10739
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
10740
+ } catch (r) {
10741
+ o = !0, n = r;
10484
10742
  } finally {
10485
10743
  try {
10486
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
10744
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
10487
10745
  } finally {
10488
- if (_d) throw _e;
10746
+ if (o) throw n;
10489
10747
  }
10490
10748
  }
10491
- return _arr;
10749
+ return a;
10492
10750
  }
10493
10751
  }
10494
- function _objectWithoutPropertiesLoose(source, excluded) {
10495
- if (source == null) return {};
10496
- var target = {};
10497
- var sourceKeys = Object.keys(source);
10498
- var key, i;
10499
- for (i = 0; i < sourceKeys.length; i++) {
10500
- key = sourceKeys[i];
10501
- if (excluded.indexOf(key) >= 0) continue;
10502
- target[key] = source[key];
10503
- }
10504
- return target;
10752
+ function _nonIterableRest() {
10753
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
10505
10754
  }
10506
- function _objectWithoutProperties(source, excluded) {
10507
- if (source == null) return {};
10508
- var target = _objectWithoutPropertiesLoose(source, excluded);
10509
- var key, i;
10755
+ function _nonIterableSpread() {
10756
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
10757
+ }
10758
+ function _objectWithoutProperties(e, t) {
10759
+ if (null == e) return {};
10760
+ var o,
10761
+ r,
10762
+ i = _objectWithoutPropertiesLoose(e, t);
10510
10763
  if (Object.getOwnPropertySymbols) {
10511
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
10512
- for (i = 0; i < sourceSymbolKeys.length; i++) {
10513
- key = sourceSymbolKeys[i];
10514
- if (excluded.indexOf(key) >= 0) continue;
10515
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
10516
- target[key] = source[key];
10517
- }
10764
+ var s = Object.getOwnPropertySymbols(e);
10765
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
10518
10766
  }
10519
- return target;
10520
- }
10521
- function _slicedToArray(arr, i) {
10522
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
10523
- }
10524
- function _toConsumableArray(arr) {
10525
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
10526
- }
10527
- function _arrayWithoutHoles(arr) {
10528
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
10529
- }
10530
- function _arrayWithHoles(arr) {
10531
- if (Array.isArray(arr)) return arr;
10767
+ return i;
10532
10768
  }
10533
- function _iterableToArray(iter) {
10534
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
10535
- }
10536
- function _unsupportedIterableToArray(o, minLen) {
10537
- if (!o) return;
10538
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
10539
- var n = Object.prototype.toString.call(o).slice(8, -1);
10540
- if (n === "Object" && o.constructor) n = o.constructor.name;
10541
- if (n === "Map" || n === "Set") return Array.from(o);
10542
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
10543
- }
10544
- function _arrayLikeToArray(arr, len) {
10545
- if (len == null || len > arr.length) len = arr.length;
10546
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
10547
- return arr2;
10769
+ function _objectWithoutPropertiesLoose(r, e) {
10770
+ if (null == r) return {};
10771
+ var t = {};
10772
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
10773
+ if (e.includes(n)) continue;
10774
+ t[n] = r[n];
10775
+ }
10776
+ return t;
10548
10777
  }
10549
- function _nonIterableSpread() {
10550
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
10778
+ function _slicedToArray(r, e) {
10779
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
10551
10780
  }
10552
- function _nonIterableRest() {
10553
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
10781
+ function _toConsumableArray(r) {
10782
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
10554
10783
  }
10555
- function _toPrimitive(input, hint) {
10556
- if (typeof input !== "object" || input === null) return input;
10557
- var prim = input[Symbol.toPrimitive];
10558
- if (prim !== undefined) {
10559
- var res = prim.call(input, hint || "default");
10560
- if (typeof res !== "object") return res;
10784
+ function _toPrimitive(t, r) {
10785
+ if ("object" != typeof t || !t) return t;
10786
+ var e = t[Symbol.toPrimitive];
10787
+ if (void 0 !== e) {
10788
+ var i = e.call(t, r );
10789
+ if ("object" != typeof i) return i;
10561
10790
  throw new TypeError("@@toPrimitive must return a primitive value.");
10562
10791
  }
10563
- return (hint === "string" ? String : Number)(input);
10792
+ return (String )(t);
10793
+ }
10794
+ function _toPropertyKey(t) {
10795
+ var i = _toPrimitive(t, "string");
10796
+ return "symbol" == typeof i ? i : i + "";
10564
10797
  }
10565
- function _toPropertyKey(arg) {
10566
- var key = _toPrimitive(arg, "string");
10567
- return typeof key === "symbol" ? key : String(key);
10798
+ function _unsupportedIterableToArray(r, a) {
10799
+ if (r) {
10800
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
10801
+ var t = {}.toString.call(r).slice(8, -1);
10802
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
10803
+ }
10568
10804
  }
10569
10805
 
10570
10806
  var index = (function () {
@@ -10628,7 +10864,6 @@
10628
10864
  }
10629
10865
  })(indexedResult); // IIFE
10630
10866
  }
10631
-
10632
10867
  var result = indexedResult;
10633
10868
  if (flattenKeys) {
10634
10869
  // flatten into array
@@ -10857,7 +11092,6 @@
10857
11092
  }); // unfix nodes when disabling dag mode
10858
11093
  }
10859
11094
  },
10860
-
10861
11095
  dagLevelDistance: {},
10862
11096
  dagNodeFilter: {
10863
11097
  "default": function _default(node) {
@@ -11051,7 +11285,6 @@
11051
11285
  if (forceFn === undefined) {
11052
11286
  return state.forceLayout.force(forceName); // Force getter
11053
11287
  }
11054
-
11055
11288
  state.forceLayout.force(forceName, forceFn); // Force setter
11056
11289
  return this;
11057
11290
  },
@@ -11366,7 +11599,6 @@
11366
11599
  __singleHop: true
11367
11600
  }); // add a single hop particle
11368
11601
  }
11369
-
11370
11602
  return this;
11371
11603
  }
11372
11604
  },
@@ -11571,6 +11803,12 @@
11571
11803
  links: []
11572
11804
  },
11573
11805
  onChange: function onChange(d, state) {
11806
+ // Wipe color registry if all objects are new
11807
+ [d.nodes, d.links].every(function (arr) {
11808
+ return (arr || []).every(function (d) {
11809
+ return !d.hasOwnProperty('__indexColor');
11810
+ });
11811
+ }) && state.colorTracker.reset();
11574
11812
  [{
11575
11813
  type: 'Node',
11576
11814
  objs: d.nodes
@@ -11754,7 +11992,7 @@
11754
11992
  // no animation
11755
11993
  setCenter(finalPos);
11756
11994
  } else {
11757
- new Tween(getCenter()).to(finalPos, transitionDuration).easing(Easing.Quadratic.Out).onUpdate(setCenter).start();
11995
+ state.tweenGroup.add(new Tween(getCenter()).to(finalPos, transitionDuration).easing(Easing.Quadratic.Out).onUpdate(setCenter).start());
11758
11996
  }
11759
11997
  return this;
11760
11998
  }
@@ -11787,14 +12025,14 @@
11787
12025
  // no animation
11788
12026
  setZoom(k);
11789
12027
  } else {
11790
- new Tween({
12028
+ state.tweenGroup.add(new Tween({
11791
12029
  k: getZoom()
11792
12030
  }).to({
11793
12031
  k: k
11794
12032
  }, transitionDuration).easing(Easing.Quadratic.Out).onUpdate(function (_ref6) {
11795
12033
  var k = _ref6.k;
11796
12034
  return setZoom(k);
11797
- }).start();
12035
+ }).start());
11798
12036
  }
11799
12037
  return this;
11800
12038
  }
@@ -11885,10 +12123,11 @@
11885
12123
  zoom: d3Zoom(),
11886
12124
  forceGraph: new CanvasForceGraph(),
11887
12125
  shadowGraph: new CanvasForceGraph().cooldownTicks(0).nodeColor('__indexColor').linkColor('__indexColor').isShadow(true),
11888
- colorTracker: new _default() // indexed objects for rgb lookup
12126
+ colorTracker: new _default(),
12127
+ // indexed objects for rgb lookup
12128
+ tweenGroup: new Group()
11889
12129
  };
11890
12130
  },
11891
-
11892
12131
  init: function init(domNode, state) {
11893
12132
  var _this = this;
11894
12133
  // Wipe DOM
@@ -12092,7 +12331,6 @@
12092
12331
  state.isPointerDragging = false;
12093
12332
  return; // don't trigger click events after pointer drag (pan / node drag functionality)
12094
12333
  }
12095
-
12096
12334
  var cbEvents = [ev, state.pointerDownEvent];
12097
12335
  requestAnimationFrame(function () {
12098
12336
  // trigger click events asynchronously, to allow hoverObj to be set (on frame)
@@ -12187,7 +12425,7 @@
12187
12425
  state.forceGraph.globalScale(globalScale).tickFrame();
12188
12426
  state.onRenderFramePost && state.onRenderFramePost(ctx, globalScale);
12189
12427
  }
12190
- update(); // update canvas animation tweens
12428
+ state.tweenGroup.update(); // update canvas animation tweens
12191
12429
 
12192
12430
  state.animationFrameRequestId = requestAnimationFrame(animate);
12193
12431
  })();