targetj 1.0.258 → 1.0.260
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Export.js +13 -1
- package/README.md +18 -25
- package/build/AnimationUtil.js +1 -8
- package/build/App.js +3 -2
- package/build/BaseModel.js +31 -10
- package/build/Child.js +504 -0
- package/build/LocationManager.js +30 -0
- package/build/ParticleRenderer.js +637 -0
- package/build/ParticleRuntime.js +898 -0
- package/build/ParticleTModel.js +1040 -0
- package/build/ParticleUtil.js +317 -0
- package/build/ScheduleUtil.js +2 -2
- package/build/StateManager.js +173 -26
- package/build/StateUtil.js +13 -14
- package/build/TModel.js +61 -27
- package/build/TModelFactory.js +48 -0
- package/build/TModelManager.js +55 -22
- package/build/TUtil.js +8 -3
- package/build/TargetData.js +4 -4
- package/build/TargetExecutor.js +52 -6
- package/build/TargetManager.js +5 -2
- package/build/TargetParser.js +19 -2
- package/build/TargetUtil.js +2 -2
- package/build/Viewport.js +2 -2
- package/build/index.js +5 -1
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +1 -1
- package/types/app.d.ts +56 -0
- package/types/attributes.d.ts +37 -0
- package/types/core.d.ts +154 -0
- package/types/events.d.ts +41 -0
- package/types/index.d.ts +29 -287
- package/types/state.d.ts +48 -0
- package/types/styles.d.ts +103 -0
- package/types/tmodel.d.ts +89 -0
- package/types/utilities.d.ts +37 -0
|
@@ -0,0 +1,898 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
4
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
5
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
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
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
8
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
9
|
+
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; } } }; }
|
|
10
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); 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; } }
|
|
11
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
13
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
14
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
import { Easing } from "./Easing.js";
|
|
18
|
+
import { ParticleUtil } from "./ParticleUtil.js";
|
|
19
|
+
import { TargetUtil } from "./TargetUtil.js";
|
|
20
|
+
import { TModelUtil } from "./TModelUtil.js";
|
|
21
|
+
import { TUtil } from "./TUtil.js";
|
|
22
|
+
import { getRunScheduler } from "./App.js";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Executes lightweight GPU-child TargetJS runtime behavior.
|
|
26
|
+
*
|
|
27
|
+
* Logical runtime state remains on ParticleTModel so it can participate
|
|
28
|
+
* in normal runtime snapshot/restore.
|
|
29
|
+
*/
|
|
30
|
+
var ParticleRuntime = /*#__PURE__*/function () {
|
|
31
|
+
function ParticleRuntime(tmodel) {
|
|
32
|
+
_classCallCheck(this, ParticleRuntime);
|
|
33
|
+
this.tmodel = tmodel;
|
|
34
|
+
this.activeTargets = [];
|
|
35
|
+
this.restoredMainIndexes = [];
|
|
36
|
+
this.restoredActivationSequences = [];
|
|
37
|
+
}
|
|
38
|
+
return _createClass(ParticleRuntime, [{
|
|
39
|
+
key: "registerChild",
|
|
40
|
+
value: function registerChild(index, targetName, compiled) {
|
|
41
|
+
var _compiled$layoutFunct;
|
|
42
|
+
var tmodel = this.tmodel;
|
|
43
|
+
var controlledTargets = {};
|
|
44
|
+
var _iterator = _createForOfIteratorHelper(compiled.runtimeTargets),
|
|
45
|
+
_step;
|
|
46
|
+
try {
|
|
47
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
48
|
+
var runtimeTarget = _step.value;
|
|
49
|
+
if (runtimeTarget.kind === "render") {
|
|
50
|
+
controlledTargets[runtimeTarget.targetName] = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
_iterator.e(err);
|
|
55
|
+
} finally {
|
|
56
|
+
_iterator.f();
|
|
57
|
+
}
|
|
58
|
+
var hasRuntime = compiled.runtimeTargets.length > 0;
|
|
59
|
+
var layoutFunctions = (_compiled$layoutFunct = compiled.layoutFunctions) !== null && _compiled$layoutFunct !== void 0 ? _compiled$layoutFunct : [];
|
|
60
|
+
tmodel.childRuntimePrograms[index] = compiled.runtimeTargets;
|
|
61
|
+
tmodel.childRuntimeStates[index] = {
|
|
62
|
+
controlledTargets: controlledTargets,
|
|
63
|
+
ownerTargetName: targetName,
|
|
64
|
+
programIndex: 0,
|
|
65
|
+
activationCount: 0,
|
|
66
|
+
layoutFunctions: layoutFunctions,
|
|
67
|
+
layoutFunctionsResolved: layoutFunctions.length === 0,
|
|
68
|
+
executions: {},
|
|
69
|
+
startRequested: false,
|
|
70
|
+
renderReady: false,
|
|
71
|
+
started: false,
|
|
72
|
+
done: !hasRuntime,
|
|
73
|
+
pendingCompletion: hasRuntime
|
|
74
|
+
};
|
|
75
|
+
if (hasRuntime) {
|
|
76
|
+
tmodel.pendingGpuChildRuntimeCounts[targetName] = (tmodel.pendingGpuChildRuntimeCounts[targetName] || 0) + 1;
|
|
77
|
+
}
|
|
78
|
+
return hasRuntime;
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "hasPending",
|
|
82
|
+
value: function hasPending(key) {
|
|
83
|
+
var targetName = TargetUtil.getTargetName(key);
|
|
84
|
+
return (this.tmodel.pendingGpuChildRuntimeCounts[targetName] || 0) > 0;
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "prepareRestore",
|
|
88
|
+
value: function prepareRestore() {
|
|
89
|
+
this.restoredMainIndexes = [];
|
|
90
|
+
this.restoredActivationSequences = [];
|
|
91
|
+
for (var index = 0; index < this.tmodel.childRuntimeStates.length; index++) {
|
|
92
|
+
var _state$executions, _state$activationCoun;
|
|
93
|
+
var state = this.tmodel.childRuntimeStates[index];
|
|
94
|
+
if (!state) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
(_state$executions = state.executions) !== null && _state$executions !== void 0 ? _state$executions : state.executions = {};
|
|
98
|
+
(_state$activationCoun = state.activationCount) !== null && _state$activationCoun !== void 0 ? _state$activationCoun : state.activationCount = 0;
|
|
99
|
+
var executions = Object.values(state.executions);
|
|
100
|
+
var mainExecutions = executions.filter(function (execution) {
|
|
101
|
+
return execution.sequenceId === "main";
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
* A main program may be between targets and therefore have no current
|
|
106
|
+
* execution record, so state.started still matters for the main sequence.
|
|
107
|
+
*/
|
|
108
|
+
if (!state.done && (state.started || mainExecutions.length)) {
|
|
109
|
+
this.restoredMainIndexes.push(index);
|
|
110
|
+
}
|
|
111
|
+
var activationSequenceIds = _toConsumableArray(new Set(executions.map(function (execution) {
|
|
112
|
+
return execution.sequenceId;
|
|
113
|
+
}).filter(function (sequenceId) {
|
|
114
|
+
return sequenceId === null || sequenceId === void 0 ? void 0 : sequenceId.startsWith("activation:");
|
|
115
|
+
})));
|
|
116
|
+
var _iterator2 = _createForOfIteratorHelper(activationSequenceIds),
|
|
117
|
+
_step2;
|
|
118
|
+
try {
|
|
119
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
120
|
+
var sequenceId = _step2.value;
|
|
121
|
+
this.restoredActivationSequences.push({
|
|
122
|
+
index: index,
|
|
123
|
+
sequenceId: sequenceId
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/*
|
|
128
|
+
* Promise/timer state belonged to the old ParticleRuntime.
|
|
129
|
+
*/
|
|
130
|
+
} catch (err) {
|
|
131
|
+
_iterator2.e(err);
|
|
132
|
+
} finally {
|
|
133
|
+
_iterator2.f();
|
|
134
|
+
}
|
|
135
|
+
state.started = false;
|
|
136
|
+
state.renderReady = false;
|
|
137
|
+
state.startRequested = false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "resumeRestored",
|
|
142
|
+
value: function resumeRestored() {
|
|
143
|
+
var mainIndexes = this.restoredMainIndexes.splice(0);
|
|
144
|
+
var activationSequences = this.restoredActivationSequences.splice(0);
|
|
145
|
+
var _iterator3 = _createForOfIteratorHelper(mainIndexes),
|
|
146
|
+
_step3;
|
|
147
|
+
try {
|
|
148
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
149
|
+
var index = _step3.value;
|
|
150
|
+
this.resumeMainProgram(index);
|
|
151
|
+
}
|
|
152
|
+
} catch (err) {
|
|
153
|
+
_iterator3.e(err);
|
|
154
|
+
} finally {
|
|
155
|
+
_iterator3.f();
|
|
156
|
+
}
|
|
157
|
+
var _iterator4 = _createForOfIteratorHelper(activationSequences),
|
|
158
|
+
_step4;
|
|
159
|
+
try {
|
|
160
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
161
|
+
var _step4$value = _step4.value,
|
|
162
|
+
_index = _step4$value.index,
|
|
163
|
+
sequenceId = _step4$value.sequenceId;
|
|
164
|
+
this.resumeActivationSequence(_index, sequenceId);
|
|
165
|
+
}
|
|
166
|
+
} catch (err) {
|
|
167
|
+
_iterator4.e(err);
|
|
168
|
+
} finally {
|
|
169
|
+
_iterator4.f();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}, {
|
|
173
|
+
key: "resumeActivationSequence",
|
|
174
|
+
value: function resumeActivationSequence(index, sequenceId) {
|
|
175
|
+
var _this$activeTargets,
|
|
176
|
+
_this$activeTargets$i,
|
|
177
|
+
_this = this;
|
|
178
|
+
var state = this.tmodel.childRuntimeStates[index];
|
|
179
|
+
if (!state) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
var executions = Object.values(state.executions || {}).filter(function (execution) {
|
|
183
|
+
return execution.sequenceId === sequenceId;
|
|
184
|
+
});
|
|
185
|
+
if (!executions.length) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
var currentTargetIndex = Math.max.apply(Math, _toConsumableArray(executions.map(function (execution) {
|
|
189
|
+
return execution.targetIndex;
|
|
190
|
+
})));
|
|
191
|
+
var activationId = sequenceId.startsWith("activation:") ? sequenceId.slice("activation:".length) : sequenceId;
|
|
192
|
+
var activeTargets = (_this$activeTargets$i = (_this$activeTargets = this.activeTargets)[index]) !== null && _this$activeTargets$i !== void 0 ? _this$activeTargets$i : _this$activeTargets[index] = {};
|
|
193
|
+
var promise = Promise.all(executions.map(function (execution) {
|
|
194
|
+
return _this.resumeExecution(index, execution);
|
|
195
|
+
})).then(function () {
|
|
196
|
+
return _this.continueActivatedSequence(index, currentTargetIndex + 1, sequenceId);
|
|
197
|
+
}).catch(function (error) {
|
|
198
|
+
console.error(error);
|
|
199
|
+
}).finally(function () {
|
|
200
|
+
delete activeTargets[activationId];
|
|
201
|
+
});
|
|
202
|
+
activeTargets[activationId] = promise;
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
}, {
|
|
206
|
+
key: "continueActivatedSequence",
|
|
207
|
+
value: function () {
|
|
208
|
+
var _continueActivatedSequence = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(index, programIndex, sequenceId) {
|
|
209
|
+
var program, runtimeTarget;
|
|
210
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
211
|
+
while (1) switch (_context.prev = _context.next) {
|
|
212
|
+
case 0:
|
|
213
|
+
program = this.tmodel.childRuntimePrograms[index];
|
|
214
|
+
if (program) {
|
|
215
|
+
_context.next = 3;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
return _context.abrupt("return");
|
|
219
|
+
case 3:
|
|
220
|
+
if (!(programIndex < program.length)) {
|
|
221
|
+
_context.next = 12;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
runtimeTarget = program[programIndex];
|
|
225
|
+
if (!(runtimeTarget.mode !== "deferred")) {
|
|
226
|
+
_context.next = 7;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
return _context.abrupt("break", 12);
|
|
230
|
+
case 7:
|
|
231
|
+
_context.next = 9;
|
|
232
|
+
return this.runTarget(index, runtimeTarget, programIndex, sequenceId);
|
|
233
|
+
case 9:
|
|
234
|
+
programIndex++;
|
|
235
|
+
_context.next = 3;
|
|
236
|
+
break;
|
|
237
|
+
case 12:
|
|
238
|
+
case "end":
|
|
239
|
+
return _context.stop();
|
|
240
|
+
}
|
|
241
|
+
}, _callee, this);
|
|
242
|
+
}));
|
|
243
|
+
function continueActivatedSequence(_x, _x2, _x3) {
|
|
244
|
+
return _continueActivatedSequence.apply(this, arguments);
|
|
245
|
+
}
|
|
246
|
+
return continueActivatedSequence;
|
|
247
|
+
}()
|
|
248
|
+
}, {
|
|
249
|
+
key: "resumeMainProgram",
|
|
250
|
+
value: function resumeMainProgram(index) {
|
|
251
|
+
var _this2 = this;
|
|
252
|
+
var state = this.tmodel.childRuntimeStates[index];
|
|
253
|
+
if (!state || state.done || state.started) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
state.started = true;
|
|
257
|
+
var runningExecutions = Object.values(state.executions || {}).filter(function (execution) {
|
|
258
|
+
return execution.sequenceId === "main";
|
|
259
|
+
});
|
|
260
|
+
Promise.all(runningExecutions.map(function (execution) {
|
|
261
|
+
return _this2.resumeExecution(index, execution);
|
|
262
|
+
})).then(function () {
|
|
263
|
+
return _this2.runProgram(index);
|
|
264
|
+
}).catch(function (error) {
|
|
265
|
+
console.error(error);
|
|
266
|
+
}).finally(function () {
|
|
267
|
+
_this2.complete(index);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}, {
|
|
271
|
+
key: "resumeExecution",
|
|
272
|
+
value: function resumeExecution(index, execution) {
|
|
273
|
+
var program = this.tmodel.childRuntimePrograms[index];
|
|
274
|
+
var runtimeTarget = program === null || program === void 0 ? void 0 : program[execution.targetIndex];
|
|
275
|
+
if (!runtimeTarget) {
|
|
276
|
+
return Promise.resolve();
|
|
277
|
+
}
|
|
278
|
+
if (execution.kind === "interval") {
|
|
279
|
+
return this.runIntervalTarget(index, runtimeTarget, execution.targetIndex, execution.sequenceId);
|
|
280
|
+
}
|
|
281
|
+
if (execution.kind === "render") {
|
|
282
|
+
return this.runRenderTarget(index, runtimeTarget, execution.targetIndex, execution.sequenceId);
|
|
283
|
+
}
|
|
284
|
+
return Promise.resolve();
|
|
285
|
+
}
|
|
286
|
+
}, {
|
|
287
|
+
key: "isControlled",
|
|
288
|
+
value: function isControlled(index, key) {
|
|
289
|
+
var _state$controlledTarg;
|
|
290
|
+
var state = this.tmodel.childRuntimeStates[index];
|
|
291
|
+
if (!state) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
var targetName = ParticleUtil.getGpuRenderTargetName(key);
|
|
295
|
+
return ((_state$controlledTarg = state.controlledTargets) === null || _state$controlledTarg === void 0 ? void 0 : _state$controlledTarg[targetName]) === true;
|
|
296
|
+
}
|
|
297
|
+
}, {
|
|
298
|
+
key: "complete",
|
|
299
|
+
value: function complete(index) {
|
|
300
|
+
var tmodel = this.tmodel;
|
|
301
|
+
var state = tmodel.childRuntimeStates[index];
|
|
302
|
+
if (!state || state.done) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
state.done = true;
|
|
306
|
+
state.started = false;
|
|
307
|
+
if (!state.pendingCompletion) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
state.pendingCompletion = false;
|
|
311
|
+
var targetName = state.ownerTargetName;
|
|
312
|
+
var count = Math.max(0, (tmodel.pendingGpuChildRuntimeCounts[targetName] || 0) - 1);
|
|
313
|
+
if (count > 0) {
|
|
314
|
+
tmodel.pendingGpuChildRuntimeCounts[targetName] = count;
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
delete tmodel.pendingGpuChildRuntimeCounts[targetName];
|
|
318
|
+
getRunScheduler().schedule(1, "gpuChildRuntimeComplete-".concat(tmodel.oid));
|
|
319
|
+
}
|
|
320
|
+
}, {
|
|
321
|
+
key: "resolveLayoutFunctions",
|
|
322
|
+
value: function resolveLayoutFunctions() {
|
|
323
|
+
var tmodel = this.tmodel;
|
|
324
|
+
var changed = false;
|
|
325
|
+
for (var index = 0; index < tmodel.childRuntimeStates.length; index++) {
|
|
326
|
+
var _state$layoutFunction;
|
|
327
|
+
var state = tmodel.childRuntimeStates[index];
|
|
328
|
+
if (!state || state.layoutFunctionsResolved || !((_state$layoutFunction = state.layoutFunctions) !== null && _state$layoutFunction !== void 0 && _state$layoutFunction.length)) {
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
var child = tmodel.childHandles[index];
|
|
332
|
+
var childChanged = false;
|
|
333
|
+
var _iterator5 = _createForOfIteratorHelper(state.layoutFunctions),
|
|
334
|
+
_step5;
|
|
335
|
+
try {
|
|
336
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
337
|
+
var entry = _step5.value;
|
|
338
|
+
var resolved = ParticleUtil.resolveGpuRenderValue(entry.value, child);
|
|
339
|
+
var value = ParticleUtil.getGpuInitialRenderValue(resolved);
|
|
340
|
+
if (tmodel.getChildValue(index, entry.targetName) === value) {
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
child.val(entry.targetName, value);
|
|
344
|
+
childChanged = true;
|
|
345
|
+
changed = true;
|
|
346
|
+
}
|
|
347
|
+
} catch (err) {
|
|
348
|
+
_iterator5.e(err);
|
|
349
|
+
} finally {
|
|
350
|
+
_iterator5.f();
|
|
351
|
+
}
|
|
352
|
+
if (!childChanged) {
|
|
353
|
+
state.layoutFunctionsResolved = true;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return changed;
|
|
357
|
+
}
|
|
358
|
+
}, {
|
|
359
|
+
key: "queueStart",
|
|
360
|
+
value: function queueStart(index) {
|
|
361
|
+
var state = this.tmodel.childRuntimeStates[index];
|
|
362
|
+
if (!state || state.done || state.started) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
state.startRequested = true;
|
|
366
|
+
this.startReady();
|
|
367
|
+
}
|
|
368
|
+
}, {
|
|
369
|
+
key: "markRenderReady",
|
|
370
|
+
value: function markRenderReady(indexes) {
|
|
371
|
+
var _iterator6 = _createForOfIteratorHelper(indexes),
|
|
372
|
+
_step6;
|
|
373
|
+
try {
|
|
374
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
375
|
+
var index = _step6.value;
|
|
376
|
+
var state = this.tmodel.childRuntimeStates[index];
|
|
377
|
+
if (state) {
|
|
378
|
+
state.renderReady = true;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
} catch (err) {
|
|
382
|
+
_iterator6.e(err);
|
|
383
|
+
} finally {
|
|
384
|
+
_iterator6.f();
|
|
385
|
+
}
|
|
386
|
+
this.startReady();
|
|
387
|
+
}
|
|
388
|
+
}, {
|
|
389
|
+
key: "markPendingRenderReady",
|
|
390
|
+
value: function markPendingRenderReady() {
|
|
391
|
+
var _iterator7 = _createForOfIteratorHelper(this.tmodel.childRuntimeStates),
|
|
392
|
+
_step7;
|
|
393
|
+
try {
|
|
394
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
395
|
+
var state = _step7.value;
|
|
396
|
+
if (state !== null && state !== void 0 && state.startRequested && !state.started && !state.done) {
|
|
397
|
+
state.renderReady = true;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
} catch (err) {
|
|
401
|
+
_iterator7.e(err);
|
|
402
|
+
} finally {
|
|
403
|
+
_iterator7.f();
|
|
404
|
+
}
|
|
405
|
+
this.startReady();
|
|
406
|
+
}
|
|
407
|
+
}, {
|
|
408
|
+
key: "startReady",
|
|
409
|
+
value: function startReady() {
|
|
410
|
+
var tmodel = this.tmodel;
|
|
411
|
+
if (!tmodel.hasDom() || tmodel.completeLayoutEpoch !== tmodel.layoutEpoch) {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
var started = false;
|
|
415
|
+
for (var index = 0; index < tmodel.childRuntimeStates.length; index++) {
|
|
416
|
+
var state = tmodel.childRuntimeStates[index];
|
|
417
|
+
if (!state || !state.startRequested || !state.renderReady || state.started || state.done) {
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
state.startRequested = false;
|
|
421
|
+
this.start(index);
|
|
422
|
+
started = true;
|
|
423
|
+
}
|
|
424
|
+
return started;
|
|
425
|
+
}
|
|
426
|
+
}, {
|
|
427
|
+
key: "start",
|
|
428
|
+
value: function start(index) {
|
|
429
|
+
var _this3 = this;
|
|
430
|
+
var state = this.tmodel.childRuntimeStates[index];
|
|
431
|
+
var program = this.tmodel.childRuntimePrograms[index];
|
|
432
|
+
if (!state || !(program !== null && program !== void 0 && program.length) || state.started || state.done) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
state.started = true;
|
|
436
|
+
state.programIndex = 0;
|
|
437
|
+
Promise.resolve(this.runProgram(index)).catch(function (error) {
|
|
438
|
+
console.error(error);
|
|
439
|
+
}).finally(function () {
|
|
440
|
+
_this3.complete(index);
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
}, {
|
|
444
|
+
key: "runProgram",
|
|
445
|
+
value: function () {
|
|
446
|
+
var _runProgram = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(index) {
|
|
447
|
+
var state, program, immediate, targetIndex, _targetIndex;
|
|
448
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
449
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
450
|
+
case 0:
|
|
451
|
+
state = this.tmodel.childRuntimeStates[index];
|
|
452
|
+
program = this.tmodel.childRuntimePrograms[index];
|
|
453
|
+
if (!(!state || !program)) {
|
|
454
|
+
_context2.next = 4;
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
return _context2.abrupt("return");
|
|
458
|
+
case 4:
|
|
459
|
+
immediate = [];
|
|
460
|
+
while (state.programIndex < program.length && program[state.programIndex].mode === "immediate") {
|
|
461
|
+
targetIndex = state.programIndex++;
|
|
462
|
+
immediate.push(this.runTarget(index, program[targetIndex], targetIndex, "main"));
|
|
463
|
+
}
|
|
464
|
+
if (!immediate.length) {
|
|
465
|
+
_context2.next = 9;
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
_context2.next = 9;
|
|
469
|
+
return Promise.all(immediate);
|
|
470
|
+
case 9:
|
|
471
|
+
if (!(state.programIndex < program.length)) {
|
|
472
|
+
_context2.next = 15;
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
_targetIndex = state.programIndex++;
|
|
476
|
+
_context2.next = 13;
|
|
477
|
+
return this.runTarget(index, program[_targetIndex], _targetIndex, "main");
|
|
478
|
+
case 13:
|
|
479
|
+
_context2.next = 9;
|
|
480
|
+
break;
|
|
481
|
+
case 15:
|
|
482
|
+
case "end":
|
|
483
|
+
return _context2.stop();
|
|
484
|
+
}
|
|
485
|
+
}, _callee2, this);
|
|
486
|
+
}));
|
|
487
|
+
function runProgram(_x4) {
|
|
488
|
+
return _runProgram.apply(this, arguments);
|
|
489
|
+
}
|
|
490
|
+
return runProgram;
|
|
491
|
+
}()
|
|
492
|
+
}, {
|
|
493
|
+
key: "runTarget",
|
|
494
|
+
value: function () {
|
|
495
|
+
var _runTarget = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(index, runtimeTarget, targetIndex) {
|
|
496
|
+
var sequenceId,
|
|
497
|
+
child,
|
|
498
|
+
value,
|
|
499
|
+
result,
|
|
500
|
+
_args3 = arguments;
|
|
501
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
502
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
503
|
+
case 0:
|
|
504
|
+
sequenceId = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : "main";
|
|
505
|
+
child = this.tmodel.childHandles[index];
|
|
506
|
+
if (child) {
|
|
507
|
+
_context3.next = 4;
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
return _context3.abrupt("return");
|
|
511
|
+
case 4:
|
|
512
|
+
if (!(runtimeTarget.kind === "interval")) {
|
|
513
|
+
_context3.next = 8;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
_context3.next = 7;
|
|
517
|
+
return this.runIntervalTarget(index, runtimeTarget, targetIndex, sequenceId);
|
|
518
|
+
case 7:
|
|
519
|
+
return _context3.abrupt("return");
|
|
520
|
+
case 8:
|
|
521
|
+
if (!(runtimeTarget.kind === "render")) {
|
|
522
|
+
_context3.next = 12;
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
_context3.next = 11;
|
|
526
|
+
return this.runRenderTarget(index, runtimeTarget, targetIndex, sequenceId);
|
|
527
|
+
case 11:
|
|
528
|
+
return _context3.abrupt("return");
|
|
529
|
+
case 12:
|
|
530
|
+
value = runtimeTarget.target.value;
|
|
531
|
+
if (!(typeof value === "function")) {
|
|
532
|
+
_context3.next = 18;
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
result = value.call(child);
|
|
536
|
+
if (!(result !== null && result !== void 0 && result.then)) {
|
|
537
|
+
_context3.next = 18;
|
|
538
|
+
break;
|
|
539
|
+
}
|
|
540
|
+
_context3.next = 18;
|
|
541
|
+
return result;
|
|
542
|
+
case 18:
|
|
543
|
+
case "end":
|
|
544
|
+
return _context3.stop();
|
|
545
|
+
}
|
|
546
|
+
}, _callee3, this);
|
|
547
|
+
}));
|
|
548
|
+
function runTarget(_x5, _x6, _x7) {
|
|
549
|
+
return _runTarget.apply(this, arguments);
|
|
550
|
+
}
|
|
551
|
+
return runTarget;
|
|
552
|
+
}()
|
|
553
|
+
}, {
|
|
554
|
+
key: "getExecutionId",
|
|
555
|
+
value: function getExecutionId(sequenceId, targetIndex) {
|
|
556
|
+
return "".concat(sequenceId, ":").concat(targetIndex);
|
|
557
|
+
}
|
|
558
|
+
}, {
|
|
559
|
+
key: "getExecution",
|
|
560
|
+
value: function getExecution(index, sequenceId, targetIndex) {
|
|
561
|
+
var _state$executions2;
|
|
562
|
+
var state = this.tmodel.childRuntimeStates[index];
|
|
563
|
+
return state === null || state === void 0 || (_state$executions2 = state.executions) === null || _state$executions2 === void 0 ? void 0 : _state$executions2[this.getExecutionId(sequenceId, targetIndex)];
|
|
564
|
+
}
|
|
565
|
+
}, {
|
|
566
|
+
key: "setExecution",
|
|
567
|
+
value: function setExecution(index, sequenceId, targetIndex, execution) {
|
|
568
|
+
var _state$executions3;
|
|
569
|
+
var state = this.tmodel.childRuntimeStates[index];
|
|
570
|
+
if (!state) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
(_state$executions3 = state.executions) !== null && _state$executions3 !== void 0 ? _state$executions3 : state.executions = {};
|
|
574
|
+
state.executions[this.getExecutionId(sequenceId, targetIndex)] = execution;
|
|
575
|
+
}
|
|
576
|
+
}, {
|
|
577
|
+
key: "clearExecution",
|
|
578
|
+
value: function clearExecution(index, sequenceId, targetIndex) {
|
|
579
|
+
var state = this.tmodel.childRuntimeStates[index];
|
|
580
|
+
if (!(state !== null && state !== void 0 && state.executions)) {
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
delete state.executions[this.getExecutionId(sequenceId, targetIndex)];
|
|
584
|
+
}
|
|
585
|
+
}, {
|
|
586
|
+
key: "runIntervalTarget",
|
|
587
|
+
value: function () {
|
|
588
|
+
var _runIntervalTarget = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(index, runtimeTarget, targetIndex, sequenceId) {
|
|
589
|
+
var child, execution;
|
|
590
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
591
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
592
|
+
case 0:
|
|
593
|
+
child = this.tmodel.childHandles[index];
|
|
594
|
+
execution = this.getExecution(index, sequenceId, targetIndex);
|
|
595
|
+
if (!execution) {
|
|
596
|
+
execution = {
|
|
597
|
+
sequenceId: sequenceId,
|
|
598
|
+
targetIndex: targetIndex,
|
|
599
|
+
kind: "interval",
|
|
600
|
+
interval: Math.max(0, Number(this.resolveOption(runtimeTarget.target.interval, child)) || 0),
|
|
601
|
+
waiting: false,
|
|
602
|
+
startTime: 0
|
|
603
|
+
};
|
|
604
|
+
this.setExecution(index, sequenceId, targetIndex, execution);
|
|
605
|
+
}
|
|
606
|
+
_context4.next = 5;
|
|
607
|
+
return this.waitForExecution(execution);
|
|
608
|
+
case 5:
|
|
609
|
+
this.clearExecution(index, sequenceId, targetIndex);
|
|
610
|
+
case 6:
|
|
611
|
+
case "end":
|
|
612
|
+
return _context4.stop();
|
|
613
|
+
}
|
|
614
|
+
}, _callee4, this);
|
|
615
|
+
}));
|
|
616
|
+
function runIntervalTarget(_x8, _x9, _x10, _x11) {
|
|
617
|
+
return _runIntervalTarget.apply(this, arguments);
|
|
618
|
+
}
|
|
619
|
+
return runIntervalTarget;
|
|
620
|
+
}()
|
|
621
|
+
}, {
|
|
622
|
+
key: "waitForExecution",
|
|
623
|
+
value: function () {
|
|
624
|
+
var _waitForExecution = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(execution) {
|
|
625
|
+
var delay;
|
|
626
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
627
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
628
|
+
case 0:
|
|
629
|
+
delay = execution.interval;
|
|
630
|
+
if (execution.waiting && execution.startTime > 0) {
|
|
631
|
+
delay = Math.max(0, execution.interval - (TUtil.now() - execution.startTime));
|
|
632
|
+
} else {
|
|
633
|
+
execution.waiting = true;
|
|
634
|
+
execution.startTime = TUtil.now();
|
|
635
|
+
}
|
|
636
|
+
if (!(delay > 0)) {
|
|
637
|
+
_context5.next = 5;
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
640
|
+
_context5.next = 5;
|
|
641
|
+
return this.wait(delay);
|
|
642
|
+
case 5:
|
|
643
|
+
execution.waiting = false;
|
|
644
|
+
execution.startTime = 0;
|
|
645
|
+
case 7:
|
|
646
|
+
case "end":
|
|
647
|
+
return _context5.stop();
|
|
648
|
+
}
|
|
649
|
+
}, _callee5, this);
|
|
650
|
+
}));
|
|
651
|
+
function waitForExecution(_x12) {
|
|
652
|
+
return _waitForExecution.apply(this, arguments);
|
|
653
|
+
}
|
|
654
|
+
return waitForExecution;
|
|
655
|
+
}()
|
|
656
|
+
}, {
|
|
657
|
+
key: "runRenderTarget",
|
|
658
|
+
value: function () {
|
|
659
|
+
var _runRenderTarget = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(index, runtimeTarget, targetIndex) {
|
|
660
|
+
var sequenceId,
|
|
661
|
+
tmodel,
|
|
662
|
+
child,
|
|
663
|
+
target,
|
|
664
|
+
targetName,
|
|
665
|
+
execution,
|
|
666
|
+
value,
|
|
667
|
+
isValueList,
|
|
668
|
+
values,
|
|
669
|
+
_args6 = arguments;
|
|
670
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
671
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
672
|
+
case 0:
|
|
673
|
+
sequenceId = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : "main";
|
|
674
|
+
tmodel = this.tmodel;
|
|
675
|
+
child = tmodel.childHandles[index];
|
|
676
|
+
target = runtimeTarget.target;
|
|
677
|
+
targetName = runtimeTarget.targetName;
|
|
678
|
+
execution = this.getExecution(index, sequenceId, targetIndex);
|
|
679
|
+
if (!execution) {
|
|
680
|
+
value = target.value;
|
|
681
|
+
if (typeof value === "function") {
|
|
682
|
+
value = value.call(child);
|
|
683
|
+
}
|
|
684
|
+
isValueList = Array.isArray(value);
|
|
685
|
+
values = isValueList ? value : [tmodel.getChildValue(index, targetName), value];
|
|
686
|
+
execution = {
|
|
687
|
+
sequenceId: sequenceId,
|
|
688
|
+
targetIndex: targetIndex,
|
|
689
|
+
kind: "render",
|
|
690
|
+
targetName: targetName,
|
|
691
|
+
values: values,
|
|
692
|
+
isValueList: isValueList,
|
|
693
|
+
segmentIndex: 0,
|
|
694
|
+
segmentReady: false,
|
|
695
|
+
step: 0,
|
|
696
|
+
waiting: false,
|
|
697
|
+
startTime: 0
|
|
698
|
+
};
|
|
699
|
+
this.setExecution(index, sequenceId, targetIndex, execution);
|
|
700
|
+
}
|
|
701
|
+
case 7:
|
|
702
|
+
if (!(execution.segmentIndex < execution.values.length - 1)) {
|
|
703
|
+
_context6.next = 18;
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
if (!execution.segmentReady) {
|
|
707
|
+
this.prepareRenderSegment(execution, runtimeTarget, child);
|
|
708
|
+
}
|
|
709
|
+
_context6.next = 11;
|
|
710
|
+
return this.animateExecution(index, execution);
|
|
711
|
+
case 11:
|
|
712
|
+
execution.segmentIndex++;
|
|
713
|
+
execution.segmentReady = false;
|
|
714
|
+
execution.step = 0;
|
|
715
|
+
execution.waiting = false;
|
|
716
|
+
execution.startTime = 0;
|
|
717
|
+
_context6.next = 7;
|
|
718
|
+
break;
|
|
719
|
+
case 18:
|
|
720
|
+
this.clearExecution(index, sequenceId, targetIndex);
|
|
721
|
+
case 19:
|
|
722
|
+
case "end":
|
|
723
|
+
return _context6.stop();
|
|
724
|
+
}
|
|
725
|
+
}, _callee6, this);
|
|
726
|
+
}));
|
|
727
|
+
function runRenderTarget(_x13, _x14, _x15) {
|
|
728
|
+
return _runRenderTarget.apply(this, arguments);
|
|
729
|
+
}
|
|
730
|
+
return runRenderTarget;
|
|
731
|
+
}()
|
|
732
|
+
}, {
|
|
733
|
+
key: "prepareRenderSegment",
|
|
734
|
+
value: function prepareRenderSegment(execution, runtimeTarget, child) {
|
|
735
|
+
var target = runtimeTarget.target;
|
|
736
|
+
var segmentIndex = execution.segmentIndex;
|
|
737
|
+
execution.from = execution.values[segmentIndex];
|
|
738
|
+
execution.to = execution.values[segmentIndex + 1];
|
|
739
|
+
execution.steps = Math.max(0, Number(this.resolveOption(target.steps, child, segmentIndex)) || 0);
|
|
740
|
+
execution.interval = TUtil.isDefined(target.interval) ? Math.max(0, Number(this.resolveOption(target.interval, child, segmentIndex)) || 0) : execution.isValueList && execution.steps > 0 ? 8 : 0;
|
|
741
|
+
execution.easingName = this.resolveOption(target.easing, child, segmentIndex);
|
|
742
|
+
execution.segmentReady = true;
|
|
743
|
+
}
|
|
744
|
+
}, {
|
|
745
|
+
key: "resolveOption",
|
|
746
|
+
value: function resolveOption(value, child) {
|
|
747
|
+
var segmentIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
748
|
+
if (typeof value === "function") {
|
|
749
|
+
return value.call(child, segmentIndex);
|
|
750
|
+
}
|
|
751
|
+
if (Array.isArray(value)) {
|
|
752
|
+
return value.length ? value[segmentIndex % value.length] : undefined;
|
|
753
|
+
}
|
|
754
|
+
return value;
|
|
755
|
+
}
|
|
756
|
+
}, {
|
|
757
|
+
key: "animateExecution",
|
|
758
|
+
value: function () {
|
|
759
|
+
var _animateExecution = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(index, execution) {
|
|
760
|
+
var tmodel, easing, step, progress, easedProgress, value;
|
|
761
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
762
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
763
|
+
case 0:
|
|
764
|
+
tmodel = this.tmodel;
|
|
765
|
+
if (!(execution.steps <= 0)) {
|
|
766
|
+
_context7.next = 5;
|
|
767
|
+
break;
|
|
768
|
+
}
|
|
769
|
+
tmodel.setChildValue(index, execution.targetName, execution.to);
|
|
770
|
+
tmodel.requestParticleRender();
|
|
771
|
+
return _context7.abrupt("return");
|
|
772
|
+
case 5:
|
|
773
|
+
easing = execution.easingName ? Easing.easingFunction(execution.easingName) : undefined;
|
|
774
|
+
step = execution.step + 1;
|
|
775
|
+
case 7:
|
|
776
|
+
if (!(step <= execution.steps)) {
|
|
777
|
+
_context7.next = 20;
|
|
778
|
+
break;
|
|
779
|
+
}
|
|
780
|
+
if (!(execution.interval > 0)) {
|
|
781
|
+
_context7.next = 11;
|
|
782
|
+
break;
|
|
783
|
+
}
|
|
784
|
+
_context7.next = 11;
|
|
785
|
+
return this.waitForExecution(execution);
|
|
786
|
+
case 11:
|
|
787
|
+
progress = step / execution.steps;
|
|
788
|
+
easedProgress = easing ? easing(progress) : progress;
|
|
789
|
+
value = TModelUtil.morph(execution.targetName, execution.from, execution.to, easedProgress);
|
|
790
|
+
tmodel.setChildValue(index, execution.targetName, value);
|
|
791
|
+
execution.step = step;
|
|
792
|
+
tmodel.requestParticleRender();
|
|
793
|
+
case 17:
|
|
794
|
+
step++;
|
|
795
|
+
_context7.next = 7;
|
|
796
|
+
break;
|
|
797
|
+
case 20:
|
|
798
|
+
case "end":
|
|
799
|
+
return _context7.stop();
|
|
800
|
+
}
|
|
801
|
+
}, _callee7, this);
|
|
802
|
+
}));
|
|
803
|
+
function animateExecution(_x16, _x17) {
|
|
804
|
+
return _animateExecution.apply(this, arguments);
|
|
805
|
+
}
|
|
806
|
+
return animateExecution;
|
|
807
|
+
}()
|
|
808
|
+
}, {
|
|
809
|
+
key: "wait",
|
|
810
|
+
value: function wait(interval) {
|
|
811
|
+
return new Promise(function (resolve) {
|
|
812
|
+
return setTimeout(resolve, Math.max(0, Number(interval) || 0));
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
}, {
|
|
816
|
+
key: "findTargetIndex",
|
|
817
|
+
value: function findTargetIndex(index, key) {
|
|
818
|
+
var program = this.tmodel.childRuntimePrograms[index];
|
|
819
|
+
if (!program) {
|
|
820
|
+
return -1;
|
|
821
|
+
}
|
|
822
|
+
var cleanKey = TargetUtil.getTargetName(key);
|
|
823
|
+
var exactIndex = program.findIndex(function (target) {
|
|
824
|
+
return target.key === key;
|
|
825
|
+
});
|
|
826
|
+
if (exactIndex >= 0) {
|
|
827
|
+
return exactIndex;
|
|
828
|
+
}
|
|
829
|
+
return program.findIndex(function (target) {
|
|
830
|
+
return target.targetName === cleanKey && target.mode === "immediate";
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
}, {
|
|
834
|
+
key: "runActivatedSequence",
|
|
835
|
+
value: function () {
|
|
836
|
+
var _runActivatedSequence = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(index, startIndex, sequenceId) {
|
|
837
|
+
var program;
|
|
838
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
839
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
840
|
+
case 0:
|
|
841
|
+
program = this.tmodel.childRuntimePrograms[index];
|
|
842
|
+
if (!(!program || startIndex < 0 || startIndex >= program.length)) {
|
|
843
|
+
_context8.next = 3;
|
|
844
|
+
break;
|
|
845
|
+
}
|
|
846
|
+
return _context8.abrupt("return");
|
|
847
|
+
case 3:
|
|
848
|
+
_context8.next = 5;
|
|
849
|
+
return this.runTarget(index, program[startIndex], startIndex, sequenceId);
|
|
850
|
+
case 5:
|
|
851
|
+
_context8.next = 7;
|
|
852
|
+
return this.continueActivatedSequence(index, startIndex + 1, sequenceId);
|
|
853
|
+
case 7:
|
|
854
|
+
case "end":
|
|
855
|
+
return _context8.stop();
|
|
856
|
+
}
|
|
857
|
+
}, _callee8, this);
|
|
858
|
+
}));
|
|
859
|
+
function runActivatedSequence(_x18, _x19, _x20) {
|
|
860
|
+
return _runActivatedSequence.apply(this, arguments);
|
|
861
|
+
}
|
|
862
|
+
return runActivatedSequence;
|
|
863
|
+
}()
|
|
864
|
+
}, {
|
|
865
|
+
key: "activateTarget",
|
|
866
|
+
value: function activateTarget(index, key) {
|
|
867
|
+
var _this$activeTargets2,
|
|
868
|
+
_this$activeTargets2$,
|
|
869
|
+
_this4 = this;
|
|
870
|
+
var state = this.tmodel.childRuntimeStates[index];
|
|
871
|
+
var program = this.tmodel.childRuntimePrograms[index];
|
|
872
|
+
if (!state || !program) {
|
|
873
|
+
return false;
|
|
874
|
+
}
|
|
875
|
+
var startIndex = this.findTargetIndex(index, key);
|
|
876
|
+
if (startIndex < 0) {
|
|
877
|
+
throw new Error("GPU child target \"".concat(key, "\" cannot be activated because it is not in the child runtime program."));
|
|
878
|
+
}
|
|
879
|
+
var runtimeTarget = program[startIndex];
|
|
880
|
+
if (runtimeTarget.kind !== "render" && runtimeTarget.kind !== "runtime") {
|
|
881
|
+
throw new Error("GPU child target \"".concat(key, "\" cannot be activated."));
|
|
882
|
+
}
|
|
883
|
+
var activationId = "".concat(runtimeTarget.key, "-").concat(++state.activationCount);
|
|
884
|
+
var sequenceId = "activation:".concat(activationId);
|
|
885
|
+
var activeTargets = (_this$activeTargets2$ = (_this$activeTargets2 = this.activeTargets)[index]) !== null && _this$activeTargets2$ !== void 0 ? _this$activeTargets2$ : _this$activeTargets2[index] = {};
|
|
886
|
+
var promise = Promise.resolve().then(function () {
|
|
887
|
+
return _this4.runActivatedSequence(index, startIndex, sequenceId);
|
|
888
|
+
}).catch(function (error) {
|
|
889
|
+
console.error(error);
|
|
890
|
+
}).finally(function () {
|
|
891
|
+
delete activeTargets[activationId];
|
|
892
|
+
});
|
|
893
|
+
activeTargets[activationId] = promise;
|
|
894
|
+
return true;
|
|
895
|
+
}
|
|
896
|
+
}]);
|
|
897
|
+
}();
|
|
898
|
+
export { ParticleRuntime };
|