@remotion/rive 4.0.499 → 4.0.501

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.
@@ -1,6 +1,6 @@
1
1
  import type { Artboard, CanvasRenderer, File, FileAsset, LinearAnimationInstance, RiveCanvas } from '@rive-app/canvas-advanced';
2
2
  import React from 'react';
3
- import type { EffectsProp, InteractiveBaseProps } from 'remotion';
3
+ import type { EffectsProp, InteractiveBaseProps, InteractiveCropProps, InteractivitySchema } from 'remotion';
4
4
  import type { RemotionRiveCanvasAlignment, RemotionRiveCanvasFit } from './map-enums.js';
5
5
  type assetLoadCallback = (asset: FileAsset, bytes: Uint8Array) => boolean;
6
6
  type onLoadCallback = (file: File) => void;
@@ -17,12 +17,13 @@ type RemotionRiveCanvasOwnProps = {
17
17
  readonly style?: React.CSSProperties;
18
18
  readonly effects?: EffectsProp;
19
19
  };
20
- export type RemotionRiveCanvasProps = RemotionRiveCanvasOwnProps & InteractiveBaseProps;
20
+ export type RemotionRiveCanvasProps = RemotionRiveCanvasOwnProps & InteractiveBaseProps & InteractiveCropProps;
21
21
  export type RiveCanvasRef = {
22
22
  getAnimationInstance: () => LinearAnimationInstance | null;
23
23
  getArtboard: () => Artboard | null;
24
24
  getRenderer: () => CanvasRenderer | null;
25
25
  getCanvas: () => RiveCanvas | null;
26
26
  };
27
- export declare const RemotionRiveCanvas: React.ForwardRefExoticComponent<RemotionRiveCanvasOwnProps & InteractiveBaseProps & React.RefAttributes<RiveCanvasRef>>;
27
+ export declare const riveCanvasSchema: InteractivitySchema;
28
+ export declare const RemotionRiveCanvas: React.ForwardRefExoticComponent<RemotionRiveCanvasOwnProps & InteractiveBaseProps & InteractiveCropProps & React.RefAttributes<RiveCanvasRef>>;
28
29
  export {};
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.RemotionRiveCanvas = void 0;
39
+ exports.RemotionRiveCanvas = exports.riveCanvasSchema = void 0;
40
40
  const jsx_runtime_1 = require("react/jsx-runtime");
41
41
  const canvas_advanced_1 = __importDefault(require("@rive-app/canvas-advanced"));
42
42
  const react_1 = __importStar(require("react"));
@@ -63,7 +63,7 @@ const riveAlignmentVariants = {
63
63
  'top-left': {},
64
64
  'top-right': {},
65
65
  };
66
- const riveCanvasSchema = {
66
+ exports.riveCanvasSchema = {
67
67
  ...remotion_1.Internals.baseSchema,
68
68
  fit: {
69
69
  type: 'enum',
@@ -80,12 +80,13 @@ const riveCanvasSchema = {
80
80
  ...remotion_1.Internals.transformSchema,
81
81
  ...remotion_1.Interactive.backgroundSchema,
82
82
  ...remotion_1.Interactive.borderSchema,
83
+ ...remotion_1.Interactive.borderRadiusSchema,
84
+ ...remotion_1.Interactive.cropSchema,
83
85
  };
84
- const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artboard: artboardName, animation: animationIndex, onLoad = null, assetLoader, enableRiveAssetCdn, className, style, effects, controls, }, ref) => {
86
+ const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artboard: artboardName, animation: animationIndex, onLoad = null, assetLoader, enableRiveAssetCdn, className, style, effects, controls, canvasRef, }, ref) => {
85
87
  var _a;
86
88
  const { width, fps, height } = (0, remotion_1.useVideoConfig)();
87
89
  const frame = (0, remotion_1.useCurrentFrame)();
88
- const canvas = (0, react_1.useRef)(null);
89
90
  const [riveCanvasInstance, setRiveCanvas] = (0, react_1.useState)(null);
90
91
  const [err, setError] = (0, react_1.useState)(null);
91
92
  const { delayRender, continueRender } = (0, remotion_1.useDelayRender)();
@@ -198,7 +199,7 @@ const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artb
198
199
  if (!riveCanvasInstance || !rive) {
199
200
  return;
200
201
  }
201
- const outputCanvas = canvas.current;
202
+ const outputCanvas = canvasRef.current;
202
203
  if (!outputCanvas || !sourceCanvas) {
203
204
  return;
204
205
  }
@@ -278,28 +279,38 @@ const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artb
278
279
  delayRender,
279
280
  continueRender,
280
281
  src,
282
+ canvasRef,
281
283
  ]);
