@rive-app/canvas 2.22.0 → 2.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/rive.d.ts +46 -2
- package/rive.js +119 -14
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +23 -0
- package/rive_fallback.wasm +0 -0
package/package.json
CHANGED
package/rive.d.ts
CHANGED
|
@@ -357,6 +357,8 @@ export declare class Rive {
|
|
|
357
357
|
private automaticallyHandleEvents;
|
|
358
358
|
private enableRiveAssetCDN;
|
|
359
359
|
private _volume;
|
|
360
|
+
private _artboardWidth;
|
|
361
|
+
private _artboardHeight;
|
|
360
362
|
private _devicePixelRatioUsed;
|
|
361
363
|
private _hasZeroSize;
|
|
362
364
|
durations: number[];
|
|
@@ -384,6 +386,7 @@ export declare class Rive {
|
|
|
384
386
|
* we hook the instance to the audio manager
|
|
385
387
|
*/
|
|
386
388
|
private initializeAudio;
|
|
389
|
+
private initArtboardSize;
|
|
387
390
|
private initData;
|
|
388
391
|
private initArtboard;
|
|
389
392
|
drawFrame(): void;
|
|
@@ -479,7 +482,12 @@ export declare class Rive {
|
|
|
479
482
|
* Accounts for devicePixelRatio as a multiplier to render the size of the canvas drawing surface.
|
|
480
483
|
* Uses the size of the backing canvas to set new width/height attributes. Need to re-render
|
|
481
484
|
* and resize the layout to match the new drawing surface afterwards.
|
|
482
|
-
* Useful function for consumers to include in a window resize listener
|
|
485
|
+
* Useful function for consumers to include in a window resize listener.
|
|
486
|
+
*
|
|
487
|
+
* This method will set the {@link devicePixelRatioUsed} property.
|
|
488
|
+
*
|
|
489
|
+
* Optionally, you can provide a {@link customDevicePixelRatio} to provide a
|
|
490
|
+
* custom value.
|
|
483
491
|
*/
|
|
484
492
|
resizeDrawingSurfaceToCanvas(customDevicePixelRatio?: number): void;
|
|
485
493
|
get source(): string;
|
|
@@ -647,10 +655,46 @@ export declare class Rive {
|
|
|
647
655
|
*/
|
|
648
656
|
get contents(): RiveFileContents;
|
|
649
657
|
/**
|
|
650
|
-
*
|
|
658
|
+
* Getter / Setter for the volume of the artboard
|
|
651
659
|
*/
|
|
652
660
|
get volume(): number;
|
|
653
661
|
set volume(value: number);
|
|
662
|
+
/**
|
|
663
|
+
* The width of the artboard.
|
|
664
|
+
*
|
|
665
|
+
* This will return undefined if the artboard is not loaded yet and a custom
|
|
666
|
+
* width has not been set.
|
|
667
|
+
*
|
|
668
|
+
* Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
|
|
669
|
+
* with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard width is
|
|
670
|
+
* automatically set.
|
|
671
|
+
*/
|
|
672
|
+
get artboardWidth(): number | undefined;
|
|
673
|
+
set artboardWidth(value: number);
|
|
674
|
+
/**
|
|
675
|
+
* The height of the artboard.
|
|
676
|
+
*
|
|
677
|
+
* This will return undefined if the artboard is not loaded yet and a custom
|
|
678
|
+
* height has not been set.
|
|
679
|
+
*
|
|
680
|
+
* Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
|
|
681
|
+
* with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard height is
|
|
682
|
+
* automatically set.
|
|
683
|
+
*/
|
|
684
|
+
get artboardHeight(): number | undefined;
|
|
685
|
+
set artboardHeight(value: number);
|
|
686
|
+
/**
|
|
687
|
+
* Reset the artboard size to its original values.
|
|
688
|
+
*/
|
|
689
|
+
resetArtboardSize(): void;
|
|
690
|
+
/**
|
|
691
|
+
* The device pixel ratio used in rendering and canvas/artboard resizing.
|
|
692
|
+
*
|
|
693
|
+
* This value will be overidden by the device pixel ratio used in
|
|
694
|
+
* {@link resizeDrawingSurfaceToCanvas}. If you use that method, do not set this value.
|
|
695
|
+
*/
|
|
696
|
+
get devicePixelRatioUsed(): number;
|
|
697
|
+
set devicePixelRatioUsed(value: number);
|
|
654
698
|
}
|
|
655
699
|
/**
|
|
656
700
|
* Contents of a state machine input
|
package/rive.js
CHANGED
|
@@ -746,7 +746,7 @@ function Ya(a, b) {
|
|
|
746
746
|
return Xa(c, a, b);
|
|
747
747
|
}));
|
|
748
748
|
}
|
|
749
|
-
var Za, $a, db = {
|
|
749
|
+
var Za, $a, db = {441740:(a, b, c, d, e) => {
|
|
750
750
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
751
751
|
return 0;
|
|
752
752
|
}
|
|
@@ -809,9 +809,9 @@ var Za, $a, db = {438588:(a, b, c, d, e) => {
|
|
|
809
809
|
}
|
|
810
810
|
window.h.Aa += 1;
|
|
811
811
|
return 1;
|
|
812
|
-
},
|
|
812
|
+
}, 443918:() => {
|
|
813
813
|
"undefined" !== typeof window.h && (--window.h.Aa, 0 === window.h.Aa && delete window.h);
|
|
814
|
-
},
|
|
814
|
+
}, 444082:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 444186:() => {
|
|
815
815
|
try {
|
|
816
816
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
817
817
|
a.close();
|
|
@@ -819,7 +819,7 @@ var Za, $a, db = {438588:(a, b, c, d, e) => {
|
|
|
819
819
|
} catch (c) {
|
|
820
820
|
return 0;
|
|
821
821
|
}
|
|
822
|
-
},
|
|
822
|
+
}, 444357:(a, b, c, d, e, f) => {
|
|
823
823
|
if ("undefined" === typeof window.h) {
|
|
824
824
|
return -1;
|
|
825
825
|
}
|
|
@@ -865,7 +865,7 @@ var Za, $a, db = {438588:(a, b, c, d, e) => {
|
|
|
865
865
|
a == window.h.I.ya && g.Z.connect(g.J.destination);
|
|
866
866
|
g.pb = f;
|
|
867
867
|
return window.h.yc(g);
|
|
868
|
-
},
|
|
868
|
+
}, 447234:a => window.h.ra(a).J.sampleRate, 447307:a => {
|
|
869
869
|
a = window.h.ra(a);
|
|
870
870
|
void 0 !== a.Z && (a.Z.onaudioprocess = function() {
|
|
871
871
|
}, a.Z.disconnect(), a.Z = void 0);
|
|
@@ -873,13 +873,13 @@ var Za, $a, db = {438588:(a, b, c, d, e) => {
|
|
|
873
873
|
a.J.close();
|
|
874
874
|
a.J = void 0;
|
|
875
875
|
a.pb = void 0;
|
|
876
|
-
},
|
|
876
|
+
}, 447707:a => {
|
|
877
877
|
window.h.Cb(a);
|
|
878
|
-
},
|
|
878
|
+
}, 447757:a => {
|
|
879
879
|
a = window.h.ra(a);
|
|
880
880
|
a.J.resume();
|
|
881
881
|
a.state = window.h.ga.xb;
|
|
882
|
-
},
|
|
882
|
+
}, 447896:a => {
|
|
883
883
|
a = window.h.ra(a);
|
|
884
884
|
a.J.suspend();
|
|
885
885
|
a.state = window.h.ga.stopped;
|
|
@@ -3365,7 +3365,7 @@ $d();
|
|
|
3365
3365
|
/* 2 */
|
|
3366
3366
|
/***/ ((module) => {
|
|
3367
3367
|
|
|
3368
|
-
module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.
|
|
3368
|
+
module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.23.1","description":"Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
3369
3369
|
|
|
3370
3370
|
/***/ }),
|
|
3371
3371
|
/* 3 */
|
|
@@ -3566,7 +3566,7 @@ var getClientCoordinates = function (event, isTouchScrollEnabled) {
|
|
|
3566
3566
|
* the state machine pointer move/up/down functions based on cursor interaction
|
|
3567
3567
|
*/
|
|
3568
3568
|
var registerTouchInteractions = function (_a) {
|
|
3569
|
-
var canvas = _a.canvas, artboard = _a.artboard, _b = _a.stateMachines, stateMachines = _b === void 0 ? [] : _b, renderer = _a.renderer, rive = _a.rive, fit = _a.fit, alignment = _a.alignment, _c = _a.isTouchScrollEnabled, isTouchScrollEnabled = _c === void 0 ? false : _c;
|
|
3569
|
+
var canvas = _a.canvas, artboard = _a.artboard, _b = _a.stateMachines, stateMachines = _b === void 0 ? [] : _b, renderer = _a.renderer, rive = _a.rive, fit = _a.fit, alignment = _a.alignment, _c = _a.isTouchScrollEnabled, isTouchScrollEnabled = _c === void 0 ? false : _c, _d = _a.layoutScaleFactor, layoutScaleFactor = _d === void 0 ? 1.0 : _d;
|
|
3570
3570
|
if (!canvas ||
|
|
3571
3571
|
!stateMachines.length ||
|
|
3572
3572
|
!renderer ||
|
|
@@ -3621,7 +3621,7 @@ var registerTouchInteractions = function (_a) {
|
|
|
3621
3621
|
minY: 0,
|
|
3622
3622
|
maxX: boundingRect.width,
|
|
3623
3623
|
maxY: boundingRect.height,
|
|
3624
|
-
}, artboard.bounds);
|
|
3624
|
+
}, artboard.bounds, layoutScaleFactor);
|
|
3625
3625
|
var invertedMatrix = new rive.Mat2D();
|
|
3626
3626
|
forwardMatrix.invert(invertedMatrix);
|
|
3627
3627
|
var canvasCoordinatesVector = new rive.Vec2D(canvasX, canvasY);
|
|
@@ -5094,6 +5094,11 @@ var Rive = /** @class */ (function () {
|
|
|
5094
5094
|
this.enableRiveAssetCDN = true;
|
|
5095
5095
|
// Keep a local value of the set volume to update it asynchronously
|
|
5096
5096
|
this._volume = 1;
|
|
5097
|
+
// Keep a local value of the set width to update it asynchronously
|
|
5098
|
+
this._artboardWidth = undefined;
|
|
5099
|
+
// Keep a local value of the set height to update it asynchronously
|
|
5100
|
+
this._artboardHeight = undefined;
|
|
5101
|
+
// Keep a local value of the device pixel ratio used in rendering and canvas/artboard resizing
|
|
5097
5102
|
this._devicePixelRatioUsed = 1;
|
|
5098
5103
|
// Whether the canvas element's size is 0
|
|
5099
5104
|
this._hasZeroSize = false;
|
|
@@ -5256,6 +5261,7 @@ var Rive = /** @class */ (function () {
|
|
|
5256
5261
|
fit: this._layout.runtimeFit(this.runtime),
|
|
5257
5262
|
alignment: this._layout.runtimeAlignment(this.runtime),
|
|
5258
5263
|
isTouchScrollEnabled: touchScrollEnabledOption,
|
|
5264
|
+
layoutScaleFactor: this._layout.layoutScaleFactor,
|
|
5259
5265
|
});
|
|
5260
5266
|
}
|
|
5261
5267
|
};
|
|
@@ -5285,6 +5291,15 @@ var Rive = /** @class */ (function () {
|
|
|
5285
5291
|
}
|
|
5286
5292
|
}
|
|
5287
5293
|
};
|
|
5294
|
+
Rive.prototype.initArtboardSize = function () {
|
|
5295
|
+
if (!this.artboard)
|
|
5296
|
+
return;
|
|
5297
|
+
// Use preset values if they are not undefined
|
|
5298
|
+
this._artboardWidth = this.artboard.width =
|
|
5299
|
+
this._artboardWidth || this.artboard.width;
|
|
5300
|
+
this._artboardHeight = this.artboard.height =
|
|
5301
|
+
this._artboardHeight || this.artboard.height;
|
|
5302
|
+
};
|
|
5288
5303
|
// Initializes runtime with Rive data and preps for playing
|
|
5289
5304
|
Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay) {
|
|
5290
5305
|
var _a;
|
|
@@ -5309,6 +5324,8 @@ var Rive = /** @class */ (function () {
|
|
|
5309
5324
|
this.file = this.riveFile.getInstance();
|
|
5310
5325
|
// Initialize and draw frame
|
|
5311
5326
|
this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay);
|
|
5327
|
+
// Initialize the artboard size
|
|
5328
|
+
this.initArtboardSize();
|
|
5312
5329
|
// Check for audio
|
|
5313
5330
|
this.initializeAudio();
|
|
5314
5331
|
// Everything's set up, emit a load event
|
|
@@ -5768,13 +5785,18 @@ var Rive = /** @class */ (function () {
|
|
|
5768
5785
|
* Accounts for devicePixelRatio as a multiplier to render the size of the canvas drawing surface.
|
|
5769
5786
|
* Uses the size of the backing canvas to set new width/height attributes. Need to re-render
|
|
5770
5787
|
* and resize the layout to match the new drawing surface afterwards.
|
|
5771
|
-
* Useful function for consumers to include in a window resize listener
|
|
5788
|
+
* Useful function for consumers to include in a window resize listener.
|
|
5789
|
+
*
|
|
5790
|
+
* This method will set the {@link devicePixelRatioUsed} property.
|
|
5791
|
+
*
|
|
5792
|
+
* Optionally, you can provide a {@link customDevicePixelRatio} to provide a
|
|
5793
|
+
* custom value.
|
|
5772
5794
|
*/
|
|
5773
5795
|
Rive.prototype.resizeDrawingSurfaceToCanvas = function (customDevicePixelRatio) {
|
|
5774
5796
|
if (this.canvas instanceof HTMLCanvasElement && !!window) {
|
|
5775
5797
|
var _a = this.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
|
|
5776
5798
|
var dpr = customDevicePixelRatio || window.devicePixelRatio || 1;
|
|
5777
|
-
this.
|
|
5799
|
+
this.devicePixelRatioUsed = dpr;
|
|
5778
5800
|
this.canvas.width = dpr * width;
|
|
5779
5801
|
this.canvas.height = dpr * height;
|
|
5780
5802
|
this.startRendering();
|
|
@@ -6234,7 +6256,7 @@ var Rive = /** @class */ (function () {
|
|
|
6234
6256
|
});
|
|
6235
6257
|
Object.defineProperty(Rive.prototype, "volume", {
|
|
6236
6258
|
/**
|
|
6237
|
-
*
|
|
6259
|
+
* Getter / Setter for the volume of the artboard
|
|
6238
6260
|
*/
|
|
6239
6261
|
get: function () {
|
|
6240
6262
|
if (this.artboard && this.artboard.volume !== this._volume) {
|
|
@@ -6251,6 +6273,89 @@ var Rive = /** @class */ (function () {
|
|
|
6251
6273
|
enumerable: false,
|
|
6252
6274
|
configurable: true
|
|
6253
6275
|
});
|
|
6276
|
+
Object.defineProperty(Rive.prototype, "artboardWidth", {
|
|
6277
|
+
/**
|
|
6278
|
+
* The width of the artboard.
|
|
6279
|
+
*
|
|
6280
|
+
* This will return undefined if the artboard is not loaded yet and a custom
|
|
6281
|
+
* width has not been set.
|
|
6282
|
+
*
|
|
6283
|
+
* Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
|
|
6284
|
+
* with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard width is
|
|
6285
|
+
* automatically set.
|
|
6286
|
+
*/
|
|
6287
|
+
get: function () {
|
|
6288
|
+
if (this.artboard) {
|
|
6289
|
+
return this.artboard.width;
|
|
6290
|
+
}
|
|
6291
|
+
return this._artboardWidth;
|
|
6292
|
+
},
|
|
6293
|
+
set: function (value) {
|
|
6294
|
+
this._artboardWidth = value;
|
|
6295
|
+
if (this.artboard) {
|
|
6296
|
+
this.artboard.width = value;
|
|
6297
|
+
}
|
|
6298
|
+
},
|
|
6299
|
+
enumerable: false,
|
|
6300
|
+
configurable: true
|
|
6301
|
+
});
|
|
6302
|
+
Object.defineProperty(Rive.prototype, "artboardHeight", {
|
|
6303
|
+
/**
|
|
6304
|
+
* The height of the artboard.
|
|
6305
|
+
*
|
|
6306
|
+
* This will return undefined if the artboard is not loaded yet and a custom
|
|
6307
|
+
* height has not been set.
|
|
6308
|
+
*
|
|
6309
|
+
* Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
|
|
6310
|
+
* with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard height is
|
|
6311
|
+
* automatically set.
|
|
6312
|
+
*/
|
|
6313
|
+
get: function () {
|
|
6314
|
+
if (this.artboard) {
|
|
6315
|
+
return this.artboard.height;
|
|
6316
|
+
}
|
|
6317
|
+
return this._artboardHeight;
|
|
6318
|
+
},
|
|
6319
|
+
set: function (value) {
|
|
6320
|
+
this._artboardHeight = value;
|
|
6321
|
+
if (this.artboard) {
|
|
6322
|
+
this.artboard.height = value;
|
|
6323
|
+
}
|
|
6324
|
+
},
|
|
6325
|
+
enumerable: false,
|
|
6326
|
+
configurable: true
|
|
6327
|
+
});
|
|
6328
|
+
/**
|
|
6329
|
+
* Reset the artboard size to its original values.
|
|
6330
|
+
*/
|
|
6331
|
+
Rive.prototype.resetArtboardSize = function () {
|
|
6332
|
+
if (this.artboard) {
|
|
6333
|
+
this.artboard.resetArtboardSize();
|
|
6334
|
+
this._artboardWidth = this.artboard.width;
|
|
6335
|
+
this._artboardHeight = this.artboard.height;
|
|
6336
|
+
}
|
|
6337
|
+
else {
|
|
6338
|
+
// If the artboard isn't loaded, we need to reset the custom width and height
|
|
6339
|
+
this._artboardWidth = undefined;
|
|
6340
|
+
this._artboardHeight = undefined;
|
|
6341
|
+
}
|
|
6342
|
+
};
|
|
6343
|
+
Object.defineProperty(Rive.prototype, "devicePixelRatioUsed", {
|
|
6344
|
+
/**
|
|
6345
|
+
* The device pixel ratio used in rendering and canvas/artboard resizing.
|
|
6346
|
+
*
|
|
6347
|
+
* This value will be overidden by the device pixel ratio used in
|
|
6348
|
+
* {@link resizeDrawingSurfaceToCanvas}. If you use that method, do not set this value.
|
|
6349
|
+
*/
|
|
6350
|
+
get: function () {
|
|
6351
|
+
return this._devicePixelRatioUsed;
|
|
6352
|
+
},
|
|
6353
|
+
set: function (value) {
|
|
6354
|
+
this._devicePixelRatioUsed = value;
|
|
6355
|
+
},
|
|
6356
|
+
enumerable: false,
|
|
6357
|
+
configurable: true
|
|
6358
|
+
});
|
|
6254
6359
|
// Error message for missing source or buffer
|
|
6255
6360
|
Rive.missingErrorMessage = "Rive source file or data buffer required";
|
|
6256
6361
|
return Rive;
|