@rive-app/canvas 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 +83 -23
- 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
|
@@ -747,7 +747,7 @@ function Xa(a, b) {
|
|
|
747
747
|
return Wa(c, a, b);
|
|
748
748
|
}));
|
|
749
749
|
}
|
|
750
|
-
var Ya, Za, cb = {
|
|
750
|
+
var Ya, Za, cb = {458556:(a, b, c, d, e) => {
|
|
751
751
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
752
752
|
return 0;
|
|
753
753
|
}
|
|
@@ -810,11 +810,11 @@ var Ya, Za, cb = {456380:(a, b, c, d, e) => {
|
|
|
810
810
|
}
|
|
811
811
|
window.h.Aa += 1;
|
|
812
812
|
return 1;
|
|
813
|
-
},
|
|
813
|
+
}, 460734:() => {
|
|
814
814
|
"undefined" !== typeof window.h && (window.h.Ta.map(function(a) {
|
|
815
815
|
document.removeEventListener(a, window.h.unlock, !0);
|
|
816
816
|
}), --window.h.Aa, 0 === window.h.Aa && delete window.h);
|
|
817
|
-
},
|
|
817
|
+
}, 461038:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 461142:() => {
|
|
818
818
|
try {
|
|
819
819
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
820
820
|
a.close();
|
|
@@ -822,7 +822,7 @@ var Ya, Za, cb = {456380:(a, b, c, d, e) => {
|
|
|
822
822
|
} catch (c) {
|
|
823
823
|
return 0;
|
|
824
824
|
}
|
|
825
|
-
},
|
|
825
|
+
}, 461313:(a, b, c, d, e, f) => {
|
|
826
826
|
if ("undefined" === typeof window.h) {
|
|
827
827
|
return -1;
|
|
828
828
|
}
|
|
@@ -868,7 +868,7 @@ var Ya, Za, cb = {456380:(a, b, c, d, e) => {
|
|
|
868
868
|
a == window.h.I.ya && g.Z.connect(g.J.destination);
|
|
869
869
|
g.qb = f;
|
|
870
870
|
return window.h.yc(g);
|
|
871
|
-
},
|
|
871
|
+
}, 464190:a => window.h.ra(a).J.sampleRate, 464263:a => {
|
|
872
872
|
a = window.h.ra(a);
|
|
873
873
|
void 0 !== a.Z && (a.Z.onaudioprocess = function() {
|
|
874
874
|
}, a.Z.disconnect(), a.Z = void 0);
|
|
@@ -876,13 +876,13 @@ var Ya, Za, cb = {456380:(a, b, c, d, e) => {
|
|
|
876
876
|
a.J.close();
|
|
877
877
|
a.J = void 0;
|
|
878
878
|
a.qb = void 0;
|
|
879
|
-
},
|
|
879
|
+
}, 464663:a => {
|
|
880
880
|
window.h.Cb(a);
|
|
881
|
-
},
|
|
881
|
+
}, 464713:a => {
|
|
882
882
|
a = window.h.ra(a);
|
|
883
883
|
a.J.resume();
|
|
884
884
|
a.state = window.h.ga.yb;
|
|
885
|
-
},
|
|
885
|
+
}, 464852:a => {
|
|
886
886
|
a = window.h.ra(a);
|
|
887
887
|
a.J.suspend();
|
|
888
888
|
a.state = window.h.ga.stopped;
|
|
@@ -3370,7 +3370,7 @@ $d();
|
|
|
3370
3370
|
/* 2 */
|
|
3371
3371
|
/***/ ((module) => {
|
|
3372
3372
|
|
|
3373
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.30.
|
|
3373
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.30.2","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}}');
|
|
3374
3374
|
|
|
3375
3375
|
/***/ }),
|
|
3376
3376
|
/* 3 */
|
|
@@ -4012,18 +4012,18 @@ var FontAssetWrapper = /** @class */ (function (_super) {
|
|
|
4012
4012
|
};
|
|
4013
4013
|
return FontAssetWrapper;
|
|
4014
4014
|
}(FileAssetWrapper));
|
|
4015
|
-
var FakeFinalizationRegistry = /** @class */ (function (
|
|
4016
|
-
|
|
4017
|
-
function FakeFinalizationRegistry(fn) {
|
|
4018
|
-
return _super.call(this, fn) || this;
|
|
4015
|
+
var FakeFinalizationRegistry = /** @class */ (function () {
|
|
4016
|
+
function FakeFinalizationRegistry(_) {
|
|
4019
4017
|
}
|
|
4020
4018
|
FakeFinalizationRegistry.prototype.register = function (object) {
|
|
4021
4019
|
object.selfUnref = true;
|
|
4022
4020
|
};
|
|
4023
4021
|
FakeFinalizationRegistry.prototype.unregister = function (_) { };
|
|
4024
4022
|
return FakeFinalizationRegistry;
|
|
4025
|
-
}(
|
|
4026
|
-
var MyFinalizationRegistry = FinalizationRegistry
|
|
4023
|
+
}());
|
|
4024
|
+
var MyFinalizationRegistry = typeof FinalizationRegistry !== "undefined"
|
|
4025
|
+
? FinalizationRegistry
|
|
4026
|
+
: FakeFinalizationRegistry;
|
|
4027
4027
|
var finalizationRegistry = new MyFinalizationRegistry(function (ob) {
|
|
4028
4028
|
ob.unref();
|
|
4029
4029
|
});
|
|
@@ -4107,6 +4107,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4107
4107
|
/* harmony export */ Testing: () => (/* binding */ Testing),
|
|
4108
4108
|
/* harmony export */ ViewModel: () => (/* binding */ ViewModel),
|
|
4109
4109
|
/* harmony export */ ViewModelInstance: () => (/* binding */ ViewModelInstance),
|
|
4110
|
+
/* harmony export */ ViewModelInstanceArtboard: () => (/* binding */ ViewModelInstanceArtboard),
|
|
4110
4111
|
/* harmony export */ ViewModelInstanceAssetImage: () => (/* binding */ ViewModelInstanceAssetImage),
|
|
4111
4112
|
/* harmony export */ ViewModelInstanceBoolean: () => (/* binding */ ViewModelInstanceBoolean),
|
|
4112
4113
|
/* harmony export */ ViewModelInstanceColor: () => (/* binding */ ViewModelInstanceColor),
|
|
@@ -4489,6 +4490,12 @@ var RiveEventType;
|
|
|
4489
4490
|
RiveEventType[RiveEventType["General"] = 128] = "General";
|
|
4490
4491
|
RiveEventType[RiveEventType["OpenUrl"] = 131] = "OpenUrl";
|
|
4491
4492
|
})(RiveEventType || (RiveEventType = {}));
|
|
4493
|
+
var Artboard = /** @class */ (function () {
|
|
4494
|
+
function Artboard(artboard) {
|
|
4495
|
+
this.nativeArtboard = artboard;
|
|
4496
|
+
}
|
|
4497
|
+
return Artboard;
|
|
4498
|
+
}());
|
|
4492
4499
|
var StateMachine = /** @class */ (function () {
|
|
4493
4500
|
/**
|
|
4494
4501
|
* @constructor
|
|
@@ -5462,6 +5469,18 @@ var RiveFile = /** @class */ (function () {
|
|
|
5462
5469
|
return this.file;
|
|
5463
5470
|
}
|
|
5464
5471
|
};
|
|
5472
|
+
RiveFile.prototype.destroyIfUnused = function () {
|
|
5473
|
+
if (this.referenceCount <= 0) {
|
|
5474
|
+
this.cleanup();
|
|
5475
|
+
}
|
|
5476
|
+
};
|
|
5477
|
+
RiveFile.prototype.getArtboard = function (name) {
|
|
5478
|
+
var nativeArtboard = this.file.artboardByName(name);
|
|
5479
|
+
if (nativeArtboard != null) {
|
|
5480
|
+
return new Artboard(nativeArtboard);
|
|
5481
|
+
}
|
|
5482
|
+
return null;
|
|
5483
|
+
};
|
|
5465
5484
|
// Error message for missing source or buffer
|
|
5466
5485
|
RiveFile.missingErrorMessage = "Rive source file or data buffer required";
|
|
5467
5486
|
// Error message for file load error
|
|
@@ -5745,28 +5764,31 @@ var Rive = /** @class */ (function () {
|
|
|
5745
5764
|
// Returns true for successful initialization.
|
|
5746
5765
|
Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
|
|
5747
5766
|
return __awaiter(this, void 0, void 0, function () {
|
|
5748
|
-
var error_2, msg;
|
|
5767
|
+
var riveFile, error_2, msg;
|
|
5749
5768
|
var _a;
|
|
5750
5769
|
return __generator(this, function (_b) {
|
|
5751
5770
|
switch (_b.label) {
|
|
5752
5771
|
case 0:
|
|
5753
5772
|
_b.trys.push([0, 3, , 4]);
|
|
5754
5773
|
if (!(this.riveFile == null)) return [3 /*break*/, 2];
|
|
5755
|
-
|
|
5774
|
+
riveFile = new RiveFile({
|
|
5756
5775
|
src: this.src,
|
|
5757
5776
|
buffer: this.buffer,
|
|
5758
5777
|
enableRiveAssetCDN: this.enableRiveAssetCDN,
|
|
5759
5778
|
assetLoader: this.assetLoader,
|
|
5760
5779
|
});
|
|
5761
|
-
|
|
5780
|
+
this.riveFile = riveFile;
|
|
5781
|
+
return [4 /*yield*/, riveFile.init()];
|
|
5762
5782
|
case 1:
|
|
5763
5783
|
_b.sent();
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5784
|
+
if (this.destroyed) {
|
|
5785
|
+
// In the very unlikely scenario where the rive file created by this Rive is shared by
|
|
5786
|
+
// another rive file, we only want to destroy it if this file is the only owner.
|
|
5787
|
+
riveFile.destroyIfUnused();
|
|
5768
5788
|
return [2 /*return*/, false];
|
|
5769
5789
|
}
|
|
5790
|
+
_b.label = 2;
|
|
5791
|
+
case 2:
|
|
5770
5792
|
this.file = this.riveFile.getInstance();
|
|
5771
5793
|
// Initialize and draw frame
|
|
5772
5794
|
this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay, autoBind);
|
|
@@ -6903,6 +6925,10 @@ var Rive = /** @class */ (function () {
|
|
|
6903
6925
|
}
|
|
6904
6926
|
return null;
|
|
6905
6927
|
};
|
|
6928
|
+
Rive.prototype.getArtboard = function (name) {
|
|
6929
|
+
var _a, _b;
|
|
6930
|
+
return (_b = (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.getArtboard(name)) !== null && _b !== void 0 ? _b : null;
|
|
6931
|
+
};
|
|
6906
6932
|
// Error message for missing source or buffer
|
|
6907
6933
|
Rive.missingErrorMessage = "Rive source file or data buffer required";
|
|
6908
6934
|
// Error message for removed rive file
|
|
@@ -7004,6 +7030,7 @@ var PropertyType;
|
|
|
7004
7030
|
PropertyType["Enum"] = "enum";
|
|
7005
7031
|
PropertyType["List"] = "list";
|
|
7006
7032
|
PropertyType["Image"] = "image";
|
|
7033
|
+
PropertyType["Artboard"] = "artboard";
|
|
7007
7034
|
})(PropertyType || (PropertyType = {}));
|
|
7008
7035
|
var ViewModelInstance = /** @class */ (function () {
|
|
7009
7036
|
function ViewModelInstance(runtimeInstance, parent) {
|
|
@@ -7130,7 +7157,7 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
7130
7157
|
return null;
|
|
7131
7158
|
};
|
|
7132
7159
|
ViewModelInstance.prototype.propertyFromPathSegments = function (pathSegments, index, type) {
|
|
7133
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
7160
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
7134
7161
|
if (index < pathSegments.length - 1) {
|
|
7135
7162
|
var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
|
|
7136
7163
|
if (viewModelInstance !== null) {
|
|
@@ -7190,6 +7217,12 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
7190
7217
|
return new ViewModelInstanceAssetImage(instance, this);
|
|
7191
7218
|
}
|
|
7192
7219
|
break;
|
|
7220
|
+
case PropertyType.Artboard:
|
|
7221
|
+
instance = (_t = (_s = this._runtimeInstance) === null || _s === void 0 ? void 0 : _s.artboard(pathSegments[index])) !== null && _t !== void 0 ? _t : null;
|
|
7222
|
+
if (instance !== null) {
|
|
7223
|
+
return new ViewModelInstanceArtboard(instance, this);
|
|
7224
|
+
}
|
|
7225
|
+
break;
|
|
7193
7226
|
}
|
|
7194
7227
|
return null;
|
|
7195
7228
|
};
|
|
@@ -7279,6 +7312,15 @@ var ViewModelInstance = /** @class */ (function () {
|
|
|
7279
7312
|
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Image);
|
|
7280
7313
|
return viewmodelInstanceValue;
|
|
7281
7314
|
};
|
|
7315
|
+
/**
|
|
7316
|
+
* method to access an artboard property instance belonging
|
|
7317
|
+
* to the view model instance or to a nested view model instance
|
|
7318
|
+
* @param path - path to the image property
|
|
7319
|
+
*/
|
|
7320
|
+
ViewModelInstance.prototype.artboard = function (path) {
|
|
7321
|
+
var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Artboard);
|
|
7322
|
+
return viewmodelInstanceValue;
|
|
7323
|
+
};
|
|
7282
7324
|
/**
|
|
7283
7325
|
* method to access a view model property instance belonging
|
|
7284
7326
|
* to the view model instance or to a nested view model instance
|
|
@@ -7663,6 +7705,24 @@ var ViewModelInstanceAssetImage = /** @class */ (function (_super) {
|
|
|
7663
7705
|
return ViewModelInstanceAssetImage;
|
|
7664
7706
|
}(ViewModelInstanceValue));
|
|
7665
7707
|
|
|
7708
|
+
var ViewModelInstanceArtboard = /** @class */ (function (_super) {
|
|
7709
|
+
__extends(ViewModelInstanceArtboard, _super);
|
|
7710
|
+
function ViewModelInstanceArtboard(instance, root) {
|
|
7711
|
+
return _super.call(this, instance, root) || this;
|
|
7712
|
+
}
|
|
7713
|
+
Object.defineProperty(ViewModelInstanceArtboard.prototype, "value", {
|
|
7714
|
+
set: function (artboard) {
|
|
7715
|
+
this._viewModelInstanceValue.value(artboard.nativeArtboard);
|
|
7716
|
+
},
|
|
7717
|
+
enumerable: false,
|
|
7718
|
+
configurable: true
|
|
7719
|
+
});
|
|
7720
|
+
ViewModelInstanceArtboard.prototype.internalHandleCallback = function (callback) {
|
|
7721
|
+
callback();
|
|
7722
|
+
};
|
|
7723
|
+
return ViewModelInstanceArtboard;
|
|
7724
|
+
}(ViewModelInstanceValue));
|
|
7725
|
+
|
|
7666
7726
|
// Loads Rive data from a URI via fetch.
|
|
7667
7727
|
var loadRiveFile = function (src) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7668
7728
|
var req, res, buffer;
|