@remotion/rive 4.0.499 → 4.0.500
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
|
|
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
|
-
|
|
66
|
+
exports.riveCanvasSchema = {
|
|
67
67
|
...remotion_1.Internals.baseSchema,
|
|
68
68
|
fit: {
|
|
69
69
|
type: 'enum',
|
|
@@ -80,12 +80,12 @@ const riveCanvasSchema = {
|
|
|
80
80
|
...remotion_1.Internals.transformSchema,
|
|
81
81
|
...remotion_1.Interactive.backgroundSchema,
|
|
82
82
|
...remotion_1.Interactive.borderSchema,
|
|
83
|
+
...remotion_1.Interactive.cropSchema,
|
|
83
84
|
};
|
|
84
|
-
const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artboard: artboardName, animation: animationIndex, onLoad = null, assetLoader, enableRiveAssetCdn, className, style, effects, controls, }, ref) => {
|
|
85
|
+
const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artboard: artboardName, animation: animationIndex, onLoad = null, assetLoader, enableRiveAssetCdn, className, style, effects, controls, canvasRef, }, ref) => {
|
|
85
86
|
var _a;
|
|
86
87
|
const { width, fps, height } = (0, remotion_1.useVideoConfig)();
|
|
87
88
|
const frame = (0, remotion_1.useCurrentFrame)();
|
|
88
|
-
const canvas = (0, react_1.useRef)(null);
|
|
89
89
|
const [riveCanvasInstance, setRiveCanvas] = (0, react_1.useState)(null);
|
|
90
90
|
const [err, setError] = (0, react_1.useState)(null);
|
|
91
91
|
const { delayRender, continueRender } = (0, remotion_1.useDelayRender)();
|
|
@@ -198,7 +198,7 @@ const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artb
|
|
|
198
198
|
if (!riveCanvasInstance || !rive) {
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
|
-
const outputCanvas =
|
|
201
|
+
const outputCanvas = canvasRef.current;
|
|
202
202
|
if (!outputCanvas || !sourceCanvas) {
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
@@ -278,28 +278,38 @@ const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artb
|
|
|
278
278
|
delayRender,
|
|
279
279
|
continueRender,
|
|
280
280
|
src,
|
|
281
|
+
canvasRef,
|
|
281
282
|
]);
|
|
282
283
|
const canvasStyle = (0, react_1.useMemo)(() => ({
|
|
283
284
|
height,
|
|
284
285
|
width,
|
|
285
286
|
...style,
|
|
286
287
|
}), [height, style, width]);
|
|
287
|
-
return (jsx_runtime_1.jsx("canvas", { ref:
|
|
288
|
+
return (jsx_runtime_1.jsx("canvas", { ref: canvasRef, width: width, height: height, className: className, style: canvasStyle }));
|
|
288
289
|
};
|
|
289
290
|
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) => {
|
|
291
|
+
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
292
|
props;
|
|
292
293
|
const memoizedEffectDefinitions = useMemoizedEffectDefinitions(effects);
|
|
294
|
+
const canvasRef = (0, react_1.useRef)(null);
|
|
295
|
+
const croppedStyle = remotion_1.Internals.useCropStyle({
|
|
296
|
+
cropLeft,
|
|
297
|
+
cropRight,
|
|
298
|
+
cropTop,
|
|
299
|
+
cropBottom,
|
|
300
|
+
style: style !== null && style !== void 0 ? style : null,
|
|
301
|
+
componentName: '<RemotionRiveCanvas />',
|
|
302
|
+
});
|
|
293
303
|
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
304
|
? '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:
|
|
305
|
+
: 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
306
|
};
|
|
297
307
|
const RemotionRiveCanvasInner = (0, react_1.forwardRef)(RemotionRiveCanvasInnerForwardRefFunction);
|
|
298
308
|
exports.RemotionRiveCanvas = remotion_1.Interactive.withSchema({
|
|
299
309
|
Component: RemotionRiveCanvasInner,
|
|
300
310
|
componentName: '<RemotionRiveCanvas>',
|
|
301
311
|
componentIdentity: 'dev.remotion.rive.RemotionRiveCanvas',
|
|
302
|
-
schema: riveCanvasSchema,
|
|
312
|
+
schema: exports.riveCanvasSchema,
|
|
303
313
|
supportsEffects: true,
|
|
304
314
|
});
|
|
305
315
|
exports.RemotionRiveCanvas.displayName =
|
package/dist/esm/index.mjs
CHANGED
|
@@ -117,7 +117,8 @@ var riveCanvasSchema = {
|
|
|
117
117
|
},
|
|
118
118
|
...Internals.transformSchema,
|
|
119
119
|
...Interactive.backgroundSchema,
|
|
120
|
-
...Interactive.borderSchema
|
|
120
|
+
...Interactive.borderSchema,
|
|
121
|
+
...Interactive.cropSchema
|
|
121
122
|
};
|
|
122
123
|
var RemotionRiveCanvasContentForwardRefFunction = ({
|
|
123
124
|
src,
|
|
@@ -131,11 +132,11 @@ var RemotionRiveCanvasContentForwardRefFunction = ({
|
|
|
131
132
|
className,
|
|
132
133
|
style,
|
|
133
134
|
effects,
|
|
134
|
-
controls
|
|
135
|
+
controls,
|
|
136
|
+
canvasRef
|
|
135
137
|
}, ref) => {
|
|
136
138
|
const { width, fps, height } = useVideoConfig();
|
|
137
139
|
const frame = useCurrentFrame();
|
|
138
|
-
const canvas = useRef(null);
|
|
139
140
|
const [riveCanvasInstance, setRiveCanvas] = useState(null);
|
|
140
141
|
const [err, setError] = useState(null);
|
|
141
142
|
const { delayRender, continueRender } = useDelayRender();
|
|
@@ -226,7 +227,7 @@ var RemotionRiveCanvasContentForwardRefFunction = ({
|
|
|
226
227
|
if (!riveCanvasInstance || !rive) {
|
|
227
228
|
return;
|
|
228
229
|
}
|
|
229
|
-
const outputCanvas =
|
|
230
|
+
const outputCanvas = canvasRef.current;
|
|
230
231
|
if (!outputCanvas || !sourceCanvas) {
|
|
231
232
|
return;
|
|
232
233
|
}
|
|
@@ -294,7 +295,8 @@ var RemotionRiveCanvasContentForwardRefFunction = ({
|
|
|
294
295
|
chainState,
|
|
295
296
|
delayRender,
|
|
296
297
|
continueRender,
|
|
297
|
-
src
|
|
298
|
+
src,
|
|
299
|
+
canvasRef
|
|
298
300
|
]);
|
|
299
301
|
const canvasStyle = useMemo(() => ({
|
|
300
302
|
height,
|
|
@@ -302,7 +304,7 @@ var RemotionRiveCanvasContentForwardRefFunction = ({
|
|
|
302
304
|
...style
|
|
303
305
|
}), [height, style, width]);
|
|
304
306
|
return /* @__PURE__ */ jsx("canvas", {
|
|
305
|
-
ref:
|
|
307
|
+
ref: canvasRef,
|
|
306
308
|
width,
|
|
307
309
|
height,
|
|
308
310
|
className,
|
|
@@ -330,9 +332,22 @@ var RemotionRiveCanvasInnerForwardRefFunction = ({
|
|
|
330
332
|
freeze,
|
|
331
333
|
showInTimeline,
|
|
332
334
|
hidden,
|
|
335
|
+
cropLeft,
|
|
336
|
+
cropRight,
|
|
337
|
+
cropTop,
|
|
338
|
+
cropBottom,
|
|
333
339
|
...props
|
|
334
340
|
}, ref) => {
|
|
335
341
|
const memoizedEffectDefinitions = useMemoizedEffectDefinitions(effects);
|
|
342
|
+
const canvasRef = useRef(null);
|
|
343
|
+
const croppedStyle = Internals.useCropStyle({
|
|
344
|
+
cropLeft,
|
|
345
|
+
cropRight,
|
|
346
|
+
cropTop,
|
|
347
|
+
cropBottom,
|
|
348
|
+
style: style ?? null,
|
|
349
|
+
componentName: "<RemotionRiveCanvas />"
|
|
350
|
+
});
|
|
336
351
|
return /* @__PURE__ */ jsx(Sequence, {
|
|
337
352
|
layout: "none",
|
|
338
353
|
from,
|
|
@@ -345,6 +360,7 @@ var RemotionRiveCanvasInnerForwardRefFunction = ({
|
|
|
345
360
|
durationInFrames,
|
|
346
361
|
controls,
|
|
347
362
|
_remotionInternalEffects: memoizedEffectDefinitions,
|
|
363
|
+
outlineRef: canvasRef,
|
|
348
364
|
...props,
|
|
349
365
|
children: /* @__PURE__ */ jsx(RemotionRiveCanvasContent, {
|
|
350
366
|
ref,
|
|
@@ -357,9 +373,10 @@ var RemotionRiveCanvasInnerForwardRefFunction = ({
|
|
|
357
373
|
assetLoader,
|
|
358
374
|
enableRiveAssetCdn,
|
|
359
375
|
className,
|
|
360
|
-
style,
|
|
376
|
+
style: croppedStyle ?? undefined,
|
|
361
377
|
effects,
|
|
362
|
-
controls
|
|
378
|
+
controls,
|
|
379
|
+
canvasRef
|
|
363
380
|
})
|
|
364
381
|
});
|
|
365
382
|
};
|
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.
|
|
6
|
+
"version": "4.0.500",
|
|
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.
|
|
26
|
+
"remotion": "4.0.500"
|
|
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.
|
|
35
|
+
"@remotion/eslint-config-internal": "4.0.500",
|
|
35
36
|
"eslint": "9.19.0",
|
|
36
37
|
"@typescript/native-preview": "7.0.0-dev.20260217.1"
|
|
37
38
|
},
|