targetj 1.1.0 → 1.1.1

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,7 +1,7 @@
1
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
1
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
4
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
5
5
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
6
6
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
7
  function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
@@ -59,6 +59,7 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
59
59
  _this.childTargetValues = {};
60
60
  _this.childTransitions = {};
61
61
  _this.pendingGpuChildren = {};
62
+ _this.pendingImperativeCompletions = new Map();
62
63
  _this.childRuntimePrograms = [];
63
64
  _this.childRuntimeStates = [];
64
65
  _this.pendingGpuChildRuntimeCounts = {};
@@ -76,9 +77,10 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
76
77
  }
77
78
  _inherits(ParticleTModel, _TModel);
78
79
  return _createClass(ParticleTModel, [{
79
- key: "onDomReady",
80
+ key: "onDomAvailable",
80
81
  value: function () {
81
- var _onDomReady = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
82
+ var _onDomAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
83
+ var ready;
82
84
  return _regeneratorRuntime().wrap(function _callee$(_context) {
83
85
  while (1) switch (_context.prev = _context.next) {
84
86
  case 0:
@@ -91,22 +93,25 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
91
93
  _context.next = 4;
92
94
  return this.syncParticleRenderer();
93
95
  case 4:
94
- this.particleRuntime.markPendingRenderReady();
95
- case 5:
96
+ ready = _context.sent;
97
+ if (ready) {
98
+ this.particleRuntime.markPendingRenderReady();
99
+ }
100
+ case 6:
96
101
  case "end":
97
102
  return _context.stop();
98
103
  }
99
104
  }, _callee, this);
100
105
  }));
101
- function onDomReady() {
102
- return _onDomReady.apply(this, arguments);
106
+ function onDomAvailable() {
107
+ return _onDomAvailable.apply(this, arguments);
103
108
  }
104
- return onDomReady;
109
+ return onDomAvailable;
105
110
  }()
106
111
  }, {
107
112
  key: "restoreRuntimeDomDerivedState",
108
113
  value: function () {
109
- var _restoreRuntimeDomDerivedState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
114
+ var _restoreRuntimeDomDerivedState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(explodeSource) {
110
115
  var restored;
111
116
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
112
117
  while (1) switch (_context2.prev = _context2.next) {
@@ -133,28 +138,62 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
133
138
  }
134
139
  return _context2.abrupt("return", false);
135
140
  case 12:
136
- _context2.next = 14;
137
- return this.particleRenderer.waitForPresentedFrame();
138
- case 14:
139
- _context2.prev = 14;
140
- this.restoringParticleRuntime = false;
141
- return _context2.finish(14);
142
- case 17:
141
+ if (!this.explodeChildrenState) {
142
+ _context2.next = 18;
143
+ break;
144
+ }
145
+ _context2.next = 15;
146
+ return this.restoreExplodeTexture(explodeSource);
147
+ case 15:
148
+ restored = _context2.sent;
143
149
  if (restored) {
144
- this.particleRuntime.resumeRestored();
150
+ _context2.next = 18;
151
+ break;
145
152
  }
153
+ return _context2.abrupt("return", false);
154
+ case 18:
155
+ this.particleRuntime.markRenderReady(this.childHandles.map(function (child) {
156
+ return child.index;
157
+ }));
158
+ _context2.next = 21;
159
+ return this.particleRenderer.waitForPresentedFrame();
160
+ case 21:
161
+ _context2.prev = 21;
162
+ this.restoringParticleRuntime = false;
163
+ return _context2.finish(21);
164
+ case 24:
146
165
  return _context2.abrupt("return", restored);
147
- case 19:
166
+ case 25:
148
167
  case "end":
149
168
  return _context2.stop();
150
169
  }
151
- }, _callee2, this, [[4,, 14, 17]]);
170
+ }, _callee2, this, [[4,, 21, 24]]);
152
171
  }));
153
- function restoreRuntimeDomDerivedState() {
172
+ function restoreRuntimeDomDerivedState(_x) {
154
173
  return _restoreRuntimeDomDerivedState.apply(this, arguments);
155
174
  }
156
175
  return restoreRuntimeDomDerivedState;
157
176
  }()
