@rive-app/canvas 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
|
@@ -3369,7 +3369,7 @@ $d();
|
|
|
3369
3369
|
/* 2 */
|
|
3370
3370
|
/***/ ((module) => {
|
|
3371
3371
|
|
|
3372
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.
|
|
3372
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.28.0","description":"Rive\'s canvas 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.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
3373
3373
|
|
|
3374
3374
|
/***/ }),
|
|
3375
3375
|
/* 3 */
|
|
@@ -3975,8 +3975,8 @@ var FileAssetWrapper = /** @class */ (function () {
|
|
|
3975
3975
|
*/
|
|
3976
3976
|
var ImageAssetWrapper = /** @class */ (function (_super) {
|
|
3977
3977
|
__extends(ImageAssetWrapper, _super);
|
|
3978
|
-
function ImageAssetWrapper(
|
|
3979
|
-
return _super.
|
|
3978
|
+
function ImageAssetWrapper() {
|
|
3979
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3980
3980
|
}
|
|
3981
3981
|
ImageAssetWrapper.prototype.setRenderImage = function (image) {
|
|
3982
3982
|
this._nativeFileAsset.setRenderImage(image.nativeImage);
|
|
@@ -3989,8 +3989,8 @@ var ImageAssetWrapper = /** @class */ (function (_super) {
|
|
|
3989
3989
|
*/
|
|
3990
3990
|
var AudioAssetWrapper = /** @class */ (function (_super) {
|
|
3991
3991
|
__extends(AudioAssetWrapper, _super);
|
|
3992
|
-
function AudioAssetWrapper(
|
|
3993
|
-
return _super.
|
|
3992
|
+
function AudioAssetWrapper() {
|
|
3993
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3994
3994
|
}
|
|
3995
3995
|
AudioAssetWrapper.prototype.setAudioSource = function (audio) {
|
|
3996
3996
|
this._nativeFileAsset.setAudioSource(audio.nativeAudio);
|
|
@@ -5366,11 +5366,7 @@ var RiveFile = /** @class */ (function () {
|
|
|
5366
5366
|
});
|
|
5367
5367
|
}
|
|
5368
5368
|
else {
|
|
5369
|
-
this.
|
|
5370
|
-
type: EventType.LoadError,
|
|
5371
|
-
data: null,
|
|
5372
|
-
});
|
|
5373
|
-
throw new Error(RiveFile.fileLoadErrorMessage);
|
|
5369
|
+
this.fireLoadError(RiveFile.fileLoadErrorMessage);
|
|
5374
5370
|
}
|
|
5375
5371
|
return [2 /*return*/];
|
|
5376
5372
|
}
|
|
@@ -5379,29 +5375,45 @@ var RiveFile = /** @class */ (function () {
|
|
|
5379
5375
|
};
|
|
5380
5376
|
RiveFile.prototype.init = function () {
|
|
5381
5377
|
return __awaiter(this, void 0, void 0, function () {
|
|
5382
|
-
var _a;
|
|
5378
|
+
var _a, error_1;
|
|
5383
5379
|
return __generator(this, function (_b) {
|
|
5384
5380
|
switch (_b.label) {
|
|
5385
5381
|
case 0:
|
|
5386
5382
|
// If no source file url specified, it's a bust
|
|
5387
5383
|
if (!this.src && !this.buffer) {
|
|
5388
|
-
|
|
5384
|
+
this.fireLoadError(RiveFile.missingErrorMessage);
|
|
5385
|
+
return [2 /*return*/];
|
|
5389
5386
|
}
|
|
5387
|
+
_b.label = 1;
|
|
5388
|
+
case 1:
|
|
5389
|
+
_b.trys.push([1, 4, , 5]);
|
|
5390
5390
|
_a = this;
|
|
5391
5391
|
return [4 /*yield*/, RuntimeLoader.awaitInstance()];
|
|
5392
|
-
case
|
|
5392
|
+
case 2:
|
|
5393
5393
|
_a.runtime = _b.sent();
|
|
5394
5394
|
if (this.destroyed) {
|
|
5395
5395
|
return [2 /*return*/];
|
|
5396
5396
|
}
|
|
5397
5397
|
return [4 /*yield*/, this.initData()];
|
|
5398
|
-
case
|
|
5398
|
+
case 3:
|
|
5399
5399
|
_b.sent();
|
|
5400
|
-
return [
|
|
5400
|
+
return [3 /*break*/, 5];
|
|
5401
|
+
case 4:
|
|
5402
|
+
error_1 = _b.sent();
|
|
5403
|
+
this.fireLoadError(error_1 instanceof Error ? error_1.message : RiveFile.fileLoadErrorMessage);
|
|
5404
|
+
return [3 /*break*/, 5];
|
|
5405
|
+
case 5: return [2 /*return*/];
|
|
5401
5406
|
}
|
|
5402
5407
|
});
|
|
5403
5408
|
});
|
|
5404
5409
|
};
|
|
5410
|
+
RiveFile.prototype.fireLoadError = function (message) {
|
|
5411
|
+
this.eventManager.fire({
|
|
5412
|
+
type: EventType.LoadError,
|
|
5413
|
+
data: message,
|
|
5414
|
+
});
|
|
5415
|
+
throw new Error(message);
|
|
5416
|
+
};
|
|
5405
5417
|
/**
|
|
5406
5418
|
* Subscribe to Rive-generated events
|
|
5407
5419
|
* @param type the type of event to subscribe to
|
|
@@ -5728,11 +5740,11 @@ var Rive = /** @class */ (function () {
|
|
|
5728
5740
|
this._artboardHeight = this.artboard.height =
|
|
5729
5741
|
this._artboardHeight || this.artboard.height;
|
|
5730
5742
|
};
|
|
5731
|
-
// Initializes runtime with Rive data and preps for playing.
|
|
5743
|
+
// Initializes runtime with Rive data and preps for playing.
|
|
5732
5744
|
// Returns true for successful initialization.
|
|
5733
5745
|
Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
|
|
5734
5746
|
return __awaiter(this, void 0, void 0, function () {
|
|
5735
|
-
var
|
|
5747
|
+
var error_2, msg;
|
|
5736
5748
|
var _a;
|
|
5737
5749
|
return __generator(this, function (_b) {
|
|
5738
5750
|
switch (_b.label) {
|
|
@@ -5774,8 +5786,8 @@ var Rive = /** @class */ (function () {
|
|
|
5774
5786
|
this.drawFrame();
|
|
5775
5787
|
return [2 /*return*/, true];
|
|
5776
5788
|
case 3:
|
|
5777
|
-
|
|
5778
|
-
msg = resolveErrorMessage(
|
|
5789
|
+
error_2 = _b.sent();
|
|
5790
|
+
msg = resolveErrorMessage(error_2);
|
|
5779
5791
|
console.warn(msg);
|
|
5780
5792
|
this.eventManager.fire({ type: EventType.LoadError, data: msg });
|
|
5781
5793
|
return [2 /*return*/, Promise.reject(msg)];
|
|
@@ -7621,8 +7633,7 @@ var ViewModelInstanceAssetImage = /** @class */ (function (_super) {
|
|
|
7621
7633
|
}
|
|
7622
7634
|
Object.defineProperty(ViewModelInstanceAssetImage.prototype, "value", {
|
|
7623
7635
|
set: function (image) {
|
|
7624
|
-
this._viewModelInstanceValue.value
|
|
7625
|
-
image.nativeImage;
|
|
7636
|
+
this._viewModelInstanceValue.value(image.nativeImage);
|
|
7626
7637
|
},
|
|
7627
7638
|
enumerable: false,
|
|
7628
7639
|
configurable: true
|