@esotericsoftware/spine-canvas 4.2.1 → 4.2.4

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.
@@ -52,7 +52,6 @@ var spine = (() => {
52
52
  IkConstraintTimeline: () => IkConstraintTimeline,
53
53
  IntSet: () => IntSet,
54
54
  Interpolation: () => Interpolation,
55
- JitterEffect: () => JitterEffect,
56
55
  MathUtils: () => MathUtils,
57
56
  MeshAttachment: () => MeshAttachment,
58
57
  MixBlend: () => MixBlend,
@@ -97,7 +96,6 @@ var spine = (() => {
97
96
  SlotData: () => SlotData,
98
97
  SpacingMode: () => SpacingMode,
99
98
  StringSet: () => StringSet,
100
- SwirlEffect: () => SwirlEffect,
101
99
  Texture: () => Texture,
102
100
  TextureAtlas: () => TextureAtlas,
103
101
  TextureAtlasPage: () => TextureAtlasPage,
@@ -514,9 +512,9 @@ var spine = (() => {
514
512
  super(name);
515
513
  this.id = _VertexAttachment.nextID++;
516
514
  this.bones = null;
517
- this.vertices = null;
515
+ this.vertices = [];
518
516
  this.worldVerticesLength = 0;
519
- this.timelineAttahment = this;
517
+ this.timelineAttachment = this;
520
518
  }
521
519
  computeWorldVertices(slot, start, count, worldVertices, offset, stride) {
522
520
  count = offset + (count >> 1) * stride;
@@ -585,10 +583,9 @@ var spine = (() => {
585
583
  if (this.vertices) {
586
584
  attachment.vertices = Utils.newFloatArray(this.vertices.length);
587
585
  Utils.arrayCopy(this.vertices, 0, attachment.vertices, 0, this.vertices.length);
588
- } else
589
- attachment.vertices = null;
586
+ }
590
587
  attachment.worldVerticesLength = this.worldVerticesLength;
591
- attachment.timelineAttahment = this.timelineAttahment;
588
+ attachment.timelineAttachment = this.timelineAttachment;
592
589
  }
593
590
  };
594
591
  var VertexAttachment = _VertexAttachment;
@@ -660,8 +657,8 @@ var spine = (() => {
660
657
  // spine-core/src/Animation.ts
661
658
  var Animation = class {
662
659
  constructor(name, timelines, duration) {
663
- this.timelines = null;
664
- this.timelineIds = null;
660
+ this.timelines = [];
661
+ this.timelineIds = new StringSet();
665
662
  if (!name)
666
663
  throw new Error("name cannot be null.");
667
664
  this.name = name;
@@ -672,7 +669,7 @@ var spine = (() => {
672
669
  if (!timelines)
673
670
  throw new Error("timelines cannot be null.");
674
671
  this.timelines = timelines;
675
- this.timelineIds = new StringSet();
672
+ this.timelineIds.clear();
676
673
  for (var i = 0; i < timelines.length; i++)
677
674
  this.timelineIds.addAll(timelines[i].getPropertyIds());
678
675
  }
@@ -731,8 +728,6 @@ var spine = (() => {
731
728
  };
732
729
  var Timeline = class {
733
730
  constructor(frameCount, propertyIds) {
734
- this.propertyIds = null;
735
- this.frames = null;
736
731
  this.propertyIds = propertyIds;
737
732
  this.frames = Utils.newFloatArray(frameCount * this.getFrameEntries());
738
733
  }
@@ -766,7 +761,6 @@ var spine = (() => {
766
761
  var CurveTimeline = class extends Timeline {
767
762
  constructor(frameCount, bezierCount, propertyIds) {
768
763
  super(frameCount, propertyIds);
769
- this.curves = null;
770
764
  this.curves = Utils.newFloatArray(frameCount + bezierCount * 18);
771
765
  this.curves[frameCount - 1] = 1;
772
766
  }
@@ -1826,8 +1820,6 @@ var spine = (() => {
1826
1820
  Property.deform + "|" + slotIndex + "|" + attachment.id
1827
1821
  ]);
1828
1822
  this.slotIndex = 0;
1829
- this.attachment = null;
1830
- this.vertices = null;
1831
1823
  this.slotIndex = slotIndex;
1832
1824
  this.attachment = attachment;
1833
1825
  this.vertices = new Array(frameCount);
@@ -1890,7 +1882,9 @@ var spine = (() => {
1890
1882
  if (!slot.bone.active)
1891
1883
  return;
1892
1884
  let slotAttachment = slot.getAttachment();
1893
- if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.timelineAttahment != this.attachment)
1885
+ if (!slotAttachment)
1886
+ return;
1887
+ if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.timelineAttachment != this.attachment)
1894
1888
  return;
1895
1889
  let deform = slot.deform;
1896
1890
  if (deform.length == 0)
@@ -2044,7 +2038,6 @@ var spine = (() => {
2044
2038
  var _EventTimeline = class extends Timeline {
2045
2039
  constructor(frameCount) {
2046
2040
  super(frameCount, _EventTimeline.propertyIds);
2047
- this.events = null;
2048
2041
  this.events = new Array(frameCount);
2049
2042
  }
2050
2043
  getFrameCount() {
@@ -2087,7 +2080,6 @@ var spine = (() => {
2087
2080
  var _DrawOrderTimeline = class extends Timeline {
2088
2081
  constructor(frameCount) {
2089
2082
  super(frameCount, _DrawOrderTimeline.propertyIds);
2090
- this.drawOrders = null;
2091
2083
  this.drawOrders = new Array(frameCount);
2092
2084
  }
2093
2085
  getFrameCount() {
@@ -2108,7 +2100,8 @@ var spine = (() => {
2108
2100
  Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
2109
2101
  return;
2110
2102
  }
2111
- let drawOrderToSetupIndex = this.drawOrders[Timeline.search1(this.frames, time)];
2103
+ let idx = Timeline.search1(this.frames, time);
2104
+ let drawOrderToSetupIndex = this.drawOrders[idx];
2112
2105
  if (!drawOrderToSetupIndex)
2113
2106
  Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
2114
2107
  else {
@@ -2470,7 +2463,7 @@ var spine = (() => {
2470
2463
  let slotAttachment = slot.attachment;
2471
2464
  let attachment = this.attachment;
2472
2465
  if (slotAttachment != attachment) {
2473
- if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.timelineAttahment != attachment)
2466
+ if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.timelineAttachment != attachment)
2474
2467
  return;
2475
2468
  }
2476
2469
  let frames = this.frames;
@@ -2483,6 +2476,8 @@ var spine = (() => {
2483
2476
  let before = frames[i];
2484
2477
  let modeAndIndex = frames[i + _SequenceTimeline.MODE];
2485
2478
  let delay = frames[i + _SequenceTimeline.DELAY];
2479
+ if (!this.attachment.sequence)
2480
+ return;
2486
2481
  let index = modeAndIndex >> 4, count = this.attachment.sequence.regions.length;
2487
2482
  let mode = SequenceModeValues[modeAndIndex & 15];
2488
2483
  if (mode != SequenceMode.hold) {
@@ -2496,7 +2491,7 @@ var spine = (() => {
2496
2491
  break;
2497
2492
  case SequenceMode.pingpong: {
2498
2493
  let n = (count << 1) - 2;
2499
- index %= n;
2494
+ index = n == 0 ? 0 : index % n;
2500
2495
  if (index >= count)
2501
2496
  index = n - index;
2502
2497
  break;
@@ -2509,7 +2504,7 @@ var spine = (() => {
2509
2504
  break;
2510
2505
  case SequenceMode.pingpongReverse: {
2511
2506
  let n = (count << 1) - 2;
2512
- index = (index + count - 1) % n;
2507
+ index = n == 0 ? 0 : (index + count - 1) % n;
2513
2508
  if (index >= count)
2514
2509
  index = n - index;
2515
2510
  }
@@ -2524,9 +2519,8 @@ var spine = (() => {
2524
2519
  SequenceTimeline.DELAY = 2;
2525
2520
 
2526
2521
  // spine-core/src/AnimationState.ts
2527
- var AnimationState = class {
2522
+ var _AnimationState = class {
2528
2523
  constructor(data) {
2529
- this.data = null;
2530
2524
  this.tracks = new Array();
2531
2525
  this.timeScale = 1;
2532
2526
  this.unkeyedState = 0;
@@ -2539,9 +2533,7 @@ var spine = (() => {
2539
2533
  this.data = data;
2540
2534
  }
2541
2535
  static emptyAnimation() {
2542
- if (!_emptyAnimation)
2543
- _emptyAnimation = new Animation("<empty>", [], 0);
2544
- return _emptyAnimation;
2536
+ return _AnimationState._emptyAnimation;
2545
2537
  }
2546
2538
  update(delta) {
2547
2539
  delta *= this.timeScale;
@@ -2974,13 +2966,13 @@ var spine = (() => {
2974
2966
  return entry;
2975
2967
  }
2976
2968
  setEmptyAnimation(trackIndex, mixDuration = 0) {
2977
- let entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation(), false);
2969
+ let entry = this.setAnimationWith(trackIndex, _AnimationState.emptyAnimation(), false);
2978
2970
  entry.mixDuration = mixDuration;
2979
2971
  entry.trackEnd = mixDuration;
2980
2972
  return entry;
2981
2973
  }
2982
2974
  addEmptyAnimation(trackIndex, mixDuration = 0, delay = 0) {
2983
- let entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation(), false, delay);
2975
+ let entry = this.addAnimationWith(trackIndex, _AnimationState.emptyAnimation(), false, delay);
2984
2976
  if (delay <= 0)
2985
2977
  entry.delay += entry.mixDuration - mixDuration;
2986
2978
  entry.mixDuration = mixDuration;
@@ -3119,6 +3111,8 @@ var spine = (() => {
3119
3111
  this.queue.clear();
3120
3112
  }
3121
3113
  };
3114
+ var AnimationState = _AnimationState;
3115
+ AnimationState._emptyAnimation = new Animation("<empty>", [], 0);
3122
3116
  var TrackEntry = class {
3123
3117
  constructor() {
3124
3118
  this.animation = null;
@@ -3200,7 +3194,6 @@ var spine = (() => {
3200
3194
  constructor(animState) {
3201
3195
  this.objects = [];
3202
3196
  this.drainDisabled = false;
3203
- this.animState = null;
3204
3197
  this.animState = animState;
3205
3198
  }
3206
3199
  start(entry) {
@@ -3243,45 +3236,57 @@ var spine = (() => {
3243
3236
  case EventType.start:
3244
3237
  if (entry.listener && entry.listener.start)
3245
3238
  entry.listener.start(entry);
3246
- for (let ii = 0; ii < listeners.length; ii++)
3247
- if (listeners[ii].start)
3248
- listeners[ii].start(entry);
3239
+ for (let ii = 0; ii < listeners.length; ii++) {
3240
+ let listener = listeners[ii];
3241
+ if (listener.start)
3242
+ listener.start(entry);
3243
+ }
3249
3244
  break;
3250
3245
  case EventType.interrupt:
3251
3246
  if (entry.listener && entry.listener.interrupt)
3252
3247
  entry.listener.interrupt(entry);
3253
- for (let ii = 0; ii < listeners.length; ii++)
3254
- if (listeners[ii].interrupt)
3255
- listeners[ii].interrupt(entry);
3248
+ for (let ii = 0; ii < listeners.length; ii++) {
3249
+ let listener = listeners[ii];
3250
+ if (listener.interrupt)
3251
+ listener.interrupt(entry);
3252
+ }
3256
3253
  break;
3257
3254
  case EventType.end:
3258
3255
  if (entry.listener && entry.listener.end)
3259
3256
  entry.listener.end(entry);
3260
- for (let ii = 0; ii < listeners.length; ii++)
3261
- if (listeners[ii].end)
3262
- listeners[ii].end(entry);
3257
+ for (let ii = 0; ii < listeners.length; ii++) {
3258
+ let listener = listeners[ii];
3259
+ if (listener.end)
3260
+ listener.end(entry);
3261
+ }
3263
3262
  case EventType.dispose:
3264
3263
  if (entry.listener && entry.listener.dispose)
3265
3264
  entry.listener.dispose(entry);
3266
- for (let ii = 0; ii < listeners.length; ii++)
3267
- if (listeners[ii].dispose)
3268
- listeners[ii].dispose(entry);
3265
+ for (let ii = 0; ii < listeners.length; ii++) {
3266
+ let listener = listeners[ii];
3267
+ if (listener.dispose)
3268
+ listener.dispose(entry);
3269
+ }
3269
3270
  this.animState.trackEntryPool.free(entry);
3270
3271
  break;
3271
3272
  case EventType.complete:
3272
3273
  if (entry.listener && entry.listener.complete)
3273
3274
  entry.listener.complete(entry);
3274
- for (let ii = 0; ii < listeners.length; ii++)
3275
- if (listeners[ii].complete)
3276
- listeners[ii].complete(entry);
3275
+ for (let ii = 0; ii < listeners.length; ii++) {
3276
+ let listener = listeners[ii];
3277
+ if (listener.complete)
3278
+ listener.complete(entry);
3279
+ }
3277
3280
  break;
3278
3281
  case EventType.event:
3279
3282
  let event = objects[i++ + 2];
3280
3283
  if (entry.listener && entry.listener.event)
3281
3284
  entry.listener.event(entry, event);
3282
- for (let ii = 0; ii < listeners.length; ii++)
3283
- if (listeners[ii].event)
3284
- listeners[ii].event(entry, event);
3285
+ for (let ii = 0; ii < listeners.length; ii++) {
3286
+ let listener = listeners[ii];
3287
+ if (listener.event)
3288
+ listener.event(entry, event);
3289
+ }
3285
3290
  break;
3286
3291
  }
3287
3292
  }
@@ -3322,12 +3327,10 @@ var spine = (() => {
3322
3327
  var HOLD_MIX = 4;
3323
3328
  var SETUP = 1;
3324
3329
  var CURRENT = 2;
3325
- var _emptyAnimation = null;
3326
3330
 
3327
3331
  // spine-core/src/AnimationStateData.ts
3328
3332
  var AnimationStateData = class {
3329
3333
  constructor(skeletonData) {
3330
- this.skeletonData = null;
3331
3334
  this.animationToMixTime = {};
3332
3335
  this.defaultMix = 0;
3333
3336
  if (!skeletonData)
@@ -3444,65 +3447,63 @@ var spine = (() => {
3444
3447
  this.regions = new Array();
3445
3448
  let reader = new TextureAtlasReader(atlasText);
3446
3449
  let entry = new Array(4);
3447
- let page = null;
3448
- let region = null;
3449
3450
  let pageFields = {};
3450
- pageFields["size"] = () => {
3451
- page.width = parseInt(entry[1]);
3452
- page.height = parseInt(entry[2]);
3451
+ pageFields["size"] = (page2) => {
3452
+ page2.width = parseInt(entry[1]);
3453
+ page2.height = parseInt(entry[2]);
3453
3454
  };
3454
3455
  pageFields["format"] = () => {
3455
3456
  };
3456
- pageFields["filter"] = () => {
3457
- page.minFilter = Utils.enumValue(TextureFilter, entry[1]);
3458
- page.magFilter = Utils.enumValue(TextureFilter, entry[2]);
3457
+ pageFields["filter"] = (page2) => {
3458
+ page2.minFilter = Utils.enumValue(TextureFilter, entry[1]);
3459
+ page2.magFilter = Utils.enumValue(TextureFilter, entry[2]);
3459
3460
  };
3460
- pageFields["repeat"] = () => {
3461
+ pageFields["repeat"] = (page2) => {
3461
3462
  if (entry[1].indexOf("x") != -1)
3462
- page.uWrap = TextureWrap.Repeat;
3463
+ page2.uWrap = TextureWrap.Repeat;
3463
3464
  if (entry[1].indexOf("y") != -1)
3464
- page.vWrap = TextureWrap.Repeat;
3465
+ page2.vWrap = TextureWrap.Repeat;
3465
3466
  };
3466
- pageFields["pma"] = () => {
3467
- page.pma = entry[1] == "true";
3467
+ pageFields["pma"] = (page2) => {
3468
+ page2.pma = entry[1] == "true";
3468
3469
  };
3469
3470
  var regionFields = {};
3470
- regionFields["xy"] = () => {
3471
+ regionFields["xy"] = (region) => {
3471
3472
  region.x = parseInt(entry[1]);
3472
3473
  region.y = parseInt(entry[2]);
3473
3474
  };
3474
- regionFields["size"] = () => {
3475
+ regionFields["size"] = (region) => {
3475
3476
  region.width = parseInt(entry[1]);
3476
3477
  region.height = parseInt(entry[2]);
3477
3478
  };
3478
- regionFields["bounds"] = () => {
3479
+ regionFields["bounds"] = (region) => {
3479
3480
  region.x = parseInt(entry[1]);
3480
3481
  region.y = parseInt(entry[2]);
3481
3482
  region.width = parseInt(entry[3]);
3482
3483
  region.height = parseInt(entry[4]);
3483
3484
  };
3484
- regionFields["offset"] = () => {
3485
+ regionFields["offset"] = (region) => {
3485
3486
  region.offsetX = parseInt(entry[1]);
3486
3487
  region.offsetY = parseInt(entry[2]);
3487
3488
  };
3488
- regionFields["orig"] = () => {
3489
+ regionFields["orig"] = (region) => {
3489
3490
  region.originalWidth = parseInt(entry[1]);
3490
3491
  region.originalHeight = parseInt(entry[2]);
3491
3492
  };
3492
- regionFields["offsets"] = () => {
3493
+ regionFields["offsets"] = (region) => {
3493
3494
  region.offsetX = parseInt(entry[1]);
3494
3495
  region.offsetY = parseInt(entry[2]);
3495
3496
  region.originalWidth = parseInt(entry[3]);
3496
3497
  region.originalHeight = parseInt(entry[4]);
3497
3498
  };
3498
- regionFields["rotate"] = () => {
3499
+ regionFields["rotate"] = (region) => {
3499
3500
  let value = entry[1];
3500
3501
  if (value == "true")
3501
3502
  region.degrees = 90;
3502
3503
  else if (value != "false")
3503
3504
  region.degrees = parseInt(value);
3504
3505
  };
3505
- regionFields["index"] = () => {
3506
+ regionFields["index"] = (region) => {
3506
3507
  region.index = parseInt(entry[1]);
3507
3508
  };
3508
3509
  let line = reader.readLine();
@@ -3515,6 +3516,7 @@ var spine = (() => {
3515
3516
  break;
3516
3517
  line = reader.readLine();
3517
3518
  }
3519
+ let page = null;
3518
3520
  let names = null;
3519
3521
  let values = null;
3520
3522
  while (true) {
@@ -3524,32 +3526,29 @@ var spine = (() => {
3524
3526
  page = null;
3525
3527
  line = reader.readLine();
3526
3528
  } else if (!page) {
3527
- page = new TextureAtlasPage();
3528
- page.name = line.trim();
3529
+ page = new TextureAtlasPage(line.trim());
3529
3530
  while (true) {
3530
3531
  if (reader.readEntry(entry, line = reader.readLine()) == 0)
3531
3532
  break;
3532
3533
  let field = pageFields[entry[0]];
3533
3534
  if (field)
3534
- field();
3535
+ field(page);
3535
3536
  }
3536
3537
  this.pages.push(page);
3537
3538
  } else {
3538
- region = new TextureAtlasRegion();
3539
- region.page = page;
3540
- region.name = line;
3539
+ let region = new TextureAtlasRegion(page, line);
3541
3540
  while (true) {
3542
3541
  let count = reader.readEntry(entry, line = reader.readLine());
3543
3542
  if (count == 0)
3544
3543
  break;
3545
3544
  let field = regionFields[entry[0]];
3546
3545
  if (field)
3547
- field();
3546
+ field(region);
3548
3547
  else {
3549
- if (!names) {
3548
+ if (!names)
3550
3549
  names = [];
3550
+ if (!values)
3551
3551
  values = [];
3552
- }
3553
3552
  names.push(entry[0]);
3554
3553
  let entryValues = [];
3555
3554
  for (let i = 0; i < count; i++)
@@ -3561,7 +3560,7 @@ var spine = (() => {
3561
3560
  region.originalWidth = region.width;
3562
3561
  region.originalHeight = region.height;
3563
3562
  }
3564
- if (names && names.length > 0) {
3563
+ if (names && names.length > 0 && values && values.length > 0) {
3565
3564
  region.names = names;
3566
3565
  region.values = values;
3567
3566
  names = null;
@@ -3593,14 +3592,14 @@ var spine = (() => {
3593
3592
  page.setTexture(assetManager.get(pathPrefix + page.name));
3594
3593
  }
3595
3594
  dispose() {
3595
+ var _a;
3596
3596
  for (let i = 0; i < this.pages.length; i++) {
3597
- this.pages[i].texture.dispose();
3597
+ (_a = this.pages[i].texture) == null ? void 0 : _a.dispose();
3598
3598
  }
3599
3599
  }
3600
3600
  };
3601
3601
  var TextureAtlasReader = class {
3602
3602
  constructor(text) {
3603
- this.lines = null;
3604
3603
  this.index = 0;
3605
3604
  this.lines = text.split(/\r\n|\r|\n/);
3606
3605
  }
@@ -3633,8 +3632,7 @@ var spine = (() => {
3633
3632
  }
3634
3633
  };
3635
3634
  var TextureAtlasPage = class {
3636
- constructor() {
3637
- this.name = null;
3635
+ constructor(name) {
3638
3636
  this.minFilter = TextureFilter.Nearest;
3639
3637
  this.magFilter = TextureFilter.Nearest;
3640
3638
  this.uWrap = TextureWrap.ClampToEdge;
@@ -3643,6 +3641,7 @@ var spine = (() => {
3643
3641
  this.width = 0;
3644
3642
  this.height = 0;
3645
3643
  this.pma = false;
3644
+ this.name = name;
3646
3645
  }
3647
3646
  setTexture(texture) {
3648
3647
  this.texture = texture;
@@ -3651,10 +3650,8 @@ var spine = (() => {
3651
3650
  }
3652
3651
  };
3653
3652
  var TextureAtlasRegion = class extends TextureRegion {
3654
- constructor() {
3655
- super(...arguments);
3656
- this.page = null;
3657
- this.name = null;
3653
+ constructor(page, name) {
3654
+ super();
3658
3655
  this.x = 0;
3659
3656
  this.y = 0;
3660
3657
  this.offsetX = 0;
@@ -3665,28 +3662,32 @@ var spine = (() => {
3665
3662
  this.degrees = 0;
3666
3663
  this.names = null;
3667
3664
  this.values = null;
3665
+ this.page = page;
3666
+ this.name = name;
3668
3667
  }
3669
3668
  };
3670
3669
 
3671
3670
  // spine-core/src/attachments/MeshAttachment.ts
3672
3671
  var MeshAttachment = class extends VertexAttachment {
3673
- constructor(name) {
3672
+ constructor(name, path) {
3674
3673
  super(name);
3675
3674
  this.region = null;
3676
- this.path = null;
3677
- this.regionUVs = null;
3678
- this.uvs = null;
3679
- this.triangles = null;
3675
+ this.regionUVs = [];
3676
+ this.uvs = [];
3677
+ this.triangles = [];
3680
3678
  this.color = new Color(1, 1, 1, 1);
3681
3679
  this.width = 0;
3682
3680
  this.height = 0;
3683
3681
  this.hullLength = 0;
3684
- this.edges = null;
3682
+ this.edges = [];
3685
3683
  this.parentMesh = null;
3686
3684
  this.sequence = null;
3687
3685
  this.tempColor = new Color(0, 0, 0, 0);
3686
+ this.path = path;
3688
3687
  }
3689
3688
  updateRegion() {
3689
+ if (!this.region)
3690
+ throw new Error("Region not set.");
3690
3691
  let regionUVs = this.regionUVs;
3691
3692
  if (!this.uvs || this.uvs.length != regionUVs.length)
3692
3693
  this.uvs = Utils.newFloatArray(regionUVs.length);
@@ -3762,9 +3763,8 @@ var spine = (() => {
3762
3763
  copy() {
3763
3764
  if (this.parentMesh)
3764
3765
  return this.newLinkedMesh();
3765
- let copy = new MeshAttachment(this.name);
3766
+ let copy = new MeshAttachment(this.name, this.path);
3766
3767
  copy.region = this.region;
3767
- copy.path = this.path;
3768
3768
  copy.color.setFromColor(this.color);
3769
3769
  this.copyTo(copy);
3770
3770
  copy.regionUVs = new Array(this.regionUVs.length);
@@ -3789,11 +3789,10 @@ var spine = (() => {
3789
3789
  super.computeWorldVertices(slot, start, count, worldVertices, offset, stride);
3790
3790
  }
3791
3791
  newLinkedMesh() {
3792
- let copy = new MeshAttachment(this.name);
3792
+ let copy = new MeshAttachment(this.name, this.path);
3793
3793
  copy.region = this.region;
3794
- copy.path = this.path;
3795
3794
  copy.color.setFromColor(this.color);
3796
- copy.timelineAttahment = this.timelineAttahment;
3795
+ copy.timelineAttachment = this.timelineAttachment;
3797
3796
  copy.setParentMesh(this.parentMesh ? this.parentMesh : this);
3798
3797
  if (copy.region != null)
3799
3798
  copy.updateRegion();
@@ -3805,7 +3804,7 @@ var spine = (() => {
3805
3804
  var PathAttachment = class extends VertexAttachment {
3806
3805
  constructor(name) {
3807
3806
  super(name);
3808
- this.lengths = null;
3807
+ this.lengths = [];
3809
3808
  this.closed = false;
3810
3809
  this.constantSpeed = false;
3811
3810
  this.color = new Color(1, 1, 1, 1);
@@ -3854,7 +3853,7 @@ var spine = (() => {
3854
3853
 
3855
3854
  // spine-core/src/attachments/RegionAttachment.ts
3856
3855
  var _RegionAttachment = class extends Attachment {
3857
- constructor(name) {
3856
+ constructor(name, path) {
3858
3857
  super(name);
3859
3858
  this.x = 0;
3860
3859
  this.y = 0;
@@ -3864,15 +3863,17 @@ var spine = (() => {
3864
3863
  this.width = 0;
3865
3864
  this.height = 0;
3866
3865
  this.color = new Color(1, 1, 1, 1);
3867
- this.path = null;
3868
3866
  this.rendererObject = null;
3869
3867
  this.region = null;
3870
3868
  this.sequence = null;
3871
3869
  this.offset = Utils.newFloatArray(8);
3872
3870
  this.uvs = Utils.newFloatArray(8);
3873
3871
  this.tempColor = new Color(1, 1, 1, 1);
3872
+ this.path = path;
3874
3873
  }
3875
3874
  updateRegion() {
3875
+ if (!this.region)
3876
+ throw new Error("Region not set.");
3876
3877
  let region = this.region;
3877
3878
  let regionScaleX = this.width / this.region.originalWidth * this.scaleX;
3878
3879
  let regionScaleY = this.height / this.region.originalHeight * this.scaleY;
@@ -3951,10 +3952,9 @@ var spine = (() => {
3951
3952
  worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
3952
3953
  }
3953
3954
  copy() {
3954
- let copy = new _RegionAttachment(this.name);
3955
+ let copy = new _RegionAttachment(this.name, this.path);
3955
3956
  copy.region = this.region;
3956
3957
  copy.rendererObject = this.rendererObject;
3957
- copy.path = this.path;
3958
3958
  copy.x = this.x;
3959
3959
  copy.y = this.y;
3960
3960
  copy.scaleX = this.scaleX;
@@ -4006,21 +4006,21 @@ var spine = (() => {
4006
4006
  // spine-core/src/AtlasAttachmentLoader.ts
4007
4007
  var AtlasAttachmentLoader = class {
4008
4008
  constructor(atlas) {
4009
- this.atlas = null;
4010
4009
  this.atlas = atlas;
4011
4010
  }
4012
4011
  loadSequence(name, basePath, sequence) {
4013
4012
  let regions = sequence.regions;
4014
4013
  for (let i = 0, n = regions.length; i < n; i++) {
4015
4014
  let path = sequence.getPath(basePath, i);
4016
- regions[i] = this.atlas.findRegion(path);
4017
- regions[i].renderObject = regions[i];
4018
- if (regions[i] == null)
4015
+ let region = this.atlas.findRegion(path);
4016
+ if (region == null)
4019
4017
  throw new Error("Region not found in atlas: " + path + " (sequence: " + name + ")");
4018
+ regions[i] = region;
4019
+ regions[i].renderObject = regions[i];
4020
4020
  }
4021
4021
  }
4022
4022
  newRegionAttachment(skin, name, path, sequence) {
4023
- let attachment = new RegionAttachment(name);
4023
+ let attachment = new RegionAttachment(name, path);
4024
4024
  if (sequence != null) {
4025
4025
  this.loadSequence(name, path, sequence);
4026
4026
  } else {
@@ -4033,7 +4033,7 @@ var spine = (() => {
4033
4033
  return attachment;
4034
4034
  }
4035
4035
  newMeshAttachment(skin, name, path, sequence) {
4036
- let attachment = new MeshAttachment(name);
4036
+ let attachment = new MeshAttachment(name, path);
4037
4037
  if (sequence != null) {
4038
4038
  this.loadSequence(name, path, sequence);
4039
4039
  } else {
@@ -4063,7 +4063,6 @@ var spine = (() => {
4063
4063
  var BoneData = class {
4064
4064
  constructor(index, name, parent) {
4065
4065
  this.index = 0;
4066
- this.name = null;
4067
4066
  this.parent = null;
4068
4067
  this.length = 0;
4069
4068
  this.x = 0;
@@ -4097,8 +4096,6 @@ var spine = (() => {
4097
4096
  // spine-core/src/Bone.ts
4098
4097
  var Bone = class {
4099
4098
  constructor(data, skeleton, parent) {
4100
- this.data = null;
4101
- this.skeleton = null;
4102
4099
  this.parent = null;
4103
4100
  this.children = new Array();
4104
4101
  this.x = 0;
@@ -4351,15 +4348,15 @@ var spine = (() => {
4351
4348
 
4352
4349
  // spine-core/src/AssetManagerBase.ts
4353
4350
  var AssetManagerBase = class {
4354
- constructor(textureLoader, pathPrefix = "", downloader = null) {
4355
- this.pathPrefix = null;
4351
+ constructor(textureLoader, pathPrefix = "", downloader = new Downloader()) {
4352
+ this.pathPrefix = "";
4356
4353
  this.assets = {};
4357
4354
  this.errors = {};
4358
4355
  this.toLoad = 0;
4359
4356
  this.loaded = 0;
4360
4357
  this.textureLoader = textureLoader;
4361
4358
  this.pathPrefix = pathPrefix;
4362
- this.downloader = downloader || new Downloader();
4359
+ this.downloader = downloader;
4363
4360
  }
4364
4361
  start(path) {
4365
4362
  this.toLoad++;
@@ -4379,10 +4376,28 @@ var spine = (() => {
4379
4376
  if (callback)
4380
4377
  callback(path, message);
4381
4378
  }
4379
+ loadAll() {
4380
+ let promise = new Promise((resolve, reject) => {
4381
+ let check = () => {
4382
+ if (this.isLoadingComplete()) {
4383
+ if (this.hasErrors())
4384
+ reject(this.errors);
4385
+ else
4386
+ resolve(this);
4387
+ return;
4388
+ }
4389
+ requestAnimationFrame(check);
4390
+ };
4391
+ requestAnimationFrame(check);
4392
+ });
4393
+ return promise;
4394
+ }
4382
4395
  setRawDataURI(path, data) {
4383
4396
  this.downloader.rawDataUris[this.pathPrefix + path] = data;
4384
4397
  }
4385
- loadBinary(path, success = null, error = null) {
4398
+ loadBinary(path, success = () => {
4399
+ }, error = () => {
4400
+ }) {
4386
4401
  path = this.start(path);
4387
4402
  this.downloader.downloadBinary(path, (data) => {
4388
4403
  this.success(success, path, data);
@@ -4390,7 +4405,9 @@ var spine = (() => {
4390
4405
  this.error(error, path, `Couldn't load binary ${path}: status ${status}, ${responseText}`);
4391
4406
  });
4392
4407
  }
4393
- loadText(path, success = null, error = null) {
4408
+ loadText(path, success = () => {
4409
+ }, error = () => {
4410
+ }) {
4394
4411
  path = this.start(path);
4395
4412
  this.downloader.downloadText(path, (data) => {
4396
4413
  this.success(success, path, data);
@@ -4398,7 +4415,9 @@ var spine = (() => {
4398
4415
  this.error(error, path, `Couldn't load text ${path}: status ${status}, ${responseText}`);
4399
4416
  });
4400
4417
  }
4401
- loadJson(path, success = null, error = null) {
4418
+ loadJson(path, success = () => {
4419
+ }, error = () => {
4420
+ }) {
4402
4421
  path = this.start(path);
4403
4422
  this.downloader.downloadJson(path, (data) => {
4404
4423
  this.success(success, path, data);
@@ -4406,7 +4425,9 @@ var spine = (() => {
4406
4425
  this.error(error, path, `Couldn't load JSON ${path}: status ${status}, ${responseText}`);
4407
4426
  });
4408
4427
  }
4409
- loadTexture(path, success = null, error = null) {
4428
+ loadTexture(path, success = () => {
4429
+ }, error = () => {
4430
+ }) {
4410
4431
  path = this.start(path);
4411
4432
  let isBrowser = !!(typeof window !== "undefined" && typeof navigator !== "undefined" && window.document);
4412
4433
  let isWebWorker = !isBrowser;
@@ -4436,7 +4457,9 @@ var spine = (() => {
4436
4457
  image.src = path;
4437
4458
  }
4438
4459
  }
4439
- loadTextureAtlas(path, success = null, error = null, fileAlias = null) {
4460
+ loadTextureAtlas(path, success = () => {
4461
+ }, error = () => {
4462
+ }, fileAlias) {
4440
4463
  let index = path.lastIndexOf("/");
4441
4464
  let parent = index >= 0 ? path.substring(0, index + 1) : "";
4442
4465
  path = this.start(path);
@@ -4445,7 +4468,7 @@ var spine = (() => {
4445
4468
  let atlas = new TextureAtlas(atlasText);
4446
4469
  let toLoad = atlas.pages.length, abort = false;
4447
4470
  for (let page of atlas.pages) {
4448
- this.loadTexture(fileAlias == null ? parent + page.name : fileAlias[page.name], (imagePath, texture) => {
4471
+ this.loadTexture(!fileAlias ? parent + page.name : fileAlias[page.name], (imagePath, texture) => {
4449
4472
  if (!abort) {
4450
4473
  page.setTexture(texture);
4451
4474
  if (--toLoad == 0)
@@ -4622,7 +4645,6 @@ var spine = (() => {
4622
4645
  // spine-core/src/Event.ts
4623
4646
  var Event = class {
4624
4647
  constructor(time, data) {
4625
- this.data = null;
4626
4648
  this.intValue = 0;
4627
4649
  this.floatValue = 0;
4628
4650
  this.stringValue = null;
@@ -4639,7 +4661,6 @@ var spine = (() => {
4639
4661
  // spine-core/src/EventData.ts
4640
4662
  var EventData = class {
4641
4663
  constructor(name) {
4642
- this.name = null;
4643
4664
  this.intValue = 0;
4644
4665
  this.floatValue = 0;
4645
4666
  this.stringValue = null;
@@ -4653,9 +4674,6 @@ var spine = (() => {
4653
4674
  // spine-core/src/IkConstraint.ts
4654
4675
  var IkConstraint = class {
4655
4676
  constructor(data, skeleton) {
4656
- this.data = null;
4657
- this.bones = null;
4658
- this.target = null;
4659
4677
  this.bendDirection = 0;
4660
4678
  this.compress = false;
4661
4679
  this.stretch = false;
@@ -4673,9 +4691,16 @@ var spine = (() => {
4673
4691
  this.compress = data.compress;
4674
4692
  this.stretch = data.stretch;
4675
4693
  this.bones = new Array();
4676
- for (let i = 0; i < data.bones.length; i++)
4677
- this.bones.push(skeleton.findBone(data.bones[i].name));
4678
- this.target = skeleton.findBone(data.target.name);
4694
+ for (let i = 0; i < data.bones.length; i++) {
4695
+ let bone = skeleton.findBone(data.bones[i].name);
4696
+ if (!bone)
4697
+ throw new Error(`Couldn't find bone ${data.bones[i].name}`);
4698
+ this.bones.push(bone);
4699
+ }
4700
+ let target = skeleton.findBone(data.target.name);
4701
+ if (!target)
4702
+ throw new Error(`Couldn't find bone ${data.target.name}`);
4703
+ this.target = target;
4679
4704
  }
4680
4705
  isActive() {
4681
4706
  return this.active;
@@ -4696,6 +4721,8 @@ var spine = (() => {
4696
4721
  }
4697
4722
  apply1(bone, targetX, targetY, compress, stretch, uniform, alpha) {
4698
4723
  let p = bone.parent;
4724
+ if (!p)
4725
+ throw new Error("IK bone must have parent.");
4699
4726
  let pa = p.a, pb = p.b, pc = p.c, pd = p.d;
4700
4727
  let rotationIK = -bone.ashearX - bone.arotation, tx = 0, ty = 0;
4701
4728
  switch (bone.data.transformMode) {
@@ -4773,6 +4800,8 @@ var spine = (() => {
4773
4800
  cwy = c * cx + d * cy + parent.worldY;
4774
4801
  }
4775
4802
  let pp = parent.parent;
4803
+ if (!pp)
4804
+ throw new Error("IK parent must itself have a parent.");
4776
4805
  a = pp.a;
4777
4806
  b = pp.b;
4778
4807
  c = pp.c;
@@ -4894,7 +4923,7 @@ var spine = (() => {
4894
4923
  constructor(name) {
4895
4924
  super(name, 0, false);
4896
4925
  this.bones = new Array();
4897
- this.target = null;
4926
+ this._target = null;
4898
4927
  this.bendDirection = 1;
4899
4928
  this.compress = false;
4900
4929
  this.stretch = false;
@@ -4902,6 +4931,15 @@ var spine = (() => {
4902
4931
  this.mix = 1;
4903
4932
  this.softness = 0;
4904
4933
  }
4934
+ set target(boneData) {
4935
+ this._target = boneData;
4936
+ }
4937
+ get target() {
4938
+ if (!this._target)
4939
+ throw new Error("BoneData not set.");
4940
+ else
4941
+ return this._target;
4942
+ }
4905
4943
  };
4906
4944
 
4907
4945
  // spine-core/src/PathConstraintData.ts
@@ -4909,10 +4947,10 @@ var spine = (() => {
4909
4947
  constructor(name) {
4910
4948
  super(name, 0, false);
4911
4949
  this.bones = new Array();
4912
- this.target = null;
4913
- this.positionMode = null;
4914
- this.spacingMode = null;
4915
- this.rotateMode = null;
4950
+ this._target = null;
4951
+ this.positionMode = PositionMode.Fixed;
4952
+ this.spacingMode = SpacingMode.Fixed;
4953
+ this.rotateMode = RotateMode.Chain;
4916
4954
  this.offsetRotation = 0;
4917
4955
  this.position = 0;
4918
4956
  this.spacing = 0;
@@ -4920,6 +4958,15 @@ var spine = (() => {
4920
4958
  this.mixX = 0;
4921
4959
  this.mixY = 0;
4922
4960
  }
4961
+ set target(slotData) {
4962
+ this._target = slotData;
4963
+ }
4964
+ get target() {
4965
+ if (!this._target)
4966
+ throw new Error("SlotData not set.");
4967
+ else
4968
+ return this._target;
4969
+ }
4923
4970
  };
4924
4971
  var PositionMode;
4925
4972
  (function(PositionMode2) {
@@ -4943,9 +4990,6 @@ var spine = (() => {
4943
4990
  // spine-core/src/PathConstraint.ts
4944
4991
  var _PathConstraint = class {
4945
4992
  constructor(data, skeleton) {
4946
- this.data = null;
4947
- this.bones = null;
4948
- this.target = null;
4949
4993
  this.position = 0;
4950
4994
  this.spacing = 0;
4951
4995
  this.mixRotate = 0;
@@ -4964,9 +5008,16 @@ var spine = (() => {
4964
5008
  throw new Error("skeleton cannot be null.");
4965
5009
  this.data = data;
4966
5010
  this.bones = new Array();
4967
- for (let i = 0, n = data.bones.length; i < n; i++)
4968
- this.bones.push(skeleton.findBone(data.bones[i].name));
4969
- this.target = skeleton.findSlot(data.target.name);
5011
+ for (let i = 0, n = data.bones.length; i < n; i++) {
5012
+ let bone = skeleton.findBone(data.bones[i].name);
5013
+ if (!bone)
5014
+ throw new Error(`Couldn't find bone ${data.bones[i].name}.`);
5015
+ this.bones.push(bone);
5016
+ }
5017
+ let target = skeleton.findSlot(data.target.name);
5018
+ if (!target)
5019
+ throw new Error(`Couldn't find target bone ${data.target.name}`);
5020
+ this.target = target;
4970
5021
  this.position = data.position;
4971
5022
  this.spacing = data.spacing;
4972
5023
  this.mixRotate = data.mixRotate;
@@ -4987,7 +5038,7 @@ var spine = (() => {
4987
5038
  let tangents = data.rotateMode == RotateMode.Tangent, scale = data.rotateMode == RotateMode.ChainScale;
4988
5039
  let bones = this.bones;
4989
5040
  let boneCount = bones.length, spacesCount = tangents ? boneCount : boneCount + 1;
4990
- let spaces = Utils.setArraySize(this.spaces, spacesCount), lengths = scale ? this.lengths = Utils.setArraySize(this.lengths, boneCount) : null;
5041
+ let spaces = Utils.setArraySize(this.spaces, spacesCount), lengths = scale ? this.lengths = Utils.setArraySize(this.lengths, boneCount) : [];
4991
5042
  let spacing = this.spacing;
4992
5043
  switch (data.spacingMode) {
4993
5044
  case SpacingMode.Percent:
@@ -5108,7 +5159,7 @@ var spine = (() => {
5108
5159
  computeWorldPositions(path, spacesCount, tangents) {
5109
5160
  let target = this.target;
5110
5161
  let position = this.position;
5111
- let spaces = this.spaces, out = Utils.setArraySize(this.positions, spacesCount * 3 + 2), world = null;
5162
+ let spaces = this.spaces, out = Utils.setArraySize(this.positions, spacesCount * 3 + 2), world = this.world;
5112
5163
  let closed2 = path.closed;
5113
5164
  let verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = _PathConstraint.NONE;
5114
5165
  if (!path.constantSpeed) {
@@ -5365,12 +5416,10 @@ var spine = (() => {
5365
5416
  // spine-core/src/Slot.ts
5366
5417
  var Slot = class {
5367
5418
  constructor(data, bone) {
5368
- this.data = null;
5369
- this.bone = null;
5370
- this.color = null;
5371
5419
  this.darkColor = null;
5372
5420
  this.attachment = null;
5373
5421
  this.attachmentState = 0;
5422
+ this.sequenceIndex = -1;
5374
5423
  this.deform = new Array();
5375
5424
  if (!data)
5376
5425
  throw new Error("data cannot be null.");
@@ -5391,7 +5440,7 @@ var spine = (() => {
5391
5440
  setAttachment(attachment) {
5392
5441
  if (this.attachment == attachment)
5393
5442
  return;
5394
- if (!(attachment instanceof VertexAttachment) || !(this.attachment instanceof VertexAttachment) || attachment.timelineAttahment != this.attachment.timelineAttahment) {
5443
+ if (!(attachment instanceof VertexAttachment) || !(this.attachment instanceof VertexAttachment) || attachment.timelineAttachment != this.attachment.timelineAttachment) {
5395
5444
  this.deform.length = 0;
5396
5445
  }
5397
5446
  this.attachment = attachment;
@@ -5413,9 +5462,6 @@ var spine = (() => {
5413
5462
  // spine-core/src/TransformConstraint.ts
5414
5463
  var TransformConstraint = class {
5415
5464
  constructor(data, skeleton) {
5416
- this.data = null;
5417
- this.bones = null;
5418
- this.target = null;
5419
5465
  this.mixRotate = 0;
5420
5466
  this.mixX = 0;
5421
5467
  this.mixY = 0;
@@ -5436,9 +5482,16 @@ var spine = (() => {
5436
5482
  this.mixScaleY = data.mixScaleY;
5437
5483
  this.mixShearY = data.mixShearY;
5438
5484
  this.bones = new Array();
5439
- for (let i = 0; i < data.bones.length; i++)
5440
- this.bones.push(skeleton.findBone(data.bones[i].name));
5441
- this.target = skeleton.findBone(data.target.name);
5485
+ for (let i = 0; i < data.bones.length; i++) {
5486
+ let bone = skeleton.findBone(data.bones[i].name);
5487
+ if (!bone)
5488
+ throw new Error(`Couldn't find bone ${data.bones[i].name}.`);
5489
+ this.bones.push(bone);
5490
+ }
5491
+ let target = skeleton.findBone(data.target.name);
5492
+ if (!target)
5493
+ throw new Error(`Couldn't find target bone ${data.target.name}.`);
5494
+ this.target = target;
5442
5495
  }
5443
5496
  isActive() {
5444
5497
  return this.active;
@@ -5623,16 +5676,8 @@ var spine = (() => {
5623
5676
  // spine-core/src/Skeleton.ts
5624
5677
  var Skeleton = class {
5625
5678
  constructor(data) {
5626
- this.data = null;
5627
- this.bones = null;
5628
- this.slots = null;
5629
- this.drawOrder = null;
5630
- this.ikConstraints = null;
5631
- this.transformConstraints = null;
5632
- this.pathConstraints = null;
5633
5679
  this._updateCache = new Array();
5634
5680
  this.skin = null;
5635
- this.color = null;
5636
5681
  this.scaleX = 1;
5637
5682
  this.scaleY = 1;
5638
5683
  this.x = 0;
@@ -5827,6 +5872,8 @@ var spine = (() => {
5827
5872
  }
5828
5873
  }
5829
5874
  sortBone(bone) {
5875
+ if (!bone)
5876
+ return;
5830
5877
  if (bone.sorted)
5831
5878
  return;
5832
5879
  let parent = bone.parent;
@@ -5863,6 +5910,8 @@ var spine = (() => {
5863
5910
  }
5864
5911
  updateWorldTransformWith(parent) {
5865
5912
  let rootBone = this.getRootBone();
5913
+ if (!rootBone)
5914
+ throw new Error("Root bone must not be null.");
5866
5915
  let pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
5867
5916
  rootBone.worldX = pa * this.x + pb * this.y + parent.worldX;
5868
5917
  rootBone.worldY = pc * this.x + pd * this.y + parent.worldY;
@@ -5983,7 +6032,10 @@ var spine = (() => {
5983
6032
  this.updateCache();
5984
6033
  }
5985
6034
  getAttachmentByName(slotName, attachmentName) {
5986
- return this.getAttachment(this.data.findSlot(slotName).index, attachmentName);
6035
+ let slot = this.data.findSlot(slotName);
6036
+ if (!slot)
6037
+ throw new Error(`Can't find slot with name ${slotName}`);
6038
+ return this.getAttachment(slot.index, attachmentName);
5987
6039
  }
5988
6040
  getAttachment(slotIndex, attachmentName) {
5989
6041
  if (!attachmentName)
@@ -6049,6 +6101,12 @@ var spine = (() => {
6049
6101
  }
6050
6102
  return null;
6051
6103
  }
6104
+ getBoundsRect() {
6105
+ let offset = new Vector2();
6106
+ let size = new Vector2();
6107
+ this.getBounds(offset, size);
6108
+ return { x: offset.x, y: offset.y, width: size.x, height: size.y };
6109
+ }
6052
6110
  getBounds(offset, size, temp = new Array(2)) {
6053
6111
  if (!offset)
6054
6112
  throw new Error("offset cannot be null.");
@@ -6203,7 +6261,7 @@ var spine = (() => {
6203
6261
 
6204
6262
  // spine-core/src/Skin.ts
6205
6263
  var SkinEntry = class {
6206
- constructor(slotIndex = 0, name = null, attachment = null) {
6264
+ constructor(slotIndex = 0, name, attachment) {
6207
6265
  this.slotIndex = slotIndex;
6208
6266
  this.name = name;
6209
6267
  this.attachment = attachment;
@@ -6211,7 +6269,6 @@ var spine = (() => {
6211
6269
  };
6212
6270
  var Skin = class {
6213
6271
  constructor(name) {
6214
- this.name = null;
6215
6272
  this.attachments = new Array();
6216
6273
  this.bones = Array();
6217
6274
  this.constraints = new Array();
@@ -6306,7 +6363,7 @@ var spine = (() => {
6306
6363
  removeAttachment(slotIndex, name) {
6307
6364
  let dictionary = this.attachments[slotIndex];
6308
6365
  if (dictionary)
6309
- dictionary[name] = null;
6366
+ delete dictionary[name];
6310
6367
  }
6311
6368
  getAttachments() {
6312
6369
  let entries = new Array();
@@ -6363,12 +6420,10 @@ var spine = (() => {
6363
6420
  var SlotData = class {
6364
6421
  constructor(index, name, boneData) {
6365
6422
  this.index = 0;
6366
- this.name = null;
6367
- this.boneData = null;
6368
6423
  this.color = new Color(1, 1, 1, 1);
6369
6424
  this.darkColor = null;
6370
6425
  this.attachmentName = null;
6371
- this.blendMode = null;
6426
+ this.blendMode = BlendMode.Normal;
6372
6427
  if (index < 0)
6373
6428
  throw new Error("index must be >= 0.");
6374
6429
  if (!name)
@@ -6393,7 +6448,7 @@ var spine = (() => {
6393
6448
  constructor(name) {
6394
6449
  super(name, 0, false);
6395
6450
  this.bones = new Array();
6396
- this.target = null;
6451
+ this._target = null;
6397
6452
  this.mixRotate = 0;
6398
6453
  this.mixX = 0;
6399
6454
  this.mixY = 0;
@@ -6409,13 +6464,21 @@ var spine = (() => {
6409
6464
  this.relative = false;
6410
6465
  this.local = false;
6411
6466
  }
6467
+ set target(boneData) {
6468
+ this._target = boneData;
6469
+ }
6470
+ get target() {
6471
+ if (!this._target)
6472
+ throw new Error("BoneData not set.");
6473
+ else
6474
+ return this._target;
6475
+ }
6412
6476
  };
6413
6477
 
6414
6478
  // spine-core/src/SkeletonBinary.ts
6415
6479
  var SkeletonBinary = class {
6416
6480
  constructor(attachmentLoader) {
6417
6481
  this.scale = 1;
6418
- this.attachmentLoader = null;
6419
6482
  this.linkedMeshes = new Array();
6420
6483
  this.attachmentLoader = attachmentLoader;
6421
6484
  }
@@ -6440,11 +6503,17 @@ var spine = (() => {
6440
6503
  }
6441
6504
  let n = 0;
6442
6505
  n = input.readInt(true);
6443
- for (let i = 0; i < n; i++)
6444
- input.strings.push(input.readString());
6506
+ for (let i = 0; i < n; i++) {
6507
+ let str = input.readString();
6508
+ if (!str)
6509
+ throw new Error("String in string table must not be null.");
6510
+ input.strings.push(str);
6511
+ }
6445
6512
  n = input.readInt(true);
6446
6513
  for (let i = 0; i < n; i++) {
6447
6514
  let name = input.readString();
6515
+ if (!name)
6516
+ throw new Error("Bone name must not be null.");
6448
6517
  let parent = i == 0 ? null : skeletonData.bones[input.readInt(true)];
6449
6518
  let data = new BoneData(i, name, parent);
6450
6519
  data.rotation = input.readFloat();
@@ -6464,6 +6533,8 @@ var spine = (() => {
6464
6533
  n = input.readInt(true);
6465
6534
  for (let i = 0; i < n; i++) {
6466
6535
  let slotName = input.readString();
6536
+ if (!slotName)
6537
+ throw new Error("Slot name must not be null.");
6467
6538
  let boneData = skeletonData.bones[input.readInt(true)];
6468
6539
  let data = new SlotData(i, slotName, boneData);
6469
6540
  Color.rgba8888ToColor(data.color, input.readInt32());
@@ -6476,7 +6547,10 @@ var spine = (() => {
6476
6547
  }
6477
6548
  n = input.readInt(true);
6478
6549
  for (let i = 0, nn; i < n; i++) {
6479
- let data = new IkConstraintData(input.readString());
6550
+ let name = input.readString();
6551
+ if (!name)
6552
+ throw new Error("IK constraint data name must not be null.");
6553
+ let data = new IkConstraintData(name);
6480
6554
  data.order = input.readInt(true);
6481
6555
  data.skinRequired = input.readBoolean();
6482
6556
  nn = input.readInt(true);
@@ -6493,7 +6567,10 @@ var spine = (() => {
6493
6567
  }
6494
6568
  n = input.readInt(true);
6495
6569
  for (let i = 0, nn; i < n; i++) {
6496
- let data = new TransformConstraintData(input.readString());
6570
+ let name = input.readString();
6571
+ if (!name)
6572
+ throw new Error("Transform constraint data name must not be null.");
6573
+ let data = new TransformConstraintData(name);
6497
6574
  data.order = input.readInt(true);
6498
6575
  data.skinRequired = input.readBoolean();
6499
6576
  nn = input.readInt(true);
@@ -6518,7 +6595,10 @@ var spine = (() => {
6518
6595
  }
6519
6596
  n = input.readInt(true);
6520
6597
  for (let i = 0, nn; i < n; i++) {
6521
- let data = new PathConstraintData(input.readString());
6598
+ let name = input.readString();
6599
+ if (!name)
6600
+ throw new Error("Path constraint data name must not be null.");
6601
+ let data = new PathConstraintData(name);
6522
6602
  data.order = input.readInt(true);
6523
6603
  data.skinRequired = input.readBoolean();
6524
6604
  nn = input.readInt(true);
@@ -6548,15 +6628,25 @@ var spine = (() => {
6548
6628
  {
6549
6629
  let i = skeletonData.skins.length;
6550
6630
  Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true));
6551
- for (; i < n; i++)
6552
- skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential);
6631
+ for (; i < n; i++) {
6632
+ let skin = this.readSkin(input, skeletonData, false, nonessential);
6633
+ if (!skin)
6634
+ throw new Error("readSkin() should not have returned null.");
6635
+ skeletonData.skins[i] = skin;
6636
+ }
6553
6637
  }
6554
6638
  n = this.linkedMeshes.length;
6555
6639
  for (let i = 0; i < n; i++) {
6556
6640
  let linkedMesh = this.linkedMeshes[i];
6557
6641
  let skin = !linkedMesh.skin ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
6642
+ if (!skin)
6643
+ throw new Error("Not skin found for linked mesh.");
6644
+ if (!linkedMesh.parent)
6645
+ throw new Error("Linked mesh parent must not be null");
6558
6646
  let parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
6559
- linkedMesh.mesh.timelineAttahment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
6647
+ if (!parent)
6648
+ throw new Error(`Parent mesh not found: ${linkedMesh.parent}`);
6649
+ linkedMesh.mesh.timelineAttachment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
6560
6650
  linkedMesh.mesh.setParentMesh(parent);
6561
6651
  if (linkedMesh.mesh.region != null)
6562
6652
  linkedMesh.mesh.updateRegion();
@@ -6564,7 +6654,10 @@ var spine = (() => {
6564
6654
  this.linkedMeshes.length = 0;
6565
6655
  n = input.readInt(true);
6566
6656
  for (let i = 0; i < n; i++) {
6567
- let data = new EventData(input.readStringRef());
6657
+ let eventName = input.readStringRef();
6658
+ if (!eventName)
6659
+ throw new Error();
6660
+ let data = new EventData(eventName);
6568
6661
  data.intValue = input.readInt(false);
6569
6662
  data.floatValue = input.readFloat();
6570
6663
  data.stringValue = input.readString();
@@ -6576,8 +6669,12 @@ var spine = (() => {
6576
6669
  skeletonData.events.push(data);
6577
6670
  }
6578
6671
  n = input.readInt(true);
6579
- for (let i = 0; i < n; i++)
6580
- skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData));
6672
+ for (let i = 0; i < n; i++) {
6673
+ let animationName = input.readString();
6674
+ if (!animationName)
6675
+ throw new Error("Animatio name must not be null.");
6676
+ skeletonData.animations.push(this.readAnimation(input, animationName, skeletonData));
6677
+ }
6581
6678
  return skeletonData;
6582
6679
  }
6583
6680
  readSkin(input, skeletonData, defaultSkin, nonessential) {
@@ -6589,7 +6686,10 @@ var spine = (() => {
6589
6686
  return null;
6590
6687
  skin = new Skin("default");
6591
6688
  } else {
6592
- skin = new Skin(input.readStringRef());
6689
+ let skinName = input.readStringRef();
6690
+ if (!skinName)
6691
+ throw new Error("Skin name must not be null.");
6692
+ skin = new Skin(skinName);
6593
6693
  skin.bones.length = input.readInt(true);
6594
6694
  for (let i = 0, n = skin.bones.length; i < n; i++)
6595
6695
  skin.bones[i] = skeletonData.bones[input.readInt(true)];
@@ -6605,6 +6705,8 @@ var spine = (() => {
6605
6705
  let slotIndex = input.readInt(true);
6606
6706
  for (let ii = 0, nn = input.readInt(true); ii < nn; ii++) {
6607
6707
  let name = input.readStringRef();
6708
+ if (!name)
6709
+ throw new Error("Attachment name must not be null");
6608
6710
  let attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name, nonessential);
6609
6711
  if (attachment)
6610
6712
  skin.setAttachment(slotIndex, name, attachment);
@@ -6671,7 +6773,7 @@ var spine = (() => {
6671
6773
  let vertices = this.readVertices(input, vertexCount);
6672
6774
  let hullLength = input.readInt(true);
6673
6775
  let sequence = this.readSequence(input);
6674
- let edges = null;
6776
+ let edges = [];
6675
6777
  let width = 0, height = 0;
6676
6778
  if (nonessential) {
6677
6779
  edges = this.readShortArray(input);
@@ -7173,6 +7275,8 @@ var spine = (() => {
7173
7275
  let slotIndex = input.readInt(true);
7174
7276
  for (let iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
7175
7277
  let attachmentName = input.readStringRef();
7278
+ if (!attachmentName)
7279
+ throw new Error("attachmentName must not be null.");
7176
7280
  let attachment = skin.getAttachment(slotIndex, attachmentName);
7177
7281
  let timelineType = input.readByte();
7178
7282
  let frameCount = input.readInt(true);
@@ -7347,7 +7451,7 @@ var spine = (() => {
7347
7451
  let chars = "";
7348
7452
  let charCount = 0;
7349
7453
  for (let i = 0; i < byteCount; ) {
7350
- let b = this.readByte();
7454
+ let b = this.readUnsignedByte();
7351
7455
  switch (b >> 4) {
7352
7456
  case 12:
7353
7457
  case 13:
@@ -7848,6 +7952,8 @@ var spine = (() => {
7848
7952
  this.clippedVertices = new Array();
7849
7953
  this.clippedTriangles = new Array();
7850
7954
  this.scratch = new Array();
7955
+ this.clipAttachment = null;
7956
+ this.clippingPolygons = null;
7851
7957
  }
7852
7958
  clipStart(slot, clip) {
7853
7959
  if (this.clipAttachment)
@@ -7887,7 +7993,7 @@ var spine = (() => {
7887
7993
  let clipOutput = this.clipOutput, clippedVertices = this.clippedVertices;
7888
7994
  let clippedTriangles = this.clippedTriangles;
7889
7995
  let polygons = this.clippingPolygons;
7890
- let polygonsCount = this.clippingPolygons.length;
7996
+ let polygonsCount = polygons.length;
7891
7997
  let vertexSize = twoColor ? 12 : 8;
7892
7998
  let index = 0;
7893
7999
  clippedVertices.length = 0;
@@ -8019,7 +8125,7 @@ var spine = (() => {
8019
8125
  clip(x1, y1, x2, y2, x3, y3, clippingArea, output) {
8020
8126
  let originalOutput = output;
8021
8127
  let clipped = false;
8022
- let input = null;
8128
+ let input;
8023
8129
  if (clippingArea.length % 4 >= 2) {
8024
8130
  input = output;
8025
8131
  output = this.scratch;
@@ -8127,7 +8233,6 @@ var spine = (() => {
8127
8233
  // spine-core/src/SkeletonJson.ts
8128
8234
  var SkeletonJson = class {
8129
8235
  constructor(attachmentLoader) {
8130
- this.attachmentLoader = null;
8131
8236
  this.scale = 1;
8132
8237
  this.linkedMeshes = new Array();
8133
8238
  this.attachmentLoader = attachmentLoader;
@@ -8175,6 +8280,8 @@ var spine = (() => {
8175
8280
  for (let i = 0; i < root.slots.length; i++) {
8176
8281
  let slotMap = root.slots[i];
8177
8282
  let boneData = skeletonData.findBone(slotMap.bone);
8283
+ if (!boneData)
8284
+ throw new Error(`Couldn't find bone ${slotMap.bone} for slot ${slotMap.name}`);
8178
8285
  let data = new SlotData(skeletonData.slots.length, slotMap.name, boneData);
8179
8286
  let color = getValue(slotMap, "color", null);
8180
8287
  if (color)
@@ -8193,9 +8300,17 @@ var spine = (() => {
8193
8300
  let data = new IkConstraintData(constraintMap.name);
8194
8301
  data.order = getValue(constraintMap, "order", 0);
8195
8302
  data.skinRequired = getValue(constraintMap, "skin", false);
8196
- for (let ii = 0; ii < constraintMap.bones.length; ii++)
8197
- data.bones.push(skeletonData.findBone(constraintMap.bones[ii]));
8198
- data.target = skeletonData.findBone(constraintMap.target);
8303
+ for (let ii = 0; ii < constraintMap.bones.length; ii++) {
8304
+ let bone = skeletonData.findBone(constraintMap.bones[ii]);
8305
+ if (!bone)
8306
+ throw new Error(`Couldn't find bone ${constraintMap.bones[ii]} for IK constraint ${constraintMap.name}.`);
8307
+ data.bones.push(bone);
8308
+ }
8309
+ let target = skeletonData.findBone(constraintMap.target);
8310
+ ;
8311
+ if (!target)
8312
+ throw new Error(`Couldn't find target bone ${constraintMap.target} for IK constraint ${constraintMap.name}.`);
8313
+ data.target = target;
8199
8314
  data.mix = getValue(constraintMap, "mix", 1);
8200
8315
  data.softness = getValue(constraintMap, "softness", 0) * scale;
8201
8316
  data.bendDirection = getValue(constraintMap, "bendPositive", true) ? 1 : -1;
@@ -8211,10 +8326,18 @@ var spine = (() => {
8211
8326
  let data = new TransformConstraintData(constraintMap.name);
8212
8327
  data.order = getValue(constraintMap, "order", 0);
8213
8328
  data.skinRequired = getValue(constraintMap, "skin", false);
8214
- for (let ii = 0; ii < constraintMap.bones.length; ii++)
8215
- data.bones.push(skeletonData.findBone(constraintMap.bones[ii]));
8329
+ for (let ii = 0; ii < constraintMap.bones.length; ii++) {
8330
+ let boneName = constraintMap.bones[ii];
8331
+ let bone = skeletonData.findBone(boneName);
8332
+ if (!bone)
8333
+ throw new Error(`Couldn't find bone ${boneName} for transform constraint ${constraintMap.name}.`);
8334
+ data.bones.push(bone);
8335
+ }
8216
8336
  let targetName = constraintMap.target;
8217
- data.target = skeletonData.findBone(targetName);
8337
+ let target = skeletonData.findBone(targetName);
8338
+ if (!target)
8339
+ throw new Error(`Couldn't find target bone ${targetName} for transform constraint ${constraintMap.name}.`);
8340
+ data.target = target;
8218
8341
  data.local = getValue(constraintMap, "local", false);
8219
8342
  data.relative = getValue(constraintMap, "relative", false);
8220
8343
  data.offsetRotation = getValue(constraintMap, "rotation", 0);
@@ -8238,10 +8361,18 @@ var spine = (() => {
8238
8361
  let data = new PathConstraintData(constraintMap.name);
8239
8362
  data.order = getValue(constraintMap, "order", 0);
8240
8363
  data.skinRequired = getValue(constraintMap, "skin", false);
8241
- for (let ii = 0; ii < constraintMap.bones.length; ii++)
8242
- data.bones.push(skeletonData.findBone(constraintMap.bones[ii]));
8364
+ for (let ii = 0; ii < constraintMap.bones.length; ii++) {
8365
+ let boneName = constraintMap.bones[ii];
8366
+ let bone = skeletonData.findBone(boneName);
8367
+ if (!bone)
8368
+ throw new Error(`Couldn't find bone ${boneName} for path constraint ${constraintMap.name}.`);
8369
+ data.bones.push(bone);
8370
+ }
8243
8371
  let targetName = constraintMap.target;
8244
- data.target = skeletonData.findSlot(targetName);
8372
+ let target = skeletonData.findSlot(targetName);
8373
+ if (!target)
8374
+ throw new Error(`Couldn't find target slot ${targetName} for path constraint ${constraintMap.name}.`);
8375
+ data.target = target;
8245
8376
  data.positionMode = Utils.enumValue(PositionMode, getValue(constraintMap, "positionMode", "Percent"));
8246
8377
  data.spacingMode = Utils.enumValue(SpacingMode, getValue(constraintMap, "spacingMode", "Length"));
8247
8378
  data.rotateMode = Utils.enumValue(RotateMode, getValue(constraintMap, "rotateMode", "Tangent"));
@@ -8263,23 +8394,45 @@ var spine = (() => {
8263
8394
  let skinMap = root.skins[i];
8264
8395
  let skin = new Skin(skinMap.name);
8265
8396
  if (skinMap.bones) {
8266
- for (let ii = 0; ii < skinMap.bones.length; ii++)
8267
- skin.bones.push(skeletonData.findBone(skinMap.bones[ii]));
8397
+ for (let ii = 0; ii < skinMap.bones.length; ii++) {
8398
+ let boneName = skinMap.bones[ii];
8399
+ let bone = skeletonData.findBone(boneName);
8400
+ if (!bone)
8401
+ throw new Error(`Couldn't find bone ${boneName} for skin ${skinMap.name}.`);
8402
+ skin.bones.push(bone);
8403
+ }
8268
8404
  }
8269
8405
  if (skinMap.ik) {
8270
- for (let ii = 0; ii < skinMap.ik.length; ii++)
8271
- skin.constraints.push(skeletonData.findIkConstraint(skinMap.ik[ii]));
8406
+ for (let ii = 0; ii < skinMap.ik.length; ii++) {
8407
+ let constraintName = skinMap.ik[ii];
8408
+ let constraint = skeletonData.findIkConstraint(constraintName);
8409
+ if (!constraint)
8410
+ throw new Error(`Couldn't find IK constraint ${constraintName} for skin ${skinMap.name}.`);
8411
+ skin.constraints.push(constraint);
8412
+ }
8272
8413
  }
8273
8414
  if (skinMap.transform) {
8274
- for (let ii = 0; ii < skinMap.transform.length; ii++)
8275
- skin.constraints.push(skeletonData.findTransformConstraint(skinMap.transform[ii]));
8415
+ for (let ii = 0; ii < skinMap.transform.length; ii++) {
8416
+ let constraintName = skinMap.transform[ii];
8417
+ let constraint = skeletonData.findTransformConstraint(constraintName);
8418
+ if (!constraint)
8419
+ throw new Error(`Couldn't find transform constraint ${constraintName} for skin ${skinMap.name}.`);
8420
+ skin.constraints.push(constraint);
8421
+ }
8276
8422
  }
8277
8423
  if (skinMap.path) {
8278
- for (let ii = 0; ii < skinMap.path.length; ii++)
8279
- skin.constraints.push(skeletonData.findPathConstraint(skinMap.path[ii]));
8424
+ for (let ii = 0; ii < skinMap.path.length; ii++) {
8425
+ let constraintName = skinMap.path[ii];
8426
+ let constraint = skeletonData.findPathConstraint(constraintName);
8427
+ if (!constraint)
8428
+ throw new Error(`Couldn't find path constraint ${constraintName} for skin ${skinMap.name}.`);
8429
+ skin.constraints.push(constraint);
8430
+ }
8280
8431
  }
8281
8432
  for (let slotName in skinMap.attachments) {
8282
8433
  let slot = skeletonData.findSlot(slotName);
8434
+ if (!slot)
8435
+ throw new Error(`Couldn't find slot ${slotName} for skin ${skinMap.name}.`);
8283
8436
  let slotMap = skinMap.attachments[slotName];
8284
8437
  for (let entryName in slotMap) {
8285
8438
  let attachment = this.readAttachment(slotMap[entryName], skin, slot.index, entryName, skeletonData);
@@ -8295,8 +8448,12 @@ var spine = (() => {
8295
8448
  for (let i = 0, n = this.linkedMeshes.length; i < n; i++) {
8296
8449
  let linkedMesh = this.linkedMeshes[i];
8297
8450
  let skin = !linkedMesh.skin ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
8451
+ if (!skin)
8452
+ throw new Error(`Skin not found: ${linkedMesh.skin}`);
8298
8453
  let parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
8299
- linkedMesh.mesh.timelineAttahment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
8454
+ if (!parent)
8455
+ throw new Error(`Parent mesh not found: ${linkedMesh.parent}`);
8456
+ linkedMesh.mesh.timelineAttachment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
8300
8457
  linkedMesh.mesh.setParentMesh(parent);
8301
8458
  if (linkedMesh.mesh.region != null)
8302
8459
  linkedMesh.mesh.updateRegion();
@@ -8479,7 +8636,10 @@ var spine = (() => {
8479
8636
  if (map.slots) {
8480
8637
  for (let slotName in map.slots) {
8481
8638
  let slotMap = map.slots[slotName];
8482
- let slotIndex = skeletonData.findSlot(slotName).index;
8639
+ let slot = skeletonData.findSlot(slotName);
8640
+ if (!slot)
8641
+ throw new Error("Slot not found: " + slotName);
8642
+ let slotIndex = slot.index;
8483
8643
  for (let timelineName in slotMap) {
8484
8644
  let timelineMap = slotMap[timelineName];
8485
8645
  if (!timelineMap)
@@ -8615,7 +8775,10 @@ var spine = (() => {
8615
8775
  if (map.bones) {
8616
8776
  for (let boneName in map.bones) {
8617
8777
  let boneMap = map.bones[boneName];
8618
- let boneIndex = skeletonData.findBone(boneName).index;
8778
+ let bone = skeletonData.findBone(boneName);
8779
+ if (!bone)
8780
+ throw new Error("Bone not found: " + boneName);
8781
+ let boneIndex = bone.index;
8619
8782
  for (let timelineName in boneMap) {
8620
8783
  let timelineMap = boneMap[timelineName];
8621
8784
  let frames = timelineMap.length;
@@ -8661,6 +8824,8 @@ var spine = (() => {
8661
8824
  if (!keyMap)
8662
8825
  continue;
8663
8826
  let constraint = skeletonData.findIkConstraint(constraintName);
8827
+ if (!constraint)
8828
+ throw new Error("IK Constraint not found: " + constraintName);
8664
8829
  let constraintIndex = skeletonData.ikConstraints.indexOf(constraint);
8665
8830
  let timeline = new IkConstraintTimeline(constraintMap.length, constraintMap.length << 1, constraintIndex);
8666
8831
  let time = getValue(keyMap, "time", 0);
@@ -8696,6 +8861,8 @@ var spine = (() => {
8696
8861
  if (!keyMap)
8697
8862
  continue;
8698
8863
  let constraint = skeletonData.findTransformConstraint(constraintName);
8864
+ if (!constraint)
8865
+ throw new Error("Transform constraint not found: " + constraintName);
8699
8866
  let constraintIndex = skeletonData.transformConstraints.indexOf(constraint);
8700
8867
  let timeline = new TransformConstraintTimeline(timelineMap.length, timelineMap.length * 6, constraintIndex);
8701
8868
  let time = getValue(keyMap, "time", 0);
@@ -8744,6 +8911,8 @@ var spine = (() => {
8744
8911
  for (let constraintName in map.path) {
8745
8912
  let constraintMap = map.path[constraintName];
8746
8913
  let constraint = skeletonData.findPathConstraint(constraintName);
8914
+ if (!constraint)
8915
+ throw new Error("Path constraint not found: " + constraintName);
8747
8916
  let constraintIndex = skeletonData.pathConstraints.indexOf(constraint);
8748
8917
  for (let timelineName in constraintMap) {
8749
8918
  let timelineMap = constraintMap[timelineName];
@@ -8795,9 +8964,14 @@ var spine = (() => {
8795
8964
  for (let attachmentsName in map.attachments) {
8796
8965
  let attachmentsMap = map.attachments[attachmentsName];
8797
8966
  let skin = skeletonData.findSkin(attachmentsName);
8967
+ if (!skin)
8968
+ throw new Error("Skin not found: " + attachmentsName);
8798
8969
  for (let slotMapName in attachmentsMap) {
8799
8970
  let slotMap = attachmentsMap[slotMapName];
8800
- let slotIndex = skeletonData.findSlot(slotMapName).index;
8971
+ let slot = skeletonData.findSlot(slotMapName);
8972
+ if (!slot)
8973
+ throw new Error("Slot not found: " + slotMapName);
8974
+ let slotIndex = slot.index;
8801
8975
  for (let attachmentMapName in slotMap) {
8802
8976
  let attachmentMap = slotMap[attachmentMapName];
8803
8977
  let attachment = skin.getAttachment(slotIndex, attachmentMapName);
@@ -8877,7 +9051,10 @@ var spine = (() => {
8877
9051
  let originalIndex = 0, unchangedIndex = 0;
8878
9052
  for (let ii = 0; ii < offsets.length; ii++) {
8879
9053
  let offsetMap = offsets[ii];
8880
- let slotIndex = skeletonData.findSlot(offsetMap.slot).index;
9054
+ let slot = skeletonData.findSlot(offsetMap.slot);
9055
+ if (!slot)
9056
+ throw new Error("Slot not found: " + slot);
9057
+ let slotIndex = slot.index;
8881
9058
  while (originalIndex != slotIndex)
8882
9059
  unchanged[unchangedIndex++] = originalIndex++;
8883
9060
  drawOrder[originalIndex + offsetMap.offset] = originalIndex++;
@@ -8898,6 +9075,8 @@ var spine = (() => {
8898
9075
  for (let i = 0; i < map.events.length; i++, frame++) {
8899
9076
  let eventMap = map.events[i];
8900
9077
  let eventData = skeletonData.findEvent(eventMap.name);
9078
+ if (!eventData)
9079
+ throw new Error("Event not found: " + eventMap.name);
8901
9080
  let event = new Event(Utils.toSinglePrecision(getValue(eventMap, "time", 0)), eventData);
8902
9081
  event.intValue = getValue(eventMap, "int", eventData.intValue);
8903
9082
  event.floatValue = getValue(eventMap, "float", eventData.floatValue);
@@ -9001,58 +9180,6 @@ var spine = (() => {
9001
9180
  }
9002
9181
  })();
9003
9182
 
9004
- // spine-core/src/vertexeffects/JitterEffect.ts
9005
- var JitterEffect = class {
9006
- constructor(jitterX, jitterY) {
9007
- this.jitterX = 0;
9008
- this.jitterY = 0;
9009
- this.jitterX = jitterX;
9010
- this.jitterY = jitterY;
9011
- }
9012
- begin(skeleton) {
9013
- }
9014
- transform(position, uv, light, dark) {
9015
- position.x += MathUtils.randomTriangular(-this.jitterX, this.jitterY);
9016
- position.y += MathUtils.randomTriangular(-this.jitterX, this.jitterY);
9017
- }
9018
- end() {
9019
- }
9020
- };
9021
-
9022
- // spine-core/src/vertexeffects/SwirlEffect.ts
9023
- var _SwirlEffect = class {
9024
- constructor(radius) {
9025
- this.centerX = 0;
9026
- this.centerY = 0;
9027
- this.radius = 0;
9028
- this.angle = 0;
9029
- this.worldX = 0;
9030
- this.worldY = 0;
9031
- this.radius = radius;
9032
- }
9033
- begin(skeleton) {
9034
- this.worldX = skeleton.x + this.centerX;
9035
- this.worldY = skeleton.y + this.centerY;
9036
- }
9037
- transform(position, uv, light, dark) {
9038
- let radAngle = this.angle * MathUtils.degreesToRadians;
9039
- let x = position.x - this.worldX;
9040
- let y = position.y - this.worldY;
9041
- let dist = Math.sqrt(x * x + y * y);
9042
- if (dist < this.radius) {
9043
- let theta = _SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
9044
- let cos = Math.cos(theta);
9045
- let sin = Math.sin(theta);
9046
- position.x = cos * x - sin * y + this.worldX;
9047
- position.y = sin * x + cos * y + this.worldY;
9048
- }
9049
- }
9050
- end() {
9051
- }
9052
- };
9053
- var SwirlEffect = _SwirlEffect;
9054
- SwirlEffect.interpolation = new PowOut(2);
9055
-
9056
9183
  // spine-canvas/src/CanvasTexture.ts
9057
9184
  var CanvasTexture = class extends Texture {
9058
9185
  constructor(image) {
@@ -9068,7 +9195,7 @@ var spine = (() => {
9068
9195
 
9069
9196
  // spine-canvas/src/AssetManager.ts
9070
9197
  var AssetManager = class extends AssetManagerBase {
9071
- constructor(pathPrefix = "", downloader = null) {
9198
+ constructor(pathPrefix = "", downloader = new Downloader()) {
9072
9199
  super((image) => {
9073
9200
  return new CanvasTexture(image);
9074
9201
  }, pathPrefix, downloader);
@@ -9156,7 +9283,8 @@ var spine = (() => {
9156
9283
  let mesh = attachment;
9157
9284
  vertices = this.computeMeshVertices(slot, mesh, false);
9158
9285
  triangles = mesh.triangles;
9159
- texture = mesh.region.renderObject.page.texture.getImage();
9286
+ let region2 = mesh.region.renderObject;
9287
+ texture = region2.page.texture.getImage();
9160
9288
  } else
9161
9289
  continue;
9162
9290
  if (texture) {