177
+ }, {
178
+ key: "restoreExplodeTexture",
179
+ value: function restoreExplodeTexture(explodeSource) {
180
+ if (!this.explodeChildrenState) {
181
+ return Promise.resolve(true);
182
+ }
183
+ if (!explodeSource) {
184
+ return Promise.resolve(false);
185
+ }
186
+ return this.particleRenderer.setExplodeSource({
187
+ bitmap: explodeSource
188
+ });
189
+ }
190
+ }, {
191
+ key: "disposeRuntimeDerivedState",
192
+ value: function disposeRuntimeDerivedState() {
193
+ var _this$particleRuntime, _this$particleRendere;
194
+ (_this$particleRuntime = this.particleRuntime) === null || _this$particleRuntime === void 0 || _this$particleRuntime.dispose();
195
+ (_this$particleRendere = this.particleRenderer) === null || _this$particleRendere === void 0 || _this$particleRendere.destroy();
196
+ }
158
197
  }, {
159
198
  key: "syncParticleRenderer",
160
199
  value: function syncParticleRenderer() {
@@ -232,12 +271,15 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
232
271
  key: "requestParticleRender",
233
272
  value: function requestParticleRender() {
234
273
  var _this3 = this;
235
- if (this.restoringParticleRuntime || !this.gpuChildrenEnabled || !this.hasDom() || this.particleRenderRequested) {
274
+ if (this.restoringParticleRuntime || !this.gpuChildrenEnabled || !this.isVisible() || !this.hasDom() || this.particleRenderRequested) {
236
275
  return;
237
276
  }
238
277
  this.particleRenderRequested = true;
239
278
  requestAnimationFrame(function () {
240
279
  _this3.particleRenderRequested = false;
280
+ if (!_this3.isVisible() || !_this3.hasDom()) {
281
+ return;
282
+ }
241
283
  if (_this3.activeChildTransitionKey) {
242
284
  _this3.particleRenderer.render();
243
285
  return;
@@ -250,6 +292,18 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
250
292
  }
251
293
  });
252
294
  }
295
+ }, {
296
+ key: "onVisibilityChange",
297
+ value: function onVisibilityChange(visible) {
298
+ if (this.restoringParticleRuntime) {
299
+ return;
300
+ }
301
+ if (visible) {
302
+ this.particleRuntime.resumeForVisibility();
303
+ } else {
304
+ this.particleRuntime.pauseForVisibility();
305
+ }
306
+ }
253
307
  }, {
254
308
  key: "getChildrenRenderer",
255
309
  value: function getChildrenRenderer() {
@@ -326,6 +380,7 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
326
380
  }, {
327
381
  key: "setChildTarget",
328
382
  value: function setChildTarget(index, key, target, steps, interval, easing) {
383
+ var _this$targetValues$or;
329
384
  var originalTargetName = TargetUtil.currentTargetName;
330
385
  var originalTModel = TargetUtil.currentTModel;
331
386
  var cleanKey = ParticleUtil.getTargetName(key);
@@ -333,8 +388,34 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
333
388
  if (!child) {
334
389
  return;
335
390
  }
391
+ if (originalTModel && originalTargetName && originalTModel !== this) {
392
+ TargetUtil.markChildAction(originalTModel, originalTargetName, child);
393
+ }
336
394
  child.allTargetMap[cleanKey] = key;
337
395
  this.childTargetMaps[index] = child.allTargetMap;
396
+
397
+ // Collect imperative assignments issued synchronously by a sequential parent target.
398
+ // TargetExecutor calls handleSpecialTarget() after evaluating the parent function.
399
+ if (originalTModel === this && typeof originalTargetName === "string" && originalTargetName.endsWith("$$") && this.targets[originalTargetName] && ((_this$targetValues$or = this.targetValues[originalTargetName]) === null || _this$targetValues$or === void 0 ? void 0 : _this$targetValues$or.status) !== "done") {
400
+ var _this$childTargetValu, _this$childTargetValu2, _targetValues$index;
401
+ var targetName = TargetUtil.getTargetName(originalTargetName);
402
+ var targetValues = (_this$childTargetValu2 = (_this$childTargetValu = this.childTargetValues)[targetName]) !== null && _this$childTargetValu2 !== void 0 ? _this$childTargetValu2 : _this$childTargetValu[targetName] = [];
403
+ var childTargets = (_targetValues$index = targetValues[index]) !== null && _targetValues$index !== void 0 ? _targetValues$index : targetValues[index] = {};
404
+ var specification = TargetParser.isTargetSpecObject(target) ? _objectSpread({}, target) : {
405
+ value: target
406
+ };
407
+ if (specification.steps === undefined && steps !== undefined) {
408
+ specification.steps = steps;
409
+ }
410
+ if (specification.interval === undefined && interval !== undefined) {
411
+ specification.interval = interval;
412
+ }
413
+ if (specification.easing === undefined && easing !== undefined) {
414
+ specification.easing = easing;
415
+ }
416
+ childTargets[cleanKey] = specification;
417
+ return;
418
+ }
338
419
  this.particleRuntime.setImperativeTarget(index, cleanKey, target, steps, interval, easing, originalTargetName, originalTModel);
339
420
  }
340
421
  }, {
@@ -484,32 +565,18 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
484
565
  if (!child || !childSteps) {
485
566
  continue;
486
567
  }
487
- var wasVisible = child.isVisible();
488
- var layoutProperties = [];
568
+ var layoutChanged = false;
489
569
  for (var _i2 = 0, _Object$keys = Object.keys(childSteps); _i2 < _Object$keys.length; _i2++) {
490
570
  var _values$index;
491
571
  var property = _Object$keys[_i2];
492
572
  child.actualValues[property] = (_values$index = values[index]) === null || _values$index === void 0 ? void 0 : _values$index[property];
493
573
  if (ParticleUtil.affectsChildLayout(property)) {
494
- layoutProperties.push(property);
574
+ child.removeFromNoDomUpdatingTargets(property);
575
+ layoutChanged = true;
495
576
  }
496
577
  }
497
- if (layoutProperties.length) {
578
+ if (layoutChanged) {
498
579
  child.actualValues.isVisible = child.calcVisibility();
499
- if (wasVisible || child.isVisible()) {
500
- var _iterator2 = _createForOfIteratorHelper(layoutProperties),
501
- _step2;
502
- try {
503
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
504
- var _property = _step2.value;
505
- child.removeFromNoDomUpdatingTargets(_property);
506
- }
507
- } catch (err) {
508
- _iterator2.e(err);
509
- } finally {
510
- _iterator2.f();
511
- }
512
- }
513
580
  }
514
581
  }
515
582
  } catch (err) {
@@ -518,16 +585,45 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
518
585
  _iterator.f();
519
586
  }
520
587
  }
588
+ }, {
589
+ key: "canBatchChildTarget",
590
+ value: function canBatchChildTarget(property, specification) {
591
+ if (!ParticleUtil.isGpuTarget(property) || !TargetParser.isTargetSpecObject(specification)) {
592
+ return false;
593
+ }
594
+
595
+ // The WebGPU shader interpolates scalar values and colors linearly. Other animation
596
+ // options need ParticleRuntime, which resolves each property's execution separately.
597
+ if (specification.interval !== undefined || specification.easing !== undefined || specification.pauseOn !== undefined || specification.loop !== undefined || specification.cycles !== undefined) {
598
+ return false;
599
+ }
600
+ if (specification.steps !== undefined && (!Number.isFinite(specification.steps) || specification.steps < 0)) {
601
+ return false;
602
+ }
603
+ if (property === "backgroundColor") {
604
+ return typeof specification.value === "string";
605
+ }
606
+ return typeof specification.value === "number" && Number.isFinite(specification.value);
607
+ }
521
608
  }, {
522
609
  key: "handleSpecialTarget",
523
- value: function handleSpecialTarget(key, value) {
524
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
610
+ value: function handleSpecialTarget(key) {
525
611
  if (!this.gpuChildrenEnabled) {
526
612
  return false;
527
613
  }
528
- var targetValues = this.getChildTargetValues(key);
529
- if (targetValues) {
530
- return this.handleChildTargets(key, targetValues, options);
614
+ var targetName = TargetUtil.getTargetName(key);
615
+ var targetValues = this.childTargetValues[targetName];
616
+ if (!targetValues) {
617
+ return false;
618
+ }
619
+ delete this.childTargetValues[targetName];
620
+ for (var index = 0; index < targetValues.length; index++) {
621
+ for (var _i3 = 0, _Object$entries2 = Object.entries(targetValues[index] || {}); _i3 < _Object$entries2.length; _i3++) {
622
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2),
623
+ property = _Object$entries2$_i[0],
624
+ specification = _Object$entries2$_i[1];
625
+ this.particleRuntime.setImperativeTarget(index, property, specification, undefined, undefined, undefined, key, this);
626
+ }
531
627
  }
532
628
  return false;
533
629
  }
@@ -562,8 +658,7 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
562
658
  }, {
563
659
  key: "addGpuChild",
564
660
  value: function addGpuChild(definition) {
565
- var key = TargetUtil.currentTargetName;
566
- var targetName = TargetUtil.getTargetName(key);
661
+ var originalTargetName = TargetUtil.currentTargetName;
567
662
  var index = this.childHandles.length;
568
663
  this.gpuChildrenEnabled = true;
569
664
  var handle = new ParticleChild(this, index);
@@ -572,7 +667,7 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
572
667
  this.childTargetMaps[index] = handle.allTargetMap;
573
668
  try {
574
669
  var _this$pendingGpuChild, _this$pendingGpuChild2;
575
- var compiled = ParticleUtil.compileChildDefinition(handle, definition);
670
+ var compiled = this.prepareInitialGpuChildRuntime(ParticleUtil.compileChildDefinition(handle, definition), definition);
576
671
  var child = this.createGpuChild(compiled.renderDefinition);
577
672
  if (!child) {
578
673
  this.childHandles.pop();
@@ -583,9 +678,9 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
583
678
  Object.assign(handle.actualValues, child.initial);
584
679
  this.childActualValues[index] = handle.actualValues;
585
680
  this.childTargetMaps[index] = handle.allTargetMap;
586
- this.particleRuntime.registerChild(index, targetName, compiled);
587
- var pending = (_this$pendingGpuChild2 = (_this$pendingGpuChild = this.pendingGpuChildren)[targetName]) !== null && _this$pendingGpuChild2 !== void 0 ? _this$pendingGpuChild2 : _this$pendingGpuChild[targetName] = {
588
- key: key,
681
+ this.particleRuntime.registerChild(index, originalTargetName, compiled);
682
+ var pending = (_this$pendingGpuChild2 = (_this$pendingGpuChild = this.pendingGpuChildren)[originalTargetName]) !== null && _this$pendingGpuChild2 !== void 0 ? _this$pendingGpuChild2 : _this$pendingGpuChild[originalTargetName] = {
683
+ key: originalTargetName,
589
684
  children: []
590
685
  };
591
686
  pending.children.push(_objectSpread({
@@ -604,6 +699,62 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
604
699
  throw error;
605
700
  }
606
701
  }
702
+ }, {
703
+ key: "prepareInitialGpuChildRuntime",
704
+ value: function prepareInitialGpuChildRuntime(compiled, definition) {
705
+ var _loop = function _loop() {
706
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i4], 2),
707
+ key = _Object$entries3$_i[0],
708
+ specification = _Object$entries3$_i[1];
709
+ if (TargetUtil.getTargetName(key) !== key || !TargetParser.isTargetSpecObject(specification) || !ParticleUtil.isGpuTarget(key)) {
710
+ return 0; // continue
711
+ }
712
+ var value = specification.value;
713
+ var hasValues = Array.isArray(value) && value.length > 1;
714
+ var steps = specification.steps;
715
+ var hasSteps = Array.isArray(steps) ? steps.some(function (step) {
716
+ return Number(step) > 0;
717
+ }) : Number(steps) > 0;
718
+ if (!hasValues && !hasSteps) {
719
+ return 0; // continue
720
+ }
721
+
722
+ // Function-valued targets are already compiled for ParticleRuntime.
723
+ if (typeof value === "function") {
724
+ return 0; // continue
725
+ }
726
+ var targetName = ParticleUtil.getTargetName(key);
727
+ var initialValue = TUtil.isDefined(specification.initialValue) ? specification.initialValue : hasValues ? value[0] : value;
728
+ var runtimeTarget = compiled.runtimeTargets.find(function (target) {
729
+ return target.key === key && target.mode === "immediate";
730
+ });
731
+
732
+ // Initial animations belong to the child, not to the parent's GPU transition.
733
+ compiled.renderDefinition[targetName] = initialValue;
734
+ if (runtimeTarget) {
735
+ runtimeTarget.requiresRuntime = true;
736
+ runtimeTarget.requiresInitialResolution = false;
737
+ runtimeTarget.renderable = true;
738
+ runtimeTarget.target = _objectSpread({}, specification);
739
+ } else {
740
+ compiled.runtimeTargets.push({
741
+ key: key,
742
+ targetName: targetName,
743
+ mode: "immediate",
744
+ target: _objectSpread({}, specification),
745
+ requiresRuntime: true,
746
+ requiresInitialResolution: false,
747
+ renderable: true
748
+ });
749
+ }
750
+ },
751
+ _ret;
752
+ for (var _i4 = 0, _Object$entries3 = Object.entries(definition); _i4 < _Object$entries3.length; _i4++) {
753
+ _ret = _loop();
754
+ if (_ret === 0) continue;
755
+ }
756
+ return compiled;
757
+ }
607
758
  }, {
608
759
  key: "removeChild",
609
760
  value: function removeChild(child) {
@@ -619,8 +770,8 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
619
770
  this.childActualValues.splice(index, 1);
620
771
  this.childTargetMaps.splice(index, 1);
621
772
  this.removeChildFromTransitions(index);
622
- for (var _i3 = 0, _Object$values = Object.values(this.childTargetValues); _i3 < _Object$values.length; _i3++) {
623
- var targetValues = _Object$values[_i3];
773
+ for (var _i5 = 0, _Object$values = Object.values(this.childTargetValues); _i5 < _Object$values.length; _i5++) {
774
+ var targetValues = _Object$values[_i5];
624
775
  targetValues === null || targetValues === void 0 || targetValues.splice(index, 1);
625
776
  }
626
777
  child.index = -1;
@@ -637,9 +788,9 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
637
788
  }, {
638
789
  key: "removeChildFromTransitions",
639
790
  value: function removeChildFromTransitions(index) {
640
- for (var _i4 = 0, _Object$values2 = Object.values(this.childTransitions); _i4 < _Object$values2.length; _i4++) {
791
+ for (var _i6 = 0, _Object$values2 = Object.values(this.childTransitions); _i6 < _Object$values2.length; _i6++) {
641
792
  var _transition$initialVa, _transition$values, _transition$steps, _transition$loops;
642
- var transition = _Object$values2[_i4];
793
+ var transition = _Object$values2[_i6];
643
794
  (_transition$initialVa = transition.initialValues) === null || _transition$initialVa === void 0 || _transition$initialVa.splice(index, 1);
644
795
  (_transition$values = transition.values) === null || _transition$values === void 0 || _transition$values.splice(index, 1);
645
796
  (_transition$steps = transition.steps) === null || _transition$steps === void 0 || _transition$steps.splice(index, 1);
@@ -648,43 +799,43 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
648
799
  transition.children = transition.children.filter(function (child) {
649
800
  return child.index !== index;
650
801
  });
651
- var _iterator3 = _createForOfIteratorHelper(transition.children),
652
- _step3;
802
+ var _iterator2 = _createForOfIteratorHelper(transition.children),
803
+ _step2;
653
804
  try {
654
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
655
- var child = _step3.value;
805
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
806
+ var child = _step2.value;
656
807
  if (child.index > index) {
657
808
  child.index--;
658
809
  }
659
810
  }
660
811
  } catch (err) {
661
- _iterator3.e(err);
812
+ _iterator2.e(err);
662
813
  } finally {
663
- _iterator3.f();
814
+ _iterator2.f();
664
815
  }
665
816
  }
666
817
  }
667
- for (var _i5 = 0, _Object$values3 = Object.values(this.pendingGpuChildren); _i5 < _Object$values3.length; _i5++) {
668
- var pending = _Object$values3[_i5];
818
+ for (var _i7 = 0, _Object$values3 = Object.values(this.pendingGpuChildren); _i7 < _Object$values3.length; _i7++) {
819
+ var pending = _Object$values3[_i7];
669
820
  if (!(pending !== null && pending !== void 0 && pending.children)) {
670
821
  continue;
671
822
  }
672
823
  pending.children = pending.children.filter(function (child) {
673
824
  return child.index !== index;
674
825
  });
675
- var _iterator4 = _createForOfIteratorHelper(pending.children),
676
- _step4;
826
+ var _iterator3 = _createForOfIteratorHelper(pending.children),
827
+ _step3;
677
828
  try {
678
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
679
- var _child = _step4.value;
829
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
830
+ var _child = _step3.value;
680
831
  if (_child.index > index) {
681
832
  _child.index--;
682
833
  }
683
834
  }
684
835
  } catch (err) {
685
- _iterator4.e(err);
836
+ _iterator3.e(err);
686
837
  } finally {
687
- _iterator4.f();
838
+ _iterator3.f();
688
839
  }
689
840
  }
690
841
  }
@@ -711,11 +862,11 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
711
862
  var loops = {};
712
863
  var valueLists = {};
713
864
  var hasTransition = false;
714
- for (var _i6 = 0, _Object$entries2 = Object.entries(definition); _i6 < _Object$entries2.length; _i6++) {
865
+ for (var _i8 = 0, _Object$entries4 = Object.entries(definition); _i8 < _Object$entries4.length; _i8++) {
715
866
  var _resolved$valueList;
716
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i6], 2),
717
- property = _Object$entries2$_i[0],
718
- value = _Object$entries2$_i[1];
867
+ var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i8], 2),
868
+ property = _Object$entries4$_i[0],
869
+ value = _Object$entries4$_i[1];
719
870
  var resolved = this.resolveInitialChildProperty(value);
720
871
  if (!resolved) {
721
872
  return;
@@ -748,99 +899,81 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
748
899
  key: "finalizeChildrenTarget",
749
900
  value: function finalizeChildrenTarget(key) {
750
901
  var _this6 = this;
751
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
752
- if (!ParticleUtil.isChildrenTarget(key)) {
902
+ if (!ParticleUtil.isChildrenTarget(key) && !TargetParser.isExplodeChildrenTarget(key)) {
753
903
  return false;
754
904
  }
755
- var targetName = TargetUtil.getTargetName(key);
756
- var pending = this.pendingGpuChildren[targetName];
905
+ var pending = this.pendingGpuChildren[key];
757
906
  if (!(pending !== null && pending !== void 0 && pending.children.length)) {
758
907
  return false;
759
908
  }
760
909
  this.invalidateLayout();
761
- var defaultSteps = Math.max(0, Number(options.steps) || 0);
762
- var segmentCount = this.getChildrenSegmentCount(pending.children);
763
- var segment = this.buildChildTransitionSegment(pending.children, 0, defaultSteps);
764
- this.commitImmediateChildTransitionValues(pending.children, segment.values, segment.steps);
765
- delete this.pendingGpuChildren[targetName];
766
- if (!segment.hasSegment || segment.maxSteps === 0) {
767
- this.commitChildTransitionSegment(pending.children, segment.values, segment.steps);
768
- var runtimeIndexes = pending.children.map(function (child) {
769
- return child.index;
770
- }).filter(function (index) {
771
- var state = _this6.childRuntimeStates[index];
772
- return state && !state.done;
773
- });
774
- var _iterator5 = _createForOfIteratorHelper(runtimeIndexes),
775
- _step5;
776
- try {
777
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
778
- var index = _step5.value;
779
- this.particleRuntime.queueStart(index);
780
- }
781
- } catch (err) {
782
- _iterator5.e(err);
783
- } finally {
784
- _iterator5.f();
785
- }
786
- if (this.hasDom()) {
787
- this.particleRenderer.setParticles(this.childHandles).then(function () {
788
- _this6.particleRuntime.markRenderReady(runtimeIndexes);
789
- });
910
+ delete this.pendingGpuChildren[key];
911
+ var childIndexes = pending.children.map(function (child) {
912
+ return child.index;
913
+ });
914
+ var runtimeIndexes = childIndexes.filter(function (index) {
915
+ var state = _this6.childRuntimeStates[index];
916
+ return state && !state.done;
917
+ });
918
+ var _iterator4 = _createForOfIteratorHelper(runtimeIndexes),
919
+ _step4;
920
+ try {
921
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
922
+ var index = _step4.value;
923
+ this.particleRuntime.queueStart(index);
790
924
  }
791
- return {
792
- handled: true,
793
- steps: 0
794
- };
925
+ } catch (err) {
926
+ _iterator4.e(err);
927
+ } finally {
928
+ _iterator4.f();
929
+ }
930
+ if (this.hasDom()) {
931
+ var particlesReady = this.particleRenderer.setParticles(this.childHandles);
932
+ var renderReady = TargetParser.isExplodeChildrenTarget(key) && this.explodeCapturePromise ? Promise.all([particlesReady, this.explodeCapturePromise]) : Promise.all([particlesReady]);
933
+ renderReady.then(function (results) {
934
+ if (results.some(function (result) {
935
+ return result !== true;
936
+ })) {
937
+ return;
938
+ }
939
+ _this6.particleRuntime.markRenderReady(childIndexes);
940
+ }).catch(function (error) {
941
+ return console.error(error);
942
+ });
795
943
  }
796
- var transition = {
797
- children: pending.children,
798
- segmentIndex: 0,
799
- segmentCount: segmentCount,
800
- defaultSteps: defaultSteps,
801
- initialValues: segment.initialValues,
802
- values: segment.values,
803
- steps: segment.steps,
804
- loops: segment.loops,
805
- hasLoop: segment.hasLoop,
806
- generation: this.childGeneration
807
- };
808
- this.childTransitions[targetName] = transition;
809
- this.activeChildTransitionKey = key;
810
- this.addChildTransitionLayoutTargets(transition);
811
944
  return {
812
945
  handled: true,
813
- steps: segment.maxSteps
946
+ steps: 0
814
947
  };
815
948
  }
816
949
  }, {
817
950
  key: "addChildTransitionLayoutTargets",
818
951
  value: function addChildTransitionLayoutTargets(transition) {
819
- var _iterator6 = _createForOfIteratorHelper(transition.children),
820
- _step6;
952
+ var _iterator5 = _createForOfIteratorHelper(transition.children),
953
+ _step5;
821
954
  try {
822
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
955
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
823
956
  var _transition$steps2;
824
- var transitionChild = _step6.value;
957
+ var transitionChild = _step5.value;
825
958
  var index = transitionChild.index;
826
959
  var child = this.childHandles[index];
827
960
  var childSteps = (_transition$steps2 = transition.steps) === null || _transition$steps2 === void 0 ? void 0 : _transition$steps2[index];
828
961
  if (!child || !childSteps) {
829
962
  continue;
830
963
  }
831
- for (var _i7 = 0, _Object$entries3 = Object.entries(childSteps); _i7 < _Object$entries3.length; _i7++) {
832
- var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i7], 2),
833
- property = _Object$entries3$_i[0],
834
- steps = _Object$entries3$_i[1];
964
+ for (var _i9 = 0, _Object$entries5 = Object.entries(childSteps); _i9 < _Object$entries5.length; _i9++) {
965
+ var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i9], 2),
966
+ property = _Object$entries5$_i[0],
967
+ steps = _Object$entries5$_i[1];
835
968
  if (steps > 0 && ParticleUtil.affectsChildLayout(property)) {
836
969
  child.addToNoDomUpdatingTargets(property);
837
970
  }
838
971
  }
839
972
  }
840
973
  } catch (err) {
841
- _iterator6.e(err);
974
+ _iterator5.e(err);
842
975
  } finally {
843
- _iterator6.f();
976
+ _iterator5.f();
844
977
  }
845
978
  }
846
979
  }, {
@@ -868,8 +1001,8 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
868
1001
  }
869
1002
  var currentStep = Math.max(0, Number(this.getTargetStep(key)) || 0);
870
1003
  var changed = false;
871
- for (var _i8 = 0, _arr = _toConsumableArray(child.noDomUpdatingTargets); _i8 < _arr.length; _i8++) {
872
- var property = _arr[_i8];
1004
+ for (var _i10 = 0, _arr = _toConsumableArray(child.noDomUpdatingTargets); _i10 < _arr.length; _i10++) {
1005
+ var property = _arr[_i10];
873
1006
  if (!ParticleUtil.affectsChildLayout(property)) {
874
1007
  child.removeFromNoDomUpdatingTargets(property);
875
1008
  continue;
@@ -942,11 +1075,11 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
942
1075
  var maxSteps = 0;
943
1076
  var hasSegment = false;
944
1077
  var hasLoop = false;
945
- var _iterator7 = _createForOfIteratorHelper(children),
946
- _step7;
1078
+ var _iterator6 = _createForOfIteratorHelper(children),
1079
+ _step6;
947
1080
  try {
948
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
949
- var transitionChild = _step7.value;
1081
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1082
+ var transitionChild = _step6.value;
950
1083
  var index = transitionChild.index;
951
1084
  var child = this.childHandles[index];
952
1085
  if (!child) {
@@ -960,8 +1093,8 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
960
1093
  var target = void 0;
961
1094
  var childSteps = void 0;
962
1095
  var childLoops = void 0;
963
- for (var _i9 = 0, _Object$keys2 = Object.keys(transitionChild.target); _i9 < _Object$keys2.length; _i9++) {
964
- var property = _Object$keys2[_i9];
1096
+ for (var _i11 = 0, _Object$keys2 = Object.keys(transitionChild.target); _i11 < _Object$keys2.length; _i11++) {
1097
+ var property = _Object$keys2[_i11];
965
1098
  var valueList = transitionChild.valueLists[property];
966
1099
  var value = void 0;
967
1100
  if (valueList) {
@@ -998,9 +1131,9 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
998
1131
  }
999
1132
  }
1000
1133
  } catch (err) {
1001
- _iterator7.e(err);
1134
+ _iterator6.e(err);
1002
1135
  } finally {
1003
- _iterator7.f();
1136
+ _iterator6.f();
1004
1137
  }
1005
1138
  return {
1006
1139
  initialValues: initialValues,
@@ -1028,8 +1161,8 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
1028
1161
  key: "getChildSegmentCount",
1029
1162
  value: function getChildSegmentCount(child) {
1030
1163
  var count = 0;
1031
- for (var _i10 = 0, _Object$values4 = Object.values(child.valueLists); _i10 < _Object$values4.length; _i10++) {
1032
- var valueList = _Object$values4[_i10];
1164
+ for (var _i12 = 0, _Object$values4 = Object.values(child.valueLists); _i12 < _Object$values4.length; _i12++) {
1165
+ var valueList = _Object$values4[_i12];
1033
1166
  count = Math.max(count, valueList.length - 1);
1034
1167
  }
1035
1168
  return count;
@@ -1038,17 +1171,17 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
1038
1171
  key: "getChildrenSegmentCount",
1039
1172
  value: function getChildrenSegmentCount(children) {
1040
1173
  var count = 0;
1041
- var _iterator8 = _createForOfIteratorHelper(children),
1042
- _step8;
1174
+ var _iterator7 = _createForOfIteratorHelper(children),
1175
+ _step7;
1043
1176
  try {
1044
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1045
- var child = _step8.value;
1177
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1178
+ var child = _step7.value;
1046
1179
  count = Math.max(count, this.getChildSegmentCount(child));
1047
1180
  }
1048
1181
  } catch (err) {
1049
- _iterator8.e(err);
1182
+ _iterator7.e(err);
1050
1183
  } finally {
1051
- _iterator8.f();
1184
+ _iterator7.f();
1052
1185
  }
1053
1186
  return count;
1054
1187
  }
@@ -1069,7 +1202,9 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
1069
1202
  if (!transition || transition.generation !== this.childGeneration) {
1070
1203
  return false;
1071
1204
  }
1072
- this.particleRenderer.setTransitionStep(this.getTargetStep(key));
1205
+ if (this.isVisible()) {
1206
+ this.particleRenderer.setTransitionStep(this.getTargetStep(key));
1207
+ }
1073
1208
  return true;
1074
1209
  }
1075
1210
  }, {
@@ -1224,11 +1359,11 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
1224
1359
  transition.values[index] = target;
1225
1360
  }
1226
1361
  var childSteps = (_transition$steps4$_i = (_transition$steps4 = transition.steps)[_index = index]) !== null && _transition$steps4$_i !== void 0 ? _transition$steps4$_i : _transition$steps4[_index] = {};
1227
- var _iterator9 = _createForOfIteratorHelper(layoutProperties),
1228
- _step9;
1362
+ var _iterator8 = _createForOfIteratorHelper(layoutProperties),
1363
+ _step8;
1229
1364
  try {
1230
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1231
- var property = _step9.value;
1365
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1366
+ var property = _step8.value;
1232
1367
  if (Object.prototype.hasOwnProperty.call(childSteps, property)) {
1233
1368
  continue;
1234
1369
  }
@@ -1240,9 +1375,9 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
1240
1375
  childSteps[property] = 0;
1241
1376
  }
1242
1377
  } catch (err) {
1243
- _iterator9.e(err);
1378
+ _iterator8.e(err);
1244
1379
  } finally {
1245
- _iterator9.f();
1380
+ _iterator8.f();
1246
1381
  }
1247
1382
  }
1248
1383
  if (transition.generation !== this.childGeneration || this.restoringParticleRuntime || !this.hasDom()) {
@@ -1261,11 +1396,11 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
1261
1396
  key: "commitImmediateChildTransitionValues",
1262
1397
  value: function commitImmediateChildTransitionValues(children, values, steps) {
1263
1398
  var changed = false;
1264
- var _iterator10 = _createForOfIteratorHelper(children),
1265
- _step10;
1399
+ var _iterator9 = _createForOfIteratorHelper(children),
1400
+ _step9;
1266
1401
  try {
1267
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1268
- var transitionChild = _step10.value;
1402
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1403
+ var transitionChild = _step9.value;
1269
1404
  var index = transitionChild.index;
1270
1405
  var child = this.childHandles[index];
1271
1406
  var childSteps = steps === null || steps === void 0 ? void 0 : steps[index];
@@ -1273,11 +1408,11 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
1273
1408
  continue;
1274
1409
  }
1275
1410
  var layoutChanged = false;
1276
- for (var _i11 = 0, _Object$entries4 = Object.entries(childSteps); _i11 < _Object$entries4.length; _i11++) {
1411
+ for (var _i13 = 0, _Object$entries6 = Object.entries(childSteps); _i13 < _Object$entries6.length; _i13++) {
1277
1412
  var _values$index2;
1278
- var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i11], 2),
1279
- property = _Object$entries4$_i[0],
1280
- propertySteps = _Object$entries4$_i[1];
1413
+ var _Object$entries6$_i = _slicedToArray(_Object$entries6[_i13], 2),
1414
+ property = _Object$entries6$_i[0],
1415
+ propertySteps = _Object$entries6$_i[1];
1281
1416
  if (propertySteps !== 0) {
1282
1417
  continue;
1283
1418
  }
@@ -1296,9 +1431,9 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
1296
1431
  }
1297
1432
  }
1298
1433
  } catch (err) {
1299
- _iterator10.e(err);
1434
+ _iterator9.e(err);
1300
1435
  } finally {
1301
- _iterator10.f();
1436
+ _iterator9.f();
1302
1437
  }
1303
1438
  return changed;
1304
1439
  }
@@ -1324,6 +1459,25 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
1324
1459
  value: function getParticleCount() {
1325
1460
  return this.childHandles.length;
1326
1461
  }
1462
+ }, {
1463
+ key: "getRuntimeSnapshotFields",
1464
+ value: function getRuntimeSnapshotFields() {
1465
+ return {
1466
+ childHandleRuntimeStates: this.childHandles.map(function (child) {
1467
+ return {
1468
+ x: child.x,
1469
+ y: child.y,
1470
+ targets: child.targets,
1471
+ targetValues: child.targetValues,
1472
+ updatingTargetList: _toConsumableArray(child.updatingTargetList),
1473
+ activeTargetList: _toConsumableArray(child.activeTargetList),
1474
+ activatedTargets: _toConsumableArray(child.activatedTargets),
1475
+ noDomUpdatingTargets: child.noDomUpdatingTargets ? new Set(child.noDomUpdatingTargets) : undefined,
1476
+ pendingTargets: child.pendingTargets
1477
+ };
1478
+ })
1479
+ };
1480
+ }
1327
1481
  }, {
1328
1482
  key: "excludeRuntimeSnapshotField",
1329
1483
  value: function excludeRuntimeSnapshotField(key) {
@@ -1336,15 +1490,43 @@ var ParticleTModel = /*#__PURE__*/function (_TModel) {
1336
1490
  this.particleRenderer.destroy();
1337
1491
  this.childActualValues || (this.childActualValues = []);
1338
1492
  this.childTargetMaps || (this.childTargetMaps = []);
1493
+ var childHandleRuntimeStates = this.childHandleRuntimeStates || [];
1339
1494
  this.childHandles = this.childActualValues.map(function (values, index) {
1495
+ var _runtimeState$x, _runtimeState$y;
1340
1496
  var child = new ParticleChild(_this9, index);
1341
1497
  var targetMap = _this9.childTargetMaps[index] || {};
1498
+ var runtimeState = childHandleRuntimeStates[index];
1342
1499
  Object.assign(child.actualValues, values);
1343
1500
  Object.assign(child.allTargetMap, targetMap);
1501
+ child.x = (_runtimeState$x = runtimeState === null || runtimeState === void 0 ? void 0 : runtimeState.x) !== null && _runtimeState$x !== void 0 ? _runtimeState$x : child.x;
1502
+ child.y = (_runtimeState$y = runtimeState === null || runtimeState === void 0 ? void 0 : runtimeState.y) !== null && _runtimeState$y !== void 0 ? _runtimeState$y : child.y;
1503
+ if (runtimeState) {
1504
+ var _child$activeTargetLi, _child$activatedTarge, _runtimeState$pending;
1505
+ Object.assign(child.targets, runtimeState.targets);
1506
+ Object.assign(child.targetValues, runtimeState.targetValues);
1507
+ var _iterator10 = _createForOfIteratorHelper(runtimeState.updatingTargetList || []),
1508
+ _step10;
1509
+ try {
1510
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1511
+ var key = _step10.value;
1512
+ child.updatingTargetList.push(key);
1513
+ child.updatingTargetMap[key] = true;
1514
+ }
1515
+ } catch (err) {
1516
+ _iterator10.e(err);
1517
+ } finally {
1518
+ _iterator10.f();
1519
+ }
1520
+ (_child$activeTargetLi = child.activeTargetList).push.apply(_child$activeTargetLi, _toConsumableArray(runtimeState.activeTargetList || []));
1521
+ (_child$activatedTarge = child.activatedTargets).push.apply(_child$activatedTarge, _toConsumableArray(runtimeState.activatedTargets || []));
1522
+ child.noDomUpdatingTargets = runtimeState.noDomUpdatingTargets ? new Set(runtimeState.noDomUpdatingTargets) : undefined;
1523
+ child.pendingTargets = (_runtimeState$pending = runtimeState.pendingTargets) !== null && _runtimeState$pending !== void 0 ? _runtimeState$pending : false;
1524
+ }
1344
1525
  _this9.childActualValues[index] = child.actualValues;
1345
1526
  _this9.childTargetMaps[index] = child.allTargetMap;
1346
1527
  return child;
1347
1528
  });
1529
+ delete this.childHandleRuntimeStates;
1348
1530
  this.childGeneration = Number.isInteger(this.childGeneration) ? this.childGeneration : 0;
1349
1531
  this.particleValuesDirty = false;
1350
1532
  this.particleRenderRequested = false;
@@ -1393,10 +1575,16 @@ function isParticleTModel(targets) {
1393
1575
  if (!targets) {
1394
1576
  return false;
1395
1577
  }
1396
- for (var _i12 = 0, _Object$entries5 = Object.entries(targets); _i12 < _Object$entries5.length; _i12++) {
1397
- var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i12], 2),
1398
- key = _Object$entries5$_i[0],
1399
- target = _Object$entries5$_i[1];
1578
+ for (var _i14 = 0, _Object$entries7 = Object.entries(targets); _i14 < _Object$entries7.length; _i14++) {
1579
+ var _Object$entries7$_i = _slicedToArray(_Object$entries7[_i14], 2),
1580
+ key = _Object$entries7$_i[0],
1581
+ target = _Object$entries7$_i[1];
1582
+ if (TargetParser.isExplodeChildrenTarget(key)) {
1583
+ if ((target === null || target === void 0 ? void 0 : target.renderer) !== "dom") {
1584
+ return true;
1585
+ }
1586
+ continue;
1587
+ }
1400
1588
  if (!ParticleUtil.isChildrenTarget(key)) {
1401
1589
  continue;
1402
1590
  }