@tawaship/pixi-animate-runtime 0.0.0-stage → 0.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.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +462 -2
  3. package/bin/pixi-animate-runtime.js +27 -0
  4. package/dist/generator.cjs.js +1056 -0
  5. package/dist/generator.cjs.js.map +1 -0
  6. package/dist/pixi-animate-runtime.cjs.js +3742 -0
  7. package/dist/pixi-animate-runtime.cjs.js.map +1 -0
  8. package/dist/pixi-animate-runtime.esm.js +3677 -0
  9. package/dist/pixi-animate-runtime.esm.js.map +1 -0
  10. package/dist/pixi-animate-runtime.js +3744 -0
  11. package/dist/pixi-animate-runtime.js.map +1 -0
  12. package/dist-skills/animate-data-converter-guide/SKILL.md +86 -0
  13. package/dist-skills/pixi-animate-runtime-guide/SKILL.md +146 -0
  14. package/package.json +70 -4
  15. package/tools/pixi-animate-runtime.bat +8 -0
  16. package/types/generator/generator/cli.d.ts +17 -0
  17. package/types/generator/generator/converter-version.d.ts +7 -0
  18. package/types/generator/generator/generate.d.ts +33 -0
  19. package/types/generator/generator/index.d.ts +6 -0
  20. package/types/generator/generator/plan.d.ts +87 -0
  21. package/types/generator/player/data.d.ts +141 -0
  22. package/types/generator/player/ease.d.ts +11 -0
  23. package/types/generator/player/semver.d.ts +27 -0
  24. package/types/generator/player/version.d.ts +2 -0
  25. package/types/player/animate-container.d.ts +73 -0
  26. package/types/player/content.d.ts +181 -0
  27. package/types/player/data.d.ts +141 -0
  28. package/types/player/display.d.ts +192 -0
  29. package/types/player/ease.d.ts +11 -0
  30. package/types/player/events.d.ts +60 -0
  31. package/types/player/geom.d.ts +19 -0
  32. package/types/player/index.d.ts +20 -0
  33. package/types/player/loader.d.ts +53 -0
  34. package/types/player/movieclip.d.ts +191 -0
  35. package/types/player/objects.d.ts +320 -0
  36. package/types/player/semver.d.ts +27 -0
  37. package/types/player/transform.d.ts +32 -0
  38. package/types/player/version.d.ts +2 -0
