@rive-app/webgl 2.22.0 → 2.23.0
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_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
|
@@ -408,7 +408,7 @@ function Qa(a, b) {
|
|
|
408
408
|
return Pa(c, a, b);
|
|
409
409
|
}));
|
|
410
410
|
}
|
|
411
|
-
var Ra, Sa, Wa = {
|
|
411
|
+
var Ra, Sa, Wa = {693516:(a, b, c, d, e) => {
|
|
412
412
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
413
413
|
return 0;
|
|
414
414
|
}
|
|
@@ -471,9 +471,9 @@ var Ra, Sa, Wa = {693276:(a, b, c, d, e) => {
|
|
|
471
471
|
}
|
|
472
472
|
window.h.Ea += 1;
|
|
473
473
|
return 1;
|
|
474
|
-
},
|
|
474
|
+
}, 695694:() => {
|
|
475
475
|
"undefined" !== typeof window.h && (--window.h.Ea, 0 === window.h.Ea && delete window.h);
|
|
476
|
-
},
|
|
476
|
+
}, 695858:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 695962:() => {
|
|
477
477
|
try {
|
|
478
478
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
479
479
|
a.close();
|
|
@@ -481,7 +481,7 @@ var Ra, Sa, Wa = {693276:(a, b, c, d, e) => {
|
|
|
481
481
|
} catch (c) {
|
|
482
482
|
return 0;
|
|
483
483
|
}
|
|
484
|
-
},
|
|
484
|
+
}, 696133:(a, b, c, d, e, f) => {
|
|
485
485
|
if ("undefined" === typeof window.h) {
|
|
486
486
|
return -1;
|
|
487
487
|
}
|
|
@@ -527,7 +527,7 @@ var Ra, Sa, Wa = {693276:(a, b, c, d, e) => {
|
|
|
527
527
|
a == window.h.H.Ca && g.X.connect(g.I.destination);
|
|
528
528
|
g.lb = f;
|
|
529
529
|
return window.h.nc(g);
|
|
530
|
-
},
|
|
530
|
+
}, 699010:a => window.h.ta(a).I.sampleRate, 699083:a => {
|
|
531
531
|
a = window.h.ta(a);
|
|
532
532
|
void 0 !== a.X && (a.X.onaudioprocess = function() {
|
|
533
533
|
}, a.X.disconnect(), a.X = void 0);
|
|
@@ -535,13 +535,13 @@ var Ra, Sa, Wa = {693276:(a, b, c, d, e) => {
|
|
|
535
535
|
a.I.close();
|
|
536
536
|
a.I = void 0;
|
|
537
537
|
a.lb = void 0;
|
|
538
|
-
},
|
|
538
|
+
}, 699483:a => {
|
|
539
539
|
window.h.xb(a);
|
|
540
|
-
},
|
|
540
|
+
}, 699533:a => {
|
|
541
541
|
a = window.h.ta(a);
|
|
542
542
|
a.I.resume();
|
|
543
543
|
a.state = window.h.ha.sb;
|
|
544
|
-
},
|
|
544
|
+
}, 699672:a => {
|
|
545
545
|
a = window.h.ta(a);
|
|
546
546
|
a.I.suspend();
|
|
547
547
|
a.state = window.h.ha.stopped;
|
|
@@ -4061,7 +4061,7 @@ Je();
|
|
|
4061
4061
|
/* 2 */
|
|
4062
4062
|
/***/ ((module) => {
|
|
4063
4063
|
|
|
4064
|
-
module.exports = JSON.parse('{"name":"@rive-app/webgl","version":"2.
|
|
4064
|
+
module.exports = JSON.parse('{"name":"@rive-app/webgl","version":"2.23.0","description":"Rive\'s webgl 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.wasm","rive_fallback.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
4065
4065
|
|
|
4066
4066
|
/***/ }),
|
|
4067
4067
|
/* 3 */
|
|
@@ -4262,7 +4262,7 @@ var getClientCoordinates = function (event, isTouchScrollEnabled) {
|
|
|
4262
4262
|
* the state machine pointer move/up/down functions based on cursor interaction
|
|
4263
4263
|
*/
|
|
4264
4264
|
var registerTouchInteractions = function (_a) {
|
|
4265
|
-
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;
|
|
4265
|
+
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;
|
|
4266
4266
|
if (!canvas ||
|
|
4267
4267
|
!stateMachines.length ||
|
|
4268
4268
|
!renderer ||
|
|
@@ -4317,7 +4317,7 @@ var registerTouchInteractions = function (_a) {
|
|
|
4317
4317
|
minY: 0,
|
|
4318
4318
|
maxX: boundingRect.width,
|
|
4319
4319
|
maxY: boundingRect.height,
|
|
4320
|
-
}, artboard.bounds);
|
|
4320
|
+
}, artboard.bounds, layoutScaleFactor);
|
|
4321
4321
|
var invertedMatrix = new rive.Mat2D();
|
|
4322
4322
|
forwardMatrix.invert(invertedMatrix);
|
|
4323
4323
|
var canvasCoordinatesVector = new rive.Vec2D(canvasX, canvasY);
|
|
@@ -5790,6 +5790,11 @@ var Rive = /** @class */ (function () {
|
|
|
5790
5790
|
this.enableRiveAssetCDN = true;
|
|
5791
5791
|
// Keep a local value of the set volume to update it asynchronously
|
|
5792
5792
|
this._volume = 1;
|
|
5793
|
+
// Keep a local value of the set width to update it asynchronously
|
|
5794
|
+
this._artboardWidth = undefined;
|
|
5795
|
+
// Keep a local value of the set height to update it asynchronously
|
|
5796
|
+
this._artboardHeight = undefined;
|
|
5797
|
+
// Keep a local value of the device pixel ratio used in rendering and canvas/artboard resizing
|
|
5793
5798
|
this._devicePixelRatioUsed = 1;
|
|
5794
5799
|
// Whether the canvas element's size is 0
|
|
5795
5800
|
this._hasZeroSize = false;
|
|
@@ -5952,6 +5957,7 @@ var Rive = /** @class */ (function () {
|
|
|
5952
5957
|
fit: this._layout.runtimeFit(this.runtime),
|
|
5953
5958
|
alignment: this._layout.runtimeAlignment(this.runtime),
|
|
5954
5959
|
isTouchScrollEnabled: touchScrollEnabledOption,
|
|
5960
|
+
layoutScaleFactor: this._layout.layoutScaleFactor,
|
|
5955
5961
|
});
|
|
5956
5962
|
}
|
|
5957
5963
|
};
|
|
@@ -5981,6 +5987,15 @@ var Rive = /** @class */ (function () {
|
|
|
5981
5987
|
}
|
|
5982
5988
|
}
|
|
5983
5989
|
};
|
|
5990
|
+
Rive.prototype.initArtboardSize = function () {
|
|
5991
|
+
if (!this.artboard)
|
|
5992
|
+
return;
|
|
5993
|
+
// Use preset values if they are not undefined
|
|
5994
|
+
this._artboardWidth = this.artboard.width =
|
|
5995
|
+
this._artboardWidth || this.artboard.width;
|
|
5996
|
+
this._artboardHeight = this.artboard.height =
|
|
5997
|
+
this._artboardHeight || this.artboard.height;
|
|
5998
|
+
};
|
|
5984
5999
|
// Initializes runtime with Rive data and preps for playing
|
|
5985
6000
|
Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay) {
|
|
5986
6001
|
var _a;
|
|
@@ -6005,6 +6020,8 @@ var Rive = /** @class */ (function () {
|
|
|
6005
6020
|
this.file = this.riveFile.getInstance();
|
|
6006
6021
|
// Initialize and draw frame
|
|
6007
6022
|
this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay);
|
|
6023
|
+
// Initialize the artboard size
|
|
6024
|
+
this.initArtboardSize();
|
|
6008
6025
|
// Check for audio
|
|
6009
6026
|
this.initializeAudio();
|
|
6010
6027
|
// Everything's set up, emit a load event
|
|
@@ -6464,13 +6481,18 @@ var Rive = /** @class */ (function () {
|
|
|
6464
6481
|
* Accounts for devicePixelRatio as a multiplier to render the size of the canvas drawing surface.
|
|
6465
6482
|
* Uses the size of the backing canvas to set new width/height attributes. Need to re-render
|
|
6466
6483
|
* and resize the layout to match the new drawing surface afterwards.
|
|
6467
|
-
* Useful function for consumers to include in a window resize listener
|
|
6484
|
+
* Useful function for consumers to include in a window resize listener.
|
|
6485
|
+
*
|
|
6486
|
+
* This method will set the {@link devicePixelRatioUsed} property.
|
|
6487
|
+
*
|
|
6488
|
+
* Optionally, you can provide a {@link customDevicePixelRatio} to provide a
|
|
6489
|
+
* custom value.
|
|
6468
6490
|
*/
|
|
6469
6491
|
Rive.prototype.resizeDrawingSurfaceToCanvas = function (customDevicePixelRatio) {
|
|
6470
6492
|
if (this.canvas instanceof HTMLCanvasElement && !!window) {
|
|
6471
6493
|
var _a = this.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
|
|
6472
6494
|
var dpr = customDevicePixelRatio || window.devicePixelRatio || 1;
|
|
6473
|
-
this.
|
|
6495
|
+
this.devicePixelRatioUsed = dpr;
|
|
6474
6496
|
this.canvas.width = dpr * width;
|
|
6475
6497
|
this.canvas.height = dpr * height;
|
|
6476
6498
|
this.startRendering();
|
|
@@ -6930,7 +6952,7 @@ var Rive = /** @class */ (function () {
|
|
|
6930
6952
|
});
|
|
6931
6953
|
Object.defineProperty(Rive.prototype, "volume", {
|
|
6932
6954
|
/**
|
|
6933
|
-
*
|
|
6955
|
+
* Getter / Setter for the volume of the artboard
|
|
6934
6956
|
*/
|
|
6935
6957
|
get: function () {
|
|
6936
6958
|
if (this.artboard && this.artboard.volume !== this._volume) {
|
|
@@ -6947,6 +6969,89 @@ var Rive = /** @class */ (function () {
|
|
|
6947
6969
|
enumerable: false,
|
|
6948
6970
|
configurable: true
|
|
6949
6971
|
});
|
|
6972
|
+
Object.defineProperty(Rive.prototype, "artboardWidth", {
|
|
6973
|
+
/**
|
|
6974
|
+
* The width of the artboard.
|
|
6975
|
+
*
|
|
6976
|
+
* This will return undefined if the artboard is not loaded yet and a custom
|
|
6977
|
+
* width has not been set.
|
|
6978
|
+
*
|
|
6979
|
+
* Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
|
|
6980
|
+
* with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard width is
|
|
6981
|
+
* automatically set.
|
|
6982
|
+
*/
|
|
6983
|
+
get: function () {
|
|
6984
|
+
if (this.artboard) {
|
|
6985
|
+
return this.artboard.width;
|
|
6986
|
+
}
|
|
6987
|
+
return this._artboardWidth;
|
|
6988
|
+
},
|
|
6989
|
+
set: function (value) {
|
|
6990
|
+
this._artboardWidth = value;
|
|
6991
|
+
if (this.artboard) {
|
|
6992
|
+
this.artboard.width = value;
|
|
6993
|
+
}
|
|
6994
|
+
},
|
|
6995
|
+
enumerable: false,
|
|
6996
|
+
configurable: true
|
|
6997
|
+
});
|
|
6998
|
+
Object.defineProperty(Rive.prototype, "artboardHeight", {
|
|
6999
|
+
/**
|
|
7000
|
+
* The height of the artboard.
|
|
7001
|
+
*
|
|
7002
|
+
* This will return undefined if the artboard is not loaded yet and a custom
|
|
7003
|
+
* height has not been set.
|
|
7004
|
+
*
|
|
7005
|
+
* Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
|
|
7006
|
+
* with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard height is
|
|
7007
|
+
* automatically set.
|
|
7008
|
+
*/
|
|
7009
|
+
get: function () {
|
|
7010
|
+
if (this.artboard) {
|
|
7011
|
+
return this.artboard.height;
|
|
7012
|
+
}
|
|
7013
|
+
return this._artboardHeight;
|
|
7014
|
+
},
|
|
7015
|
+
set: function (value) {
|
|
7016
|
+
this._artboardHeight = value;
|
|
7017
|
+
if (this.artboard) {
|
|
7018
|
+
this.artboard.height = value;
|
|
7019
|
+
}
|
|
7020
|
+
},
|
|
7021
|
+
enumerable: false,
|
|
7022
|
+
configurable: true
|
|
7023
|
+
});
|
|
7024
|
+
/**
|
|
7025
|
+
* Reset the artboard size to its original values.
|
|
7026
|
+
*/
|
|
7027
|
+
Rive.prototype.resetArtboardSize = function () {
|
|
7028
|
+
if (this.artboard) {
|
|
7029
|
+
this.artboard.resetArtboardSize();
|
|
7030
|
+
this._artboardWidth = this.artboard.width;
|
|
7031
|
+
this._artboardHeight = this.artboard.height;
|
|
7032
|
+
}
|
|
7033
|
+
else {
|
|
7034
|
+
// If the artboard isn't loaded, we need to reset the custom width and height
|
|
7035
|
+
this._artboardWidth = undefined;
|
|
7036
|
+
this._artboardHeight = undefined;
|
|
7037
|
+
}
|
|
7038
|
+
};
|
|
7039
|
+
Object.defineProperty(Rive.prototype, "devicePixelRatioUsed", {
|
|
7040
|
+
/**
|
|
7041
|
+
* The device pixel ratio used in rendering and canvas/artboard resizing.
|
|
7042
|
+
*
|
|
7043
|
+
* This value will be overidden by the device pixel ratio used in
|
|
7044
|
+
* {@link resizeDrawingSurfaceToCanvas}. If you use that method, do not set this value.
|
|
7045
|
+
*/
|
|
7046
|
+
get: function () {
|
|
7047
|
+
return this._devicePixelRatioUsed;
|
|
7048
|
+
},
|
|
7049
|
+
set: function (value) {
|
|
7050
|
+
this._devicePixelRatioUsed = value;
|
|
7051
|
+
},
|
|
7052
|
+
enumerable: false,
|
|
7053
|
+
configurable: true
|
|
7054
|
+
});
|
|
6950
7055
|
// Error message for missing source or buffer
|
|
6951
7056
|
Rive.missingErrorMessage = "Rive source file or data buffer required";
|
|
6952
7057
|
return Rive;
|