@rive-app/canvas-single 2.41.0 → 2.42.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/canvas-single",
3
- "version": "2.41.0",
3
+ "version": "2.42.0",
4
4
  "description": "Rive's high-level canvas based web api all in one js file.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.d.ts CHANGED
@@ -379,6 +379,17 @@ export interface RiveParameters {
379
379
  * Enum with drawing options for optimizations
380
380
  */
381
381
  drawingOptions?: DrawOptimizationOptions;
382
+ /**
383
+ * @experimental This API is early and may encounter breaking behavior change without a major version bump
384
+ *
385
+ * Render GPU Canvas content, which draws through the deferred renderer.
386
+ *
387
+ * Only applies when this instance loads its own file (`src`/`buffer`), where it
388
+ * is forwarded to that file as {@link RiveFileParameters.enableGPUCanvas}. With a
389
+ * supplied `riveFile` the file's own flag wins, since a file's mode is fixed at
390
+ * import. False by default.
391
+ */
392
+ enableGPUCanvas?: boolean;
382
393
  /**
383
394
  * Emit performance.mark / performance.measure entries for load lifecycle
384
395
  * events and the first 3 render frames. Useful for profiling Rive's
@@ -467,6 +478,14 @@ export interface RiveLoadParameters {
467
478
  tabIndex?: number;
468
479
  semanticsMode?: SemanticMode;
469
480
  semanticsOptions?: RiveSemanticsOptions;
481
+ /**
482
+ * @experimental This API is early and may encounter breaking behavior change without a major version bump
483
+ *
484
+ * Render GPU Canvas content, which draws through the deferred renderer. Forwarded
485
+ * to the file this instance loads; with a supplied `riveFile` the file's flag wins.
486
+ * False by default.
487
+ */
488
+ enableGPUCanvas?: boolean;
470
489
  }
