@rive-app/webgl 2.31.2 → 2.31.3
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 +4 -1
- package/rive.js +77 -39
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +1 -1
- package/rive_fallback.wasm +0 -0
package/package.json
CHANGED
package/rive.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as rc from "./rive_advanced.mjs";
|
|
2
|
+
import { FinalizableTarget } from "./utils";
|
|
2
3
|
export type AssetLoadCallback = (asset: rc.FileAsset, bytes: Uint8Array) => Boolean;
|
|
3
4
|
export type { FileAsset, AudioAsset, FontAsset, ImageAsset, } from "./rive_advanced.mjs";
|
|
4
5
|
/**
|
|
@@ -306,7 +307,7 @@ export interface RiveFileParameters {
|
|
|
306
307
|
onLoad?: EventCallback;
|
|
307
308
|
onLoadError?: EventCallback;
|
|
308
309
|
}
|
|
309
|
-
export declare class RiveFile {
|
|
310
|
+
export declare class RiveFile implements FinalizableTarget {
|
|
310
311
|
private static readonly missingErrorMessage;
|
|
311
312
|
private static readonly fileLoadErrorMessage;
|
|
312
313
|
private src;
|
|
@@ -318,7 +319,9 @@ export declare class RiveFile {
|
|
|
318
319
|
private eventManager;
|
|
319
320
|
private referenceCount;
|
|
320
321
|
private destroyed;
|
|
322
|
+
selfUnref: boolean;
|
|
321
323
|
constructor(params: RiveFileParameters);
|
|
324
|
+
private releaseFile;
|
|
322
325
|
private initData;
|
|
323
326
|
init(): Promise<void>;
|
|
324
327
|
private fireLoadError;
|
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 = {716568:(a, b, c, d, e) => {
|
|
412
412
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
413
413
|
return 0;
|
|
414
414
|
}
|
|
@@ -471,11 +471,11 @@ var Ra, Sa, Wa = {715500:(a, b, c, d, e) => {
|
|
|
471
471
|
}
|
|
472
472
|
window.h.Ea += 1;
|
|
473
473
|
return 1;
|
|
474
|
-
},
|
|
474
|
+
}, 718746:() => {
|
|
475
475
|
"undefined" !== typeof window.h && (window.h.Ta.map(function(a) {
|
|
476
476
|
document.removeEventListener(a, window.h.unlock, !0);
|
|
477
477
|
}), --window.h.Ea, 0 === window.h.Ea && delete window.h);
|
|
478
|
-
},
|
|
478
|
+
}, 719050:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 719154:() => {
|
|
479
479
|
try {
|
|
480
480
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
481
481
|
a.close();
|
|
@@ -483,7 +483,7 @@ var Ra, Sa, Wa = {715500:(a, b, c, d, e) => {
|
|
|
483
483
|
} catch (c) {
|
|
484
484
|
return 0;
|
|
485
485
|
}
|
|
486
|
-
},
|
|
486
|
+
}, 719325:(a, b, c, d, e, f) => {
|
|
487
487
|
if ("undefined" === typeof window.h) {
|
|
488
488
|
return -1;
|
|
489
489
|
}
|
|
@@ -529,7 +529,7 @@ var Ra, Sa, Wa = {715500:(a, b, c, d, e) => {
|
|
|
529
529
|
a == window.h.H.Ca && g.X.connect(g.I.destination);
|
|
530
530
|
g.mb = f;
|
|
531
531
|
return window.h.nc(g);
|
|
532
|
-
},
|
|
532
|
+
}, 722202:a => window.h.ta(a).I.sampleRate, 722275:a => {
|
|
533
533
|
a = window.h.ta(a);
|
|
534
534
|
void 0 !== a.X && (a.X.onaudioprocess = function() {
|
|
535
535
|
}, a.X.disconnect(), a.X = void 0);
|
|
@@ -537,13 +537,13 @@ var Ra, Sa, Wa = {715500:(a, b, c, d, e) => {
|
|
|
537
537
|
a.I.close();
|
|
538
538
|
a.I = void 0;
|
|
539
539
|
a.mb = void 0;
|
|
540
|
-
},
|
|
540
|
+
}, 722675:a => {
|
|
541
541
|
window.h.xb(a);
|
|
542
|
-
},
|
|
542
|
+
}, 722725:a => {
|
|
543
543
|
a = window.h.ta(a);
|
|
544
544
|
a.I.resume();
|
|
545
545
|
a.state = window.h.ha.tb;
|
|
546
|
-
},
|
|
546
|
+
}, 722864:a => {
|
|
547
547
|
a = window.h.ta(a);
|
|
548
548
|
a.I.suspend();
|
|
549
549
|
a.state = window.h.ha.stopped;
|
|
@@ -4065,7 +4065,7 @@ Je();
|
|
|
4065
4065
|
/* 2 */
|
|
4066
4066
|
/***/ ((module) => {
|
|
4067
4067
|
|
|
4068
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.31.
|
|
4068
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl","version":"2.31.3","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}}');
|
|
4069
4069
|
|
|
4070
4070
|
/***/ }),
|
|
4071
4071
|
/* 3 */
|
|
@@ -4212,11 +4212,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4212
4212
|
/* harmony export */ BLANK_URL: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__.BLANK_URL),
|
|
4213
4213
|
/* harmony export */ CustomFileAssetLoaderWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.CustomFileAssetLoaderWrapper),
|
|
4214
4214
|
/* harmony export */ FileAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.FileAssetWrapper),
|
|
4215
|
-
/* harmony export */
|
|
4215
|
+
/* harmony export */ FileFinalizer: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.FileFinalizer),
|
|
4216
4216
|
/* harmony export */ FontAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.FontAssetWrapper),
|
|
4217
4217
|
/* harmony export */ FontWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.FontWrapper),
|
|
4218
4218
|
/* harmony export */ ImageAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.ImageAssetWrapper),
|
|
4219
4219
|
/* harmony export */ ImageWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.ImageWrapper),
|
|
4220
|
+
/* harmony export */ createFinalization: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.createFinalization),
|
|
4220
4221
|
/* harmony export */ finalizationRegistry: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.finalizationRegistry),
|
|
4221
4222
|
/* harmony export */ registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions),
|
|
4222
4223
|
/* harmony export */ sanitizeUrl: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__.sanitizeUrl)
|
|
@@ -4483,11 +4484,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4483
4484
|
/* harmony export */ AudioWrapper: () => (/* binding */ AudioWrapper),
|
|
4484
4485
|
/* harmony export */ CustomFileAssetLoaderWrapper: () => (/* binding */ CustomFileAssetLoaderWrapper),
|
|
4485
4486
|
/* harmony export */ FileAssetWrapper: () => (/* binding */ FileAssetWrapper),
|
|
4486
|
-
/* harmony export */
|
|
4487
|
+
/* harmony export */ FileFinalizer: () => (/* binding */ FileFinalizer),
|
|
4487
4488
|
/* harmony export */ FontAssetWrapper: () => (/* binding */ FontAssetWrapper),
|
|
4488
4489
|
/* harmony export */ FontWrapper: () => (/* binding */ FontWrapper),
|
|
4489
4490
|
/* harmony export */ ImageAssetWrapper: () => (/* binding */ ImageAssetWrapper),
|
|
4490
4491
|
/* harmony export */ ImageWrapper: () => (/* binding */ ImageWrapper),
|
|
4492
|
+
/* harmony export */ createFinalization: () => (/* binding */ createFinalization),
|
|
4491
4493
|
/* harmony export */ finalizationRegistry: () => (/* binding */ finalizationRegistry)
|
|
4492
4494
|
/* harmony export */ });
|
|
4493
4495
|
var __extends = (undefined && undefined.__extends) || (function () {
|
|
@@ -4505,11 +4507,33 @@ var __extends = (undefined && undefined.__extends) || (function () {
|
|
|
4505
4507
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
4506
4508
|
};
|
|
4507
4509
|
})();
|
|
4508
|
-
var
|
|
4509
|
-
function
|
|
4510
|
+
var FileFinalizer = /** @class */ (function () {
|
|
4511
|
+
function FileFinalizer(file) {
|
|
4510
4512
|
this.selfUnref = false;
|
|
4513
|
+
this._file = file;
|
|
4511
4514
|
}
|
|
4512
|
-
|
|
4515
|
+
FileFinalizer.prototype.unref = function () {
|
|
4516
|
+
if (this._file) {
|
|
4517
|
+
this._file.unref();
|
|
4518
|
+
}
|
|
4519
|
+
};
|
|
4520
|
+
return FileFinalizer;
|
|
4521
|
+
}());
|
|
4522
|
+
var ObjectFinalizer = /** @class */ (function () {
|
|
4523
|
+
function ObjectFinalizer(finalizableObject) {
|
|
4524
|
+
this._finalizableObject = finalizableObject;
|
|
4525
|
+
}
|
|
4526
|
+
ObjectFinalizer.prototype.unref = function () {
|
|
4527
|
+
this._finalizableObject.unref();
|
|
4528
|
+
};
|
|
4529
|
+
return ObjectFinalizer;
|
|
4530
|
+
}());
|
|
4531
|
+
var AssetWrapper = /** @class */ (function () {
|
|
4532
|
+
function AssetWrapper() {
|
|
4533
|
+
this.selfUnref = false;
|
|
4534
|
+
}
|
|
4535
|
+
AssetWrapper.prototype.unref = function () { };
|
|
4536
|
+
return AssetWrapper;
|
|
4513
4537
|
}());
|
|
4514
4538
|
var ImageWrapper = /** @class */ (function (_super) {
|
|
4515
4539
|
__extends(ImageWrapper, _super);
|
|
@@ -4531,7 +4555,7 @@ var ImageWrapper = /** @class */ (function (_super) {
|
|
|
4531
4555
|
}
|
|
4532
4556
|
};
|
|
4533
4557
|
return ImageWrapper;
|
|
4534
|
-
}(
|
|
4558
|
+
}(AssetWrapper));
|
|
4535
4559
|
var AudioWrapper = /** @class */ (function (_super) {
|
|
4536
4560
|
__extends(AudioWrapper, _super);
|
|
4537
4561
|
function AudioWrapper(audio) {
|
|
@@ -4552,7 +4576,7 @@ var AudioWrapper = /** @class */ (function (_super) {
|
|
|
4552
4576
|
}
|
|
4553
4577
|
};
|
|
4554
4578
|
return AudioWrapper;
|
|
4555
|
-
}(
|
|
4579
|
+
}(AssetWrapper));
|
|
4556
4580
|
var FontWrapper = /** @class */ (function (_super) {
|
|
4557
4581
|
__extends(FontWrapper, _super);
|
|
4558
4582
|
function FontWrapper(font) {
|
|
@@ -4573,7 +4597,7 @@ var FontWrapper = /** @class */ (function (_super) {
|
|
|
4573
4597
|
}
|
|
4574
4598
|
};
|
|
4575
4599
|
return FontWrapper;
|
|
4576
|
-
}(
|
|
4600
|
+
}(AssetWrapper));
|
|
4577
4601
|
var CustomFileAssetLoaderWrapper = /** @class */ (function () {
|
|
4578
4602
|
function CustomFileAssetLoaderWrapper(runtime, loaderCallback) {
|
|
4579
4603
|
this._assetLoaderCallback = loaderCallback;
|
|
@@ -4720,8 +4744,12 @@ var MyFinalizationRegistry = typeof FinalizationRegistry !== "undefined"
|
|
|
4720
4744
|
? FinalizationRegistry
|
|
4721
4745
|
: FakeFinalizationRegistry;
|
|
4722
4746
|
var finalizationRegistry = new MyFinalizationRegistry(function (ob) {
|
|
4723
|
-
ob.unref();
|
|
4747
|
+
ob === null || ob === void 0 ? void 0 : ob.unref();
|
|
4724
4748
|
});
|
|
4749
|
+
var createFinalization = function (target, finalizable) {
|
|
4750
|
+
var finalizer = new ObjectFinalizer(finalizable);
|
|
4751
|
+
finalizationRegistry.register(target, finalizer);
|
|
4752
|
+
};
|
|
4725
4753
|
|
|
4726
4754
|
|
|
4727
4755
|
|
|
@@ -5451,9 +5479,6 @@ var Animator = /** @class */ (function () {
|
|
|
5451
5479
|
if (sm) {
|
|
5452
5480
|
var newStateMachine = new StateMachine(sm, this.runtime, playing, this.artboard);
|
|
5453
5481
|
this.stateMachines.push(newStateMachine);
|
|
5454
|
-
if (!playing) {
|
|
5455
|
-
newStateMachine.advanceAndApply(0);
|
|
5456
|
-
}
|
|
5457
5482
|
}
|
|
5458
5483
|
else {
|
|
5459
5484
|
console.warn("State Machine with name ".concat(animatables[i], " not found."));
|
|
@@ -5472,6 +5497,16 @@ var Animator = /** @class */ (function () {
|
|
|
5472
5497
|
Animator.prototype.play = function (animatables) {
|
|
5473
5498
|
return this.add(animatables, true);
|
|
5474
5499
|
};
|
|
5500
|
+
/**
|
|
5501
|
+
* Advance state machines if they are paused after initialization
|
|
5502
|
+
*/
|
|
5503
|
+
Animator.prototype.advanceIfPaused = function () {
|
|
5504
|
+
this.stateMachines.forEach(function (sm) {
|
|
5505
|
+
if (!sm.playing) {
|
|
5506
|
+
sm.advanceAndApply(0);
|
|
5507
|
+
}
|
|
5508
|
+
});
|
|
5509
|
+
};
|
|
5475
5510
|
/**
|
|
5476
5511
|
* Pauses named animations and state machines, or everything if nothing is
|
|
5477
5512
|
* specified
|
|
@@ -6015,6 +6050,7 @@ var RiveFile = /** @class */ (function () {
|
|
|
6015
6050
|
this.enableRiveAssetCDN = true;
|
|
6016
6051
|
this.referenceCount = 0;
|
|
6017
6052
|
this.destroyed = false;
|
|
6053
|
+
this.selfUnref = false;
|
|
6018
6054
|
this.src = params.src;
|
|
6019
6055
|
this.buffer = params.buffer;
|
|
6020
6056
|
if (params.assetLoader)
|
|
@@ -6030,19 +6066,25 @@ var RiveFile = /** @class */ (function () {
|
|
|
6030
6066
|
if (params.onLoadError)
|
|
6031
6067
|
this.on(EventType.LoadError, params.onLoadError);
|
|
6032
6068
|
}
|
|
6069
|
+
RiveFile.prototype.releaseFile = function () {
|
|
6070
|
+
var _a;
|
|
6071
|
+
if (this.selfUnref) {
|
|
6072
|
+
(_a = this.file) === null || _a === void 0 ? void 0 : _a.unref();
|
|
6073
|
+
}
|
|
6074
|
+
this.file = null;
|
|
6075
|
+
};
|
|
6033
6076
|
RiveFile.prototype.initData = function () {
|
|
6034
6077
|
return __awaiter(this, void 0, void 0, function () {
|
|
6035
|
-
var _a, loader, loaderWrapper, _b;
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
switch (_d.label) {
|
|
6078
|
+
var _a, loader, loaderWrapper, _b, fileFinalizer;
|
|
6079
|
+
return __generator(this, function (_c) {
|
|
6080
|
+
switch (_c.label) {
|
|
6039
6081
|
case 0:
|
|
6040
6082
|
if (!this.src) return [3 /*break*/, 2];
|
|
6041
6083
|
_a = this;
|
|
6042
6084
|
return [4 /*yield*/, loadRiveFile(this.src)];
|
|
6043
6085
|
case 1:
|
|
6044
|
-
_a.buffer =
|
|
6045
|
-
|
|
6086
|
+
_a.buffer = _c.sent();
|
|
6087
|
+
_c.label = 2;
|
|
6046
6088
|
case 2:
|
|
6047
6089
|
if (this.destroyed) {
|
|
6048
6090
|
return [2 /*return*/];
|
|
@@ -6056,10 +6098,11 @@ var RiveFile = /** @class */ (function () {
|
|
|
6056
6098
|
return [4 /*yield*/, this.runtime.load(new Uint8Array(this.buffer), loader, this.enableRiveAssetCDN)];
|
|
6057
6099
|
case 3:
|
|
6058
6100
|
// Load the Rive file
|
|
6059
|
-
_b.file =
|
|
6101
|
+
_b.file = _c.sent();
|
|
6102
|
+
fileFinalizer = new _utils__WEBPACK_IMPORTED_MODULE_3__.FileFinalizer(this.file);
|
|
6103
|
+
_utils__WEBPACK_IMPORTED_MODULE_3__.finalizationRegistry.register(this, fileFinalizer);
|
|
6060
6104
|
if (this.destroyed) {
|
|
6061
|
-
|
|
6062
|
-
this.file = null;
|
|
6105
|
+
this.releaseFile();
|
|
6063
6106
|
return [2 /*return*/];
|
|
6064
6107
|
}
|
|
6065
6108
|
if (this.file !== null) {
|
|
@@ -6140,12 +6183,10 @@ var RiveFile = /** @class */ (function () {
|
|
|
6140
6183
|
});
|
|
6141
6184
|
};
|
|
6142
6185
|
RiveFile.prototype.cleanup = function () {
|
|
6143
|
-
var _a;
|
|
6144
6186
|
this.referenceCount -= 1;
|
|
6145
6187
|
if (this.referenceCount <= 0) {
|
|
6146
6188
|
this.removeAllRiveEventListeners();
|
|
6147
|
-
|
|
6148
|
-
this.file = null;
|
|
6189
|
+
this.releaseFile();
|
|
6149
6190
|
this.destroyed = true;
|
|
6150
6191
|
}
|
|
6151
6192
|
};
|
|
@@ -6497,6 +6538,9 @@ var Rive = /** @class */ (function () {
|
|
|
6497
6538
|
type: EventType.Load,
|
|
6498
6539
|
data: (_a = this.src) !== null && _a !== void 0 ? _a : "buffer",
|
|
6499
6540
|
});
|
|
6541
|
+
// Only initialize paused state machines after the load event has been fired
|
|
6542
|
+
// to allow users to initialize inputs and view models before the first advance
|
|
6543
|
+
this.animator.advanceIfPaused();
|
|
6500
6544
|
// Flag ready for playback commands and clear the task queue; this order
|
|
6501
6545
|
// is important or it may infinitely recurse
|
|
6502
6546
|
this.readyForPlaying = true;
|
|
@@ -6532,12 +6576,6 @@ var Rive = /** @class */ (function () {
|
|
|
6532
6576
|
}
|
|
6533
6577
|
this.artboard = rootArtboard;
|
|
6534
6578
|
rootArtboard.volume = this._volume * audioManager.systemVolume;
|
|
6535
|
-
// Check that the artboard has at least 1 animation
|
|
6536
|
-
if (this.artboard.animationCount() < 1) {
|
|
6537
|
-
var msg = "Artboard has no animations";
|
|
6538
|
-
this.eventManager.fire({ type: EventType.LoadError, data: msg });
|
|
6539
|
-
throw msg;
|
|
6540
|
-
}
|
|
6541
6579
|
// Initialize the animator
|
|
6542
6580
|
this.animator = new Animator(this.runtime, this.artboard, this.eventManager);
|
|
6543
6581
|
// Initialize the animations; as loaded hasn't happened yet, we need to
|