remotion 4.0.470 → 4.0.472
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/AbsoluteFill.js +1 -1
- package/dist/cjs/CanUseRemotionHooks.js +1 -1
- package/dist/cjs/Composition.d.ts +1 -1
- package/dist/cjs/Composition.js +3 -3
- package/dist/cjs/CompositionErrorBoundary.js +2 -5
- package/dist/cjs/CompositionManager.d.ts +2 -0
- package/dist/cjs/CompositionManagerContext.d.ts +1 -1
- package/dist/cjs/CompositionManagerProvider.d.ts +2 -2
- package/dist/cjs/CompositionManagerProvider.js +3 -2
- package/dist/cjs/EditorProps.d.ts +2 -2
- package/dist/cjs/EditorProps.js +1 -1
- package/dist/cjs/Folder.d.ts +1 -0
- package/dist/cjs/Folder.js +7 -3
- package/dist/cjs/HtmlInCanvas.d.ts +15 -3
- package/dist/cjs/HtmlInCanvas.js +77 -16
- package/dist/cjs/IFrame.d.ts +2 -2
- package/dist/cjs/IFrame.js +1 -1
- package/dist/cjs/Img.d.ts +27 -13
- package/dist/cjs/Img.js +37 -21
- package/dist/cjs/RemotionRoot.js +1 -1
- package/dist/cjs/RenderAssetManager.js +1 -1
- package/dist/cjs/Sequence.js +19 -8
- package/dist/cjs/SequenceManager.d.ts +4 -3
- package/dist/cjs/SequenceManager.js +1 -1
- package/dist/cjs/Still.js +1 -1
- package/dist/cjs/TimelineContext.js +1 -1
- package/dist/cjs/animated-image/AnimatedImage.d.ts +4 -4
- package/dist/cjs/animated-image/AnimatedImage.js +24 -5
- package/dist/cjs/animated-image/canvas.js +1 -1
- package/dist/cjs/animated-image/decode-image.d.ts +2 -1
- package/dist/cjs/animated-image/decode-image.js +2 -2
- package/dist/cjs/animated-image/index.js +1 -1
- package/dist/cjs/animated-image/props.d.ts +1 -0
- package/dist/cjs/animated-image/request-init.d.ts +1 -0
- package/dist/cjs/animated-image/request-init.js +16 -0
- package/dist/cjs/audio/AudioForPreview.js +1 -1
- package/dist/cjs/audio/AudioForRendering.d.ts +20 -5
- package/dist/cjs/audio/AudioForRendering.js +1 -1
- package/dist/cjs/audio/html5-audio.d.ts +36 -36
- package/dist/cjs/audio/html5-audio.js +6 -6
- package/dist/cjs/audio/index.js +1 -1
- package/dist/cjs/audio/props.d.ts +1 -1
- package/dist/cjs/audio/shared-audio-tags.js +7 -4
- package/dist/cjs/audio/shared-element-source-node.d.ts +1 -1
- package/dist/cjs/audio/use-audio-context.d.ts +1 -2
- package/dist/cjs/audio/wait-until-actually-resumed.d.ts +1 -2
- package/dist/cjs/audio/wait-until-actually-resumed.js +2 -1
- package/dist/cjs/buffer-until-first-frame.d.ts +3 -4
- package/dist/cjs/buffering.js +1 -1
- package/dist/cjs/canvas-image/CanvasImage.d.ts +34 -18
- package/dist/cjs/canvas-image/CanvasImage.js +19 -6
- package/dist/cjs/canvas-image/index.js +1 -1
- package/dist/cjs/canvas-image/props.d.ts +4 -0
- package/dist/cjs/default-css.d.ts +1 -1
- package/dist/cjs/delay-render.d.ts +2 -3
- package/dist/cjs/delay-render.js +2 -1
- package/dist/cjs/effects/Solid.d.ts +2 -1
- package/dist/cjs/effects/Solid.js +39 -10
- package/dist/cjs/effects/canvas-pool.js +4 -2
- package/dist/cjs/effects/use-memoized-effects.d.ts +1 -1
- package/dist/cjs/effects/use-memoized-effects.js +13 -3
- package/dist/cjs/freeze.js +1 -1
- package/dist/cjs/get-effective-visual-mode-value.d.ts +15 -4
- package/dist/cjs/get-effective-visual-mode-value.js +35 -4
- package/dist/cjs/index.d.ts +6 -3
- package/dist/cjs/index.js +33 -29
- package/dist/cjs/internals.d.ts +183 -133
- package/dist/cjs/internals.js +11 -0
- package/dist/cjs/interpolate-colors.d.ts +1 -1
- package/dist/cjs/interpolate-keyframed-status.d.ts +1 -1
- package/dist/cjs/interpolate-keyframed-status.js +0 -6
- package/dist/cjs/interpolate.d.ts +2 -0
- package/dist/cjs/interpolate.js +218 -37
- package/dist/cjs/is-player.js +1 -1
- package/dist/cjs/loading-indicator.js +4 -2
- package/dist/cjs/log-level-context.d.ts +1 -1
- package/dist/cjs/log.d.ts +1 -1
- package/dist/cjs/loop/index.js +1 -1
- package/dist/cjs/media-tag-current-time-timestamp.d.ts +1 -1
- package/dist/cjs/media-tag-current-time-timestamp.js +4 -3
- package/dist/cjs/no-react.d.ts +39 -18
- package/dist/cjs/no-react.js +5 -2
- package/dist/cjs/normalize-number.d.ts +1 -0
- package/dist/cjs/normalize-number.js +7 -0
- package/dist/cjs/play-and-handle-not-allowed-error.d.ts +3 -4
- package/dist/cjs/playback-logging.d.ts +1 -2
- package/dist/cjs/prefetch-state.js +1 -1
- package/dist/cjs/prefetch.d.ts +6 -7
- package/dist/cjs/props-if-has-props.d.ts +1 -2
- package/dist/cjs/register-root.d.ts +2 -2
- package/dist/cjs/resolve-video-config.d.ts +2 -2
- package/dist/cjs/scale-value.d.ts +4 -0
- package/dist/cjs/scale-value.js +48 -0
- package/dist/cjs/seek.d.ts +2 -3
- package/dist/cjs/sequence-field-schema.d.ts +133 -40
- package/dist/cjs/sequence-field-schema.js +25 -4
- package/dist/cjs/series/flatten-children.d.ts +1 -3
- package/dist/cjs/series/index.d.ts +1 -2
- package/dist/cjs/series/index.js +8 -4
- package/dist/cjs/series/is-inside-series.js +2 -2
- package/dist/cjs/spring/index.d.ts +1 -1
- package/dist/cjs/spring/index.js +1 -1
- package/dist/cjs/spring/measure-spring.d.ts +1 -1
- package/dist/cjs/spring/spring-utils.d.ts +1 -1
- package/dist/cjs/timeline-position-state.d.ts +1 -1
- package/dist/cjs/use-amplification.d.ts +6 -4
- package/dist/cjs/use-current-scale.d.ts +2 -2
- package/dist/cjs/use-delay-render.d.ts +1 -2
- package/dist/cjs/use-lazy-component.d.ts +1 -1
- package/dist/cjs/use-media-buffering.d.ts +2 -3
- package/dist/cjs/use-media-enabled.d.ts +1 -1
- package/dist/cjs/use-media-enabled.js +1 -1
- package/dist/cjs/use-media-in-timeline.d.ts +2 -2
- package/dist/cjs/use-media-in-timeline.js +3 -1
- package/dist/cjs/use-media-playback.d.ts +2 -2
- package/dist/cjs/use-media-playback.js +4 -3
- package/dist/cjs/use-media-tag.d.ts +1 -1
- package/dist/cjs/use-pixel-density.d.ts +7 -0
- package/dist/cjs/use-pixel-density.js +66 -0
- package/dist/cjs/use-request-video-callback-time.d.ts +3 -3
- package/dist/cjs/use-schema.d.ts +26 -12
- package/dist/cjs/use-schema.js +66 -12
- package/dist/cjs/validate-media-props.d.ts +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/video/MediaPlaybackError.js +1 -0
- package/dist/cjs/video/OffthreadVideo.js +5 -5
- package/dist/cjs/video/OffthreadVideoForRendering.js +1 -1
- package/dist/cjs/video/VideoForPreview.d.ts +1 -1
- package/dist/cjs/video/VideoForPreview.js +1 -1
- package/dist/cjs/video/VideoForRendering.d.ts +3 -5
- package/dist/cjs/video/VideoForRendering.js +3 -1
- package/dist/cjs/video/duration-state.js +1 -1
- package/dist/cjs/video/emit-video-frame.d.ts +1 -1
- package/dist/cjs/video/emit-video-frame.js +10 -4
- package/dist/cjs/video/html5-video.d.ts +36 -34
- package/dist/cjs/video/html5-video.js +8 -9
- package/dist/cjs/video/index.js +2 -2
- package/dist/cjs/video/props.d.ts +5 -5
- package/dist/cjs/video/seek-until-right.d.ts +2 -3
- package/dist/cjs/warn-about-non-seekable-media.d.ts +1 -1
- package/dist/cjs/wrap-in-schema.d.ts +7 -3
- package/dist/cjs/wrap-in-schema.js +2 -1
- package/dist/cjs/wrap-remotion-context.d.ts +1 -1
- package/dist/cjs/wrap-remotion-context.js +1 -1
- package/dist/esm/index.mjs +1132 -589
- package/dist/esm/no-react.mjs +293 -35
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
package/dist/cjs/AbsoluteFill.js
CHANGED
|
@@ -106,7 +106,7 @@ const AbsoluteFillRefForwarding = (props, ref) => {
|
|
|
106
106
|
...style,
|
|
107
107
|
};
|
|
108
108
|
}, [other.className, style]);
|
|
109
|
-
return
|
|
109
|
+
return jsx_runtime_1.jsx("div", { ref: ref, style: actualStyle, ...other });
|
|
110
110
|
};
|
|
111
111
|
/*
|
|
112
112
|
* @description A helper component which renders an absolutely positioned <div> element with full width, height, and flex display suited for content layering.
|
|
@@ -5,6 +5,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
exports.CanUseRemotionHooks = (0, react_1.createContext)(false);
|
|
7
7
|
const CanUseRemotionHooksProvider = ({ children }) => {
|
|
8
|
-
return (
|
|
8
|
+
return (jsx_runtime_1.jsx(exports.CanUseRemotionHooks.Provider, { value: true, children: children }));
|
|
9
9
|
};
|
|
10
10
|
exports.CanUseRemotionHooksProvider = CanUseRemotionHooksProvider;
|
|
@@ -59,5 +59,5 @@ export type CompositionProps<Schema extends AnyZodObject, Props extends Record<s
|
|
|
59
59
|
readonly id: string;
|
|
60
60
|
readonly schema?: Schema;
|
|
61
61
|
} & CompositionCalculateMetadataOrExplicit<Schema, Props> & CompProps<Props> & PropsIfHasProps<Schema, Props>;
|
|
62
|
-
export declare const Composition: <Schema extends AnyZodObject, Props extends Record<string, unknown>>(props: CompositionProps<Schema, Props>) => import("react/jsx-runtime
|
|
62
|
+
export declare const Composition: <Schema extends AnyZodObject, Props extends Record<string, unknown>>(props: CompositionProps<Schema, Props>) => import("react/jsx-runtime").JSX.Element | null;
|
|
63
63
|
export {};
|
package/dist/cjs/Composition.js
CHANGED
|
@@ -116,7 +116,7 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
|
|
|
116
116
|
resolved.type !== 'success-and-refreshing')) {
|
|
117
117
|
return null;
|
|
118
118
|
}
|
|
119
|
-
return (0, react_dom_1.createPortal)(
|
|
119
|
+
return (0, react_dom_1.createPortal)(jsx_runtime_1.jsx(CanUseRemotionHooks_js_1.CanUseRemotionHooksProvider, { children: jsx_runtime_1.jsx(CompositionErrorBoundary_js_1.CompositionErrorBoundary, { onError: onError, onClear: onClear, children: jsx_runtime_1.jsx(react_1.Suspense, { fallback: jsx_runtime_1.jsx(loading_indicator_js_1.Loading, {}), children: jsx_runtime_1.jsx(Comp, { ...((_c = resolved.result.props) !== null && _c !== void 0 ? _c : {}) }) }) }) }), (0, portal_node_js_1.portalNode)());
|
|
120
120
|
}
|
|
121
121
|
if (environment.isRendering &&
|
|
122
122
|
video &&
|
|
@@ -128,7 +128,7 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
|
|
|
128
128
|
resolved.type !== 'success-and-refreshing')) {
|
|
129
129
|
return null;
|
|
130
130
|
}
|
|
131
|
-
return (0, react_dom_1.createPortal)(
|
|
131
|
+
return (0, react_dom_1.createPortal)(jsx_runtime_1.jsx(CanUseRemotionHooks_js_1.CanUseRemotionHooksProvider, { children: jsx_runtime_1.jsx(react_1.Suspense, { fallback: jsx_runtime_1.jsx(Fallback, {}), children: jsx_runtime_1.jsx(Comp, { ...((_d = resolved.result.props) !== null && _d !== void 0 ? _d : {}) }) }) }), (0, portal_node_js_1.portalNode)());
|
|
132
132
|
}
|
|
133
133
|
return null;
|
|
134
134
|
};
|
|
@@ -142,6 +142,6 @@ const Composition = (props) => {
|
|
|
142
142
|
return null;
|
|
143
143
|
}
|
|
144
144
|
// @ts-expect-error
|
|
145
|
-
return
|
|
145
|
+
return jsx_runtime_1.jsx(InnerComposition, { ...props });
|
|
146
146
|
};
|
|
147
147
|
exports.Composition = Composition;
|
|
@@ -18,11 +18,8 @@ const getHot = () => {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
class CompositionErrorBoundary extends react_1.default.Component {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.state = { hasError: false };
|
|
24
|
-
this.hmrStatusHandler = null;
|
|
25
|
-
}
|
|
21
|
+
state = { hasError: false };
|
|
22
|
+
hmrStatusHandler = null;
|
|
26
23
|
static getDerivedStateFromError() {
|
|
27
24
|
return { hasError: true };
|
|
28
25
|
}
|
|
@@ -54,6 +54,7 @@ export type SequenceControls = {
|
|
|
54
54
|
schema: SequenceSchema;
|
|
55
55
|
currentRuntimeValueDotNotation: Record<string, unknown>;
|
|
56
56
|
overrideId: string;
|
|
57
|
+
supportsEffects: boolean;
|
|
57
58
|
};
|
|
58
59
|
export type TSequence = {
|
|
59
60
|
from: number;
|
|
@@ -72,6 +73,7 @@ export type TSequence = {
|
|
|
72
73
|
controls: SequenceControls | null;
|
|
73
74
|
refForOutline: React.RefObject<HTMLElement | null> | null;
|
|
74
75
|
effects: readonly EffectDefinition<unknown>[];
|
|
76
|
+
isInsideSeries: boolean;
|
|
75
77
|
} & EnhancedTSequenceData;
|
|
76
78
|
export type AudioOrVideoAsset = {
|
|
77
79
|
type: 'audio' | 'video';
|
|
@@ -25,7 +25,7 @@ export type CanvasContent = {
|
|
|
25
25
|
export type CompositionManagerSetters = {
|
|
26
26
|
registerComposition: <Schema extends AnyZodObject, Props extends Record<string, unknown>>(comp: TComposition<Schema, Props>) => void;
|
|
27
27
|
unregisterComposition: (name: string) => void;
|
|
28
|
-
registerFolder: (name: string, parent: string | null, nonce: NonceHistory) => void;
|
|
28
|
+
registerFolder: (name: string, parent: string | null, nonce: NonceHistory, stack: string | null) => void;
|
|
29
29
|
unregisterFolder: (name: string, parent: string | null) => void;
|
|
30
30
|
setCanvasContent: React.Dispatch<React.SetStateAction<CanvasContent | null>>;
|
|
31
31
|
onlyRenderComposition: string | null;
|
|
@@ -2,9 +2,9 @@ import { type AnyComposition } from './CompositionManager';
|
|
|
2
2
|
import type { CanvasContent } from './CompositionManagerContext';
|
|
3
3
|
import type { BaseMetadata } from './CompositionManagerContext.js';
|
|
4
4
|
export declare const CompositionManagerProvider: ({ children, onlyRenderComposition, currentCompositionMetadata, initialCompositions, initialCanvasContent, }: {
|
|
5
|
-
readonly children:
|
|
5
|
+
readonly children: import("react").ReactNode;
|
|
6
6
|
readonly onlyRenderComposition: string | null;
|
|
7
7
|
readonly currentCompositionMetadata: BaseMetadata | null;
|
|
8
8
|
readonly initialCompositions: AnyComposition[];
|
|
9
9
|
readonly initialCanvasContent: CanvasContent | null;
|
|
10
|
-
}) => import("react/jsx-runtime
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -31,7 +31,7 @@ const CompositionManagerProvider = ({ children, onlyRenderComposition, currentCo
|
|
|
31
31
|
return comps.filter((c) => c.id !== id);
|
|
32
32
|
});
|
|
33
33
|
}, []);
|
|
34
|
-
const registerFolder = (0, react_1.useCallback)((name, parent, nonce) => {
|
|
34
|
+
const registerFolder = (0, react_1.useCallback)((name, parent, nonce, stack) => {
|
|
35
35
|
setFolders((prevFolders) => {
|
|
36
36
|
return [
|
|
37
37
|
...prevFolders,
|
|
@@ -39,6 +39,7 @@ const CompositionManagerProvider = ({ children, onlyRenderComposition, currentCo
|
|
|
39
39
|
name,
|
|
40
40
|
parent,
|
|
41
41
|
nonce,
|
|
42
|
+
stack,
|
|
42
43
|
},
|
|
43
44
|
];
|
|
44
45
|
});
|
|
@@ -77,6 +78,6 @@ const CompositionManagerProvider = ({ children, onlyRenderComposition, currentCo
|
|
|
77
78
|
canvasContent,
|
|
78
79
|
};
|
|
79
80
|
}, [compositions, folders, currentCompositionMetadata, canvasContent]);
|
|
80
|
-
return (
|
|
81
|
+
return (jsx_runtime_1.jsx(CompositionManagerContext_1.CompositionManager.Provider, { value: compositionManagerContextValue, children: jsx_runtime_1.jsx(CompositionManagerContext_1.CompositionSetters.Provider, { value: compositionManagerSetters, children: children }) }));
|
|
81
82
|
};
|
|
82
83
|
exports.CompositionManagerProvider = CompositionManagerProvider;
|
|
@@ -13,9 +13,9 @@ export declare const EditorPropsContext: React.Context<EditorPropsContextType>;
|
|
|
13
13
|
export declare const timeValueRef: React.RefObject<{
|
|
14
14
|
goToFrame: () => void;
|
|
15
15
|
seek: (newFrame: number) => void;
|
|
16
|
-
play: (e?: SyntheticEvent |
|
|
16
|
+
play: (e?: PointerEvent | SyntheticEvent<Element, Event> | undefined) => void;
|
|
17
17
|
pause: () => void;
|
|
18
|
-
toggle: (e?: SyntheticEvent |
|
|
18
|
+
toggle: (e?: PointerEvent | SyntheticEvent<Element, Event> | undefined) => void;
|
|
19
19
|
} | null>;
|
|
20
20
|
export declare const EditorPropsProvider: React.FC<{
|
|
21
21
|
readonly children: React.ReactNode;
|
package/dist/cjs/EditorProps.js
CHANGED
|
@@ -59,6 +59,6 @@ const EditorPropsProvider = ({ children }) => {
|
|
|
59
59
|
const ctx = (0, react_1.useMemo)(() => {
|
|
60
60
|
return { props, updateProps };
|
|
61
61
|
}, [props, updateProps]);
|
|
62
|
-
return (
|
|
62
|
+
return (jsx_runtime_1.jsx(exports.EditorPropsContext.Provider, { value: ctx, children: children }));
|
|
63
63
|
};
|
|
64
64
|
exports.EditorPropsProvider = EditorPropsProvider;
|
package/dist/cjs/Folder.d.ts
CHANGED
package/dist/cjs/Folder.js
CHANGED
|
@@ -15,10 +15,13 @@ exports.FolderContext = (0, react_1.createContext)({
|
|
|
15
15
|
* @description By wrapping a <Composition /> inside a <Folder />, you can visually categorize it in your sidebar, should you have many compositions.
|
|
16
16
|
* @see [Documentation](https://remotion.dev/docs/folder)
|
|
17
17
|
*/
|
|
18
|
-
const Folder = (
|
|
18
|
+
const Folder = (props) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const { name, children } = props;
|
|
19
21
|
const parent = (0, react_1.useContext)(exports.FolderContext);
|
|
20
22
|
const { registerFolder, unregisterFolder } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionSetters);
|
|
21
23
|
const nonce = (0, nonce_js_1.useNonce)();
|
|
24
|
+
const stack = (_a = props.stack) !== null && _a !== void 0 ? _a : null;
|
|
22
25
|
(0, validate_folder_name_js_1.validateFolderName)(name);
|
|
23
26
|
const parentNameArr = [parent.parentName, parent.folderName].filter(truthy_js_1.truthy);
|
|
24
27
|
const parentName = parentNameArr.length === 0 ? null : parentNameArr.join('/');
|
|
@@ -29,7 +32,7 @@ const Folder = ({ name, children }) => {
|
|
|
29
32
|
};
|
|
30
33
|
}, [name, parentName]);
|
|
31
34
|
(0, react_1.useEffect)(() => {
|
|
32
|
-
registerFolder(name, parentName, nonce.get());
|
|
35
|
+
registerFolder(name, parentName, nonce.get(), stack);
|
|
33
36
|
return () => {
|
|
34
37
|
unregisterFolder(name, parentName);
|
|
35
38
|
};
|
|
@@ -40,7 +43,8 @@ const Folder = ({ name, children }) => {
|
|
|
40
43
|
registerFolder,
|
|
41
44
|
unregisterFolder,
|
|
42
45
|
nonce,
|
|
46
|
+
stack,
|
|
43
47
|
]);
|
|
44
|
-
return (
|
|
48
|
+
return (jsx_runtime_1.jsx(exports.FolderContext.Provider, { value: value, children: children }));
|
|
45
49
|
};
|
|
46
50
|
exports.Folder = Folder;
|
|
@@ -44,6 +44,7 @@ export type HtmlInCanvasOnPaintParams = {
|
|
|
44
44
|
readonly canvas: OffscreenCanvas;
|
|
45
45
|
readonly element: HTMLDivElement;
|
|
46
46
|
readonly elementImage: ElementImage;
|
|
47
|
+
readonly pixelDensity: number;
|
|
47
48
|
};
|
|
48
49
|
export declare const isHtmlInCanvasSupported: () => boolean;
|
|
49
50
|
/** Shown when {@link isHtmlInCanvasSupported} is false: APIs are absent (old Chrome and/or flag off). */
|
|
@@ -51,7 +52,8 @@ export declare const HTML_IN_CANVAS_UNSUPPORTED_MESSAGE = "HTML in Canvas is not
|
|
|
51
52
|
export type HtmlInCanvasOnPaint = (params: HtmlInCanvasOnPaintParams) => void | Promise<void>;
|
|
52
53
|
export type HtmlInCanvasOnInitCleanup = () => void;
|
|
53
54
|
export type HtmlInCanvasOnInit = (params: HtmlInCanvasOnPaintParams) => HtmlInCanvasOnInitCleanup | Promise<HtmlInCanvasOnInitCleanup>;
|
|
54
|
-
export type
|
|
55
|
+
export type HtmlInCanvasPixelDensity = number;
|
|
56
|
+
export type HtmlInCanvasProps = Omit<SequenceProps, 'children' | 'durationInFrames' | keyof LayoutAndStyle | '_remotionInternalEffects' | '_remotionInternalRefForOutline'> & Omit<AbsoluteFillLayout, 'layout' | 'styleWhilePostmounted' | 'postmountFor' | 'premountFor' | 'styleWhilePremounted'> & {
|
|
55
57
|
readonly durationInFrames?: number;
|
|
56
58
|
readonly width: number;
|
|
57
59
|
readonly height: number;
|
|
@@ -59,7 +61,17 @@ export type HtmlInCanvasProps = Omit<SequenceProps, 'children' | 'durationInFram
|
|
|
59
61
|
readonly children: React.ReactNode;
|
|
60
62
|
readonly onPaint?: HtmlInCanvasOnPaint;
|
|
61
63
|
readonly onInit?: HtmlInCanvasOnInit;
|
|
64
|
+
readonly pixelDensity?: HtmlInCanvasPixelDensity;
|
|
62
65
|
};
|
|
63
|
-
export declare const HtmlInCanvas: React.ForwardRefExoticComponent<
|
|
64
|
-
readonly
|
|
66
|
+
export declare const HtmlInCanvas: React.ForwardRefExoticComponent<Omit<SequenceProps, "_remotionInternalEffects" | "_remotionInternalRefForOutline" | "children" | "durationInFrames" | "layout"> & Omit<AbsoluteFillLayout, "layout" | "postmountFor" | "premountFor" | "styleWhilePostmounted" | "styleWhilePremounted"> & {
|
|
67
|
+
readonly durationInFrames?: number | undefined;
|
|
68
|
+
readonly width: number;
|
|
69
|
+
readonly height: number;
|
|
70
|
+
readonly effects?: EffectsProp | undefined;
|
|
71
|
+
readonly children: React.ReactNode;
|
|
72
|
+
readonly onPaint?: HtmlInCanvasOnPaint | undefined;
|
|
73
|
+
readonly onInit?: HtmlInCanvasOnInit | undefined;
|
|
74
|
+
readonly pixelDensity?: number | undefined;
|
|
75
|
+
} & React.RefAttributes<HTMLCanvasElement>> & {
|
|
76
|
+
readonly isSupported: () => boolean;
|
|
65
77
|
};
|
package/dist/cjs/HtmlInCanvas.js
CHANGED
|
@@ -47,6 +47,25 @@ function assertHtmlInCanvasDimensions(width, height) {
|
|
|
47
47
|
throw new Error(`HtmlInCanvas: \`height\` must be a positive integer. Received: ${String(height)}.`);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
function resolveHtmlInCanvasPixelDensity(pixelDensity) {
|
|
51
|
+
if (pixelDensity === undefined) {
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
if (typeof pixelDensity !== 'number' ||
|
|
55
|
+
!Number.isFinite(pixelDensity) ||
|
|
56
|
+
pixelDensity <= 0) {
|
|
57
|
+
throw new Error(`HtmlInCanvas: \`pixelDensity\` must be a positive finite number. Received: ${String(pixelDensity)}.`);
|
|
58
|
+
}
|
|
59
|
+
return pixelDensity;
|
|
60
|
+
}
|
|
61
|
+
const resizeOffscreenCanvas = ({ offscreen, width, height, }) => {
|
|
62
|
+
if (offscreen.width !== width) {
|
|
63
|
+
offscreen.width = width;
|
|
64
|
+
}
|
|
65
|
+
if (offscreen.height !== height) {
|
|
66
|
+
offscreen.height = height;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
50
69
|
const defaultOnPaint = ({ canvas, element, elementImage, }) => {
|
|
51
70
|
const ctx = canvas.getContext('2d');
|
|
52
71
|
if (!ctx) {
|
|
@@ -58,10 +77,13 @@ const defaultOnPaint = ({ canvas, element, elementImage, }) => {
|
|
|
58
77
|
};
|
|
59
78
|
/* eslint-enable react/require-default-props */
|
|
60
79
|
const HtmlInCanvasAncestorContext = (0, react_1.createContext)(false);
|
|
61
|
-
const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, children, onPaint, onInit, controls, style }, ref) => {
|
|
80
|
+
const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, children, onPaint, onInit, pixelDensity, controls, style, }, ref) => {
|
|
62
81
|
var _a;
|
|
63
82
|
const isInsideAncestorHtmlInCanvas = (0, react_1.useContext)(HtmlInCanvasAncestorContext);
|
|
64
83
|
assertHtmlInCanvasDimensions(width, height);
|
|
84
|
+
const resolvedPixelDensity = resolveHtmlInCanvasPixelDensity(pixelDensity);
|
|
85
|
+
const canvasWidth = Math.ceil(width * resolvedPixelDensity);
|
|
86
|
+
const canvasHeight = Math.ceil(height * resolvedPixelDensity);
|
|
65
87
|
const { continueRender, cancelRender } = (0, use_delay_render_js_1.useDelayRender)();
|
|
66
88
|
if (!(0, exports.isHtmlInCanvasSupported)()) {
|
|
67
89
|
cancelRender(new Error(exports.HTML_IN_CANVAS_UNSUPPORTED_MESSAGE));
|
|
@@ -69,7 +91,7 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
|
|
|
69
91
|
const canvas2dRef = (0, react_1.useRef)(null);
|
|
70
92
|
const offscreenRef = (0, react_1.useRef)(null);
|
|
71
93
|
const divRef = (0, react_1.useRef)(null);
|
|
72
|
-
const canvasSizeKey = `${width}x${height}`;
|
|
94
|
+
const canvasSizeKey = `${width}x${height}@${resolvedPixelDensity}`;
|
|
73
95
|
const setLayoutCanvasRef = (0, react_1.useCallback)((node) => {
|
|
74
96
|
canvas2dRef.current = node;
|
|
75
97
|
if (typeof ref === 'function') {
|
|
@@ -105,8 +127,11 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
|
|
|
105
127
|
if (!offscreen) {
|
|
106
128
|
throw new Error('HtmlInCanvas: offscreen canvas not ready (transferControlToOffscreen failed or canvas is remounting)');
|
|
107
129
|
}
|
|
108
|
-
|
|
109
|
-
|
|
130
|
+
resizeOffscreenCanvas({
|
|
131
|
+
offscreen,
|
|
132
|
+
width: canvasWidth,
|
|
133
|
+
height: canvasHeight,
|
|
134
|
+
});
|
|
110
135
|
try {
|
|
111
136
|
const placeholderCanvas = canvas2dRef.current;
|
|
112
137
|
if (!placeholderCanvas) {
|
|
@@ -135,6 +160,7 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
|
|
|
135
160
|
canvas: offscreen,
|
|
136
161
|
element,
|
|
137
162
|
elementImage: initImage,
|
|
163
|
+
pixelDensity: resolvedPixelDensity,
|
|
138
164
|
});
|
|
139
165
|
if (typeof cleanup !== 'function') {
|
|
140
166
|
throw new Error('HtmlInCanvas: when `onInit` is provided, it must return a cleanup function, or a Promise that resolves to one.');
|
|
@@ -153,21 +179,29 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
|
|
|
153
179
|
canvas: offscreen,
|
|
154
180
|
element,
|
|
155
181
|
elementImage: elImage,
|
|
182
|
+
pixelDensity: resolvedPixelDensity,
|
|
156
183
|
});
|
|
157
184
|
await (0, run_effect_chain_js_1.runEffectChain)({
|
|
158
|
-
state: chainState.get(
|
|
185
|
+
state: chainState.get(canvasWidth, canvasHeight),
|
|
159
186
|
source: offscreen,
|
|
160
187
|
effects: effectsRef.current,
|
|
161
188
|
output: offscreen,
|
|
162
|
-
width,
|
|
163
|
-
height,
|
|
189
|
+
width: canvasWidth,
|
|
190
|
+
height: canvasHeight,
|
|
164
191
|
});
|
|
165
192
|
continueRender(handle);
|
|
166
193
|
}
|
|
167
194
|
catch (error) {
|
|
168
195
|
cancelRender(error);
|
|
169
196
|
}
|
|
170
|
-
}, [
|
|
197
|
+
}, [
|
|
198
|
+
canvasHeight,
|
|
199
|
+
canvasWidth,
|
|
200
|
+
chainState,
|
|
201
|
+
continueRender,
|
|
202
|
+
cancelRender,
|
|
203
|
+
resolvedPixelDensity,
|
|
204
|
+
]);
|
|
171
205
|
// Transfer control once per layout canvas instance, then listen for paint on
|
|
172
206
|
// the placeholder (capture) while drawing on the linked offscreen surface.
|
|
173
207
|
(0, react_1.useLayoutEffect)(() => {
|
|
@@ -178,8 +212,11 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
|
|
|
178
212
|
placeholder.layoutSubtree = true;
|
|
179
213
|
const offscreen = placeholder.transferControlToOffscreen();
|
|
180
214
|
offscreenRef.current = offscreen;
|
|
181
|
-
|
|
182
|
-
|
|
215
|
+
resizeOffscreenCanvas({
|
|
216
|
+
offscreen,
|
|
217
|
+
width: canvasWidth,
|
|
218
|
+
height: canvasHeight,
|
|
219
|
+
});
|
|
183
220
|
initializedRef.current = false;
|
|
184
221
|
unmountedRef.current = false;
|
|
185
222
|
placeholder.addEventListener('paint', onPaintCb);
|
|
@@ -192,7 +229,7 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
|
|
|
192
229
|
(_a = onInitCleanupRef.current) === null || _a === void 0 ? void 0 : _a.call(onInitCleanupRef);
|
|
193
230
|
onInitCleanupRef.current = null;
|
|
194
231
|
};
|
|
195
|
-
}, [onPaintCb, cancelRender,
|
|
232
|
+
}, [onPaintCb, cancelRender, canvasWidth, canvasHeight]);
|
|
196
233
|
const onPaintChangedRef = (0, react_1.useRef)(false);
|
|
197
234
|
(0, react_1.useLayoutEffect)(() => {
|
|
198
235
|
var _a;
|
|
@@ -225,26 +262,50 @@ const HtmlInCanvasContent = (0, react_1.forwardRef)(({ width, height, effects, c
|
|
|
225
262
|
height,
|
|
226
263
|
};
|
|
227
264
|
}, [width, height]);
|
|
265
|
+
const canvasStyle = (0, react_1.useMemo)(() => {
|
|
266
|
+
return {
|
|
267
|
+
width,
|
|
268
|
+
height,
|
|
269
|
+
...(style !== null && style !== void 0 ? style : {}),
|
|
270
|
+
};
|
|
271
|
+
}, [height, style, width]);
|
|
228
272
|
if (isInsideAncestorHtmlInCanvas) {
|
|
229
273
|
throw new Error('<HtmlInCanvas> effects cannot be nested together. Chrome will only display the outer effect. Consider merging the effects into one if you can.');
|
|
230
274
|
}
|
|
231
|
-
return (
|
|
275
|
+
return (jsx_runtime_1.jsx(HtmlInCanvasAncestorContext.Provider, { value: true, children: jsx_runtime_1.jsx("canvas", { ref: setLayoutCanvasRef, width: canvasWidth, height: canvasHeight, style: canvasStyle, children: jsx_runtime_1.jsx("div", { ref: divRef, style: innerStyle, children: children }) }, canvasSizeKey) }));
|
|
232
276
|
});
|
|
233
277
|
HtmlInCanvasContent.displayName = 'HtmlInCanvasContent';
|
|
234
|
-
const HtmlInCanvasInner = (0, react_1.forwardRef)(({ width, height, effects = [], children, onPaint, onInit, _experimentalControls: controls, style, durationInFrames, name, ...sequenceProps }, ref) => {
|
|
278
|
+
const HtmlInCanvasInner = (0, react_1.forwardRef)(({ width, height, effects = [], children, onPaint, onInit, pixelDensity, _experimentalControls: controls, style, durationInFrames, name, ...sequenceProps }, ref) => {
|
|
235
279
|
const { durationInFrames: videoDuration } = (0, use_video_config_js_1.useVideoConfig)();
|
|
236
280
|
const resolvedDuration = durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : videoDuration;
|
|
237
281
|
const memoizedEffectDefinitions = (0, use_memoized_effects_js_1.useMemoizedEffectDefinitions)(effects);
|
|
238
|
-
|
|
282
|
+
const actualRef = (0, react_1.useRef)(null);
|
|
283
|
+
const setCanvasRef = (0, react_1.useCallback)((node) => {
|
|
284
|
+
actualRef.current = node;
|
|
285
|
+
if (typeof ref === 'function') {
|
|
286
|
+
ref(node);
|
|
287
|
+
}
|
|
288
|
+
else if (ref) {
|
|
289
|
+
ref.current =
|
|
290
|
+
node;
|
|
291
|
+
}
|
|
292
|
+
}, [ref]);
|
|
293
|
+
return (jsx_runtime_1.jsx(Sequence_js_1.Sequence, { durationInFrames: resolvedDuration, name: name !== null && name !== void 0 ? name : '<HtmlInCanvas>', _remotionInternalDocumentationLink: name === undefined
|
|
239
294
|
? 'https://www.remotion.dev/docs/remotion/html-in-canvas'
|
|
240
|
-
: undefined, _experimentalControls: controls, _remotionInternalEffects: memoizedEffectDefinitions, layout: "none", ...sequenceProps, children:
|
|
295
|
+
: undefined, _experimentalControls: controls, _remotionInternalEffects: memoizedEffectDefinitions, _remotionInternalRefForOutline: actualRef, layout: "none", ...sequenceProps, children: jsx_runtime_1.jsx(HtmlInCanvasContent, { ref: setCanvasRef, width: width, height: height, effects: effects, onPaint: onPaint, onInit: onInit, pixelDensity: pixelDensity, controls: controls, style: style, children: children }) }));
|
|
241
296
|
});
|
|
242
297
|
HtmlInCanvasInner.displayName = 'HtmlInCanvas';
|
|
243
298
|
const htmlInCanvasSchema = {
|
|
299
|
+
durationInFrames: sequence_field_schema_js_1.durationInFramesField,
|
|
300
|
+
from: sequence_field_schema_js_1.fromField,
|
|
244
301
|
...sequence_field_schema_js_1.sequenceVisualStyleSchema,
|
|
245
302
|
hidden: sequence_field_schema_js_1.hiddenField,
|
|
246
303
|
};
|
|
247
|
-
const HtmlInCanvasWrapped = (0, wrap_in_schema_js_1.wrapInSchema)(
|
|
304
|
+
const HtmlInCanvasWrapped = (0, wrap_in_schema_js_1.wrapInSchema)({
|
|
305
|
+
Component: HtmlInCanvasInner,
|
|
306
|
+
schema: htmlInCanvasSchema,
|
|
307
|
+
supportsEffects: true,
|
|
308
|
+
});
|
|
248
309
|
exports.HtmlInCanvas = Object.assign(HtmlInCanvasWrapped, {
|
|
249
310
|
isSupported: exports.isHtmlInCanvasSupported,
|
|
250
311
|
});
|
package/dist/cjs/IFrame.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare const IFrame: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLIFrameElement> & React.IframeHTMLAttributes<HTMLIFrameElement> & {
|
|
3
|
-
readonly delayRenderRetries?: number;
|
|
4
|
-
readonly delayRenderTimeoutInMilliseconds?: number;
|
|
3
|
+
readonly delayRenderRetries?: number | undefined;
|
|
4
|
+
readonly delayRenderTimeoutInMilliseconds?: number | undefined;
|
|
5
5
|
}, "ref"> & React.RefAttributes<HTMLIFrameElement>>;
|
package/dist/cjs/IFrame.js
CHANGED
|
@@ -24,7 +24,7 @@ const IFrameRefForwarding = ({ onLoad, onError, delayRenderRetries, delayRenderT
|
|
|
24
24
|
console.error('Error loading iframe:', e, 'Handle the event using the onError() prop to make this message disappear.');
|
|
25
25
|
}
|
|
26
26
|
}, [handle, onError, continueRender]);
|
|
27
|
-
return (
|
|
27
|
+
return (jsx_runtime_1.jsx("iframe", { referrerPolicy: "strict-origin-when-cross-origin", ...props, ref: ref, onError: didGetError, onLoad: didLoad }));
|
|
28
28
|
};
|
|
29
29
|
/*
|
|
30
30
|
* @description The <IFrame /> can be used like a regular <iframe> HTML tag.
|
package/dist/cjs/Img.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ export type ImgProps = NativeImgProps & {
|
|
|
18
18
|
readonly stack?: string;
|
|
19
19
|
} & Pick<SequenceProps, 'durationInFrames' | 'from' | 'hidden'>;
|
|
20
20
|
export declare const imgSchema: {
|
|
21
|
-
readonly hidden: import("./sequence-field-schema.js").SequenceFieldSchema;
|
|
22
21
|
readonly 'style.translate': {
|
|
23
22
|
readonly type: "translate";
|
|
24
23
|
readonly step: 1;
|
|
@@ -26,7 +25,7 @@ export declare const imgSchema: {
|
|
|
26
25
|
readonly description: "Offset";
|
|
27
26
|
};
|
|
28
27
|
readonly 'style.scale': {
|
|
29
|
-
readonly type: "
|
|
28
|
+
readonly type: "scale";
|
|
30
29
|
readonly min: 0.05;
|
|
31
30
|
readonly max: 100;
|
|
32
31
|
readonly step: 0.01;
|
|
@@ -34,7 +33,7 @@ export declare const imgSchema: {
|
|
|
34
33
|
readonly description: "Scale";
|
|
35
34
|
};
|
|
36
35
|
readonly 'style.rotate': {
|
|
37
|
-
readonly type: "rotation";
|
|
36
|
+
readonly type: "rotation-css";
|
|
38
37
|
readonly step: 1;
|
|
39
38
|
readonly default: "0deg";
|
|
40
39
|
readonly description: "Rotation";
|
|
@@ -46,21 +45,36 @@ export declare const imgSchema: {
|
|
|
46
45
|
readonly step: 0.01;
|
|
47
46
|
readonly default: 1;
|
|
48
47
|
readonly description: "Opacity";
|
|
48
|
+
readonly hiddenFromList: false;
|
|
49
|
+
};
|
|
50
|
+
readonly durationInFrames: {
|
|
51
|
+
readonly type: "number";
|
|
52
|
+
readonly default: undefined;
|
|
53
|
+
readonly min: 1;
|
|
54
|
+
readonly step: 1;
|
|
55
|
+
readonly hiddenFromList: true;
|
|
49
56
|
};
|
|
57
|
+
readonly from: {
|
|
58
|
+
readonly type: "number";
|
|
59
|
+
readonly default: 0;
|
|
60
|
+
readonly step: 1;
|
|
61
|
+
readonly hiddenFromList: true;
|
|
62
|
+
};
|
|
63
|
+
readonly hidden: import("./sequence-field-schema.js").SequenceFieldSchema;
|
|
50
64
|
};
|
|
51
65
|
export declare const Img: React.ComponentType<NativeImgProps & {
|
|
52
|
-
readonly maxRetries?: number;
|
|
53
|
-
readonly pauseWhenLoading?: boolean;
|
|
54
|
-
readonly delayRenderRetries?: number;
|
|
55
|
-
readonly delayRenderTimeoutInMilliseconds?: number;
|
|
56
|
-
readonly onImageFrame?: (imageElement: HTMLImageElement) => void;
|
|
66
|
+
readonly maxRetries?: number | undefined;
|
|
67
|
+
readonly pauseWhenLoading?: boolean | undefined;
|
|
68
|
+
readonly delayRenderRetries?: number | undefined;
|
|
69
|
+
readonly delayRenderTimeoutInMilliseconds?: number | undefined;
|
|
70
|
+
readonly onImageFrame?: ((imageElement: HTMLImageElement) => void) | undefined;
|
|
57
71
|
readonly src: string;
|
|
58
|
-
readonly effects?: EffectsProp;
|
|
59
|
-
readonly showInTimeline?: boolean;
|
|
60
|
-
readonly name?: string;
|
|
72
|
+
readonly effects?: EffectsProp | undefined;
|
|
73
|
+
readonly showInTimeline?: boolean | undefined;
|
|
74
|
+
readonly name?: string | undefined;
|
|
61
75
|
/**
|
|
62
76
|
* @deprecated For internal use only
|
|
63
77
|
*/
|
|
64
|
-
readonly stack?: string;
|
|
65
|
-
} & Pick<SequenceProps, "
|
|
78
|
+
readonly stack?: string | undefined;
|
|
79
|
+
} & Pick<SequenceProps, "durationInFrames" | "from" | "hidden">>;
|
|
66
80
|
export {};
|