@rive-app/canvas-single 2.38.4 → 2.39.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 +118 -1
- package/rive.js +4624 -2337
- package/rive.js.map +1 -1
- package/rive_advanced.mjs.d.ts +131 -0
- package/utils/registerKeyboardInteractions.d.ts +31 -1
package/package.json
CHANGED
package/rive.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as rc from "./rive_advanced.mjs";
|
|
2
2
|
import { RuntimeLoader, type RuntimeCallback } from "./runtimeLoader";
|
|
3
|
+
import { SemanticTreeModel, AccessibilityOverlay, SemanticMode, type RiveSemanticsOptions } from "./semantics";
|
|
3
4
|
import { ImageWrapper, AudioWrapper, FontWrapper, RiveFont as RiveFontClassUtil } from "./utils";
|
|
4
5
|
export type AssetLoadCallback = (asset: rc.FileAsset, bytes: Uint8Array) => boolean;
|
|
5
6
|
export { RiveFontClassUtil as RiveFont };
|
|
7
|
+
export { SemanticMode };
|
|
8
|
+
export type { RiveSemanticsOptions };
|
|
6
9
|
export type { FileAsset, AudioAsset, FontAsset, ImageAsset, } from "./rive_advanced.mjs";
|
|
7
10
|
/**
|
|
8
11
|
* Generic type for a parameterless void callback
|
|
@@ -243,6 +246,19 @@ export interface RiveParameters {
|
|
|
243
246
|
* enabled by default.
|
|
244
247
|
*/
|
|
245
248
|
enableRiveAssetCDN?: boolean;
|
|
249
|
+
/**
|
|
250
|
+
* @experimental This API is early and may encounter breaking behavior change without a major version bump
|
|
251
|
+
*
|
|
252
|
+
* When to build semantic trees and the accessibility DOM overlay.
|
|
253
|
+
* Defaults to {@link SemanticMode.Disabled}.
|
|
254
|
+
*/
|
|
255
|
+
semanticsMode?: SemanticMode;
|
|
256
|
+
/**
|
|
257
|
+
* @experimental This API is early and may encounter breaking behavior change without a major version bump
|
|
258
|
+
*
|
|
259
|
+
* Optional options for the accessibility overlay container.
|
|
260
|
+
*/
|
|
261
|
+
semanticsOptions?: RiveSemanticsOptions;
|
|
246
262
|
/**
|
|
247
263
|
* Turn off Rive Listeners. This means state machines that have Listeners
|
|
248
264
|
* will not be invoked, and also, no event listeners pertaining to Listeners
|
|
@@ -340,6 +356,8 @@ export interface RiveLoadParameters {
|
|
|
340
356
|
useOffscreenRenderer?: boolean;
|
|
341
357
|
shouldDisableRiveListeners?: boolean;
|
|
342
358
|
tabIndex?: number;
|
|
359
|
+
semanticsMode?: SemanticMode;
|
|
360
|
+
semanticsOptions?: RiveSemanticsOptions;
|
|
343
361
|
}
|
|
344
362
|
export interface RiveResetParameters {
|
|
345
363
|
artboard?: string;
|
|
@@ -418,6 +436,10 @@ export declare class RiveFile implements rc.FinalizableTarget {
|
|
|
418
436
|
getDefaultBindableArtboard(): BindableArtboard | null;
|
|
419
437
|
internalBindableArtboardFromArtboard(artboard: rc.Artboard): BindableArtboard | null;
|
|
420
438
|
viewModelByName(name: string): ViewModel | null;
|
|
439
|
+
/**
|
|
440
|
+
* @returns the names of the file's global view models, in file order.
|
|
441
|
+
*/
|
|
442
|
+
globalViewModelNames(): string[];
|
|
421
443
|
}
|
|
422
444
|
export declare class Rive {
|
|
423
445
|
private readonly canvas;
|
|
@@ -453,6 +475,10 @@ export declare class Rive {
|
|
|
453
475
|
private dispatchPointerExit;
|
|
454
476
|
private enableMultiTouch;
|
|
455
477
|
private enableRiveAssetCDN;
|
|
478
|
+
private semanticsMode;
|
|
479
|
+
private semanticsOptions;
|
|
480
|
+
/** True when this instance may drain semantics and render the overlay. */
|
|
481
|
+
private _semanticsActive;
|
|
456
482
|
private _volume;
|
|
457
483
|
private _artboardWidth;
|
|
458
484
|
private _artboardHeight;
|
|
@@ -466,10 +492,21 @@ export declare class Rive {
|
|
|
466
492
|
private _pageVisibilityHandler;
|
|
467
493
|
private _explicitlyStoppedRendering;
|
|
468
494
|
private _viewModelInstance;
|
|
495
|
+
private _globalViewModelInstances;
|
|
469
496
|
private _dataEnums;
|
|
470
497
|
private _tabIndex;
|
|
471
498
|
private _prevHasFocus;
|
|
472
499
|
private _focusOptions;
|
|
500
|
+
private _semanticTree;
|
|
501
|
+
private _accessibilityOverlay;
|
|
502
|
+
/**
|
|
503
|
+
* True when an input to the accessibility overlay's artboard→canvas transform
|
|
504
|
+
* (layout fit/alignment/bounds, devicePixelRatio, or layout scale) has changed
|
|
505
|
+
* and the matrix must be recomputed on the next overlay update. Avoids calling
|
|
506
|
+
* computeAlignment every frame when only the semantic tree changed.
|
|
507
|
+
*/
|
|
508
|
+
private _overlayTransformDirty;
|
|
509
|
+
private readonly _instanceId;
|
|
473
510
|
private drawOptimization;
|
|
474
511
|
private enablePerfMarks;
|
|
475
512
|
durations: number[];
|
|
@@ -479,6 +516,21 @@ export declare class Rive {
|
|
|
479
516
|
constructor(params: RiveParameters);
|
|
480
517
|
get viewModelCount(): number;
|
|
481
518
|
static new(params: RiveParameters): Rive;
|
|
519
|
+
/**
|
|
520
|
+
* @experimental Turns on semantics and the accessibility overlay for this
|
|
521
|
+
* instance. Idempotent; safe to call before or after load. Use this to drive
|
|
522
|
+
* a consumer-controlled accessibility toggle when constructed with the
|
|
523
|
+
* default {@link SemanticMode.Disabled}.
|
|
524
|
+
*/
|
|
525
|
+
enableSemantics(): void;
|
|
526
|
+
private activateSemantics;
|
|
527
|
+
private syncSemanticsOnStateMachines;
|
|
528
|
+
/**
|
|
529
|
+
* Tears down the semantic tree and accessibility overlay. The overlay captures the
|
|
530
|
+
* active state machine in its action closures, so it must not outlive the
|
|
531
|
+
* instances it points at (reset/load delete them)
|
|
532
|
+
*/
|
|
533
|
+
private cleanupSemantics;
|
|
482
534
|
private onSystemAudioChanged;
|
|
483
535
|
private onCanvasResize;
|
|
484
536
|
private init;
|
|
@@ -489,6 +541,11 @@ export declare class Rive {
|
|
|
489
541
|
* i.e. { isTouchScrollEnabled: true }
|
|
490
542
|
*/
|
|
491
543
|
setupRiveListeners(riveListenerOptions?: SetupRiveListenersOptions): void;
|
|
544
|
+
/**
|
|
545
|
+
* Wire keyboard interactions when a playing state machine has focus nodes.
|
|
546
|
+
* Called at listener setup and lazily each frame so late-bound bindable artboards work.
|
|
547
|
+
*/
|
|
548
|
+
private ensureKeyboardInteractions;
|
|
492
549
|
private cleanupKeyboardInteractions;
|
|
493
550
|
/**
|
|
494
551
|
* Remove Rive Listeners setup on the canvas
|
|
@@ -621,6 +678,18 @@ export declare class Rive {
|
|
|
621
678
|
* Returns the name of the active artboard
|
|
622
679
|
*/
|
|
623
680
|
get activeArtboard(): string;
|
|
681
|
+
/**
|
|
682
|
+
* Returns the semantic tree model when semantics are enabled, or null.
|
|
683
|
+
* The overlay and external consumers use this to inspect the
|
|
684
|
+
* current state of the semantic tree.
|
|
685
|
+
*/
|
|
686
|
+
get semanticTree(): SemanticTreeModel | null;
|
|
687
|
+
/**
|
|
688
|
+
* Returns the accessibility overlay when semantics are enabled, or null.
|
|
689
|
+
* External consumers can use this to inspect the
|
|
690
|
+
* current state of the accessibility overlay for this instance.
|
|
691
|
+
*/
|
|
692
|
+
get accessibilityOverlay(): AccessibilityOverlay | null;
|
|
624
693
|
get animationNames(): string[];
|
|
625
694
|
/**
|
|
626
695
|
* Returns a list of state machine names from the current artboard
|
|
@@ -830,10 +899,47 @@ export declare class Rive {
|
|
|
830
899
|
get devicePixelRatioUsed(): number;
|
|
831
900
|
set devicePixelRatioUsed(value: number);
|
|
832
901
|
/**
|
|
833
|
-
*
|
|
902
|
+
* Sets the main view model instance and applies it (rebinds). Equivalent to
|
|
903
|
+
* `setViewModelInstance(vmi)` followed by `bind()`.
|
|
834
904
|
*/
|
|
835
905
|
bindViewModelInstance(viewModelInstance: ViewModelInstance | null): void;
|
|
906
|
+
/**
|
|
907
|
+
* Sets the main view model instance in the data context WITHOUT rebinding.
|
|
908
|
+
* Call {@link bind} to apply. Use this with {@link setGlobalViewModelInstance}
|
|
909
|
+
* to batch multiple changes into a single rebind.
|
|
910
|
+
*/
|
|
911
|
+
setViewModelInstance(viewModelInstance: ViewModelInstance | null): void;
|
|
912
|
+
/**
|
|
913
|
+
* Applies any pending `set*` view model instance changes by rebinding the
|
|
914
|
+
* data binds once.
|
|
915
|
+
* Implicitly creates and binds any view models that have not been set.
|
|
916
|
+
*/
|
|
917
|
+
bind(): void;
|
|
836
918
|
get viewModelInstance(): ViewModelInstance | null;
|
|
919
|
+
/**
|
|
920
|
+
* Sets (or replaces) the global view model instance for the given global view
|
|
921
|
+
* model name in the data context WITHOUT rebinding. The main instance and any
|
|
922
|
+
* other globals keep their order. Call {@link bind} to apply — batch several
|
|
923
|
+
* `set*` calls then a single `bind()` to avoid rebinding per set.
|
|
924
|
+
* @param name - the name of the global view model
|
|
925
|
+
* @param viewModelInstance - the instance to set for that global
|
|
926
|
+
* @returns whether the instance was set (false if `name` does not match a
|
|
927
|
+
* global view model in the file)
|
|
928
|
+
*/
|
|
929
|
+
setGlobalViewModelInstance(name: string, viewModelInstance: ViewModelInstance): boolean;
|
|
930
|
+
/**
|
|
931
|
+
* @param name - the name of the global view model
|
|
932
|
+
* @returns the global view model instance bound under the given name — the
|
|
933
|
+
* instance set via {@link setGlobalViewModelInstance} or one created by
|
|
934
|
+
* auto-bind — or null if none has been set/created for that name (globals are
|
|
935
|
+
* not auto-created; the getter never creates one).
|
|
936
|
+
*/
|
|
937
|
+
globalViewModelInstance(name: string): ViewModelInstance | null;
|
|
938
|
+
/**
|
|
939
|
+
* @returns the names of the file's global view models, in file order. Use
|
|
940
|
+
* these with {@link setGlobalViewModelInstance} / {@link globalViewModelInstance}.
|
|
941
|
+
*/
|
|
942
|
+
globalViewModelNames(): string[];
|
|
837
943
|
viewModelByIndex(index: number): ViewModel | null;
|
|
838
944
|
viewModelByName(name: string): ViewModel | null;
|
|
839
945
|
enums(): DataEnum[];
|
|
@@ -957,6 +1063,12 @@ export declare class ViewModelInstance {
|
|
|
957
1063
|
* @param path - path to the image property
|
|
958
1064
|
*/
|
|
959
1065
|
image(path: string): ViewModelInstanceAssetImage | null;
|
|
1066
|
+
/**
|
|
1067
|
+
* method to access a view model property instance belonging
|
|
1068
|
+
* to the view model instance or to a nested view model instance
|
|
1069
|
+
* @param path - path to the font property
|
|
1070
|
+
*/
|
|
1071
|
+
font(path: string): ViewModelInstanceAssetFont | null;
|
|
960
1072
|
/**
|
|
961
1073
|
* method to access an artboard property instance belonging
|
|
962
1074
|
* to the view model instance or to a nested view model instance
|
|
@@ -1058,6 +1170,11 @@ export declare class ViewModelInstanceAssetImage extends ViewModelInstanceValue
|
|
|
1058
1170
|
set value(image: rc.Image | null);
|
|
1059
1171
|
internalHandleCallback(callback: Function): void;
|
|
1060
1172
|
}
|
|
1173
|
+
export declare class ViewModelInstanceAssetFont extends ViewModelInstanceValue {
|
|
1174
|
+
constructor(instance: rc.ViewModelInstanceAssetFont, root: ViewModelInstance);
|
|
1175
|
+
set value(font: rc.Font | null);
|
|
1176
|
+
internalHandleCallback(callback: Function): void;
|
|
1177
|
+
}
|
|
1061
1178
|
export declare class ViewModelInstanceArtboard extends ViewModelInstanceValue {
|
|
1062
1179
|
constructor(instance: rc.ViewModelInstanceArtboard, root: ViewModelInstance);
|
|
1063
1180
|
set value(artboard: BaseArtboard | null);
|