471
490
  export interface RiveResetParameters {
472
491
  artboard?: string;
@@ -501,6 +520,19 @@ export interface RiveFileParameters {
501
520
  * events. False by default.
502
521
  */
503
522
  enablePerfMarks?: boolean;
523
+ /**
524
+ * @experimental This API is early and may encounter breaking behavior change without a major version bump
525
+ *
526
+ * Render GPU Canvas content in this file, importing it through a deferred
527
+ * rendering session.
528
+ *
529
+ * Fixed at import and has no setter: a file's resources are typed by the factory
530
+ * that made them and can never switch. The session records for the one canvas that
531
+ * displays the file, so a second Rive instance sharing this file re-imports it into
532
+ * a session of its own.
533
+ * False by default.
534
+ */
535
+ enableGPUCanvas?: boolean;
504
536
  }
505
537
  export declare class RiveFile implements rc.FinalizableTarget {
506
538
  private static readonly missingErrorMessage;
@@ -517,8 +549,15 @@ export declare class RiveFile implements rc.FinalizableTarget {
517
549
  private destroyed;
518
550
  selfUnref: boolean;
519
551
  private bindableArtboards;
552
+ private deferred;
553
+ private session;
554
+ private _sessionClaimed;
555
+ private fileFinalizer;
556
+ private boundElsewhereWarned;
557
+ private static deferredUnsupportedWarned;
520
558
  constructor(params: RiveFileParameters);
521
559
  private releaseFile;
560
+ private releaseSession;
522
561
  private releaseBindableArtboards;
523
562
  private initData;
524
563
  private loadRiveFileBytes;
@@ -538,6 +577,38 @@ export declare class RiveFile implements rc.FinalizableTarget {
538
577
  */
539
578
  off(type: EventType, callback: EventCallback): void;
540
579
  cleanup(): void;
580
+ private static makeDeferredSession;
581
+ /**
582
+ * @internal The deferred session this file imported through, or null if it
583
+ * was imported in immediate mode.
584
+ */
585
+ get deferredSession(): rc.DeferredSession | null;
586
+ /**
587
+ * @internal Whether deferred was asked for, even when this build could not
588
+ * honor it and imported immediate.
589
+ */
590
+ get deferredRequested(): boolean;
591
+ /**
592
+ * @internal Whether this file's session has ever been attached to a renderer.
593
+ * Attaching is once per session, so a claimed file re-imports for the next
594
+ * instance even after the renderer it was bound to is gone.
595
+ */
596
+ get sessionClaimed(): boolean;
597
+ /**
598
+ * @internal Marks this file's session as spent. There is no matching release:
599
+ * a session that has been attached can never replay for another renderer.
600
+ */
601
+ claimSession(): void;
602
+ /**
603
+ * @internal One warning per file however many instances collide on it.
604
+ */
605
+ warnBoundElsewhereOnce(): void;
606
+ /**
607
+ * @internal Re-imports this file from its retained buffer into a mode of its
608
+ * own. The copy is owned by whoever asked for it and never joins this file's
609
+ * reference count.
610
+ */
611
+ reimport(deferred: boolean): Promise<RiveFile>;
541
612
  /**
542
613
  * Unsubscribes all Rive listeners from an event type, or everything if no type is
543
614
  * given
@@ -582,6 +653,8 @@ export declare class Rive {
582
653
  */
583
654
  private readyForPlaying;
584
655
  private runtime;
656
+ private deferredRenderer;
657
+ private ownsRiveFile;
585
658
  private artboard;
586
659
  private eventCleanup;
587
660
  private _keyboardInteractions;
@@ -681,9 +754,18 @@ export declare class Rive {
681
754
  private initializeAudio;
682
755
  private initArtboardSize;
683
756
  private initData;
757
+ /**
758
+ * Settles which rendering mode this Rive instance runs in. The file dictates: its rendering mode
759
+ * is fixed at import, and an immediate renderer silently drops a deferred
760
+ * file's resources. Every mismatch warns and degrades to something that
761
+ * renders, so users shouldn't have a blank canvas. A fallback self-reimport replaces `this.riveFile`;
762
+ * only a file this instance imported is released when that happens.
763
+ */
764
+ private resolveDeferredRendering;
684
765
  private initArtboard;
685
766
  drawFrame(): void;
686
767
  private _canvasSizeChanged;
768
+ private _deferredWorkPending;
687
769
  /**
688
770
  * Poll focus state each frame to see if we should focus/blur the canvas in case
689
771
  * Rive internally updated focus outside of user interaction (e.g., via listener action)
@@ -723,11 +805,31 @@ export declare class Rive {
723
805
  * Rive class
724
806
  */
725
807
  cleanup(): void;
808
+ /**
809
+ * Drops this instance's hold on `this.riveFile`. A reference taken through
810
+ * getInstance() is given back; a file we imported but never referenced is
811
+ * released outright so its session goes with it. A caller-supplied file we
812
+ * never referenced is left alone.
813
+ *
814
+ * `isTeardown` distinguishes cleanup() from a reload. Teardown always hands
815
+ * the reference back, as it always has. A reload must not do that for a
816
+ * caller-supplied file: a RiveFile carries no reference for its creator, so
817
+ * releasing here would take the last one and destroy a file the caller still
818
+ * holds.
819
+ */
820
+ private releaseCurrentRiveFile;
726
821
  /**
727
822
  * Cleans up the Renderer object. Only call this API if you no longer
728
823
  * need to render Rive content in your session.
729
824
  */
730
825
  deleteRiveRenderer(): void;
826
+ /**
827
+ * @experimental This API is early and may encounter breaking behavior change without a major version bump
828
+ *
829
+ * Whether this instance is rendering through a deferred session. False whenever
830
+ * a fallback ran, whatever was requested.
831
+ */
832
+ get deferredRendererActive(): boolean;
731
833
  /**
732
834
  * Cleans up any Wasm-generated objects that need to be manually destroyed:
733
835
  * artboard instances, animation instances, state machine instances.