@rive-app/canvas-single 2.50.0 → 2.51.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.
@@ -26,8 +26,6 @@ export default Rive;
26
26
  export interface ScriptFetchConfig {
27
27
  proxyUrl: string | null;
28
28
  allowedHosts: string[] | null;
29
- /** 0 is no limit. */
30
- maxRequestsPerMinute: number;
31
29
  /** 0 keeps the runtime's default. */
32
30
  maxResponseBytes: number;
33
31
  }
@@ -62,8 +60,12 @@ export interface RiveCanvas {
62
60
  decodeAudio: DecodeAudio;
63
61
  decodeImage: DecodeImage;
64
62
  decodeFont: DecodeFont;
65
- // Returns a pointer value to the FontWrapper
66
- setFallbackFontCallback: (callback: (missingGlyph: number, fallbackFontIndex: number, weight: number) => number | null) => void;
63
+ // Returns a pointer value to the FontWrapper. [languages] are BCP 47 tags,
64
+ // the text's own language first, then the system languages.
65
+ setFallbackFontCallback: (callback: (missingGlyph: number, fallbackFontIndex: number, weight: number, languages: string[]) => number | null) => void;
66
+ // The preferred languages text without a language of its own shapes and
67
+ // falls back with, most preferred first.
68
+ setSystemLanguages: (languages: string[]) => void;
67
69
 
68
70
  /**
69
71
  * @experimental Creates a deferred recording session. Only present in builds
@@ -118,6 +120,9 @@ export interface RiveCanvas {
118
120
  * @param enableRiveAssetCDN - boolean flag to allow loading assets from the Rive CDN, enabled by default.
119
121
  * @param session - @experimental Deferred session to import through. The file's mode is fixed
120
122
  * at import: pass null (the default) for an immediate file.
123
+ * @param deferDecoding - Decode animations, artboards (other than the default
124
+ * one) and file level view model instances the first time they're used instead of at import.
125
+ * False by default.
121
126
  * @returns A Promise for a Rive File class
122
127
  */
123
128
  load(
@@ -125,6 +130,7 @@ export interface RiveCanvas {
125
130
  assetLoader?: FileAssetLoader,
126
131
  enableRiveAssetCDN?: boolean,
127
132
  session?: DeferredSession | null,
133
+ deferDecoding?: boolean,
128
134
  ): Promise<File>;
129
135
 
130
136
  /**
@@ -167,9 +173,14 @@ export interface RiveCanvas {
167
173
  * A Rive-specific requestAnimationFrame function; this must be used instead of the global
168
174
  * requestAnimationFrame function.
169
175
  * @param cb - Callback function to call with an elapsed timestamp
176
+ * @param onWorker - True when the caller's renderer draws on the replay
177
+ * worker (`replaysOnWorker()`), so a worker's frames pace it
170
178
  * @returns number - An ID of the requestAnimationFrame request
171
179
  */
172
- requestAnimationFrame(cb: (timestamp: DOMHighResTimeStamp) => void): number;
180
+ requestAnimationFrame(
181
+ cb: (timestamp: DOMHighResTimeStamp) => void,
182
+ onWorker?: boolean,
183
+ ): number;
173
184
  /**
174
185
  * A Rive-specific cancelAnimationFrame function; this must be used instead of the global
175
186
  * cancelAnimationFrame function.
@@ -338,7 +349,7 @@ export declare class RendererWrapper {
338
349
  acceptsFrame?(): boolean;
339
350
  /**
340
351
  * @experimental How long the replay worker's recent frames took to finish,
341
- * in milliseconds, or 0 before its first.
352
+ * in milliseconds, or 0 before its third.
342
353
  */
343
354
  replayMs?(): number;
344
355
  /**
@@ -1167,7 +1178,7 @@ export declare class StateMachineInstance {
1167
1178
  * @param dy - Vertical distance the content moves, in Artboard pixels. Revealing content below
1168
1179
  * is negative.
1169
1180
  * @param phase - Where the event sits within its gesture: 0 begin, 1 update, 2 end,
1170
- * 3 momentum, 4 inertiaCancel. A phaseless wheel only ever sends 1 (update).
1181
+ * 3 momentum, 4 inertiaCancel. A phaseless wheel sends 1 (update), or 3 for momentum.
1171
1182
  * @param precise - True for a pixel-precise source such as a trackpad, false for a detented
1172
1183
  * wheel.
1173
1184
  * @param timeStamp - Event time in seconds.
@@ -26,12 +26,6 @@ export interface ScriptFetchOptions {
26
26
  * only allowed when named, e.g. `["*", "www.example.com"]`.
27
27
  */
28
28
  allowedHosts?: string[];
29
- /**
30
- * Requests scripts may start per minute, counted per scripting VM, so
31
- * scripts that share one share the limit. Requests past it wait their turn
32
- * rather than fail. 0 is no limit. Default 60.
33
- */
34
- maxRequestsPerMinute?: number;
35
29
  /**
36
30
  * Largest response body, in bytes, up to 64 MiB. 0 keeps the default of
37
31
  * 16 MiB.
@@ -62,6 +56,10 @@ export declare class RuntimeLoader {
62
56
  */
63
57
  static enablePerfMarks: boolean;
64
58
  private static notifyError;
59
+ private static systemLanguages;
60
+ private static listeningForLanguageChange;
61
+ static setSystemLanguages(languages: readonly string[] | null): void;
62
+ private static applySystemLanguages;
65
63
  private static loaded;
66
64
  private static loadRuntime;
67
65
  private static loadUnthreaded;
@@ -1,5 +1,5 @@
1
1
  import type { FontWrapper } from "./finalizationRegistry";
2
- export type FallbackFontsCallback = (missingGlyph: number, weight: number) => FontWrapper | FontWrapper[] | null | undefined;
2
+ export type FallbackFontsCallback = (missingGlyph: number, weight: number, languages: string[]) => FontWrapper | FontWrapper[] | null | undefined;
3
3
  export declare class RiveFont {
4
4
  private static _fallbackFontCallback;
5
5
  private constructor();
@@ -9,6 +9,15 @@ export declare class RiveFont {
9
9
  * @param fontCallback Callback to set a list of fallback fonts.
10
10
  */
11
11
  static setFallbackFontCallback(fontCallback: FallbackFontsCallback | null): void;
12
+ /**
13
+ * Set the preferred languages (BCP 47 tags, most preferred first) that text
14
+ * without a `language` of its own shapes and falls back with, like
15
+ * `navigator.languages` is for a page. Pass nothing to follow
16
+ * `navigator.languages`, which is also what happens until this is called,
17
+ * including when the browser's languages change.
18
+ * @param languages The languages to use, or nothing for the browser's.
19
+ */
20
+ static setSystemLanguages(languages?: readonly string[] | null): void;
12
21
  private static _fontToPtr;
13
22
  private static _getFallbackPtr;
14
23
  private static _wireFallbackProc;
@@ -0,0 +1,15 @@
1
+ /** Tells the platform's momentum from the fingers in pixel wheel events. */
2
+ export declare class WheelMomentumDetector {
3
+ private lastTime;
4
+ private lastX;
5
+ private lastY;
6
+ private base;
7
+ private peak;
8
+ private falls;
9
+ private rises;
10
+ private heldSince;
11
+ private momentum;
12
+ reset(): void;
13
+ isMomentum(event: WheelEvent, deltaX: number, deltaY: number): boolean;
14
+ private restart;
15
+ }