@rive-app/webgl2 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
|
@@ -3562,7 +3562,7 @@ ae();
|
|
|
3562
3562
|
/* 2 */
|
|
3563
3563
|
/***/ ((module) => {
|
|
3564
3564
|
|
|
3565
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.
|
|
3565
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.28.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}}');
|
|
3566
3566
|
|
|
3567
3567
|
/***/ }),
|
|
3568
3568
|
/* 3 */
|
|
@@ -4168,8 +4168,8 @@ var FileAssetWrapper = /** @class */ (function () {
|
|
|
4168
4168
|
*/
|
|
4169
4169
|
var ImageAssetWrapper = /** @class */ (function (_super) {
|
|
4170
4170
|
__extends(ImageAssetWrapper, _super);
|
|
4171
|
-
function ImageAssetWrapper(
|
|
4172
|
-
return _super.
|
|
4171
|
+
function ImageAssetWrapper() {
|
|
4172
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4173
4173
|
}
|
|
4174
4174
|
ImageAssetWrapper.prototype.setRenderImage = function (image) {
|
|
4175
4175
|
this._nativeFileAsset.setRenderImage(image.nativeImage);
|
|
@@ -4182,8 +4182,8 @@ var ImageAssetWrapper = /** @class */ (function (_super) {
|
|
|
4182
4182
|
*/
|
|
4183
4183
|
var AudioAssetWrapper = /** @class */ (function (_super) {
|
|
4184
4184
|
__extends(AudioAssetWrapper, _super);
|
|
4185
|
-
function AudioAssetWrapper(
|
|
4186
|
-
return _super.
|
|
4185
|
+
function AudioAssetWrapper() {
|
|
4186
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4187
4187
|
}
|
|
4188
4188
|
AudioAssetWrapper.prototype.setAudioSource = function (audio) {
|
|
4189
4189
|
this._nativeFileAsset.setAudioSource(audio.nativeAudio);
|
|
@@ -5559,11 +5559,7 @@ var RiveFile = /** @class */ (function () {
|
|
|
5559
5559
|
});
|
|
5560
5560
|
}
|
|
5561
5561
|
else {
|
|
5562
|
-
this.
|
|
5563
|
-
type: EventType.LoadError,
|
|
5564
|
-
data: null,
|
|
5565
|
-
});
|
|
5566
|
-
throw new Error(RiveFile.fileLoadErrorMessage);
|
|
5562
|
+
this.fireLoadError(RiveFile.fileLoadErrorMessage);
|
|
5567
5563
|
}
|
|
5568
5564
|
return [2 /*return*/];
|
|
5569
5565
|
}
|
|
@@ -5572,29 +5568,45 @@ var RiveFile = /** @class */ (function () {
|
|
|
5572
5568
|
};
|
|
5573
5569
|
RiveFile.prototype.init = function () {
|
|
5574
5570
|
return __awaiter(this, void 0, void 0, function () {
|
|
5575
|
-
var _a;
|
|
5571
|
+
var _a, error_1;
|
|
5576
5572
|
return __generator(this, function (_b) {
|
|
5577
5573
|
switch (_b.label) {
|
|
5578
5574
|
case 0:
|
|
5579
5575
|
// If no source file url specified, it's a bust
|
|
5580
5576
|
if (!this.src && !this.buffer) {
|
|
5581
|
-
|
|
5577
|
+
this.fireLoadError(RiveFile.missingErrorMessage);
|
|
5578
|
+
return [2 /*return*/];
|
|
5582
5579
|
}
|
|
5580
|
+
_b.label = 1;
|
|
5581
|
+
case 1:
|
|
5582
|
+
_b.trys.push([1, 4, , 5]);
|
|
5583
5583
|
_a = this;
|
|
5584
5584
|
return [4 /*yield*/, RuntimeLoader.awaitInstance()];
|
|
5585
|
-
case
|
|
5585
|
+
case 2:
|
|
5586
5586
|
_a.runtime = _b.sent();
|
|
5587
5587
|
if (this.destroyed) {
|
|
5588
5588
|
return [2 /*return*/];
|
|
5589
5589
|
}
|
|
5590
5590
|
return [4 /*yield*/, this.initData()];
|
|
5591
|
-
case
|
|
5591
|
+
case 3:
|
|
5592
5592
|
_b.sent();
|
|
5593
|
-
return [
|
|
5593
|
+
return [3 /*break*/, 5];
|
|
5594
|
+
case 4:
|
|
5595
|
+
error_1 = _b.sent();
|
|
5596
|
+
this.fireLoadError(error_1 instanceof Error ? error_1.message : RiveFile.fileLoadErrorMessage);
|
|
5597
|
+
return [3 /*break*/, 5];
|
|
5598
|
+
case 5: return [2 /*return*/];
|
|
5594
5599
|
}
|
|
5595
5600
|
});
|
|
5596
5601
|
});
|
|
5597
5602
|
};
|
|
5603
|
+
RiveFile.prototype.fireLoadError = function (message) {
|
|
5604
|
+
this.eventManager.fire({
|
|
5605
|
+
type: EventType.LoadError,
|
|
5606
|
+
data: message,
|
|
5607
|
+
});
|
|
5608
|
+
throw new Error(message);
|
|
5609
|
+
};
|
|
5598
5610
|
/**
|
|
5599
5611
|
* Subscribe to Rive-generated events
|
|
5600
5612
|
* @param type the type of event to subscribe to
|
|
@@ -5921,11 +5933,11 @@ var Rive = /** @class */ (function () {
|
|
|
5921
5933
|
this._artboardHeight = this.artboard.height =
|
|
5922
5934
|
this._artboardHeight || this.artboard.height;
|
|
5923
5935
|
};
|
|
5924
|
-
// Initializes runtime with Rive data and preps for playing.
|
|
5936
|
+
// Initializes runtime with Rive data and preps for playing.
|
|
5925
5937
|
// Returns true for successful initialization.
|
|
5926
5938
|
Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
|
|
5927
5939
|
return __awaiter(this, void 0, void 0, function () {
|
|
5928
|
-
var
|
|
5940
|
+
var error_2, msg;
|
|
5929
5941
|
var _a;
|
|
5930
5942
|
return __generator(this, function (_b) {
|
|
5931
5943
|
switch (_b.label) {
|
|
@@ -5967,8 +5979,8 @@ var Rive = /** @class */ (function () {
|
|
|
5967
5979
|
this.drawFrame();
|
|
5968
5980
|
return [2 /*return*/, true];
|
|
5969
5981
|
case 3:
|
|
5970
|
-
|
|
5971
|
-
msg = resolveErrorMessage(
|
|
5982
|
+
error_2 = _b.sent();
|
|
5983
|
+
msg = resolveErrorMessage(error_2);
|
|
5972
5984
|
console.warn(msg);
|
|
5973
5985
|
this.eventManager.fire({ type: EventType.LoadError, data: msg });
|
|
5974
5986
|
return [2 /*return*/, Promise.reject(msg)];
|
|
@@ -7814,8 +7826,7 @@ var ViewModelInstanceAssetImage = /** @class */ (function (_super) {
|
|
|
7814
7826
|
}
|
|
7815
7827
|
Object.defineProperty(ViewModelInstanceAssetImage.prototype, "value", {
|
|
7816
7828
|
set: function (image) {
|
|
7817
|
-
this._viewModelInstanceValue.value
|
|
7818
|
-
image.nativeImage;
|
|
7829
|
+
this._viewModelInstanceValue.value(image.nativeImage);
|
|
7819
7830
|
},
|
|
7820
7831
|
enumerable: false,
|
|
7821
7832
|
configurable: true
|