282
284
  const canvasStyle = (0, react_1.useMemo)(() => ({
283
285
  height,
284
286
  width,
285
287
  ...style,
286
288
  }), [height, style, width]);
287
- return (jsx_runtime_1.jsx("canvas", { ref: canvas, width: width, height: height, className: className, style: canvasStyle }));
289
+ return (jsx_runtime_1.jsx("canvas", { ref: canvasRef, width: width, height: height, className: className, style: canvasStyle }));
288
290
  };
289
291
  const RemotionRiveCanvasContent = (0, react_1.forwardRef)(RemotionRiveCanvasContentForwardRefFunction);
290
- const RemotionRiveCanvasInnerForwardRefFunction = ({ src, fit = 'contain', alignment = 'center', artboard, animation, onLoad = null, assetLoader, enableRiveAssetCdn = true, className, style, effects = [], controls, durationInFrames, name, from, trimBefore, freeze, showInTimeline, hidden, ...props }, ref) => {
292
+ const RemotionRiveCanvasInnerForwardRefFunction = ({ src, fit = 'contain', alignment = 'center', artboard, animation, onLoad = null, assetLoader, enableRiveAssetCdn = true, className, style, effects = [], controls, durationInFrames, name, from, trimBefore, freeze, showInTimeline, hidden, cropLeft, cropRight, cropTop, cropBottom, ...props }, ref) => {
291
293
  props;
292
294
  const memoizedEffectDefinitions = useMemoizedEffectDefinitions(effects);
295
+ const canvasRef = (0, react_1.useRef)(null);
296
+ const croppedStyle = remotion_1.Internals.useCropStyle({
297
+ cropLeft,
298
+ cropRight,
299
+ cropTop,
300
+ cropBottom,
301
+ style: style !== null && style !== void 0 ? style : null,
302
+ componentName: '<RemotionRiveCanvas />',
303
+ });
293
304
  return (jsx_runtime_1.jsx(remotion_1.Sequence, { layout: "none", from: from, trimBefore: trimBefore, freeze: freeze, hidden: hidden, showInTimeline: showInTimeline, name: name !== null && name !== void 0 ? name : '<RemotionRiveCanvas>', _remotionInternalDocumentationLink: name === undefined
294
305
  ? 'https://www.remotion.dev/docs/rive/remotionrivecanvas'
295
- : undefined, durationInFrames: durationInFrames, controls: controls, _remotionInternalEffects: memoizedEffectDefinitions, ...props, children: jsx_runtime_1.jsx(RemotionRiveCanvasContent, { ref: ref, src: src, fit: fit, alignment: alignment, artboard: artboard, animation: animation, onLoad: onLoad, assetLoader: assetLoader, enableRiveAssetCdn: enableRiveAssetCdn, className: className, style: style, effects: effects, controls: controls }) }));
306
+ : undefined, durationInFrames: durationInFrames, controls: controls, _remotionInternalEffects: memoizedEffectDefinitions, outlineRef: canvasRef, ...props, children: jsx_runtime_1.jsx(RemotionRiveCanvasContent, { ref: ref, src: src, fit: fit, alignment: alignment, artboard: artboard, animation: animation, onLoad: onLoad, assetLoader: assetLoader, enableRiveAssetCdn: enableRiveAssetCdn, className: className, style: croppedStyle !== null && croppedStyle !== void 0 ? croppedStyle : undefined, effects: effects, controls: controls, canvasRef: canvasRef }) }));
296
307
  };
297
308
  const RemotionRiveCanvasInner = (0, react_1.forwardRef)(RemotionRiveCanvasInnerForwardRefFunction);
298
309
  exports.RemotionRiveCanvas = remotion_1.Interactive.withSchema({
299
310
  Component: RemotionRiveCanvasInner,
300
311
  componentName: '<RemotionRiveCanvas>',
301
312
  componentIdentity: 'dev.remotion.rive.RemotionRiveCanvas',
302
- schema: riveCanvasSchema,
313
+ schema: exports.riveCanvasSchema,
303
314
  supportsEffects: true,
304
315
  });
305
316
  exports.RemotionRiveCanvas.displayName =
@@ -117,7 +117,9 @@ var riveCanvasSchema = {
117
117
  },
118
118
  ...Internals.transformSchema,
119
119
  ...Interactive.backgroundSchema,
120
- ...Interactive.borderSchema
120
+ ...Interactive.borderSchema,
121
+ ...Interactive.borderRadiusSchema,
122
+ ...Interactive.cropSchema
121
123
  };
