remotion 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/README.md +1 -1
- package/dist/cjs/AbsoluteFill.d.ts +1 -6
- package/dist/cjs/AbsoluteFill.js +1 -1
- package/dist/cjs/Composition.js +15 -20
- package/dist/cjs/CompositionManager.d.ts +0 -4
- package/dist/cjs/CompositionManagerContext.d.ts +1 -6
- package/dist/cjs/CompositionManagerContext.js +0 -4
- package/dist/cjs/CompositionManagerProvider.js +77 -169
- package/dist/cjs/CompositionRegistryProvider.d.ts +5 -0
- package/dist/cjs/CompositionRegistryProvider.js +142 -0
- package/dist/cjs/DefaultPremountContext.d.ts +1 -0
- package/dist/cjs/DefaultPremountContext.js +6 -0
- package/dist/cjs/Folder.js +11 -20
- package/dist/cjs/HtmlInCanvas.d.ts +2 -2
- package/dist/cjs/HtmlInCanvas.js +177 -30
- package/dist/cjs/IFrame.js +40 -8
- package/dist/cjs/Img.js +2 -1
- package/dist/cjs/Interactive.d.ts +12 -0
- package/dist/cjs/Interactive.js +19 -8
- package/dist/cjs/RemotionRoot.js +2 -1
- package/dist/cjs/Sequence.d.ts +2 -3
- package/dist/cjs/Sequence.js +72 -38
- package/dist/cjs/SequenceActivityBoundary.d.ts +10 -0
- package/dist/cjs/SequenceActivityBoundary.js +88 -0
- package/dist/cjs/SequenceActivityBudget.d.ts +13 -0
- package/dist/cjs/SequenceActivityBudget.js +181 -0
- package/dist/cjs/SequenceManager.d.ts +4 -22
- package/dist/cjs/SequenceManager.js +36 -196
- package/dist/cjs/SequenceRegistryProvider.d.ts +4 -0
- package/dist/cjs/SequenceRegistryProvider.js +292 -0
- package/dist/cjs/Track.d.ts +10 -3
- package/dist/cjs/Track.js +7 -6
- package/dist/cjs/animated-image/AnimatedImage.js +42 -31
- package/dist/cjs/audio/AudioForPreview.js +54 -41
- package/dist/cjs/audio/get-audio-sync-anchor-tolerance.d.ts +1 -0
- package/dist/cjs/audio/get-audio-sync-anchor-tolerance.js +11 -0
- package/dist/cjs/audio/use-audio-context.js +26 -7
- package/dist/cjs/canvas-image/CanvasImage.js +2 -1
- package/dist/cjs/committed-metadata.d.ts +68 -0
- package/dist/cjs/committed-metadata.js +39 -0
- package/dist/cjs/component-identity.d.ts +6 -0
- package/dist/cjs/component-identity.js +39 -0
- package/dist/cjs/composition-registry-fallback.d.ts +14 -0
- package/dist/cjs/composition-registry-fallback.js +35 -0
- package/dist/cjs/create-element-source-proxy.d.ts +4 -0
- package/dist/cjs/create-element-source-proxy.js +46 -0
- package/dist/cjs/default-premount-in-seconds.d.ts +3 -0
- package/dist/cjs/default-premount-in-seconds.js +12 -0
- package/dist/cjs/effects/Solid.js +2 -1
- package/dist/cjs/effects/canvas-pool.d.ts +1 -0
- package/dist/cjs/effects/canvas-pool.js +15 -10
- package/dist/cjs/effects/run-effect-chain.js +3 -3
- package/dist/cjs/effects/use-memoized-effects.js +96 -17
- package/dist/cjs/enable-sequence-stack-traces.d.ts +2 -8
- package/dist/cjs/enable-sequence-stack-traces.js +7 -38
- package/dist/cjs/freeze.js +4 -1
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/interactivity-schema.d.ts +45 -9
- package/dist/cjs/interactivity-schema.js +30 -3
- package/dist/cjs/internals.d.ts +104 -25
- package/dist/cjs/internals.js +29 -7
- package/dist/cjs/interpolate-keyframed-status.d.ts +4 -0
- package/dist/cjs/interpolate-keyframed-status.js +38 -1
- package/dist/cjs/interpolate.d.ts +12 -0
- package/dist/cjs/interpolate.js +7 -0
- package/dist/cjs/no-react.d.ts +4 -0
- package/dist/cjs/no-react.js +6 -0
- package/dist/cjs/optimistic-sequence-deletion.d.ts +17 -0
- package/dist/cjs/optimistic-sequence-deletion.js +114 -0
- package/dist/cjs/registry-store.d.ts +17 -0
- package/dist/cjs/registry-store.js +68 -0
- package/dist/cjs/sequence-activity-context.d.ts +13 -0
- package/dist/cjs/sequence-activity-context.js +20 -0
- package/dist/cjs/sequence-activity-defaults.d.ts +1 -0
- package/dist/cjs/sequence-activity-defaults.js +4 -0
- package/dist/cjs/sequence-outline.js +1 -2
- package/dist/cjs/sequence-registry-context.d.ts +26 -0
- package/dist/cjs/sequence-registry-context.js +71 -0
- package/dist/cjs/series/index.d.ts +2 -1
- package/dist/cjs/series/index.js +12 -4
- package/dist/cjs/timeline-position-state.js +11 -3
- package/dist/cjs/timeline-track-context.d.ts +1 -0
- package/dist/cjs/use-lazy-component.js +29 -15
- package/dist/cjs/use-media-in-timeline.d.ts +7 -14
- package/dist/cjs/use-media-in-timeline.js +15 -117
- package/dist/cjs/use-premounting.js +3 -4
- package/dist/cjs/use-sequence-registration.d.ts +1 -1
- package/dist/cjs/use-sequence-registration.js +22 -6
- package/dist/cjs/use-video.d.ts +7 -2
- package/dist/cjs/use-video.js +11 -3
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/video/VideoForPreview.js +55 -42
- package/dist/cjs/with-interactivity-schema.js +40 -14
- package/dist/cjs/wrap-remotion-context.d.ts +15 -2
- package/dist/cjs/wrap-remotion-context.js +101 -4
- package/dist/esm/index.mjs +3352 -2284
- package/dist/esm/no-react.mjs +71 -35
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ Remotion is extensively documented over more than 1000 pages.
|
|
|
81
81
|
- [Discord](https://remotion.dev/discord)
|
|
82
82
|
- [Search](https://remotion.dev/search)
|
|
83
83
|
- [Ask AI](https://remotion.dev/ai)
|
|
84
|
-
- [GitHub Issues](https://remotion
|
|
84
|
+
- [GitHub Issues](https://github.com/remotion-dev/remotion/issues)
|
|
85
85
|
|
|
86
86
|
## Documentation
|
|
87
87
|
|
|
@@ -181,12 +181,7 @@ export declare const absoluteFillSchema: {
|
|
|
181
181
|
readonly default: "transparent";
|
|
182
182
|
readonly description: "Color";
|
|
183
183
|
};
|
|
184
|
-
readonly children:
|
|
185
|
-
readonly type: "text-content";
|
|
186
|
-
readonly default: "";
|
|
187
|
-
readonly description: "Text";
|
|
188
|
-
readonly keyframable: false;
|
|
189
|
-
};
|
|
184
|
+
readonly children: import("./interactivity-schema.js").InteractivitySchemaField;
|
|
190
185
|
readonly premountFor: {
|
|
191
186
|
readonly type: "number";
|
|
192
187
|
readonly default: 0;
|
package/dist/cjs/AbsoluteFill.js
CHANGED
|
@@ -20,7 +20,7 @@ exports.absoluteFillSchema = {
|
|
|
20
20
|
...interactivity_schema_js_1.borderSchema,
|
|
21
21
|
...interactivity_schema_js_1.borderRadiusSchema,
|
|
22
22
|
...interactivity_schema_js_1.textSchema,
|
|
23
|
-
...interactivity_schema_js_1.
|
|
23
|
+
...interactivity_schema_js_1.childrenSchema,
|
|
24
24
|
};
|
|
25
25
|
const setRef = (ref, value) => {
|
|
26
26
|
if (typeof ref === 'function') {
|
package/dist/cjs/Composition.js
CHANGED
|
@@ -5,17 +5,18 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const react_dom_1 = require("react-dom");
|
|
7
7
|
const CanUseRemotionHooks_js_1 = require("./CanUseRemotionHooks.js");
|
|
8
|
+
const committed_metadata_js_1 = require("./committed-metadata.js");
|
|
9
|
+
const component_identity_js_1 = require("./component-identity.js");
|
|
10
|
+
const composition_registry_fallback_js_1 = require("./composition-registry-fallback.js");
|
|
8
11
|
const composition_render_error_context_js_1 = require("./composition-render-error-context.js");
|
|
9
12
|
const CompositionErrorBoundary_js_1 = require("./CompositionErrorBoundary.js");
|
|
10
13
|
const CompositionManagerContext_js_1 = require("./CompositionManagerContext.js");
|
|
11
|
-
const enable_sequence_stack_traces_js_1 = require("./enable-sequence-stack-traces.js");
|
|
12
14
|
const Folder_js_1 = require("./Folder.js");
|
|
13
15
|
const input_props_serialization_js_1 = require("./input-props-serialization.js");
|
|
14
16
|
const is_player_js_1 = require("./is-player.js");
|
|
15
17
|
const loading_indicator_js_1 = require("./loading-indicator.js");
|
|
16
18
|
const portal_node_js_1 = require("./portal-node.js");
|
|
17
19
|
const ResolveCompositionConfig_js_1 = require("./ResolveCompositionConfig.js");
|
|
18
|
-
const sequence_order_marker_js_1 = require("./sequence-order-marker.js");
|
|
19
20
|
const use_delay_render_js_1 = require("./use-delay-render.js");
|
|
20
21
|
const use_lazy_component_js_1 = require("./use-lazy-component.js");
|
|
21
22
|
const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
|
|
@@ -32,8 +33,6 @@ const Fallback = () => {
|
|
|
32
33
|
};
|
|
33
34
|
const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultProps, schema, ...compProps }) => {
|
|
34
35
|
var _a, _b, _c, _d;
|
|
35
|
-
const compManager = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionSetters);
|
|
36
|
-
const { registerComposition, unregisterComposition } = compManager;
|
|
37
36
|
const video = (0, use_video_js_1.useVideo)();
|
|
38
37
|
const lazy = (0, use_lazy_component_js_1.useLazyComponent)({
|
|
39
38
|
compProps: compProps,
|
|
@@ -57,9 +56,9 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
|
|
|
57
56
|
const stack = (_b = compProps
|
|
58
57
|
._remotionInternalStack) !== null && _b !== void 0 ? _b : null;
|
|
59
58
|
const componentFromProps = 'component' in compProps
|
|
60
|
-
? (0,
|
|
59
|
+
? (0, component_identity_js_1.resolveComponentIdentity)(compProps.component)
|
|
61
60
|
: null;
|
|
62
|
-
(0, react_1.
|
|
61
|
+
const registration = (0, react_1.useMemo)(() => {
|
|
63
62
|
var _a;
|
|
64
63
|
// Ensure it's a URL safe id
|
|
65
64
|
if (!id) {
|
|
@@ -67,7 +66,7 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
|
|
|
67
66
|
}
|
|
68
67
|
(0, validate_composition_id_js_1.validateCompositionId)(id);
|
|
69
68
|
(0, validate_default_props_js_1.validateDefaultAndInputProps)(defaultProps, 'defaultProps', id);
|
|
70
|
-
|
|
69
|
+
return {
|
|
71
70
|
durationInFrames: durationInFrames !== null && durationInFrames !== void 0 ? durationInFrames : undefined,
|
|
72
71
|
fps: fps !== null && fps !== void 0 ? fps : undefined,
|
|
73
72
|
height: height !== null && height !== void 0 ? height : undefined,
|
|
@@ -82,9 +81,6 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
|
|
|
82
81
|
schema: schema !== null && schema !== void 0 ? schema : null,
|
|
83
82
|
calculateMetadata: (_a = compProps.calculateMetadata) !== null && _a !== void 0 ? _a : null,
|
|
84
83
|
stack,
|
|
85
|
-
});
|
|
86
|
-
return () => {
|
|
87
|
-
unregisterComposition(id);
|
|
88
84
|
};
|
|
89
85
|
}, [
|
|
90
86
|
durationInFrames,
|
|
@@ -100,9 +96,9 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
|
|
|
100
96
|
schema,
|
|
101
97
|
compProps.calculateMetadata,
|
|
102
98
|
stack,
|
|
103
|
-
registerComposition,
|
|
104
|
-
unregisterComposition,
|
|
105
99
|
]);
|
|
100
|
+
const metadata = (0, react_1.useMemo)(() => ({ type: 'composition', id, value: registration }), [id, registration]);
|
|
101
|
+
(0, composition_registry_fallback_js_1.useCommittedCompositionEntry)(metadata);
|
|
106
102
|
const resolved = (0, ResolveCompositionConfig_js_1.useResolvedVideoConfig)(id);
|
|
107
103
|
const { setError, clearError } = (0, react_1.useContext)(composition_render_error_context_js_1.CompositionRenderErrorContext);
|
|
108
104
|
const onError = (0, react_1.useCallback)((error) => {
|
|
@@ -111,6 +107,7 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
|
|
|
111
107
|
const onClear = (0, react_1.useCallback)(() => {
|
|
112
108
|
clearError();
|
|
113
109
|
}, [clearError]);
|
|
110
|
+
const wrapRegistration = (content) => (jsx_runtime_1.jsx(committed_metadata_js_1.CommittedMetadataProvider, { value: null, _remotionCommitMetadata: metadata, children: content }));
|
|
114
111
|
if (environment.isStudio &&
|
|
115
112
|
video &&
|
|
116
113
|
video.component === lazy &&
|
|
@@ -119,9 +116,9 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
|
|
|
119
116
|
if (resolved === null ||
|
|
120
117
|
(resolved.type !== 'success' &&
|
|
121
118
|
resolved.type !== 'success-and-refreshing')) {
|
|
122
|
-
return null;
|
|
119
|
+
return wrapRegistration(null);
|
|
123
120
|
}
|
|
124
|
-
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)());
|
|
121
|
+
return wrapRegistration((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)()));
|
|
125
122
|
}
|
|
126
123
|
if (environment.isRendering &&
|
|
127
124
|
video &&
|
|
@@ -131,11 +128,11 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
|
|
|
131
128
|
if (resolved === null ||
|
|
132
129
|
(resolved.type !== 'success' &&
|
|
133
130
|
resolved.type !== 'success-and-refreshing')) {
|
|
134
|
-
return null;
|
|
131
|
+
return wrapRegistration(null);
|
|
135
132
|
}
|
|
136
|
-
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)());
|
|
133
|
+
return wrapRegistration((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)()));
|
|
137
134
|
}
|
|
138
|
-
return null;
|
|
135
|
+
return wrapRegistration(null);
|
|
139
136
|
};
|
|
140
137
|
/*
|
|
141
138
|
* @description This component is used to register a video to make it renderable and make it show in the sidebar, in dev mode.
|
|
@@ -143,12 +140,10 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
|
|
|
143
140
|
*/
|
|
144
141
|
const Composition = (props) => {
|
|
145
142
|
const { onlyRenderComposition } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionSetters);
|
|
146
|
-
const environment = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
|
|
147
143
|
if (onlyRenderComposition && onlyRenderComposition !== props.id) {
|
|
148
144
|
return null;
|
|
149
145
|
}
|
|
150
146
|
// @ts-expect-error
|
|
151
|
-
|
|
152
|
-
return environment.isStudio ? (jsx_runtime_1.jsx(sequence_order_marker_js_1.CompositionOrderMarker, { compositionId: props.id, children: composition })) : (composition);
|
|
147
|
+
return jsx_runtime_1.jsx(InnerComposition, { ...props });
|
|
153
148
|
};
|
|
154
149
|
exports.Composition = Composition;
|
|
@@ -33,8 +33,6 @@ type EnhancedTSequenceData = {
|
|
|
33
33
|
} | {
|
|
34
34
|
type: 'audio';
|
|
35
35
|
src: string;
|
|
36
|
-
volume: string | number;
|
|
37
|
-
doesVolumeChange: boolean;
|
|
38
36
|
muted: boolean;
|
|
39
37
|
startMediaFrom: number;
|
|
40
38
|
mediaFrameAtSequenceZero: number | null;
|
|
@@ -43,8 +41,6 @@ type EnhancedTSequenceData = {
|
|
|
43
41
|
} | {
|
|
44
42
|
type: 'video';
|
|
45
43
|
src: string;
|
|
46
|
-
volume: string | number;
|
|
47
|
-
doesVolumeChange: boolean;
|
|
48
44
|
muted: boolean;
|
|
49
45
|
startMediaFrom: number;
|
|
50
46
|
mediaFrameAtSequenceZero: number | null;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
import type { AnyComposition, TComposition } from './CompositionManager.js';
|
|
2
|
+
import type { AnyComposition } from './CompositionManager.js';
|
|
4
3
|
import type { TFolder } from './Folder.js';
|
|
5
4
|
import type { VideoConfig } from './video-config.js';
|
|
6
5
|
export type BaseMetadata = Pick<VideoConfig, 'durationInFrames' | 'fps' | 'props' | 'height' | 'width' | 'defaultCodec' | 'defaultOutName' | 'defaultVideoImageFormat' | 'defaultPixelFormat' | 'defaultProResProfile' | 'defaultSampleRate'>;
|
|
@@ -27,10 +26,6 @@ export type CanvasContent = {
|
|
|
27
26
|
sizeInBytes: number;
|
|
28
27
|
};
|
|
29
28
|
export type CompositionManagerSetters = {
|
|
30
|
-
registerComposition: <Schema extends AnyZodObject, Props extends Record<string, unknown>>(comp: TComposition<Schema, Props>) => void;
|
|
31
|
-
unregisterComposition: (name: string) => void;
|
|
32
|
-
registerFolder: (name: string, parent: string | null, stack: string | null) => void;
|
|
33
|
-
unregisterFolder: (name: string, parent: string | null) => void;
|
|
34
29
|
setCanvasContent: React.Dispatch<React.SetStateAction<CanvasContent | null>>;
|
|
35
30
|
setCurrentAssetMetadata: React.Dispatch<React.SetStateAction<AssetPreviewMetadata | null>>;
|
|
36
31
|
onlyRenderComposition: string | null;
|
|
@@ -12,10 +12,6 @@ exports.CompositionManager = (0, react_1.createContext)({
|
|
|
12
12
|
canvasContent: null,
|
|
13
13
|
});
|
|
14
14
|
exports.CompositionSetters = (0, react_1.createContext)({
|
|
15
|
-
registerComposition: () => undefined,
|
|
16
|
-
unregisterComposition: () => undefined,
|
|
17
|
-
registerFolder: () => undefined,
|
|
18
|
-
unregisterFolder: () => undefined,
|
|
19
15
|
setCanvasContent: () => undefined,
|
|
20
16
|
setCurrentAssetMetadata: () => undefined,
|
|
21
17
|
onlyRenderComposition: null,
|
|
@@ -3,185 +3,91 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CompositionManagerProvider = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const committed_metadata_js_1 = require("./committed-metadata.js");
|
|
6
7
|
const CompositionManager_1 = require("./CompositionManager");
|
|
7
8
|
const CompositionManagerContext_1 = require("./CompositionManagerContext");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const CompositionRegistryProvider_js_1 = require("./CompositionRegistryProvider.js");
|
|
10
|
+
const registry_store_js_1 = require("./registry-store.js");
|
|
11
|
+
const use_sync_external_store_js_1 = require("./use-sync-external-store.js");
|
|
11
12
|
const CompositionManagerProvider = ({ children, onlyRenderComposition, currentCompositionMetadata, initialCompositions, initialCanvasContent, }) => {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const [folders, setFolders] = (0, react_1.useState)([]);
|
|
13
|
+
const committedKeysRef = (0, react_1.useRef)(new Set());
|
|
14
|
+
const flushSnapshotRef = (0, react_1.useRef)(null);
|
|
15
|
+
const committedDescriptorsRef = (0, react_1.useRef)(new Map());
|
|
16
|
+
const [registrationError, setRegistrationError] = (0, react_1.useState)(null);
|
|
17
|
+
const [registry] = (0, react_1.useState)(() => (0, registry_store_js_1.createRegistryStore)({
|
|
18
|
+
compositions: initialCompositions.map((composition, order) => ({
|
|
19
|
+
...composition,
|
|
20
|
+
order,
|
|
21
|
+
})),
|
|
22
|
+
folders: [],
|
|
23
|
+
}));
|
|
24
|
+
const { compositions, folders } = (0, use_sync_external_store_js_1.useSyncExternalStore)(registry.subscribe, registry.getSnapshot, registry.getSnapshot);
|
|
25
25
|
const [canvasContent, setCanvasContent] = (0, react_1.useState)(initialCanvasContent);
|
|
26
26
|
const [currentAssetMetadata, setCurrentAssetMetadata] = (0, react_1.useState)(null);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
id: comp.id,
|
|
40
|
-
});
|
|
41
|
-
const internalOrder = nextInternalOrderRef.current++;
|
|
42
|
-
internalOrderRef.current.set(orderKey, internalOrder);
|
|
43
|
-
updateCompositions((comps) => {
|
|
44
|
-
var _a;
|
|
45
|
-
var _b;
|
|
46
|
-
if (comps.find((c) => c.id === comp.id)) {
|
|
47
|
-
throw new Error(`Multiple composition with id ${comp.id} are registered.`);
|
|
48
|
-
}
|
|
49
|
-
return [
|
|
50
|
-
...comps,
|
|
51
|
-
{
|
|
52
|
-
...comp,
|
|
53
|
-
order: (_b = (_a = committedOrderRef.current) === null || _a === void 0 ? void 0 : _a.get(orderKey)) !== null && _b !== void 0 ? _b : internalOrder,
|
|
54
|
-
},
|
|
55
|
-
];
|
|
56
|
-
});
|
|
57
|
-
}, [updateCompositions]);
|
|
58
|
-
const unregisterComposition = (0, react_1.useCallback)((id) => {
|
|
59
|
-
internalOrderRef.current.delete((0, sequence_order_marker_js_1.getCompositionAndFolderOrderKey)({ type: 'composition', id }));
|
|
60
|
-
updateCompositions((comps) => comps.filter((c) => c.id !== id));
|
|
61
|
-
}, [updateCompositions]);
|
|
62
|
-
const registerFolder = (0, react_1.useCallback)((name, parent, stack) => {
|
|
63
|
-
const orderKey = (0, sequence_order_marker_js_1.getCompositionAndFolderOrderKey)({
|
|
64
|
-
type: 'folder',
|
|
65
|
-
id: (0, sequence_order_marker_js_1.getFolderOrderId)({ name, parent }),
|
|
66
|
-
});
|
|
67
|
-
const internalOrder = nextInternalOrderRef.current++;
|
|
68
|
-
internalOrderRef.current.set(orderKey, internalOrder);
|
|
69
|
-
setFolders((prevFolders) => {
|
|
70
|
-
var _a;
|
|
71
|
-
var _b;
|
|
72
|
-
return [
|
|
73
|
-
...prevFolders,
|
|
74
|
-
{
|
|
75
|
-
name,
|
|
76
|
-
parent,
|
|
77
|
-
order: (_b = (_a = committedOrderRef.current) === null || _a === void 0 ? void 0 : _a.get(orderKey)) !== null && _b !== void 0 ? _b : internalOrder,
|
|
78
|
-
stack,
|
|
79
|
-
},
|
|
80
|
-
];
|
|
81
|
-
});
|
|
82
|
-
}, []);
|
|
83
|
-
const unregisterFolder = (0, react_1.useCallback)((name, parent) => {
|
|
84
|
-
internalOrderRef.current.delete((0, sequence_order_marker_js_1.getCompositionAndFolderOrderKey)({
|
|
85
|
-
type: 'folder',
|
|
86
|
-
id: (0, sequence_order_marker_js_1.getFolderOrderId)({ name, parent }),
|
|
87
|
-
}));
|
|
88
|
-
setFolders((prevFolders) => {
|
|
89
|
-
return prevFolders.filter((p) => !(p.name === name && p.parent === parent));
|
|
90
|
-
});
|
|
91
|
-
}, []);
|
|
92
|
-
useIsomorphicLayoutEffect(() => {
|
|
93
|
-
if (!isStudio) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
let unmounted = false;
|
|
97
|
-
const onCommitOrder = (event) => {
|
|
98
|
-
const { detail } = event;
|
|
99
|
-
const managerOrder = detail.compositionManagers.find((item) => item.managerId === compositionManagerId);
|
|
100
|
-
if (!managerOrder) {
|
|
27
|
+
const onCommitRegistrations = (0, react_1.useCallback)((pending) => {
|
|
28
|
+
const previousKeys = committedKeysRef.current;
|
|
29
|
+
const previousDescriptors = committedDescriptorsRef.current;
|
|
30
|
+
const existingIds = new Set(registry
|
|
31
|
+
.getSnapshot()
|
|
32
|
+
.compositions.map((composition) => composition.id));
|
|
33
|
+
const descriptors = new Map();
|
|
34
|
+
for (const composition of pending.compositions) {
|
|
35
|
+
const key = `composition:${composition.id}`;
|
|
36
|
+
if (descriptors.has(key) ||
|
|
37
|
+
(!previousKeys.has(key) && existingIds.has(composition.id))) {
|
|
38
|
+
setRegistrationError(new Error(`Multiple composition with id ${composition.id} are registered.`));
|
|
101
39
|
return;
|
|
102
40
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
type: 'composition',
|
|
123
|
-
id: composition.id,
|
|
124
|
-
}))) !== null && _a !== void 0 ? _a : internalOrderRef.current.get((0, sequence_order_marker_js_1.getCompositionAndFolderOrderKey)({
|
|
125
|
-
type: 'composition',
|
|
126
|
-
id: composition.id,
|
|
127
|
-
}))) !== null && _b !== void 0 ? _b : composition.order;
|
|
128
|
-
if (nextOrder === composition.order) {
|
|
129
|
-
return composition;
|
|
130
|
-
}
|
|
131
|
-
changed = true;
|
|
132
|
-
return { ...composition, order: nextOrder };
|
|
133
|
-
});
|
|
134
|
-
return changed ? nextCompositions : currentCompositions;
|
|
135
|
-
});
|
|
136
|
-
setFolders((currentFolders) => {
|
|
137
|
-
let changed = false;
|
|
138
|
-
const nextFolders = currentFolders.map((folder) => {
|
|
139
|
-
var _a, _b;
|
|
140
|
-
const nextOrder = (_b = (_a = order.get((0, sequence_order_marker_js_1.getCompositionAndFolderOrderKey)({
|
|
141
|
-
type: 'folder',
|
|
142
|
-
id: (0, sequence_order_marker_js_1.getFolderOrderId)(folder),
|
|
143
|
-
}))) !== null && _a !== void 0 ? _a : internalOrderRef.current.get((0, sequence_order_marker_js_1.getCompositionAndFolderOrderKey)({
|
|
144
|
-
type: 'folder',
|
|
145
|
-
id: (0, sequence_order_marker_js_1.getFolderOrderId)(folder),
|
|
146
|
-
}))) !== null && _b !== void 0 ? _b : folder.order;
|
|
147
|
-
if (nextOrder === folder.order) {
|
|
148
|
-
return folder;
|
|
149
|
-
}
|
|
150
|
-
changed = true;
|
|
151
|
-
return { ...folder, order: nextOrder };
|
|
152
|
-
});
|
|
153
|
-
return changed ? nextFolders : currentFolders;
|
|
154
|
-
});
|
|
41
|
+
descriptors.set(key, composition);
|
|
42
|
+
}
|
|
43
|
+
for (const folder of pending.folders) {
|
|
44
|
+
descriptors.set(`folder:${(0, committed_metadata_js_1.getFolderOrderId)(folder)}`, folder);
|
|
45
|
+
}
|
|
46
|
+
const nextKeys = new Set(descriptors.keys());
|
|
47
|
+
const order = new Map(pending.orderIds.map((id, index) => [id, index]));
|
|
48
|
+
committedKeysRef.current = nextKeys;
|
|
49
|
+
committedDescriptorsRef.current = descriptors;
|
|
50
|
+
registry.setSnapshot((current) => {
|
|
51
|
+
const nextCompositions = (0, registry_store_js_1.reconcileRegistryEntries)({
|
|
52
|
+
current: current.compositions,
|
|
53
|
+
entries: pending.compositions,
|
|
54
|
+
previousDescriptors,
|
|
55
|
+
previousKeys,
|
|
56
|
+
nextKeys,
|
|
57
|
+
getKey: (composition) => `composition:${composition.id}`,
|
|
58
|
+
order,
|
|
59
|
+
orderProperty: 'order',
|
|
155
60
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
61
|
+
const nextFolders = (0, registry_store_js_1.reconcileRegistryEntries)({
|
|
62
|
+
current: current.folders,
|
|
63
|
+
entries: pending.folders,
|
|
64
|
+
previousDescriptors,
|
|
65
|
+
previousKeys,
|
|
66
|
+
nextKeys,
|
|
67
|
+
getKey: (folder) => `folder:${(0, committed_metadata_js_1.getFolderOrderId)(folder)}`,
|
|
68
|
+
order,
|
|
69
|
+
orderProperty: 'order',
|
|
70
|
+
});
|
|
71
|
+
return nextCompositions === current.compositions &&
|
|
72
|
+
nextFolders === current.folders
|
|
73
|
+
? current
|
|
74
|
+
: { compositions: nextCompositions, folders: nextFolders };
|
|
75
|
+
});
|
|
76
|
+
}, [registry]);
|
|
163
77
|
(0, react_1.useImperativeHandle)(CompositionManager_1.compositionsRef, () => {
|
|
164
78
|
return {
|
|
165
|
-
getCompositions: () =>
|
|
79
|
+
getCompositions: () => {
|
|
80
|
+
var _a;
|
|
81
|
+
(_a = flushSnapshotRef.current) === null || _a === void 0 ? void 0 : _a.call(flushSnapshotRef);
|
|
82
|
+
return registry.getSnapshot().compositions;
|
|
83
|
+
},
|
|
166
84
|
};
|
|
167
|
-
}, []);
|
|
168
|
-
const compositionManagerSetters = (0, react_1.useMemo)(() => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
unregisterComposition,
|
|
172
|
-
registerFolder,
|
|
173
|
-
unregisterFolder,
|
|
174
|
-
setCanvasContent,
|
|
175
|
-
setCurrentAssetMetadata,
|
|
176
|
-
onlyRenderComposition,
|
|
177
|
-
};
|
|
178
|
-
}, [
|
|
179
|
-
registerComposition,
|
|
180
|
-
registerFolder,
|
|
181
|
-
unregisterComposition,
|
|
182
|
-
unregisterFolder,
|
|
85
|
+
}, [registry]);
|
|
86
|
+
const compositionManagerSetters = (0, react_1.useMemo)(() => ({
|
|
87
|
+
setCanvasContent,
|
|
88
|
+
setCurrentAssetMetadata,
|
|
183
89
|
onlyRenderComposition,
|
|
184
|
-
]);
|
|
90
|
+
}), [onlyRenderComposition]);
|
|
185
91
|
const compositionManagerContextValue = (0, react_1.useMemo)(() => {
|
|
186
92
|
return {
|
|
187
93
|
compositions,
|
|
@@ -197,7 +103,9 @@ const CompositionManagerProvider = ({ children, onlyRenderComposition, currentCo
|
|
|
197
103
|
currentAssetMetadata,
|
|
198
104
|
canvasContent,
|
|
199
105
|
]);
|
|
200
|
-
|
|
201
|
-
|
|
106
|
+
if (registrationError !== null) {
|
|
107
|
+
throw registrationError;
|
|
108
|
+
}
|
|
109
|
+
return (jsx_runtime_1.jsx(CompositionRegistryProvider_js_1.CompositionRegistryProvider, { ref: flushSnapshotRef, onSnapshot: onCommitRegistrations, children: jsx_runtime_1.jsx(CompositionManagerContext_1.CompositionManager.Provider, { value: compositionManagerContextValue, children: jsx_runtime_1.jsx(CompositionManagerContext_1.CompositionSetters.Provider, { value: compositionManagerSetters, children: children }) }) }));
|
|
202
110
|
};
|
|
203
111
|
exports.CompositionManagerProvider = CompositionManagerProvider;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type CommittedCompositionSnapshot } from './committed-metadata.js';
|
|
2
|
+
export declare const CompositionRegistryProvider: import("react").ForwardRefExoticComponent<{
|
|
3
|
+
readonly children: import("react").ReactNode;
|
|
4
|
+
readonly onSnapshot: (snapshot: CommittedCompositionSnapshot) => void;
|
|
5
|
+
} & import("react").RefAttributes<() => void>>;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompositionRegistryProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const committed_metadata_js_1 = require("./committed-metadata.js");
|
|
7
|
+
const composition_registry_fallback_js_1 = require("./composition-registry-fallback.js");
|
|
8
|
+
const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
|
|
9
|
+
const useIsomorphicLayoutEffect = typeof window === 'undefined' ? react_1.useEffect : react_1.useLayoutEffect;
|
|
10
|
+
const CompositionRegistryFallbackProvider = (0, committed_metadata_js_1.withCommittedMetadata)(composition_registry_fallback_js_1.CompositionRegistryFallbackContext.Provider);
|
|
11
|
+
// Every consumer receives a complete committed snapshot. The fallback changes
|
|
12
|
+
// how descriptors are captured, rather than exposing a second registration API.
|
|
13
|
+
exports.CompositionRegistryProvider = (0, react_1.forwardRef)(({ children, onSnapshot }, flushSnapshotRef) => {
|
|
14
|
+
const { isStudio } = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
|
|
15
|
+
const [managerId] = (0, react_1.useState)(() => String(Math.random()));
|
|
16
|
+
const [useCommitObserver, setUseCommitObserver] = (0, react_1.useState)(() => isStudio && (0, committed_metadata_js_1.isCommitRegistrationObserverInstalled)());
|
|
17
|
+
const observedCommitRef = (0, react_1.useRef)(false);
|
|
18
|
+
const observerFailedRef = (0, react_1.useRef)(false);
|
|
19
|
+
const unmountedRef = (0, react_1.useRef)(false);
|
|
20
|
+
const onSnapshotRef = (0, react_1.useRef)(onSnapshot);
|
|
21
|
+
const lastSnapshotRef = (0, react_1.useRef)(null);
|
|
22
|
+
const pendingSnapshotRef = (0, react_1.useRef)(null);
|
|
23
|
+
const flushSnapshot = (0, react_1.useCallback)(() => {
|
|
24
|
+
const pending = pendingSnapshotRef.current;
|
|
25
|
+
pendingSnapshotRef.current = null;
|
|
26
|
+
if (pending === null || unmountedRef.current) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const committed = typeof pending === 'function' ? pending() : pending;
|
|
30
|
+
const previous = lastSnapshotRef.current;
|
|
31
|
+
if (previous !== null &&
|
|
32
|
+
(previous.compositions === committed.compositions ||
|
|
33
|
+
(previous.compositions.length === committed.compositions.length &&
|
|
34
|
+
previous.compositions.every((composition, index) => composition === committed.compositions[index]))) &&
|
|
35
|
+
(previous.folders === committed.folders ||
|
|
36
|
+
(previous.folders.length === committed.folders.length &&
|
|
37
|
+
previous.folders.every((folder, index) => folder === committed.folders[index]))) &&
|
|
38
|
+
(previous.orderIds === committed.orderIds ||
|
|
39
|
+
(previous.orderIds.length === committed.orderIds.length &&
|
|
40
|
+
previous.orderIds.every((id, index) => id === committed.orderIds[index])))) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
lastSnapshotRef.current = committed;
|
|
44
|
+
onSnapshotRef.current(committed);
|
|
45
|
+
}, []);
|
|
46
|
+
(0, react_1.useImperativeHandle)(flushSnapshotRef, () => flushSnapshot, [flushSnapshot]);
|
|
47
|
+
const queueSnapshot = (0, react_1.useCallback)((snapshot) => {
|
|
48
|
+
const alreadyPending = pendingSnapshotRef.current !== null;
|
|
49
|
+
pendingSnapshotRef.current = snapshot;
|
|
50
|
+
if (alreadyPending) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
queueMicrotask(flushSnapshot);
|
|
54
|
+
}, [flushSnapshot]);
|
|
55
|
+
const onObservedSnapshot = (0, react_1.useCallback)((snapshot) => {
|
|
56
|
+
if (observerFailedRef.current) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
observedCommitRef.current = true;
|
|
60
|
+
queueSnapshot(snapshot);
|
|
61
|
+
}, [queueSnapshot]);
|
|
62
|
+
const fallbackRegistry = (0, react_1.useMemo)(() => {
|
|
63
|
+
const entries = new Map();
|
|
64
|
+
const getSnapshot = () => {
|
|
65
|
+
const compositions = [];
|
|
66
|
+
const folders = [];
|
|
67
|
+
const orderIds = [];
|
|
68
|
+
for (const entry of entries.values()) {
|
|
69
|
+
if (entry.type === 'composition') {
|
|
70
|
+
compositions.push(entry.value);
|
|
71
|
+
orderIds.push((0, committed_metadata_js_1.getCompositionAndFolderOrderKey)({
|
|
72
|
+
type: 'composition',
|
|
73
|
+
id: entry.value.id,
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
folders.push(entry.value);
|
|
78
|
+
orderIds.push((0, committed_metadata_js_1.getCompositionAndFolderOrderKey)({
|
|
79
|
+
type: 'folder',
|
|
80
|
+
id: (0, committed_metadata_js_1.getFolderOrderId)(entry.value),
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { compositions, folders, orderIds };
|
|
85
|
+
};
|
|
86
|
+
return { entries, notifyCommit: () => queueSnapshot(getSnapshot) };
|
|
87
|
+
}, [queueSnapshot]);
|
|
88
|
+
useIsomorphicLayoutEffect(() => {
|
|
89
|
+
if (onSnapshotRef.current !== onSnapshot) {
|
|
90
|
+
const previous = lastSnapshotRef.current;
|
|
91
|
+
lastSnapshotRef.current = null;
|
|
92
|
+
if (useCommitObserver && previous !== null) {
|
|
93
|
+
queueSnapshot(previous);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
onSnapshotRef.current = onSnapshot;
|
|
97
|
+
if (!useCommitObserver) {
|
|
98
|
+
fallbackRegistry.notifyCommit();
|
|
99
|
+
}
|
|
100
|
+
}, [fallbackRegistry, onSnapshot, queueSnapshot, useCommitObserver]);
|
|
101
|
+
useIsomorphicLayoutEffect(() => {
|
|
102
|
+
unmountedRef.current = false;
|
|
103
|
+
let unmounted = false;
|
|
104
|
+
const onRegistrationError = () => {
|
|
105
|
+
if (observerFailedRef.current) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
observerFailedRef.current = true;
|
|
109
|
+
pendingSnapshotRef.current = null;
|
|
110
|
+
queueMicrotask(() => {
|
|
111
|
+
if (!unmountedRef.current) {
|
|
112
|
+
setUseCommitObserver(false);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
if (isStudio) {
|
|
117
|
+
window.addEventListener(committed_metadata_js_1.COMMIT_REGISTRATION_ERROR_EVENT, onRegistrationError);
|
|
118
|
+
if (useCommitObserver) {
|
|
119
|
+
queueMicrotask(() => {
|
|
120
|
+
if (!unmounted && !observedCommitRef.current) {
|
|
121
|
+
onRegistrationError();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return () => {
|
|
127
|
+
unmounted = true;
|
|
128
|
+
unmountedRef.current = true;
|
|
129
|
+
if (isStudio) {
|
|
130
|
+
window.removeEventListener(committed_metadata_js_1.COMMIT_REGISTRATION_ERROR_EVENT, onRegistrationError);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}, [isStudio, useCommitObserver]);
|
|
134
|
+
const metadata = (0, react_1.useMemo)(() => isStudio
|
|
135
|
+
? {
|
|
136
|
+
type: 'composition-manager',
|
|
137
|
+
id: managerId,
|
|
138
|
+
onCommit: useCommitObserver ? onObservedSnapshot : null,
|
|
139
|
+
}
|
|
140
|
+
: null, [isStudio, managerId, onObservedSnapshot, useCommitObserver]);
|
|
141
|
+
return (jsx_runtime_1.jsx(CompositionRegistryFallbackProvider, { value: useCommitObserver ? null : fallbackRegistry, _remotionCommitMetadata: metadata, children: children }));
|
|
142
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DefaultPremountContext: import("react").Context<number>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultPremountContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const default_premount_in_seconds_js_1 = require("./default-premount-in-seconds.js");
|
|
6
|
+
exports.DefaultPremountContext = (0, react_1.createContext)(default_premount_in_seconds_js_1.DEFAULT_PREMOUNT_IN_SECONDS);
|