@@ -0,0 +1,3744 @@
1
+ /*!
2
+ * @tawaship/pixi-animate-runtime - v0.1.1
3
+ *
4
+ * @author tawaship (makazu.mori@gmail.com)
5
+ * @license MIT
6
+ */
7
+
8
+ this.PIXI = this.PIXI || {};
9
+ (function (exports, PIXI) {
10
+ 'use strict';
11
+
12
+ function _interopNamespaceDefault(e) {
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var PIXI__namespace = /*#__PURE__*/_interopNamespaceDefault(PIXI);
30
+
31
+ /**
32
+ * createjs-compatible events: Event and EventDispatcher, with the capture,
33
+ * target and bubble phases createjs dispatches through the parent chain.
34
+ */
35
+ var Event = function Event(type, bubbles, cancelable) {
36
+ this.target = null;
37
+ this.currentTarget = null;
38
+ this.eventPhase = 0;
39
+ this.defaultPrevented = false;
40
+ this.propagationStopped = false;
41
+ this.immediatePropagationStopped = false;
42
+ this.removed = false;
43
+ this.type = type;
44
+ this.bubbles = !!bubbles;
45
+ this.cancelable = !!cancelable;
46
+ this.timeStamp = Date.now();
47
+ };
48
+ Event.prototype.preventDefault = function preventDefault () {
49
+ this.defaultPrevented = this.cancelable;
50
+ };
51
+ Event.prototype.stopPropagation = function stopPropagation () {
52
+ this.propagationStopped = true;
53
+ };
54
+ Event.prototype.stopImmediatePropagation = function stopImmediatePropagation () {
55
+ this.immediatePropagationStopped = this.propagationStopped = true;
56
+ };
57
+ Event.prototype.remove = function remove () {
58
+ this.removed = true;
59
+ };
60
+ Event.prototype.clone = function clone () {
61
+ return new Event(this.type, this.bubbles, this.cancelable);
62
+ };
63
+ Event.prototype.set = function set (props) {
64
+ var this$1$1 = this;
65
+
66
+ Object.keys(props).forEach(function (key) {
67
+ Reflect.set(this$1$1, key, props[key]);
68
+ });
69
+ return this;
70
+ };
71
+ Event.prototype.toString = function toString () {
72
+ return '[Event (type=' + this.type + ')]';
73
+ };
74
+ function callListener(listener, event) {
75
+ // As createjs: an object with handleEvent is called through it, anything else directly
76
+ if (typeof listener !== 'function') {
77
+ listener.handleEvent(event);
78
+ }
79
+ else {
80
+ listener(event);
81
+ }
82
+ }
83
+ var EventDispatcher = function EventDispatcher() {
84
+ this._listeners = null;
85
+ this._captureListeners = null;
86
+ };
87
+
88
+ var prototypeAccessors$2 = { _eventParent: { configurable: true } };
89
+ /** The parent the bubble and capture phases walk through (a display object's parent) */
90
+ prototypeAccessors$2._eventParent.get = function () {
91
+ return null;
92
+ };
93
+ EventDispatcher.prototype.addEventListener = function addEventListener (type, listener, useCapture) {
94
+ var listeners = useCapture ? this._captureListeners : this._listeners;
95
+ if (!listeners) {
96
+ listeners = {};
97
+ if (useCapture) {
98
+ this._captureListeners = listeners;
99
+ }
100
+ else {
101
+ this._listeners = listeners;
102
+ }
103
+ }
104
+ var list = listeners[type];
105
+ if (list) {
106
+ this.removeEventListener(type, listener, useCapture);
107
+ // Removing may have dropped the list
108
+ var again = listeners[type];
109
+ if (again) {
110
+ again.push(listener);
111
+ }
112
+ else {
113
+ listeners[type] = [listener];
114
+ }
115
+ }
116
+ else {
117
+ listeners[type] = [listener];
118
+ }
119
+ return listener;
120
+ };
121
+ EventDispatcher.prototype.on = function on (type, listener, scope, once, data, useCapture) {
122
+ var owner = typeof listener === 'function' ? (scope || this) : (scope || listener);
123
+ var wrapper = function (event) {
124
+ if (typeof listener === 'function') {
125
+ listener.call(owner, event, data);
126
+ }
127
+ else {
128
+ listener.handleEvent.call(owner, event);
129
+ }
130
+ if (once) {
131
+ event.remove();
132
+ }
133
+ };
134
+ return this.addEventListener(type, wrapper, useCapture);
135
+ };
136
+ EventDispatcher.prototype.removeEventListener = function removeEventListener (type, listener, useCapture) {
137
+ var listeners = useCapture ? this._captureListeners : this._listeners;
138
+ if (!listeners) {
139
+ return;
140
+ }
141
+ var list = listeners[type];
142
+ if (!list) {
143
+ return;
144
+ }
145
+ for (var i = 0, l = list.length; i < l; i++) {
146
+ if (list[i] === listener) {
147
+ if (l === 1) {
148
+ delete listeners[type];
149
+ }
150
+ else {
151
+ list.splice(i, 1);
152
+ }
153
+ break;
154
+ }
155
+ }
156
+ };
157
+ EventDispatcher.prototype.off = function off (type, listener, useCapture) {
158
+ this.removeEventListener(type, listener, useCapture);
159
+ };
160
+ EventDispatcher.prototype.removeAllEventListeners = function removeAllEventListeners (type) {
161
+ if (!type) {
162
+ this._listeners = this._captureListeners = null;
163
+ return;
164
+ }
165
+ if (this._listeners) {
166
+ delete this._listeners[type];
167
+ }
168
+ if (this._captureListeners) {
169
+ delete this._captureListeners[type];
170
+ }
171
+ };
172
+ EventDispatcher.prototype.dispatchEvent = function dispatchEvent (eventOrType, bubbles, cancelable) {
173
+ var event;
174
+ if (typeof eventOrType === 'string') {
175
+ var listeners = this._listeners;
176
+ if (!bubbles && (!listeners || !listeners[eventOrType])) {
177
+ return true;
178
+ }
179
+ event = new Event(eventOrType, bubbles, cancelable);
180
+ }
181
+ else {
182
+ // An event that has been dispatched already is dispatched as a copy
183
+ event = eventOrType.target ? eventOrType.clone() : eventOrType;
184
+ }
185
+ event.target = this;
186
+ if (!event.bubbles || !this._eventParent) {
187
+ this._dispatchEvent(event, 2);
188
+ }
189
+ else {
190
+ var chain = [];
191
+ for (var top = this; top; top = top._eventParent) {
192
+ chain.push(top);
193
+ }
194
+ // Capture phase, from the top down to the target's parent
195
+ for (var i = chain.length - 1; i >= 0 && !event.propagationStopped; i--) {
196
+ chain[i]._dispatchEvent(event, 1 + (i === 0 ? 1 : 0));
197
+ }
198
+ // Bubble phase, from the target's parent up
199
+ for (var i$1 = 1; i$1 < chain.length && !event.propagationStopped; i$1++) {
200
+ chain[i$1]._dispatchEvent(event, 3);
201
+ }
202
+ }
203
+ return !event.defaultPrevented;
204
+ };
205
+ EventDispatcher.prototype.hasEventListener = function hasEventListener (type) {
206
+ var listeners = this._listeners;
207
+ var capture = this._captureListeners;
208
+ return !!((listeners && listeners[type]) || (capture && capture[type]));
209
+ };
210
+ EventDispatcher.prototype.willTrigger = function willTrigger (type) {
211
+ for (var o = this; o; o = o._eventParent) {
212
+ if (o.hasEventListener(type)) {
213
+ return true;
214
+ }
215
+ }
216
+ return false;
217
+ };
218
+ /**
219
+ * Phase 1 is capture, 2 the target, 3 bubbling. At the target, the capture
220
+ * listeners run first and then the others (createjs runs the target phase
221
+ * twice, the second time as phase 2.1, which reads the non-capture listeners).
222
+ */
223
+ EventDispatcher.prototype._dispatchEvent = function _dispatchEvent (event, phase) {
224
+ var map = phase <= 2 ? this._captureListeners : this._listeners;
225
+ var found = map ? map[event.type] : undefined;
226
+ if (found && found.length) {
227
+ var list = found.slice();
228
+ event.currentTarget = this;
229
+ event.eventPhase = phase | 0;
230
+ event.removed = false;
231
+ for (var i = 0; i < list.length && !event.immediatePropagationStopped; i++) {
232
+ var listener = list[i];
233
+ callListener(listener, event);
234
+ if (event.removed) {
235
+ this.off(event.type, listener, phase === 1);
236
+ event.removed = false;
237
+ }
238
+ }
239
+ }
240
+ if (phase === 2) {
241
+ this._dispatchEvent(event, 2.1);
242
+ }
243
+ };
244
+
245
+ Object.defineProperties( EventDispatcher.prototype, prototypeAccessors$2 );
246
+
247
+ var DEG_TO_RAD = Math.PI / 180;
248
+ var RAD_TO_DEG = 180 / Math.PI;
249
+ /**
250
+ * A Pixi Transform whose rotation and skew follow createjs.
251
+ *
252
+ * - The createjs values (degrees) are kept as written, so that reading them
253
+ * back gives exactly what was written (a degrees -> radians -> degrees round
254
+ * trip does not)
255
+ * - Pixi's own fields carry the same values in Pixi's terms (rotation in
256
+ * radians, skew.x = -skewX, skew.y = skewY, all in radians), so code that
257
+ * uses the Pixi node sees consistent values. A write made through Pixi
258
+ * (node.rotation, node.skew) is taken over as the new createjs value
259
+ * - The local matrix is built the createjs way: skew x (rotation x scale),
260
+ * i.e. the object is rotated first and then skewed. Pixi composes rotation
261
+ * and skew the other way round (skewed, then rotated as a whole); the two
262
+ * agree only while the rotation is 0 or skewX equals skewY. Published
263
+ * content is the reference, so createjs's composition is used
264
+ */
265
+ var CjsTransform = /*@__PURE__*/(function (superclass) {
266
+ function CjsTransform() {
267
+ superclass.apply(this, arguments);
268
+ /** createjs rotation, in degrees */
269
+ this.degRotation = 0;
270
+ /** createjs skewX / skewY, in degrees */
271
+ this.degSkewX = 0;
272
+ this.degSkewY = 0;
273
+ /** The radians last written to the Pixi fields for the values above */
274
+ this._radRotation = 0;
275
+ this._radSkewX = 0;
276
+ this._radSkewY = 0;
277
+ }
278
+
279
+ if ( superclass ) CjsTransform.__proto__ = superclass;
280
+ CjsTransform.prototype = Object.create( superclass && superclass.prototype );
281
+ CjsTransform.prototype.constructor = CjsTransform;
282
+ CjsTransform.prototype.setRotation = function setRotation (degrees) {
283
+ this.degRotation = degrees;
284
+ this._radRotation = degrees * DEG_TO_RAD;
285
+ if (this._rotation !== this._radRotation) {
286
+ this._rotation = this._radRotation;
287
+ }
288
+ this.updateSkew();
289
+ };
290
+ CjsTransform.prototype.setSkewX = function setSkewX (degrees) {
291
+ this.degSkewX = degrees;
292
+ this._radSkewX = -degrees * DEG_TO_RAD;
293
+ // Setting the point calls updateSkew when the value changes
294
+ this.skew.x = this._radSkewX;
295
+ this.updateSkew();
296
+ };
297
+ CjsTransform.prototype.setSkewY = function setSkewY (degrees) {
298
+ this.degSkewY = degrees;
299
+ this._radSkewY = degrees * DEG_TO_RAD;
300
+ this.skew.y = this._radSkewY;
301
+ this.updateSkew();
302
+ };
303
+ CjsTransform.prototype.updateSkew = function updateSkew () {
304
+ // Values written through Pixi become the createjs values
305
+ if (this._rotation !== this._radRotation) {
306
+ this._radRotation = this._rotation;
307
+ this.degRotation = this._rotation * RAD_TO_DEG;
308
+ }
309
+ if (this.skew.x !== this._radSkewX) {
310
+ this._radSkewX = this.skew.x;
311
+ this.degSkewX = -this.skew.x * RAD_TO_DEG;
312
+ }
313
+ if (this.skew.y !== this._radSkewY) {
314
+ this._radSkewY = this.skew.y;
315
+ this.degSkewY = this.skew.y * RAD_TO_DEG;
316
+ }
317
+ // createjs Matrix2D.appendTransform: (skew) x (rotation, scale)
318
+ var cos = 1;
319
+ var sin = 0;
320
+ if (this.degRotation % 360) {
321
+ var r = this.degRotation * DEG_TO_RAD;
322
+ cos = Math.cos(r);
323
+ sin = Math.sin(r);
324
+ }
325
+ if (this.degSkewX || this.degSkewY) {
326
+ var skewX = this.degSkewX * DEG_TO_RAD;
327
+ var skewY = this.degSkewY * DEG_TO_RAD;
328
+ var a1 = Math.cos(skewY);
329
+ var b1 = Math.sin(skewY);
330
+ var c1 = -Math.sin(skewX);
331
+ var d1 = Math.cos(skewX);
332
+ this._cx = a1 * cos + c1 * sin;
333
+ this._sx = b1 * cos + d1 * sin;
334
+ this._cy = a1 * -sin + c1 * cos;
335
+ this._sy = b1 * -sin + d1 * cos;
336
+ }
337
+ else {
338
+ this._cx = cos;
339
+ this._sx = sin;
340
+ this._cy = -sin;
341
+ this._sy = cos;
342
+ }
343
+ this._localID++;
344
+ };
345
+
346
+ return CjsTransform;
347
+ }(PIXI__namespace.Transform));
348
+
349
+ /**
350
+ * createjs-compatible Rectangle (its own members are exactly x, y, width,
351
+ * height, as createjs's; Pixi's Rectangle also carries a shape type).
352
+ */
353
+ var Rectangle = function Rectangle(x, y, width, height) {
354
+ this.x = x || 0;
355
+ this.y = y || 0;
356
+ this.width = width || 0;
357
+ this.height = height || 0;
358
+ };
359
+ Rectangle.prototype.setValues = function setValues (x, y, width, height) {
360
+ this.x = x || 0;
361
+ this.y = y || 0;
362
+ this.width = width || 0;
363
+ this.height = height || 0;
364
+ return this;
365
+ };
366
+ Rectangle.prototype.copy = function copy (rect) {
367
+ return this.setValues(rect.x, rect.y, rect.width, rect.height);
368
+ };
369
+ Rectangle.prototype.clone = function clone () {
370
+ return new Rectangle(this.x, this.y, this.width, this.height);
371
+ };
372
+ Rectangle.prototype.contains = function contains (x, y, width, height) {
373
+ var w = width || 0;
374
+ var h = height || 0;
375
+ return x >= this.x && x + w <= this.x + this.width && y >= this.y && y + h <= this.y + this.height;
376
+ };
377
+ Rectangle.prototype.isEmpty = function isEmpty () {
378
+ return this.width <= 0 || this.height <= 0;
379
+ };
380
+ Rectangle.prototype.toPixi = function toPixi () {
381
+ return new PIXI__namespace.Rectangle(this.x, this.y, this.width, this.height);
382
+ };
383
+ Rectangle.prototype.toString = function toString () {
384
+ return '[Rectangle (x=' + this.x + ' y=' + this.y + ' width=' + this.width + ' height=' + this.height + ')]';
385
+ };
386
+
387
+ var PixiContainer = /*@__PURE__*/(function (superclass) {
388
+ function PixiContainer() {
389
+ superclass.apply(this, arguments);
390
+ this.owner = null;
391
+ }
392
+
393
+ if ( superclass ) PixiContainer.__proto__ = superclass;
394
+ PixiContainer.prototype = Object.create( superclass && superclass.prototype );
395
+ PixiContainer.prototype.constructor = PixiContainer;
396
+
397
+ return PixiContainer;
398
+ }(PIXI__namespace.Container));
399
+ var nextId = 0;
400
+ /** A hit area nothing is inside: Pixi's hit test skips a node with it and the node's children */
401
+ var NO_HIT_AREA = new PIXI__namespace.Rectangle(0, 0, 0, 0);
402
+ /** createjs compositeOperation -> Pixi blend mode (the ones WebGL renders) */
403
+ var BLEND_MODES = {
404
+ 'source-over': PIXI__namespace.BLEND_MODES.NORMAL,
405
+ lighter: PIXI__namespace.BLEND_MODES.ADD,
406
+ multiply: PIXI__namespace.BLEND_MODES.MULTIPLY,
407
+ screen: PIXI__namespace.BLEND_MODES.SCREEN
408
+ };
409
+ /**
410
+ * createjs-compatible display object: a window onto a Pixi node.
411
+ *
412
+ * The values both have in common live on the Pixi node only (x / y on
413
+ * position, scaleX / scaleY on scale, regX / regY on pivot, alpha, visible),
414
+ * read and written through accessors, so a write through the Pixi node and a
415
+ * write through this object are the same write. Members that mean different
416
+ * things in createjs and Pixi keep the createjs meaning here (rotation and
417
+ * skew in degrees, mask, filters, parent); the Pixi node keeps the Pixi one.
418
+ */
419
+ var DisplayObject = /*@__PURE__*/(function (EventDispatcher) {
420
+ function DisplayObject(pixi) {
421
+ EventDispatcher.call(this);
422
+ this.parent = null;
423
+ this.tickEnabled = true;
424
+ this.mouseEnabled = true;
425
+ this.cursor = null;
426
+ this.hitArea = null;
427
+ this.shadow = null;
428
+ this.snapToPixel = true;
429
+ /**
430
+ * Kept off the display list by the timeline (published code sets it on masks
431
+ * and absent instances). createjs reads it only when its timeline places
432
+ * children: it does not affect drawing (an _off object on a display list is drawn)
433
+ */
434
+ /** createjs leaves it unset (undefined) until the timeline or published code sets it */
435
+ this._offValue = undefined;
436
+ this._name = null;
437
+ this._mask = null;
438
+ this._filters = null;
439
+ this._compositeOperation = null;
440
+ /** The composite operation in effect on the parent (createjs draws children under it) */
441
+ this._inheritedComposite = null;
442
+ /** The cache createjs would draw through (filters show in Pixi without one) */
443
+ this.bitmapCache = null;
444
+ this._bounds = null;
445
+ /** The parent whose Pixi node holds this object's mask node */
446
+ this._maskHost = null;
447
+ /** The objects this object masks (while they are on a display list) */
448
+ this._maskTargets = [];
449
+ /**
450
+ * Set on a root when a timeline under it jumped outside the playing (a goto):
451
+ * its clips are to be settled before Pixi draws it (settleForDrawing), as a
452
+ * createjs draw would. The resolve phase of a frame clears it
453
+ */
454
+ this._pendingResolve = false;
455
+ this.id = nextId++;
456
+ this.pixi = pixi;
457
+ pixi.owner = this;
458
+ pixi.transform = new CjsTransform();
459
+ }
460
+
461
+ if ( EventDispatcher ) DisplayObject.__proto__ = EventDispatcher;
462
+ DisplayObject.prototype = Object.create( EventDispatcher && EventDispatcher.prototype );
463
+ DisplayObject.prototype.constructor = DisplayObject;
464
+
465
+ var prototypeAccessors = { _eventParent: { configurable: true },_transform: { configurable: true },x: { configurable: true },y: { configurable: true },scaleX: { configurable: true },scaleY: { configurable: true },regX: { configurable: true },regY: { configurable: true },rotation: { configurable: true },skewX: { configurable: true },skewY: { configurable: true },alpha: { configurable: true },visible: { configurable: true },name: { configurable: true },_off: { configurable: true },compositeOperation: { configurable: true },mask: { configurable: true },filters: { configurable: true } };
466
+ prototypeAccessors._eventParent.get = function () {
467
+ return this.parent;
468
+ };
469
+ prototypeAccessors._transform.get = function () {
470
+ var transform = this.pixi.transform;
471
+ if (transform instanceof CjsTransform) {
472
+ return transform;
473
+ }
474
+ // The Pixi side replaced the transform: keep createjs semantics on a new one
475
+ var replacement = new CjsTransform();
476
+ replacement.setFromMatrix(transform.localTransform);
477
+ this.pixi.transform = replacement;
478
+ return replacement;
479
+ };
480
+ prototypeAccessors.x.get = function () { return this.pixi.position.x; };
481
+ prototypeAccessors.x.set = function (value) { this.pixi.position.x = value; };
482
+ prototypeAccessors.y.get = function () { return this.pixi.position.y; };
483
+ prototypeAccessors.y.set = function (value) { this.pixi.position.y = value; };
484
+ prototypeAccessors.scaleX.get = function () { return this.pixi.scale.x; };
485
+ prototypeAccessors.scaleX.set = function (value) { this.pixi.scale.x = value; };
486
+ prototypeAccessors.scaleY.get = function () { return this.pixi.scale.y; };
487
+ prototypeAccessors.scaleY.set = function (value) { this.pixi.scale.y = value; };
488
+ prototypeAccessors.regX.get = function () { return this.pixi.pivot.x; };
489
+ prototypeAccessors.regX.set = function (value) { this.pixi.pivot.x = value; };
490
+ prototypeAccessors.regY.get = function () { return this.pixi.pivot.y; };
491
+ prototypeAccessors.regY.set = function (value) { this.pixi.pivot.y = value; };
492
+ prototypeAccessors.rotation.get = function () { return this._transform.degRotation; };
493
+ prototypeAccessors.rotation.set = function (value) { this._transform.setRotation(value); };
494
+ prototypeAccessors.skewX.get = function () { return this._transform.degSkewX; };
495
+ prototypeAccessors.skewX.set = function (value) { this._transform.setSkewX(value); };
496
+ prototypeAccessors.skewY.get = function () { return this._transform.degSkewY; };
497
+ prototypeAccessors.skewY.set = function (value) { this._transform.setSkewY(value); };
498
+ prototypeAccessors.alpha.get = function () { return this.pixi.alpha; };
499
+ prototypeAccessors.alpha.set = function (value) { this.pixi.alpha = value; };
500
+ prototypeAccessors.visible.get = function () { return this.pixi.visible; };
501
+ prototypeAccessors.visible.set = function (value) { this.pixi.visible = value; };
502
+ prototypeAccessors.name.get = function () { return this._name; };
503
+ prototypeAccessors.name.set = function (value) {
504
+ this._name = value;
505
+ this.pixi.name = value == null ? '' : String(value);
506
+ };
507
+ prototypeAccessors._off.get = function () { return this._offValue; };
508
+ prototypeAccessors._off.set = function (value) {
509
+ this._offValue = value;
510
+ };
511
+ prototypeAccessors.compositeOperation.get = function () { return this._compositeOperation; };
512
+ prototypeAccessors.compositeOperation.set = function (value) {
513
+ this._compositeOperation = value;
514
+ this._applyComposite();
515
+ };
516
+ /**
517
+ * The composite operation createjs draws this object with: its own, or else
518
+ * the nearest ancestor's (createjs sets it on the context and draws the
519
+ * children under it, each child saving and restoring the context)
520
+ */
521
+ DisplayObject.prototype._effectiveComposite = function _effectiveComposite () {
522
+ return this._compositeOperation || this._inheritedComposite;
523
+ };
524
+ /** Told by the parent when the composite operation in effect on it changes */
525
+ DisplayObject.prototype._setInheritedComposite = function _setInheritedComposite (value) {
526
+ if (value === this._inheritedComposite) {
527
+ return;
528
+ }
529
+ this._inheritedComposite = value;
530
+ this._applyComposite();
531
+ };
532
+ /**
533
+ * Pixi blends per drawing node (a container has no blend mode of its own),
534
+ * so the composite operation in effect is set on this object's drawing node
535
+ * and handed down to the children
536
+ */
537
+ DisplayObject.prototype._applyComposite = function _applyComposite () {
538
+ var composite = this._effectiveComposite();
539
+ var mode = composite ? BLEND_MODES[composite] : undefined;
540
+ this._setBlendMode(mode === undefined ? PIXI__namespace.BLEND_MODES.NORMAL : mode);
541
+ };
542
+ prototypeAccessors.mask.get = function () { return this._mask; };
543
+ prototypeAccessors.mask.set = function (value) {
544
+ if (this._mask === value) {
545
+ return;
546
+ }
547
+ var host = this._maskHost;
548
+ if (host) {
549
+ host._detachMask(this);
550
+ }
551
+ this._mask = value;
552
+ this.pixi.mask = null;
553
+ if (this.parent) {
554
+ this.parent._attachMask(this);
555
+ }
556
+ };
557
+ prototypeAccessors.filters.get = function () { return this._filters; };
558
+ prototypeAccessors.filters.set = function (value) {
559
+ this._filters = value;
560
+ this.pixi.filters = value && value.length ? value.map(function (filter) { return filter.pixiFilter; }) : [];
561
+ };
562
+ /** Blend mode for the Pixi node(s) that draw this object */
563
+ DisplayObject.prototype._setBlendMode = function _setBlendMode (mode) {
564
+ var node = this.pixi;
565
+ if (node instanceof PIXI__namespace.Sprite || node instanceof PIXI__namespace.Graphics) {
566
+ node.blendMode = mode;
567
+ }
568
+ };
569
+ /**
570
+ * The node is drawn unless Pixi uses it as a mask, or it is in a parent's
571
+ * node only to carry the mask shape of a sibling (a createjs mask is not on
572
+ * any display list and is not drawn itself)
573
+ */
574
+ DisplayObject.prototype._updateRenderable = function _updateRenderable () {
575
+ var maskOnly = this.pixi.isMask || this._maskTargets.length > 0;
576
+ this.pixi.renderable = !maskOnly;
577
+ // Pixi hit tests nodes that are not drawn: a mask's node is kept out of pointer
578
+ // hits (with its children) by a hit area nothing is inside, as createjs never hits a mask
579
+ if (maskOnly) {
580
+ this.pixi.hitArea = NO_HIT_AREA;
581
+ }
582
+ else if (this.pixi.hitArea === NO_HIT_AREA) {
583
+ // Back to Pixi's default (null; the type definition does not take null, Pixi does)
584
+ Reflect.set(this.pixi, 'hitArea', null);
585
+ }
586
+ };
587
+ /** Whether this object clips when used as a mask (createjs clips only with a non-empty Graphics) */
588
+ DisplayObject.prototype._clipsAsMask = function _clipsAsMask () {
589
+ return false;
590
+ };
591
+ /** The node Pixi masks with when this object is a mask */
592
+ DisplayObject.prototype._pixiMaskNode = function _pixiMaskNode () {
593
+ return null;
594
+ };
595
+ /** Called when this object stops being some object's Pixi mask */
596
+ DisplayObject.prototype._releaseMaskNode = function _releaseMaskNode () {
597
+ // Nothing to release for objects that are not shapes
598
+ };
599
+ /** Sets the Pixi mask from the createjs one: Pixi masks only while the createjs mask would clip */
600
+ DisplayObject.prototype._updatePixiMask = function _updatePixiMask () {
601
+ var mask = this._mask;
602
+ var node = mask && this._maskHost && mask._clipsAsMask() ? mask._pixiMaskNode() : null;
603
+ if (this.pixi.mask !== node) {
604
+ this.pixi.mask = node;
605
+ if (!node && mask) {
606
+ mask._releaseMaskNode();
607
+ }
608
+ }
609
+ };
610
+ DisplayObject.prototype.setTransform = function setTransform (x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
611
+ this.x = x || 0;
612
+ this.y = y || 0;
613
+ this.scaleX = scaleX == null ? 1 : scaleX;
614
+ this.scaleY = scaleY == null ? 1 : scaleY;
615
+ this.rotation = rotation || 0;
616
+ this.skewX = skewX || 0;
617
+ this.skewY = skewY || 0;
618
+ this.regX = regX || 0;
619
+ this.regY = regY || 0;
620
+ return this;
621
+ };
622
+ DisplayObject.prototype.set = function set (props) {
623
+ var this$1$1 = this;
624
+
625
+ Object.keys(props).forEach(function (key) {
626
+ Reflect.set(this$1$1, key, props[key]);
627
+ });
628
+ return this;
629
+ };
630
+ DisplayObject.prototype.isVisible = function isVisible () {
631
+ return !!(this.visible && this.alpha > 0 && this.scaleX !== 0 && this.scaleY !== 0);
632
+ };
633
+ DisplayObject.prototype.cache = function cache (x, y, width, height, scale) {
634
+ this.bitmapCache = { x: x, y: y, width: width, height: height, scale: scale || 1 };
635
+ };
636
+ DisplayObject.prototype.updateCache = function updateCache () {
637
+ // Nothing is cached on the Pixi side; filters apply without a cache
638
+ };
639
+ DisplayObject.prototype.uncache = function uncache () {
640
+ this.bitmapCache = null;
641
+ };
642
+ DisplayObject.prototype.setBounds = function setBounds (x, y, width, height) {
643
+ this._bounds = x == null ? null : new Rectangle(x, y, width, height);
644
+ };
645
+ DisplayObject.prototype.getChildDepth = function getChildDepth () {
646
+ var depth = 0;
647
+ for (var o = this.parent; o; o = o.parent) {
648
+ depth++;
649
+ }
650
+ return depth;
651
+ };
652
+ /** createjs tick phase: dispatches the tick event to listeners */
653
+ DisplayObject.prototype._tick = function _tick (event) {
654
+ var listeners = this._listeners;
655
+ if (listeners && listeners.tick) {
656
+ event.target = null;
657
+ event.propagationStopped = event.immediatePropagationStopped = false;
658
+ this.dispatchEvent(event);
659
+ }
660
+ };
661
+ DisplayObject.prototype.toString = function toString () {
662
+ return '[DisplayObject (name=' + this.name + ')]';
663
+ };
664
+
665
+ Object.defineProperties( DisplayObject.prototype, prototypeAccessors );
666
+
667
+ return DisplayObject;
668
+ }(EventDispatcher));
669
+ /**
670
+ * createjs-compatible Container. The Pixi node's children are the display
671
+ * list's nodes in the same order, followed by the nodes of the masks the
672
+ * children use (a createjs mask is drawn in its target's parent space, so
673
+ * its node lives in the parent's node).
674
+ */
675
+ var Container = /*@__PURE__*/(function (DisplayObject) {
676
+ function Container(pixi) {
677
+ DisplayObject.call(this, pixi || new PixiContainer());
678
+ this.children = [];
679
+ this.tickChildren = true;
680
+ this.mouseChildren = true;
681
+ /** Mask nodes held in this container's node, by the child that uses them */
682
+ this._maskNodes = {};
683
+ }
684
+
685
+ if ( DisplayObject ) Container.__proto__ = DisplayObject;
686
+ Container.prototype = Object.create( DisplayObject && DisplayObject.prototype );
687
+ Container.prototype.constructor = Container;
688
+
689
+ var prototypeAccessors$1 = { numChildren: { configurable: true } };
690
+ prototypeAccessors$1.numChildren.get = function () {
691
+ return this.children.length;
692
+ };
693
+ Container.prototype.addChild = function addChild () {
694
+ var this$1$1 = this;
695
+ var children = [], len = arguments.length;
696
+ while ( len-- ) children[ len ] = arguments[ len ];
697
+
698
+ var last = null;
699
+ children.forEach(function (child) {
700
+ if (child != null) {
701
+ last = this$1$1.addChildAt(child, this$1$1.children.length);
702
+ }
703
+ });
704
+ return last;
705
+ };
706
+ Container.prototype.addChildAt = function addChildAt (child, index) {
707
+ if (index < 0 || index > this.children.length) {
708
+ return child;
709
+ }
710
+ var oldParent = child.parent;
711
+ var same = oldParent === this;
712
+ if (oldParent) {
713
+ oldParent._removeChildAt(oldParent.children.indexOf(child), same);
714
+ }
715
+ child.parent = this;
716
+ this.children.splice(index, 0, child);
717
+ this.pixi.addChildAt(child.pixi, index);
718
+ this._attachMask(child);
719
+ child._setInheritedComposite(this._effectiveComposite());
720
+ if (!same) {
721
+ child.dispatchEvent('added');
722
+ }
723
+ return child;
724
+ };
725
+ Container.prototype.removeChild = function removeChild () {
726
+ var this$1$1 = this;
727
+ var children = [], len = arguments.length;
728
+ while ( len-- ) children[ len ] = arguments[ len ];
729
+
730
+ var removed = true;
731
+ children.forEach(function (child) {
732
+ removed = this$1$1._removeChildAt(this$1$1.children.indexOf(child)) && removed;
733
+ });
734
+ return removed;
735
+ };
736
+ Container.prototype.removeChildAt = function removeChildAt () {
737
+ var this$1$1 = this;
738
+ var indexes = [], len = arguments.length;
739
+ while ( len-- ) indexes[ len ] = arguments[ len ];
740
+
741
+ var sorted = indexes.slice().sort(function (a, b) { return b - a; });
742
+ var removed = true;
743
+ sorted.forEach(function (index) {
744
+ removed = this$1$1._removeChildAt(index) && removed;
745
+ });
746
+ return removed;
747
+ };
748
+ Container.prototype.removeAllChildren = function removeAllChildren () {
749
+ while (this.children.length) {
750
+ this._removeChildAt(0);
751
+ }
752
+ };
753
+ Container.prototype.getChildAt = function getChildAt (index) {
754
+ return this.children[index];
755
+ };
756
+ Container.prototype.getChildByName = function getChildByName (name) {
757
+ var children = this.children;
758
+ for (var i = 0; i < children.length; i++) {
759
+ if (children[i].name == name) {
760
+ return children[i];
761
+ }
762
+ }
763
+ return null;
764
+ };
765
+ Container.prototype.getChildIndex = function getChildIndex (child) {
766
+ return this.children.indexOf(child);
767
+ };
768
+ Container.prototype.setChildIndex = function setChildIndex (child, index) {
769
+ var children = this.children;
770
+ if (child.parent !== this || index < 0 || index >= children.length) {
771
+ return;
772
+ }
773
+ var current = children.indexOf(child);
774
+ if (current < 0 || current === index) {
775
+ return;
776
+ }
777
+ children.splice(current, 1);
778
+ children.splice(index, 0, child);
779
+ this.pixi.setChildIndex(child.pixi, index);
780
+ };
781
+ Container.prototype.swapChildrenAt = function swapChildrenAt (index1, index2) {
782
+ var children = this.children;
783
+ var a = children[index1];
784
+ var b = children[index2];
785
+ if (!a || !b) {
786
+ return;
787
+ }
788
+ children[index1] = b;
789
+ children[index2] = a;
790
+ this.pixi.swapChildren(a.pixi, b.pixi);
791
+ };
792
+ Container.prototype.swapChildren = function swapChildren (child1, child2) {
793
+ var index1 = this.children.indexOf(child1);
794
+ var index2 = this.children.indexOf(child2);
795
+ if (index1 >= 0 && index2 >= 0) {
796
+ this.swapChildrenAt(index1, index2);
797
+ }
798
+ };
799
+ Container.prototype.sortChildren = function sortChildren (compare) {
800
+ var this$1$1 = this;
801
+
802
+ this.children.sort(compare);
803
+ this.children.forEach(function (child, index) {
804
+ this$1$1.pixi.setChildIndex(child.pixi, index);
805
+ });
806
+ };
807
+ Container.prototype.contains = function contains (child) {
808
+ for (var o = child; o; o = o.parent) {
809
+ if (o === this) {
810
+ return true;
811
+ }
812
+ }
813
+ return false;
814
+ };
815
+ Container.prototype._removeChildAt = function _removeChildAt (index, silent) {
816
+ if (index < 0 || index > this.children.length - 1) {
817
+ return false;
818
+ }
819
+ var child = this.children[index];
820
+ this._detachMask(child);
821
+ child.parent = null;
822
+ this.children.splice(index, 1);
823
+ this.pixi.removeChild(child.pixi);
824
+ // A silent removal is the first half of re-adding to this same container
825
+ // (the timeline does it every resolve): the inherited composite stays
826
+ if (!silent) {
827
+ child._setInheritedComposite(null);
828
+ child.dispatchEvent('removed');
829
+ }
830
+ return true;
831
+ };
832
+ /** Puts the node of a child's mask into this container's node, and sets it as the Pixi mask */
833
+ Container.prototype._attachMask = function _attachMask (child) {
834
+ var mask = child.mask;
835
+ if (!mask || child.parent !== this) {
836
+ return;
837
+ }
838
+ this._maskNodes[child.id] = mask.pixi;
839
+ this.pixi.addChild(mask.pixi);
840
+ child._maskHost = this;
841
+ mask._maskTargets.push(child);
842
+ mask._updateRenderable();
843
+ child._updatePixiMask();
844
+ };
845
+ Container.prototype._detachMask = function _detachMask (child) {
846
+ var node = this._maskNodes[child.id];
847
+ if (node) {
848
+ delete this._maskNodes[child.id];
849
+ if (node.parent === this.pixi) {
850
+ this.pixi.removeChild(node);
851
+ }
852
+ }
853
+ var mask = child.mask;
854
+ if (mask) {
855
+ var index = mask._maskTargets.indexOf(child);
856
+ if (index >= 0) {
857
+ mask._maskTargets.splice(index, 1);
858
+ }
859
+ }
860
+ child._maskHost = null;
861
+ child.pixi.mask = null;
862
+ if (mask) {
863
+ // Pixi makes a released mask node renderable again
864
+ mask._releaseMaskNode();
865
+ mask._updateRenderable();
866
+ }
867
+ };
868
+ Container.prototype._applyComposite = function _applyComposite () {
869
+ DisplayObject.prototype._applyComposite.call(this);
870
+ var composite = this._effectiveComposite();
871
+ this.children.forEach(function (child) { return child._setInheritedComposite(composite); });
872
+ };
873
+ /** createjs tick phase: children in reverse order (live array), then this object's listeners */
874
+ Container.prototype._tick = function _tick (event) {
875
+ if (this.tickChildren) {
876
+ for (var i = this.children.length - 1; i >= 0; i--) {
877
+ var child = this.children[i];
878
+ if (child.tickEnabled) {
879
+ child._tick(event);
880
+ }
881
+ }
882
+ }
883
+ DisplayObject.prototype._tick.call(this, event);
884
+ };
885
+ Container.prototype.toString = function toString () {
886
+ return '[Container (name=' + this.name + ')]';
887
+ };
888
+
889
+ Object.defineProperties( Container.prototype, prototypeAccessors$1 );
890
+
891
+ return Container;
892
+ }(DisplayObject));
893
+
894
+ /**
895
+ * The playback state of one tween of an instance. The values come from the
896
+ * shared definition; only the positions are per instance.
897
+ */
898
+ var TweenState = function TweenState(def, target, scope, self) {
899
+ this.position = 0;
900
+ this.rawPosition = -1;
901
+ /** Distance from the start of the current step (synched children take their frame from it) */
902
+ this._stepPosition = 0;
903
+ this.passive = false;
904
+ this.def = def;
905
+ this.target = target;
906
+ this.scope = scope;
907
+ this.self = self;
908
+ };
909
+
910
+ var prototypeAccessors$1 = { duration: { configurable: true } };
911
+ prototypeAccessors$1.duration.get = function () {
912
+ return this.def.duration;
913
+ };
914
+ /**
915
+ * Tween.setPosition as a timeline drives it (actions are run separately by
916
+ * the timeline). Nothing happens when the raw position does not change.
917
+ */
918
+ TweenState.prototype.setPosition = function setPosition (rawPosition, jump) {
919
+ var duration = this.def.duration;
920
+ var previous = this.rawPosition;
921
+ var raw = rawPosition < 0 ? 0 : rawPosition;
922
+ var position = 0;
923
+ var end;
924
+ if (duration === 0) {
925
+ end = true;
926
+ if (previous !== -1) {
927
+ return;
928
+ }
929
+ }
930
+ else {
931
+ var loops = raw / duration | 0;
932
+ position = raw - loops * duration;
933
+ // A tween in a timeline does not loop: it ends at its duration
934
+ end = raw >= duration;
935
+ if (end) {
936
+ raw = position = duration;
937
+ }
938
+ if (raw === previous) {
939
+ return;
940
+ }
941
+ }
942
+ this.position = position;
943
+ this.rawPosition = raw;
944
+ this._updatePosition(jump, end);
945
+ };
946
+ TweenState.prototype._updatePosition = function _updatePosition (jump, end) {
947
+ var def = this.def;
948
+ var position = this.position;
949
+ if (def.writer !== null) {
950
+ this.scope.writer(def.writer)(this.target, def.values[def.frames[position]], this.scope.value);
951
+ }
952
+ // The last step whose start is at or before the position
953
+ var keyframes = def.keyframes;
954
+ var start = 0;
955
+ var found = false;
956
+ for (var i = 0; i < keyframes.length; i++) {
957
+ if (keyframes[i] <= position || i === 0) {
958
+ start = keyframes[i];
959
+ found = true;
960
+ }
961
+ else {
962
+ break;
963
+ }
964
+ }
965
+ this._stepPosition = found ? position - start : 0;
966
+ };
967
+ /** AbstractTween._runActions for this tween's actions */
968
+ TweenState.prototype._runActions = function _runActions (startRaw, endRaw, jump, includeStart) {
969
+ if (!this.def.actions.length) {
970
+ return false;
971
+ }
972
+ return runActions(this, this.def.duration, 0, startRaw, endRaw, jump, includeStart);
973
+ };
974
+ /** Tween._runActionsRange: runs the actions in the range, stopping when one moves the tween */
975
+ TweenState.prototype._runActionsRange = function _runActionsRange (start, end, jump, includeStart) {
976
+ var actions = this.def.actions;
977
+ var reverse = start > end;
978
+ var low = reverse ? end : start;
979
+ var high = reverse ? start : end;
980
+ var position = this.position;
981
+ for (var n = 0; n < actions.length; n++) {
982
+ var action = actions[reverse ? actions.length - 1 - n : n];
983
+ var t = action.position;
984
+ if (t === end || (t > low && t < high) || (includeStart && t === start)) {
985
+ var scope = this.scope;
986
+ var params = action.params ? action.params.map(function (value) { return scope.value(value); }) : [this];
987
+ scope.script(action.script).apply(this.self, params);
988
+ if (position !== this.position) {
989
+ return true;
990
+ }
991
+ }
992
+ }
993
+ return false;
994
+ };
995
+
996
+ Object.defineProperties( TweenState.prototype, prototypeAccessors$1 );
997
+ /**
998
+ * AbstractTween._runActions: splits the move from one raw position to another
999
+ * into per-loop ranges and runs the actions of each, as createjs does.
1000
+ */
1001
+ function runActions(runner, duration, loop, startRaw, endRaw, jump, includeStart) {
1002
+ var startLoop;
1003
+ var endLoop;
1004
+ var start;
1005
+ var end;
1006
+ if (duration === 0) {
1007
+ startLoop = endLoop = start = end = 0;
1008
+ }
1009
+ else {
1010
+ startLoop = startRaw / duration | 0;
1011
+ endLoop = endRaw / duration | 0;
1012
+ start = startRaw - startLoop * duration;
1013
+ end = endRaw - endLoop * duration;
1014
+ }
1015
+ if (loop !== -1) {
1016
+ if (endLoop > loop) {
1017
+ end = duration;
1018
+ endLoop = loop;
1019
+ }
1020
+ if (startLoop > loop) {
1021
+ start = duration;
1022
+ startLoop = loop;
1023
+ }
1024
+ }
1025
+ if (jump) {
1026
+ return runner._runActionsRange(end, end, jump, includeStart);
1027
+ }
1028
+ if (startLoop !== endLoop || start !== end || jump || includeStart) {
1029
+ if (startLoop === -1) {
1030
+ startLoop = start = 0;
1031
+ }
1032
+ var forward = endRaw >= startRaw;
1033
+ var n = startLoop;
1034
+ var first = includeStart;
1035
+ do {
1036
+ var rangeStart = n === startLoop ? start : forward ? 0 : duration;
1037
+ var rangeEnd = n === endLoop ? end : forward ? duration : 0;
1038
+ if (runner._runActionsRange(rangeStart, rangeEnd, jump, first || n !== startLoop)) {
1039
+ return true;
1040
+ }
1041
+ first = false;
1042
+ } while ((forward && ++n <= endLoop) || (!forward && --n >= endLoop));
1043
+ }
1044
+ return false;
1045
+ }
1046
+ /**
1047
+ * The timeline of a MovieClip instance (createjs.Timeline as a MovieClip drives it).
1048
+ */
1049
+ var Timeline = function Timeline(duration, labels) {
1050
+ var this$1$1 = this;
1051
+
1052
+ this.tweens = [];
1053
+ this.loop = 0;
1054
+ this.position = 0;
1055
+ this.rawPosition = -1;
1056
+ this.duration = duration;
1057
+ this._labels = {};
1058
+ labels.forEach(function (label) {
1059
+ this$1$1._labels[label.label] = label.position;
1060
+ });
1061
+ this._labelList = labels.slice().sort(function (a, b) { return a.position - b.position; });
1062
+ };
1063
+
1064
+ var prototypeAccessors$1$1 = { currentLabel: { configurable: true } };
1065
+ Timeline.prototype.getLabels = function getLabels () {
1066
+ return this._labelList;
1067
+ };
1068
+ prototypeAccessors$1$1.currentLabel.get = function () {
1069
+ var labels = this._labelList;
1070
+ var i = 0;
1071
+ for (; i < labels.length; i++) {
1072
+ if (this.position < labels[i].position) {
1073
+ break;
1074
+ }
1075
+ }
1076
+ return i === 0 ? null : labels[i - 1].label;
1077
+ };
1078
+ Timeline.prototype.resolve = function resolve (positionOrLabel) {
1079
+ var position = Number(positionOrLabel);
1080
+ if (!isNaN(position)) {
1081
+ return position;
1082
+ }
1083
+ var label = this._labels[positionOrLabel];
1084
+ return label === undefined ? undefined : label;
1085
+ };
1086
+ /**
1087
+ * AbstractTween.setPosition for the timeline: moves every tween, calls
1088
+ * back (the clip resolves its children), then runs the actions passed.
1089
+ */
1090
+ Timeline.prototype.setPosition = function setPosition (rawPosition, skipActions, jump, callback) {
1091
+ var duration = this.duration;
1092
+ var loop = this.loop;
1093
+ var previous = this.rawPosition;
1094
+ var raw = rawPosition < 0 ? 0 : rawPosition;
1095
+ var position = 0;
1096
+ if (duration === 0) {
1097
+ if (previous !== -1) {
1098
+ return;
1099
+ }
1100
+ }
1101
+ else {
1102
+ var loops = raw / duration | 0;
1103
+ position = raw - loops * duration;
1104
+ var end = loop !== -1 && raw >= loop * duration + duration;
1105
+ if (end) {
1106
+ position = duration;
1107
+ raw = duration * loop + duration;
1108
+ }
1109
+ if (raw === previous) {
1110
+ return;
1111
+ }
1112
+ }
1113
+ this.position = position;
1114
+ this.rawPosition = raw;
1115
+ for (var i = 0; i < this.tweens.length; i++) {
1116
+ this.tweens[i].setPosition(position, jump);
1117
+ }
1118
+ if (callback) {
1119
+ callback();
1120
+ }
1121
+ if (!skipActions) {
1122
+ runActions(this, this.duration, this.loop, previous, raw, jump, !jump && previous === -1);
1123
+ }
1124
+ };
1125
+ Timeline.prototype._runActionsRange = function _runActionsRange (start, end, jump, includeStart) {
1126
+ var position = this.position;
1127
+ for (var i = 0; i < this.tweens.length; i++) {
1128
+ this.tweens[i]._runActions(start, end, jump, includeStart);
1129
+ if (position !== this.position) {
1130
+ return true;
1131
+ }
1132
+ }
1133
+ return false;
1134
+ };
1135
+
1136
+ Object.defineProperties( Timeline.prototype, prototypeAccessors$1$1 );
1137
+ var INDEPENDENT = 'independent';
1138
+ var SINGLE_FRAME = 'single';
1139
+ var SYNCHED = 'synched';
1140
+ /**
1141
+ * createjs-compatible MovieClip. Plays its symbol's timeline from the shared
1142
+ * definition with createjs's rules: the two phases (tick: advance the
1143
+ * playhead; then resolve: write the tweens and settle the children), the
1144
+ * write rule (a tween writes only when its position changes), synched /
1145
+ * single children taking their frame from the parent's step, the reset of an
1146
+ * independent child when it comes back on the display list, and when frame
1147
+ * scripts run.
1148
+ */
1149
+ var MovieClip = /*@__PURE__*/(function (Container) {
1150
+ function MovieClip(mode, startPosition, loop, timeline, pixi) {
1151
+ var this$1$1 = this;
1152
+
1153
+ Container.call(this, pixi);
1154
+ this.currentFrame = 0;
1155
+ this.paused = false;
1156
+ this.actionsEnabled = true;
1157
+ this.autoReset = true;
1158
+ this.framerate = null;
1159
+ this._synchOffset = 0;
1160
+ this._rawPosition = -1;
1161
+ this._t = 0;
1162
+ this._framerate = null;
1163
+ /**
1164
+ * Display objects the timeline placed, with the resolve that last placed
1165
+ * them (_resolveCount at that time). One placed in an earlier resolve and
1166
+ * not in the current one is removed at its end (createjs marks every entry
1167
+ * 1 at the start of a resolve and placed ones 2: an earlier count is its 1)
1168
+ */
1169
+ this._managed = {};
1170
+ this._resolveCount = 0;
1171
+ /**
1172
+ * While a resolve can still leave the display list as it is: the index of
1173
+ * the child the next placement has to be for that (createjs moves each placed
1174
+ * child to the bottom, so in a resolve that changes nothing they come from
1175
+ * the top of the placed block down), -1 once all have come. Null when the
1176
+ * placements are done as createjs does them.
1177
+ */
1178
+ this._expected = null;
1179
+ /** The length of the placed block at the start of the resolve (the children placed last time, at the bottom) */
1180
+ this._placedBlock = 0;
1181
+ /** The frame rate the content was published with (lib.properties.fps), set on the content's symbols */
1182
+ this.contentFps = null;
1183
+ this.mode = mode || INDEPENDENT;
1184
+ this.startPosition = startPosition || 0;
1185
+ this.loop = loop === true ? -1 : (loop || 0);
1186
+ this.timeline = timeline || new Timeline(0, []);
1187
+ this._boundResolve = function () { return this$1$1._resolveState(); };
1188
+ }
1189
+
1190
+ if ( Container ) MovieClip.__proto__ = Container;
1191
+ MovieClip.prototype = Object.create( Container && Container.prototype );
1192
+ MovieClip.prototype.constructor = MovieClip;
1193
+
1194
+ var prototypeAccessors$2 = { labels: { configurable: true },currentLabel: { configurable: true },totalFrames: { configurable: true },duration: { configurable: true } };
1195
+ prototypeAccessors$2.labels.get = function () { return this.timeline.getLabels(); };
1196
+ prototypeAccessors$2.currentLabel.get = function () { return this.timeline.currentLabel; };
1197
+ prototypeAccessors$2.totalFrames.get = function () { return this.timeline.duration; };
1198
+ prototypeAccessors$2.duration.get = function () { return this.timeline.duration; };
1199
+ MovieClip.prototype.isVisible = function isVisible () {
1200
+ return !!(this.visible && this.alpha > 0 && this.scaleX !== 0 && this.scaleY !== 0);
1201
+ };
1202
+ MovieClip.prototype.play = function play () { this.paused = false; };
1203
+ MovieClip.prototype.stop = function stop () { this.paused = true; };
1204
+ MovieClip.prototype.gotoAndPlay = function gotoAndPlay (positionOrLabel) {
1205
+ this.paused = false;
1206
+ this._goto(positionOrLabel);
1207
+ };
1208
+ MovieClip.prototype.gotoAndStop = function gotoAndStop (positionOrLabel) {
1209
+ this.paused = true;
1210
+ this._goto(positionOrLabel);
1211
+ };
1212
+ MovieClip.prototype.advance = function advance (time) {
1213
+ if (this.mode !== INDEPENDENT) {
1214
+ return;
1215
+ }
1216
+ var framerate = this.framerate;
1217
+ for (var o = this.parent; o && framerate === null; o = o.parent) {
1218
+ if (o instanceof MovieClip && o.mode === INDEPENDENT) {
1219
+ framerate = o._framerate;
1220
+ }
1221
+ }
1222
+ this._framerate = framerate;
1223
+ if (!this.paused) {
1224
+ // As createjs: a missing time (undefined, not null) with a framerate gives NaN, i.e. no advance
1225
+ var frames = framerate !== null && framerate !== -1 && time !== null ? Number(time) / (1000 / framerate) + this._t : 1;
1226
+ var count = frames | 0;
1227
+ this._t = frames - count;
1228
+ while (count--) {
1229
+ this._updateTimeline(this._rawPosition + 1, false);
1230
+ }
1231
+ }
1232
+ };
1233
+ /** createjs tick phase: advance the playhead, then the children (reverse), then tick listeners */
1234
+ MovieClip.prototype._tick = function _tick (event) {
1235
+ this.advance(event ? event.delta : undefined);
1236
+ Container.prototype._tick.call(this, event);
1237
+ };
1238
+ /** createjs resolve phase (MovieClip draw / Stage update) */
1239
+ MovieClip.prototype._updateState = function _updateState () {
1240
+ if (this._rawPosition === -1 || this.mode !== INDEPENDENT) {
1241
+ this._updateTimeline(-1, false);
1242
+ }
1243
+ };
1244
+ MovieClip.prototype._goto = function _goto (positionOrLabel) {
1245
+ var position = this.timeline.resolve(positionOrLabel);
1246
+ if (position != null) {
1247
+ this._t = 0;
1248
+ this._updateTimeline(position, true);
1249
+ // The clips it placed (synched ones, ones to start over) are settled by createjs when it
1250
+ // draws: the root is to be settled before Pixi draws it, if no frame is played before
1251
+ var root = this;
1252
+ while (root.parent) {
1253
+ root = root.parent;
1254
+ }
1255
+ root._pendingResolve = true;
1256
+ }
1257
+ };
1258
+ MovieClip.prototype._reset = function _reset () {
1259
+ this._rawPosition = -1;
1260
+ this._t = this.currentFrame = 0;
1261
+ this.paused = false;
1262
+ };
1263
+ MovieClip.prototype._updateTimeline = function _updateTimeline (rawPosition, jump) {
1264
+ var synched = this.mode !== INDEPENDENT;
1265
+ var timeline = this.timeline;
1266
+ var position = rawPosition;
1267
+ if (synched) {
1268
+ position = this.startPosition + (this.mode === SINGLE_FRAME ? 0 : this._synchOffset);
1269
+ }
1270
+ if (position < 0) {
1271
+ position = 0;
1272
+ }
1273
+ if (this._rawPosition !== position || synched) {
1274
+ this._rawPosition = position;
1275
+ timeline.loop = this.loop;
1276
+ timeline.setPosition(position, synched || !this.actionsEnabled, jump, this._boundResolve);
1277
+ }
1278
+ };
1279
+ MovieClip.prototype._renderFirstFrame = function _renderFirstFrame () {
1280
+ var timeline = this.timeline;
1281
+ var raw = timeline.rawPosition;
1282
+ timeline.setPosition(0, true, true, this._boundResolve);
1283
+ timeline.rawPosition = raw;
1284
+ };
1285
+ /**
1286
+ * MovieClip._resolveState: places every tween target (and state entry) at
1287
+ * the bottom of the display list in turn, then removes the children placed
1288
+ * before and not now. The placements are skipped while they would leave the
1289
+ * display list as it is (_addManagedChild); otherwise everything is done as
1290
+ * createjs does it.
1291
+ */
1292
+ MovieClip.prototype._resolveState = function _resolveState () {
1293
+ var timeline = this.timeline;
1294
+ this.currentFrame = timeline.position;
1295
+ var current = ++this._resolveCount;
1296
+ var managed = this._managed;
1297
+ var children = this.children;
1298
+ // The children the timeline placed, from the bottom (a resolve leaves them there): a placement
1299
+ // can be skipped only for one of them (it was placed before, so it would not be reset). What
1300
+ // is above the block does not matter: createjs's placements put the placed ones below it
1301
+ var block = 0;
1302
+ while (block < children.length && managed[children[block].id] !== undefined) {
1303
+ block++;
1304
+ }
1305
+ this._placedBlock = block;
1306
+ this._expected = block - 1;
1307
+ var tweens = timeline.tweens;
1308
+ for (var i = 0; i < tweens.length; i++) {
1309
+ var tween = tweens[i];
1310
+ var target = tween.target;
1311
+ if (target !== this && !tween.passive) {
1312
+ var offset = tween._stepPosition;
1313
+ if (target instanceof DisplayObject) {
1314
+ this._addManagedChild(target, offset);
1315
+ }
1316
+ else {
1317
+ this._setState(Reflect.get(target, 'state'), tween.scope, offset);
1318
+ }
1319
+ }
1320
+ }
1321
+ // Children of the block not placed now: put the placed ones in front of them as createjs has them
1322
+ this._followCreatejs();
1323
+ for (var i$1 = children.length - 1; i$1 >= 0; i$1--) {
1324
+ var id = children[i$1].id;
1325
+ var placed = managed[id];
1326
+ // Earlier than this resolve (a resolve nested in this one, from an event, counts as now)
1327
+ if (placed !== undefined && placed < current) {
1328
+ this.removeChildAt(i$1);
1329
+ delete managed[id];
1330
+ }
1331
+ }
1332
+ };
1333
+ /**
1334
+ * Stops skipping placements: the children placed so far (the top of the
1335
+ * block, from the expected index up) are moved to the bottom as createjs's
1336
+ * placements would have left them, with no events (moves within the same
1337
+ * parent are silent in createjs).
1338
+ */
1339
+ MovieClip.prototype._followCreatejs = function _followCreatejs () {
1340
+ var this$1$1 = this;
1341
+
1342
+ var expected = this._expected;
1343
+ this._expected = null;
1344
+ if (expected === null || expected < 0) {
1345
+ return;
1346
+ }
1347
+ var children = this.children;
1348
+ var placed = children.splice(expected + 1, this._placedBlock - expected - 1);
1349
+ for (var i = placed.length - 1; i >= 0; i--) {
1350
+ children.unshift(placed[i]);
1351
+ }
1352
+ placed.forEach(function (child, index) {
1353
+ this$1$1.pixi.setChildIndex(child.pixi, index);
1354
+ });
1355
+ };
1356
+ MovieClip.prototype._setState = function _setState (state, scope, offset) {
1357
+ var this$1$1 = this;
1358
+
1359
+ if (!Array.isArray(state)) {
1360
+ return;
1361
+ }
1362
+ var loop = function ( i ) {
1363
+ var entry = state[i];
1364
+ var target = scope.stateTarget(entry);
1365
+ if (!target) {
1366
+ return;
1367
+ }
1368
+ var props = entry.props;
1369
+ if (props) {
1370
+ Object.keys(props).forEach(function (key) {
1371
+ Reflect.set(target, key, scope.value(props[key]));
1372
+ });
1373
+ }
1374
+ this$1$1._addManagedChild(target, offset);
1375
+ };
1376
+
1377
+ for (var i = state.length - 1; i >= 0; i--) loop( i );
1378
+ };
1379
+ MovieClip.prototype._addManagedChild = function _addManagedChild (child, offset) {
1380
+ if (child._off) {
1381
+ return;
1382
+ }
1383
+ var expected = this._expected;
1384
+ if (expected !== null) {
1385
+ // Moving it to the bottom would put it where it is: the next child of the block down, or
1386
+ // the child placed last (placed twice in this resolve: createjs has it at the bottom already).
1387
+ // Only what the placement records is done (it was placed before, so no reset)
1388
+ var next = expected >= 0 && this.children[expected] === child;
1389
+ if (next || (expected + 1 < this._placedBlock && this.children[expected + 1] === child)) {
1390
+ if (next) {
1391
+ this._expected = expected - 1;
1392
+ }
1393
+ if (child instanceof MovieClip) {
1394
+ child._synchOffset = offset;
1395
+ }
1396
+ this._managed[child.id] = this._resolveCount;
1397
+ return;
1398
+ }
1399
+ this._followCreatejs();
1400
+ }
1401
+ this.addChildAt(child, 0);
1402
+ if (child instanceof MovieClip) {
1403
+ child._synchOffset = offset;
1404
+ if (child.mode === INDEPENDENT && child.autoReset && !this._managed[child.id]) {
1405
+ child._reset();
1406
+ }
1407
+ }
1408
+ this._managed[child.id] = this._resolveCount;
1409
+ };
1410
+ MovieClip.prototype.toString = function toString () {
1411
+ return '[MovieClip (name=' + this.name + ')]';
1412
+ };
1413
+
1414
+ Object.defineProperties( MovieClip.prototype, prototypeAccessors$2 );
1415
+
1416
+ return MovieClip;
1417
+ }(Container));
1418
+ MovieClip.INDEPENDENT = INDEPENDENT;
1419
+ MovieClip.SINGLE_FRAME = SINGLE_FRAME;
1420
+ MovieClip.SYNCHED = SYNCHED;
1421
+
1422
+ /** Changes a geometry's reference count (Pixi 5 counts the Graphics showing it, and disposes of it at 0) */
1423
+ function addReference(geometry, delta) {
1424
+ var count = Reflect.get(geometry, 'refCount');
1425
+ Reflect.set(geometry, 'refCount', count + delta);
1426
+ }
1427
+ var PixiGraphics = /*@__PURE__*/(function (superclass) {
1428
+ function PixiGraphics() {
1429
+ superclass.apply(this, arguments);
1430
+ this.owner = null;
1431
+ }
1432
+
1433
+ if ( superclass ) PixiGraphics.__proto__ = superclass;
1434
+ PixiGraphics.prototype = Object.create( superclass && superclass.prototype );
1435
+ PixiGraphics.prototype.constructor = PixiGraphics;
1436
+ /**
1437
+ * Shows another (shared) geometry. Pixi 5 can share a geometry between
1438
+ * Graphics (new Graphics(geometry), as clone() does) but has no way to
1439
+ * change it afterwards, and does not declare the field that holds it; it is
1440
+ * set by name here, and what Pixi derives from the geometry (the batches,
1441
+ * their vertices and tint) is marked stale so it is built again.
1442
+ */
1443
+ PixiGraphics.prototype.setGeometry = function setGeometry (geometry) {
1444
+ var current = this.geometry;
1445
+ if (current === geometry) {
1446
+ return;
1447
+ }
1448
+ // The reference count (undeclared as well) keeps a shared geometry alive while shown
1449
+ addReference(current, -1);
1450
+ addReference(geometry, 1);
1451
+ Reflect.set(this, '_geometry', geometry);
1452
+ Reflect.set(this, '_transformID', -1);
1453
+ this.batchDirty = -1;
1454
+ this.batchTint = -1;
1455
+ };
1456
+ /**
1457
+ * Pixi 5's Graphics keeps the blend mode in the batches it builds, and
1458
+ * builds them again only when the geometry changes: a blend mode set later
1459
+ * would not be drawn. The batches are marked stale so they are built again.
1460
+ */
1461
+ PixiGraphics.prototype.setBlendMode = function setBlendMode (mode) {
1462
+ if (this.blendMode !== mode) {
1463
+ this.blendMode = mode;
1464
+ this.batchDirty = -1;
1465
+ }
1466
+ };
1467
+
1468
+ return PixiGraphics;
1469
+ }(PIXI__namespace.Graphics));
1470
+ var PixiSprite = /*@__PURE__*/(function (superclass) {
1471
+ function PixiSprite() {
1472
+ superclass.apply(this, arguments);
1473
+ this.owner = null;
1474
+ }
1475
+
1476
+ if ( superclass ) PixiSprite.__proto__ = superclass;
1477
+ PixiSprite.prototype = Object.create( superclass && superclass.prototype );
1478
+ PixiSprite.prototype.constructor = PixiSprite;
1479
+
1480
+ return PixiSprite;
1481
+ }(PIXI__namespace.Sprite));
1482
+ var PixiText = /*@__PURE__*/(function (superclass) {
1483
+ function PixiText() {
1484
+ superclass.apply(this, arguments);
1485
+ this.owner = null;
1486
+ }
1487
+
1488
+ if ( superclass ) PixiText.__proto__ = superclass;
1489
+ PixiText.prototype = Object.create( superclass && superclass.prototype );
1490
+ PixiText.prototype.constructor = PixiText;
1491
+
1492
+ return PixiText;
1493
+ }(PIXI__namespace.Text));
1494
+ var NAMED_COLORS = {
1495
+ black: 0x000000, white: 0xffffff, red: 0xff0000, green: 0x008000, blue: 0x0000ff,
1496
+ yellow: 0xffff00, cyan: 0x00ffff, magenta: 0xff00ff, gray: 0x808080, grey: 0x808080
1497
+ };
1498
+ /**
1499
+ * A CSS color as createjs writes it (#RGB, #RRGGBB, rgb(), rgba(), a few names).
1500
+ */
1501
+ function parseColor(value) {
1502
+ if (typeof value !== 'string') {
1503
+ return null;
1504
+ }
1505
+ var text = value.trim().toLowerCase();
1506
+ if (text.charAt(0) === '#') {
1507
+ var hex = text.slice(1);
1508
+ if (hex.length === 3) {
1509
+ hex = hex.charAt(0) + hex.charAt(0) + hex.charAt(1) + hex.charAt(1) + hex.charAt(2) + hex.charAt(2);
1510
+ }
1511
+ var color = parseInt(hex.slice(0, 6), 16);
1512
+ return isNaN(color) ? null : { color: color, alpha: 1 };
1513
+ }
1514
+ var match = /^rgba?\(([^)]*)\)$/.exec(text);
1515
+ if (match) {
1516
+ var parts = match[1].split(',').map(function (part) { return parseFloat(part); });
1517
+ var alpha = parts.length > 3 ? parts[3] : 1;
1518
+ return { color: ((parts[0] & 255) << 16) | ((parts[1] & 255) << 8) | (parts[2] & 255), alpha: alpha };
1519
+ }
1520
+ var named = NAMED_COLORS[text];
1521
+ return named === undefined ? null : { color: named, alpha: 1 };
1522
+ }
1523
+ function num(props, key) {
1524
+ var value = props[key];
1525
+ return typeof value === 'number' ? value : 0;
1526
+ }
1527
+ function isDataMap(value) {
1528
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
1529
+ }
1530
+ var LINE_CAPS = [PIXI__namespace.LINE_CAP.BUTT, PIXI__namespace.LINE_CAP.ROUND, PIXI__namespace.LINE_CAP.SQUARE];
1531
+ var LINE_JOINS = [PIXI__namespace.LINE_JOIN.MITER, PIXI__namespace.LINE_JOIN.ROUND, PIXI__namespace.LINE_JOIN.BEVEL];
1532
+ function lineCap(value) {
1533
+ if (typeof value === 'number') {
1534
+ return LINE_CAPS[value] || PIXI__namespace.LINE_CAP.BUTT;
1535
+ }
1536
+ return value === 'round' ? PIXI__namespace.LINE_CAP.ROUND : value === 'square' ? PIXI__namespace.LINE_CAP.SQUARE : PIXI__namespace.LINE_CAP.BUTT;
1537
+ }
1538
+ function lineJoin(value) {
1539
+ if (typeof value === 'number') {
1540
+ return LINE_JOINS[value] || PIXI__namespace.LINE_JOIN.MITER;
1541
+ }
1542
+ return value === 'round' ? PIXI__namespace.LINE_JOIN.ROUND : value === 'bevel' ? PIXI__namespace.LINE_JOIN.BEVEL : PIXI__namespace.LINE_JOIN.MITER;
1543
+ }
1544
+ var PATH_COMMANDS = ['MoveTo', 'LineTo', 'QuadraticCurveTo', 'BezierCurveTo', 'ArcTo', 'Arc', 'ClosePath', 'Rect', 'RoundRect', 'Circle', 'Ellipse', 'PolyStar'];
1545
+ function paintOf(style, matrix, textures) {
1546
+ var solid = parseColor(style);
1547
+ if (solid) {
1548
+ return { color: solid.color, alpha: solid.alpha, texture: null, matrix: null };
1549
+ }
1550
+ if (!isDataMap(style)) {
1551
+ return null;
1552
+ }
1553
+ if (style.type === 'bitmap') {
1554
+ var image = style.image;
1555
+ var texture$1 = null;
1556
+ if (isDataMap(image)) {
1557
+ if (typeof image.image === 'string') {
1558
+ texture$1 = textures.image(image.image);
1559
+ }
1560
+ else if (typeof image.sheet === 'string' && typeof image.frame === 'number') {
1561
+ texture$1 = textures.frame(image.sheet, image.frame);
1562
+ }
1563
+ }
1564
+ var m = isDataMap(matrix) ? new PIXI__namespace.Matrix(num(matrix, 'a'), num(matrix, 'b'), num(matrix, 'c'), num(matrix, 'd'), num(matrix, 'tx'), num(matrix, 'ty')) : null;
1565
+ return texture$1 ? { color: 0xffffff, alpha: 1, texture: texture$1, matrix: m } : null;
1566
+ }
1567
+ var gradient = gradientOf(style);
1568
+ if (!gradient) {
1569
+ return null;
1570
+ }
1571
+ var texture = gradientTexture(gradient);
1572
+ // A gradient canvas paints nothing with (a line of length 0, a circle of radius 0): nothing is drawn
1573
+ return texture ? { color: 0xffffff, alpha: 1, texture: texture, matrix: texture.toShape } : { color: 0, alpha: 0, texture: null, matrix: null };
1574
+ }
1575
+ function gradientOf(style) {
1576
+ var type = style.type;
1577
+ var colors = style.colors;
1578
+ var ratios = style.ratios;
1579
+ if ((type !== 'linear' && type !== 'radial') || !Array.isArray(colors) || !Array.isArray(ratios)) {
1580
+ return null;
1581
+ }
1582
+ return {
1583
+ type: type,
1584
+ colors: colors.map(function (color) { return String(color); }),
1585
+ ratios: ratios.map(function (ratio) { return Number(ratio); }),
1586
+ x0: num(style, 'x0'), y0: num(style, 'y0'), r0: type === 'radial' ? num(style, 'r0') : 0,
1587
+ x1: num(style, 'x1'), y1: num(style, 'y1'), r1: type === 'radial' ? num(style, 'r1') : 0
1588
+ };
1589
+ }
1590
+ /** Pixels a gradient is drawn across: along the line of a linear one, across the circles of a radial one */
1591
+ var GRADIENT_SIZE = 256;
1592
+ /**
1593
+ * A gradient drawn into a canvas by the browser's own gradient (so its
1594
+ * colors are what canvas, and createjs, paints), as a texture that Pixi's
1595
+ * Graphics fills and strokes with through a matrix. `gradient` is the
1596
+ * gradient in the shape's coordinates, `local` the same gradient in the
1597
+ * texture's pixels, and `toShape` takes texture pixels to the shape's
1598
+ * coordinates. Outside the drawn area the texture's edge pixels repeat
1599
+ * (Pixi clamps), which is how canvas pads a gradient with its end colors.
1600
+ */
1601
+ var GradientTexture = /*@__PURE__*/(function (superclass) {
1602
+ function GradientTexture(canvas, gradient, local, toShape) {
1603
+ superclass.call(this, PIXI__namespace.BaseTexture.from(canvas));
1604
+ this.gradient = gradient;
1605
+ this.local = local;
1606
+ this.toShape = toShape;
1607
+ }
1608
+
1609
+ if ( superclass ) GradientTexture.__proto__ = superclass;
1610
+ GradientTexture.prototype = Object.create( superclass && superclass.prototype );
1611
+ GradientTexture.prototype.constructor = GradientTexture;
1612
+
1613
+ return GradientTexture;
1614
+ }(PIXI__namespace.Texture));
1615
+ /** Gradient textures by their gradient, shared by every drawing that uses the same gradient */
1616
+ var gradientTextures = new Map();
1617
+ function gradientTexture(gradient) {
1618
+ var key = JSON.stringify(gradient);
1619
+ var known = gradientTextures.get(key);
1620
+ if (known !== undefined) {
1621
+ return known;
1622
+ }
1623
+ var texture = gradient.type === 'linear' ? linearGradientTexture(gradient) : radialGradientTexture(gradient);
1624
+ gradientTextures.set(key, texture);
1625
+ return texture;
1626
+ }
1627
+ function paintGradient(canvas, local) {
1628
+ var context = canvas.getContext('2d');
1629
+ if (!context) {
1630
+ return;
1631
+ }
1632
+ var paint = local.type === 'linear'
1633
+ ? context.createLinearGradient(local.x0, local.y0, local.x1, local.y1)
1634
+ : context.createRadialGradient(local.x0, local.y0, local.r0, local.x1, local.y1, local.r1);
1635
+ local.colors.forEach(function (color, i) {
1636
+ paint.addColorStop(local.ratios[i], color);
1637
+ });
1638
+ context.fillStyle = paint;
1639
+ context.fillRect(0, 0, canvas.width, canvas.height);
1640
+ }
1641
+ /**
1642
+ * A linear gradient drawn from the left edge to the right edge of a canvas
1643
+ * one pixel high. The texture's x axis runs along the gradient's line and its
1644
+ * y axis across it (every row is the same, so how far across does not matter).
1645
+ */
1646
+ function linearGradientTexture(gradient) {
1647
+ var dx = gradient.x1 - gradient.x0;
1648
+ var dy = gradient.y1 - gradient.y0;
1649
+ var length = Math.sqrt(dx * dx + dy * dy);
1650
+ if (!length) {
1651
+ return null;
1652
+ }
1653
+ var canvas = document.createElement('canvas');
1654
+ canvas.width = GRADIENT_SIZE;
1655
+ canvas.height = 1;
1656
+ var local = {
1657
+ type: 'linear', colors: gradient.colors, ratios: gradient.ratios,
1658
+ x0: 0, y0: 0, r0: 0, x1: GRADIENT_SIZE, y1: 0, r1: 0
1659
+ };
1660
+ paintGradient(canvas, local);
1661
+ var toShape = new PIXI__namespace.Matrix(dx / GRADIENT_SIZE, dy / GRADIENT_SIZE, -dy / length, dx / length, gradient.x0, gradient.y0);
1662
+ return new GradientTexture(canvas, gradient, local, toShape);
1663
+ }
1664
+ /**
1665
+ * A radial gradient drawn into a square canvas covering both of its circles,
1666
+ * scaled to fit (the mapping is a scale and a move, so the circles stay
1667
+ * circles and every point keeps its place in the gradient).
1668
+ */
1669
+ function radialGradientTexture(gradient) {
1670
+ var left = Math.min(gradient.x0 - gradient.r0, gradient.x1 - gradient.r1);
1671
+ var top = Math.min(gradient.y0 - gradient.r0, gradient.y1 - gradient.r1);
1672
+ var right = Math.max(gradient.x0 + gradient.r0, gradient.x1 + gradient.r1);
1673
+ var bottom = Math.max(gradient.y0 + gradient.r0, gradient.y1 + gradient.r1);
1674
+ var size = Math.max(right - left, bottom - top);
1675
+ if (!(size > 0) || gradient.r1 === gradient.r0 && gradient.x0 === gradient.x1 && gradient.y0 === gradient.y1) {
1676
+ return null;
1677
+ }
1678
+ var scale = GRADIENT_SIZE / size;
1679
+ var canvas = document.createElement('canvas');
1680
+ canvas.width = GRADIENT_SIZE;
1681
+ canvas.height = GRADIENT_SIZE;
1682
+ var local = {
1683
+ type: 'radial', colors: gradient.colors, ratios: gradient.ratios,
1684
+ x0: (gradient.x0 - left) * scale, y0: (gradient.y0 - top) * scale, r0: gradient.r0 * scale,
1685
+ x1: (gradient.x1 - left) * scale, y1: (gradient.y1 - top) * scale, r1: gradient.r1 * scale
1686
+ };
1687
+ paintGradient(canvas, local);
1688
+ var toShape = new PIXI__namespace.Matrix(1 / scale, 0, 0, 1 / scale, left, top);
1689
+ return new GradientTexture(canvas, gradient, local, toShape);
1690
+ }
1691
+ function drawPath(target, command) {
1692
+ var p = command.props;
1693
+ switch (command.type) {
1694
+ case 'MoveTo':
1695
+ target.moveTo(num(p, 'x'), num(p, 'y'));
1696
+ break;
1697
+ case 'LineTo':
1698
+ target.lineTo(num(p, 'x'), num(p, 'y'));
1699
+ break;
1700
+ case 'QuadraticCurveTo':
1701
+ target.quadraticCurveTo(num(p, 'cpx'), num(p, 'cpy'), num(p, 'x'), num(p, 'y'));
1702
+ break;
1703
+ case 'BezierCurveTo':
1704
+ target.bezierCurveTo(num(p, 'cp1x'), num(p, 'cp1y'), num(p, 'cp2x'), num(p, 'cp2y'), num(p, 'x'), num(p, 'y'));
1705
+ break;
1706
+ case 'ArcTo':
1707
+ target.arcTo(num(p, 'x1'), num(p, 'y1'), num(p, 'x2'), num(p, 'y2'), num(p, 'radius'));
1708
+ break;
1709
+ case 'Arc':
1710
+ target.arc(num(p, 'x'), num(p, 'y'), num(p, 'radius'), num(p, 'startAngle'), num(p, 'endAngle'), !!p.anticlockwise);
1711
+ break;
1712
+ case 'ClosePath':
1713
+ target.closePath();
1714
+ break;
1715
+ case 'Rect':
1716
+ target.drawRect(num(p, 'x'), num(p, 'y'), num(p, 'w'), num(p, 'h'));
1717
+ break;
1718
+ case 'RoundRect':
1719
+ target.drawRoundedRect(num(p, 'x'), num(p, 'y'), num(p, 'w'), num(p, 'h'), num(p, 'radiusTL'));
1720
+ break;
1721
+ case 'Circle':
1722
+ target.drawCircle(num(p, 'x'), num(p, 'y'), num(p, 'radius'));
1723
+ break;
1724
+ case 'Ellipse': {
1725
+ var w = num(p, 'w');
1726
+ var h = num(p, 'h');
1727
+ target.drawEllipse(num(p, 'x') + w / 2, num(p, 'y') + h / 2, w / 2, h / 2);
1728
+ break;
1729
+ }
1730
+ case 'PolyStar': {
1731
+ var sides = num(p, 'sides');
1732
+ var pointSize = num(p, 'pointSize');
1733
+ var radius = num(p, 'radius');
1734
+ var rotation = num(p, 'angle') / 180 * Math.PI;
1735
+ if (pointSize > 0 && pointSize < 1) {
1736
+ target.drawStar(num(p, 'x'), num(p, 'y'), sides, radius, radius * (1 - pointSize), rotation);
1737
+ }
1738
+ else {
1739
+ target.drawRegularPolygon(num(p, 'x'), num(p, 'y'), radius, sides, rotation);
1740
+ }
1741
+ break;
1742
+ }
1743
+ }
1744
+ }
1745
+ function pathSegments(commands) {
1746
+ var segments = [];
1747
+ var path = [];
1748
+ var fill = null;
1749
+ var stroke = null;
1750
+ var strokeStyle = null;
1751
+ var painted = false;
1752
+ var push = function () {
1753
+ if (path.length && (fill || stroke)) {
1754
+ segments.push({ path: path, fill: fill, stroke: stroke, strokeStyle: strokeStyle });
1755
+ }
1756
+ };
1757
+ commands.forEach(function (command) {
1758
+ if (command.type === 'BeginPath') {
1759
+ if (painted) {
1760
+ push();
1761
+ path = [];
1762
+ fill = stroke = null;
1763
+ painted = false;
1764
+ }
1765
+ return;
1766
+ }
1767
+ if (PATH_COMMANDS.indexOf(command.type) >= 0) {
1768
+ if (painted) {
1769
+ // A path after paint without BeginPath continues the same path in canvas: what is painted so far is drawn, and the path goes on
1770
+ push();
1771
+ path = path.slice();
1772
+ fill = stroke = null;
1773
+ painted = false;
1774
+ }
1775
+ path.push(command);
1776
+ return;
1777
+ }
1778
+ if (command.type === 'Fill') {
1779
+ fill = command;
1780
+ painted = true;
1781
+ }
1782
+ else if (command.type === 'Stroke') {
1783
+ stroke = command;
1784
+ painted = true;
1785
+ }
1786
+ else if (command.type === 'StrokeStyle') {
1787
+ strokeStyle = command.props;
1788
+ }
1789
+ });
1790
+ push();
1791
+ return segments;
1792
+ }
1793
+ /** A Pixi Graphics that draws a geometry once (for working out holes, and for the shared geometries) */
1794
+ var GeometryBuilder = /*@__PURE__*/(function (superclass) {
1795
+ function GeometryBuilder () {
1796
+ superclass.apply(this, arguments);
1797
+ }
1798
+
1799
+ if ( superclass ) GeometryBuilder.__proto__ = superclass;
1800
+ GeometryBuilder.prototype = Object.create( superclass && superclass.prototype );
1801
+ GeometryBuilder.prototype.constructor = GeometryBuilder;
1802
+
1803
+ GeometryBuilder.prototype.finish = function finish () {
1804
+ this.finishPoly();
1805
+ };
1806
+
1807
+ return GeometryBuilder;
1808
+ }(PIXI__namespace.Graphics));
1809
+ var emptyGraphics = null;
1810
+ /** The geometry of a shape with no drawing, shared (kept by a Graphics that is never destroyed) */
1811
+ function getEmptyGeometry() {
1812
+ if (!emptyGraphics) {
1813
+ emptyGraphics = new PIXI__namespace.Graphics();
1814
+ }
1815
+ return emptyGraphics.geometry;
1816
+ }
1817
+ /**
1818
+ * The subpaths of a filled path that cut holes: a subpath that starts inside
1819
+ * what the path's earlier subpaths cover (holes taken out) is a hole in it;
1820
+ * one that starts outside, or inside a hole, is a shape of its own. The
1821
+ * MoveTo commands that start holes are returned.
1822
+ */
1823
+ function findHoles(path) {
1824
+ var holes = [];
1825
+ var probe = new GeometryBuilder();
1826
+ probe.beginFill(0);
1827
+ var first = true;
1828
+ var inHole = false;
1829
+ path.forEach(function (command) {
1830
+ if (command.type === 'MoveTo') {
1831
+ if (!first) {
1832
+ probe.finish();
1833
+ var inside = probe.geometry.containsPoint(new PIXI__namespace.Point(num(command.props, 'x'), num(command.props, 'y')));
1834
+ if (inside) {
1835
+ holes.push(command);
1836
+ if (!inHole) {
1837
+ probe.beginHole();
1838
+ inHole = true;
1839
+ }
1840
+ }
1841
+ else if (inHole) {
1842
+ probe.endHole();
1843
+ inHole = false;
1844
+ }
1845
+ }
1846
+ first = false;
1847
+ }
1848
+ drawPath(probe, command);
1849
+ });
1850
+ probe.destroy();
1851
+ return holes;
1852
+ }
1853
+ /** Replays a path, cutting the holes (Pixi attaches a hole to the shape drawn before it) */
1854
+ function drawPathWithHoles(target, path, holes) {
1855
+ var inHole = false;
1856
+ path.forEach(function (command) {
1857
+ if (holes && command.type === 'MoveTo') {
1858
+ var hole = holes.indexOf(command) >= 0;
1859
+ if (hole && !inHole) {
1860
+ target.beginHole();
1861
+ inHole = true;
1862
+ }
1863
+ else if (!hole && inHole) {
1864
+ target.endHole();
1865
+ inHole = false;
1866
+ }
1867
+ }
1868
+ drawPath(target, command);
1869
+ });
1870
+ if (inHole) {
1871
+ target.endHole();
1872
+ }
1873
+ }
1874
+ /**
1875
+ * Draws createjs drawing commands into a Pixi Graphics. Pixi takes the paint
1876
+ * first, so each path is replayed under the paint that follows it, with the
1877
+ * holes canvas's nonzero fill would cut (holes: the MoveTo commands that
1878
+ * start holes, see Graphics.holes).
1879
+ */
1880
+ function drawCommands(target, commands, textures, holes) {
1881
+ target.clear();
1882
+ pathSegments(commands).forEach(function (segment) {
1883
+ var fill = segment.fill ? paintOf(segment.fill.props.style, segment.fill.props.matrix, textures) : null;
1884
+ var stroke = segment.stroke ? paintOf(segment.stroke.props.style, null, textures) : null;
1885
+ var strokeStyle = segment.strokeStyle;
1886
+ if (!fill && !stroke) {
1887
+ return;
1888
+ }
1889
+ if (stroke && strokeStyle) {
1890
+ target.lineTextureStyle({
1891
+ width: num(strokeStyle, 'width'),
1892
+ color: stroke.color,
1893
+ alpha: stroke.alpha,
1894
+ texture: stroke.texture || PIXI__namespace.Texture.WHITE,
1895
+ matrix: stroke.matrix || undefined,
1896
+ cap: lineCap(strokeStyle.caps),
1897
+ join: lineJoin(strokeStyle.joints),
1898
+ miterLimit: typeof strokeStyle.miterLimit === 'number' ? strokeStyle.miterLimit : 10
1899
+ });
1900
+ }
1901
+ else {
1902
+ target.lineStyle(0);
1903
+ }
1904
+ if (fill) {
1905
+ target.beginTextureFill({ texture: fill.texture || PIXI__namespace.Texture.WHITE, color: fill.color, alpha: fill.alpha, matrix: fill.matrix || undefined });
1906
+ }
1907
+ drawPathWithHoles(target, segment.path, fill ? holes || null : null);
1908
+ if (fill) {
1909
+ target.endFill();
1910
+ }
1911
+ });
1912
+ }
1913
+ /**
1914
+ * A drawing command as createjs keeps it (Graphics.MoveTo, Graphics.Fill, ...):
1915
+ * the command's own properties, with fill and stroke styles as objects whose
1916
+ * `props` are the arguments they were made with.
1917
+ */
1918
+ var GraphicsCommand = function GraphicsCommand () {};
1919
+ /** The createjs drawing command class names */
1920
+ var GRAPHICS_COMMANDS = [
1921
+ 'MoveTo', 'LineTo', 'ArcTo', 'Arc', 'QuadraticCurveTo', 'BezierCurveTo', 'Rect', 'ClosePath', 'BeginPath',
1922
+ 'Fill', 'Stroke', 'StrokeStyle', 'StrokeDash', 'RoundRect', 'Circle', 'Ellipse', 'PolyStar'
1923
+ ];
1924
+ var COMMAND_CLASSES = {};
1925
+ GRAPHICS_COMMANDS.forEach(function (type) {
1926
+ COMMAND_CLASSES[type] = /*@__PURE__*/(function (GraphicsCommand) {
1927
+ function type () {
1928
+ GraphicsCommand.apply(this, arguments);
1929
+ }if ( GraphicsCommand ) type.__proto__ = GraphicsCommand;
1930
+ type.prototype = Object.create( GraphicsCommand && GraphicsCommand.prototype );
1931
+ type.prototype.constructor = type;
1932
+
1933
+
1934
+
1935
+ return type;
1936
+ }(GraphicsCommand));
1937
+ });
1938
+ var MATRIX_KEYS = ['a', 'b', 'c', 'd', 'tx', 'ty'];
1939
+ function toCommandValue(value, assets) {
1940
+ if (Array.isArray(value)) {
1941
+ return value.map(function (v) { return toCommandValue(v, assets); });
1942
+ }
1943
+ if (!isDataMap(value)) {
1944
+ return value;
1945
+ }
1946
+ var keys = Object.keys(value);
1947
+ if (keys.length === 1 && typeof value.image === 'string') {
1948
+ return assets.imageAsset(value.image);
1949
+ }
1950
+ if (keys.length === 2 && typeof value.sheet === 'string' && typeof value.frame === 'number') {
1951
+ return assets.frameAsset(value.sheet, value.frame);
1952
+ }
1953
+ var map = {};
1954
+ if (keys.length === 6 && MATRIX_KEYS.every(function (key) { return typeof value[key] === 'number'; })) {
1955
+ MATRIX_KEYS.forEach(function (key) { map[key] = value[key]; });
1956
+ return map;
1957
+ }
1958
+ keys.forEach(function (key) { map[key] = toCommandValue(value[key], assets); });
1959
+ return map;
1960
+ }
1961
+ /**
1962
+ * Draws the path of createjs drawing commands filled, ignoring their fills
1963
+ * and strokes: the shape a createjs mask clips with (all the drawing as one
1964
+ * path, with the holes named by holes, see Graphics.maskHoles).
1965
+ */
1966
+ function drawMaskPath(target, commands, holes) {
1967
+ target.clear();
1968
+ var path = commands.filter(function (command) { return PATH_COMMANDS.indexOf(command.type) >= 0; });
1969
+ if (!path.length) {
1970
+ return;
1971
+ }
1972
+ target.beginFill(0xffffff, 1);
1973
+ drawPathWithHoles(target, path, holes || null);
1974
+ target.endFill();
1975
+ }
1976
+ /**
1977
+ * createjs-compatible Graphics holding the drawing commands of a definition.
1978
+ */
1979
+ var Graphics = function Graphics(commands, textures) {
1980
+ this._instructions = null;
1981
+ this._holes = null;
1982
+ this._maskHoles = null;
1983
+ this._geometry = null;
1984
+ this._maskGeometry = null;
1985
+ this.commands = commands;
1986
+ this.textures = textures;
1987
+ };
1988
+
1989
+ var prototypeAccessors = { instructions: { configurable: true } };
1990
+ /** The commands as createjs's command objects (made when first read) */
1991
+ prototypeAccessors.instructions.get = function () {
1992
+ if (!this._instructions) {
1993
+ var assets = this.textures;
1994
+ this._instructions = this.commands.map(function (command) {
1995
+ var CommandClass = COMMAND_CLASSES[command.type] || GraphicsCommand;
1996
+ var instruction = new CommandClass();
1997
+ Object.keys(command.props).forEach(function (key) {
1998
+ var value = toCommandValue(command.props[key], assets);
1999
+ // A gradient or bitmap style object carries its arguments as props
2000
+ Reflect.set(instruction, key, key === 'style' && value !== null && typeof value === 'object' ? { props: value } : value);
2001
+ });
2002
+ return instruction;
2003
+ });
2004
+ }
2005
+ return this._instructions;
2006
+ };
2007
+ Graphics.prototype.isEmpty = function isEmpty () {
2008
+ return !this.commands.length;
2009
+ };
2010
+ /**
2011
+ * The MoveTo commands that start holes in the filled paths (worked out once
2012
+ * per drawing and shared by every shape that shows it)
2013
+ */
2014
+ Graphics.prototype.holes = function holes () {
2015
+ if (!this._holes) {
2016
+ var holes = [];
2017
+ pathSegments(this.commands).forEach(function (segment) {
2018
+ if (segment.fill) {
2019
+ findHoles(segment.path).forEach(function (command) { return holes.push(command); });
2020
+ }
2021
+ });
2022
+ this._holes = holes;
2023
+ }
2024
+ return this._holes;
2025
+ };
2026
+ /**
2027
+ * The drawing as a Pixi geometry, drawn the first time it is asked for and
2028
+ * shared from then on by every shape that shows this drawing (a shape's
2029
+ * Pixi node must therefore not be drawn into: that would change it for all)
2030
+ */
2031
+ Graphics.prototype.geometry = function geometry () {
2032
+ if (!this._geometry) {
2033
+ var builder = new GeometryBuilder();
2034
+ drawCommands(builder, this.commands, this.textures, this.holes());
2035
+ builder.finish();
2036
+ this._geometry = builder;
2037
+ }
2038
+ return this._geometry.geometry;
2039
+ };
2040
+ /** The drawing as a mask (its path filled), shared the same way */
2041
+ Graphics.prototype.maskGeometry = function maskGeometry () {
2042
+ if (!this._maskGeometry) {
2043
+ var builder = new GeometryBuilder();
2044
+ drawMaskPath(builder, this.commands, this.maskHoles());
2045
+ builder.finish();
2046
+ this._maskGeometry = builder;
2047
+ }
2048
+ return this._maskGeometry.geometry;
2049
+ };
2050
+ /** The holes of the drawing as a mask (all of it one path) */
2051
+ Graphics.prototype.maskHoles = function maskHoles () {
2052
+ if (!this._maskHoles) {
2053
+ this._maskHoles = findHoles(this.commands.filter(function (command) { return PATH_COMMANDS.indexOf(command.type) >= 0; }));
2054
+ }
2055
+ return this._maskHoles;
2056
+ };
2057
+
2058
+ Object.defineProperties( Graphics.prototype, prototypeAccessors );
2059
+ GRAPHICS_COMMANDS.forEach(function (type) {
2060
+ Object.defineProperty(Graphics, type, { value: COMMAND_CLASSES[type], enumerable: true });
2061
+ });
2062
+ /**
2063
+ * createjs-compatible Shape on a Pixi Graphics.
2064
+ */
2065
+ var Shape = /*@__PURE__*/(function (DisplayObject) {
2066
+ function Shape(graphics) {
2067
+ var node = new PixiGraphics(graphics ? graphics.geometry() : getEmptyGeometry());
2068
+ DisplayObject.call(this, node);
2069
+ this._graphics = null;
2070
+ /** The shape as a mask (made when first used as one), a child of this shape's node */
2071
+ this._maskGraphics = null;
2072
+ this.pixiGraphics = node;
2073
+ this._graphics = graphics || null;
2074
+ }
2075
+
2076
+ if ( DisplayObject ) Shape.__proto__ = DisplayObject;
2077
+ Shape.prototype = Object.create( DisplayObject && DisplayObject.prototype );
2078
+ Shape.prototype.constructor = Shape;
2079
+
2080
+ var prototypeAccessors$1 = { graphics: { configurable: true } };
2081
+ prototypeAccessors$1.graphics.get = function () {
2082
+ return this._graphics;
2083
+ };
2084
+ prototypeAccessors$1.graphics.set = function (value) {
2085
+ if (value === this._graphics) {
2086
+ return;
2087
+ }
2088
+ this._graphics = value;
2089
+ this.pixiGraphics.setGeometry(value ? value.geometry() : getEmptyGeometry());
2090
+ if (this._maskGraphics) {
2091
+ this._maskGraphics.setGeometry(value ? value.maskGeometry() : getEmptyGeometry());
2092
+ }
2093
+ this._maskTargets.forEach(function (target) { return target._updatePixiMask(); });
2094
+ };
2095
+ Shape.prototype._clipsAsMask = function _clipsAsMask () {
2096
+ return !!(this._graphics && !this._graphics.isEmpty());
2097
+ };
2098
+ Shape.prototype._setBlendMode = function _setBlendMode (mode) {
2099
+ this.pixiGraphics.setBlendMode(mode);
2100
+ };
2101
+ /**
2102
+ * createjs clips with the shape's path alone (Graphics.drawAsPath, then
2103
+ * clip), whatever its fill and stroke; published masks are paths with no
2104
+ * fill. The mask node is that path, filled. It is a child of the shape's
2105
+ * node, so it moves with the shape (the shape's own node is not drawn while
2106
+ * it serves as a mask).
2107
+ */
2108
+ Shape.prototype._pixiMaskNode = function _pixiMaskNode () {
2109
+ var node = this._maskGraphics;
2110
+ if (!node) {
2111
+ node = this._maskGraphics = new PixiGraphics(this._graphics ? this._graphics.maskGeometry() : getEmptyGeometry());
2112
+ // Never hit by the pointer, as createjs never hits a mask
2113
+ node.hitArea = NO_HIT_AREA;
2114
+ this.pixiGraphics.addChild(node);
2115
+ }
2116
+ return node;
2117
+ };
2118
+ Shape.prototype._releaseMaskNode = function _releaseMaskNode () {
2119
+ var node = this._maskGraphics;
2120
+ if (node && !node.isMask) {
2121
+ node.renderable = false;
2122
+ }
2123
+ };
2124
+ Shape.prototype.toString = function toString () {
2125
+ return '[Shape (name=' + this.name + ')]';
2126
+ };
2127
+
2128
+ Object.defineProperties( Shape.prototype, prototypeAccessors$1 );
2129
+
2130
+ return Shape;
2131
+ }(DisplayObject));
2132
+ /**
2133
+ * createjs-compatible SpriteSheet: frames cut from an atlas image.
2134
+ */
2135
+ var SpriteSheet = function SpriteSheet(image, rects) {
2136
+ this.framerate = 0;
2137
+ this.complete = true;
2138
+ this.frames = rects.map(function (rect) { return ({ image: image, rect: new Rectangle(rect[0], rect[1], rect[2], rect[3]) }); });
2139
+ this.textures = this.frames.map(function (frame) { return new PIXI__namespace.Texture(image.texture.baseTexture, frame.rect.toPixi()); });
2140
+ };
2141
+ SpriteSheet.prototype.getFrame = function getFrame (index) {
2142
+ return this.frames[index] || null;
2143
+ };
2144
+ SpriteSheet.prototype.getNumFrames = function getNumFrames () {
2145
+ return this.frames.length;
2146
+ };
2147
+ /**
2148
+ * createjs-compatible Sprite (frame by frame from a sprite sheet).
2149
+ */
2150
+ var Sprite = /*@__PURE__*/(function (DisplayObject) {
2151
+ function Sprite(spriteSheet, frame) {
2152
+ var node = new PixiSprite(PIXI__namespace.Texture.EMPTY);
2153
+ DisplayObject.call(this, node);
2154
+ this.currentFrame = 0;
2155
+ this.paused = false;
2156
+ this.framerate = 0;
2157
+ this.pixiSprite = node;
2158
+ this.spriteSheet = spriteSheet;
2159
+ if (frame != null) {
2160
+ this.gotoAndPlay(frame);
2161
+ }
2162
+ }
2163
+
2164
+ if ( DisplayObject ) Sprite.__proto__ = DisplayObject;
2165
+ Sprite.prototype = Object.create( DisplayObject && DisplayObject.prototype );
2166
+ Sprite.prototype.constructor = Sprite;
2167
+ Sprite.prototype.play = function play () { this.paused = false; };
2168
+ Sprite.prototype.stop = function stop () { this.paused = true; };
2169
+ Sprite.prototype.gotoAndPlay = function gotoAndPlay (frame) {
2170
+ this.paused = false;
2171
+ this._goto(frame);
2172
+ };
2173
+ Sprite.prototype.gotoAndStop = function gotoAndStop (frame) {
2174
+ this.paused = true;
2175
+ this._goto(frame);
2176
+ };
2177
+ Sprite.prototype.advance = function advance () {
2178
+ var count = this.spriteSheet.getNumFrames();
2179
+ this._goto(count ? (this.currentFrame + 1) % count : 0);
2180
+ };
2181
+ Sprite.prototype._goto = function _goto (frame) {
2182
+ this.currentFrame = frame;
2183
+ var texture = this.spriteSheet.textures[frame];
2184
+ this.pixiSprite.texture = texture || PIXI__namespace.Texture.EMPTY;
2185
+ };
2186
+ Sprite.prototype._tick = function _tick (event) {
2187
+ if (!this.paused) {
2188
+ this.advance();
2189
+ }
2190
+ DisplayObject.prototype._tick.call(this, event);
2191
+ };
2192
+ Sprite.prototype._setBlendMode = function _setBlendMode (mode) {
2193
+ this.pixiSprite.blendMode = mode;
2194
+ };
2195
+ Sprite.prototype.toString = function toString () {
2196
+ return '[Sprite (name=' + this.name + ')]';
2197
+ };
2198
+
2199
+ return Sprite;
2200
+ }(DisplayObject));
2201
+ /**
2202
+ * createjs-compatible Bitmap.
2203
+ */
2204
+ var Bitmap = /*@__PURE__*/(function (DisplayObject) {
2205
+ function Bitmap(image) {
2206
+ var node = new PixiSprite(PIXI__namespace.Texture.EMPTY);
2207
+ DisplayObject.call(this, node);
2208
+ this._image = null;
2209
+ this._sourceRect = null;
2210
+ this.pixiSprite = node;
2211
+ this.image = image || null;
2212
+ }
2213
+
2214
+ if ( DisplayObject ) Bitmap.__proto__ = DisplayObject;
2215
+ Bitmap.prototype = Object.create( DisplayObject && DisplayObject.prototype );
2216
+ Bitmap.prototype.constructor = Bitmap;
2217
+
2218
+ var prototypeAccessors$2 = { image: { configurable: true },sourceRect: { configurable: true } };
2219
+ prototypeAccessors$2.image.get = function () { return this._image; };
2220
+ prototypeAccessors$2.image.set = function (value) {
2221
+ this._image = value;
2222
+ this._updateTexture();
2223
+ };
2224
+ prototypeAccessors$2.sourceRect.get = function () { return this._sourceRect; };
2225
+ prototypeAccessors$2.sourceRect.set = function (value) {
2226
+ this._sourceRect = value;
2227
+ this._updateTexture();
2228
+ };
2229
+ Bitmap.prototype._updateTexture = function _updateTexture () {
2230
+ var image = this._image;
2231
+ if (!image) {
2232
+ this.pixiSprite.texture = PIXI__namespace.Texture.EMPTY;
2233
+ return;
2234
+ }
2235
+ var rect = this._sourceRect;
2236
+ this.pixiSprite.texture = rect ? new PIXI__namespace.Texture(image.texture.baseTexture, rect.toPixi()) : image.texture;
2237
+ };
2238
+ Bitmap.prototype._setBlendMode = function _setBlendMode (mode) {
2239
+ this.pixiSprite.blendMode = mode;
2240
+ };
2241
+ Bitmap.prototype.toString = function toString () {
2242
+ return '[Bitmap (name=' + this.name + ')]';
2243
+ };
2244
+
2245
+ Object.defineProperties( Bitmap.prototype, prototypeAccessors$2 );
2246
+
2247
+ return Bitmap;
2248
+ }(DisplayObject));
2249
+ /**
2250
+ * The parts of a CSS font shorthand ("bold 20px 'Nirmala UI'").
2251
+ */
2252
+ function parseFont(font) {
2253
+ var match = /^\s*(.*?)\s*(\d+(?:\.\d+)?)px(?:\/\S+)?\s+(.+)$/.exec(font);
2254
+ if (!match) {
2255
+ return { fontStyle: 'normal', fontWeight: 'normal', fontSize: 10, fontFamily: 'sans-serif' };
2256
+ }
2257
+ var words = match[1].split(/\s+/);
2258
+ var fontStyle = 'normal';
2259
+ var fontWeight = 'normal';
2260
+ words.forEach(function (word) {
2261
+ if (word === 'italic' || word === 'oblique') {
2262
+ fontStyle = word;
2263
+ }
2264
+ else if (word === 'bold' || word === 'bolder' || word === 'lighter' || /^\d{3}$/.test(word)) {
2265
+ fontWeight = word;
2266
+ }
2267
+ });
2268
+ return { fontStyle: fontStyle, fontWeight: fontWeight, fontSize: parseFloat(match[2]), fontFamily: match[3].replace(/['"]/g, '') };
2269
+ }
2270
+ var TEXT_ANCHOR_X = { left: 0, start: 0, center: 0.5, right: 1, end: 1 };
2271
+ var TEXT_ANCHOR_Y = { top: 0, hanging: 0, middle: 0.5, alphabetic: 0.8, ideographic: 0.9, bottom: 1 };
2272
+ /**
2273
+ * The lines createjs draws a text in (Text._drawText): the text split at line
2274
+ * breaks (CR LF, CR, LF), then a line wider than lineWidth broken at whitespace
2275
+ * only, words added while they fit (a word wider than lineWidth stays whole).
2276
+ * No breaking at all when lineWidth is null.
2277
+ */
2278
+ function breakLines(text, lineWidth, measure) {
2279
+ var lines = [];
2280
+ String(text).split(/(?:\r\n|\r|\n)/).forEach(function (source) {
2281
+ var line = source;
2282
+ if (lineWidth != null && measure(line) > lineWidth) {
2283
+ var words = line.split(/(\s)/);
2284
+ line = words[0];
2285
+ var width = measure(line);
2286
+ for (var i = 1; i < words.length; i += 2) {
2287
+ var wordWidth = measure(words[i] + words[i + 1]);
2288
+ if (width + wordWidth > lineWidth) {
2289
+ lines.push(line);
2290
+ line = words[i + 1];
2291
+ width = measure(line);
2292
+ }
2293
+ else {
2294
+ line += words[i] + words[i + 1];
2295
+ width += wordWidth;
2296
+ }
2297
+ }
2298
+ }
2299
+ lines.push(line);
2300
+ });
2301
+ return lines;
2302
+ }
2303
+ /**
2304
+ * createjs-compatible Text on a Pixi Text.
2305
+ */
2306
+ var Text = /*@__PURE__*/(function (DisplayObject) {
2307
+ function Text(text, font, color) {
2308
+ var node = new PixiText('');
2309
+ // Pixi draws text into an image and places that image: at a position between pixels it is
2310
+ // blurred by sampling, where canvas (createjs) draws the glyphs sharp at any position
2311
+ node.roundPixels = true;
2312
+ DisplayObject.call(this, node);
2313
+ this._text = '';
2314
+ // As createjs: what the constructor is given, kept as given (none: null); drawing falls back to
2315
+ // 10px sans-serif and black
2316
+ this._font = null;
2317
+ this._color = null;
2318
+ this._textAlign = 'left';
2319
+ this._textBaseline = 'top';
2320
+ this._lineHeight = 0;
2321
+ this._lineWidth = null;
2322
+ this._maxWidth = null;
2323
+ this._outline = 0;
2324
+ this.pixiText = node;
2325
+ this._text = text == null ? '' : String(text);
2326
+ this._font = font == null ? null : font;
2327
+ this._color = color == null ? null : color;
2328
+ this._updateText();
2329
+ }
2330
+
2331
+ if ( DisplayObject ) Text.__proto__ = DisplayObject;
2332
+ Text.prototype = Object.create( DisplayObject && DisplayObject.prototype );
2333
+ Text.prototype.constructor = Text;
2334
+
2335
+ var prototypeAccessors$3 = { text: { configurable: true },font: { configurable: true },color: { configurable: true },textAlign: { configurable: true },textBaseline: { configurable: true },lineHeight: { configurable: true },lineWidth: { configurable: true },maxWidth: { configurable: true },outline: { configurable: true } };
2336
+ prototypeAccessors$3.text.get = function () { return this._text; };
2337
+ prototypeAccessors$3.text.set = function (value) { this._text = value; this._updateText(); };
2338
+ prototypeAccessors$3.font.get = function () { return this._font; };
2339
+ prototypeAccessors$3.font.set = function (value) { this._font = value; this._updateText(); };
2340
+ prototypeAccessors$3.color.get = function () { return this._color; };
2341
+ prototypeAccessors$3.color.set = function (value) { this._color = value; this._updateText(); };
2342
+ prototypeAccessors$3.textAlign.get = function () { return this._textAlign; };
2343
+ prototypeAccessors$3.textAlign.set = function (value) { this._textAlign = value; this._updateText(); };
2344
+ prototypeAccessors$3.textBaseline.get = function () { return this._textBaseline; };
2345
+ prototypeAccessors$3.textBaseline.set = function (value) { this._textBaseline = value; this._updateText(); };
2346
+ prototypeAccessors$3.lineHeight.get = function () { return this._lineHeight; };
2347
+ prototypeAccessors$3.lineHeight.set = function (value) { this._lineHeight = value; this._updateText(); };
2348
+ prototypeAccessors$3.lineWidth.get = function () { return this._lineWidth; };
2349
+ prototypeAccessors$3.lineWidth.set = function (value) { this._lineWidth = value; this._updateText(); };
2350
+ prototypeAccessors$3.maxWidth.get = function () { return this._maxWidth; };
2351
+ prototypeAccessors$3.maxWidth.set = function (value) { this._maxWidth = value; this._updateText(); };
2352
+ prototypeAccessors$3.outline.get = function () { return this._outline; };
2353
+ prototypeAccessors$3.outline.set = function (value) { this._outline = value; this._updateText(); };
2354
+ Text.prototype._updateText = function _updateText () {
2355
+ var node = this.pixiText;
2356
+ var font = parseFont(this._font || '10px sans-serif');
2357
+ var color = parseColor(this._color || '#000');
2358
+ var style = new PIXI__namespace.TextStyle({
2359
+ fontStyle: font.fontStyle,
2360
+ fontWeight: font.fontWeight,
2361
+ fontSize: font.fontSize,
2362
+ fontFamily: font.fontFamily,
2363
+ fill: this._outline ? 'rgba(0,0,0,0)' : (color ? color.color : 0),
2364
+ stroke: color ? color.color : 0,
2365
+ strokeThickness: this._outline || 0,
2366
+ align: this._textAlign === 'center' ? 'center' : (this._textAlign === 'right' || this._textAlign === 'end') ? 'right' : 'left',
2367
+ // Lines are broken here the way createjs breaks them, not by Pixi's word wrap
2368
+ wordWrap: false
2369
+ });
2370
+ var measure = function (line) { return PIXI__namespace.TextMetrics.measureText(line, style, false).width; };
2371
+ // createjs's line height when none is set: 1.2 times the width of an M
2372
+ style.lineHeight = this._lineHeight || 1.2 * measure('M');
2373
+ node.style = style;
2374
+ node.text = breakLines(this._text, this._lineWidth, measure).join('\n');
2375
+ var anchorX = TEXT_ANCHOR_X[this._textAlign];
2376
+ var anchorY = TEXT_ANCHOR_Y[this._textBaseline];
2377
+ node.anchor.set(anchorX === undefined ? 0 : anchorX, anchorY === undefined ? 0 : anchorY);
2378
+ };
2379
+ Text.prototype._setBlendMode = function _setBlendMode (mode) {
2380
+ this.pixiText.blendMode = mode;
2381
+ };
2382
+ Text.prototype.toString = function toString () {
2383
+ return '[Text (text=' + this._text + ')]';
2384
+ };
2385
+
2386
+ Object.defineProperties( Text.prototype, prototypeAccessors$3 );
2387
+
2388
+ return Text;
2389
+ }(DisplayObject));
2390
+ /**
2391
+ * createjs-compatible ColorFilter on a Pixi ColorMatrixFilter.
2392
+ */
2393
+ var ColorFilter = function ColorFilter(redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier, redOffset, greenOffset, blueOffset, alphaOffset) {
2394
+ this.pixiFilter = new PIXI__namespace.filters.ColorMatrixFilter();
2395
+ this._values = [
2396
+ redMultiplier == null ? 1 : redMultiplier,
2397
+ greenMultiplier == null ? 1 : greenMultiplier,
2398
+ blueMultiplier == null ? 1 : blueMultiplier,
2399
+ alphaMultiplier == null ? 1 : alphaMultiplier,
2400
+ redOffset || 0, greenOffset || 0, blueOffset || 0, alphaOffset || 0
2401
+ ];
2402
+ this._updateMatrix();
2403
+ };
2404
+
2405
+ var prototypeAccessors$4 = { redMultiplier: { configurable: true },greenMultiplier: { configurable: true },blueMultiplier: { configurable: true },alphaMultiplier: { configurable: true },redOffset: { configurable: true },greenOffset: { configurable: true },blueOffset: { configurable: true },alphaOffset: { configurable: true } };
2406
+ prototypeAccessors$4.redMultiplier.get = function () { return this._values[0]; };
2407
+ prototypeAccessors$4.redMultiplier.set = function (value) { this._set(0, value); };
2408
+ prototypeAccessors$4.greenMultiplier.get = function () { return this._values[1]; };
2409
+ prototypeAccessors$4.greenMultiplier.set = function (value) { this._set(1, value); };
2410
+ prototypeAccessors$4.blueMultiplier.get = function () { return this._values[2]; };
2411
+ prototypeAccessors$4.blueMultiplier.set = function (value) { this._set(2, value); };
2412
+ prototypeAccessors$4.alphaMultiplier.get = function () { return this._values[3]; };
2413
+ prototypeAccessors$4.alphaMultiplier.set = function (value) { this._set(3, value); };
2414
+ prototypeAccessors$4.redOffset.get = function () { return this._values[4]; };
2415
+ prototypeAccessors$4.redOffset.set = function (value) { this._set(4, value); };
2416
+ prototypeAccessors$4.greenOffset.get = function () { return this._values[5]; };
2417
+ prototypeAccessors$4.greenOffset.set = function (value) { this._set(5, value); };
2418
+ prototypeAccessors$4.blueOffset.get = function () { return this._values[6]; };
2419
+ prototypeAccessors$4.blueOffset.set = function (value) { this._set(6, value); };
2420
+ prototypeAccessors$4.alphaOffset.get = function () { return this._values[7]; };
2421
+ prototypeAccessors$4.alphaOffset.set = function (value) { this._set(7, value); };
2422
+ ColorFilter.prototype._set = function _set (index, value) {
2423
+ this._values[index] = value;
2424
+ this._updateMatrix();
2425
+ };
2426
+ ColorFilter.prototype._updateMatrix = function _updateMatrix () {
2427
+ var v = this._values;
2428
+ var m = this.pixiFilter.matrix;
2429
+ for (var i = 0; i < 20; i++) {
2430
+ m[i] = 0;
2431
+ }
2432
+ m[0] = v[0];
2433
+ m[6] = v[1];
2434
+ m[12] = v[2];
2435
+ m[18] = v[3];
2436
+ m[4] = v[4] / 255;
2437
+ m[9] = v[5] / 255;
2438
+ m[14] = v[6] / 255;
2439
+ m[19] = v[7] / 255;
2440
+ };
2441
+ ColorFilter.prototype.toString = function toString () {
2442
+ return '[ColorFilter]';
2443
+ };
2444
+
2445
+ Object.defineProperties( ColorFilter.prototype, prototypeAccessors$4 );
2446
+ /**
2447
+ * createjs-compatible ButtonHelper: sends its target to the out / over /
2448
+ * down frames on mouse events, and stops it on the out frame from the start.
2449
+ */
2450
+ var ButtonHelper = function ButtonHelper(target, outLabel, overLabel, downLabel, play, hitArea, hitLabel) {
2451
+ this._isPressed = false;
2452
+ this._isOver = false;
2453
+ this._enabled = false;
2454
+ this._originalReset = null;
2455
+ this.target = target;
2456
+ this.overLabel = overLabel == null ? 'over' : overLabel;
2457
+ this.outLabel = outLabel == null ? 'out' : outLabel;
2458
+ this.downLabel = downLabel == null ? 'down' : downLabel;
2459
+ this.play = !!play;
2460
+ target.mouseChildren = false;
2461
+ this.enabled = true;
2462
+ this.handleEvent(new Event(''));
2463
+ if (hitArea) {
2464
+ // As createjs: only a truthy label sends the hit area there (frame 0 leaves it as it is)
2465
+ if (hitLabel) {
2466
+ hitArea.actionsEnabled = false;
2467
+ hitArea.gotoAndStop(hitLabel);
2468
+ }
2469
+ target.hitArea = hitArea;
2470
+ }
2471
+ };
2472
+
2473
+ var prototypeAccessors$5 = { enabled: { configurable: true } };
2474
+ prototypeAccessors$5.enabled.get = function () { return this._enabled; };
2475
+ prototypeAccessors$5.enabled.set = function (value) {
2476
+ if (value === this._enabled) {
2477
+ return;
2478
+ }
2479
+ var target = this.target;
2480
+ this._enabled = value;
2481
+ if (value) {
2482
+ target.cursor = 'pointer';
2483
+ target.addEventListener('rollover', this);
2484
+ target.addEventListener('rollout', this);
2485
+ target.addEventListener('mousedown', this);
2486
+ target.addEventListener('pressup', this);
2487
+ // The target keeps its paused state when its timeline resets it on re-entry
2488
+ var reset = target._reset;
2489
+ this._originalReset = reset;
2490
+ target._reset = function () {
2491
+ var paused = target.paused;
2492
+ reset.call(target);
2493
+ target.paused = paused;
2494
+ };
2495
+ }
2496
+ else {
2497
+ target.cursor = null;
2498
+ target.removeEventListener('rollover', this);
2499
+ target.removeEventListener('rollout', this);
2500
+ target.removeEventListener('mousedown', this);
2501
+ target.removeEventListener('pressup', this);
2502
+ var original = this._originalReset;
2503
+ if (original) {
2504
+ target._reset = original;
2505
+ this._originalReset = null;
2506
+ }
2507
+ }
2508
+ };
2509
+ ButtonHelper.prototype.handleEvent = function handleEvent (event) {
2510
+ var type = event.type;
2511
+ var label;
2512
+ if (type === 'mousedown') {
2513
+ this._isPressed = true;
2514
+ label = this.downLabel;
2515
+ }
2516
+ else if (type === 'pressup') {
2517
+ this._isPressed = false;
2518
+ label = this._isOver ? this.overLabel : this.outLabel;
2519
+ }
2520
+ else if (type === 'rollover') {
2521
+ this._isOver = true;
2522
+ label = this._isPressed ? this.downLabel : this.overLabel;
2523
+ }
2524
+ else {
2525
+ this._isOver = false;
2526
+ label = this._isPressed ? this.overLabel : this.outLabel;
2527
+ }
2528
+ if (this.play) {
2529
+ this.target.gotoAndPlay(label);
2530
+ }
2531
+ else {
2532
+ this.target.gotoAndStop(label);
2533
+ }
2534
+ };
2535
+ ButtonHelper.prototype.toString = function toString () {
2536
+ return '[ButtonHelper]';
2537
+ };
2538
+
2539
+ Object.defineProperties( ButtonHelper.prototype, prototypeAccessors$5 );
2540
+
2541
+ /**
2542
+ * Semantic version numbers and ranges, as far as the version checks of
2543
+ * definitions and runtime content need them: versions are MAJOR.MINOR.PATCH,
2544
+ * and ranges are written as npm writes them (`1.2.3`, `1.x`, `^1.2.0`,
2545
+ * `~1.2.0`, `>=1.0.0 <2.0.0`, `0.x || 1.x`). Pre-release tags are not handled.
2546
+ */
2547
+ /** A version as its three numbers, or null when it is not MAJOR.MINOR.PATCH */
2548
+ function parseVersion(text) {
2549
+ var match = /^\s*v?(\d+)\.(\d+)\.(\d+)\s*$/.exec(text);
2550
+ return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
2551
+ }
2552
+ function compareParsed(a, b) {
2553
+ for (var i = 0; i < 3; i++) {
2554
+ if (a[i] !== b[i]) {
2555
+ return a[i] < b[i] ? -1 : 1;
2556
+ }
2557
+ }
2558
+ return 0;
2559
+ }
2560
+ /** -1, 0 or 1 as a is lower than, the same as or higher than b (both have to be versions) */
2561
+ function compareVersions(a, b) {
2562
+ var pa = parseVersion(a);
2563
+ var pb = parseVersion(b);
2564
+ if (!pa || !pb) {
2565
+ throw new Error('not a version: ' + (pa ? b : a));
2566
+ }
2567
+ return compareParsed(pa, pb);
2568
+ }
2569
+ /** A partial version (1, 1.2, 1.x, *): the numbers given, the rest left open */
2570
+ function parsePartial(text) {
2571
+ if (text === '*' || text === 'x' || text === 'X') {
2572
+ return [];
2573
+ }
2574
+ var parts = text.split('.');
2575
+ if (parts.length > 3) {
2576
+ return null;
2577
+ }
2578
+ var numbers = [];
2579
+ for (var i = 0; i < parts.length; i++) {
2580
+ var part = parts[i];
2581
+ if (part === 'x' || part === 'X' || part === '*') {
2582
+ break;
2583
+ }
2584
+ if (!/^\d+$/.test(part)) {
2585
+ return null;
2586
+ }
2587
+ numbers.push(Number(part));
2588
+ }
2589
+ return numbers;
2590
+ }
2591
+ function lowest(numbers) {
2592
+ return [numbers[0] || 0, numbers[1] || 0, numbers[2] || 0];
2593
+ }
2594
+ /** The first version above every version the given numbers start (1.2 -> 1.3.0); null for none (*) */
2595
+ function above(numbers) {
2596
+ if (numbers.length === 0) {
2597
+ return null;
2598
+ }
2599
+ if (numbers.length === 1) {
2600
+ return [numbers[0] + 1, 0, 0];
2601
+ }
2602
+ if (numbers.length === 2) {
2603
+ return [numbers[0], numbers[1] + 1, 0];
2604
+ }
2605
+ return [numbers[0], numbers[1], numbers[2] + 1];
2606
+ }
2607
+ /** The tests one word of a range stands for, or null when the word is not understood */
2608
+ function parseComparator(word) {
2609
+ var match = /^(\^|~|>=|<=|>|<|=)?(.+)$/.exec(word);
2610
+ if (!match) {
2611
+ return null;
2612
+ }
2613
+ var op = match[1] || '=';
2614
+ var numbers = parsePartial(match[2]);
2615
+ if (!numbers) {
2616
+ return null;
2617
+ }
2618
+ var low = lowest(numbers);
2619
+ var result = [];
2620
+ var atLeast = function (bound) {
2621
+ result.push({ op: '>=', bound: bound });
2622
+ };
2623
+ var below = function (bound) {
2624
+ if (bound) {
2625
+ result.push({ op: '<', bound: bound });
2626
+ }
2627
+ };
2628
+ if (op === '=') {
2629
+ atLeast(low);
2630
+ below(above(numbers));
2631
+ }
2632
+ else if (op === '^') {
2633
+ // The left-most non-zero number given stays the same (^1.2.3 <2.0.0, ^0.2.3 <0.3.0, ^0.0.3 <0.0.4)
2634
+ var fixed = 0;
2635
+ while (fixed < numbers.length - 1 && numbers[fixed] === 0) {
2636
+ fixed++;
2637
+ }
2638
+ atLeast(low);
2639
+ below(above(numbers.slice(0, fixed + 1)));
2640
+ }
2641
+ else if (op === '~') {
2642
+ atLeast(low);
2643
+ below(above(numbers.slice(0, numbers.length > 1 ? 2 : 1)));
2644
+ }
2645
+ else if (op === '>=') {
2646
+ atLeast(low);
2647
+ }
2648
+ else if (op === '>') {
2649
+ var next = above(numbers);
2650
+ if (!next) {
2651
+ return null;
2652
+ }
2653
+ atLeast(next);
2654
+ }
2655
+ else if (op === '<') {
2656
+ below(low);
2657
+ }
2658
+ else {
2659
+ // <=
2660
+ below(above(numbers));
2661
+ }
2662
+ return result;
2663
+ }
2664
+ /** Whether a version is in a range (npm's notation, see above); a range not understood throws */
2665
+ function satisfies(version, range) {
2666
+ var parsed = parseVersion(version);
2667
+ if (!parsed) {
2668
+ return false;
2669
+ }
2670
+ return range.split('||').some(function (set) {
2671
+ var words = set.trim().split(/\s+/).filter(function (word) { return word !== ''; });
2672
+ if (!words.length) {
2673
+ throw new Error('not a version range: ' + range);
2674
+ }
2675
+ return words.every(function (word) {
2676
+ var comparators = parseComparator(word);
2677
+ if (!comparators) {
2678
+ throw new Error('not a version range: ' + range);
2679
+ }
2680
+ return comparators.every(function (c) {
2681
+ var order = compareParsed(parsed, c.bound);
2682
+ return c.op === '>=' ? order >= 0 : order < 0;
2683
+ });
2684
+ });
2685
+ });
2686
+ }
2687
+ function checkVersion(version, range, known) {
2688
+ var parsed = parseVersion(version);
2689
+ if (!parsed) {
2690
+ return { error: 'no version (' + JSON.stringify(version) + ')', warning: null, newer: false };
2691
+ }
2692
+ var newer = compareVersions(version, known) > 0;
2693
+ if (!satisfies(version, range)) {
2694
+ return { error: version + ' is outside ' + range, warning: null, newer: newer };
2695
+ }
2696
+ return { error: null, warning: newer ? version + ' is newer than ' + known : null, newer: newer };
2697
+ }
2698
+
2699
+ /** The version of this package (written in from package.json when the package is built) */
2700
+ var VERSION = "0.1.1";
2701
+
2702
+ /**
2703
+ * The eases of CreateJS (createjs.Ease), computed as CreateJS computes them,
2704
+ * by name. Runtime content names the ease of an interpolated stretch of a
2705
+ * tween; the player computes the stretch's values with it once, when a symbol's
2706
+ * class is made. `get:<amount>` is Ease.get(amount) (Animate's classic ease).
2707
+ */
2708
+ function powIn(pow) {
2709
+ return function (t) { return Math.pow(t, pow); };
2710
+ }
2711
+ function powOut(pow) {
2712
+ return function (t) { return 1 - Math.pow(1 - t, pow); };
2713
+ }
2714
+ function powInOut(pow) {
2715
+ return function (t) { return ((t *= 2) < 1 ? 0.5 * Math.pow(t, pow) : 1 - 0.5 * Math.abs(Math.pow(2 - t, pow))); };
2716
+ }
2717
+ function backIn(amount) {
2718
+ return function (t) { return t * t * ((amount + 1) * t - amount); };
2719
+ }
2720
+ function backOut(amount) {
2721
+ return function (t) { return --t * t * ((amount + 1) * t + amount) + 1; };
2722
+ }
2723
+ function backInOut(amount) {
2724
+ amount *= 1.525;
2725
+ return function (t) { return ((t *= 2) < 1 ? 0.5 * (t * t * ((amount + 1) * t - amount)) : 0.5 * ((t -= 2) * t * ((amount + 1) * t + amount) + 2)); };
2726
+ }
2727
+ function elasticIn(amplitude, period) {
2728
+ var pi2 = 2 * Math.PI;
2729
+ return function (t) {
2730
+ if (t == 0 || t == 1) {
2731
+ return t;
2732
+ }
2733
+ var s = period / pi2 * Math.asin(1 / amplitude);
2734
+ return -(amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period));
2735
+ };
2736
+ }
2737
+ function elasticOut(amplitude, period) {
2738
+ var pi2 = 2 * Math.PI;
2739
+ return function (t) {
2740
+ if (t == 0 || t == 1) {
2741
+ return t;
2742
+ }
2743
+ var s = period / pi2 * Math.asin(1 / amplitude);
2744
+ return amplitude * Math.pow(2, -10 * t) * Math.sin((t - s) * pi2 / period) + 1;
2745
+ };
2746
+ }
2747
+ function elasticInOut(amplitude, period) {
2748
+ var pi2 = 2 * Math.PI;
2749
+ return function (t) {
2750
+ var s = period / pi2 * Math.asin(1 / amplitude);
2751
+ return (t *= 2) < 1
2752
+ ? -0.5 * (amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period))
2753
+ : amplitude * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * 0.5 + 1;
2754
+ };
2755
+ }
2756
+ function bounceOut(t) {
2757
+ return 1 / 2.75 > t ? 7.5625 * t * t
2758
+ : 2 / 2.75 > t ? 7.5625 * (t -= 1.5 / 2.75) * t + 0.75
2759
+ : 2.5 / 2.75 > t ? 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375
2760
+ : 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;
2761
+ }
2762
+ function bounceIn(t) {
2763
+ return 1 - bounceOut(1 - t);
2764
+ }
2765
+ /** Ease.get(amount): Animate's classic ease, amount from -1 (in) to 1 (out) */
2766
+ function classic(amount) {
2767
+ amount = amount < -1 ? -1 : amount > 1 ? 1 : amount;
2768
+ return function (t) { return (amount == 0 ? t : amount < 0 ? t * (t * -amount + 1 + amount) : t * ((2 - t) * amount + (1 - amount))); };
2769
+ }
2770
+ var EASES = {
2771
+ linear: function (t) { return t; },
2772
+ quadIn: powIn(2), quadOut: powOut(2), quadInOut: powInOut(2),
2773
+ cubicIn: powIn(3), cubicOut: powOut(3), cubicInOut: powInOut(3),
2774
+ quartIn: powIn(4), quartOut: powOut(4), quartInOut: powInOut(4),
2775
+ quintIn: powIn(5), quintOut: powOut(5), quintInOut: powInOut(5),
2776
+ sineIn: function (t) { return 1 - Math.cos(t * Math.PI / 2); },
2777
+ sineOut: function (t) { return Math.sin(t * Math.PI / 2); },
2778
+ sineInOut: function (t) { return -0.5 * (Math.cos(Math.PI * t) - 1); },
2779
+ backIn: backIn(1.7), backOut: backOut(1.7), backInOut: backInOut(1.7),
2780
+ circIn: function (t) { return -(Math.sqrt(1 - t * t) - 1); },
2781
+ circOut: function (t) { return Math.sqrt(1 - --t * t); },
2782
+ circInOut: function (t) { return ((t *= 2) < 1 ? -0.5 * (Math.sqrt(1 - t * t) - 1) : 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1)); },
2783
+ bounceIn: bounceIn, bounceOut: bounceOut,
2784
+ bounceInOut: function (t) { return (0.5 > t ? 0.5 * bounceIn(2 * t) : 0.5 * bounceOut(2 * t - 1) + 0.5); },
2785
+ elasticIn: elasticIn(1, 0.3), elasticOut: elasticOut(1, 0.3), elasticInOut: elasticInOut(1, 0.3 * 1.5)
2786
+ };
2787
+ /** The ease runtime content names (null for a name the player does not know) */
2788
+ function easeOf(id) {
2789
+ if (id.indexOf('get:') === 0) {
2790
+ return classic(Number(id.slice(4)));
2791
+ }
2792
+ return Object.prototype.hasOwnProperty.call(EASES, id) ? EASES[id] : null;
2793
+ }
2794
+
2795
+ /**
2796
+ * The data of runtime content (what the generator writes and the player reads): the definition
2797
+ * extracted by @tawaship/animate-data-converter, with every frame script
2798
+ * taken out of the data and referenced by its index in the runtime content's
2799
+ * script list (the scripts themselves are code in the runtime content), and with
2800
+ * the writes of each tween and of each instance's initial values compiled
2801
+ * into writer functions (code in the runtime content as well, referenced by index).
2802
+ * Drawings are gathered into one table for the whole content, identical
2803
+ * ones merged, and a symbol refers to them by index.
2804
+ */
2805
+ /** A drawing's commands as the player draws them, from their written form */
2806
+ function commandsOf(kinds, graphics) {
2807
+ return graphics.commands.map(function (command) {
2808
+ var kind = kinds[typeof command[0] === 'number' ? command[0] : 0];
2809
+ var props = {};
2810
+ kind[1].forEach(function (name, i) {
2811
+ props[name] = command[i + 1];
2812
+ });
2813
+ return { type: kind[0], props: props };
2814
+ });
2815
+ }
2816
+ /**
2817
+ * The pixi-animate-runtime versions whose runtime content this player plays
2818
+ * (npm's range notation). Raised when the player stops playing runtime
2819
+ * content older versions made.
2820
+ */
2821
+ var RUNTIME_CONTENT_RANGE = '0.x';
2822
+ /**
2823
+ * The values at a position of a step, as CreateJS's Tween computes them: the
2824
+ * ratio of the position in the step, eased, then each value from its start
2825
+ * toward its end (a value that is not a number, or does not change, keeps its
2826
+ * start until the eased ratio reaches 1).
2827
+ */
2828
+ function interpolated(from, to, position, length, ease) {
2829
+ var ratio = position / length;
2830
+ if (ease) {
2831
+ ratio = ease(ratio);
2832
+ }
2833
+ return from.map(function (v0, i) {
2834
+ var v1 = to[i];
2835
+ return v0 !== v1 && typeof v0 === 'number' && typeof v1 === 'number' ? v0 + (v1 - v0) * ratio : ratio >= 1 ? v1 : v0;
2836
+ });
2837
+ }
2838
+ /** A display list entry as the player uses it, from its written form */
2839
+ function stateEntryOf(entry) {
2840
+ return typeof entry === 'number' ? { target: { type: 'slot', slot: entry }, props: null } : entry;
2841
+ }
2842
+ /**
2843
+ * A tween with the values of every position: its display lists (the values of
2844
+ * its `state` prop) as entries, and its interpolated stretches computed (each
2845
+ * position of a stretch gets values of its own)
2846
+ */
2847
+ function tweenOf(data) {
2848
+ var state = data.props.indexOf('state');
2849
+ var values = data.values.map(function (frame) { return frame.map(function (value, i) {
2850
+ if (i === state && Array.isArray(value)) {
2851
+ return value.map(stateEntryOf);
2852
+ }
2853
+ return isFrameValue(value) ? value : null;
2854
+ }); });
2855
+ var frames = [];
2856
+ data.frames.forEach(function (ref) {
2857
+ if (typeof ref === 'number') {
2858
+ frames.push(ref);
2859
+ return;
2860
+ }
2861
+ var ease = easeOf(ref[3]);
2862
+ for (var position = 0; position < ref[2]; position++) {
2863
+ frames.push(values.push(interpolated(values[ref[0]], values[ref[1]], position, ref[2], ease)) - 1);
2864
+ }
2865
+ });
2866
+ return Object.assign({}, data, { values: values, frames: frames });
2867
+ }
2868
+ /** Whether a written value is a frame value as it is (all but a display list with slot indexes) */
2869
+ function isFrameValue(value) {
2870
+ return !Array.isArray(value) || value.every(function (entry) { return typeof entry !== 'number'; });
2871
+ }
2872
+ /** The values a slot's fields have when runtime content leaves them out */
2873
+ var SLOT_DEFAULTS = {
2874
+ symbol: null, mode: null, startPosition: null, loop: null, graphics: null, sprite: null, bitmap: null, text: null,
2875
+ mask: null, hitArea: null, filters: null, cache: null, button: null, filterCacheListener: false, parentSet: false,
2876
+ initWriter: null, initValues: null
2877
+ };
2878
+ /** A slot from its template (the fields left out at their defaults) and its initial values */
2879
+ function slotOf(templates, ref) {
2880
+ var template = templates[typeof ref === 'number' ? ref : ref[0]];
2881
+ return Object.assign({}, SLOT_DEFAULTS, template, { initValues: typeof ref === 'number' ? null : ref[1] });
2882
+ }
2883
+
2884
+ /**
2885
+ * Whether this player plays runtime content: an error when the version of
2886
+ * pixi-animate-runtime that generated it is outside the range the player
2887
+ * plays, a warning when it is newer than the player (it may hold what the
2888
+ * player does not know and leaves out).
2889
+ */
2890
+ function checkRuntimeContent(data) {
2891
+ var made = typeof data.runtimeVersion === 'string' ? data.runtimeVersion : '';
2892
+ var check = checkVersion(made, RUNTIME_CONTENT_RANGE, VERSION);
2893
+ var by = 'This runtime content was generated by pixi-animate-runtime ' + (made || '(no version)');
2894
+ if (check.error) {
2895
+ throw new Error(by + ', which this player (' + VERSION + ') does not play (it plays runtime content generated by ' + RUNTIME_CONTENT_RANGE + '). '
2896
+ + (check.newer ? 'Update the player.' : 'Generate the runtime content again with pixi-animate-runtime ' + VERSION + '.'));
2897
+ }
2898
+ if (check.warning) {
2899
+ console.warn(by + ', newer than this player (' + VERSION + '). What the newer version added may not play; update the player.');
2900
+ }
2901
+ }
2902
+ /**
2903
+ * The createjs-compatible names frame scripts reach as `cjs` / `createjs`.
2904
+ */
2905
+ var namespace = {
2906
+ DisplayObject: DisplayObject, Container: Container, MovieClip: MovieClip, Shape: Shape, Graphics: Graphics, Sprite: Sprite, SpriteSheet: SpriteSheet, Bitmap: Bitmap, Text: Text,
2907
+ ColorFilter: ColorFilter, ButtonHelper: ButtonHelper, Event: Event, EventDispatcher: EventDispatcher, Rectangle: Rectangle, Point: PIXI__namespace.Point
2908
+ };
2909
+ function playSound() {
2910
+ return {
2911
+ paused: false, volume: 1,
2912
+ addEventListener: function addEventListener() { }, removeEventListener: function removeEventListener() { },
2913
+ on: function on() { }, stop: function stop() { }, play: function play() { }
2914
+ };
2915
+ }
2916
+ function isMovieClipClass(content, id, value) {
2917
+ var def = content.data.symbols[id];
2918
+ return !!def && def.kind === 'movieclip';
2919
+ }
2920
+ function isSpriteClass(content, id, value) {
2921
+ var def = content.data.symbols[id];
2922
+ return !!def && def.kind === 'sprite';
2923
+ }
2924
+ function isBitmapClass(content, id, value) {
2925
+ var def = content.data.symbols[id];
2926
+ return !!def && def.kind === 'bitmap';
2927
+ }
2928
+ function toRect(rect) {
2929
+ return rect ? new Rectangle(rect.x, rect.y, rect.width, rect.height) : null;
2930
+ }
2931
+ function toRects(rects) {
2932
+ return rects ? rects.map(function (rect) { return new Rectangle(rect.x, rect.y, rect.width, rect.height); }) : null;
2933
+ }
2934
+ function numbers(value) {
2935
+ return Array.isArray(value) ? value.map(function (v) { return (typeof v === 'number' ? v : 0); }) : [0, 0, 0, 0];
2936
+ }
2937
+ /**
2938
+ * The template's AdobeAn.handleFilterCache: re-caches the instances a clip's
2939
+ * filterCacheList names while the clip is within their frame ranges.
2940
+ */
2941
+ function handleFilterCache(event) {
2942
+ if (event.paused) {
2943
+ return;
2944
+ }
2945
+ var target = event.target;
2946
+ if (!(target instanceof MovieClip) || !target.filterCacheList) {
2947
+ return;
2948
+ }
2949
+ target.filterCacheList.forEach(function (entry) {
2950
+ if (entry.startFrame <= target.currentFrame && target.currentFrame <= entry.endFrame) {
2951
+ entry.instance.cache(entry.x, entry.y, entry.w, entry.h);
2952
+ }
2953
+ });
2954
+ }
2955
+ /**
2956
+ * A content: the symbol classes built from generated data, sharing one
2957
+ * definition per symbol. Not part of the API: applications get an IContent.
2958
+ * @internal
2959
+ */
2960
+ var Content = function Content(factory, assets) {
2961
+ var this$1$1 = this;
2962
+
2963
+ this.lib = {};
2964
+ this.images = {};
2965
+ /** One Graphics per drawing of the content, shared by every symbol that shows it */
2966
+ this.graphics = [];
2967
+ this.spriteSheets = {};
2968
+ this._frameAssets = {};
2969
+ var generated = factory(namespace, namespace, this.lib, undefined, undefined, playSound);
2970
+ checkRuntimeContent(generated.data);
2971
+ this.data = generated.data;
2972
+ this.scripts = generated.scripts;
2973
+ this.writers = generated.writers;
2974
+ this.memberWriters = generated.memberWriters;
2975
+ this.data.graphics.forEach(function (def) {
2976
+ this$1$1.graphics.push(new Graphics(commandsOf(this$1$1.data.commandKinds, def), this$1$1));
2977
+ });
2978
+ this._applyImages(assets && assets.images ? assets.images : {});
2979
+ Object.keys(this.data.symbols).forEach(function (id) {
2980
+ var def = this$1$1.data.symbols[id];
2981
+ if (def.kind === 'movieclip') {
2982
+ this$1$1.lib[id] = this$1$1._movieClipClass(def);
2983
+ }
2984
+ else if (def.kind === 'sprite') {
2985
+ this$1$1.lib[id] = this$1$1._spriteClass(def);
2986
+ }
2987
+ else if (def.kind === 'bitmap') {
2988
+ this$1$1.lib[id] = this$1$1._bitmapClass(def);
2989
+ }
2990
+ });
2991
+ };
2992
+ /**
2993
+ * Sets the textures of the content's images (by manifest id) and the sprite
2994
+ * sheets cut from them. Done before any instance is made: the constructor's
2995
+ * assets, or the textures a loader read for the content afterwards.
2996
+ */
2997
+ Content.prototype._applyImages = function _applyImages (textures) {
2998
+ var this$1$1 = this;
2999
+
3000
+ this.data.images.forEach(function (entry) {
3001
+ var texture = textures[entry.id];
3002
+ this$1$1.images[entry.id] = { src: entry.src, texture: texture || PIXI__namespace.Texture.EMPTY };
3003
+ });
3004
+ this.data.spriteSheets.forEach(function (sheet) {
3005
+ var image = this$1$1.images[sheet.name] || { src: sheet.name, texture: PIXI__namespace.Texture.EMPTY };
3006
+ this$1$1.spriteSheets[sheet.name] = new SpriteSheet(image, sheet.frames.map(numbers));
3007
+ });
3008
+ };
3009
+ Content.prototype.image = function image (id) {
3010
+ var image = this.images[id];
3011
+ return image ? image.texture : null;
3012
+ };
3013
+ Content.prototype.frame = function frame (sheet, index) {
3014
+ var spriteSheet = this.spriteSheets[sheet];
3015
+ return spriteSheet ? spriteSheet.textures[index] || null : null;
3016
+ };
3017
+ Content.prototype.imageAsset = function imageAsset (id) {
3018
+ return this.images[id] || null;
3019
+ };
3020
+ /** The image a frame of a sheet is drawn into for a bitmap fill (named after the atlas and the frame) */
3021
+ Content.prototype.frameAsset = function frameAsset (sheet, index) {
3022
+ var key = sheet + '#' + index;
3023
+ var asset = this._frameAssets[key];
3024
+ if (!asset) {
3025
+ var spriteSheet = this.spriteSheets[sheet];
3026
+ var texture = spriteSheet ? spriteSheet.textures[index] : undefined;
3027
+ if (!spriteSheet || !texture) {
3028
+ return null;
3029
+ }
3030
+ asset = this._frameAssets[key] = { src: spriteSheet.frames[index].image.src + '#' + index, texture: texture };
3031
+ }
3032
+ return asset;
3033
+ };
3034
+ /**
3035
+ * An instance of a symbol for the application to place, set up as the HTML
3036
+ * template sets up the root it creates: a clip that re-caches its children's
3037
+ * color effects (it has a filterCacheList) gets the filter cache handling,
3038
+ * which published code otherwise gets from the symbol that creates it (an
3039
+ * instance made by `new lib[id]()` in a frame script gets none, as in
3040
+ * CreateJS). The handling does not change what the player draws (it draws
3041
+ * color effects without caches); it keeps the instance's state the
3042
+ * template's.
3043
+ */
3044
+ Content.prototype.create = function create (id) {
3045
+ var symbolClass = this.lib[id];
3046
+ if (!symbolClass) {
3047
+ throw new Error('no symbol "' + id + '"');
3048
+ }
3049
+ var instance = new symbolClass();
3050
+ if (instance instanceof MovieClip && instance.filterCacheList) {
3051
+ instance.addEventListener('tick', handleFilterCache);
3052
+ }
3053
+ return instance;
3054
+ };
3055
+ Content.prototype._movieClipClass = function _movieClipClass (data) {
3056
+ var content = this;
3057
+ // The slots filled in, and the display lists turned back into entries, once for the symbol, not for every instance
3058
+ var templates = this.data.slotTemplates;
3059
+ var def = Object.assign({}, data, { slots: data.slots.map(function (ref) { return slotOf(templates, ref); }), tweens: data.tweens.map(tweenOf) });
3060
+ // The symbol's drawings, from the content's table (shared with every symbol that shows the same drawing)
3061
+ var graphics = def.graphics.map(function (index) { return content.graphics[index]; });
3062
+ var fps = typeof this.data.properties.fps === 'number' ? this.data.properties.fps : null;
3063
+ var nominalBounds = toRect(def.nominalBounds);
3064
+ var frameBounds = toRects(def.frameBounds);
3065
+ return /*@__PURE__*/(function (MovieClip) {
3066
+ function anonymous(mode, startPosition, loop) {
3067
+ // Constructed with no arguments (a root, or new lib.X()): the resolved defaults
3068
+ var defaults = def.defaults;
3069
+ var noArgs = mode === undefined && startPosition === undefined && loop === undefined;
3070
+ MovieClip.call(this, noArgs && defaults ? defaults.mode : mode, noArgs && defaults ? defaults.startPosition : startPosition, noArgs && defaults ? defaults.loop : loop, new Timeline(def.duration, def.labels));
3071
+ this.contentFps = fps;
3072
+ if (nominalBounds) {
3073
+ this.nominalBounds = nominalBounds;
3074
+ }
3075
+ if (frameBounds) {
3076
+ this.frameBounds = frameBounds;
3077
+ }
3078
+ content._populate(this, def, graphics);
3079
+ }
3080
+
3081
+ if ( MovieClip ) anonymous.__proto__ = MovieClip;
3082
+ anonymous.prototype = Object.create( MovieClip && MovieClip.prototype );
3083
+ anonymous.prototype.constructor = anonymous;
3084
+
3085
+ return anonymous;
3086
+ }(MovieClip));
3087
+ };
3088
+ Content.prototype._spriteClass = function _spriteClass (def) {
3089
+ var content = this;
3090
+ var nominalBounds = toRect(def.nominalBounds);
3091
+ var frameBounds = toRects(def.frameBounds);
3092
+ return /*@__PURE__*/(function (Sprite) {
3093
+ function anonymous() {
3094
+ Sprite.call(this, content._sheet(def.sprite.sheet));
3095
+ if (nominalBounds) {
3096
+ this.nominalBounds = nominalBounds;
3097
+ }
3098
+ if (frameBounds) {
3099
+ this.frameBounds = frameBounds;
3100
+ }
3101
+ content._applySprite(this, def.sprite);
3102
+ }
3103
+
3104
+ if ( Sprite ) anonymous.__proto__ = Sprite;
3105
+ anonymous.prototype = Object.create( Sprite && Sprite.prototype );
3106
+ anonymous.prototype.constructor = anonymous;
3107
+
3108
+ return anonymous;
3109
+ }(Sprite));
3110
+ };
3111
+ Content.prototype._bitmapClass = function _bitmapClass (def) {
3112
+ var content = this;
3113
+ var nominalBounds = toRect(def.nominalBounds);
3114
+ var frameBounds = toRects(def.frameBounds);
3115
+ return /*@__PURE__*/(function (Bitmap) {
3116
+ function anonymous() {
3117
+ Bitmap.call(this, content._image(def.bitmap.image));
3118
+ if (nominalBounds) {
3119
+ this.nominalBounds = nominalBounds;
3120
+ }
3121
+ if (frameBounds) {
3122
+ this.frameBounds = frameBounds;
3123
+ }
3124
+ content._applyBitmap(this, def.bitmap);
3125
+ }
3126
+
3127
+ if ( Bitmap ) anonymous.__proto__ = Bitmap;
3128
+ anonymous.prototype = Object.create( Bitmap && Bitmap.prototype );
3129
+ anonymous.prototype.constructor = anonymous;
3130
+
3131
+ return anonymous;
3132
+ }(Bitmap));
3133
+ };
3134
+ Content.prototype._sheet = function _sheet (name) {
3135
+ var sheet = this.spriteSheets[name];
3136
+ if (!sheet) {
3137
+ throw new Error('no sprite sheet "' + name + '"');
3138
+ }
3139
+ return sheet;
3140
+ };
3141
+ Content.prototype._image = function _image (id) {
3142
+ return this.images[id] || null;
3143
+ };
3144
+ Content.prototype._applySprite = function _applySprite (sprite, def) {
3145
+ if (!def) {
3146
+ return;
3147
+ }
3148
+ sprite.spriteSheet = this._sheet(def.sheet);
3149
+ if (def.paused) {
3150
+ sprite.gotoAndStop(def.frame);
3151
+ }
3152
+ else {
3153
+ sprite.gotoAndPlay(def.frame);
3154
+ }
3155
+ };
3156
+ Content.prototype._applyBitmap = function _applyBitmap (bitmap, def) {
3157
+ if (!def) {
3158
+ return;
3159
+ }
3160
+ bitmap.image = this._image(def.image);
3161
+ bitmap.sourceRect = toRect(def.sourceRect);
3162
+ };
3163
+ Content.prototype._createSlot = function _createSlot (slot, graphics) {
3164
+ var symbol = slot.symbol;
3165
+ var symbolClass = symbol ? this.lib[symbol] : undefined;
3166
+ if (slot.kind === 'movieclip') {
3167
+ if (!symbol || !symbolClass || !isMovieClipClass(this, symbol)) {
3168
+ throw new Error('missing MovieClip symbol ' + symbol);
3169
+ }
3170
+ return new symbolClass(slot.mode, slot.startPosition, slot.loop);
3171
+ }
3172
+ if (slot.kind === 'shape') {
3173
+ return new Shape(slot.graphics === null ? null : graphics[slot.graphics]);
3174
+ }
3175
+ if (slot.kind === 'sprite') {
3176
+ var sprite;
3177
+ if (symbol && symbolClass && isSpriteClass(this, symbol)) {
3178
+ sprite = new symbolClass();
3179
+ }
3180
+ else {
3181
+ sprite = new Sprite(this._sheet(slot.sprite ? slot.sprite.sheet : ''));
3182
+ }
3183
+ this._applySprite(sprite, slot.sprite);
3184
+ return sprite;
3185
+ }
3186
+ if (slot.kind === 'bitmap') {
3187
+ var bitmap;
3188
+ if (symbol && symbolClass && isBitmapClass(this, symbol)) {
3189
+ bitmap = new symbolClass();
3190
+ }
3191
+ else {
3192
+ bitmap = new Bitmap(null);
3193
+ }
3194
+ this._applyBitmap(bitmap, slot.bitmap);
3195
+ return bitmap;
3196
+ }
3197
+ if (slot.kind === 'text') {
3198
+ var props = slot.text || {};
3199
+ var text = new Text(String(props.text == null ? '' : props.text), typeof props.font === 'string' ? props.font : undefined, typeof props.color === 'string' ? props.color : undefined);
3200
+ Object.keys(props).forEach(function (key) {
3201
+ Reflect.set(text, key, props[key]);
3202
+ });
3203
+ return text;
3204
+ }
3205
+ throw new Error('unsupported display object in the content data');
3206
+ };
3207
+ /**
3208
+ * Builds an instance of a MovieClip symbol: what the published
3209
+ * constructor builds, from the shared definition.
3210
+ */
3211
+ Content.prototype._populate = function _populate (self, def, graphics) {
3212
+ var this$1$1 = this;
3213
+
3214
+ var slots = def.slots.map(function (slot) {
3215
+ var obj = this$1$1._createSlot(slot, graphics);
3216
+ if (slot.initWriter !== null) {
3217
+ this$1$1.writers[slot.initWriter](obj, slot.initValues === null ? undefined : slot.initValues);
3218
+ }
3219
+ if (slot.parentSet) {
3220
+ obj.parent = self;
3221
+ }
3222
+ if (slot.filters) {
3223
+ obj.filters = slot.filters.map(function (filter) {
3224
+ var p = filter.props;
3225
+ var n = function (key) { var v = p[key]; return typeof v === 'number' ? v : 0; };
3226
+ return new ColorFilter(n('redMultiplier'), n('greenMultiplier'), n('blueMultiplier'), n('alphaMultiplier'), n('redOffset'), n('greenOffset'), n('blueOffset'), n('alphaOffset'));
3227
+ });
3228
+ }
3229
+ if (slot.cache) {
3230
+ var c = slot.cache;
3231
+ obj.cache(c.x, c.y, c.width, c.height, c.scale);
3232
+ }
3233
+ return obj;
3234
+ });
3235
+ var resolve = function (target) {
3236
+ if (target.type === 'self') {
3237
+ return self;
3238
+ }
3239
+ if (target.type === 'slot') {
3240
+ return slots[target.slot];
3241
+ }
3242
+ if (target.type === 'filter') {
3243
+ var filters = slots[target.slot].filters;
3244
+ return filters ? filters[target.filter] : {};
3245
+ }
3246
+ return {};
3247
+ };
3248
+ def.slots.forEach(function (slot, i) {
3249
+ var obj = slots[i];
3250
+ if (slot.mask !== null) {
3251
+ obj.mask = slots[slot.mask];
3252
+ }
3253
+ if (slot.button) {
3254
+ var b = slot.button;
3255
+ var hit = b.hit === null ? null : slots[b.hit];
3256
+ if (obj instanceof MovieClip) {
3257
+ new ButtonHelper(obj, b.out, b.over, b.down, b.play, hit instanceof MovieClip ? hit : null, b.hitFrame);
3258
+ }
3259
+ if (hit && !(hit instanceof MovieClip)) {
3260
+ obj.hitArea = hit;
3261
+ }
3262
+ }
3263
+ else if (slot.hitArea !== null) {
3264
+ obj.hitArea = slots[slot.hitArea];
3265
+ }
3266
+ if (slot.filterCacheListener) {
3267
+ obj.addEventListener('tick', handleFilterCache);
3268
+ }
3269
+ });
3270
+ if (def.filterCacheList) {
3271
+ self.filterCacheList = def.filterCacheList.map(function (entry) {
3272
+ var instance = resolve(entry.instance);
3273
+ return {
3274
+ instance: instance instanceof DisplayObject ? instance : self,
3275
+ startFrame: entry.startFrame, endFrame: entry.endFrame,
3276
+ x: entry.x, y: entry.y, w: entry.w, h: entry.h
3277
+ };
3278
+ });
3279
+ }
3280
+ if (def.memberWriter !== null) {
3281
+ this.memberWriters[def.memberWriter](self, slots);
3282
+ }
3283
+ def.unmanaged.forEach(function (index) {
3284
+ self.addChild(slots[index]);
3285
+ });
3286
+ var content = this;
3287
+ var scope = {
3288
+ stateTarget: function stateTarget(entry) {
3289
+ var target = resolve(entry.target);
3290
+ return target instanceof DisplayObject ? target : null;
3291
+ },
3292
+ value: function value(value$1) {
3293
+ if (value$1 !== null && typeof value$1 === 'object' && !Array.isArray(value$1)) {
3294
+ return graphics[value$1.graphics] || null;
3295
+ }
3296
+ return value$1;
3297
+ },
3298
+ script: function script(index) {
3299
+ return content.scripts[index];
3300
+ },
3301
+ writer: function writer(index) {
3302
+ return content.writers[index];
3303
+ }
3304
+ };
3305
+ def.tweens.forEach(function (tween) {
3306
+ self.timeline.tweens.push(new TweenState(tween, resolve(tween.target), scope, self));
3307
+ });
3308
+ self._renderFirstFrame();
3309
+ };
3310
+ /**
3311
+ * What the application gets of a content: the content itself stays out of
3312
+ * reach, the methods closing over it.
3313
+ */
3314
+ function contentInterface(content) {
3315
+ var properties = {};
3316
+ Object.keys(content.data.properties).forEach(function (key) {
3317
+ var value = content.data.properties[key];
3318
+ if (value === null || typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean') {
3319
+ properties[key] = value;
3320
+ }
3321
+ });
3322
+ var id = properties.id;
3323
+ return {
3324
+ id: typeof id === 'string' ? id : '',
3325
+ lib: content.lib,
3326
+ properties: Object.freeze(properties),
3327
+ create: function create(symbol) {
3328
+ return content.create(symbol);
3329
+ }
3330
+ };
3331
+ }
3332
+ /**
3333
+ * Plays one frame of a display tree the way createjs does on a stage update:
3334
+ * the tick phase (playheads advance, children in reverse order, tick
3335
+ * listeners), then the resolve phase (each MovieClip settles its timeline,
3336
+ * children in reverse order).
3337
+ */
3338
+ function tick(root, event) {
3339
+ root._tick(event || new Event('tick'));
3340
+ resolveState(root);
3341
+ }
3342
+ /**
3343
+ * The resolve phase alone: each MovieClip settles its timeline (children in
3344
+ * reverse order), without playing a frame.
3345
+ */
3346
+ function resolveState(node) {
3347
+ node._pendingResolve = false;
3348
+ if (node instanceof MovieClip) {
3349
+ node._updateState();
3350
+ }
3351
+ if (node instanceof Container) {
3352
+ var children = node.children;
3353
+ for (var i = children.length - 1; i >= 0; i--) {
3354
+ if (children[i] instanceof MovieClip) {
3355
+ resolveState(children[i]);
3356
+ }
3357
+ }
3358
+ }
3359
+ }
3360
+ /**
3361
+ * Settles a display tree for drawing without playing it on, as a createjs
3362
+ * stage draw shows it (MovieClip.draw settles each clip): the synched and
3363
+ * single frame clips are placed at the frame their parent gives, and a clip
3364
+ * waiting to start over (an independent clip reset when its parent placed it
3365
+ * again) is shown at its first frame the way a new clip is (no frame script,
3366
+ * its playhead left to start on the next frame, as in the template, where
3367
+ * createjs draws only after a frame). Children after their parent, in reverse
3368
+ * order as the resolve phase.
3369
+ */
3370
+ function settleForDrawing(node) {
3371
+ if (node instanceof MovieClip) {
3372
+ if (node.mode !== INDEPENDENT) {
3373
+ node._updateState();
3374
+ }
3375
+ else if (node._rawPosition === -1) {
3376
+ node._renderFirstFrame();
3377
+ }
3378
+ }
3379
+ if (node instanceof Container) {
3380
+ var children = node.children.slice();
3381
+ for (var i = children.length - 1; i >= 0; i--) {
3382
+ if (children[i] instanceof MovieClip) {
3383
+ settleForDrawing(children[i]);
3384
+ }
3385
+ }
3386
+ }
3387
+ }
3388
+
3389
+ /** The frame rate a root plays at when its content does not give one */
3390
+ var DEFAULT_FPS = 60;
3391
+ /** How many of the latest deltas the usual delta of the display is the median of */
3392
+ var DELTA_SAMPLES = 30;
3393
+ /** The share of its distance from the real time the steady clock moves by on each call */
3394
+ var PULL = 0.05;
3395
+ /**
3396
+ * Plays the content roots put on a Pixi container at their content's frame
3397
+ * rate (the rate the content was published with). AnimateContainer is a Pixi
3398
+ * container with one; a container of another framework can hold one too.
3399
+ *
3400
+ * Each handleTick call owes every root `delta x speed x fps / 60` frames
3401
+ * (delta being the ticker's: 1 per frame of a 60 fps display) and plays the
3402
+ * whole frames owed. With `smooth`, the frames played follow a steady clock
3403
+ * instead of the deltas themselves: it advances by the usual delta of the
3404
+ * display (the median of the latest ones) on every call, so that small changes
3405
+ * of the delta do not play a frame early or late (0 frames on one call and 2
3406
+ * on the next), and it is pulled toward the real time a little on every call,
3407
+ * and set to it when they are a frame apart (a frame of the display was
3408
+ * missed), so that the content keeps the real time. One frame is createjs's
3409
+ * tick phase followed by its resolve phase. The first call after a root is put
3410
+ * on only settles it on its first frame.
3411
+ */
3412
+ var AnimateController = function AnimateController(container) {
3413
+ /** Playback speed (1 is the content's own frame rate, 0 stops; a value below 0 is taken as 0) */
3414
+ this.speed = 1;
3415
+ /** Whether one call may play more than one frame (when the display runs slower than the content) */
3416
+ this.overSpeed = true;
3417
+ /** Whether frames are played by a steady clock, so that small changes of the delta do not make the playing uneven */
3418
+ this.smooth = true;
3419
+ this._targets = {};
3420
+ this._nextId = 0;
3421
+ /** The latest deltas (a ring of DELTA_SAMPLES) */
3422
+ this._deltas = [];
3423
+ this._nextDelta = 0;
3424
+ this._container = container;
3425
+ // Pixi updates the transforms of the tree before every draw: the roots a goto changed outside
3426
+ // the playing are settled then, as a createjs draw settles them (frames played meanwhile settle them first)
3427
+ var updateTransform = container.updateTransform;
3428
+ var controller = this;
3429
+ container.updateTransform = function () {
3430
+ controller._settleForDrawing();
3431
+ updateTransform.call(this);
3432
+ };
3433
+ };
3434
+ /** Settles the roots marked by a goto since they were last resolved */
3435
+ AnimateController.prototype._settleForDrawing = function _settleForDrawing () {
3436
+ var targets = this._targets;
3437
+ Object.keys(targets).forEach(function (key) {
3438
+ var target = targets[Number(key)];
3439
+ if (target && target.root._pendingResolve) {
3440
+ target.root._pendingResolve = false;
3441
+ settleForDrawing(target.root);
3442
+ }
3443
+ });
3444
+ };
3445
+ AnimateController.prototype.handleTick = function handleTick (delta) {
3446
+ var this$1$1 = this;
3447
+
3448
+ // A speed below 0 plays as 0 does (nothing is played backward): the frames owed stay where they
3449
+ // were, and the playing goes on from there once the speed is above 0 again
3450
+ var speed = Math.max(this.speed, 0);
3451
+ var d = delta * speed;
3452
+ var usual = this._usualDelta(delta) * speed;
3453
+ var targets = this._targets;
3454
+ Object.keys(targets).forEach(function (key) {
3455
+ var target = targets[Number(key)];
3456
+ if (!target) {
3457
+ return;
3458
+ }
3459
+ var fps = target.root.contentFps != null ? target.root.contentFps : DEFAULT_FPS;
3460
+ target.t += d * fps / 60;
3461
+ // The steady clock follows the real time half a step ahead, so that it sits
3462
+ // midway between whole frames, not on one (where the pull alone would move it across)
3463
+ var step = usual * fps / 60;
3464
+ var lead = Math.min(step, 1) / 2;
3465
+ if (target.isFirst) {
3466
+ target.isFirst = false;
3467
+ target.clock = target.t + lead;
3468
+ resolveState(target.root);
3469
+ return;
3470
+ }
3471
+ if (this$1$1.smooth) {
3472
+ target.clock += step;
3473
+ var behind = target.t + lead - target.clock;
3474
+ if (behind >= 1 || behind <= -1) {
3475
+ target.clock = target.t + lead;
3476
+ }
3477
+ else {
3478
+ target.clock += behind * PULL;
3479
+ }
3480
+ }
3481
+ else {
3482
+ target.clock = target.t;
3483
+ }
3484
+ var whole = Math.max(Math.floor(target.clock), 0);
3485
+ var frames = this$1$1.overSpeed ? whole : Math.min(whole, 1);
3486
+ target.t -= whole;
3487
+ target.clock -= whole;
3488
+ for (var f = 0; f < frames; f++) {
3489
+ tick(target.root);
3490
+ }
3491
+ });
3492
+ };
3493
+ /** Records a delta and gives the median of the latest ones */
3494
+ AnimateController.prototype._usualDelta = function _usualDelta (delta) {
3495
+ var deltas = this._deltas;
3496
+ deltas[this._nextDelta] = delta;
3497
+ this._nextDelta = (this._nextDelta + 1) % DELTA_SAMPLES;
3498
+ var sorted = deltas.slice().sort(function (a, b) { return a - b; });
3499
+ var middle = sorted.length >> 1;
3500
+ return sorted.length % 2 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
3501
+ };
3502
+ /** Puts a content object on the container; a MovieClip plays from then on */
3503
+ AnimateController.prototype.addCreatejs = function addCreatejs (obj) {
3504
+ this._register(obj);
3505
+ this._container.addChild(obj.pixi);
3506
+ return obj;
3507
+ };
3508
+ AnimateController.prototype.addCreatejsAt = function addCreatejsAt (obj, index) {
3509
+ this._register(obj);
3510
+ this._container.addChildAt(obj.pixi, index);
3511
+ return obj;
3512
+ };
3513
+ AnimateController.prototype.removeCreatejs = function removeCreatejs (obj) {
3514
+ this._container.removeChild(obj.pixi);
3515
+ return obj;
3516
+ };
3517
+ /**
3518
+ * A MovieClip is played while its node is on the container. Coming from
3519
+ * another parent, it starts over from its first frame.
3520
+ */
3521
+ AnimateController.prototype._register = function _register (obj) {
3522
+ var this$1$1 = this;
3523
+
3524
+ if (!(obj instanceof MovieClip)) {
3525
+ return;
3526
+ }
3527
+ var node = obj.pixi;
3528
+ var previous = node.parent;
3529
+ node.once('added', function () {
3530
+ if (node.parent !== previous) {
3531
+ obj.gotoAndPlay(0);
3532
+ }
3533
+ var id = this$1$1._nextId++;
3534
+ this$1$1._targets[id] = { root: obj, t: 0, clock: 0, isFirst: true };
3535
+ node.once('removed', function () {
3536
+ delete this$1$1._targets[id];
3537
+ });
3538
+ });
3539
+ };
3540
+ /**
3541
+ * A Pixi container that plays the content roots put on it at their
3542
+ * content's frame rate (see AnimateController).
3543
+ *
3544
+ * Call handleTick from the application's ticker:
3545
+ * `app.ticker.add(container.handleTick, container)`.
3546
+ */
3547
+ var AnimateContainer = /*@__PURE__*/(function (superclass) {
3548
+ function AnimateContainer() {
3549
+ superclass.apply(this, arguments);
3550
+ this._controller = new AnimateController(this);
3551
+ }
3552
+
3553
+ if ( superclass ) AnimateContainer.__proto__ = superclass;
3554
+ AnimateContainer.prototype = Object.create( superclass && superclass.prototype );
3555
+ AnimateContainer.prototype.constructor = AnimateContainer;
3556
+
3557
+ var prototypeAccessors = { speed: { configurable: true },overSpeed: { configurable: true },smooth: { configurable: true } };
3558
+ /** Playback speed (1 is the content's own frame rate, 0 stops; a value below 0 is taken as 0) */
3559
+ prototypeAccessors.speed.get = function () { return this._controller.speed; };
3560
+ prototypeAccessors.speed.set = function (value) { this._controller.speed = value; };
3561
+ /** Whether one call may play more than one frame (when the display runs slower than the content) */
3562
+ prototypeAccessors.overSpeed.get = function () { return this._controller.overSpeed; };
3563
+ prototypeAccessors.overSpeed.set = function (value) { this._controller.overSpeed = value; };
3564
+ /** Whether frames are played by a steady clock, so that small changes of the delta do not make the playing uneven */
3565
+ prototypeAccessors.smooth.get = function () { return this._controller.smooth; };
3566
+ prototypeAccessors.smooth.set = function (value) { this._controller.smooth = value; };
3567
+ AnimateContainer.prototype.handleTick = function handleTick (delta) {
3568
+ this._controller.handleTick(delta);
3569
+ };
3570
+ /** Puts a content object on this container; a MovieClip plays from then on */
3571
+ AnimateContainer.prototype.addCreatejs = function addCreatejs (obj) {
3572
+ return this._controller.addCreatejs(obj);
3573
+ };
3574
+ AnimateContainer.prototype.addCreatejsAt = function addCreatejsAt (obj, index) {
3575
+ return this._controller.addCreatejsAt(obj, index);
3576
+ };
3577
+ AnimateContainer.prototype.removeCreatejs = function removeCreatejs (obj) {
3578
+ return this._controller.removeCreatejs(obj);
3579
+ };
3580
+
3581
+ Object.defineProperties( AnimateContainer.prototype, prototypeAccessors );
3582
+
3583
+ return AnimateContainer;
3584
+ }(PIXI__namespace.Container));
3585
+
3586
+ /**
3587
+ * The global runtime content files register their factories in, by
3588
+ * composition id: `window.PixiAnimateRuntimeContents[id] = factory`. It is not
3589
+ * under the player's namespace, so that a runtime content file can be loaded
3590
+ * before the player, and the same file serves every player package.
3591
+ */
3592
+ var CONTENTS_GLOBAL = 'PixiAnimateRuntimeContents';
3593
+ /** The factories registered so far (none when no runtime content file was loaded) */
3594
+ function registeredContents() {
3595
+ var contents = Reflect.get(window, CONTENTS_GLOBAL);
3596
+ return contents !== null && typeof contents === 'object' ? contents : null;
3597
+ }
3598
+ function describeRegistered(contents) {
3599
+ if (!contents || !Object.keys(contents).length) {
3600
+ return 'none is loaded';
3601
+ }
3602
+ return 'loaded: ' + Object.keys(contents).map(function (id) {
3603
+ var source = Reflect.get(Reflect.get(contents, id), 'source');
3604
+ return JSON.stringify(id) + (typeof source === 'string' ? ' (' + source + ')' : '');
3605
+ }).join(', ');
3606
+ }
3607
+ /**
3608
+ * The factory a runtime content file registered under a composition id. The
3609
+ * file has to be loaded first (a script tag, or any other way).
3610
+ */
3611
+ function getContentFactory(id) {
3612
+ var contents = registeredContents();
3613
+ var found = contents ? Reflect.get(contents, id) : undefined;
3614
+ var factory = typeof found === 'function' ? found : null;
3615
+ if (!factory) {
3616
+ throw new Error('No runtime content ' + JSON.stringify(id) + ' (' + describeRegistered(contents) + '). Load its runtime content file before loading the content.');
3617
+ }
3618
+ return factory;
3619
+ }
3620
+ /**
3621
+ * A query added to a URL, keeping the queries it has (one of the same name is
3622
+ * replaced). The same as Pixim.js's utils.resolveQuery, so that both players
3623
+ * request the same URL.
3624
+ */
3625
+ function withQuery(url, name, value) {
3626
+ var parts = url.split('?');
3627
+ var kept = parts[1] ? parts[1].split('&').filter(function (query) { return query.split('=')[0] !== name; }) : [];
3628
+ kept.push(name + '=' + value);
3629
+ return parts[0] + '?' + kept.join('&');
3630
+ }
3631
+ /**
3632
+ * The URL of a content's image: its path resolved against the base path, with
3633
+ * the version added as `_fv=<version>` (the query the path already has, such as
3634
+ * the one Animate adds on every publish, stays). data: and blob: URLs are used
3635
+ * as they are. The same as Pixim.js's utils.resolveUri.
3636
+ */
3637
+ function resolveContentUrl(basepath, src, version) {
3638
+ if (src.indexOf('data:') === 0 || src.indexOf('blob:') === 0) {
3639
+ return src;
3640
+ }
3641
+ var url = PIXI__namespace.utils.url.resolve(basepath, src);
3642
+ return version === undefined || version === null || version === '' ? url : withQuery(url, '_fv', String(version));
3643
+ }
3644
+ /** The images a content loads, with their URLs */
3645
+ function imageRequests(manifest, basepath, version) {
3646
+ return manifest.map(function (entry) { return ({ id: entry.id, url: resolveContentUrl(basepath, entry.src, version) }); });
3647
+ }
3648
+ function loadContent(target, options) {
3649
+ return Promise.resolve().then(function () {
3650
+ var content = new Content(getContentFactory(target.id));
3651
+ var manifest = content.data.images.map(function (entry) { return ({ id: entry.id, src: entry.src }); });
3652
+ var handleManifest = target.options && target.options.handleManifest;
3653
+ return Promise.resolve(handleManifest ? handleManifest(manifest) : undefined).then(function () { return loadImages(target, content, imageRequests(manifest, target.basepath, options.version)); });
3654
+ });
3655
+ }
3656
+ function loadImages(target, content, requests) {
3657
+ return new Promise(function (resolve, reject) {
3658
+ if (!requests.length) {
3659
+ resolve(contentInterface(content));
3660
+ return;
3661
+ }
3662
+ var crossOrigin = !target.options || target.options.crossOrigin !== false;
3663
+ var loader = new PIXI__namespace.Loader();
3664
+ requests.forEach(function (request) {
3665
+ // Loaded as images whatever the URL looks like (a blob: URL has no extension to tell)
3666
+ loader.add({ name: request.id, url: request.url, crossOrigin: crossOrigin ? 'anonymous' : undefined, loadType: PIXI__namespace.LoaderResource.LOAD_TYPE.IMAGE });
3667
+ });
3668
+ var failed = [];
3669
+ loader.onError.add(function (error, _loader, resource) {
3670
+ failed.push(resource.url);
3671
+ });
3672
+ loader.load(function (_loader, resources) {
3673
+ if (failed.length) {
3674
+ reject(new Error('Could not load the images of runtime content ' + JSON.stringify(target.id) + ': ' + failed.join(', ')));
3675
+ return;
3676
+ }
3677
+ var textures = {};
3678
+ requests.forEach(function (request) {
3679
+ var resource = resources[request.id];
3680
+ if (resource && resource.texture) {
3681
+ textures[request.id] = resource.texture;
3682
+ }
3683
+ });
3684
+ content._applyImages(textures);
3685
+ resolve(contentInterface(content));
3686
+ });
3687
+ });
3688
+ }
3689
+ function loadContentAsync(targets, options) {
3690
+ var opts = options || {};
3691
+ if (Array.isArray(targets)) {
3692
+ return Promise.all(targets.map(function (target) { return loadContent(target, opts); }));
3693
+ }
3694
+ return loadContent(targets, opts);
3695
+ }
3696
+
3697
+ exports.AnimateContainer = AnimateContainer;
3698
+ exports.AnimateController = AnimateController;
3699
+ exports.Bitmap = Bitmap;
3700
+ exports.ButtonHelper = ButtonHelper;
3701
+ exports.CONTENTS_GLOBAL = CONTENTS_GLOBAL;
3702
+ exports.CjsTransform = CjsTransform;
3703
+ exports.ColorFilter = ColorFilter;
3704
+ exports.Container = Container;
3705
+ exports.Content = Content;
3706
+ exports.DisplayObject = DisplayObject;
3707
+ exports.Event = Event;
3708
+ exports.EventDispatcher = EventDispatcher;
3709
+ exports.GRAPHICS_COMMANDS = GRAPHICS_COMMANDS;
3710
+ exports.GradientTexture = GradientTexture;
3711
+ exports.Graphics = Graphics;
3712
+ exports.GraphicsCommand = GraphicsCommand;
3713
+ exports.INDEPENDENT = INDEPENDENT;
3714
+ exports.MovieClip = MovieClip;
3715
+ exports.PixiContainer = PixiContainer;
3716
+ exports.PixiGraphics = PixiGraphics;
3717
+ exports.PixiSprite = PixiSprite;
3718
+ exports.PixiText = PixiText;
3719
+ exports.RUNTIME_CONTENT_RANGE = RUNTIME_CONTENT_RANGE;
3720
+ exports.Rectangle = Rectangle;
3721
+ exports.SINGLE_FRAME = SINGLE_FRAME;
3722
+ exports.SYNCHED = SYNCHED;
3723
+ exports.Shape = Shape;
3724
+ exports.Sprite = Sprite;
3725
+ exports.SpriteSheet = SpriteSheet;
3726
+ exports.Text = Text;
3727
+ exports.Timeline = Timeline;
3728
+ exports.TweenState = TweenState;
3729
+ exports.VERSION = VERSION;
3730
+ exports.checkVersion = checkVersion;
3731
+ exports.compareVersions = compareVersions;
3732
+ exports.drawCommands = drawCommands;
3733
+ exports.getContentFactory = getContentFactory;
3734
+ exports.loadContentAsync = loadContentAsync;
3735
+ exports.namespace = namespace;
3736
+ exports.parseColor = parseColor;
3737
+ exports.parseVersion = parseVersion;
3738
+ exports.resolveContentUrl = resolveContentUrl;
3739
+ exports.resolveState = resolveState;
3740
+ exports.satisfies = satisfies;
3741
+ exports.tick = tick;
3742
+
3743
+ })(this.PIXI.animateRuntime = this.PIXI.animateRuntime || {}, PIXI);
3744
+ //# sourceMappingURL=pixi-animate-runtime.js.map