@rive-app/webgl 2.33.3 → 2.34.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 +7 -0
- package/rive.js +60 -17
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +1 -0
- package/rive_fallback.wasm +0 -0
package/package.json
CHANGED
package/rive.d.ts
CHANGED
|
@@ -128,7 +128,9 @@ declare class Artboard extends BaseArtboard {
|
|
|
128
128
|
declare class BindableArtboard extends BaseArtboard implements rc.FinalizableTarget {
|
|
129
129
|
selfUnref: boolean;
|
|
130
130
|
nativeArtboard: rc.BindableArtboard;
|
|
131
|
+
nativeViewModel: rc.ViewModelInstance | null;
|
|
131
132
|
constructor(artboard: rc.BindableArtboard);
|
|
133
|
+
set viewModel(value: ViewModelInstance);
|
|
132
134
|
destroy(): void;
|
|
133
135
|
}
|
|
134
136
|
/**
|
|
@@ -386,6 +388,7 @@ export declare class RiveFile implements rc.FinalizableTarget {
|
|
|
386
388
|
getBindableArtboard(name: string): BindableArtboard | null;
|
|
387
389
|
getDefaultBindableArtboard(): BindableArtboard | null;
|
|
388
390
|
internalBindableArtboardFromArtboard(artboard: rc.Artboard): BindableArtboard | null;
|
|
391
|
+
viewModelByName(name: string): ViewModel | null;
|
|
389
392
|
}
|
|
390
393
|
export declare class Rive {
|
|
391
394
|
private readonly canvas;
|
|
@@ -425,6 +428,9 @@ export declare class Rive {
|
|
|
425
428
|
private _artboardHeight;
|
|
426
429
|
private _devicePixelRatioUsed;
|
|
427
430
|
private _hasZeroSize;
|
|
431
|
+
private _needsRedraw;
|
|
432
|
+
private _currentCanvasWidth;
|
|
433
|
+
private _currentCanvasHeight;
|
|
428
434
|
private _audioEventListener;
|
|
429
435
|
private _boundDraw;
|
|
430
436
|
private _viewModelInstance;
|
|
@@ -460,6 +466,7 @@ export declare class Rive {
|
|
|
460
466
|
private initData;
|
|
461
467
|
private initArtboard;
|
|
462
468
|
drawFrame(): void;
|
|
469
|
+
private _canvasSizeChanged;
|
|
463
470
|
private lastRenderTime;
|
|
464
471
|
private frameRequestId;
|
|
465
472
|
/**
|
package/rive.js
CHANGED
|
@@ -393,7 +393,7 @@ function Ra(a, b) {
|
|
|
393
393
|
return Qa(c, a, b);
|
|
394
394
|
}));
|
|
395
395
|
}
|
|
396
|
-
var Sa, Ta, Xa = {
|
|
396
|
+
var Sa, Ta, Xa = {739746:(a, b, c, d, e) => {
|
|
397
397
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
398
398
|
return 0;
|
|
399
399
|
}
|
|
@@ -456,11 +456,11 @@ var Sa, Ta, Xa = {737794:(a, b, c, d, e) => {
|
|
|
456
456
|
}
|
|
457
457
|
window.h.Ca += 1;
|
|
458
458
|
return 1;
|
|
459
|
-
},
|
|
459
|
+
}, 741924:() => {
|
|
460
460
|
"undefined" !== typeof window.h && (window.h.Ra.map(function(a) {
|
|
461
461
|
document.removeEventListener(a, window.h.unlock, !0);
|
|
462
462
|
}), --window.h.Ca, 0 === window.h.Ca && delete window.h);
|
|
463
|
-
},
|
|
463
|
+
}, 742228:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 742332:() => {
|
|
464
464
|
try {
|
|
465
465
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
466
466
|
a.close();
|
|
@@ -468,7 +468,7 @@ var Sa, Ta, Xa = {737794:(a, b, c, d, e) => {
|
|
|
468
468
|
} catch (c) {
|
|
469
469
|
return 0;
|
|
470
470
|
}
|
|
471
|
-
},
|
|
471
|
+
}, 742503:(a, b, c, d, e, f) => {
|
|
472
472
|
if ("undefined" === typeof window.h) {
|
|
473
473
|
return -1;
|
|
474
474
|
}
|
|
@@ -514,7 +514,7 @@ var Sa, Ta, Xa = {737794:(a, b, c, d, e) => {
|
|
|
514
514
|
a == window.h.H.Aa && g.W.connect(g.J.destination);
|
|
515
515
|
g.kb = f;
|
|
516
516
|
return window.h.fc(g);
|
|
517
|
-
},
|
|
517
|
+
}, 745380:a => window.h.ra(a).J.sampleRate, 745453:a => {
|
|
518
518
|
a = window.h.ra(a);
|
|
519
519
|
void 0 !== a.W && (a.W.onaudioprocess = function() {
|
|
520
520
|
}, a.W.disconnect(), a.W = void 0);
|
|
@@ -522,13 +522,13 @@ var Sa, Ta, Xa = {737794:(a, b, c, d, e) => {
|
|
|
522
522
|
a.J.close();
|
|
523
523
|
a.J = void 0;
|
|
524
524
|
a.kb = void 0;
|
|
525
|
-
},
|
|
525
|
+
}, 745853:a => {
|
|
526
526
|
window.h.ub(a);
|
|
527
|
-
},
|
|
527
|
+
}, 745903:a => {
|
|
528
528
|
a = window.h.ra(a);
|
|
529
529
|
a.J.resume();
|
|
530
530
|
a.state = window.h.ga.qb;
|
|
531
|
-
},
|
|
531
|
+
}, 746042:a => {
|
|
532
532
|
a = window.h.ra(a);
|
|
533
533
|
a.J.suspend();
|
|
534
534
|
a.state = window.h.ga.stopped;
|
|
@@ -3935,7 +3935,7 @@ moduleRtn = ca;
|
|
|
3935
3935
|
/* 2 */
|
|
3936
3936
|
/***/ ((module) => {
|
|
3937
3937
|
|
|
3938
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.
|
|
3938
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.34.1","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}}');
|
|
3939
3939
|
|
|
3940
3940
|
/***/ }),
|
|
3941
3941
|
/* 3 */
|
|
@@ -5178,9 +5178,18 @@ var BindableArtboard = /** @class */ (function (_super) {
|
|
|
5178
5178
|
_this.nativeArtboard = artboard;
|
|
5179
5179
|
return _this;
|
|
5180
5180
|
}
|
|
5181
|
+
Object.defineProperty(BindableArtboard.prototype, "viewModel", {
|
|
5182
|
+
set: function (value) {
|
|
5183
|
+
this.nativeViewModel = value.nativeInstance;
|
|
5184
|
+
},
|
|
5185
|
+
enumerable: false,
|
|
5186
|
+
configurable: true
|
|
5187
|
+
});
|
|
5181
5188
|
BindableArtboard.prototype.destroy = function () {
|
|
5189
|
+
var _a;
|
|
5182
5190
|
if (this.selfUnref) {
|
|
5183
5191
|
this.nativeArtboard.unref();
|
|
5192
|
+
(_a = this.nativeViewModel) === null || _a === void 0 ? void 0 : _a.unref();
|
|
5184
5193
|
}
|
|
5185
5194
|
};
|
|
5186
5195
|
return BindableArtboard;
|
|
@@ -6216,6 +6225,13 @@ var RiveFile = /** @class */ (function () {
|
|
|
6216
6225
|
var nativeBindableArtboard = this.file.internalBindableArtboardFromArtboard(artboard);
|
|
6217
6226
|
return this.createBindableArtboard(nativeBindableArtboard);
|
|
6218
6227
|
};
|
|
6228
|
+
RiveFile.prototype.viewModelByName = function (name) {
|
|
6229
|
+
var viewModel = this.file.viewModelByName(name);
|
|
6230
|
+
if (viewModel !== null) {
|
|
6231
|
+
return new ViewModel(viewModel);
|
|
6232
|
+
}
|
|
6233
|
+
return null;
|
|
6234
|
+
};
|
|
6219
6235
|
// Error message for missing source or buffer
|
|
6220
6236
|
RiveFile.missingErrorMessage = "Rive source file or data buffer required";
|
|
6221
6237
|
// Error message for file load error
|
|
@@ -6262,6 +6278,12 @@ var Rive = /** @class */ (function () {
|
|
|
6262
6278
|
this._devicePixelRatioUsed = 1;
|
|
6263
6279
|
// Whether the canvas element's size is 0
|
|
6264
6280
|
this._hasZeroSize = false;
|
|
6281
|
+
// Whether a draw operation needs to be forced
|
|
6282
|
+
this._needsRedraw = false;
|
|
6283
|
+
// Canvas width and height. Values are lazily updated so they might
|
|
6284
|
+
// not be in sync with current canvas size.
|
|
6285
|
+
this._currentCanvasWidth = 0;
|
|
6286
|
+
this._currentCanvasHeight = 0;
|
|
6265
6287
|
// Audio event listener
|
|
6266
6288
|
this._audioEventListener = null;
|
|
6267
6289
|
// draw method bound to the class
|
|
@@ -6296,6 +6318,8 @@ var Rive = /** @class */ (function () {
|
|
|
6296
6318
|
if (params.canvas.constructor === HTMLCanvasElement) {
|
|
6297
6319
|
this._observed = observers.add(this.canvas, this.onCanvasResize);
|
|
6298
6320
|
}
|
|
6321
|
+
this._currentCanvasWidth = this.canvas.width;
|
|
6322
|
+
this._currentCanvasHeight = this.canvas.height;
|
|
6299
6323
|
this.src = params.src;
|
|
6300
6324
|
this.buffer = params.buffer;
|
|
6301
6325
|
this.riveFile = params.riveFile;
|
|
@@ -6636,6 +6660,20 @@ var Rive = /** @class */ (function () {
|
|
|
6636
6660
|
this.scheduleRendering();
|
|
6637
6661
|
}
|
|
6638
6662
|
};
|
|
6663
|
+
Rive.prototype._canvasSizeChanged = function () {
|
|
6664
|
+
var changed = false;
|
|
6665
|
+
if (this.canvas) {
|
|
6666
|
+
if (this.canvas.width !== this._currentCanvasWidth) {
|
|
6667
|
+
this._currentCanvasWidth = this.canvas.width;
|
|
6668
|
+
changed = true;
|
|
6669
|
+
}
|
|
6670
|
+
if (this.canvas.height !== this._currentCanvasHeight) {
|
|
6671
|
+
this._currentCanvasHeight = this.canvas.height;
|
|
6672
|
+
changed = true;
|
|
6673
|
+
}
|
|
6674
|
+
}
|
|
6675
|
+
return changed;
|
|
6676
|
+
};
|
|
6639
6677
|
/**
|
|
6640
6678
|
* Draw rendering loop; renders animation frames at the correct time interval.
|
|
6641
6679
|
* @param time the time at which to render a frame
|
|
@@ -6724,7 +6762,9 @@ var Rive = /** @class */ (function () {
|
|
|
6724
6762
|
if (!this._hasZeroSize) {
|
|
6725
6763
|
// If there was no dirt on this frame, do not clear and draw
|
|
6726
6764
|
if (this.drawOptimization == DrawOptimizationOptions.AlwaysDraw ||
|
|
6727
|
-
this.artboard.didChange()
|
|
6765
|
+
this.artboard.didChange() ||
|
|
6766
|
+
this._needsRedraw ||
|
|
6767
|
+
this._canvasSizeChanged()) {
|
|
6728
6768
|
// Canvas must be wiped to prevent artifacts
|
|
6729
6769
|
renderer.clear();
|
|
6730
6770
|
renderer.save();
|
|
@@ -6733,6 +6773,7 @@ var Rive = /** @class */ (function () {
|
|
|
6733
6773
|
this.artboard.draw(renderer);
|
|
6734
6774
|
renderer.restore();
|
|
6735
6775
|
renderer.flush();
|
|
6776
|
+
this._needsRedraw = false;
|
|
6736
6777
|
}
|
|
6737
6778
|
}
|
|
6738
6779
|
// Check for any animations that looped
|
|
@@ -7057,6 +7098,7 @@ var Rive = /** @class */ (function () {
|
|
|
7057
7098
|
this.devicePixelRatioUsed = dpr;
|
|
7058
7099
|
this.canvas.width = dpr * width;
|
|
7059
7100
|
this.canvas.height = dpr * height;
|
|
7101
|
+
this._needsRedraw = true;
|
|
7060
7102
|
this.resizeToCanvas();
|
|
7061
7103
|
this.drawFrame();
|
|
7062
7104
|
if (this.layout.fit === Fit.Layout) {
|
|
@@ -7353,7 +7395,8 @@ var Rive = /** @class */ (function () {
|
|
|
7353
7395
|
* @returns true if no animations are playing or paused
|
|
7354
7396
|
*/
|
|
7355
7397
|
get: function () {
|
|
7356
|
-
|
|
7398
|
+
var _a, _b;
|
|
7399
|
+
return (_b = (_a = this.animator) === null || _a === void 0 ? void 0 : _a.isStopped) !== null && _b !== void 0 ? _b : true;
|
|
7357
7400
|
},
|
|
7358
7401
|
enumerable: false,
|
|
7359
7402
|
configurable: true
|
|
@@ -7655,11 +7698,8 @@ var Rive = /** @class */ (function () {
|
|
|
7655
7698
|
return null;
|
|
7656
7699
|
};
|
|
7657
7700
|
Rive.prototype.viewModelByName = function (name) {
|
|
7658
|
-
var
|
|
7659
|
-
|
|
7660
|
-
return new ViewModel(viewModel);
|
|
7661
|
-
}
|
|
7662
|
-
return null;
|
|
7701
|
+
var _a;
|
|
7702
|
+
return (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.viewModelByName(name);
|
|
7663
7703
|
};
|
|
7664
7704
|
Rive.prototype.enums = function () {
|
|
7665
7705
|
if (this._dataEnums === null) {
|
|
@@ -8502,7 +8542,7 @@ var ViewModelInstanceArtboard = /** @class */ (function (_super) {
|
|
|
8502
8542
|
}
|
|
8503
8543
|
Object.defineProperty(ViewModelInstanceArtboard.prototype, "value", {
|
|
8504
8544
|
set: function (artboard) {
|
|
8505
|
-
var _a;
|
|
8545
|
+
var _a, _b;
|
|
8506
8546
|
var bindableArtboard;
|
|
8507
8547
|
if (artboard.isBindableArtboard) {
|
|
8508
8548
|
bindableArtboard = artboard;
|
|
@@ -8511,6 +8551,9 @@ var ViewModelInstanceArtboard = /** @class */ (function (_super) {
|
|
|
8511
8551
|
bindableArtboard = artboard.file.internalBindableArtboardFromArtboard(artboard.nativeArtboard);
|
|
8512
8552
|
}
|
|
8513
8553
|
this._viewModelInstanceValue.value((_a = bindableArtboard === null || bindableArtboard === void 0 ? void 0 : bindableArtboard.nativeArtboard) !== null && _a !== void 0 ? _a : null);
|
|
8554
|
+
if (bindableArtboard === null || bindableArtboard === void 0 ? void 0 : bindableArtboard.nativeViewModel) {
|
|
8555
|
+
this._viewModelInstanceValue.viewModelInstance((_b = bindableArtboard === null || bindableArtboard === void 0 ? void 0 : bindableArtboard.nativeViewModel) !== null && _b !== void 0 ? _b : null);
|
|
8556
|
+
}
|
|
8514
8557
|
},
|
|
8515
8558
|
enumerable: false,
|
|
8516
8559
|
configurable: true
|