@rive-app/webgl 2.15.5 → 2.16.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 +48 -1
- package/rive.js +196 -58
- 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
|
@@ -123,7 +123,7 @@ export declare enum EventType {
|
|
|
123
123
|
export type RiveEventPayload = rc.RiveEvent | rc.OpenUrlEvent;
|
|
124
124
|
export interface Event {
|
|
125
125
|
type: EventType;
|
|
126
|
-
data?: string | string[] | LoopEvent | number | RiveEventPayload;
|
|
126
|
+
data?: string | string[] | LoopEvent | number | RiveEventPayload | RiveFile;
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Looping types: one-shot, loop, and ping-pong
|
|
@@ -189,6 +189,7 @@ export interface RiveParameters {
|
|
|
189
189
|
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
190
190
|
src?: string;
|
|
191
191
|
buffer?: ArrayBuffer;
|
|
192
|
+
riveFile?: RiveFile;
|
|
192
193
|
artboard?: string;
|
|
193
194
|
animations?: string | string[];
|
|
194
195
|
stateMachines?: string | string[];
|
|
@@ -265,6 +266,7 @@ export interface RiveParameters {
|
|
|
265
266
|
export interface RiveLoadParameters {
|
|
266
267
|
src?: string;
|
|
267
268
|
buffer?: ArrayBuffer;
|
|
269
|
+
riveFile?: RiveFile;
|
|
268
270
|
autoplay?: boolean;
|
|
269
271
|
artboard?: string;
|
|
270
272
|
animations?: string | string[];
|
|
@@ -278,6 +280,50 @@ export interface RiveResetParameters {
|
|
|
278
280
|
stateMachines?: string | string[];
|
|
279
281
|
autoplay?: boolean;
|
|
280
282
|
}
|
|
283
|
+
export interface RiveFileParameters {
|
|
284
|
+
src?: string;
|
|
285
|
+
buffer?: ArrayBuffer;
|
|
286
|
+
assetLoader?: AssetLoadCallback;
|
|
287
|
+
enableRiveAssetCDN?: boolean;
|
|
288
|
+
onLoad?: EventCallback;
|
|
289
|
+
onLoadError?: EventCallback;
|
|
290
|
+
}
|
|
291
|
+
export declare class RiveFile {
|
|
292
|
+
private static readonly missingErrorMessage;
|
|
293
|
+
private static readonly fileLoadErrorMessage;
|
|
294
|
+
private src;
|
|
295
|
+
private buffer;
|
|
296
|
+
private runtime;
|
|
297
|
+
private file;
|
|
298
|
+
private assetLoader;
|
|
299
|
+
private enableRiveAssetCDN;
|
|
300
|
+
private eventManager;
|
|
301
|
+
private referenceCount;
|
|
302
|
+
constructor(params: RiveFileParameters);
|
|
303
|
+
private initData;
|
|
304
|
+
init(): Promise<void>;
|
|
305
|
+
/**
|
|
306
|
+
* Subscribe to Rive-generated events
|
|
307
|
+
* @param type the type of event to subscribe to
|
|
308
|
+
* @param callback callback to fire when the event occurs
|
|
309
|
+
*/
|
|
310
|
+
on(type: EventType, callback: EventCallback): void;
|
|
311
|
+
/**
|
|
312
|
+
* Unsubscribes from a Rive-generated event
|
|
313
|
+
* @param type the type of event to unsubscribe from
|
|
314
|
+
* @param callback the callback to unsubscribe
|
|
315
|
+
*/
|
|
316
|
+
off(type: EventType, callback: EventCallback): void;
|
|
317
|
+
cleanup(): void;
|
|
318
|
+
/**
|
|
319
|
+
* Unsubscribes all Rive listeners from an event type, or everything if no type is
|
|
320
|
+
* given
|
|
321
|
+
* @param type the type of event to unsubscribe from, or all types if
|
|
322
|
+
* undefined
|
|
323
|
+
*/
|
|
324
|
+
removeAllRiveEventListeners(type?: EventType): void;
|
|
325
|
+
getInstance(): rc.File;
|
|
326
|
+
}
|
|
281
327
|
export declare class Rive {
|
|
282
328
|
private readonly canvas;
|
|
283
329
|
private src;
|
|
@@ -298,6 +344,7 @@ export declare class Rive {
|
|
|
298
344
|
private artboard;
|
|
299
345
|
private eventCleanup;
|
|
300
346
|
private file;
|
|
347
|
+
private riveFile;
|
|
301
348
|
private eventManager;
|
|
302
349
|
private taskQueue;
|
|
303
350
|
private animator;
|
package/rive.js
CHANGED
|
@@ -400,7 +400,7 @@ function Qa(a, b) {
|
|
|
400
400
|
return Pa(c, a, b);
|
|
401
401
|
}));
|
|
402
402
|
}
|
|
403
|
-
var Ra, Sa, Wa = {
|
|
403
|
+
var Ra, Sa, Wa = {685260:(a, b, c, d, e) => {
|
|
404
404
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
405
405
|
return 0;
|
|
406
406
|
}
|
|
@@ -463,9 +463,9 @@ var Ra, Sa, Wa = {685180:(a, b, c, d, e) => {
|
|
|
463
463
|
}
|
|
464
464
|
window.h.Ea += 1;
|
|
465
465
|
return 1;
|
|
466
|
-
},
|
|
466
|
+
}, 687438:() => {
|
|
467
467
|
"undefined" !== typeof window.h && (--window.h.Ea, 0 === window.h.Ea && delete window.h);
|
|
468
|
-
},
|
|
468
|
+
}, 687602:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 687706:() => {
|
|
469
469
|
try {
|
|
470
470
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
471
471
|
a.close();
|
|
@@ -473,7 +473,7 @@ var Ra, Sa, Wa = {685180:(a, b, c, d, e) => {
|
|
|
473
473
|
} catch (c) {
|
|
474
474
|
return 0;
|
|
475
475
|
}
|
|
476
|
-
},
|
|
476
|
+
}, 687877:(a, b, c, d, e, f) => {
|
|
477
477
|
if ("undefined" === typeof window.h) {
|
|
478
478
|
return -1;
|
|
479
479
|
}
|
|
@@ -519,7 +519,7 @@ var Ra, Sa, Wa = {685180:(a, b, c, d, e) => {
|
|
|
519
519
|
a == window.h.H.Ca && g.X.connect(g.I.destination);
|
|
520
520
|
g.lb = f;
|
|
521
521
|
return window.h.nc(g);
|
|
522
|
-
},
|
|
522
|
+
}, 690754:a => window.h.ta(a).I.sampleRate, 690827:a => {
|
|
523
523
|
a = window.h.ta(a);
|
|
524
524
|
void 0 !== a.X && (a.X.onaudioprocess = function() {
|
|
525
525
|
}, a.X.disconnect(), a.X = void 0);
|
|
@@ -527,13 +527,13 @@ var Ra, Sa, Wa = {685180:(a, b, c, d, e) => {
|
|
|
527
527
|
a.I.close();
|
|
528
528
|
a.I = void 0;
|
|
529
529
|
a.lb = void 0;
|
|
530
|
-
},
|
|
530
|
+
}, 691227:a => {
|
|
531
531
|
window.h.xb(a);
|
|
532
|
-
},
|
|
532
|
+
}, 691277:a => {
|
|
533
533
|
a = window.h.ta(a);
|
|
534
534
|
a.I.resume();
|
|
535
535
|
a.state = window.h.ha.sb;
|
|
536
|
-
},
|
|
536
|
+
}, 691416:a => {
|
|
537
537
|
a = window.h.ta(a);
|
|
538
538
|
a.I.suspend();
|
|
539
539
|
a.state = window.h.ha.stopped;
|
|
@@ -4053,7 +4053,7 @@ Ie();
|
|
|
4053
4053
|
/* 2 */
|
|
4054
4054
|
/***/ ((module) => {
|
|
4055
4055
|
|
|
4056
|
-
module.exports = JSON.parse('{"name":"@rive-app/webgl","version":"2.
|
|
4056
|
+
module.exports = JSON.parse('{"name":"@rive-app/webgl","version":"2.16.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}}');
|
|
4057
4057
|
|
|
4058
4058
|
/***/ }),
|
|
4059
4059
|
/* 3 */
|
|
@@ -4347,6 +4347,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4347
4347
|
/* harmony export */ LoopType: () => (/* binding */ LoopType),
|
|
4348
4348
|
/* harmony export */ Rive: () => (/* binding */ Rive),
|
|
4349
4349
|
/* harmony export */ RiveEventType: () => (/* binding */ RiveEventType),
|
|
4350
|
+
/* harmony export */ RiveFile: () => (/* binding */ RiveFile),
|
|
4350
4351
|
/* harmony export */ RuntimeLoader: () => (/* binding */ RuntimeLoader),
|
|
4351
4352
|
/* harmony export */ StateMachineInput: () => (/* binding */ StateMachineInput),
|
|
4352
4353
|
/* harmony export */ StateMachineInputType: () => (/* binding */ StateMachineInputType),
|
|
@@ -5532,6 +5533,142 @@ var ObjectObservers = /** @class */ (function () {
|
|
|
5532
5533
|
return ObjectObservers;
|
|
5533
5534
|
}());
|
|
5534
5535
|
var observers = new ObjectObservers();
|
|
5536
|
+
var RiveFile = /** @class */ (function () {
|
|
5537
|
+
function RiveFile(params) {
|
|
5538
|
+
// Allow the runtime to automatically load assets hosted in Rive's runtime.
|
|
5539
|
+
this.enableRiveAssetCDN = true;
|
|
5540
|
+
this.referenceCount = 0;
|
|
5541
|
+
this.src = params.src;
|
|
5542
|
+
this.buffer = params.buffer;
|
|
5543
|
+
if (params.assetLoader)
|
|
5544
|
+
this.assetLoader = params.assetLoader;
|
|
5545
|
+
this.enableRiveAssetCDN =
|
|
5546
|
+
typeof params.enableRiveAssetCDN == "boolean"
|
|
5547
|
+
? params.enableRiveAssetCDN
|
|
5548
|
+
: true;
|
|
5549
|
+
// New event management system
|
|
5550
|
+
this.eventManager = new EventManager();
|
|
5551
|
+
if (params.onLoad)
|
|
5552
|
+
this.on(EventType.Load, params.onLoad);
|
|
5553
|
+
if (params.onLoadError)
|
|
5554
|
+
this.on(EventType.LoadError, params.onLoadError);
|
|
5555
|
+
}
|
|
5556
|
+
RiveFile.prototype.initData = function () {
|
|
5557
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5558
|
+
var _a, loader, _b;
|
|
5559
|
+
return __generator(this, function (_c) {
|
|
5560
|
+
switch (_c.label) {
|
|
5561
|
+
case 0:
|
|
5562
|
+
if (!this.src) return [3 /*break*/, 2];
|
|
5563
|
+
_a = this;
|
|
5564
|
+
return [4 /*yield*/, loadRiveFile(this.src)];
|
|
5565
|
+
case 1:
|
|
5566
|
+
_a.buffer = _c.sent();
|
|
5567
|
+
_c.label = 2;
|
|
5568
|
+
case 2:
|
|
5569
|
+
if (this.assetLoader) {
|
|
5570
|
+
loader = new this.runtime.CustomFileAssetLoader({
|
|
5571
|
+
loadContents: this.assetLoader,
|
|
5572
|
+
});
|
|
5573
|
+
}
|
|
5574
|
+
// Load the Rive file
|
|
5575
|
+
_b = this;
|
|
5576
|
+
return [4 /*yield*/, this.runtime.load(new Uint8Array(this.buffer), loader, this.enableRiveAssetCDN)];
|
|
5577
|
+
case 3:
|
|
5578
|
+
// Load the Rive file
|
|
5579
|
+
_b.file = _c.sent();
|
|
5580
|
+
if (this.file !== null) {
|
|
5581
|
+
this.eventManager.fire({
|
|
5582
|
+
type: EventType.Load,
|
|
5583
|
+
data: this,
|
|
5584
|
+
});
|
|
5585
|
+
}
|
|
5586
|
+
else {
|
|
5587
|
+
this.eventManager.fire({
|
|
5588
|
+
type: EventType.LoadError,
|
|
5589
|
+
data: null,
|
|
5590
|
+
});
|
|
5591
|
+
throw new Error(RiveFile.fileLoadErrorMessage);
|
|
5592
|
+
}
|
|
5593
|
+
return [2 /*return*/];
|
|
5594
|
+
}
|
|
5595
|
+
});
|
|
5596
|
+
});
|
|
5597
|
+
};
|
|
5598
|
+
RiveFile.prototype.init = function () {
|
|
5599
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
5600
|
+
var _a;
|
|
5601
|
+
return __generator(this, function (_b) {
|
|
5602
|
+
switch (_b.label) {
|
|
5603
|
+
case 0:
|
|
5604
|
+
// If no source file url specified, it's a bust
|
|
5605
|
+
if (!this.src && !this.buffer) {
|
|
5606
|
+
throw new Error(RiveFile.missingErrorMessage);
|
|
5607
|
+
}
|
|
5608
|
+
_a = this;
|
|
5609
|
+
return [4 /*yield*/, RuntimeLoader.awaitInstance()];
|
|
5610
|
+
case 1:
|
|
5611
|
+
_a.runtime = _b.sent();
|
|
5612
|
+
return [4 /*yield*/, this.initData()];
|
|
5613
|
+
case 2:
|
|
5614
|
+
_b.sent();
|
|
5615
|
+
return [2 /*return*/];
|
|
5616
|
+
}
|
|
5617
|
+
});
|
|
5618
|
+
});
|
|
5619
|
+
};
|
|
5620
|
+
/**
|
|
5621
|
+
* Subscribe to Rive-generated events
|
|
5622
|
+
* @param type the type of event to subscribe to
|
|
5623
|
+
* @param callback callback to fire when the event occurs
|
|
5624
|
+
*/
|
|
5625
|
+
RiveFile.prototype.on = function (type, callback) {
|
|
5626
|
+
this.eventManager.add({
|
|
5627
|
+
type: type,
|
|
5628
|
+
callback: callback,
|
|
5629
|
+
});
|
|
5630
|
+
};
|
|
5631
|
+
/**
|
|
5632
|
+
* Unsubscribes from a Rive-generated event
|
|
5633
|
+
* @param type the type of event to unsubscribe from
|
|
5634
|
+
* @param callback the callback to unsubscribe
|
|
5635
|
+
*/
|
|
5636
|
+
RiveFile.prototype.off = function (type, callback) {
|
|
5637
|
+
this.eventManager.remove({
|
|
5638
|
+
type: type,
|
|
5639
|
+
callback: callback,
|
|
5640
|
+
});
|
|
5641
|
+
};
|
|
5642
|
+
RiveFile.prototype.cleanup = function () {
|
|
5643
|
+
var _a;
|
|
5644
|
+
this.referenceCount -= 1;
|
|
5645
|
+
if (this.referenceCount <= 0) {
|
|
5646
|
+
this.removeAllRiveEventListeners();
|
|
5647
|
+
(_a = this.file) === null || _a === void 0 ? void 0 : _a.delete();
|
|
5648
|
+
}
|
|
5649
|
+
};
|
|
5650
|
+
/**
|
|
5651
|
+
* Unsubscribes all Rive listeners from an event type, or everything if no type is
|
|
5652
|
+
* given
|
|
5653
|
+
* @param type the type of event to unsubscribe from, or all types if
|
|
5654
|
+
* undefined
|
|
5655
|
+
*/
|
|
5656
|
+
RiveFile.prototype.removeAllRiveEventListeners = function (type) {
|
|
5657
|
+
this.eventManager.removeAll(type);
|
|
5658
|
+
};
|
|
5659
|
+
RiveFile.prototype.getInstance = function () {
|
|
5660
|
+
if (this.file !== null) {
|
|
5661
|
+
this.referenceCount += 1;
|
|
5662
|
+
return this.file;
|
|
5663
|
+
}
|
|
5664
|
+
};
|
|
5665
|
+
// Error message for missing source or buffer
|
|
5666
|
+
RiveFile.missingErrorMessage = "Rive source file or data buffer required";
|
|
5667
|
+
// Error message for file load error
|
|
5668
|
+
RiveFile.fileLoadErrorMessage = "The file failed to load";
|
|
5669
|
+
return RiveFile;
|
|
5670
|
+
}());
|
|
5671
|
+
|
|
5535
5672
|
var Rive = /** @class */ (function () {
|
|
5536
5673
|
function Rive(params) {
|
|
5537
5674
|
var _this = this;
|
|
@@ -5580,6 +5717,7 @@ var Rive = /** @class */ (function () {
|
|
|
5580
5717
|
}
|
|
5581
5718
|
this.src = params.src;
|
|
5582
5719
|
this.buffer = params.buffer;
|
|
5720
|
+
this.riveFile = params.riveFile;
|
|
5583
5721
|
this.layout = (_a = params.layout) !== null && _a !== void 0 ? _a : new Layout();
|
|
5584
5722
|
this.shouldDisableRiveListeners = !!params.shouldDisableRiveListeners;
|
|
5585
5723
|
this.isTouchScrollEnabled = !!params.isTouchScrollEnabled;
|
|
@@ -5633,6 +5771,7 @@ var Rive = /** @class */ (function () {
|
|
|
5633
5771
|
this.init({
|
|
5634
5772
|
src: this.src,
|
|
5635
5773
|
buffer: this.buffer,
|
|
5774
|
+
riveFile: this.riveFile,
|
|
5636
5775
|
autoplay: params.autoplay,
|
|
5637
5776
|
animations: params.animations,
|
|
5638
5777
|
stateMachines: params.stateMachines,
|
|
@@ -5652,11 +5791,12 @@ var Rive = /** @class */ (function () {
|
|
|
5652
5791
|
// Initializes the Rive object either from constructor or load()
|
|
5653
5792
|
Rive.prototype.init = function (_a) {
|
|
5654
5793
|
var _this = this;
|
|
5655
|
-
var src = _a.src, buffer = _a.buffer, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c;
|
|
5794
|
+
var src = _a.src, buffer = _a.buffer, riveFile = _a.riveFile, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c;
|
|
5656
5795
|
this.src = src;
|
|
5657
5796
|
this.buffer = buffer;
|
|
5797
|
+
this.riveFile = riveFile;
|
|
5658
5798
|
// If no source file url specified, it's a bust
|
|
5659
|
-
if (!this.src && !this.buffer) {
|
|
5799
|
+
if (!this.src && !this.buffer && !this.riveFile) {
|
|
5660
5800
|
throw new Error(Rive.missingErrorMessage);
|
|
5661
5801
|
}
|
|
5662
5802
|
// List of animations that should be initialized.
|
|
@@ -5747,59 +5887,56 @@ var Rive = /** @class */ (function () {
|
|
|
5747
5887
|
Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay) {
|
|
5748
5888
|
var _a;
|
|
5749
5889
|
return __awaiter(this, void 0, void 0, function () {
|
|
5750
|
-
var
|
|
5751
|
-
return __generator(this, function (
|
|
5752
|
-
switch (
|
|
5890
|
+
var error_1, msg;
|
|
5891
|
+
return __generator(this, function (_b) {
|
|
5892
|
+
switch (_b.label) {
|
|
5753
5893
|
case 0:
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5894
|
+
_b.trys.push([0, 3, , 4]);
|
|
5895
|
+
if (!(this.riveFile == null)) return [3 /*break*/, 2];
|
|
5896
|
+
this.riveFile = new RiveFile({
|
|
5897
|
+
src: this.src,
|
|
5898
|
+
buffer: this.buffer,
|
|
5899
|
+
enableRiveAssetCDN: this.enableRiveAssetCDN,
|
|
5900
|
+
assetLoader: this.assetLoader,
|
|
5901
|
+
});
|
|
5902
|
+
return [4 /*yield*/, this.riveFile.init()];
|
|
5757
5903
|
case 1:
|
|
5758
|
-
_b.
|
|
5759
|
-
|
|
5904
|
+
_b.sent();
|
|
5905
|
+
_b.label = 2;
|
|
5760
5906
|
case 2:
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
//
|
|
5767
|
-
|
|
5768
|
-
|
|
5907
|
+
this.file = this.riveFile.getInstance();
|
|
5908
|
+
// Initialize and draw frame
|
|
5909
|
+
this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay);
|
|
5910
|
+
// Check for audio
|
|
5911
|
+
this.initializeAudio();
|
|
5912
|
+
// Everything's set up, emit a load event
|
|
5913
|
+
this.loaded = true;
|
|
5914
|
+
this.eventManager.fire({
|
|
5915
|
+
type: EventType.Load,
|
|
5916
|
+
data: (_a = this.src) !== null && _a !== void 0 ? _a : "buffer",
|
|
5917
|
+
});
|
|
5918
|
+
// Flag ready for playback commands and clear the task queue; this order
|
|
5919
|
+
// is important or it may infinitely recurse
|
|
5920
|
+
this.readyForPlaying = true;
|
|
5921
|
+
this.taskQueue.process();
|
|
5922
|
+
this.drawFrame();
|
|
5923
|
+
return [2 /*return*/, Promise.resolve()];
|
|
5769
5924
|
case 3:
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
this.initializeAudio();
|
|
5777
|
-
// Everything's set up, emit a load event
|
|
5778
|
-
this.loaded = true;
|
|
5779
|
-
this.eventManager.fire({
|
|
5780
|
-
type: EventType.Load,
|
|
5781
|
-
data: (_a = this.src) !== null && _a !== void 0 ? _a : "buffer",
|
|
5782
|
-
});
|
|
5783
|
-
// Flag ready for playback commands and clear the task queue; this order
|
|
5784
|
-
// is important or it may infinitely recurse
|
|
5785
|
-
this.readyForPlaying = true;
|
|
5786
|
-
this.taskQueue.process();
|
|
5787
|
-
this.drawFrame();
|
|
5788
|
-
return [2 /*return*/, Promise.resolve()];
|
|
5789
|
-
}
|
|
5790
|
-
else {
|
|
5791
|
-
msg = "Problem loading file; may be corrupt!";
|
|
5792
|
-
console.warn(msg);
|
|
5793
|
-
this.eventManager.fire({ type: EventType.LoadError, data: msg });
|
|
5794
|
-
return [2 /*return*/, Promise.reject(msg)];
|
|
5795
|
-
}
|
|
5796
|
-
return [2 /*return*/];
|
|
5925
|
+
error_1 = _b.sent();
|
|
5926
|
+
msg = "Problem loading file; may be corrupt!";
|
|
5927
|
+
console.warn(msg);
|
|
5928
|
+
this.eventManager.fire({ type: EventType.LoadError, data: msg });
|
|
5929
|
+
return [2 /*return*/, Promise.reject(msg)];
|
|
5930
|
+
case 4: return [2 /*return*/];
|
|
5797
5931
|
}
|
|
5798
5932
|
});
|
|
5799
5933
|
});
|
|
5800
5934
|
};
|
|
5801
5935
|
// Initialize for playback
|
|
5802
5936
|
Rive.prototype.initArtboard = function (artboardName, animationNames, stateMachineNames, autoplay) {
|
|
5937
|
+
if (!this.file) {
|
|
5938
|
+
return;
|
|
5939
|
+
}
|
|
5803
5940
|
// Fetch the artboard
|
|
5804
5941
|
var rootArtboard = artboardName
|
|
5805
5942
|
? this.file.artboardByName(artboardName)
|
|
@@ -6019,8 +6156,8 @@ var Rive = /** @class */ (function () {
|
|
|
6019
6156
|
if (this._observed !== null) {
|
|
6020
6157
|
observers.remove(this._observed);
|
|
6021
6158
|
}
|
|
6022
|
-
|
|
6023
|
-
|
|
6159
|
+
(_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.cleanup();
|
|
6160
|
+
this.riveFile = null;
|
|
6024
6161
|
this.file = null;
|
|
6025
6162
|
};
|
|
6026
6163
|
/**
|
|
@@ -6184,6 +6321,7 @@ var Rive = /** @class */ (function () {
|
|
|
6184
6321
|
};
|
|
6185
6322
|
// Loads a new Rive file, keeping listeners in place
|
|
6186
6323
|
Rive.prototype.load = function (params) {
|
|
6324
|
+
this.file = null;
|
|
6187
6325
|
// Stop all animations
|
|
6188
6326
|
this.stop();
|
|
6189
6327
|
// Reinitialize
|
|
@@ -6262,7 +6400,7 @@ var Rive = /** @class */ (function () {
|
|
|
6262
6400
|
// Returns a list of animation names on the chosen artboard
|
|
6263
6401
|
get: function () {
|
|
6264
6402
|
// If the file's not loaded, we got nothing to return
|
|
6265
|
-
if (!this.loaded) {
|
|
6403
|
+
if (!this.loaded || !this.artboard) {
|
|
6266
6404
|
return [];
|
|
6267
6405
|
}
|
|
6268
6406
|
var animationNames = [];
|
|
@@ -6280,7 +6418,7 @@ var Rive = /** @class */ (function () {
|
|
|
6280
6418
|
*/
|
|
6281
6419
|
get: function () {
|
|
6282
6420
|
// If the file's not loaded, we got nothing to return
|
|
6283
|
-
if (!this.loaded) {
|
|
6421
|
+
if (!this.loaded || !this.artboard) {
|
|
6284
6422
|
return [];
|
|
6285
6423
|
}
|
|
6286
6424
|
var stateMachineNames = [];
|