@remotion/rive 4.0.534 → 4.0.535
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/dist/cjs/RemotionRiveCanvas.js +46 -53
- package/dist/esm/index.mjs +46 -17
- package/package.json +3 -3
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -39,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
6
|
exports.RemotionRiveCanvas = exports.riveCanvasSchema = void 0;
|
|
40
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
8
|
const canvas_advanced_1 = __importDefault(require("@rive-app/canvas-advanced"));
|
|
42
|
-
const react_1 =
|
|
9
|
+
const react_1 = require("react");
|
|
43
10
|
const remotion_1 = require("remotion");
|
|
44
11
|
const map_enums_js_1 = require("./map-enums.js");
|
|
45
12
|
const { runEffectChain, useEffectChainState, useMemoizedEffectDefinitions, useMemoizedEffects, } = remotion_1.Internals;
|
|
@@ -85,13 +52,13 @@ exports.riveCanvasSchema = {
|
|
|
85
52
|
...remotion_1.Interactive.cropSchema,
|
|
86
53
|
};
|
|
87
54
|
const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artboard: artboardName, animation: animationIndex, onLoad = null, assetLoader, enableRiveAssetCdn, className, style, effects, controls, canvasRef, }, ref) => {
|
|
88
|
-
var _a, _b;
|
|
55
|
+
var _a, _b, _c;
|
|
89
56
|
const { width, fps, height } = (0, remotion_1.useVideoConfig)();
|
|
90
57
|
const frame = (0, remotion_1.useCurrentFrame)();
|
|
91
|
-
const [
|
|
58
|
+
const [loadedRuntime, setLoadedRuntime] = (0, react_1.useState)(null);
|
|
59
|
+
const riveCanvasInstance = (_a = loadedRuntime === null || loadedRuntime === void 0 ? void 0 : loadedRuntime.instance) !== null && _a !== void 0 ? _a : null;
|
|
92
60
|
const [err, setError] = (0, react_1.useState)(null);
|
|
93
61
|
const { delayRender, continueRender } = (0, remotion_1.useDelayRender)();
|
|
94
|
-
const [handle] = (0, react_1.useState)(() => delayRender());
|
|
95
62
|
const lastFrame = (0, react_1.useRef)(0);
|
|
96
63
|
// Rive draws to this offscreen-style canvas; the effect chain then
|
|
97
64
|
// composites from here onto the visible output canvas.
|
|
@@ -104,8 +71,8 @@ const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artb
|
|
|
104
71
|
const chainState = useEffectChainState();
|
|
105
72
|
const memoizedEffects = useMemoizedEffects({
|
|
106
73
|
effects,
|
|
107
|
-
overrideId: (
|
|
108
|
-
videoConfigValues: (
|
|
74
|
+
overrideId: (_b = controls === null || controls === void 0 ? void 0 : controls.overrideId) !== null && _b !== void 0 ? _b : null,
|
|
75
|
+
videoConfigValues: (_c = controls === null || controls === void 0 ? void 0 : controls.videoConfigValues) !== null && _c !== void 0 ? _c : null,
|
|
109
76
|
});
|
|
110
77
|
if (err) {
|
|
111
78
|
throw err;
|
|
@@ -130,35 +97,51 @@ const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artb
|
|
|
130
97
|
},
|
|
131
98
|
};
|
|
132
99
|
}, [rive, riveCanvasInstance]);
|
|
133
|
-
(0, react_1.
|
|
100
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
101
|
+
const handle = delayRender('Loading Rive runtime');
|
|
102
|
+
let cancelled = false;
|
|
134
103
|
(0, canvas_advanced_1.default)({
|
|
135
104
|
locateFile: () => 'https://unpkg.com/@rive-app/canvas-advanced@2.31.5/rive.wasm',
|
|
136
105
|
})
|
|
137
106
|
.then((riveInstance) => {
|
|
138
|
-
|
|
139
|
-
|
|
107
|
+
if (!cancelled) {
|
|
108
|
+
setLoadedRuntime({ instance: riveInstance, handle });
|
|
109
|
+
}
|
|
140
110
|
})
|
|
141
111
|
.catch((newErr) => {
|
|
142
|
-
|
|
112
|
+
if (!cancelled) {
|
|
113
|
+
setError(newErr);
|
|
114
|
+
}
|
|
143
115
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
116
|
+
return () => {
|
|
117
|
+
cancelled = true;
|
|
118
|
+
continueRender(handle);
|
|
119
|
+
};
|
|
120
|
+
}, [delayRender, continueRender]);
|
|
121
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
122
|
+
if (!riveCanvasInstance || !sourceCanvas || !loadedRuntime) {
|
|
147
123
|
return;
|
|
148
124
|
}
|
|
125
|
+
const handle = delayRender(`Loading <RemotionRiveCanvas src="${src}"/>`);
|
|
126
|
+
continueRender(loadedRuntime.handle);
|
|
127
|
+
let cancelled = false;
|
|
128
|
+
const controller = new AbortController();
|
|
149
129
|
sourceCanvas.width = width;
|
|
150
130
|
sourceCanvas.height = height;
|
|
151
131
|
const renderer = riveCanvasInstance.makeRenderer(sourceCanvas);
|
|
152
|
-
fetch(new Request(src))
|
|
132
|
+
fetch(new Request(src), { signal: controller.signal })
|
|
153
133
|
.then((f) => f.arrayBuffer())
|
|
154
134
|
.then((b) => {
|
|
155
|
-
riveCanvasInstance
|
|
135
|
+
return riveCanvasInstance
|
|
156
136
|
.load(new Uint8Array(b), assetLoader
|
|
157
137
|
? new riveCanvasInstance.CustomFileAssetLoader({
|
|
158
138
|
loadContents: assetLoader,
|
|
159
139
|
})
|
|
160
140
|
: undefined, enableRiveAssetCdn)
|
|
161
141
|
.then((file) => {
|
|
142
|
+
if (cancelled) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
162
145
|
const artboard = typeof artboardName === 'string'
|
|
163
146
|
? file.artboardByName(artboardName)
|
|
164
147
|
: typeof artboardName === 'number'
|
|
@@ -174,12 +157,20 @@ const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artb
|
|
|
174
157
|
artboard,
|
|
175
158
|
renderer,
|
|
176
159
|
file,
|
|
160
|
+
handle,
|
|
177
161
|
});
|
|
178
162
|
});
|
|
179
163
|
})
|
|
180
164
|
.catch((newErr) => {
|
|
181
|
-
|
|
165
|
+
if (!cancelled) {
|
|
166
|
+
setError(newErr);
|
|
167
|
+
}
|
|
182
168
|
});
|
|
169
|
+
return () => {
|
|
170
|
+
cancelled = true;
|
|
171
|
+
controller.abort();
|
|
172
|
+
continueRender(handle);
|
|
173
|
+
};
|
|
183
174
|
}, [
|
|
184
175
|
animationIndex,
|
|
185
176
|
artboardName,
|
|
@@ -191,13 +182,16 @@ const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artb
|
|
|
191
182
|
sourceCanvas,
|
|
192
183
|
width,
|
|
193
184
|
height,
|
|
185
|
+
loadedRuntime,
|
|
186
|
+
delayRender,
|
|
187
|
+
continueRender,
|
|
194
188
|
]);
|
|
195
189
|
(0, react_1.useEffect)(() => {
|
|
196
190
|
if (onLoad && rive) {
|
|
197
191
|
onLoad(rive.file);
|
|
198
192
|
}
|
|
199
193
|
}, [onLoad, rive]);
|
|
200
|
-
react_1.
|
|
194
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
201
195
|
if (!riveCanvasInstance || !rive) {
|
|
202
196
|
return;
|
|
203
197
|
}
|
|
@@ -245,6 +239,7 @@ const RemotionRiveCanvasContentForwardRefFunction = ({ src, fit, alignment, artb
|
|
|
245
239
|
return;
|
|
246
240
|
}
|
|
247
241
|
const effectChainHandle = delayRender(`Rendering frame at ${frame} of <RemotionRiveCanvas src="${src}"/>`);
|
|
242
|
+
continueRender(rive.handle);
|
|
248
243
|
let cancelled = false;
|
|
249
244
|
runEffectChain({
|
|
250
245
|
state,
|
|
@@ -317,9 +312,7 @@ const RemotionRiveCanvasInnerForwardRefFunction = ({ src, fit = 'contain', align
|
|
|
317
312
|
style: premountingStyle,
|
|
318
313
|
componentName: '<RemotionRiveCanvas />',
|
|
319
314
|
});
|
|
320
|
-
return (jsx_runtime_1.jsx(remotion_1.Freeze, { frame: freezeFrame, active: isPremountingOrPostmounting, children: jsx_runtime_1.jsx(remotion_1.Sequence, { layout: "none", from: from, trimBefore: trimBefore, playbackRate: playbackRate, loop: loop, freeze: freeze, hidden: hidden, showInTimeline: showInTimeline, name: name !== null && name !== void 0 ? name : '<RemotionRiveCanvas>', _remotionInternalDocumentationLink:
|
|
321
|
-
? 'https://www.remotion.dev/docs/rive/remotionrivecanvas'
|
|
322
|
-
: undefined, durationInFrames: durationInFrames, controls: controls, _remotionInternalEffects: memoizedEffectDefinitions, ...props, _remotionInternalPremountDisplay: effectivePremountFor || null, _remotionInternalPostmountDisplay: effectivePostmountFor || null, _remotionInternalIsPremounting: premountingActive, _remotionInternalIsPostmounting: postmountingActive, 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 }) }) }));
|
|
315
|
+
return (jsx_runtime_1.jsx(remotion_1.Freeze, { frame: freezeFrame, active: isPremountingOrPostmounting, children: jsx_runtime_1.jsx(remotion_1.Sequence, { layout: "none", from: from, trimBefore: trimBefore, playbackRate: playbackRate, loop: loop, freeze: freeze, hidden: hidden, showInTimeline: showInTimeline, name: name !== null && name !== void 0 ? name : '<RemotionRiveCanvas>', _remotionInternalDocumentationLink: "https://www.remotion.dev/docs/rive/remotionrivecanvas", durationInFrames: durationInFrames, controls: controls, _remotionInternalEffects: memoizedEffectDefinitions, ...props, _remotionInternalPremountDisplay: effectivePremountFor || null, _remotionInternalPostmountDisplay: effectivePostmountFor || null, _remotionInternalIsPremounting: premountingActive, _remotionInternalIsPostmounting: postmountingActive, 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 }) }) }));
|
|
323
316
|
};
|
|
324
317
|
const RemotionRiveCanvasInner = (0, react_1.forwardRef)(RemotionRiveCanvasInnerForwardRefFunction);
|
|
325
318
|
exports.RemotionRiveCanvas = remotion_1.Interactive.withSchema({
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// src/RemotionRiveCanvas.tsx
|
|
2
2
|
import riveCanvas from "@rive-app/canvas-advanced";
|
|
3
|
-
import
|
|
3
|
+
import {
|
|
4
4
|
forwardRef,
|
|
5
5
|
useEffect,
|
|
6
6
|
useImperativeHandle,
|
|
7
|
+
useLayoutEffect,
|
|
7
8
|
useMemo,
|
|
8
9
|
useRef,
|
|
9
10
|
useState
|
|
@@ -140,10 +141,10 @@ var RemotionRiveCanvasContentForwardRefFunction = ({
|
|
|
140
141
|
}, ref) => {
|
|
141
142
|
const { width, fps, height } = useVideoConfig();
|
|
142
143
|
const frame = useCurrentFrame();
|
|
143
|
-
const [
|
|
144
|
+
const [loadedRuntime, setLoadedRuntime] = useState(null);
|
|
145
|
+
const riveCanvasInstance = loadedRuntime?.instance ?? null;
|
|
144
146
|
const [err, setError] = useState(null);
|
|
145
147
|
const { delayRender, continueRender } = useDelayRender();
|
|
146
|
-
const [handle] = useState(() => delayRender());
|
|
147
148
|
const lastFrame = useRef(0);
|
|
148
149
|
const sourceCanvas = useMemo(() => {
|
|
149
150
|
if (typeof document === "undefined") {
|
|
@@ -177,39 +178,63 @@ var RemotionRiveCanvasContentForwardRefFunction = ({
|
|
|
177
178
|
}
|
|
178
179
|
};
|
|
179
180
|
}, [rive, riveCanvasInstance]);
|
|
180
|
-
|
|
181
|
+
useLayoutEffect(() => {
|
|
182
|
+
const handle = delayRender("Loading Rive runtime");
|
|
183
|
+
let cancelled = false;
|
|
181
184
|
riveCanvas({
|
|
182
185
|
locateFile: () => "https://unpkg.com/@rive-app/canvas-advanced@2.31.5/rive.wasm"
|
|
183
186
|
}).then((riveInstance) => {
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
if (!cancelled) {
|
|
188
|
+
setLoadedRuntime({ instance: riveInstance, handle });
|
|
189
|
+
}
|
|
186
190
|
}).catch((newErr) => {
|
|
187
|
-
|
|
191
|
+
if (!cancelled) {
|
|
192
|
+
setError(newErr);
|
|
193
|
+
}
|
|
188
194
|
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
195
|
+
return () => {
|
|
196
|
+
cancelled = true;
|
|
197
|
+
continueRender(handle);
|
|
198
|
+
};
|
|
199
|
+
}, [delayRender, continueRender]);
|
|
200
|
+
useLayoutEffect(() => {
|
|
201
|
+
if (!riveCanvasInstance || !sourceCanvas || !loadedRuntime) {
|
|
192
202
|
return;
|
|
193
203
|
}
|
|
204
|
+
const handle = delayRender(`Loading <RemotionRiveCanvas src="${src}"/>`);
|
|
205
|
+
continueRender(loadedRuntime.handle);
|
|
206
|
+
let cancelled = false;
|
|
207
|
+
const controller = new AbortController;
|
|
194
208
|
sourceCanvas.width = width;
|
|
195
209
|
sourceCanvas.height = height;
|
|
196
210
|
const renderer = riveCanvasInstance.makeRenderer(sourceCanvas);
|
|
197
|
-
fetch(new Request(src)).then((f) => f.arrayBuffer()).then((b) => {
|
|
198
|
-
riveCanvasInstance.load(new Uint8Array(b), assetLoader ? new riveCanvasInstance.CustomFileAssetLoader({
|
|
211
|
+
fetch(new Request(src), { signal: controller.signal }).then((f) => f.arrayBuffer()).then((b) => {
|
|
212
|
+
return riveCanvasInstance.load(new Uint8Array(b), assetLoader ? new riveCanvasInstance.CustomFileAssetLoader({
|
|
199
213
|
loadContents: assetLoader
|
|
200
214
|
}) : undefined, enableRiveAssetCdn).then((file) => {
|
|
215
|
+
if (cancelled) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
201
218
|
const artboard = typeof artboardName === "string" ? file.artboardByName(artboardName) : typeof artboardName === "number" ? file.artboardByIndex(artboardName) : file.defaultArtboard();
|
|
202
219
|
const animation = new riveCanvasInstance.LinearAnimationInstance(typeof animationIndex === "number" ? artboard.animationByIndex(animationIndex) : typeof animationIndex === "string" ? artboard.animationByName(animationIndex) : artboard.animationByIndex(0), artboard);
|
|
203
220
|
setRive({
|
|
204
221
|
animation,
|
|
205
222
|
artboard,
|
|
206
223
|
renderer,
|
|
207
|
-
file
|
|
224
|
+
file,
|
|
225
|
+
handle
|
|
208
226
|
});
|
|
209
227
|
});
|
|
210
228
|
}).catch((newErr) => {
|
|
211
|
-
|
|
229
|
+
if (!cancelled) {
|
|
230
|
+
setError(newErr);
|
|
231
|
+
}
|
|
212
232
|
});
|
|
233
|
+
return () => {
|
|
234
|
+
cancelled = true;
|
|
235
|
+
controller.abort();
|
|
236
|
+
continueRender(handle);
|
|
237
|
+
};
|
|
213
238
|
}, [
|
|
214
239
|
animationIndex,
|
|
215
240
|
artboardName,
|
|
@@ -220,14 +245,17 @@ var RemotionRiveCanvasContentForwardRefFunction = ({
|
|
|
220
245
|
enableRiveAssetCdn,
|
|
221
246
|
sourceCanvas,
|
|
222
247
|
width,
|
|
223
|
-
height
|
|
248
|
+
height,
|
|
249
|
+
loadedRuntime,
|
|
250
|
+
delayRender,
|
|
251
|
+
continueRender
|
|
224
252
|
]);
|
|
225
253
|
useEffect(() => {
|
|
226
254
|
if (onLoad && rive) {
|
|
227
255
|
onLoad(rive.file);
|
|
228
256
|
}
|
|
229
257
|
}, [onLoad, rive]);
|
|
230
|
-
|
|
258
|
+
useLayoutEffect(() => {
|
|
231
259
|
if (!riveCanvasInstance || !rive) {
|
|
232
260
|
return;
|
|
233
261
|
}
|
|
@@ -266,6 +294,7 @@ var RemotionRiveCanvasContentForwardRefFunction = ({
|
|
|
266
294
|
return;
|
|
267
295
|
}
|
|
268
296
|
const effectChainHandle = delayRender(`Rendering frame at ${frame} of <RemotionRiveCanvas src="${src}"/>`);
|
|
297
|
+
continueRender(rive.handle);
|
|
269
298
|
let cancelled = false;
|
|
270
299
|
runEffectChain({
|
|
271
300
|
state,
|
|
@@ -393,7 +422,7 @@ var RemotionRiveCanvasInnerForwardRefFunction = ({
|
|
|
393
422
|
hidden,
|
|
394
423
|
showInTimeline,
|
|
395
424
|
name: name ?? "<RemotionRiveCanvas>",
|
|
396
|
-
_remotionInternalDocumentationLink:
|
|
425
|
+
_remotionInternalDocumentationLink: "https://www.remotion.dev/docs/rive/remotionrivecanvas",
|
|
397
426
|
durationInFrames,
|
|
398
427
|
controls,
|
|
399
428
|
_remotionInternalEffects: memoizedEffectDefinitions,
|
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.535",
|
|
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",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"license": "See LICENSE.md",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@rive-app/canvas-advanced": "2.31.5",
|
|
26
|
-
"remotion": "4.0.
|
|
26
|
+
"remotion": "4.0.535"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": ">=18.2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"react": "19.2.3",
|
|
34
34
|
"react-dom": "19.2.3",
|
|
35
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
35
|
+
"@remotion/eslint-config-internal": "4.0.535",
|
|
36
36
|
"eslint": "9.19.0",
|
|
37
37
|
"@typescript/native-preview": "7.0.0-dev.20260217.1"
|
|
38
38
|
},
|