remotion 4.0.438 → 4.0.440
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/Composition.js +0 -7
- package/dist/cjs/CompositionManager.d.ts +3 -0
- package/dist/cjs/CompositionManagerContext.d.ts +0 -1
- package/dist/cjs/CompositionManagerContext.js +0 -1
- package/dist/cjs/CompositionManagerProvider.js +0 -16
- package/dist/cjs/EditorProps.d.ts +0 -5
- package/dist/cjs/EditorProps.js +3 -23
- package/dist/cjs/Img.d.ts +6 -0
- package/dist/cjs/Img.js +16 -1
- package/dist/cjs/ResolveCompositionConfig.d.ts +0 -1
- package/dist/cjs/ResolveCompositionConfig.js +1 -2
- package/dist/cjs/codec.d.ts +1 -1
- package/dist/cjs/codec.js +1 -0
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/internals.d.ts +1 -10
- package/dist/cjs/internals.js +0 -2
- package/dist/cjs/interpolate-colors.js +176 -0
- package/dist/cjs/use-media-in-timeline.d.ts +11 -1
- package/dist/cjs/use-media-in-timeline.js +64 -1
- package/dist/cjs/use-schema.js +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/index.mjs +279 -90
- package/dist/esm/no-react.mjs +158 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
package/dist/cjs/Composition.js
CHANGED
|
@@ -93,13 +93,6 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
|
|
|
93
93
|
registerComposition,
|
|
94
94
|
unregisterComposition,
|
|
95
95
|
]);
|
|
96
|
-
(0, react_1.useEffect)(() => {
|
|
97
|
-
window.dispatchEvent(new CustomEvent(ResolveCompositionConfig_js_1.PROPS_UPDATED_EXTERNALLY, {
|
|
98
|
-
detail: {
|
|
99
|
-
resetUnsaved: id,
|
|
100
|
-
},
|
|
101
|
-
}));
|
|
102
|
-
}, [defaultProps, id]);
|
|
103
96
|
const resolved = (0, ResolveCompositionConfig_js_1.useResolvedVideoConfig)(id);
|
|
104
97
|
if (environment.isStudio &&
|
|
105
98
|
video &&
|
|
@@ -28,7 +28,6 @@ export type CompositionManagerSetters = {
|
|
|
28
28
|
registerFolder: (name: string, parent: string | null, nonce: NonceHistory) => void;
|
|
29
29
|
unregisterFolder: (name: string, parent: string | null) => void;
|
|
30
30
|
setCanvasContent: React.Dispatch<React.SetStateAction<CanvasContent | null>>;
|
|
31
|
-
updateCompositionDefaultProps: (id: string, newDefaultProps: Record<string, unknown>) => void;
|
|
32
31
|
onlyRenderComposition: string | null;
|
|
33
32
|
};
|
|
34
33
|
export type CompositionManagerContext = {
|
|
@@ -53,20 +53,6 @@ const CompositionManagerProvider = ({ children, onlyRenderComposition, currentCo
|
|
|
53
53
|
getCompositions: () => currentcompositionsRef.current,
|
|
54
54
|
};
|
|
55
55
|
}, []);
|
|
56
|
-
const updateCompositionDefaultProps = (0, react_1.useCallback)((id, newDefaultProps) => {
|
|
57
|
-
setCompositions((comps) => {
|
|
58
|
-
const updated = comps.map((c) => {
|
|
59
|
-
if (c.id === id) {
|
|
60
|
-
return {
|
|
61
|
-
...c,
|
|
62
|
-
defaultProps: newDefaultProps,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return c;
|
|
66
|
-
});
|
|
67
|
-
return updated;
|
|
68
|
-
});
|
|
69
|
-
}, []);
|
|
70
56
|
const compositionManagerSetters = (0, react_1.useMemo)(() => {
|
|
71
57
|
return {
|
|
72
58
|
registerComposition,
|
|
@@ -74,7 +60,6 @@ const CompositionManagerProvider = ({ children, onlyRenderComposition, currentCo
|
|
|
74
60
|
registerFolder,
|
|
75
61
|
unregisterFolder,
|
|
76
62
|
setCanvasContent,
|
|
77
|
-
updateCompositionDefaultProps,
|
|
78
63
|
onlyRenderComposition,
|
|
79
64
|
};
|
|
80
65
|
}, [
|
|
@@ -82,7 +67,6 @@ const CompositionManagerProvider = ({ children, onlyRenderComposition, currentCo
|
|
|
82
67
|
registerFolder,
|
|
83
68
|
unregisterComposition,
|
|
84
69
|
unregisterFolder,
|
|
85
|
-
updateCompositionDefaultProps,
|
|
86
70
|
onlyRenderComposition,
|
|
87
71
|
]);
|
|
88
72
|
const compositionManagerContextValue = (0, react_1.useMemo)(() => {
|
|
@@ -8,13 +8,8 @@ export type EditorPropsContextType = {
|
|
|
8
8
|
defaultProps: Record<string, unknown>;
|
|
9
9
|
newProps: Record<string, unknown> | ((oldProps: Record<string, unknown>) => Record<string, unknown>);
|
|
10
10
|
}) => void;
|
|
11
|
-
resetUnsaved: (compositionId: string) => void;
|
|
12
11
|
};
|
|
13
12
|
export declare const EditorPropsContext: React.Context<EditorPropsContextType>;
|
|
14
|
-
export declare const editorPropsProviderRef: React.RefObject<{
|
|
15
|
-
getProps: () => Props;
|
|
16
|
-
setProps: React.Dispatch<React.SetStateAction<Props>>;
|
|
17
|
-
} | null>;
|
|
18
13
|
export declare const timeValueRef: React.RefObject<{
|
|
19
14
|
goToFrame: () => void;
|
|
20
15
|
seek: (newFrame: number) => void;
|
package/dist/cjs/EditorProps.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.EditorPropsProvider = exports.timeValueRef = exports.
|
|
36
|
+
exports.EditorPropsProvider = exports.timeValueRef = exports.EditorPropsContext = void 0;
|
|
37
37
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
38
|
const react_1 = __importStar(require("react"));
|
|
39
39
|
exports.EditorPropsContext = (0, react_1.createContext)({
|
|
@@ -41,11 +41,7 @@ exports.EditorPropsContext = (0, react_1.createContext)({
|
|
|
41
41
|
updateProps: () => {
|
|
42
42
|
throw new Error('Not implemented');
|
|
43
43
|
},
|
|
44
|
-
resetUnsaved: () => {
|
|
45
|
-
throw new Error('Not implemented');
|
|
46
|
-
},
|
|
47
44
|
});
|
|
48
|
-
exports.editorPropsProviderRef = react_1.default.createRef();
|
|
49
45
|
exports.timeValueRef = react_1.default.createRef();
|
|
50
46
|
const EditorPropsProvider = ({ children }) => {
|
|
51
47
|
const [props, setProps] = react_1.default.useState({});
|
|
@@ -60,25 +56,9 @@ const EditorPropsProvider = ({ children }) => {
|
|
|
60
56
|
};
|
|
61
57
|
});
|
|
62
58
|
}, []);
|
|
63
|
-
const resetUnsaved = (0, react_1.useCallback)((compositionId) => {
|
|
64
|
-
setProps((prev) => {
|
|
65
|
-
if (prev[compositionId]) {
|
|
66
|
-
const newProps = { ...prev };
|
|
67
|
-
delete newProps[compositionId];
|
|
68
|
-
return newProps;
|
|
69
|
-
}
|
|
70
|
-
return prev;
|
|
71
|
-
});
|
|
72
|
-
}, []);
|
|
73
|
-
(0, react_1.useImperativeHandle)(exports.editorPropsProviderRef, () => {
|
|
74
|
-
return {
|
|
75
|
-
getProps: () => props,
|
|
76
|
-
setProps,
|
|
77
|
-
};
|
|
78
|
-
}, [props]);
|
|
79
59
|
const ctx = (0, react_1.useMemo)(() => {
|
|
80
|
-
return { props, updateProps
|
|
81
|
-
}, [props,
|
|
60
|
+
return { props, updateProps };
|
|
61
|
+
}, [props, updateProps]);
|
|
82
62
|
return ((0, jsx_runtime_1.jsx)(exports.EditorPropsContext.Provider, { value: ctx, children: children }));
|
|
83
63
|
};
|
|
84
64
|
exports.EditorPropsProvider = EditorPropsProvider;
|
package/dist/cjs/Img.d.ts
CHANGED
|
@@ -7,6 +7,12 @@ export type ImgProps = NativeImgProps & {
|
|
|
7
7
|
readonly delayRenderTimeoutInMilliseconds?: number;
|
|
8
8
|
readonly onImageFrame?: (imageElement: HTMLImageElement) => void;
|
|
9
9
|
readonly src: string;
|
|
10
|
+
readonly showInTimeline?: boolean;
|
|
11
|
+
readonly name?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated For internal use only
|
|
14
|
+
*/
|
|
15
|
+
readonly stack?: string;
|
|
10
16
|
};
|
|
11
17
|
export declare const Img: React.ForwardRefExoticComponent<Omit<ImgProps, "ref"> & React.RefAttributes<HTMLImageElement>>;
|
|
12
18
|
export {};
|
package/dist/cjs/Img.js
CHANGED
|
@@ -3,20 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Img = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const enable_sequence_stack_traces_js_1 = require("./enable-sequence-stack-traces.js");
|
|
6
7
|
const get_cross_origin_value_js_1 = require("./get-cross-origin-value.js");
|
|
7
8
|
const prefetch_js_1 = require("./prefetch.js");
|
|
8
9
|
const SequenceContext_js_1 = require("./SequenceContext.js");
|
|
9
10
|
const use_buffer_state_js_1 = require("./use-buffer-state.js");
|
|
10
11
|
const use_delay_render_js_1 = require("./use-delay-render.js");
|
|
12
|
+
const use_media_in_timeline_js_1 = require("./use-media-in-timeline.js");
|
|
11
13
|
const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
|
|
12
14
|
function exponentialBackoff(errorCount) {
|
|
13
15
|
return 1000 * 2 ** (errorCount - 1);
|
|
14
16
|
}
|
|
15
|
-
const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, delayRenderRetries, delayRenderTimeoutInMilliseconds, onImageFrame, crossOrigin, ...props }, ref) => {
|
|
17
|
+
const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, delayRenderRetries, delayRenderTimeoutInMilliseconds, onImageFrame, crossOrigin, showInTimeline, name, stack, ...props }, ref) => {
|
|
18
|
+
var _a, _b;
|
|
16
19
|
const imageRef = (0, react_1.useRef)(null);
|
|
17
20
|
const errors = (0, react_1.useRef)({});
|
|
18
21
|
const { delayPlayback } = (0, use_buffer_state_js_1.useBufferState)();
|
|
19
22
|
const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
|
|
23
|
+
const [timelineId] = (0, react_1.useState)(() => String(Math.random()));
|
|
20
24
|
if (!src) {
|
|
21
25
|
throw new Error('No "src" prop was passed to <Img>.');
|
|
22
26
|
}
|
|
@@ -27,6 +31,16 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
|
|
|
27
31
|
(0, react_1.useImperativeHandle)(ref, () => {
|
|
28
32
|
return imageRef.current;
|
|
29
33
|
}, []);
|
|
34
|
+
(0, use_media_in_timeline_js_1.useImageInTimeline)({
|
|
35
|
+
src,
|
|
36
|
+
displayName: name !== null && name !== void 0 ? name : null,
|
|
37
|
+
id: timelineId,
|
|
38
|
+
stack: stack !== null && stack !== void 0 ? stack : null,
|
|
39
|
+
showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true,
|
|
40
|
+
premountDisplay: (_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premountDisplay) !== null && _a !== void 0 ? _a : null,
|
|
41
|
+
postmountDisplay: (_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.postmountDisplay) !== null && _b !== void 0 ? _b : null,
|
|
42
|
+
loopDisplay: undefined,
|
|
43
|
+
});
|
|
30
44
|
const actualSrc = (0, prefetch_js_1.usePreload)(src);
|
|
31
45
|
const retryIn = (0, react_1.useCallback)((timeout) => {
|
|
32
46
|
if (!imageRef.current) {
|
|
@@ -175,3 +189,4 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
|
|
|
175
189
|
* @see [Documentation](https://remotion.dev/docs/img)
|
|
176
190
|
*/
|
|
177
191
|
exports.Img = (0, react_1.forwardRef)(ImgRefForwarding);
|
|
192
|
+
(0, enable_sequence_stack_traces_js_1.addSequenceStackTraces)(exports.Img);
|
|
@@ -19,6 +19,5 @@ type VideoConfigState = {
|
|
|
19
19
|
error: Error;
|
|
20
20
|
};
|
|
21
21
|
export declare const needsResolution: (composition: AnyComposition) => boolean;
|
|
22
|
-
export declare const PROPS_UPDATED_EXTERNALLY = "remotion.propsUpdatedExternally";
|
|
23
22
|
export declare const useResolvedVideoConfig: (preferredCompositionId: string | null) => VideoConfigState | null;
|
|
24
23
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useResolvedVideoConfig = exports.
|
|
3
|
+
exports.useResolvedVideoConfig = exports.needsResolution = exports.resolveCompositionsRef = exports.ResolveCompositionContext = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const CompositionManagerContext_js_1 = require("./CompositionManagerContext.js");
|
|
6
6
|
const input_props_js_1 = require("./config/input-props.js");
|
|
@@ -15,7 +15,6 @@ const needsResolution = (composition) => {
|
|
|
15
15
|
return Boolean(composition.calculateMetadata);
|
|
16
16
|
};
|
|
17
17
|
exports.needsResolution = needsResolution;
|
|
18
|
-
exports.PROPS_UPDATED_EXTERNALLY = 'remotion.propsUpdatedExternally';
|
|
19
18
|
const useResolvedVideoConfig = (preferredCompositionId) => {
|
|
20
19
|
const context = (0, react_1.useContext)(exports.ResolveCompositionContext);
|
|
21
20
|
const { props: allEditorProps } = (0, react_1.useContext)(EditorProps_js_1.EditorPropsContext);
|
package/dist/cjs/codec.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const validCodecs: readonly ["h264", "h265", "vp8", "vp9", "mp3", "aac", "wav", "prores", "h264-mkv", "h264-ts", "gif"];
|
|
1
|
+
export declare const validCodecs: readonly ["h264", "h265", "vp8", "vp9", "av1", "mp3", "aac", "wav", "prores", "h264-mkv", "h264-ts", "gif"];
|
|
2
2
|
export type Codec = (typeof validCodecs)[number];
|
|
3
3
|
export type CodecOrUndefined = Codec | undefined;
|
|
4
4
|
export declare const DEFAULT_CODEC: Codec;
|
package/dist/cjs/codec.js
CHANGED
package/dist/cjs/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ declare global {
|
|
|
39
39
|
remotion_ignoreFastRefreshUpdate: number | null;
|
|
40
40
|
remotion_numberOfAudioTags: number;
|
|
41
41
|
remotion_audioLatencyHint: AudioContextLatencyCategory | undefined;
|
|
42
|
-
remotion_logLevel: LogLevel;
|
|
42
|
+
remotion_logLevel: LogLevel | undefined;
|
|
43
43
|
remotion_projectName: string;
|
|
44
44
|
remotion_cwd: string;
|
|
45
45
|
remotion_studioServerCommand: string;
|
|
@@ -65,7 +65,6 @@ declare global {
|
|
|
65
65
|
siteVersion: '11';
|
|
66
66
|
remotion_version: string;
|
|
67
67
|
remotion_imported: string | boolean;
|
|
68
|
-
remotion_unsavedProps: boolean | undefined;
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
70
|
export type BundleCompositionState = {
|
package/dist/cjs/internals.d.ts
CHANGED
|
@@ -315,15 +315,6 @@ export declare const Internals: {
|
|
|
315
315
|
height: number;
|
|
316
316
|
};
|
|
317
317
|
}) => number;
|
|
318
|
-
readonly editorPropsProviderRef: import("react").RefObject<{
|
|
319
|
-
getProps: () => {
|
|
320
|
-
[x: string]: Record<string, unknown>;
|
|
321
|
-
};
|
|
322
|
-
setProps: React.Dispatch<React.SetStateAction<{
|
|
323
|
-
[x: string]: Record<string, unknown>;
|
|
324
|
-
}>>;
|
|
325
|
-
} | null>;
|
|
326
|
-
readonly PROPS_UPDATED_EXTERNALLY: "remotion.propsUpdatedExternally";
|
|
327
318
|
readonly validateRenderAsset: (artifact: TRenderAsset) => void;
|
|
328
319
|
readonly Log: {
|
|
329
320
|
trace: (options: {
|
|
@@ -401,7 +392,7 @@ export declare const Internals: {
|
|
|
401
392
|
readonly useBasicMediaInTimeline: ({ volume, mediaVolume, mediaType, src, displayName, trimBefore, trimAfter, playbackRate, }: {
|
|
402
393
|
volume: import("./volume-prop.js").VolumeProp | undefined;
|
|
403
394
|
mediaVolume: number;
|
|
404
|
-
mediaType: "audio" | "video";
|
|
395
|
+
mediaType: "audio" | "video" | "image";
|
|
405
396
|
src: string | undefined;
|
|
406
397
|
displayName: string | null;
|
|
407
398
|
trimBefore: number | undefined;
|
package/dist/cjs/internals.js
CHANGED
|
@@ -184,8 +184,6 @@ exports.Internals = {
|
|
|
184
184
|
CurrentScaleContext: use_current_scale_js_1.CurrentScaleContext,
|
|
185
185
|
PreviewSizeContext: use_current_scale_js_1.PreviewSizeContext,
|
|
186
186
|
calculateScale: use_current_scale_js_1.calculateScale,
|
|
187
|
-
editorPropsProviderRef: EditorProps_js_1.editorPropsProviderRef,
|
|
188
|
-
PROPS_UPDATED_EXTERNALLY: ResolveCompositionConfig_js_1.PROPS_UPDATED_EXTERNALLY,
|
|
189
187
|
validateRenderAsset: validate_artifact_js_1.validateRenderAsset,
|
|
190
188
|
Log: log_js_1.Log,
|
|
191
189
|
LogLevelContext: log_level_context_js_1.LogLevelContext,
|
|
@@ -13,6 +13,20 @@ const PERCENTAGE = NUMBER + '%';
|
|
|
13
13
|
function call(...args) {
|
|
14
14
|
return '\\(\\s*(' + args.join(')\\s*,\\s*(') + ')\\s*\\)';
|
|
15
15
|
}
|
|
16
|
+
// Modern CSS Color Level 4 syntax: space-separated values with optional / alpha
|
|
17
|
+
const MODERN_VALUE = '(?:none|[-+]?\\d*\\.?\\d+(?:%|deg|rad|grad|turn)?)';
|
|
18
|
+
function modernColorCall(name) {
|
|
19
|
+
return new RegExp(name +
|
|
20
|
+
'\\(\\s*(' +
|
|
21
|
+
MODERN_VALUE +
|
|
22
|
+
')\\s+(' +
|
|
23
|
+
MODERN_VALUE +
|
|
24
|
+
')\\s+(' +
|
|
25
|
+
MODERN_VALUE +
|
|
26
|
+
')(?:\\s*\\/\\s*(' +
|
|
27
|
+
MODERN_VALUE +
|
|
28
|
+
'))?\\s*\\)');
|
|
29
|
+
}
|
|
16
30
|
function getMatchers() {
|
|
17
31
|
const cachedMatchers = {
|
|
18
32
|
rgb: undefined,
|
|
@@ -24,6 +38,11 @@ function getMatchers() {
|
|
|
24
38
|
hex5: undefined,
|
|
25
39
|
hex6: undefined,
|
|
26
40
|
hex8: undefined,
|
|
41
|
+
oklch: undefined,
|
|
42
|
+
oklab: undefined,
|
|
43
|
+
lab: undefined,
|
|
44
|
+
lch: undefined,
|
|
45
|
+
hwb: undefined,
|
|
27
46
|
};
|
|
28
47
|
if (cachedMatchers.rgb === undefined) {
|
|
29
48
|
cachedMatchers.rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER));
|
|
@@ -35,6 +54,11 @@ function getMatchers() {
|
|
|
35
54
|
/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
|
36
55
|
cachedMatchers.hex6 = /^#([0-9a-fA-F]{6})$/;
|
|
37
56
|
cachedMatchers.hex8 = /^#([0-9a-fA-F]{8})$/;
|
|
57
|
+
cachedMatchers.oklch = modernColorCall('oklch');
|
|
58
|
+
cachedMatchers.oklab = modernColorCall('oklab');
|
|
59
|
+
cachedMatchers.lab = modernColorCall('lab');
|
|
60
|
+
cachedMatchers.lch = modernColorCall('lch');
|
|
61
|
+
cachedMatchers.hwb = modernColorCall('hwb');
|
|
38
62
|
}
|
|
39
63
|
return cachedMatchers;
|
|
40
64
|
}
|
|
@@ -101,6 +125,106 @@ function parsePercentage(str) {
|
|
|
101
125
|
}
|
|
102
126
|
return int / 100;
|
|
103
127
|
}
|
|
128
|
+
// Modern CSS Color Level 4 parsing helpers
|
|
129
|
+
function parseModernComponent(str, percentScale) {
|
|
130
|
+
if (str === 'none')
|
|
131
|
+
return 0;
|
|
132
|
+
if (str.endsWith('%')) {
|
|
133
|
+
return (Number.parseFloat(str) / 100) * percentScale;
|
|
134
|
+
}
|
|
135
|
+
return Number.parseFloat(str);
|
|
136
|
+
}
|
|
137
|
+
function parseHueAngle(str) {
|
|
138
|
+
if (str === 'none')
|
|
139
|
+
return 0;
|
|
140
|
+
if (str.endsWith('rad')) {
|
|
141
|
+
return (Number.parseFloat(str) * 180) / Math.PI;
|
|
142
|
+
}
|
|
143
|
+
if (str.endsWith('grad'))
|
|
144
|
+
return Number.parseFloat(str) * 0.9;
|
|
145
|
+
if (str.endsWith('turn'))
|
|
146
|
+
return Number.parseFloat(str) * 360;
|
|
147
|
+
// 'deg' suffix or plain number = degrees
|
|
148
|
+
return Number.parseFloat(str);
|
|
149
|
+
}
|
|
150
|
+
function parseModernAlpha(str) {
|
|
151
|
+
if (str === undefined || str === 'none')
|
|
152
|
+
return 1;
|
|
153
|
+
if (str.endsWith('%')) {
|
|
154
|
+
return Math.max(0, Math.min(1, Number.parseFloat(str) / 100));
|
|
155
|
+
}
|
|
156
|
+
return Math.max(0, Math.min(1, Number.parseFloat(str)));
|
|
157
|
+
}
|
|
158
|
+
// sRGB gamma correction
|
|
159
|
+
function linearToSrgb(c) {
|
|
160
|
+
if (c <= 0.0031308)
|
|
161
|
+
return 12.92 * c;
|
|
162
|
+
return 1.055 * c ** (1 / 2.4) - 0.055;
|
|
163
|
+
}
|
|
164
|
+
function clamp01(v) {
|
|
165
|
+
return Math.max(0, Math.min(1, v));
|
|
166
|
+
}
|
|
167
|
+
function rgbFloatToInt(r, g, b, alpha) {
|
|
168
|
+
const ri = Math.round(clamp01(r) * 255);
|
|
169
|
+
const gi = Math.round(clamp01(g) * 255);
|
|
170
|
+
const bi = Math.round(clamp01(b) * 255);
|
|
171
|
+
const ai = Math.round(clamp01(alpha) * 255);
|
|
172
|
+
return ((ri << 24) | (gi << 16) | (bi << 8) | ai) >>> 0;
|
|
173
|
+
}
|
|
174
|
+
// OKLab to sRGB conversion
|
|
175
|
+
function oklabToSrgb(L, a, b) {
|
|
176
|
+
const l_ = L + 0.3963377774 * a + 0.2158037573 * b;
|
|
177
|
+
const m_ = L - 0.1055613458 * a - 0.0638541728 * b;
|
|
178
|
+
const s_ = L - 0.0894841775 * a - 1.291485548 * b;
|
|
179
|
+
const l = l_ * l_ * l_;
|
|
180
|
+
const m = m_ * m_ * m_;
|
|
181
|
+
const s = s_ * s_ * s_;
|
|
182
|
+
const rLin = 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s;
|
|
183
|
+
const gLin = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s;
|
|
184
|
+
const bLin = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s;
|
|
185
|
+
return [linearToSrgb(rLin), linearToSrgb(gLin), linearToSrgb(bLin)];
|
|
186
|
+
}
|
|
187
|
+
// CIE Lab to sRGB conversion (D65 illuminant)
|
|
188
|
+
function labToSrgb(L, a, b) {
|
|
189
|
+
const epsilon = 216 / 24389;
|
|
190
|
+
const kappa = 24389 / 27;
|
|
191
|
+
// D65 white point
|
|
192
|
+
const Xn = 0.95047;
|
|
193
|
+
const Yn = 1.0;
|
|
194
|
+
const Zn = 1.08883;
|
|
195
|
+
const fy = (L + 16) / 116;
|
|
196
|
+
const fx = a / 500 + fy;
|
|
197
|
+
const fz = fy - b / 200;
|
|
198
|
+
const fx3 = fx * fx * fx;
|
|
199
|
+
const fz3 = fz * fz * fz;
|
|
200
|
+
const xr = fx3 > epsilon ? fx3 : (116 * fx - 16) / kappa;
|
|
201
|
+
const yr = L > kappa * epsilon ? ((L + 16) / 116) ** 3 : L / kappa;
|
|
202
|
+
const zr = fz3 > epsilon ? fz3 : (116 * fz - 16) / kappa;
|
|
203
|
+
const X = xr * Xn;
|
|
204
|
+
const Y = yr * Yn;
|
|
205
|
+
const Z = zr * Zn;
|
|
206
|
+
// XYZ to linear sRGB (D65)
|
|
207
|
+
const rLin = 3.2404542 * X - 1.5371385 * Y - 0.4985314 * Z;
|
|
208
|
+
const gLin = -0.969266 * X + 1.8760108 * Y + 0.041556 * Z;
|
|
209
|
+
const bLin = 0.0556434 * X - 0.2040259 * Y + 1.0572252 * Z;
|
|
210
|
+
return [linearToSrgb(rLin), linearToSrgb(gLin), linearToSrgb(bLin)];
|
|
211
|
+
}
|
|
212
|
+
// HWB to sRGB conversion
|
|
213
|
+
function hwbToSrgb(h, w, bk) {
|
|
214
|
+
// h is 0-1 (hue as fraction of 360), w and bk are 0-1
|
|
215
|
+
if (w + bk >= 1) {
|
|
216
|
+
const gray = w / (w + bk);
|
|
217
|
+
return [gray, gray, gray];
|
|
218
|
+
}
|
|
219
|
+
// Get pure hue RGB (HSL with S=100%, L=50%)
|
|
220
|
+
const q = 1; // l=0.5, s=1: q = 0.5*(1+1) = 1
|
|
221
|
+
const p = 0; // 2*0.5 - 1 = 0
|
|
222
|
+
const r = hue2rgb(p, q, h + 1 / 3);
|
|
223
|
+
const g = hue2rgb(p, q, h);
|
|
224
|
+
const bl = hue2rgb(p, q, h - 1 / 3);
|
|
225
|
+
const factor = 1 - w - bk;
|
|
226
|
+
return [r * factor + w, g * factor + w, bl * factor + w];
|
|
227
|
+
}
|
|
104
228
|
exports.colorNames = {
|
|
105
229
|
transparent: 0x00000000,
|
|
106
230
|
// http://www.w3.org/TR/css3-color/#svg-color
|
|
@@ -339,6 +463,58 @@ function normalizeColor(color) {
|
|
|
339
463
|
0);
|
|
340
464
|
}
|
|
341
465
|
}
|
|
466
|
+
if (matchers.oklch) {
|
|
467
|
+
if ((match = matchers.oklch.exec(color))) {
|
|
468
|
+
const L = parseModernComponent(match[1], 1); // 100% = 1
|
|
469
|
+
const C = parseModernComponent(match[2], 0.4); // 100% = 0.4
|
|
470
|
+
const H = parseHueAngle(match[3]);
|
|
471
|
+
const alpha = parseModernAlpha(match[4]);
|
|
472
|
+
const hRad = (H * Math.PI) / 180;
|
|
473
|
+
const [r, g, b] = oklabToSrgb(L, C * Math.cos(hRad), C * Math.sin(hRad));
|
|
474
|
+
return rgbFloatToInt(r, g, b, alpha);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (matchers.oklab) {
|
|
478
|
+
if ((match = matchers.oklab.exec(color))) {
|
|
479
|
+
const L = parseModernComponent(match[1], 1);
|
|
480
|
+
const a = parseModernComponent(match[2], 0.4);
|
|
481
|
+
const b = parseModernComponent(match[3], 0.4);
|
|
482
|
+
const alpha = parseModernAlpha(match[4]);
|
|
483
|
+
const [r, g, bl] = oklabToSrgb(L, a, b);
|
|
484
|
+
return rgbFloatToInt(r, g, bl, alpha);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
if (matchers.lab) {
|
|
488
|
+
if ((match = matchers.lab.exec(color))) {
|
|
489
|
+
const L = parseModernComponent(match[1], 100); // 100% = 100
|
|
490
|
+
const a = parseModernComponent(match[2], 125); // 100% = 125
|
|
491
|
+
const b = parseModernComponent(match[3], 125);
|
|
492
|
+
const alpha = parseModernAlpha(match[4]);
|
|
493
|
+
const [r, g, bl] = labToSrgb(L, a, b);
|
|
494
|
+
return rgbFloatToInt(r, g, bl, alpha);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
if (matchers.lch) {
|
|
498
|
+
if ((match = matchers.lch.exec(color))) {
|
|
499
|
+
const L = parseModernComponent(match[1], 100);
|
|
500
|
+
const C = parseModernComponent(match[2], 150); // 100% = 150
|
|
501
|
+
const H = parseHueAngle(match[3]);
|
|
502
|
+
const alpha = parseModernAlpha(match[4]);
|
|
503
|
+
const hRad = (H * Math.PI) / 180;
|
|
504
|
+
const [r, g, bl] = labToSrgb(L, C * Math.cos(hRad), C * Math.sin(hRad));
|
|
505
|
+
return rgbFloatToInt(r, g, bl, alpha);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (matchers.hwb) {
|
|
509
|
+
if ((match = matchers.hwb.exec(color))) {
|
|
510
|
+
const H = parseHueAngle(match[1]);
|
|
511
|
+
const W = parseModernComponent(match[2], 1); // 100% = 1
|
|
512
|
+
const B = parseModernComponent(match[3], 1);
|
|
513
|
+
const alpha = parseModernAlpha(match[4]);
|
|
514
|
+
const [r, g, bl] = hwbToSrgb(H / 360, W, B);
|
|
515
|
+
return rgbFloatToInt(r, g, bl, alpha);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
342
518
|
throw new Error(`invalid color string ${color} provided`);
|
|
343
519
|
}
|
|
344
520
|
const opacity = (c) => {
|
|
@@ -3,7 +3,7 @@ import type { VolumeProp } from './volume-prop.js';
|
|
|
3
3
|
export declare const useBasicMediaInTimeline: ({ volume, mediaVolume, mediaType, src, displayName, trimBefore, trimAfter, playbackRate, }: {
|
|
4
4
|
volume: VolumeProp | undefined;
|
|
5
5
|
mediaVolume: number;
|
|
6
|
-
mediaType: "audio" | "video";
|
|
6
|
+
mediaType: "audio" | "video" | "image";
|
|
7
7
|
src: string | undefined;
|
|
8
8
|
displayName: string | null;
|
|
9
9
|
trimBefore: number | undefined;
|
|
@@ -18,6 +18,16 @@ export declare const useBasicMediaInTimeline: ({ volume, mediaVolume, mediaType,
|
|
|
18
18
|
isStudio: boolean;
|
|
19
19
|
finalDisplayName: string;
|
|
20
20
|
};
|
|
21
|
+
export declare const useImageInTimeline: ({ src, displayName, id, stack, showInTimeline, premountDisplay, postmountDisplay, loopDisplay, }: {
|
|
22
|
+
src: string | undefined;
|
|
23
|
+
displayName: string | null;
|
|
24
|
+
id: string;
|
|
25
|
+
stack: string | null;
|
|
26
|
+
showInTimeline: boolean;
|
|
27
|
+
premountDisplay: number | null;
|
|
28
|
+
postmountDisplay: number | null;
|
|
29
|
+
loopDisplay: LoopDisplay | undefined;
|
|
30
|
+
}) => void;
|
|
21
31
|
export declare const useMediaInTimeline: ({ volume, mediaVolume, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, postmountDisplay, loopDisplay, }: {
|
|
22
32
|
volume: VolumeProp | undefined;
|
|
23
33
|
mediaVolume: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useMediaInTimeline = exports.useBasicMediaInTimeline = void 0;
|
|
3
|
+
exports.useMediaInTimeline = exports.useImageInTimeline = exports.useBasicMediaInTimeline = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const use_audio_frame_js_1 = require("./audio/use-audio-frame.js");
|
|
6
6
|
const calculate_media_duration_js_1 = require("./calculate-media-duration.js");
|
|
@@ -73,6 +73,69 @@ const useBasicMediaInTimeline = ({ volume, mediaVolume, mediaType, src, displayN
|
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
75
|
exports.useBasicMediaInTimeline = useBasicMediaInTimeline;
|
|
76
|
+
const useImageInTimeline = ({ src, displayName, id, stack, showInTimeline, premountDisplay, postmountDisplay, loopDisplay, }) => {
|
|
77
|
+
const parentSequence = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
|
|
78
|
+
const { registerSequence, unregisterSequence } = (0, react_1.useContext)(SequenceManager_js_1.SequenceManager);
|
|
79
|
+
const { duration, nonce, rootId, isStudio, finalDisplayName } = (0, exports.useBasicMediaInTimeline)({
|
|
80
|
+
volume: undefined,
|
|
81
|
+
mediaVolume: 0,
|
|
82
|
+
mediaType: 'image',
|
|
83
|
+
src,
|
|
84
|
+
displayName,
|
|
85
|
+
trimAfter: undefined,
|
|
86
|
+
trimBefore: undefined,
|
|
87
|
+
playbackRate: 1,
|
|
88
|
+
});
|
|
89
|
+
(0, react_1.useEffect)(() => {
|
|
90
|
+
var _a, _b, _c;
|
|
91
|
+
if (!src) {
|
|
92
|
+
throw new Error('No src passed');
|
|
93
|
+
}
|
|
94
|
+
if (!isStudio && ((_b = (_a = window.process) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.NODE_ENV) !== 'test') {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!showInTimeline) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
registerSequence({
|
|
101
|
+
type: 'image',
|
|
102
|
+
src,
|
|
103
|
+
id,
|
|
104
|
+
duration,
|
|
105
|
+
from: 0,
|
|
106
|
+
parent: (_c = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _c !== void 0 ? _c : null,
|
|
107
|
+
displayName: finalDisplayName,
|
|
108
|
+
rootId,
|
|
109
|
+
showInTimeline: true,
|
|
110
|
+
nonce: nonce.get(),
|
|
111
|
+
loopDisplay,
|
|
112
|
+
stack,
|
|
113
|
+
premountDisplay,
|
|
114
|
+
postmountDisplay,
|
|
115
|
+
controls: null,
|
|
116
|
+
});
|
|
117
|
+
return () => {
|
|
118
|
+
unregisterSequence(id);
|
|
119
|
+
};
|
|
120
|
+
}, [
|
|
121
|
+
duration,
|
|
122
|
+
id,
|
|
123
|
+
parentSequence,
|
|
124
|
+
src,
|
|
125
|
+
registerSequence,
|
|
126
|
+
unregisterSequence,
|
|
127
|
+
nonce,
|
|
128
|
+
stack,
|
|
129
|
+
showInTimeline,
|
|
130
|
+
premountDisplay,
|
|
131
|
+
postmountDisplay,
|
|
132
|
+
isStudio,
|
|
133
|
+
loopDisplay,
|
|
134
|
+
rootId,
|
|
135
|
+
finalDisplayName,
|
|
136
|
+
]);
|
|
137
|
+
};
|
|
138
|
+
exports.useImageInTimeline = useImageInTimeline;
|
|
76
139
|
const useMediaInTimeline = ({ volume, mediaVolume, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, postmountDisplay, loopDisplay, }) => {
|
|
77
140
|
const parentSequence = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
|
|
78
141
|
const startsAt = (0, use_audio_frame_js_1.useMediaStartsAt)();
|
package/dist/cjs/use-schema.js
CHANGED
|
@@ -50,7 +50,7 @@ const useSchema = (schema, currentValue) => {
|
|
|
50
50
|
const overrideValues = (_a = overrides[overrideId]) !== null && _a !== void 0 ? _a : {};
|
|
51
51
|
const propStatus = codeValues[overrideId];
|
|
52
52
|
const currentValueKeys = Object.keys(currentValue);
|
|
53
|
-
const keysToUpdate = new Set(currentValueKeys)
|
|
53
|
+
const keysToUpdate = [...new Set(currentValueKeys)];
|
|
54
54
|
const merged = {};
|
|
55
55
|
// Apply code values over runtime values, falling back to schema default
|
|
56
56
|
for (const key of keysToUpdate) {
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED