stage-js 1.0.1 → 1.0.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.
package/dist/stage.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Stage.js v1.0.1
2
+ * Stage.js v1.0.2
3
3
  * @copyright Copyright Ali Shakiba
4
4
  * @license Licensed under the MIT (https://github.com/piqnt/stage.js/blob/main/LICENSE.md)
5
5
  */
@@ -52,7 +52,7 @@ math.rotate = wrap;
52
52
  math.limit = clamp;
53
53
  var Matrix = (
54
54
  /** @class */
55
- function() {
55
+ (function() {
56
56
  function Matrix2(a, b, c, d, e, f) {
57
57
  this.a = 1;
58
58
  this.b = 0;
@@ -216,7 +216,7 @@ var Matrix = (
216
216
  return this.b * x + this.d * y + this.f;
217
217
  };
218
218
  return Matrix2;
219
- }()
219
+ })()
220
220
  );
221
221
  /*! *****************************************************************************
222
222
  Copyright (c) Microsoft Corporation.
@@ -373,7 +373,7 @@ var uid = function() {
373
373
  };
374
374
  var Texture = (
375
375
  /** @class */
376
- function() {
376
+ (function() {
377
377
  function Texture2() {
378
378
  this.uid = "texture:" + uid();
379
379
  this.sx = 0;
@@ -431,11 +431,11 @@ var Texture = (
431
431
  this.drawWithNormalizedArgs(context, sx, sy, sw, sh, dx, dy, dw, dh);
432
432
  };
433
433
  return Texture2;
434
- }()
434
+ })()
435
435
  );
436
436
  var ImageTexture = (
437
437
  /** @class */
438
- function(_super) {
438
+ (function(_super) {
439
439
  __extends(ImageTexture2, _super);
440
440
  function ImageTexture2(source, pixelRatio) {
441
441
  var _this = _super.call(this) || this;
@@ -492,11 +492,11 @@ var ImageTexture = (
492
492
  }
493
493
  };
494
494
  return ImageTexture2;
495
- }(Texture)
495
+ })(Texture)
496
496
  );
497
497
  var PipeTexture = (
498
498
  /** @class */
499
- function(_super) {
499
+ (function(_super) {
500
500
  __extends(PipeTexture2, _super);
501
501
  function PipeTexture2(source) {
502
502
  var _this = _super.call(this) || this;
@@ -525,11 +525,11 @@ var PipeTexture = (
525
525
  texture2.draw(context, sx, sy, sw, sh, dx, dy, dw, dh);
526
526
  };
527
527
  return PipeTexture2;
528
- }(Texture)
528
+ })(Texture)
529
529
  );
530
530
  var Atlas = (
531
531
  /** @class */
532
- function(_super) {
532
+ (function(_super) {
533
533
  __extends(Atlas2, _super);
534
534
  function Atlas2(def) {
535
535
  if (def === void 0) {
@@ -644,7 +644,7 @@ var Atlas = (
644
644
  });
645
645
  };
646
646
  return Atlas2;
647
- }(ImageTexture)
647
+ })(ImageTexture)
648
648
  );
649
649
  function asyncLoadImage(src) {
650
650
  console.debug && console.debug("Loading image: " + src);
@@ -684,7 +684,7 @@ function isAtlasSpriteDefinition(selection) {
684
684
  }
685
685
  var TextureSelection = (
686
686
  /** @class */
687
- function() {
687
+ (function() {
688
688
  function TextureSelection2(selection, atlas2) {
689
689
  this.selection = selection;
690
690
  this.atlas = atlas2;
@@ -727,10 +727,10 @@ var TextureSelection = (
727
727
  return array;
728
728
  };
729
729
  return TextureSelection2;
730
- }()
730
+ })()
731
731
  );
732
732
  var NO_TEXTURE = new /** @class */
733
- (function(_super) {
733
+ ((function(_super) {
734
734
  __extends(class_1, _super);
735
735
  function class_1() {
736
736
  var _this = _super.call(this) || this;
@@ -759,7 +759,7 @@ var NO_TEXTURE = new /** @class */
759
759
  class_1.prototype.draw = function() {
760
760
  };
761
761
  return class_1;
762
- }(Texture))();
762
+ })(Texture))();
763
763
  var NO_SELECTION = new TextureSelection(NO_TEXTURE);
764
764
  var ATLAS_MEMO_BY_NAME = {};
765
765
  var ATLAS_ARRAY = [];
@@ -839,7 +839,7 @@ function texture(query) {
839
839
  }
840
840
  var ResizableTexture = (
841
841
  /** @class */
842
- function(_super) {
842
+ (function(_super) {
843
843
  __extends(ResizableTexture2, _super);
844
844
  function ResizableTexture2(source, mode) {
845
845
  var _this = _super.call(this) || this;
@@ -936,7 +936,7 @@ var ResizableTexture = (
936
936
  }
937
937
  };
938
938
  return ResizableTexture2;
939
- }(Texture)
939
+ })(Texture)
940
940
  );
941
941
  function getDevicePixelRatio() {
942
942
  return typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
@@ -945,9 +945,12 @@ function isValidFitMode(value) {
945
945
  return value && (value === "cover" || value === "contain" || value === "fill" || value === "in" || value === "in-pad" || value === "out" || value === "out-crop");
946
946
  }
947
947
  var iid$1 = 0;
948
+ function getIID() {
949
+ return iid$1++;
950
+ }
948
951
  var Pin = (
949
952
  /** @class */
950
- function() {
953
+ (function() {
951
954
  function Pin2(owner) {
952
955
  this.uid = "pin:" + uid();
953
956
  this._directionX = 1;
@@ -1012,6 +1015,7 @@ var Pin = (
1012
1015
  var abs = this._absoluteMatrix;
1013
1016
  abs.reset(this.relativeMatrix());
1014
1017
  this._parent && abs.concat(this._parent._absoluteMatrix);
1018
+ this._owner._xf && abs.concat(this._owner._xf);
1015
1019
  this._ts_matrix = ++iid$1;
1016
1020
  return abs;
1017
1021
  };
@@ -1135,8 +1139,39 @@ var Pin = (
1135
1139
  }
1136
1140
  };
1137
1141
  return Pin2;
1138
- }()
1142
+ })()
1139
1143
  );
1144
+ function fit(inWidth, inHeight, outWidth, outHeight, mode) {
1145
+ if (mode === "contain")
1146
+ mode = "in-pad";
1147
+ if (mode === "cover")
1148
+ mode = "out-crop";
1149
+ var scaleX;
1150
+ var scaleY;
1151
+ var width;
1152
+ var height;
1153
+ if (typeof outWidth === "number") {
1154
+ scaleX = outWidth / inWidth;
1155
+ width = inWidth;
1156
+ }
1157
+ if (typeof outHeight === "number") {
1158
+ scaleY = outHeight / inHeight;
1159
+ height = inHeight;
1160
+ }
1161
+ if (typeof outWidth === "number" && typeof outHeight === "number" && typeof mode === "string") {
1162
+ if (mode === "fill") ;
1163
+ else if (mode === "out" || mode === "out-crop") {
1164
+ scaleX = scaleY = Math.max(scaleX, scaleY);
1165
+ } else if (mode === "in" || mode === "in-pad") {
1166
+ scaleX = scaleY = Math.min(scaleX, scaleY);
1167
+ }
1168
+ if (mode === "out-crop" || mode === "in-pad") {
1169
+ width = outWidth / scaleX;
1170
+ height = outHeight / scaleY;
1171
+ }
1172
+ }
1173
+ return { scaleX, scaleY, width, height };
1174
+ }
1140
1175
  var getters = {
1141
1176
  alpha: function(pin) {
1142
1177
  return pin._alpha;
@@ -1364,7 +1399,7 @@ var IDENTITY = function(x) {
1364
1399
  };
1365
1400
  var Easing = (
1366
1401
  /** @class */
1367
- function() {
1402
+ (function() {
1368
1403
  function Easing2() {
1369
1404
  }
1370
1405
  Easing2.init = function(query, params) {
@@ -1386,7 +1421,7 @@ var Easing = (
1386
1421
  return easing;
1387
1422
  };
1388
1423
  return Easing2;
1389
- }()
1424
+ })()
1390
1425
  );
1391
1426
  var initEasing = function(query, params) {
1392
1427
  var easing;
@@ -1446,6 +1481,9 @@ var bounce = function(t) {
1446
1481
  return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + 0.75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375 : 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;
1447
1482
  };
1448
1483
  var poly = function(e) {
1484
+ if (e === void 0) {
1485
+ e = 3;
1486
+ }
1449
1487
  return function(t) {
1450
1488
  return Math.pow(t, e);
1451
1489
  };
@@ -1569,7 +1607,7 @@ var EasingFactories = {
1569
1607
  };
1570
1608
  var Transition = (
1571
1609
  /** @class */
1572
- function() {
1610
+ (function() {
1573
1611
  function Transition2(owner, options) {
1574
1612
  if (options === void 0) {
1575
1613
  options = {};
@@ -1739,7 +1777,7 @@ var Transition = (
1739
1777
  return this;
1740
1778
  };
1741
1779
  return Transition2;
1742
- }()
1780
+ })()
1743
1781
  );
1744
1782
  function pinning(component2, map, key, value) {
1745
1783
  if (typeof component2._pin.get(key) === "number") {
@@ -1749,6 +1787,37 @@ function pinning(component2, map, key, value) {
1749
1787
  map[key + "Y"] = value;
1750
1788
  }
1751
1789
  }
1790
+ function renderAxis(ctx, size) {
1791
+ ctx.strokeStyle = "rgba(93, 173, 226)";
1792
+ ctx.beginPath();
1793
+ ctx.moveTo(0, 0);
1794
+ ctx.lineTo(0, 0.8 * size);
1795
+ ctx.lineTo(-0.2 * size, 0.8 * size);
1796
+ ctx.lineTo(0, size);
1797
+ ctx.lineTo(0.2 * size, 0.8 * size);
1798
+ ctx.lineTo(0, 0.8 * size);
1799
+ ctx.stroke();
1800
+ ctx.strokeStyle = "rgba(236, 112, 99)";
1801
+ ctx.beginPath();
1802
+ ctx.moveTo(0, 0);
1803
+ ctx.lineTo(0.8 * size, 0);
1804
+ ctx.lineTo(0.8 * size, -0.2 * size);
1805
+ ctx.lineTo(size, 0);
1806
+ ctx.lineTo(0.8 * size, 0.2 * size);
1807
+ ctx.lineTo(0.8 * size, 0);
1808
+ ctx.stroke();
1809
+ }
1810
+ function renderPoint(ctx, px, py) {
1811
+ ctx.beginPath();
1812
+ ctx.beginPath();
1813
+ ctx.moveTo(px - 0.2, py - 0.2);
1814
+ ctx.lineTo(px + 0.2, py + 0.2);
1815
+ ctx.stroke();
1816
+ ctx.beginPath();
1817
+ ctx.moveTo(px - 0.2, py + 0.2);
1818
+ ctx.lineTo(px + 0.2, py - 0.2);
1819
+ ctx.stroke();
1820
+ }
1752
1821
  var iid = 0;
1753
1822
  stats.create = 0;
1754
1823
  function assertType(obj) {
@@ -1786,7 +1855,7 @@ function maximize() {
1786
1855
  }
1787
1856
  var Component = (
1788
1857
  /** @class */
1789
- function() {
1858
+ (function() {
1790
1859
  function Component2() {
1791
1860
  var _this = this;
1792
1861
  this.uid = "component:" + uid();
@@ -1848,15 +1917,14 @@ var Component = (
1848
1917
  return this._pin.absoluteMatrix();
1849
1918
  };
1850
1919
  Component2.prototype.getPixelRatio = function() {
1851
- var _a;
1852
- var m = (_a = this._parent) === null || _a === void 0 ? void 0 : _a.matrix();
1853
- var pixelRatio = !m ? 1 : Math.max(Math.abs(m.a), Math.abs(m.b)) / getDevicePixelRatio();
1854
- return pixelRatio;
1920
+ return this.getLogicalPixelRatio();
1855
1921
  };
1856
1922
  Component2.prototype.getDevicePixelRatio = function() {
1857
1923
  var _a;
1858
1924
  var parentMatrix = (_a = this._parent) === null || _a === void 0 ? void 0 : _a.matrix();
1859
- var pixelRatio = !parentMatrix ? 1 : Math.max(Math.abs(parentMatrix.a), Math.abs(parentMatrix.b));
1925
+ if (!parentMatrix)
1926
+ return 1;
1927
+ var pixelRatio = Math.max(Math.abs(parentMatrix.a), Math.abs(parentMatrix.b));
1860
1928
  return pixelRatio;
1861
1929
  };
1862
1930
  Component2.prototype.getLogicalPixelRatio = function() {
@@ -2228,6 +2296,7 @@ var Component = (
2228
2296
  }
2229
2297
  stats.component++;
2230
2298
  var m = this.matrix();
2299
+ this.renderDebug(context, m);
2231
2300
  context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
2232
2301
  this._alpha = this._pin._alpha * (this._parent ? this._parent._alpha : 1);
2233
2302
  var alpha = this._pin._textureAlpha * this._alpha;
@@ -2618,8 +2687,30 @@ var Component = (
2618
2687
  this._spacing = space;
2619
2688
  return this;
2620
2689
  };
2690
+ Component2.prototype.renderDebug = function(ctx, xf) {
2691
+ if (!this._debug)
2692
+ return;
2693
+ var ppu = this.getLogicalPixelRatio();
2694
+ ctx.lineWidth = 1 / ppu;
2695
+ ctx.lineCap = "round";
2696
+ ctx.lineJoin = "round";
2697
+ renderAxis(ctx, 1);
2698
+ var pin = this._pin;
2699
+ if (pin._pivoted) {
2700
+ ctx.strokeStyle = "orange";
2701
+ renderPoint(ctx, pin._pivotX * pin._width, pin._pivotY * pin._height);
2702
+ }
2703
+ if (pin._aligned) {
2704
+ ctx.strokeStyle = "green";
2705
+ renderPoint(ctx, pin._alignX * pin._width, pin._alignY * pin._height);
2706
+ }
2707
+ if (pin._handled) {
2708
+ ctx.strokeStyle = "yellow";
2709
+ renderPoint(ctx, pin._handleX * pin._width, pin._handleY * pin._height);
2710
+ }
2711
+ };
2621
2712
  return Component2;
2622
- }()
2713
+ })()
2623
2714
  );
2624
2715
  function sprite(frame) {
2625
2716
  var sprite2 = new Sprite();
@@ -2628,7 +2719,7 @@ function sprite(frame) {
2628
2719
  }
2629
2720
  var Sprite = (
2630
2721
  /** @class */
2631
- function(_super) {
2722
+ (function(_super) {
2632
2723
  __extends(Sprite2, _super);
2633
2724
  function Sprite2() {
2634
2725
  var _this = _super.call(this) || this;
@@ -2696,11 +2787,11 @@ var Sprite = (
2696
2787
  this._texture.draw(context);
2697
2788
  };
2698
2789
  return Sprite2;
2699
- }(Component)
2790
+ })(Component)
2700
2791
  );
2701
2792
  var CanvasTexture = (
2702
2793
  /** @class */
2703
- function(_super) {
2794
+ (function(_super) {
2704
2795
  __extends(CanvasTexture2, _super);
2705
2796
  function CanvasTexture2() {
2706
2797
  var _this = _super.call(this, document.createElement("canvas")) || this;
@@ -2773,7 +2864,7 @@ var CanvasTexture = (
2773
2864
  return this;
2774
2865
  };
2775
2866
  return CanvasTexture2;
2776
- }(ImageTexture)
2867
+ })(ImageTexture)
2777
2868
  );
2778
2869
  function canvas(type, attributes, legacyTextureDrawer) {
2779
2870
  if (typeof type === "function") {
@@ -2825,7 +2916,7 @@ var POINTER_START = "touchstart mousedown";
2825
2916
  var POINTER_END = "touchend mouseup";
2826
2917
  var EventPoint = (
2827
2918
  /** @class */
2828
- function() {
2919
+ (function() {
2829
2920
  function EventPoint2() {
2830
2921
  }
2831
2922
  EventPoint2.prototype.clone = function(obj) {
@@ -2844,11 +2935,11 @@ var EventPoint = (
2844
2935
  return (this.x | 0) + "x" + (this.y | 0);
2845
2936
  };
2846
2937
  return EventPoint2;
2847
- }()
2938
+ })()
2848
2939
  );
2849
2940
  var PointerSyntheticEvent = (
2850
2941
  /** @class */
2851
- function() {
2942
+ (function() {
2852
2943
  function PointerSyntheticEvent2() {
2853
2944
  this.abs = new EventPoint();
2854
2945
  }
@@ -2868,11 +2959,11 @@ var PointerSyntheticEvent = (
2868
2959
  return this.type + ": " + (this.x | 0) + "x" + (this.y | 0);
2869
2960
  };
2870
2961
  return PointerSyntheticEvent2;
2871
- }()
2962
+ })()
2872
2963
  );
2873
2964
  var VisitPayload = (
2874
2965
  /** @class */
2875
- function() {
2966
+ (function() {
2876
2967
  function VisitPayload2() {
2877
2968
  this.type = "";
2878
2969
  this.x = 0;
@@ -2886,13 +2977,13 @@ var VisitPayload = (
2886
2977
  return this.type + ": " + (this.x | 0) + "x" + (this.y | 0);
2887
2978
  };
2888
2979
  return VisitPayload2;
2889
- }()
2980
+ })()
2890
2981
  );
2891
2982
  var syntheticEvent = new PointerSyntheticEvent();
2892
2983
  var PAYLOAD = new VisitPayload();
2893
2984
  var Pointer = (
2894
2985
  /** @class */
2895
- function() {
2986
+ (function() {
2896
2987
  function Pointer2() {
2897
2988
  var _this = this;
2898
2989
  this.ratio = 1;
@@ -3056,7 +3147,7 @@ var Pointer = (
3056
3147
  };
3057
3148
  Pointer2.DEBUG = false;
3058
3149
  return Pointer2;
3059
- }()
3150
+ })()
3060
3151
  );
3061
3152
  var Mouse = {
3062
3153
  CLICK: "click",
@@ -3088,7 +3179,7 @@ function mount(configs) {
3088
3179
  var DEFAULT_CANVAS_MOUNTED = false;
3089
3180
  var Root = (
3090
3181
  /** @class */
3091
- function(_super) {
3182
+ (function(_super) {
3092
3183
  __extends(Root2, _super);
3093
3184
  function Root2() {
3094
3185
  var _this = _super.call(this) || this;
@@ -3183,9 +3274,6 @@ var Root = (
3183
3274
  if (_this.canvasWidth > 0 && _this.canvasHeight > 0) {
3184
3275
  _this.context.setTransform(1, 0, 0, 1, 0, 0);
3185
3276
  _this.context.clearRect(0, 0, _this.canvasWidth, _this.canvasHeight);
3186
- if (_this.debugDrawAxis > 0) {
3187
- _this.renderDebug(_this.context);
3188
- }
3189
3277
  _this.render(_this.context);
3190
3278
  }
3191
3279
  } else if (tickRequest) {
@@ -3195,7 +3283,6 @@ var Root = (
3195
3283
  }
3196
3284
  stats.fps = elapsed ? 1e3 / elapsed : 0;
3197
3285
  };
3198
- _this.debugDrawAxis = 0;
3199
3286
  _this.label("Root");
3200
3287
  return _this;
3201
3288
  }
@@ -3228,35 +3315,12 @@ var Root = (
3228
3315
  ratio: pixelRatio
3229
3316
  });
3230
3317
  };
3231
- Root2.prototype.renderDebug = function(context) {
3232
- var size = typeof this.debugDrawAxis === "number" ? this.debugDrawAxis : 10;
3233
- var m = this.matrix();
3234
- context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
3235
- var lineWidth = 3 / m.a;
3236
- context.beginPath();
3237
- context.moveTo(0, 0);
3238
- context.lineTo(0, 0.8 * size);
3239
- context.lineTo(-0.2 * size, 0.8 * size);
3240
- context.lineTo(0, size);
3241
- context.lineTo(0.2 * size, 0.8 * size);
3242
- context.lineTo(0, 0.8 * size);
3243
- context.strokeStyle = "rgba(93, 173, 226)";
3244
- context.lineJoin = "round";
3245
- context.lineCap = "round";
3246
- context.lineWidth = lineWidth;
3247
- context.stroke();
3248
- context.beginPath();
3249
- context.moveTo(0, 0);
3250
- context.lineTo(0.8 * size, 0);
3251
- context.lineTo(0.8 * size, -0.2 * size);
3252
- context.lineTo(size, 0);
3253
- context.lineTo(0.8 * size, 0.2 * size);
3254
- context.lineTo(0.8 * size, 0);
3255
- context.strokeStyle = "rgba(236, 112, 99)";
3256
- context.lineJoin = "round";
3257
- context.lineCap = "round";
3258
- context.lineWidth = lineWidth;
3259
- context.stroke();
3318
+ Root2.prototype.renderDebug = function(ctx, m) {
3319
+ if (!this._debug)
3320
+ return;
3321
+ ctx.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
3322
+ ctx.lineWidth = 3 / m.a;
3323
+ renderAxis(ctx, 10);
3260
3324
  };
3261
3325
  Root2.prototype.resume = function() {
3262
3326
  if (this.sleep || this.paused) {
@@ -3313,7 +3377,7 @@ var Root = (
3313
3377
  height,
3314
3378
  ratio: typeof ratio === "number" ? ratio : 1
3315
3379
  };
3316
- this.viewbox();
3380
+ this.rescale();
3317
3381
  var data_1 = Object.assign({}, this._viewport);
3318
3382
  this.visit({
3319
3383
  start: function(component2) {
@@ -3340,39 +3404,25 @@ var Root = (
3340
3404
  return this;
3341
3405
  };
3342
3406
  Root2.prototype.camera = function(matrix) {
3343
- this._camera = matrix;
3344
- this.rescale();
3407
+ this._xf = matrix.clone();
3408
+ this._pin._ts_transform = getIID();
3409
+ this.touch();
3345
3410
  return this;
3346
3411
  };
3347
3412
  Root2.prototype.rescale = function() {
3348
3413
  var viewbox = this._viewbox;
3349
3414
  var viewport = this._viewport;
3350
- var camera = this._camera;
3351
3415
  if (viewport && viewbox) {
3352
- var viewportWidth = viewport.width;
3353
- var viewportHeight = viewport.height;
3354
3416
  var viewboxMode = isValidFitMode(viewbox.mode) ? viewbox.mode : "in-pad";
3355
- var viewboxWidth = viewbox.width;
3356
- var viewboxHeight = viewbox.height;
3417
+ var fitted = fit(viewbox.width, viewbox.height, viewport.width, viewport.height, viewboxMode);
3357
3418
  this.pin({
3358
- width: viewboxWidth,
3359
- height: viewboxHeight
3419
+ width: fitted.width,
3420
+ height: fitted.height,
3421
+ scaleX: fitted.scaleX,
3422
+ scaleY: fitted.scaleY,
3423
+ offsetX: -(viewbox.x || 0) * fitted.scaleX,
3424
+ offsetY: -(viewbox.y || 0) * fitted.scaleY
3360
3425
  });
3361
- this.fit(viewportWidth, viewportHeight, viewboxMode);
3362
- var viewboxX = viewbox.x || 0;
3363
- var viewboxY = viewbox.y || 0;
3364
- var cameraZoomX = (camera === null || camera === void 0 ? void 0 : camera.a) || 1;
3365
- var cameraZoomY = (camera === null || camera === void 0 ? void 0 : camera.d) || 1;
3366
- var cameraX = (camera === null || camera === void 0 ? void 0 : camera.e) || 0;
3367
- var cameraY = (camera === null || camera === void 0 ? void 0 : camera.f) || 0;
3368
- var pinScaleX = this.pin("scaleX");
3369
- var pinScaleY = this.pin("scaleY");
3370
- var scaleX = pinScaleX * cameraZoomX;
3371
- var scaleY = pinScaleY * cameraZoomY;
3372
- this.pin("scaleX", scaleX);
3373
- this.pin("scaleY", scaleY);
3374
- this.pin("offsetX", cameraX - viewboxX * scaleX);
3375
- this.pin("offsetY", cameraY - viewboxY * scaleY);
3376
3426
  } else if (viewport) {
3377
3427
  this.pin({
3378
3428
  width: viewport.width,
@@ -3390,7 +3440,7 @@ var Root = (
3390
3440
  return this;
3391
3441
  };
3392
3442
  return Root2;
3393
- }(Component)
3443
+ })(Component)
3394
3444
  );
3395
3445
  function anim(frames, fps) {
3396
3446
  var anim2 = new Anim();
@@ -3401,7 +3451,7 @@ function anim(frames, fps) {
3401
3451
  var FPS = 15;
3402
3452
  var Anim = (
3403
3453
  /** @class */
3404
- function(_super) {
3454
+ (function(_super) {
3405
3455
  __extends(Anim2, _super);
3406
3456
  function Anim2() {
3407
3457
  var _this = _super.call(this) || this;
@@ -3506,14 +3556,14 @@ var Anim = (
3506
3556
  return this;
3507
3557
  };
3508
3558
  return Anim2;
3509
- }(Component)
3559
+ })(Component)
3510
3560
  );
3511
3561
  function monotype(chars) {
3512
3562
  return new Monotype().frames(chars);
3513
3563
  }
3514
3564
  var Monotype = (
3515
3565
  /** @class */
3516
- function(_super) {
3566
+ (function(_super) {
3517
3567
  __extends(Monotype2, _super);
3518
3568
  function Monotype2() {
3519
3569
  var _this = _super.call(this) || this;
@@ -3580,7 +3630,7 @@ var Monotype = (
3580
3630
  return this;
3581
3631
  };
3582
3632
  return Monotype2;
3583
- }(Component)
3633
+ })(Component)
3584
3634
  );
3585
3635
  const Stage = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3586
3636
  __proto__: null,
@@ -3620,6 +3670,8 @@ const Stage = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
3620
3670
  column,
3621
3671
  component,
3622
3672
  create,
3673
+ fit,
3674
+ getIID,
3623
3675
  image: sprite,
3624
3676
  isValidFitMode,
3625
3677
  layer,
@@ -3679,6 +3731,8 @@ export {
3679
3731
  component,
3680
3732
  create,
3681
3733
  Stage as default,
3734
+ fit,
3735
+ getIID,
3682
3736
  sprite as image,
3683
3737
  isValidFitMode,
3684
3738
  layer,