122
124
  var RemotionRiveCanvasContentForwardRefFunction = ({
123
125
  src,
@@ -131,11 +133,11 @@ var RemotionRiveCanvasContentForwardRefFunction = ({
131
133
  className,
132
134
  style,
133
135
  effects,
134
- controls
136
+ controls,
137
+ canvasRef
135
138
  }, ref) => {
136
139
  const { width, fps, height } = useVideoConfig();
137
140
  const frame = useCurrentFrame();
138
- const canvas = useRef(null);
139
141
  const [riveCanvasInstance, setRiveCanvas] = useState(null);
140
142
  const [err, setError] = useState(null);
141
143
  const { delayRender, continueRender } = useDelayRender();
@@ -226,7 +228,7 @@ var RemotionRiveCanvasContentForwardRefFunction = ({
226
228
  if (!riveCanvasInstance || !rive) {
227
229
  return;
228
230
  }
229
- const outputCanvas = canvas.current;
231
+ const outputCanvas = canvasRef.current;
230
232
  if (!outputCanvas || !sourceCanvas) {
231
233
  return;
232
234
  }
@@ -294,7 +296,8 @@ var RemotionRiveCanvasContentForwardRefFunction = ({
294
296
  chainState,
295
297
  delayRender,
296
298
  continueRender,
297
- src
299
+ src,
300
+ canvasRef
298
301
  ]);
299
302
  const canvasStyle = useMemo(() => ({
300
303
  height,
@@ -302,7 +305,7 @@ var RemotionRiveCanvasContentForwardRefFunction = ({
302
305
  ...style
303
306
  }), [height, style, width]);
304
307
  return /* @__PURE__ */ jsx("canvas", {
305
- ref: canvas,
308
+ ref: canvasRef,
306
309
  width,
307
310
  height,
308
311
  className,
@@ -330,9 +333,22 @@ var RemotionRiveCanvasInnerForwardRefFunction = ({
330
333
  freeze,
331
334
  showInTimeline,
332
335
  hidden,
336
+ cropLeft,
337
+ cropRight,
338
+ cropTop,
339
+ cropBottom,
333
340
  ...props
334
341
  }, ref) => {
335
342
  const memoizedEffectDefinitions = useMemoizedEffectDefinitions(effects);
343
+ const canvasRef = useRef(null);
344
+ const croppedStyle = Internals.useCropStyle({
345
+ cropLeft,
346
+ cropRight,
347
+ cropTop,
348
+ cropBottom,
349
+ style: style ?? null,
350
+ componentName: "<RemotionRiveCanvas />"
351
+ });
336
352
  return /* @__PURE__ */ jsx(Sequence, {
337
353
  layout: "none",
338
354
  from,
@@ -345,6 +361,7 @@ var RemotionRiveCanvasInnerForwardRefFunction = ({
345
361
  durationInFrames,
346
362
  controls,
347
363
  _remotionInternalEffects: memoizedEffectDefinitions,
364
+ outlineRef: canvasRef,
348
365
  ...props,
349
366
  children: /* @__PURE__ */ jsx(RemotionRiveCanvasContent, {
350
367
  ref,
@@ -357,9 +374,10 @@ var RemotionRiveCanvasInnerForwardRefFunction = ({
357
374
  assetLoader,
358
375
  enableRiveAssetCdn,
359
376
  className,
360
- style,
377
+ style: croppedStyle ?? undefined,
361
378
  effects,
362
- controls
379
+ controls,
380
+ canvasRef
363
381
  })
364
382
  });
365
383
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/rive"
4
4
  },
5
5
  "name": "@remotion/rive",
6
- "version": "4.0.499",
6
+ "version": "4.0.501",
7
7
  "description": "Embed Rive animations in a Remotion video",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",
@@ -12,6 +12,7 @@
12
12
  "formatting": "oxfmt src --check",
13
13
  "format": "oxfmt src",
14
14
  "lint": "eslint src",
15
+ "test": "bun test src/test",
15
16
  "make": "tsgo -d && bun --env-file=../.env.bundle bundle.ts"
16
17
  },
17
18
  "bugs": {
@@ -22,7 +23,7 @@
22
23
  "license": "See LICENSE.md",
23
24
  "dependencies": {
24
25
  "@rive-app/canvas-advanced": "2.31.5",
25
- "remotion": "4.0.499"
26
+ "remotion": "4.0.501"
26
27
  },
27
28
  "peerDependencies": {
28
29
  "react": ">=18.2.0",
@@ -31,7 +32,7 @@
31
32
  "devDependencies": {
32
33
  "react": "19.2.3",
33
34
  "react-dom": "19.2.3",
34
- "@remotion/eslint-config-internal": "4.0.499",
35
+ "@remotion/eslint-config-internal": "4.0.501",
35
36
  "eslint": "9.19.0",
36
37
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
37
38
  },