@esotericsoftware/spine-canvas 4.1.16 → 4.2.2

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.
@@ -514,7 +514,7 @@ var spine = (() => {
514
514
  super(name);
515
515
  this.id = _VertexAttachment.nextID++;
516
516
  this.bones = null;
517
- this.vertices = null;
517
+ this.vertices = [];
518
518
  this.worldVerticesLength = 0;
519
519
  this.timelineAttahment = this;
520
520
  }
@@ -585,8 +585,7 @@ var spine = (() => {
585
585
  if (this.vertices) {
586
586
  attachment.vertices = Utils.newFloatArray(this.vertices.length);
587
587
  Utils.arrayCopy(this.vertices, 0, attachment.vertices, 0, this.vertices.length);
588
- } else
589
- attachment.vertices = null;
588
+ }
590
589
  attachment.worldVerticesLength = this.worldVerticesLength;
591
590
  attachment.timelineAttahment = this.timelineAttahment;
592
591
  }
@@ -660,8 +659,8 @@ var spine = (() => {
660
659
  // spine-core/src/Animation.ts
661
660
  var Animation = class {
662
661
  constructor(name, timelines, duration) {
663
- this.timelines = null;
664
- this.timelineIds = null;
662
+ this.timelines = [];
663
+ this.timelineIds = new StringSet();
665
664
  if (!name)
666
665
  throw new Error("name cannot be null.");
667
666
  this.name = name;
@@ -672,7 +671,7 @@ var spine = (() => {
672
671
  if (!timelines)
673
672
  throw new Error("timelines cannot be null.");
674
673
  this.timelines = timelines;
675
- this.timelineIds = new StringSet();
674
+ this.timelineIds.clear();
676
675
  for (var i = 0; i < timelines.length; i++)
677
676
  this.timelineIds.addAll(timelines[i].getPropertyIds());
678
677
  }
@@ -731,8 +730,6 @@ var spine = (() => {
731
730
  };
732
731
  var Timeline = class {
733
732
  constructor(frameCount, propertyIds) {
734
- this.propertyIds = null;
735
- this.frames = null;
736
733
  this.propertyIds = propertyIds;
737
734
  this.frames = Utils.newFloatArray(frameCount * this.getFrameEntries());
738
735
  }
@@ -766,7 +763,6 @@ var spine = (() => {
766
763
  var CurveTimeline = class extends Timeline {
767
764
  constructor(frameCount, bezierCount, propertyIds) {
768
765
  super(frameCount, propertyIds);
769
- this.curves = null;
770
766
  this.curves = Utils.newFloatArray(frameCount + bezierCount * 18);
771
767
  this.curves[frameCount - 1] = 1;
772
768
  }
@@ -1826,8 +1822,6 @@ var spine = (() => {
1826
1822
  Property.deform + "|" + slotIndex + "|" + attachment.id
1827
1823
  ]);
1828
1824
  this.slotIndex = 0;
1829
- this.attachment = null;
1830
- this.vertices = null;
1831
1825
  this.slotIndex = slotIndex;
1832
1826
  this.attachment = attachment;
1833
1827
  this.vertices = new Array(frameCount);
@@ -1890,6 +1884,8 @@ var spine = (() => {
1890
1884
  if (!slot.bone.active)
1891
1885
  return;
1892
1886
  let slotAttachment = slot.getAttachment();
1887
+ if (!slotAttachment)
1888
+ return;
1893
1889
  if (!(slotAttachment instanceof VertexAttachment) || slotAttachment.timelineAttahment != this.attachment)
1894
1890
  return;
1895
1891
  let deform = slot.deform;
@@ -2044,7 +2040,6 @@ var spine = (() => {
2044
2040
  var _EventTimeline = class extends Timeline {
2045
2041
  constructor(frameCount) {
2046
2042
  super(frameCount, _EventTimeline.propertyIds);
2047
- this.events = null;
2048
2043
  this.events = new Array(frameCount);
2049
2044
  }
2050
2045
  getFrameCount() {
@@ -2087,7 +2082,6 @@ var spine = (() => {
2087
2082
  var _DrawOrderTimeline = class extends Timeline {
2088
2083
  constructor(frameCount) {
2089
2084
  super(frameCount, _DrawOrderTimeline.propertyIds);
2090
- this.drawOrders = null;
2091
2085
  this.drawOrders = new Array(frameCount);
2092
2086
  }
2093
2087
  getFrameCount() {
@@ -2108,7 +2102,8 @@ var spine = (() => {
2108
2102
  Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
2109
2103
  return;
2110
2104
  }
2111
- let drawOrderToSetupIndex = this.drawOrders[Timeline.search1(this.frames, time)];
2105
+ let idx = Timeline.search1(this.frames, time);
2106
+ let drawOrderToSetupIndex = this.drawOrders[idx];
2112
2107
  if (!drawOrderToSetupIndex)
2113
2108
  Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
2114
2109
  else {
@@ -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,9 +3789,8 @@ 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
3795
  copy.timelineAttahment = this.timelineAttahment;
3797
3796
  copy.setParentMesh(this.parentMesh ? this.parentMesh : this);
@@ -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++;
@@ -4398,7 +4395,9 @@ var spine = (() => {
4398
4395
  setRawDataURI(path, data) {
4399
4396
  this.downloader.rawDataUris[this.pathPrefix + path] = data;
4400
4397
  }
4401
- loadBinary(path, success = null, error = null) {
4398
+ loadBinary(path, success = () => {
4399
+ }, error = () => {
4400
+ }) {
4402
4401
  path = this.start(path);
4403
4402
  this.downloader.downloadBinary(path, (data) => {
4404
4403
  this.success(success, path, data);
@@ -4406,7 +4405,9 @@ var spine = (() => {
4406
4405
  this.error(error, path, `Couldn't load binary ${path}: status ${status}, ${responseText}`);
4407
4406
  });
4408
4407
  }
4409
- loadText(path, success = null, error = null) {
4408
+ loadText(path, success = () => {
4409
+ }, error = () => {
4410
+ }) {
4410
4411
  path = this.start(path);
4411
4412
  this.downloader.downloadText(path, (data) => {
4412
4413
  this.success(success, path, data);
@@ -4414,7 +4415,9 @@ var spine = (() => {
4414
4415
  this.error(error, path, `Couldn't load text ${path}: status ${status}, ${responseText}`);
4415
4416
  });
4416
4417
  }
4417
- loadJson(path, success = null, error = null) {
4418
+ loadJson(path, success = () => {
4419
+ }, error = () => {
4420
+ }) {
4418
4421
  path = this.start(path);
4419
4422
  this.downloader.downloadJson(path, (data) => {
4420
4423
  this.success(success, path, data);
@@ -4422,7 +4425,9 @@ var spine = (() => {
4422
4425
  this.error(error, path, `Couldn't load JSON ${path}: status ${status}, ${responseText}`);
4423
4426
  });
4424
4427
  }
4425
- loadTexture(path, success = null, error = null) {
4428
+ loadTexture(path, success = () => {
4429
+ }, error = () => {
4430
+ }) {
4426
4431
  path = this.start(path);
4427
4432
  let isBrowser = !!(typeof window !== "undefined" && typeof navigator !== "undefined" && window.document);
4428
4433
  let isWebWorker = !isBrowser;
@@ -4452,7 +4457,9 @@ var spine = (() => {
4452
4457
  image.src = path;
4453
4458
  }
4454
4459
  }
4455
- loadTextureAtlas(path, success = null, error = null, fileAlias = null) {
4460
+ loadTextureAtlas(path, success = () => {
4461
+ }, error = () => {
4462
+ }, fileAlias) {
4456
4463
  let index = path.lastIndexOf("/");
4457
4464
  let parent = index >= 0 ? path.substring(0, index + 1) : "";
4458
4465
  path = this.start(path);
@@ -4461,7 +4468,7 @@ var spine = (() => {
4461
4468
  let atlas = new TextureAtlas(atlasText);
4462
4469
  let toLoad = atlas.pages.length, abort = false;
4463
4470
  for (let page of atlas.pages) {
4464
- this.loadTexture(fileAlias == null ? parent + page.name : fileAlias[page.name], (imagePath, texture) => {
4471
+ this.loadTexture(!fileAlias ? parent + page.name : fileAlias[page.name], (imagePath, texture) => {
4465
4472
  if (!abort) {
4466
4473
  page.setTexture(texture);
4467
4474
  if (--toLoad == 0)
@@ -4638,7 +4645,6 @@ var spine = (() => {
4638
4645
  // spine-core/src/Event.ts
4639
4646
  var Event = class {
4640
4647
  constructor(time, data) {
4641
- this.data = null;
4642
4648
  this.intValue = 0;
4643
4649
  this.floatValue = 0;
4644
4650
  this.stringValue = null;
@@ -4655,7 +4661,6 @@ var spine = (() => {
4655
4661
  // spine-core/src/EventData.ts
4656
4662
  var EventData = class {
4657
4663
  constructor(name) {
4658
- this.name = null;
4659
4664
  this.intValue = 0;
4660
4665
  this.floatValue = 0;
4661
4666
  this.stringValue = null;
@@ -4669,9 +4674,6 @@ var spine = (() => {
4669
4674
  // spine-core/src/IkConstraint.ts
4670
4675
  var IkConstraint = class {
4671
4676
  constructor(data, skeleton) {
4672
- this.data = null;
4673
- this.bones = null;
4674
- this.target = null;
4675
4677
  this.bendDirection = 0;
4676
4678
  this.compress = false;
4677
4679
  this.stretch = false;
@@ -4689,9 +4691,16 @@ var spine = (() => {
4689
4691
  this.compress = data.compress;
4690
4692
  this.stretch = data.stretch;
4691
4693
  this.bones = new Array();
4692
- for (let i = 0; i < data.bones.length; i++)
4693
- this.bones.push(skeleton.findBone(data.bones[i].name));
4694
- 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;
4695
4704
  }
4696
4705
  isActive() {
4697
4706
  return this.active;
@@ -4712,6 +4721,8 @@ var spine = (() => {
4712
4721
  }
4713
4722
  apply1(bone, targetX, targetY, compress, stretch, uniform, alpha) {
4714
4723
  let p = bone.parent;
4724
+ if (!p)
4725
+ throw new Error("IK bone must have parent.");
4715
4726
  let pa = p.a, pb = p.b, pc = p.c, pd = p.d;
4716
4727
  let rotationIK = -bone.ashearX - bone.arotation, tx = 0, ty = 0;
4717
4728
  switch (bone.data.transformMode) {
@@ -4789,6 +4800,8 @@ var spine = (() => {
4789
4800
  cwy = c * cx + d * cy + parent.worldY;
4790
4801
  }
4791
4802
  let pp = parent.parent;
4803
+ if (!pp)
4804
+ throw new Error("IK parent must itself have a parent.");
4792
4805
  a = pp.a;
4793
4806
  b = pp.b;
4794
4807
  c = pp.c;
@@ -4910,7 +4923,7 @@ var spine = (() => {
4910
4923
  constructor(name) {
4911
4924
  super(name, 0, false);
4912
4925
  this.bones = new Array();
4913
- this.target = null;
4926
+ this._target = null;
4914
4927
  this.bendDirection = 1;
4915
4928
  this.compress = false;
4916
4929
  this.stretch = false;
@@ -4918,6 +4931,15 @@ var spine = (() => {
4918
4931
  this.mix = 1;
4919
4932
  this.softness = 0;
4920
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
+ }
4921
4943
  };
4922
4944
 
4923
4945
  // spine-core/src/PathConstraintData.ts
@@ -4925,10 +4947,10 @@ var spine = (() => {
4925
4947
  constructor(name) {
4926
4948
  super(name, 0, false);
4927
4949
  this.bones = new Array();
4928
- this.target = null;
4929
- this.positionMode = null;
4930
- this.spacingMode = null;
4931
- this.rotateMode = null;
4950
+ this._target = null;
4951
+ this.positionMode = PositionMode.Fixed;
4952
+ this.spacingMode = SpacingMode.Fixed;
4953
+ this.rotateMode = RotateMode.Chain;
4932
4954
  this.offsetRotation = 0;
4933
4955
  this.position = 0;
4934
4956
  this.spacing = 0;
@@ -4936,6 +4958,15 @@ var spine = (() => {
4936
4958
  this.mixX = 0;
4937
4959
  this.mixY = 0;
4938
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
+ }
4939
4970
  };
4940
4971
  var PositionMode;
4941
4972
  (function(PositionMode2) {
@@ -4959,9 +4990,6 @@ var spine = (() => {
4959
4990
  // spine-core/src/PathConstraint.ts
4960
4991
  var _PathConstraint = class {
4961
4992
  constructor(data, skeleton) {
4962
- this.data = null;
4963
- this.bones = null;
4964
- this.target = null;
4965
4993
  this.position = 0;
4966
4994
  this.spacing = 0;
4967
4995
  this.mixRotate = 0;
@@ -4980,9 +5008,16 @@ var spine = (() => {
4980
5008
  throw new Error("skeleton cannot be null.");
4981
5009
  this.data = data;
4982
5010
  this.bones = new Array();
4983
- for (let i = 0, n = data.bones.length; i < n; i++)
4984
- this.bones.push(skeleton.findBone(data.bones[i].name));
4985
- 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;
4986
5021
  this.position = data.position;
4987
5022
  this.spacing = data.spacing;
4988
5023
  this.mixRotate = data.mixRotate;
@@ -5003,7 +5038,7 @@ var spine = (() => {
5003
5038
  let tangents = data.rotateMode == RotateMode.Tangent, scale = data.rotateMode == RotateMode.ChainScale;
5004
5039
  let bones = this.bones;
5005
5040
  let boneCount = bones.length, spacesCount = tangents ? boneCount : boneCount + 1;
5006
- 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) : [];
5007
5042
  let spacing = this.spacing;
5008
5043
  switch (data.spacingMode) {
5009
5044
  case SpacingMode.Percent:
@@ -5124,7 +5159,7 @@ var spine = (() => {
5124
5159
  computeWorldPositions(path, spacesCount, tangents) {
5125
5160
  let target = this.target;
5126
5161
  let position = this.position;
5127
- 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;
5128
5163
  let closed2 = path.closed;
5129
5164
  let verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = _PathConstraint.NONE;
5130
5165
  if (!path.constantSpeed) {
@@ -5381,12 +5416,10 @@ var spine = (() => {
5381
5416
  // spine-core/src/Slot.ts
5382
5417
  var Slot = class {
5383
5418
  constructor(data, bone) {
5384
- this.data = null;
5385
- this.bone = null;
5386
- this.color = null;
5387
5419
  this.darkColor = null;
5388
5420
  this.attachment = null;
5389
5421
  this.attachmentState = 0;
5422
+ this.sequenceIndex = -1;
5390
5423
  this.deform = new Array();
5391
5424
  if (!data)
5392
5425
  throw new Error("data cannot be null.");
@@ -5429,9 +5462,6 @@ var spine = (() => {
5429
5462
  // spine-core/src/TransformConstraint.ts
5430
5463
  var TransformConstraint = class {
5431
5464
  constructor(data, skeleton) {
5432
- this.data = null;
5433
- this.bones = null;
5434
- this.target = null;
5435
5465
  this.mixRotate = 0;
5436
5466
  this.mixX = 0;
5437
5467
  this.mixY = 0;
@@ -5452,9 +5482,16 @@ var spine = (() => {
5452
5482
  this.mixScaleY = data.mixScaleY;
5453
5483
  this.mixShearY = data.mixShearY;
5454
5484
  this.bones = new Array();
5455
- for (let i = 0; i < data.bones.length; i++)
5456
- this.bones.push(skeleton.findBone(data.bones[i].name));
5457
- 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;
5458
5495
  }
5459
5496
  isActive() {
5460
5497
  return this.active;
@@ -5639,16 +5676,8 @@ var spine = (() => {
5639
5676
  // spine-core/src/Skeleton.ts
5640
5677
  var Skeleton = class {
5641
5678
  constructor(data) {
5642
- this.data = null;
5643
- this.bones = null;
5644
- this.slots = null;
5645
- this.drawOrder = null;
5646
- this.ikConstraints = null;
5647
- this.transformConstraints = null;
5648
- this.pathConstraints = null;
5649
5679
  this._updateCache = new Array();
5650
5680
  this.skin = null;
5651
- this.color = null;
5652
5681
  this.scaleX = 1;
5653
5682
  this.scaleY = 1;
5654
5683
  this.x = 0;
@@ -5843,6 +5872,8 @@ var spine = (() => {
5843
5872
  }
5844
5873
  }
5845
5874
  sortBone(bone) {
5875
+ if (!bone)
5876
+ return;
5846
5877
  if (bone.sorted)
5847
5878
  return;
5848
5879
  let parent = bone.parent;
@@ -5879,6 +5910,8 @@ var spine = (() => {
5879
5910
  }
5880
5911
  updateWorldTransformWith(parent) {
5881
5912
  let rootBone = this.getRootBone();
5913
+ if (!rootBone)
5914
+ throw new Error("Root bone must not be null.");
5882
5915
  let pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;
5883
5916
  rootBone.worldX = pa * this.x + pb * this.y + parent.worldX;
5884
5917
  rootBone.worldY = pc * this.x + pd * this.y + parent.worldY;
@@ -5999,7 +6032,10 @@ var spine = (() => {
5999
6032
  this.updateCache();
6000
6033
  }
6001
6034
  getAttachmentByName(slotName, attachmentName) {
6002
- 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);
6003
6039
  }
6004
6040
  getAttachment(slotIndex, attachmentName) {
6005
6041
  if (!attachmentName)
@@ -6225,7 +6261,7 @@ var spine = (() => {
6225
6261
 
6226
6262
  // spine-core/src/Skin.ts
6227
6263
  var SkinEntry = class {
6228
- constructor(slotIndex = 0, name = null, attachment = null) {
6264
+ constructor(slotIndex = 0, name, attachment) {
6229
6265
  this.slotIndex = slotIndex;
6230
6266
  this.name = name;
6231
6267
  this.attachment = attachment;
@@ -6233,7 +6269,6 @@ var spine = (() => {
6233
6269
  };
6234
6270
  var Skin = class {
6235
6271
  constructor(name) {
6236
- this.name = null;
6237
6272
  this.attachments = new Array();
6238
6273
  this.bones = Array();
6239
6274
  this.constraints = new Array();
@@ -6328,7 +6363,7 @@ var spine = (() => {
6328
6363
  removeAttachment(slotIndex, name) {
6329
6364
  let dictionary = this.attachments[slotIndex];
6330
6365
  if (dictionary)
6331
- dictionary[name] = null;
6366
+ delete dictionary[name];
6332
6367
  }
6333
6368
  getAttachments() {
6334
6369
  let entries = new Array();
@@ -6385,12 +6420,10 @@ var spine = (() => {
6385
6420
  var SlotData = class {
6386
6421
  constructor(index, name, boneData) {
6387
6422
  this.index = 0;
6388
- this.name = null;
6389
- this.boneData = null;
6390
6423
  this.color = new Color(1, 1, 1, 1);
6391
6424
  this.darkColor = null;
6392
6425
  this.attachmentName = null;
6393
- this.blendMode = null;
6426
+ this.blendMode = BlendMode.Normal;
6394
6427
  if (index < 0)
6395
6428
  throw new Error("index must be >= 0.");
6396
6429
  if (!name)
@@ -6415,7 +6448,7 @@ var spine = (() => {
6415
6448
  constructor(name) {
6416
6449
  super(name, 0, false);
6417
6450
  this.bones = new Array();
6418
- this.target = null;
6451
+ this._target = null;
6419
6452
  this.mixRotate = 0;
6420
6453
  this.mixX = 0;
6421
6454
  this.mixY = 0;
@@ -6431,13 +6464,21 @@ var spine = (() => {
6431
6464
  this.relative = false;
6432
6465
  this.local = false;
6433
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
+ }
6434
6476
  };
6435
6477
 
6436
6478
  // spine-core/src/SkeletonBinary.ts
6437
6479
  var SkeletonBinary = class {
6438
6480
  constructor(attachmentLoader) {
6439
6481
  this.scale = 1;
6440
- this.attachmentLoader = null;
6441
6482
  this.linkedMeshes = new Array();
6442
6483
  this.attachmentLoader = attachmentLoader;
6443
6484
  }
@@ -6462,11 +6503,17 @@ var spine = (() => {
6462
6503
  }
6463
6504
  let n = 0;
6464
6505
  n = input.readInt(true);
6465
- for (let i = 0; i < n; i++)
6466
- 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
+ }
6467
6512
  n = input.readInt(true);
6468
6513
  for (let i = 0; i < n; i++) {
6469
6514
  let name = input.readString();
6515
+ if (!name)
6516
+ throw new Error("Bone name must not be null.");
6470
6517
  let parent = i == 0 ? null : skeletonData.bones[input.readInt(true)];
6471
6518
  let data = new BoneData(i, name, parent);
6472
6519
  data.rotation = input.readFloat();
@@ -6486,6 +6533,8 @@ var spine = (() => {
6486
6533
  n = input.readInt(true);
6487
6534
  for (let i = 0; i < n; i++) {
6488
6535
  let slotName = input.readString();
6536
+ if (!slotName)
6537
+ throw new Error("Slot name must not be null.");
6489
6538
  let boneData = skeletonData.bones[input.readInt(true)];
6490
6539
  let data = new SlotData(i, slotName, boneData);
6491
6540
  Color.rgba8888ToColor(data.color, input.readInt32());
@@ -6498,7 +6547,10 @@ var spine = (() => {
6498
6547
  }
6499
6548
  n = input.readInt(true);
6500
6549
  for (let i = 0, nn; i < n; i++) {
6501
- 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);
6502
6554
  data.order = input.readInt(true);
6503
6555
  data.skinRequired = input.readBoolean();
6504
6556
  nn = input.readInt(true);
@@ -6515,7 +6567,10 @@ var spine = (() => {
6515
6567
  }
6516
6568
  n = input.readInt(true);
6517
6569
  for (let i = 0, nn; i < n; i++) {
6518
- 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);
6519
6574
  data.order = input.readInt(true);
6520
6575
  data.skinRequired = input.readBoolean();
6521
6576
  nn = input.readInt(true);
@@ -6540,7 +6595,10 @@ var spine = (() => {
6540
6595
  }
6541
6596
  n = input.readInt(true);
6542
6597
  for (let i = 0, nn; i < n; i++) {
6543
- 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);
6544
6602
  data.order = input.readInt(true);
6545
6603
  data.skinRequired = input.readBoolean();
6546
6604
  nn = input.readInt(true);
@@ -6570,14 +6628,24 @@ var spine = (() => {
6570
6628
  {
6571
6629
  let i = skeletonData.skins.length;
6572
6630
  Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true));
6573
- for (; i < n; i++)
6574
- 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
+ }
6575
6637
  }
6576
6638
  n = this.linkedMeshes.length;
6577
6639
  for (let i = 0; i < n; i++) {
6578
6640
  let linkedMesh = this.linkedMeshes[i];
6579
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");
6580
6646
  let parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
6647
+ if (!parent)
6648
+ throw new Error(`Parent mesh not found: ${linkedMesh.parent}`);
6581
6649
  linkedMesh.mesh.timelineAttahment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
6582
6650
  linkedMesh.mesh.setParentMesh(parent);
6583
6651
  if (linkedMesh.mesh.region != null)
@@ -6586,7 +6654,10 @@ var spine = (() => {
6586
6654
  this.linkedMeshes.length = 0;
6587
6655
  n = input.readInt(true);
6588
6656
  for (let i = 0; i < n; i++) {
6589
- let data = new EventData(input.readStringRef());
6657
+ let eventName = input.readStringRef();
6658
+ if (!eventName)
6659
+ throw new Error();
6660
+ let data = new EventData(eventName);
6590
6661
  data.intValue = input.readInt(false);
6591
6662
  data.floatValue = input.readFloat();
6592
6663
  data.stringValue = input.readString();
@@ -6598,8 +6669,12 @@ var spine = (() => {
6598
6669
  skeletonData.events.push(data);
6599
6670
  }
6600
6671
  n = input.readInt(true);
6601
- for (let i = 0; i < n; i++)
6602
- 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
+ }
6603
6678
  return skeletonData;
6604
6679
  }
6605
6680
  readSkin(input, skeletonData, defaultSkin, nonessential) {
@@ -6611,7 +6686,10 @@ var spine = (() => {
6611
6686
  return null;
6612
6687
  skin = new Skin("default");
6613
6688
  } else {
6614
- 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);
6615
6693
  skin.bones.length = input.readInt(true);
6616
6694
  for (let i = 0, n = skin.bones.length; i < n; i++)
6617
6695
  skin.bones[i] = skeletonData.bones[input.readInt(true)];
@@ -6627,6 +6705,8 @@ var spine = (() => {
6627
6705
  let slotIndex = input.readInt(true);
6628
6706
  for (let ii = 0, nn = input.readInt(true); ii < nn; ii++) {
6629
6707
  let name = input.readStringRef();
6708
+ if (!name)
6709
+ throw new Error("Attachment name must not be null");
6630
6710
  let attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name, nonessential);
6631
6711
  if (attachment)
6632
6712
  skin.setAttachment(slotIndex, name, attachment);
@@ -6693,7 +6773,7 @@ var spine = (() => {
6693
6773
  let vertices = this.readVertices(input, vertexCount);
6694
6774
  let hullLength = input.readInt(true);
6695
6775
  let sequence = this.readSequence(input);
6696
- let edges = null;
6776
+ let edges = [];
6697
6777
  let width = 0, height = 0;
6698
6778
  if (nonessential) {
6699
6779
  edges = this.readShortArray(input);
@@ -7195,6 +7275,8 @@ var spine = (() => {
7195
7275
  let slotIndex = input.readInt(true);
7196
7276
  for (let iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
7197
7277
  let attachmentName = input.readStringRef();
7278
+ if (!attachmentName)
7279
+ throw new Error("attachmentName must not be null.");
7198
7280
  let attachment = skin.getAttachment(slotIndex, attachmentName);
7199
7281
  let timelineType = input.readByte();
7200
7282
  let frameCount = input.readInt(true);
@@ -7870,6 +7952,8 @@ var spine = (() => {
7870
7952
  this.clippedVertices = new Array();
7871
7953
  this.clippedTriangles = new Array();
7872
7954
  this.scratch = new Array();
7955
+ this.clipAttachment = null;
7956
+ this.clippingPolygons = null;
7873
7957
  }
7874
7958
  clipStart(slot, clip) {
7875
7959
  if (this.clipAttachment)
@@ -7909,7 +7993,7 @@ var spine = (() => {
7909
7993
  let clipOutput = this.clipOutput, clippedVertices = this.clippedVertices;
7910
7994
  let clippedTriangles = this.clippedTriangles;
7911
7995
  let polygons = this.clippingPolygons;
7912
- let polygonsCount = this.clippingPolygons.length;
7996
+ let polygonsCount = polygons.length;
7913
7997
  let vertexSize = twoColor ? 12 : 8;
7914
7998
  let index = 0;
7915
7999
  clippedVertices.length = 0;
@@ -8041,7 +8125,7 @@ var spine = (() => {
8041
8125
  clip(x1, y1, x2, y2, x3, y3, clippingArea, output) {
8042
8126
  let originalOutput = output;
8043
8127
  let clipped = false;
8044
- let input = null;
8128
+ let input;
8045
8129
  if (clippingArea.length % 4 >= 2) {
8046
8130
  input = output;
8047
8131
  output = this.scratch;
@@ -8149,7 +8233,6 @@ var spine = (() => {
8149
8233
  // spine-core/src/SkeletonJson.ts
8150
8234
  var SkeletonJson = class {
8151
8235
  constructor(attachmentLoader) {
8152
- this.attachmentLoader = null;
8153
8236
  this.scale = 1;
8154
8237
  this.linkedMeshes = new Array();
8155
8238
  this.attachmentLoader = attachmentLoader;
@@ -8197,6 +8280,8 @@ var spine = (() => {
8197
8280
  for (let i = 0; i < root.slots.length; i++) {
8198
8281
  let slotMap = root.slots[i];
8199
8282
  let boneData = skeletonData.findBone(slotMap.bone);
8283
+ if (!boneData)
8284
+ throw new Error(`Couldn't find bone ${slotMap.bone} for slot ${slotMap.name}`);
8200
8285
  let data = new SlotData(skeletonData.slots.length, slotMap.name, boneData);
8201
8286
  let color = getValue(slotMap, "color", null);
8202
8287
  if (color)
@@ -8215,9 +8300,17 @@ var spine = (() => {
8215
8300
  let data = new IkConstraintData(constraintMap.name);
8216
8301
  data.order = getValue(constraintMap, "order", 0);
8217
8302
  data.skinRequired = getValue(constraintMap, "skin", false);
8218
- for (let ii = 0; ii < constraintMap.bones.length; ii++)
8219
- data.bones.push(skeletonData.findBone(constraintMap.bones[ii]));
8220
- 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;
8221
8314
  data.mix = getValue(constraintMap, "mix", 1);
8222
8315
  data.softness = getValue(constraintMap, "softness", 0) * scale;
8223
8316
  data.bendDirection = getValue(constraintMap, "bendPositive", true) ? 1 : -1;
@@ -8233,10 +8326,18 @@ var spine = (() => {
8233
8326
  let data = new TransformConstraintData(constraintMap.name);
8234
8327
  data.order = getValue(constraintMap, "order", 0);
8235
8328
  data.skinRequired = getValue(constraintMap, "skin", false);
8236
- for (let ii = 0; ii < constraintMap.bones.length; ii++)
8237
- 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
+ }
8238
8336
  let targetName = constraintMap.target;
8239
- 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;
8240
8341
  data.local = getValue(constraintMap, "local", false);
8241
8342
  data.relative = getValue(constraintMap, "relative", false);
8242
8343
  data.offsetRotation = getValue(constraintMap, "rotation", 0);
@@ -8260,10 +8361,18 @@ var spine = (() => {
8260
8361
  let data = new PathConstraintData(constraintMap.name);
8261
8362
  data.order = getValue(constraintMap, "order", 0);
8262
8363
  data.skinRequired = getValue(constraintMap, "skin", false);
8263
- for (let ii = 0; ii < constraintMap.bones.length; ii++)
8264
- 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
+ }
8265
8371
  let targetName = constraintMap.target;
8266
- 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;
8267
8376
  data.positionMode = Utils.enumValue(PositionMode, getValue(constraintMap, "positionMode", "Percent"));
8268
8377
  data.spacingMode = Utils.enumValue(SpacingMode, getValue(constraintMap, "spacingMode", "Length"));
8269
8378
  data.rotateMode = Utils.enumValue(RotateMode, getValue(constraintMap, "rotateMode", "Tangent"));
@@ -8285,23 +8394,45 @@ var spine = (() => {
8285
8394
  let skinMap = root.skins[i];
8286
8395
  let skin = new Skin(skinMap.name);
8287
8396
  if (skinMap.bones) {
8288
- for (let ii = 0; ii < skinMap.bones.length; ii++)
8289
- 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
+ }
8290
8404
  }
8291
8405
  if (skinMap.ik) {
8292
- for (let ii = 0; ii < skinMap.ik.length; ii++)
8293
- 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
+ }
8294
8413
  }
8295
8414
  if (skinMap.transform) {
8296
- for (let ii = 0; ii < skinMap.transform.length; ii++)
8297
- 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
+ }
8298
8422
  }
8299
8423
  if (skinMap.path) {
8300
- for (let ii = 0; ii < skinMap.path.length; ii++)
8301
- 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
+ }
8302
8431
  }
8303
8432
  for (let slotName in skinMap.attachments) {
8304
8433
  let slot = skeletonData.findSlot(slotName);
8434
+ if (!slot)
8435
+ throw new Error(`Couldn't find slot ${slotName} for skin ${skinMap.name}.`);
8305
8436
  let slotMap = skinMap.attachments[slotName];
8306
8437
  for (let entryName in slotMap) {
8307
8438
  let attachment = this.readAttachment(slotMap[entryName], skin, slot.index, entryName, skeletonData);
@@ -8317,7 +8448,11 @@ var spine = (() => {
8317
8448
  for (let i = 0, n = this.linkedMeshes.length; i < n; i++) {
8318
8449
  let linkedMesh = this.linkedMeshes[i];
8319
8450
  let skin = !linkedMesh.skin ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);
8451
+ if (!skin)
8452
+ throw new Error(`Skin not found: ${linkedMesh.skin}`);
8320
8453
  let parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
8454
+ if (!parent)
8455
+ throw new Error(`Parent mesh not found: ${linkedMesh.parent}`);
8321
8456
  linkedMesh.mesh.timelineAttahment = linkedMesh.inheritTimeline ? parent : linkedMesh.mesh;
8322
8457
  linkedMesh.mesh.setParentMesh(parent);
8323
8458
  if (linkedMesh.mesh.region != null)
@@ -8501,7 +8636,10 @@ var spine = (() => {
8501
8636
  if (map.slots) {
8502
8637
  for (let slotName in map.slots) {
8503
8638
  let slotMap = map.slots[slotName];
8504
- 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;
8505
8643
  for (let timelineName in slotMap) {
8506
8644
  let timelineMap = slotMap[timelineName];
8507
8645
  if (!timelineMap)
@@ -8637,7 +8775,10 @@ var spine = (() => {
8637
8775
  if (map.bones) {
8638
8776
  for (let boneName in map.bones) {
8639
8777
  let boneMap = map.bones[boneName];
8640
- 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;
8641
8782
  for (let timelineName in boneMap) {
8642
8783
  let timelineMap = boneMap[timelineName];
8643
8784
  let frames = timelineMap.length;
@@ -8683,6 +8824,8 @@ var spine = (() => {
8683
8824
  if (!keyMap)
8684
8825
  continue;
8685
8826
  let constraint = skeletonData.findIkConstraint(constraintName);
8827
+ if (!constraint)
8828
+ throw new Error("IK Constraint not found: " + constraintName);
8686
8829
  let constraintIndex = skeletonData.ikConstraints.indexOf(constraint);
8687
8830
  let timeline = new IkConstraintTimeline(constraintMap.length, constraintMap.length << 1, constraintIndex);
8688
8831
  let time = getValue(keyMap, "time", 0);
@@ -8718,6 +8861,8 @@ var spine = (() => {
8718
8861
  if (!keyMap)
8719
8862
  continue;
8720
8863
  let constraint = skeletonData.findTransformConstraint(constraintName);
8864
+ if (!constraint)
8865
+ throw new Error("Transform constraint not found: " + constraintName);
8721
8866
  let constraintIndex = skeletonData.transformConstraints.indexOf(constraint);
8722
8867
  let timeline = new TransformConstraintTimeline(timelineMap.length, timelineMap.length * 6, constraintIndex);
8723
8868
  let time = getValue(keyMap, "time", 0);
@@ -8766,6 +8911,8 @@ var spine = (() => {
8766
8911
  for (let constraintName in map.path) {
8767
8912
  let constraintMap = map.path[constraintName];
8768
8913
  let constraint = skeletonData.findPathConstraint(constraintName);
8914
+ if (!constraint)
8915
+ throw new Error("Path constraint not found: " + constraintName);
8769
8916
  let constraintIndex = skeletonData.pathConstraints.indexOf(constraint);
8770
8917
  for (let timelineName in constraintMap) {
8771
8918
  let timelineMap = constraintMap[timelineName];
@@ -8817,9 +8964,14 @@ var spine = (() => {
8817
8964
  for (let attachmentsName in map.attachments) {
8818
8965
  let attachmentsMap = map.attachments[attachmentsName];
8819
8966
  let skin = skeletonData.findSkin(attachmentsName);
8967
+ if (!skin)
8968
+ throw new Error("Skin not found: " + attachmentsName);
8820
8969
  for (let slotMapName in attachmentsMap) {
8821
8970
  let slotMap = attachmentsMap[slotMapName];
8822
- 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;
8823
8975
  for (let attachmentMapName in slotMap) {
8824
8976
  let attachmentMap = slotMap[attachmentMapName];
8825
8977
  let attachment = skin.getAttachment(slotIndex, attachmentMapName);
@@ -8899,7 +9051,10 @@ var spine = (() => {
8899
9051
  let originalIndex = 0, unchangedIndex = 0;
8900
9052
  for (let ii = 0; ii < offsets.length; ii++) {
8901
9053
  let offsetMap = offsets[ii];
8902
- 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;
8903
9058
  while (originalIndex != slotIndex)
8904
9059
  unchanged[unchangedIndex++] = originalIndex++;
8905
9060
  drawOrder[originalIndex + offsetMap.offset] = originalIndex++;
@@ -8920,6 +9075,8 @@ var spine = (() => {
8920
9075
  for (let i = 0; i < map.events.length; i++, frame++) {
8921
9076
  let eventMap = map.events[i];
8922
9077
  let eventData = skeletonData.findEvent(eventMap.name);
9078
+ if (!eventData)
9079
+ throw new Error("Event not found: " + eventMap.name);
8923
9080
  let event = new Event(Utils.toSinglePrecision(getValue(eventMap, "time", 0)), eventData);
8924
9081
  event.intValue = getValue(eventMap, "int", eventData.intValue);
8925
9082
  event.floatValue = getValue(eventMap, "float", eventData.floatValue);
@@ -9090,7 +9247,7 @@ var spine = (() => {
9090
9247
 
9091
9248
  // spine-canvas/src/AssetManager.ts
9092
9249
  var AssetManager = class extends AssetManagerBase {
9093
- constructor(pathPrefix = "", downloader = null) {
9250
+ constructor(pathPrefix = "", downloader = new Downloader()) {
9094
9251
  super((image) => {
9095
9252
  return new CanvasTexture(image);
9096
9253
  }, pathPrefix, downloader);
@@ -9178,7 +9335,8 @@ var spine = (() => {
9178
9335
  let mesh = attachment;
9179
9336
  vertices = this.computeMeshVertices(slot, mesh, false);
9180
9337
  triangles = mesh.triangles;
9181
- texture = mesh.region.renderObject.page.texture.getImage();
9338
+ let region2 = mesh.region.renderObject;
9339
+ texture = region2.page.texture.getImage();
9182
9340
  } else
9183
9341
  continue;
9184
9342
  if (texture) {