@rive-app/canvas-lite 2.30.0 → 2.30.2
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 +18 -0
- package/rive.js +75 -15
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +4 -0
- package/rive_fallback.wasm +0 -0
package/package.json
CHANGED
package/rive.d.ts
CHANGED
|
@@ -112,6 +112,10 @@ export declare enum RiveEventType {
|
|
|
112
112
|
General = 128,
|
|
113
113
|
OpenUrl = 131
|
|
114
114
|
}
|
|
115
|
+
declare class Artboard {
|
|
116
|
+
nativeArtboard: rc.Artboard;
|
|
117
|
+
constructor(artboard: rc.Artboard);
|
|
118
|
+
}
|
|
115
119
|
/**
|
|
116
120
|
* Supported event types triggered in Rive
|
|
117
121
|
*/
|
|
@@ -339,6 +343,8 @@ export declare class RiveFile {
|
|
|
339
343
|
*/
|
|
340
344
|
removeAllRiveEventListeners(type?: EventType): void;
|
|
341
345
|
getInstance(): rc.File;
|
|
346
|
+
destroyIfUnused(): void;
|
|
347
|
+
getArtboard(name: string): Artboard | null;
|
|
342
348
|
}
|
|
343
349
|
export declare class Rive {
|
|
344
350
|
private readonly canvas;
|
|
@@ -724,6 +730,7 @@ export declare class Rive {
|
|
|
724
730
|
viewModelByName(name: string): ViewModel | null;
|
|
725
731
|
enums(): DataEnum[];
|
|
726
732
|
defaultViewModel(): ViewModel | null;
|
|
733
|
+
getArtboard(name: string): Artboard | null;
|
|
727
734
|
}
|
|
728
735
|
export declare class ViewModel {
|
|
729
736
|
private _viewModel;
|
|
@@ -812,6 +819,12 @@ export declare class ViewModelInstance {
|
|
|
812
819
|
* @param path - path to the image property
|
|
813
820
|
*/
|
|
814
821
|
image(path: string): ViewModelInstanceAssetImage | null;
|
|
822
|
+
/**
|
|
823
|
+
* method to access an artboard property instance belonging
|
|
824
|
+
* to the view model instance or to a nested view model instance
|
|
825
|
+
* @param path - path to the image property
|
|
826
|
+
*/
|
|
827
|
+
artboard(path: string): ViewModelInstanceArtboard | null;
|
|
815
828
|
/**
|
|
816
829
|
* method to access a view model property instance belonging
|
|
817
830
|
* to the view model instance or to a nested view model instance
|
|
@@ -903,6 +916,11 @@ export declare class ViewModelInstanceAssetImage extends ViewModelInstanceValue
|
|
|
903
916
|
set value(image: rc.Image | null);
|
|
904
917
|
internalHandleCallback(callback: Function): void;
|
|
905
918
|
}
|
|
919
|
+
export declare class ViewModelInstanceArtboard extends ViewModelInstanceValue {
|
|
920
|
+
constructor(instance: rc.ViewModelInstanceArtboard, root: ViewModelInstance);
|
|
921
|
+
set value(artboard: Artboard | null);
|
|
922
|
+
internalHandleCallback(callback: Function): void;
|
|
923
|
+
}
|
|
906
924
|
/**
|
|
907
925
|
* Contents of a state machine input
|
|
908
926
|
*/
|
package/rive.js
CHANGED
|
@@ -2272,7 +2272,7 @@ Qc();
|
|
|
2272
2272
|
/* 2 */
|
|
2273
2273
|
/***/ ((module) => {
|
|
2274
2274
|
|
|
2275
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.30.
|
|
2275
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.30.2","description":"A lite version of 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}}');
|
|
2276
2276
|
|
|
2277
2277
|
/***/ }),
|
|
2278
2278
|
/* 3 */
|
|
@@ -2914,18 +2914,18 @@ var FontAssetWrapper = /** @class */ (function (_super) {
|
|
|
2914
2914
|
};
|
|
2915
2915
|
return FontAssetWrapper;
|
|
2916
2916
|
}(FileAssetWrapper));
|
|
2917
|
-
var FakeFinalizationRegistry = /** @class */ (function (
|
|
2918
|
-
|
|
2919
|
-
function FakeFinalizationRegistry(fn) {
|
|
2920
|
-
return _super.call(this, fn) || this;
|
|
2917
|
+
var FakeFinalizationRegistry = /** @class */ (function () {
|
|
2918
|
+
function FakeFinalizationRegistry(_) {
|
|
2921
2919
|
}
|
|
2922
2920
|
FakeFinalizationRegistry.prototype.register = function (object) {
|
|
2923
2921
|
object.selfUnref = true;
|
|
2924
2922
|
};
|
|
2925
2923
|
FakeFinalizationRegistry.prototype.unregister = function (_) { };
|
|
2926
2924
|
return FakeFinalizationRegistry;
|
|
2927
|
-
}(
|
|
2928
|
-
var MyFinalizationRegistry = FinalizationRegistry
|
|
2925
|
+
}());
|
|
2926
|
+
var MyFinalizationRegistry = typeof FinalizationRegistry !== "undefined"
|
|
2927
|
+
? FinalizationRegistry
|
|
2928
|
+
: FakeFinalizationRegistry;
|
|
2929
2929
|
var finalizationRegistry = new MyFinalizationRegistry(function (ob) {
|
|
2930
2930
|
ob.unref();
|
|
2931
2931
|
});
|
|
@@ -3009,6 +3009,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3009
3009
|
/* harmony export */ Testing: () => (/* binding */ Testing),
|
|
3010
3010
|
/* harmony export */ ViewModel: () => (/* binding */ ViewModel),
|
|
3011
3011
|
/* harmony export */ ViewModelInstance: () => (/* binding */ ViewModelInstance),
|
|
3012
|
+
/* harmony export */ ViewModelInstanceArtboard: () => (/* binding */ ViewModelInstanceArtboard),
|
|
3012
3013
|
/* harmony export */ ViewModelInstanceAssetImage: () => (/* binding */ ViewModelInstanceAssetImage),
|
|
3013
3014
|
/* harmony export */ ViewModelInstanceBoolean: () => (/* binding */ ViewModelInstanceBoolean),
|
|
3014
3015
|
/* harmony export */ ViewModelInstanceColor: () => (/* binding */ ViewModelInstanceColor),
|
|
@@ -3391,6 +3392,12 @@ var RiveEventType;
|
|
|
3391
3392
|
RiveEventType[RiveEventType["General"] = 128] = "General";
|
|
3392
3393
|
RiveEventType[RiveEventType["OpenUrl"] = 131] = "OpenUrl";
|
|
3393
3394
|
})(RiveEventType || (RiveEventType = {}));
|
|
3395
|
+
var Artboard = /** @class */ (function () {
|
|
3396
|
+
function Artboard(artboard) {
|
|
3397
|
+
this.nativeArtboard = artboard;
|
|
3398
|
+
}
|
|
3399
|
+
return Artboard;
|
|
3400
|
+
}());
|
|
3394
3401
|
var StateMachine = /** @class */ (function () {
|
|
3395
3402
|
/**
|
|
3396
3403
|
* @constructor
|
|
@@ -4364,6 +4371,18 @@ var RiveFile = /** @class */ (function () {
|
|
|
4364
4371
|
return this.file;
|
|
4365
4372
|
}
|
|
4366
4373
|
};
|
|
4374
|
+
RiveFile.prototype.destroyIfUnused = function () {
|
|
4375
|
+
if (this.referenceCount <= 0) {
|
|
4376
|
+
this.cleanup();
|
|
4377
|
+
}
|
|
4378
|
+
};
|
|
4379
|
+
RiveFile.prototype.getArtboard = function (name) {
|
|
4380
|
+
var nativeArtboard = this.file.artboardByName(name);
|
|
4381
|
+
if (nativeArtboard != null) {
|
|
4382
|
+
return new Artboard(nativeArtboard);
|
|
4383
|
+
}
|
|
4384
|
+
return null;
|
|
4385
|
+
};
|
|
4367
4386
|
// Error message for missing source or buffer
|
|
4368
4387
|
RiveFile.missingErrorMessage = "Rive source file or data buffer required";
|
|
4369
4388
|
// Error message for file load error
|
|
@@ -4647,28 +4666,31 @@ var Rive = /** @class */ (function () {
|
|
|
4647
4666
|
// Returns true for successful initialization.
|
|
4648
4667
|
Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
|
|
4649
4668
|
return __awaiter(this, void 0, void 0, function () {
|
|
4650
|
-
var error_2, msg;
|
|
4669
|
+
var riveFile, error_2, msg;
|
|
4651
4670
|
var _a;
|
|
4652
4671
|
return __generator(this, function (_b) {
|
|
4653
4672
|
switch (_b.label) {
|
|
4654
4673
|
case 0:
|
|
4655
4674
|
_b.trys.push([0, 3, , 4]);
|
|
4656
4675
|
if (!(this.riveFile == null)) return [3 /*break*/, 2];
|
|
4657
|
-
|
|
4676
|
+
riveFile = new RiveFile({
|
|
4658
4677
|
src: this.src,
|
|
4659
4678
|
buffer: this.buffer,
|
|
4660
4679
|
enableRiveAssetCDN: this.enableRiveAssetCDN,
|
|
4661
4680
|
assetLoader: this.assetLoader,
|
|
4662
4681
|
});
|
|
4663
|
-
|
|
4682
|
+
this.riveFile = riveFile;
|
|
4683
|
+
return [4 /*yield*/, riveFile.init()];
|
|
4664
4684
|
case 1:
|
|
4665
4685
|
_b.sent();
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4686
|
+
if (this.destroyed) {
|
|
4687
|
+
// In the very unlikely scenario where the rive file created by this Rive is shared by
|
|
4688
|
+
// another rive file, we only want to destroy it if this file is the only owner.
|
|
4689
|
+
riveFile.destroyIfUnused();
|
|
4670
4690
|
return [2 /*return*/, false];
|
|
4671
4691
|
}
|
|
4692
|
+
_b.label = 2;
|
|
4693
|
+
case 2:
|
|
4672
4694
|
this.file = this.riveFile.getInstance();
|
|
4673
4695
|
// Initialize and draw frame
|
|
4674
4696
|
this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay, autoBind);
|
|
@@ -5805,6 +5827,10 @@ var Rive = /** @class */ (function () {
|
|
|
5805
5827
|
}
|
|
5806
5828
|
return null;
|
|
5807
5829
|
};
|
|
5830
|
+
Rive.prototype.getArtboard = function (name) {
|
|
5831
|
+
var _a, _b;
|
|
5832
|
+
return (_b = (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.getArtboard(name)) !== null && _b !== void 0 ? _b : null;
|
|
5833
|
+
};
|
|
5808
5834
|
// Error message for missing source or buffer
|
|
5809
5835
|
Rive.missingErrorMessage = "Rive source file or data buffer required";
|
|
5810
5836
|
// Error message for removed rive file
|
|
@@ -5906,6 +5932,7 @@ var PropertyType;
|
|
|
5906
5932
|
PropertyType["Enum"] = "enum";
|
|
5907
5933
|
PropertyType["List"] = "list";
|
|
5908
5934
|
PropertyType["Image"] = "image";
|
|
5935
|
+
PropertyType["Artboard"] = "artboard";
|
|
5909
5936
|
})(PropertyType || (PropertyType = {}));
|
|
5910
5937
|
var ViewModelInstance = /** @class */ (function () {
|
|
5911
5938
|
function ViewModelInstance(runtimeInstance, parent) {
|
|
@@ -6032,7 +6059,7 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
6032
6059
|
return null;
|
|
6033
6060
|
};
|
|
6034
6061
|
ViewModelInstance.prototype.propertyFromPathSegments = function (pathSegments, index, type) {
|
|
6035
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
6062
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
6036
6063
|
if (index < pathSegments.length - 1) {
|
|
6037
6064
|
var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
|
|
6038
6065
|
if (viewModelInstance !== null) {
|
|
@@ -6092,6 +6119,12 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
6092
6119
|
return new ViewModelInstanceAssetImage(instance, this);
|
|
6093
6120
|
}
|
|
6094
6121
|
break;
|
|
6122
|
+
case PropertyType.Artboard:
|
|
6123
|
+
instance = (_t = (_s = this._runtimeInstance) === null || _s === void 0 ? void 0 : _s.artboard(pathSegments[index])) !== null && _t !== void 0 ? _t : null;
|
|
6124
|
+
if (instance !== null) {
|
|
6125
|
+
return new ViewModelInstanceArtboard(instance, this);
|
|
6126
|
+
}
|
|
6127
|
+
break;
|
|
6095
6128
|
}
|
|
6096
6129
|
return null;
|
|
6097
6130
|
};
|
|
@@ -6181,6 +6214,15 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
6181
6214
|
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Image);
|
|
6182
6215
|
return viewmodelInstanceValue;
|
|
6183
6216
|
};
|
|
6217
|
+
/**
|
|
6218
|
+
* method to access an artboard property instance belonging
|
|
6219
|
+
* to the view model instance or to a nested view model instance
|
|
6220
|
+
* @param path - path to the image property
|
|
6221
|
+
*/
|
|
6222
|
+
ViewModelInstance.prototype.artboard = function (path) {
|
|
6223
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Artboard);
|
|
6224
|
+
return viewmodelInstanceValue;
|
|
6225
|
+
};
|
|
6184
6226
|
/**
|
|
6185
6227
|
* method to access a view model property instance belonging
|
|
6186
6228
|
* to the view model instance or to a nested view model instance
|
|
@@ -6565,6 +6607,24 @@ var ViewModelInstanceAssetImage = /** @class */ (function (_super) {
|
|
|
6565
6607
|
return ViewModelInstanceAssetImage;
|
|
6566
6608
|
}(ViewModelInstanceValue));
|
|
6567
6609
|
|
|
6610
|
+
var ViewModelInstanceArtboard = /** @class */ (function (_super) {
|
|
6611
|
+
__extends(ViewModelInstanceArtboard, _super);
|
|
6612
|
+
function ViewModelInstanceArtboard(instance, root) {
|
|
6613
|
+
return _super.call(this, instance, root) || this;
|
|
6614
|
+
}
|
|
6615
|
+
Object.defineProperty(ViewModelInstanceArtboard.prototype, "value", {
|
|
6616
|
+
set: function (artboard) {
|
|
6617
|
+
this._viewModelInstanceValue.value(artboard.nativeArtboard);
|
|
6618
|
+
},
|
|
6619
|
+
enumerable: false,
|
|
6620
|
+
configurable: true
|
|
6621
|
+
});
|
|
6622
|
+
ViewModelInstanceArtboard.prototype.internalHandleCallback = function (callback) {
|
|
6623
|
+
callback();
|
|
6624
|
+
};
|
|
6625
|
+
return ViewModelInstanceArtboard;
|
|
6626
|
+
}(ViewModelInstanceValue));
|
|
6627
|
+
|
|
6568
6628
|
// Loads Rive data from a URI via fetch.
|
|
6569
6629
|
var loadRiveFile = function (src) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6570
6630
|
var req, res, buffer;
|