@rive-app/webgl2 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 +121 -16
- package/rive.js.map +1 -1
- package/rive.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
|
@@ -423,7 +423,7 @@ function Oa(a, b) {
|
|
|
423
423
|
return Na(c, a, b);
|
|
424
424
|
}));
|
|
425
425
|
}
|
|
426
|
-
var Pa, Qa, Ua = {
|
|
426
|
+
var Pa, Qa, Ua = {485221:(a, b, c, d, e) => {
|
|
427
427
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
428
428
|
return 0;
|
|
429
429
|
}
|
|
@@ -486,9 +486,9 @@ var Pa, Qa, Ua = {484853:(a, b, c, d, e) => {
|
|
|
486
486
|
}
|
|
487
487
|
window.h.Da += 1;
|
|
488
488
|
return 1;
|
|
489
|
-
},
|
|
489
|
+
}, 487399:() => {
|
|
490
490
|
"undefined" !== typeof window.h && (--window.h.Da, 0 === window.h.Da && delete window.h);
|
|
491
|
-
},
|
|
491
|
+
}, 487563:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 487667:() => {
|
|
492
492
|
try {
|
|
493
493
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
494
494
|
a.close();
|
|
@@ -496,7 +496,7 @@ var Pa, Qa, Ua = {484853:(a, b, c, d, e) => {
|
|
|
496
496
|
} catch (c) {
|
|
497
497
|
return 0;
|
|
498
498
|
}
|
|
499
|
-
},
|
|
499
|
+
}, 487838:(a, b, c, d, e, f) => {
|
|
500
500
|
if ("undefined" === typeof window.h) {
|
|
501
501
|
return -1;
|
|
502
502
|
}
|
|
@@ -542,7 +542,7 @@ var Pa, Qa, Ua = {484853:(a, b, c, d, e) => {
|
|
|
542
542
|
a == window.h.I.Ba && g.Y.connect(g.J.destination);
|
|
543
543
|
g.jb = f;
|
|
544
544
|
return window.h.lc(g);
|
|
545
|
-
},
|
|
545
|
+
}, 490715:a => window.h.va(a).J.sampleRate, 490788:a => {
|
|
546
546
|
a = window.h.va(a);
|
|
547
547
|
void 0 !== a.Y && (a.Y.onaudioprocess = function() {
|
|
548
548
|
}, a.Y.disconnect(), a.Y = void 0);
|
|
@@ -550,13 +550,13 @@ var Pa, Qa, Ua = {484853:(a, b, c, d, e) => {
|
|
|
550
550
|
a.J.close();
|
|
551
551
|
a.J = void 0;
|
|
552
552
|
a.jb = void 0;
|
|
553
|
-
},
|
|
553
|
+
}, 491188:a => {
|
|
554
554
|
window.h.wb(a);
|
|
555
|
-
},
|
|
555
|
+
}, 491238:a => {
|
|
556
556
|
a = window.h.va(a);
|
|
557
557
|
a.J.resume();
|
|
558
558
|
a.state = window.h.ha.rb;
|
|
559
|
-
},
|
|
559
|
+
}, 491377:a => {
|
|
560
560
|
a = window.h.va(a);
|
|
561
561
|
a.J.suspend();
|
|
562
562
|
a.state = window.h.ha.stopped;
|
|
@@ -3467,8 +3467,8 @@ n.dynCall_viijii = (a, b, c, d, e, f, g) => (n.dynCall_viijii = z.dynCall_viijii
|
|
|
3467
3467
|
n.dynCall_iiiiij = (a, b, c, d, e, f, g) => (n.dynCall_iiiiij = z.dynCall_iiiiij)(a, b, c, d, e, f, g);
|
|
3468
3468
|
n.dynCall_iiiiijj = (a, b, c, d, e, f, g, m, p) => (n.dynCall_iiiiijj = z.dynCall_iiiiijj)(a, b, c, d, e, f, g, m, p);
|
|
3469
3469
|
n.dynCall_iiiiiijj = (a, b, c, d, e, f, g, m, p, l) => (n.dynCall_iiiiiijj = z.dynCall_iiiiiijj)(a, b, c, d, e, f, g, m, p, l);
|
|
3470
|
-
n.___start_em_js =
|
|
3471
|
-
n.___stop_em_js =
|
|
3470
|
+
n.___start_em_js = 482596;
|
|
3471
|
+
n.___stop_em_js = 485221;
|
|
3472
3472
|
var Xd;
|
|
3473
3473
|
Ha = function Yd() {
|
|
3474
3474
|
Xd || Zd();
|
|
@@ -3528,7 +3528,7 @@ Zd();
|
|
|
3528
3528
|
/* 2 */
|
|
3529
3529
|
/***/ ((module) => {
|
|
3530
3530
|
|
|
3531
|
-
module.exports = JSON.parse('{"name":"@rive-app/webgl2","version":"2.
|
|
3531
|
+
module.exports = JSON.parse('{"name":"@rive-app/webgl2","version":"2.23.0","description":"Rive\'s webgl2 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)","Chris Dalton <chris@rive.app> (https://rive.app)"],"license":"MIT","files":["rive.js","rive.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
3532
3532
|
|
|
3533
3533
|
/***/ }),
|
|
3534
3534
|
/* 3 */
|
|
@@ -3729,7 +3729,7 @@ var getClientCoordinates = function (event, isTouchScrollEnabled) {
|
|
|
3729
3729
|
* the state machine pointer move/up/down functions based on cursor interaction
|
|
3730
3730
|
*/
|
|
3731
3731
|
var registerTouchInteractions = function (_a) {
|
|
3732
|
-
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;
|
|
3732
|
+
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;
|
|
3733
3733
|
if (!canvas ||
|
|
3734
3734
|
!stateMachines.length ||
|
|
3735
3735
|
!renderer ||
|
|
@@ -3784,7 +3784,7 @@ var registerTouchInteractions = function (_a) {
|
|
|
3784
3784
|
minY: 0,
|
|
3785
3785
|
maxX: boundingRect.width,
|
|
3786
3786
|
maxY: boundingRect.height,
|
|
3787
|
-
}, artboard.bounds);
|
|
3787
|
+
}, artboard.bounds, layoutScaleFactor);
|
|
3788
3788
|
var invertedMatrix = new rive.Mat2D();
|
|
3789
3789
|
forwardMatrix.invert(invertedMatrix);
|
|
3790
3790
|
var canvasCoordinatesVector = new rive.Vec2D(canvasX, canvasY);
|
|
@@ -5257,6 +5257,11 @@ var Rive = /** @class */ (function () {
|
|
|
5257
5257
|
this.enableRiveAssetCDN = true;
|
|
5258
5258
|
// Keep a local value of the set volume to update it asynchronously
|
|
5259
5259
|
this._volume = 1;
|
|
5260
|
+
// Keep a local value of the set width to update it asynchronously
|
|
5261
|
+
this._artboardWidth = undefined;
|
|
5262
|
+
// Keep a local value of the set height to update it asynchronously
|
|
5263
|
+
this._artboardHeight = undefined;
|
|
5264
|
+
// Keep a local value of the device pixel ratio used in rendering and canvas/artboard resizing
|
|
5260
5265
|
this._devicePixelRatioUsed = 1;
|
|
5261
5266
|
// Whether the canvas element's size is 0
|
|
5262
5267
|
this._hasZeroSize = false;
|
|
@@ -5419,6 +5424,7 @@ var Rive = /** @class */ (function () {
|
|
|
5419
5424
|
fit: this._layout.runtimeFit(this.runtime),
|
|
5420
5425
|
alignment: this._layout.runtimeAlignment(this.runtime),
|
|
5421
5426
|
isTouchScrollEnabled: touchScrollEnabledOption,
|
|
5427
|
+
layoutScaleFactor: this._layout.layoutScaleFactor,
|
|
5422
5428
|
});
|
|
5423
5429
|
}
|
|
5424
5430
|
};
|
|
@@ -5448,6 +5454,15 @@ var Rive = /** @class */ (function () {
|
|
|
5448
5454
|
}
|
|
5449
5455
|
}
|
|
5450
5456
|
};
|
|
5457
|
+
Rive.prototype.initArtboardSize = function () {
|
|
5458
|
+
if (!this.artboard)
|
|
5459
|
+
return;
|
|
5460
|
+
// Use preset values if they are not undefined
|
|
5461
|
+
this._artboardWidth = this.artboard.width =
|
|
5462
|
+
this._artboardWidth || this.artboard.width;
|
|
5463
|
+
this._artboardHeight = this.artboard.height =
|
|
5464
|
+
this._artboardHeight || this.artboard.height;
|
|
5465
|
+
};
|
|
5451
5466
|
// Initializes runtime with Rive data and preps for playing
|
|
5452
5467
|
Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay) {
|
|
5453
5468
|
var _a;
|
|
@@ -5472,6 +5487,8 @@ var Rive = /** @class */ (function () {
|
|
|
5472
5487
|
this.file = this.riveFile.getInstance();
|
|
5473
5488
|
// Initialize and draw frame
|
|
5474
5489
|
this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay);
|
|
5490
|
+
// Initialize the artboard size
|
|
5491
|
+
this.initArtboardSize();
|
|
5475
5492
|
// Check for audio
|
|
5476
5493
|
this.initializeAudio();
|
|
5477
5494
|
// Everything's set up, emit a load event
|
|
@@ -5931,13 +5948,18 @@ var Rive = /** @class */ (function () {
|
|
|
5931
5948
|
* Accounts for devicePixelRatio as a multiplier to render the size of the canvas drawing surface.
|
|
5932
5949
|
* Uses the size of the backing canvas to set new width/height attributes. Need to re-render
|
|
5933
5950
|
* and resize the layout to match the new drawing surface afterwards.
|
|
5934
|
-
* Useful function for consumers to include in a window resize listener
|
|
5951
|
+
* Useful function for consumers to include in a window resize listener.
|
|
5952
|
+
*
|
|
5953
|
+
* This method will set the {@link devicePixelRatioUsed} property.
|
|
5954
|
+
*
|
|
5955
|
+
* Optionally, you can provide a {@link customDevicePixelRatio} to provide a
|
|
5956
|
+
* custom value.
|
|
5935
5957
|
*/
|
|
5936
5958
|
Rive.prototype.resizeDrawingSurfaceToCanvas = function (customDevicePixelRatio) {
|
|
5937
5959
|
if (this.canvas instanceof HTMLCanvasElement && !!window) {
|
|
5938
5960
|
var _a = this.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
|
|
5939
5961
|
var dpr = customDevicePixelRatio || window.devicePixelRatio || 1;
|
|
5940
|
-
this.
|
|
5962
|
+
this.devicePixelRatioUsed = dpr;
|
|
5941
5963
|
this.canvas.width = dpr * width;
|
|
5942
5964
|
this.canvas.height = dpr * height;
|
|
5943
5965
|
this.startRendering();
|
|
@@ -6397,7 +6419,7 @@ var Rive = /** @class */ (function () {
|
|
|
6397
6419
|
});
|
|
6398
6420
|
Object.defineProperty(Rive.prototype, "volume", {
|
|
6399
6421
|
/**
|
|
6400
|
-
*
|
|
6422
|
+
* Getter / Setter for the volume of the artboard
|
|
6401
6423
|
*/
|
|
6402
6424
|
get: function () {
|
|
6403
6425
|
if (this.artboard && this.artboard.volume !== this._volume) {
|
|
@@ -6414,6 +6436,89 @@ var Rive = /** @class */ (function () {
|
|
|
6414
6436
|
enumerable: false,
|
|
6415
6437
|
configurable: true
|
|
6416
6438
|
});
|
|
6439
|
+
Object.defineProperty(Rive.prototype, "artboardWidth", {
|
|
6440
|
+
/**
|
|
6441
|
+
* The width of the artboard.
|
|
6442
|
+
*
|
|
6443
|
+
* This will return undefined if the artboard is not loaded yet and a custom
|
|
6444
|
+
* width has not been set.
|
|
6445
|
+
*
|
|
6446
|
+
* Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
|
|
6447
|
+
* with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard width is
|
|
6448
|
+
* automatically set.
|
|
6449
|
+
*/
|
|
6450
|
+
get: function () {
|
|
6451
|
+
if (this.artboard) {
|
|
6452
|
+
return this.artboard.width;
|
|
6453
|
+
}
|
|
6454
|
+
return this._artboardWidth;
|
|
6455
|
+
},
|
|
6456
|
+
set: function (value) {
|
|
6457
|
+
this._artboardWidth = value;
|
|
6458
|
+
if (this.artboard) {
|
|
6459
|
+
this.artboard.width = value;
|
|
6460
|
+
}
|
|
6461
|
+
},
|
|
6462
|
+
enumerable: false,
|
|
6463
|
+
configurable: true
|
|
6464
|
+
});
|
|
6465
|
+
Object.defineProperty(Rive.prototype, "artboardHeight", {
|
|
6466
|
+
/**
|
|
6467
|
+
* The height of the artboard.
|
|
6468
|
+
*
|
|
6469
|
+
* This will return undefined if the artboard is not loaded yet and a custom
|
|
6470
|
+
* height has not been set.
|
|
6471
|
+
*
|
|
6472
|
+
* Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
|
|
6473
|
+
* with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard height is
|
|
6474
|
+
* automatically set.
|
|
6475
|
+
*/
|
|
6476
|
+
get: function () {
|
|
6477
|
+
if (this.artboard) {
|
|
6478
|
+
return this.artboard.height;
|
|
6479
|
+
}
|
|
6480
|
+
return this._artboardHeight;
|
|
6481
|
+
},
|
|
6482
|
+
set: function (value) {
|
|
6483
|
+
this._artboardHeight = value;
|
|
6484
|
+
if (this.artboard) {
|
|
6485
|
+
this.artboard.height = value;
|
|
6486
|
+
}
|
|
6487
|
+
},
|
|
6488
|
+
enumerable: false,
|
|
6489
|
+
configurable: true
|
|
6490
|
+
});
|
|
6491
|
+
/**
|
|
6492
|
+
* Reset the artboard size to its original values.
|
|
6493
|
+
*/
|
|
6494
|
+
Rive.prototype.resetArtboardSize = function () {
|
|
6495
|
+
if (this.artboard) {
|
|
6496
|
+
this.artboard.resetArtboardSize();
|
|
6497
|
+
this._artboardWidth = this.artboard.width;
|
|
6498
|
+
this._artboardHeight = this.artboard.height;
|
|
6499
|
+
}
|
|
6500
|
+
else {
|
|
6501
|
+
// If the artboard isn't loaded, we need to reset the custom width and height
|
|
6502
|
+
this._artboardWidth = undefined;
|
|
6503
|
+
this._artboardHeight = undefined;
|
|
6504
|
+
}
|
|
6505
|
+
};
|
|
6506
|
+
Object.defineProperty(Rive.prototype, "devicePixelRatioUsed", {
|
|
6507
|
+
/**
|
|
6508
|
+
* The device pixel ratio used in rendering and canvas/artboard resizing.
|
|
6509
|
+
*
|
|
6510
|
+
* This value will be overidden by the device pixel ratio used in
|
|
6511
|
+
* {@link resizeDrawingSurfaceToCanvas}. If you use that method, do not set this value.
|
|
6512
|
+
*/
|
|
6513
|
+
get: function () {
|
|
6514
|
+
return this._devicePixelRatioUsed;
|
|
6515
|
+
},
|
|
6516
|
+
set: function (value) {
|
|
6517
|
+
this._devicePixelRatioUsed = value;
|
|
6518
|
+
},
|
|
6519
|
+
enumerable: false,
|
|
6520
|
+
configurable: true
|
|
6521
|
+
});
|
|
6417
6522
|
// Error message for missing source or buffer
|
|
6418
6523
|
Rive.missingErrorMessage = "Rive source file or data buffer required";
|
|
6419
6524
|
return Rive;
|