@rive-app/canvas-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
|
@@ -3358,7 +3358,7 @@ Xd();
|
|
|
3358
3358
|
/* 2 */
|
|
3359
3359
|
/***/ ((module) => {
|
|
3360
3360
|
|
|
3361
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-single","version":"2.
|
|
3361
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-single","version":"2.28.0","description":"Rive\'s high-level canvas based web api all in one js file.","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}}');
|
|
3362
3362
|
|
|
3363
3363
|
/***/ }),
|
|
3364
3364
|
/* 3 */
|
|
@@ -3964,8 +3964,8 @@ var FileAssetWrapper = /** @class */ (function () {
|
|
|
3964
3964
|
*/
|
|
3965
3965
|
var ImageAssetWrapper = /** @class */ (function (_super) {
|
|
3966
3966
|
__extends(ImageAssetWrapper, _super);
|
|
3967
|
-
function ImageAssetWrapper(
|
|
3968
|
-
return _super.
|
|
3967
|
+
function ImageAssetWrapper() {
|
|
3968
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3969
3969
|
}
|
|
3970
3970
|
ImageAssetWrapper.prototype.setRenderImage = function (image) {
|
|
3971
3971
|
this._nativeFileAsset.setRenderImage(image.nativeImage);
|
|
@@ -3978,8 +3978,8 @@ var ImageAssetWrapper = /** @class */ (function (_super) {
|
|
|
3978
3978
|
*/
|
|
3979
3979
|
var AudioAssetWrapper = /** @class */ (function (_super) {
|
|
3980
3980
|
__extends(AudioAssetWrapper, _super);
|
|
3981
|
-
function AudioAssetWrapper(
|
|
3982
|
-
return _super.
|
|
3981
|
+
function AudioAssetWrapper() {
|
|
3982
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3983
3983
|
}
|
|
3984
3984
|
AudioAssetWrapper.prototype.setAudioSource = function (audio) {
|
|
3985
3985
|
this._nativeFileAsset.setAudioSource(audio.nativeAudio);
|
|
@@ -5355,11 +5355,7 @@ var RiveFile = /** @class */ (function () {
|
|
|
5355
5355
|
});
|
|
5356
5356
|
}
|
|
5357
5357
|
else {
|
|
5358
|
-
this.
|
|
5359
|
-
type: EventType.LoadError,
|
|
5360
|
-
data: null,
|
|
5361
|
-
});
|
|
5362
|
-
throw new Error(RiveFile.fileLoadErrorMessage);
|
|
5358
|
+
this.fireLoadError(RiveFile.fileLoadErrorMessage);
|
|
5363
5359
|
}
|
|
5364
5360
|
return [2 /*return*/];
|
|
5365
5361
|
}
|
|
@@ -5368,29 +5364,45 @@ var RiveFile = /** @class */ (function () {
|
|
|
5368
5364
|
};
|
|
5369
5365
|
RiveFile.prototype.init = function () {
|
|
5370
5366
|
return __awaiter(this, void 0, void 0, function () {
|
|
5371
|
-
var _a;
|
|
5367
|
+
var _a, error_1;
|
|
5372
5368
|
return __generator(this, function (_b) {
|
|
5373
5369
|
switch (_b.label) {
|
|
5374
5370
|
case 0:
|
|
5375
5371
|
// If no source file url specified, it's a bust
|
|
5376
5372
|
if (!this.src && !this.buffer) {
|
|
5377
|
-
|
|
5373
|
+
this.fireLoadError(RiveFile.missingErrorMessage);
|
|
5374
|
+
return [2 /*return*/];
|
|
5378
5375
|
}
|
|
5376
|
+
_b.label = 1;
|
|
5377
|
+
case 1:
|
|
5378
|
+
_b.trys.push([1, 4, , 5]);
|
|
5379
5379
|
_a = this;
|
|
5380
5380
|
return [4 /*yield*/, RuntimeLoader.awaitInstance()];
|
|
5381
|
-
case
|
|
5381
|
+
case 2:
|
|
5382
5382
|
_a.runtime = _b.sent();
|
|
5383
5383
|
if (this.destroyed) {
|
|
5384
5384
|
return [2 /*return*/];
|
|
5385
5385
|
}
|
|
5386
5386
|
return [4 /*yield*/, this.initData()];
|
|
5387
|
-
case
|
|
5387
|
+
case 3:
|
|
5388
5388
|
_b.sent();
|
|
5389
|
-
return [
|
|
5389
|
+
return [3 /*break*/, 5];
|
|
5390
|
+
case 4:
|
|
5391
|
+
error_1 = _b.sent();
|
|
5392
|
+
this.fireLoadError(error_1 instanceof Error ? error_1.message : RiveFile.fileLoadErrorMessage);
|
|
5393
|
+
return [3 /*break*/, 5];
|
|
5394
|
+
case 5: return [2 /*return*/];
|
|
5390
5395
|
}
|
|
5391
5396
|
});
|
|
5392
5397
|
});
|
|
5393
5398
|
};
|
|
5399
|
+
RiveFile.prototype.fireLoadError = function (message) {
|
|
5400
|
+
this.eventManager.fire({
|
|
5401
|
+
type: EventType.LoadError,
|
|
5402
|
+
data: message,
|
|
5403
|
+
});
|
|
5404
|
+
throw new Error(message);
|
|
5405
|
+
};
|
|
5394
5406
|
/**
|
|
5395
5407
|
* Subscribe to Rive-generated events
|
|
5396
5408
|
* @param type the type of event to subscribe to
|
|
@@ -5717,11 +5729,11 @@ var Rive = /** @class */ (function () {
|
|
|
5717
5729
|
this._artboardHeight = this.artboard.height =
|
|
5718
5730
|
this._artboardHeight || this.artboard.height;
|
|
5719
5731
|
};
|
|
5720
|
-
// Initializes runtime with Rive data and preps for playing.
|
|
5732
|
+
// Initializes runtime with Rive data and preps for playing.
|
|
5721
5733
|
// Returns true for successful initialization.
|
|
5722
5734
|
Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
|
|
5723
5735
|
return __awaiter(this, void 0, void 0, function () {
|
|
5724
|
-
var
|
|
5736
|
+
var error_2, msg;
|
|
5725
5737
|
var _a;
|
|
5726
5738
|
return __generator(this, function (_b) {
|
|
5727
5739
|
switch (_b.label) {
|
|
@@ -5763,8 +5775,8 @@ var Rive = /** @class */ (function () {
|
|
|
5763
5775
|
this.drawFrame();
|
|
5764
5776
|
return [2 /*return*/, true];
|
|
5765
5777
|
case 3:
|
|
5766
|
-
|
|
5767
|
-
msg = resolveErrorMessage(
|
|
5778
|
+
error_2 = _b.sent();
|
|
5779
|
+
msg = resolveErrorMessage(error_2);
|
|
5768
5780
|
console.warn(msg);
|
|
5769
5781
|
this.eventManager.fire({ type: EventType.LoadError, data: msg });
|
|
5770
5782
|
return [2 /*return*/, Promise.reject(msg)];
|
|
@@ -7610,8 +7622,7 @@ var ViewModelInstanceAssetImage = /** @class */ (function (_super) {
|
|
|
7610
7622
|
}
|
|
7611
7623
|
Object.defineProperty(ViewModelInstanceAssetImage.prototype, "value", {
|
|
7612
7624
|
set: function (image) {
|
|
7613
|
-
this._viewModelInstanceValue.value
|
|
7614
|
-
image.nativeImage;
|
|
7625
|
+
this._viewModelInstanceValue.value(image.nativeImage);
|
|
7615
7626
|
},
|
|
7616
7627
|
enumerable: false,
|
|
7617
7628
|
configurable: true
|