@rive-app/webgl-single 2.27.4 → 2.28.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 +7 -6
- package/rive.js +32 -21
- package/rive.js.map +1 -1
- package/rive_advanced.mjs.d.ts +41 -1
package/package.json
CHANGED
package/rive.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as rc from "./rive_advanced.mjs";
|
|
2
|
-
|
|
3
|
-
export type {
|
|
2
|
+
export type AssetLoadCallback = (asset: rc.FileAsset, bytes: Uint8Array) => Boolean;
|
|
3
|
+
export type { FileAsset, AudioAsset, FontAsset, ImageAsset, } from "./rive_advanced.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* Generic type for a parameterless void callback
|
|
6
6
|
*/
|
|
@@ -245,7 +245,7 @@ export interface RiveParameters {
|
|
|
245
245
|
onLoop?: EventCallback;
|
|
246
246
|
onStateChange?: EventCallback;
|
|
247
247
|
onAdvance?: EventCallback;
|
|
248
|
-
assetLoader?:
|
|
248
|
+
assetLoader?: AssetLoadCallback;
|
|
249
249
|
/**
|
|
250
250
|
* @deprecated Use `onLoad()` instead
|
|
251
251
|
*/
|
|
@@ -297,7 +297,7 @@ export interface RiveResetParameters {
|
|
|
297
297
|
export interface RiveFileParameters {
|
|
298
298
|
src?: string;
|
|
299
299
|
buffer?: ArrayBuffer;
|
|
300
|
-
assetLoader?:
|
|
300
|
+
assetLoader?: AssetLoadCallback;
|
|
301
301
|
enableRiveAssetCDN?: boolean;
|
|
302
302
|
onLoad?: EventCallback;
|
|
303
303
|
onLoadError?: EventCallback;
|
|
@@ -317,6 +317,7 @@ export declare class RiveFile {
|
|
|
317
317
|
constructor(params: RiveFileParameters);
|
|
318
318
|
private initData;
|
|
319
319
|
init(): Promise<void>;
|
|
320
|
+
private fireLoadError;
|
|
320
321
|
/**
|
|
321
322
|
* Subscribe to Rive-generated events
|
|
322
323
|
* @param type the type of event to subscribe to
|
|
@@ -897,7 +898,7 @@ export declare class ViewModelInstanceColor extends ViewModelInstanceValue {
|
|
|
897
898
|
}
|
|
898
899
|
export declare class ViewModelInstanceAssetImage extends ViewModelInstanceValue {
|
|
899
900
|
constructor(instance: rc.ViewModelInstanceAssetImage, root: ViewModelInstance);
|
|
900
|
-
set value(image:
|
|
901
|
+
set value(image: rc.Image);
|
|
901
902
|
internalHandleCallback(callback: Function): void;
|
|
902
903
|
}
|
|
903
904
|
/**
|
|
@@ -946,7 +947,7 @@ export declare const decodeAudio: (bytes: Uint8Array) => Promise<rc.Audio>;
|
|
|
946
947
|
* Be sure to call `.unref()` on the image once it is no longer needed. This
|
|
947
948
|
* allows the engine to clean it up when it is not used by any more animations.
|
|
948
949
|
*/
|
|
949
|
-
export declare const decodeImage: (bytes: Uint8Array) => Promise<
|
|
950
|
+
export declare const decodeImage: (bytes: Uint8Array) => Promise<rc.Image>;
|
|
950
951
|
/**
|
|
951
952
|
* Decodes bytes into a font.
|
|
952
953
|
*
|
package/rive.js
CHANGED
|
@@ -4054,7 +4054,7 @@ Ge();
|
|
|
4054
4054
|
/* 2 */
|
|
4055
4055
|
/***/ ((module) => {
|
|
4056
4056
|
|
|
4057
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl-single","version":"2.
|
|
4057
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl-single","version":"2.28.0","description":"Rive\'s webgl based web api with bundled wasm.","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.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
4058
4058
|
|
|
4059
4059
|
/***/ }),
|
|
4060
4060
|
/* 3 */
|
|
@@ -4660,8 +4660,8 @@ var FileAssetWrapper = /** @class */ (function () {
|
|
|
4660
4660
|
*/
|
|
4661
4661
|
var ImageAssetWrapper = /** @class */ (function (_super) {
|
|
4662
4662
|
__extends(ImageAssetWrapper, _super);
|
|
4663
|
-
function ImageAssetWrapper(
|
|
4664
|
-
return _super.
|
|
4663
|
+
function ImageAssetWrapper() {
|
|
4664
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4665
4665
|
}
|
|
4666
4666
|
ImageAssetWrapper.prototype.setRenderImage = function (image) {
|
|
4667
4667
|
this._nativeFileAsset.setRenderImage(image.nativeImage);
|
|
@@ -4674,8 +4674,8 @@ var ImageAssetWrapper = /** @class */ (function (_super) {
|
|
|
4674
4674
|
*/
|
|
4675
4675
|
var AudioAssetWrapper = /** @class */ (function (_super) {
|
|
4676
4676
|
__extends(AudioAssetWrapper, _super);
|
|
4677
|
-
function AudioAssetWrapper(
|
|
4678
|
-
return _super.
|
|
4677
|
+
function AudioAssetWrapper() {
|
|
4678
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4679
4679
|
}
|
|
4680
4680
|
AudioAssetWrapper.prototype.setAudioSource = function (audio) {
|
|
4681
4681
|
this._nativeFileAsset.setAudioSource(audio.nativeAudio);
|
|
@@ -6051,11 +6051,7 @@ var RiveFile = /** @class */ (function () {
|
|
|
6051
6051
|
});
|
|
6052
6052
|
}
|
|
6053
6053
|
else {
|
|
6054
|
-
this.
|
|
6055
|
-
type: EventType.LoadError,
|
|
6056
|
-
data: null,
|
|
6057
|
-
});
|
|
6058
|
-
throw new Error(RiveFile.fileLoadErrorMessage);
|
|
6054
|
+
this.fireLoadError(RiveFile.fileLoadErrorMessage);
|
|
6059
6055
|
}
|
|
6060
6056
|
return [2 /*return*/];
|
|
6061
6057
|
}
|
|
@@ -6064,29 +6060,45 @@ var RiveFile = /** @class */ (function () {
|
|
|
6064
6060
|
};
|
|
6065
6061
|
RiveFile.prototype.init = function () {
|
|
6066
6062
|
return __awaiter(this, void 0, void 0, function () {
|
|
6067
|
-
var _a;
|
|
6063
|
+
var _a, error_1;
|
|
6068
6064
|
return __generator(this, function (_b) {
|
|
6069
6065
|
switch (_b.label) {
|
|
6070
6066
|
case 0:
|
|
6071
6067
|
// If no source file url specified, it's a bust
|
|
6072
6068
|
if (!this.src && !this.buffer) {
|
|
6073
|
-
|
|
6069
|
+
this.fireLoadError(RiveFile.missingErrorMessage);
|
|
6070
|
+
return [2 /*return*/];
|
|
6074
6071
|
}
|
|
6072
|
+
_b.label = 1;
|
|
6073
|
+
case 1:
|
|
6074
|
+
_b.trys.push([1, 4, , 5]);
|
|
6075
6075
|
_a = this;
|
|
6076
6076
|
return [4 /*yield*/, RuntimeLoader.awaitInstance()];
|
|
6077
|
-
case
|
|
6077
|
+
case 2:
|
|
6078
6078
|
_a.runtime = _b.sent();
|
|
6079
6079
|
if (this.destroyed) {
|
|
6080
6080
|
return [2 /*return*/];
|
|
6081
6081
|
}
|
|
6082
6082
|
return [4 /*yield*/, this.initData()];
|
|
6083
|
-
case
|
|
6083
|
+
case 3:
|
|
6084
6084
|
_b.sent();
|
|
6085
|
-
return [
|
|
6085
|
+
return [3 /*break*/, 5];
|
|
6086
|
+
case 4:
|
|
6087
|
+
error_1 = _b.sent();
|
|
6088
|
+
this.fireLoadError(error_1 instanceof Error ? error_1.message : RiveFile.fileLoadErrorMessage);
|
|
6089
|
+
return [3 /*break*/, 5];
|
|
6090
|
+
case 5: return [2 /*return*/];
|
|
6086
6091
|
}
|
|
6087
6092
|
});
|
|
6088
6093
|
});
|
|
6089
6094
|
};
|
|
6095
|
+
RiveFile.prototype.fireLoadError = function (message) {
|
|
6096
|
+
this.eventManager.fire({
|
|
6097
|
+
type: EventType.LoadError,
|
|
6098
|
+
data: message,
|
|
6099
|
+
});
|
|
6100
|
+
throw new Error(message);
|
|
6101
|
+
};
|
|
6090
6102
|
/**
|
|
6091
6103
|
* Subscribe to Rive-generated events
|
|
6092
6104
|
* @param type the type of event to subscribe to
|
|
@@ -6413,11 +6425,11 @@ var Rive = /** @class */ (function () {
|
|
|
6413
6425
|
this._artboardHeight = this.artboard.height =
|
|
6414
6426
|
this._artboardHeight || this.artboard.height;
|
|
6415
6427
|
};
|
|
6416
|
-
// Initializes runtime with Rive data and preps for playing.
|
|
6428
|
+
// Initializes runtime with Rive data and preps for playing.
|
|
6417
6429
|
// Returns true for successful initialization.
|
|
6418
6430
|
Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
|
|
6419
6431
|
return __awaiter(this, void 0, void 0, function () {
|
|
6420
|
-
var
|
|
6432
|
+
var error_2, msg;
|
|
6421
6433
|
var _a;
|
|
6422
6434
|
return __generator(this, function (_b) {
|
|
6423
6435
|
switch (_b.label) {
|
|
@@ -6459,8 +6471,8 @@ var Rive = /** @class */ (function () {
|
|
|
6459
6471
|
this.drawFrame();
|
|
6460
6472
|
return [2 /*return*/, true];
|
|
6461
6473
|
case 3:
|
|
6462
|
-
|
|
6463
|
-
msg = resolveErrorMessage(
|
|
6474
|
+
error_2 = _b.sent();
|
|
6475
|
+
msg = resolveErrorMessage(error_2);
|
|
6464
6476
|
console.warn(msg);
|
|
6465
6477
|
this.eventManager.fire({ type: EventType.LoadError, data: msg });
|
|
6466
6478
|
return [2 /*return*/, Promise.reject(msg)];
|
|
@@ -8306,8 +8318,7 @@ var ViewModelInstanceAssetImage = /** @class */ (function (_super) {
|
|
|
8306
8318
|
}
|
|
8307
8319
|
Object.defineProperty(ViewModelInstanceAssetImage.prototype, "value", {
|
|
8308
8320
|
set: function (image) {
|
|
8309
|
-
this._viewModelInstanceValue.value
|
|
8310
|
-
image.nativeImage;
|
|
8321
|
+
this._viewModelInstanceValue.value(image.nativeImage);
|
|
8311
8322
|
},
|
|
8312
8323
|
enumerable: false,
|
|
8313
8324
|
configurable: true
|