@rive-app/canvas-lite 2.40.1 → 2.41.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 +206 -5
- package/rive.js +262 -26
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_fallback.wasm +0 -0
package/rive.js
CHANGED
|
@@ -449,7 +449,7 @@ Hc=await (async function(){function b(c){c=Hc=c.exports;gb=c.V;Ec=c.W;fb=c.X;Fc=
|
|
|
449
449
|
/* 5 */
|
|
450
450
|
/***/ ((module) => {
|
|
451
451
|
|
|
452
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.
|
|
452
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.41.0","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","runtimeLoader.d.ts","utils","semantics"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
453
453
|
|
|
454
454
|
/***/ }),
|
|
455
455
|
/* 6 */
|
|
@@ -3574,6 +3574,12 @@ var Layout = /** @class */ (function () {
|
|
|
3574
3574
|
|
|
3575
3575
|
// #endregion
|
|
3576
3576
|
// #region state machines
|
|
3577
|
+
/**
|
|
3578
|
+
* @deprecated State machine inputs are deprecated and will be removed in a
|
|
3579
|
+
* future major version: please use data binding properties instead. See
|
|
3580
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs}
|
|
3581
|
+
* for how to migrate.
|
|
3582
|
+
*/
|
|
3577
3583
|
var StateMachineInputType;
|
|
3578
3584
|
(function (StateMachineInputType) {
|
|
3579
3585
|
StateMachineInputType[StateMachineInputType["Number"] = 56] = "Number";
|
|
@@ -3582,6 +3588,10 @@ var StateMachineInputType;
|
|
|
3582
3588
|
})(StateMachineInputType || (StateMachineInputType = {}));
|
|
3583
3589
|
/**
|
|
3584
3590
|
* An input for a state machine
|
|
3591
|
+
* @deprecated State machine inputs are deprecated and will be removed in a
|
|
3592
|
+
* future major version: please use data binding properties instead. See
|
|
3593
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs}
|
|
3594
|
+
* for how to migrate.
|
|
3585
3595
|
*/
|
|
3586
3596
|
var StateMachineInput = /** @class */ (function () {
|
|
3587
3597
|
function StateMachineInput(type, runtimeInput) {
|
|
@@ -3631,6 +3641,11 @@ var StateMachineInput = /** @class */ (function () {
|
|
|
3631
3641
|
return StateMachineInput;
|
|
3632
3642
|
}());
|
|
3633
3643
|
|
|
3644
|
+
/**
|
|
3645
|
+
* @deprecated Rive Events are deprecated and will be removed in a future major
|
|
3646
|
+
* version: please use data binding instead. See
|
|
3647
|
+
* {@link https://rive.app/docs/runtimes/web/rive-events} for how to migrate.
|
|
3648
|
+
*/
|
|
3634
3649
|
var RiveEventType;
|
|
3635
3650
|
(function (RiveEventType) {
|
|
3636
3651
|
RiveEventType[RiveEventType["General"] = 128] = "General";
|
|
@@ -4173,6 +4188,12 @@ var Animator = /** @class */ (function () {
|
|
|
4173
4188
|
var instancedName;
|
|
4174
4189
|
if (this.animations.length === 0 && this.stateMachines.length === 0) {
|
|
4175
4190
|
if (this.artboard.animationCount() > 0) {
|
|
4191
|
+
// Warn only when the v3 default would actually change what plays
|
|
4192
|
+
if (this.artboard.stateMachineCount() > 0) {
|
|
4193
|
+
warnOnce("No `stateMachine` was specified, so the artboard's first linear animation is playing by default. " +
|
|
4194
|
+
"In the next major version, the artboard's state machine will be played by default instead when one exists. " +
|
|
4195
|
+
"Pass the `stateMachine` parameter to adopt that behavior now.");
|
|
4196
|
+
}
|
|
4176
4197
|
// Add the first animation
|
|
4177
4198
|
this.add([(instancedName = this.artboard.animationByIndex(0).name)], playing, fireEvent);
|
|
4178
4199
|
}
|
|
@@ -4251,15 +4272,84 @@ var EventType;
|
|
|
4251
4272
|
EventType["Play"] = "play";
|
|
4252
4273
|
EventType["Pause"] = "pause";
|
|
4253
4274
|
EventType["Stop"] = "stop";
|
|
4275
|
+
/**
|
|
4276
|
+
* @deprecated Loop events are deprecated and will be removed in a future
|
|
4277
|
+
* major version: they are only reported for linear animation playback, which
|
|
4278
|
+
* is deprecated. Use a state machine to control playback and data binding to
|
|
4279
|
+
* react to changes instead. See
|
|
4280
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide} for how
|
|
4281
|
+
* to migrate.
|
|
4282
|
+
*/
|
|
4254
4283
|
EventType["Loop"] = "loop";
|
|
4255
4284
|
EventType["Draw"] = "draw";
|
|
4256
4285
|
EventType["Advance"] = "advance";
|
|
4286
|
+
/**
|
|
4287
|
+
* @deprecated State change events are deprecated and will be removed in a
|
|
4288
|
+
* future major version. Use data binding (view model property observers) or
|
|
4289
|
+
* state machine actions to react to changes from your graphic instead. See
|
|
4290
|
+
* {@link https://rive.app/docs/editor/state-machine/states#actions} for more details.
|
|
4291
|
+
*/
|
|
4257
4292
|
EventType["StateChange"] = "statechange";
|
|
4293
|
+
/**
|
|
4294
|
+
* @deprecated Rive Events are deprecated and will be removed in a future
|
|
4295
|
+
* major version: please use data binding instead. See
|
|
4296
|
+
* {@link https://rive.app/docs/runtimes/web/rive-events} for how to migrate.
|
|
4297
|
+
*/
|
|
4258
4298
|
EventType["RiveEvent"] = "riveevent";
|
|
4259
4299
|
EventType["AudioStatusChange"] = "audiostatuschange";
|
|
4260
4300
|
})(EventType || (EventType = {}));
|
|
4301
|
+
var riveEventsDeprecationWarning = "Rive Events are deprecated and will be removed in a future major version: " +
|
|
4302
|
+
"please use data binding instead. See " +
|
|
4303
|
+
"https://rive.app/docs/runtimes/web/rive-events for how to migrate.";
|
|
4304
|
+
var stateMachineInputsDeprecationWarning = "State machine inputs are deprecated and will be removed in a future major version: " +
|
|
4305
|
+
"please use data binding properties instead. See " +
|
|
4306
|
+
"https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs for how to migrate.";
|
|
4307
|
+
var textRunsDeprecationWarning = "Text run APIs are deprecated and will be removed in a future major version: " +
|
|
4308
|
+
"please use data binding instead. See " +
|
|
4309
|
+
"https://rive.app/docs/editor/data-binding/migration-guide#updating-text-runs-at-runtime for how to migrate.";
|
|
4310
|
+
var loopEventsDeprecationWarning = "Loop events are deprecated and will be removed in a future major version: " +
|
|
4311
|
+
"they are only reported for linear animation playback, which is deprecated. " +
|
|
4312
|
+
"Use a state machine to control playback and data binding to react to changes instead. See " +
|
|
4313
|
+
"https://rive.app/docs/editor/data-binding/migration-guide for how to migrate.";
|
|
4314
|
+
var stateChangeEventsDeprecationWarning = "State change events are deprecated and will be removed in a future major version: " +
|
|
4315
|
+
"use data binding (view model property observers) or state machine actions to react to " +
|
|
4316
|
+
"changes from your graphic instead. See " +
|
|
4317
|
+
"https://rive.app/docs/editor/state-machine/states#actions for how to migrate.";
|
|
4318
|
+
// Deprecation warnings already emitted; each is logged at most once per page
|
|
4319
|
+
// session to avoid flooding the console when many instances are created.
|
|
4320
|
+
var emittedWarnings = new Set();
|
|
4321
|
+
var warnOnce = function (message) {
|
|
4322
|
+
if (!emittedWarnings.has(message)) {
|
|
4323
|
+
emittedWarnings.add(message);
|
|
4324
|
+
console.warn("[Rive] ".concat(message));
|
|
4325
|
+
}
|
|
4326
|
+
};
|
|
4327
|
+
/**
|
|
4328
|
+
* Warns that a playback-control method received an array of names; the next
|
|
4329
|
+
* major version restricts these parameters to a single string, since playing
|
|
4330
|
+
* multiple animations or state machines at once will not be supported.
|
|
4331
|
+
*/
|
|
4332
|
+
var warnIfNamesArray = function (names, methodName) {
|
|
4333
|
+
if (Array.isArray(names)) {
|
|
4334
|
+
warnOnce("Passing an array of names to `".concat(methodName, "()` is deprecated: in the next major version this parameter will be a single string, and playing multiple animations or state machines at once will not be supported."));
|
|
4335
|
+
}
|
|
4336
|
+
};
|
|
4337
|
+
/**
|
|
4338
|
+
* Warns that a playback-control method received linear animation names;
|
|
4339
|
+
* name-based control remains supported for state machines only, so
|
|
4340
|
+
* user-specified linear animation names are going away in a future major
|
|
4341
|
+
* version.
|
|
4342
|
+
*/
|
|
4343
|
+
var warnDeprecatedAnimationNames = function (methodName) {
|
|
4344
|
+
warnOnce("Passing linear animation names to `".concat(methodName, "()` is deprecated and will be removed in a future major version: ") +
|
|
4345
|
+
"Pass a single state machine name to control playback instead.");
|
|
4346
|
+
};
|
|
4261
4347
|
/**
|
|
4262
4348
|
* Looping types: one-shot, loop, and ping-pong
|
|
4349
|
+
* @deprecated Loop events are deprecated and will be removed in a future major
|
|
4350
|
+
* version: they are only reported for linear animation playback, which is
|
|
4351
|
+
* deprecated. Use a state machine to control playback and data binding to
|
|
4352
|
+
* react to changes instead.
|
|
4263
4353
|
*/
|
|
4264
4354
|
var LoopType;
|
|
4265
4355
|
(function (LoopType) {
|
|
@@ -4573,6 +4663,31 @@ var observers = new ObjectObservers();
|
|
|
4573
4663
|
// #endregion
|
|
4574
4664
|
// #region Rive
|
|
4575
4665
|
var nextRiveInstanceId = 0;
|
|
4666
|
+
/**
|
|
4667
|
+
* Resolves which animation/state machine names playback should start with.
|
|
4668
|
+
* The `stateMachine` parameter takes priority; the deprecated plural
|
|
4669
|
+
* `animations`/`stateMachines` parameters apply only when it
|
|
4670
|
+
* is not provided.
|
|
4671
|
+
*/
|
|
4672
|
+
var resolveStartingPlayback = function (_a) {
|
|
4673
|
+
var stateMachine = _a.stateMachine, animations = _a.animations, stateMachines = _a.stateMachines;
|
|
4674
|
+
if (animations !== undefined) {
|
|
4675
|
+
warnOnce("The `animations` parameter is deprecated and will be removed in a future major version: please use the `stateMachine` parameter to play a state machine instead.");
|
|
4676
|
+
}
|
|
4677
|
+
if (stateMachines !== undefined) {
|
|
4678
|
+
warnOnce("The `stateMachines` parameter is deprecated: please use `stateMachine` with a single state machine name instead.");
|
|
4679
|
+
}
|
|
4680
|
+
if (stateMachine) {
|
|
4681
|
+
return {
|
|
4682
|
+
startingAnimationNames: [],
|
|
4683
|
+
startingStateMachineNames: [stateMachine],
|
|
4684
|
+
};
|
|
4685
|
+
}
|
|
4686
|
+
return {
|
|
4687
|
+
startingAnimationNames: mapToStringArray(animations),
|
|
4688
|
+
startingStateMachineNames: mapToStringArray(stateMachines),
|
|
4689
|
+
};
|
|
4690
|
+
};
|
|
4576
4691
|
var RiveFile = /** @class */ (function () {
|
|
4577
4692
|
function RiveFile(params) {
|
|
4578
4693
|
// Allow the runtime to automatically load assets hosted in Rive's runtime.
|
|
@@ -4994,6 +5109,10 @@ var Rive = /** @class */ (function () {
|
|
|
4994
5109
|
this.layout = (_a = params.layout) !== null && _a !== void 0 ? _a : new Layout();
|
|
4995
5110
|
this.shouldDisableRiveListeners = !!params.shouldDisableRiveListeners;
|
|
4996
5111
|
this.isTouchScrollEnabled = !!params.isTouchScrollEnabled;
|
|
5112
|
+
if (params.automaticallyHandleEvents) {
|
|
5113
|
+
warnOnce("The `automaticallyHandleEvents` parameter is deprecated. " +
|
|
5114
|
+
riveEventsDeprecationWarning);
|
|
5115
|
+
}
|
|
4997
5116
|
this.automaticallyHandleEvents = !!params.automaticallyHandleEvents;
|
|
4998
5117
|
this.dispatchPointerExit =
|
|
4999
5118
|
params.dispatchPointerExit === false
|
|
@@ -5058,6 +5177,7 @@ var Rive = /** @class */ (function () {
|
|
|
5058
5177
|
riveFile: this.riveFile,
|
|
5059
5178
|
autoplay: params.autoplay,
|
|
5060
5179
|
autoBind: params.autoBind,
|
|
5180
|
+
stateMachine: params.stateMachine,
|
|
5061
5181
|
animations: params.animations,
|
|
5062
5182
|
stateMachines: params.stateMachines,
|
|
5063
5183
|
artboard: params.artboard,
|
|
@@ -5124,7 +5244,7 @@ var Rive = /** @class */ (function () {
|
|
|
5124
5244
|
// Initializes the Rive object either from constructor or load()
|
|
5125
5245
|
Rive.prototype.init = function (_a) {
|
|
5126
5246
|
var _this = this;
|
|
5127
|
-
var src = _a.src, buffer = _a.buffer, riveFile = _a.riveFile, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c, _d = _a.autoBind, autoBind = _d === void 0 ? false : _d, tabIndex = _a.tabIndex, semanticsMode = _a.semanticsMode, semanticsOptions = _a.semanticsOptions;
|
|
5247
|
+
var src = _a.src, buffer = _a.buffer, riveFile = _a.riveFile, stateMachine = _a.stateMachine, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c, _d = _a.autoBind, autoBind = _d === void 0 ? false : _d, tabIndex = _a.tabIndex, semanticsMode = _a.semanticsMode, semanticsOptions = _a.semanticsOptions;
|
|
5128
5248
|
if (this.destroyed) {
|
|
5129
5249
|
return;
|
|
5130
5250
|
}
|
|
@@ -5138,10 +5258,12 @@ var Rive = /** @class */ (function () {
|
|
|
5138
5258
|
if (!this.src && !this.buffer && !this.riveFile) {
|
|
5139
5259
|
throw new RiveError(Rive.missingErrorMessage);
|
|
5140
5260
|
}
|
|
5141
|
-
//
|
|
5142
|
-
var
|
|
5143
|
-
|
|
5144
|
-
|
|
5261
|
+
// Names of the animations and state machines that should be initialized
|
|
5262
|
+
var _e = resolveStartingPlayback({
|
|
5263
|
+
stateMachine: stateMachine,
|
|
5264
|
+
animations: animations,
|
|
5265
|
+
stateMachines: stateMachines,
|
|
5266
|
+
}), startingAnimationNames = _e.startingAnimationNames, startingStateMachineNames = _e.startingStateMachineNames;
|
|
5145
5267
|
// Ensure loaded is marked as false if loading new file
|
|
5146
5268
|
this.loaded = false;
|
|
5147
5269
|
this.readyForPlaying = false;
|
|
@@ -5858,6 +5980,7 @@ var Rive = /** @class */ (function () {
|
|
|
5858
5980
|
* might happen.
|
|
5859
5981
|
*/
|
|
5860
5982
|
Rive.prototype.cleanupInstances = function () {
|
|
5983
|
+
var _a;
|
|
5861
5984
|
if (this.eventCleanup !== null) {
|
|
5862
5985
|
this.eventCleanup();
|
|
5863
5986
|
}
|
|
@@ -5865,8 +5988,9 @@ var Rive = /** @class */ (function () {
|
|
|
5865
5988
|
// Tear down semantics before deleting state machines — the overlay's action
|
|
5866
5989
|
// closures point at instances that stop() is about to free.
|
|
5867
5990
|
this.cleanupSemantics();
|
|
5868
|
-
// Delete all animation and state machine instances
|
|
5869
|
-
|
|
5991
|
+
// Delete all animation and state machine instances synchronously via the
|
|
5992
|
+
// animator
|
|
5993
|
+
(_a = this.animator) === null || _a === void 0 ? void 0 : _a.stop();
|
|
5870
5994
|
if (this.artboard) {
|
|
5871
5995
|
this.artboard.delete();
|
|
5872
5996
|
this.artboard = null;
|
|
@@ -5899,29 +6023,58 @@ var Rive = /** @class */ (function () {
|
|
|
5899
6023
|
* Returns a string from a given text run node name, or undefined if the text run
|
|
5900
6024
|
* cannot be queried.
|
|
5901
6025
|
*
|
|
6026
|
+
* @deprecated Text run APIs are deprecated: use data binding instead. See
|
|
6027
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#updating-text-runs-at-runtime}
|
|
6028
|
+
* for how to migrate.
|
|
5902
6029
|
* @param textRunName - Name of the text run node associated with a text object
|
|
5903
6030
|
* @returns - String value of the text run node or undefined
|
|
5904
6031
|
*/
|
|
5905
6032
|
Rive.prototype.getTextRunValue = function (textRunName) {
|
|
6033
|
+
warnOnce(textRunsDeprecationWarning);
|
|
5906
6034
|
var textRun = this.retrieveTextRun(textRunName);
|
|
5907
6035
|
return textRun ? textRun.text : undefined;
|
|
5908
6036
|
};
|
|
5909
6037
|
/**
|
|
5910
6038
|
* Sets a text value for a given text run node name if possible
|
|
5911
6039
|
*
|
|
6040
|
+
* @deprecated Text run APIs are deprecated: use data binding instead. See
|
|
6041
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#updating-text-runs-at-runtime}
|
|
6042
|
+
* for how to migrate.
|
|
5912
6043
|
* @param textRunName - Name of the text run node associated with a text object
|
|
5913
6044
|
* @param textRunValue - String value to set on the text run node
|
|
5914
6045
|
*/
|
|
5915
6046
|
Rive.prototype.setTextRunValue = function (textRunName, textRunValue) {
|
|
6047
|
+
warnOnce(textRunsDeprecationWarning);
|
|
5916
6048
|
var textRun = this.retrieveTextRun(textRunName);
|
|
5917
6049
|
if (textRun) {
|
|
5918
6050
|
textRun.text = textRunValue;
|
|
5919
6051
|
}
|
|
5920
6052
|
};
|
|
5921
|
-
|
|
6053
|
+
/**
|
|
6054
|
+
* Warns when playback-control names match linear animations in the
|
|
6055
|
+
* Animator's instanced context; state machine playback remain supported.
|
|
6056
|
+
*
|
|
6057
|
+
* Remove for v3 release
|
|
6058
|
+
*/
|
|
6059
|
+
Rive.prototype.warnIfLinearAnimationNames = function (names, methodName) {
|
|
6060
|
+
if (this.animator &&
|
|
6061
|
+
this.animator.animations.some(function (a) { return names.includes(a.name); })) {
|
|
6062
|
+
warnDeprecatedAnimationNames(methodName);
|
|
6063
|
+
}
|
|
6064
|
+
};
|
|
6065
|
+
/**
|
|
6066
|
+
* Plays specified animations or state machines; if none specified, it
|
|
6067
|
+
* unpauses everything.
|
|
6068
|
+
* @param animationNames Animation or state machine name(s) to play.
|
|
6069
|
+
*
|
|
6070
|
+
* Deprecated usage: passing linear animation names (control playback with a
|
|
6071
|
+
* state machine instead) and passing an array of names (this parameter
|
|
6072
|
+
* becomes a single string in the next major version).
|
|
6073
|
+
*/
|
|
5922
6074
|
Rive.prototype.play = function (animationNames, autoplay) {
|
|
5923
6075
|
var _this = this;
|
|
5924
|
-
animationNames
|
|
6076
|
+
warnIfNamesArray(animationNames, "play");
|
|
6077
|
+
var names = mapToStringArray(animationNames);
|
|
5925
6078
|
// If the file's not loaded, queue up the play
|
|
5926
6079
|
if (!this.readyForPlaying) {
|
|
5927
6080
|
this.taskQueue.add({
|
|
@@ -5929,7 +6082,8 @@ var Rive = /** @class */ (function () {
|
|
|
5929
6082
|
});
|
|
5930
6083
|
return;
|
|
5931
6084
|
}
|
|
5932
|
-
this.animator.play(
|
|
6085
|
+
this.animator.play(names);
|
|
6086
|
+
this.warnIfLinearAnimationNames(names, "play");
|
|
5933
6087
|
this.syncSemanticsOnStateMachines();
|
|
5934
6088
|
if (this.eventCleanup) {
|
|
5935
6089
|
this.eventCleanup();
|
|
@@ -5938,10 +6092,19 @@ var Rive = /** @class */ (function () {
|
|
|
5938
6092
|
this.setupRiveListeners();
|
|
5939
6093
|
this.startRendering();
|
|
5940
6094
|
};
|
|
5941
|
-
|
|
6095
|
+
/**
|
|
6096
|
+
* Pauses specified animations or state machines; if none specified, pauses
|
|
6097
|
+
* all.
|
|
6098
|
+
* @param animationNames Animation or state machine name(s) to pause.
|
|
6099
|
+
*
|
|
6100
|
+
* Deprecated usage: passing linear animation names (control playback with a
|
|
6101
|
+
* state machine instead) and passing an array of names (this parameter
|
|
6102
|
+
* becomes a single string in the next major version).
|
|
6103
|
+
*/
|
|
5942
6104
|
Rive.prototype.pause = function (animationNames) {
|
|
5943
6105
|
var _this = this;
|
|
5944
|
-
animationNames
|
|
6106
|
+
warnIfNamesArray(animationNames, "pause");
|
|
6107
|
+
var names = mapToStringArray(animationNames);
|
|
5945
6108
|
// If the file's not loaded, early out, nothing to pause
|
|
5946
6109
|
if (!this.readyForPlaying) {
|
|
5947
6110
|
this.taskQueue.add({
|
|
@@ -5953,11 +6116,20 @@ var Rive = /** @class */ (function () {
|
|
|
5953
6116
|
this.eventCleanup();
|
|
5954
6117
|
}
|
|
5955
6118
|
this.cleanupKeyboardInteractions();
|
|
5956
|
-
this.animator.pause(
|
|
6119
|
+
this.animator.pause(names);
|
|
6120
|
+
this.warnIfLinearAnimationNames(names, "pause");
|
|
5957
6121
|
};
|
|
6122
|
+
/**
|
|
6123
|
+
* Scrubs specified animations to the given time; if none specified, scrubs
|
|
6124
|
+
* all of them.
|
|
6125
|
+
* @deprecated `scrub()` will be removed in a future major version: use a
|
|
6126
|
+
* state machine to control playback instead
|
|
6127
|
+
*/
|
|
5958
6128
|
Rive.prototype.scrub = function (animationNames, value) {
|
|
5959
6129
|
var _this = this;
|
|
5960
|
-
|
|
6130
|
+
warnOnce("`scrub()` is deprecated and will be removed in a future major version: " +
|
|
6131
|
+
"use a state machine to control playback instead.");
|
|
6132
|
+
var names = mapToStringArray(animationNames);
|
|
5961
6133
|
// If the file's not loaded, early out, nothing to pause
|
|
5962
6134
|
if (!this.readyForPlaying) {
|
|
5963
6135
|
this.taskQueue.add({
|
|
@@ -5967,13 +6139,22 @@ var Rive = /** @class */ (function () {
|
|
|
5967
6139
|
}
|
|
5968
6140
|
// Scrub the animation time; we draw a single frame here so that if
|
|
5969
6141
|
// nothing's currently playing, the scrubbed animation is still rendered/
|
|
5970
|
-
this.animator.scrub(
|
|
6142
|
+
this.animator.scrub(names, value || 0);
|
|
5971
6143
|
this.drawFrame();
|
|
5972
6144
|
};
|
|
5973
|
-
|
|
6145
|
+
/**
|
|
6146
|
+
* Stops specified animations or state machines; if none specified, stops
|
|
6147
|
+
* them all.
|
|
6148
|
+
* @param animationNames Animation or state machine name(s) to stop.
|
|
6149
|
+
*
|
|
6150
|
+
* Deprecated usage: passing linear animation names (control playback with a
|
|
6151
|
+
* state machine instead) and passing an array of names (this parameter
|
|
6152
|
+
* becomes a single string in the next major version).
|
|
6153
|
+
*/
|
|
5974
6154
|
Rive.prototype.stop = function (animationNames) {
|
|
5975
6155
|
var _this = this;
|
|
5976
|
-
animationNames
|
|
6156
|
+
warnIfNamesArray(animationNames, "stop");
|
|
6157
|
+
var names = mapToStringArray(animationNames);
|
|
5977
6158
|
// If the file's not loaded, early out, nothing to pause
|
|
5978
6159
|
if (!this.readyForPlaying) {
|
|
5979
6160
|
this.taskQueue.add({
|
|
@@ -5981,9 +6162,10 @@ var Rive = /** @class */ (function () {
|
|
|
5981
6162
|
});
|
|
5982
6163
|
return;
|
|
5983
6164
|
}
|
|
6165
|
+
this.warnIfLinearAnimationNames(names, "stop");
|
|
5984
6166
|
// If there is no artboard, this.animator will be undefined
|
|
5985
6167
|
if (this.animator) {
|
|
5986
|
-
this.animator.stop(
|
|
6168
|
+
this.animator.stop(names);
|
|
5987
6169
|
}
|
|
5988
6170
|
if (this.eventCleanup) {
|
|
5989
6171
|
this.eventCleanup();
|
|
@@ -5994,8 +6176,7 @@ var Rive = /** @class */ (function () {
|
|
|
5994
6176
|
/**
|
|
5995
6177
|
* Resets the animation
|
|
5996
6178
|
* @param artboard the name of the artboard, or default if none given
|
|
5997
|
-
* @param
|
|
5998
|
-
* @param stateMachines the names of state machines for playback
|
|
6179
|
+
* @param stateMachine the name of the state machine for playback
|
|
5999
6180
|
* @param autoplay whether to autoplay when reset, defaults to false
|
|
6000
6181
|
*
|
|
6001
6182
|
*/
|
|
@@ -6003,15 +6184,22 @@ var Rive = /** @class */ (function () {
|
|
|
6003
6184
|
var _a, _b;
|
|
6004
6185
|
// Get the current artboard, animations, state machines, and playback states
|
|
6005
6186
|
var artBoardName = params === null || params === void 0 ? void 0 : params.artboard;
|
|
6006
|
-
var
|
|
6007
|
-
|
|
6187
|
+
var _c = resolveStartingPlayback({
|
|
6188
|
+
stateMachine: params === null || params === void 0 ? void 0 : params.stateMachine,
|
|
6189
|
+
animations: params === null || params === void 0 ? void 0 : params.animations,
|
|
6190
|
+
stateMachines: params === null || params === void 0 ? void 0 : params.stateMachines,
|
|
6191
|
+
}), animationNames = _c.startingAnimationNames, stateMachineNames = _c.startingStateMachineNames;
|
|
6008
6192
|
var autoplay = (_a = params === null || params === void 0 ? void 0 : params.autoplay) !== null && _a !== void 0 ? _a : false;
|
|
6009
6193
|
var autoBind = (_b = params === null || params === void 0 ? void 0 : params.autoBind) !== null && _b !== void 0 ? _b : false;
|
|
6010
6194
|
// Stop everything and clean up
|
|
6011
6195
|
this.cleanupInstances();
|
|
6012
6196
|
// Reinitialize an artboard instance with the state
|
|
6013
6197
|
this.initArtboard(artBoardName, animationNames, stateMachineNames, autoplay, autoBind);
|
|
6014
|
-
|
|
6198
|
+
// Only drain the task queue once playback commands can execute; tasks
|
|
6199
|
+
// queued before then re-add themselves in a loop.
|
|
6200
|
+
if (this.readyForPlaying) {
|
|
6201
|
+
this.taskQueue.process();
|
|
6202
|
+
}
|
|
6015
6203
|
};
|
|
6016
6204
|
// Loads a new Rive file, keeping listeners in place
|
|
6017
6205
|
Rive.prototype.load = function (params) {
|
|
@@ -6166,11 +6354,18 @@ var Rive = /** @class */ (function () {
|
|
|
6166
6354
|
});
|
|
6167
6355
|
/**
|
|
6168
6356
|
* Returns the inputs for the specified instanced state machine, or an empty
|
|
6169
|
-
* list if the name is invalid or the state machine is not instanced
|
|
6357
|
+
* list if the name is invalid or the state machine is not instanced. Returns
|
|
6358
|
+
* undefined if the file is not loaded yet.
|
|
6359
|
+
*
|
|
6360
|
+
* @deprecated State machine inputs are deprecated: use data binding
|
|
6361
|
+
* properties instead. See
|
|
6362
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs}
|
|
6363
|
+
* for how to migrate.
|
|
6170
6364
|
* @param name the state machine name
|
|
6171
|
-
* @returns the inputs for the named state machine
|
|
6365
|
+
* @returns the inputs for the named state machine or undefined
|
|
6172
6366
|
*/
|
|
6173
6367
|
Rive.prototype.stateMachineInputs = function (name) {
|
|
6368
|
+
warnOnce(stateMachineInputsDeprecationWarning);
|
|
6174
6369
|
// If the file's not loaded, early out, nothing to pause
|
|
6175
6370
|
if (!this.loaded) {
|
|
6176
6371
|
return;
|
|
@@ -6197,11 +6392,16 @@ var Rive = /** @class */ (function () {
|
|
|
6197
6392
|
};
|
|
6198
6393
|
/**
|
|
6199
6394
|
* Set the boolean input with the provided name at the given path with value
|
|
6395
|
+
* @deprecated State machine inputs are deprecated: use data binding
|
|
6396
|
+
* properties instead. See
|
|
6397
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs}
|
|
6398
|
+
* for how to migrate.
|
|
6200
6399
|
* @param input the state machine input name
|
|
6201
6400
|
* @param value the value to set the input to
|
|
6202
6401
|
* @param path the path the input is located at an artboard level
|
|
6203
6402
|
*/
|
|
6204
6403
|
Rive.prototype.setBooleanStateAtPath = function (inputName, value, path) {
|
|
6404
|
+
warnOnce(stateMachineInputsDeprecationWarning);
|
|
6205
6405
|
var input = this.retrieveInputAtPath(inputName, path);
|
|
6206
6406
|
if (!input)
|
|
6207
6407
|
return;
|
|
@@ -6214,11 +6414,16 @@ var Rive = /** @class */ (function () {
|
|
|
6214
6414
|
};
|
|
6215
6415
|
/**
|
|
6216
6416
|
* Set the number input with the provided name at the given path with value
|
|
6417
|
+
* @deprecated State machine inputs are deprecated: use data binding
|
|
6418
|
+
* properties instead. See
|
|
6419
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs}
|
|
6420
|
+
* for how to migrate.
|
|
6217
6421
|
* @param input the state machine input name
|
|
6218
6422
|
* @param value the value to set the input to
|
|
6219
6423
|
* @param path the path the input is located at an artboard level
|
|
6220
6424
|
*/
|
|
6221
6425
|
Rive.prototype.setNumberStateAtPath = function (inputName, value, path) {
|
|
6426
|
+
warnOnce(stateMachineInputsDeprecationWarning);
|
|
6222
6427
|
var input = this.retrieveInputAtPath(inputName, path);
|
|
6223
6428
|
if (!input)
|
|
6224
6429
|
return;
|
|
@@ -6231,10 +6436,15 @@ var Rive = /** @class */ (function () {
|
|
|
6231
6436
|
};
|
|
6232
6437
|
/**
|
|
6233
6438
|
* Fire the trigger with the provided name at the given path
|
|
6439
|
+
* @deprecated State machine inputs are deprecated: use data binding
|
|
6440
|
+
* properties instead. See
|
|
6441
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#state-machine-inputs}
|
|
6442
|
+
* for how to migrate.
|
|
6234
6443
|
* @param input the state machine input name
|
|
6235
6444
|
* @param path the path the input is located at an artboard level
|
|
6236
6445
|
*/
|
|
6237
6446
|
Rive.prototype.fireStateAtPath = function (inputName, path) {
|
|
6447
|
+
warnOnce(stateMachineInputsDeprecationWarning);
|
|
6238
6448
|
var input = this.retrieveInputAtPath(inputName, path);
|
|
6239
6449
|
if (!input)
|
|
6240
6450
|
return;
|
|
@@ -6282,8 +6492,13 @@ var Rive = /** @class */ (function () {
|
|
|
6282
6492
|
*
|
|
6283
6493
|
* @remarks
|
|
6284
6494
|
* If the text run cannot be found at the specified path, a warning will be logged to the console.
|
|
6495
|
+
*
|
|
6496
|
+
* @deprecated Text run APIs are deprecated: use data binding instead. See
|
|
6497
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#updating-text-runs-at-runtime}
|
|
6498
|
+
* for how to migrate.
|
|
6285
6499
|
*/
|
|
6286
6500
|
Rive.prototype.getTextRunValueAtPath = function (textName, path) {
|
|
6501
|
+
warnOnce(textRunsDeprecationWarning);
|
|
6287
6502
|
var run = this.retrieveTextAtPath(textName, path);
|
|
6288
6503
|
if (!run) {
|
|
6289
6504
|
console.warn("Could not get text with name: '".concat(textName, "', at path:'").concat(path, "'"));
|
|
@@ -6308,8 +6523,13 @@ var Rive = /** @class */ (function () {
|
|
|
6308
6523
|
*
|
|
6309
6524
|
* @remarks
|
|
6310
6525
|
* If the text run cannot be found at the specified path, a warning will be logged to the console.
|
|
6526
|
+
*
|
|
6527
|
+
* @deprecated Text run APIs are deprecated: use data binding instead. See
|
|
6528
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide#updating-text-runs-at-runtime}
|
|
6529
|
+
* for how to migrate.
|
|
6311
6530
|
*/
|
|
6312
6531
|
Rive.prototype.setTextRunValueAtPath = function (textName, value, path) {
|
|
6532
|
+
warnOnce(textRunsDeprecationWarning);
|
|
6313
6533
|
var run = this.retrieveTextAtPath(textName, path);
|
|
6314
6534
|
if (!run) {
|
|
6315
6535
|
console.warn("Could not set text with name: '".concat(textName, "', at path:'").concat(path, "'"));
|
|
@@ -6418,10 +6638,26 @@ var Rive = /** @class */ (function () {
|
|
|
6418
6638
|
});
|
|
6419
6639
|
/**
|
|
6420
6640
|
* Subscribe to Rive-generated events
|
|
6641
|
+
*
|
|
6642
|
+
* Note: subscribing to {@link EventType.RiveEvent},
|
|
6643
|
+
* {@link EventType.StateChange}, or {@link EventType.Loop} is deprecated;
|
|
6644
|
+
* use data binding instead. See
|
|
6645
|
+
* {@link https://rive.app/docs/runtimes/web/rive-events} (Rive Events) and
|
|
6646
|
+
* {@link https://rive.app/docs/editor/data-binding/migration-guide} for how
|
|
6647
|
+
* to migrate Rive graphics to a data binding workflow instead.
|
|
6421
6648
|
* @param type the type of event to subscribe to
|
|
6422
6649
|
* @param callback callback to fire when the event occurs
|
|
6423
6650
|
*/
|
|
6424
6651
|
Rive.prototype.on = function (type, callback) {
|
|
6652
|
+
if (type === EventType.RiveEvent) {
|
|
6653
|
+
warnOnce(riveEventsDeprecationWarning);
|
|
6654
|
+
}
|
|
6655
|
+
else if (type === EventType.StateChange) {
|
|
6656
|
+
warnOnce(stateChangeEventsDeprecationWarning);
|
|
6657
|
+
}
|
|
6658
|
+
else if (type === EventType.Loop) {
|
|
6659
|
+
warnOnce(loopEventsDeprecationWarning);
|
|
6660
|
+
}
|
|
6425
6661
|
this.eventManager.add({
|
|
6426
6662
|
type: type,
|
|
6427
6663
|
callback: callback,
|