remotion 4.0.71 → 4.0.72

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.
@@ -59,7 +59,7 @@ function truthy(value) {
59
59
  }
60
60
 
61
61
  // Automatically generated on publish
62
- const VERSION = '4.0.71';
62
+ const VERSION = '4.0.72';
63
63
 
64
64
  const checkMultipleRemotionVersions = () => {
65
65
  if (typeof globalThis === 'undefined') {
@@ -426,35 +426,6 @@ const staticFile = (path) => {
426
426
  // Must keep this file in sync with the one in packages/lambda/src/shared/serialize-props.ts!
427
427
  const DATE_TOKEN = 'remotion-date:';
428
428
  const FILE_TOKEN = 'remotion-file:';
429
- const serializeJSONWithDate = ({ data, indent, staticBase, }) => {
430
- let customDateUsed = false;
431
- let customFileUsed = false;
432
- let mapUsed = false;
433
- let setUsed = false;
434
- const serializedString = JSON.stringify(data, function (key, value) {
435
- const item = this[key];
436
- if (item instanceof Date) {
437
- customDateUsed = true;
438
- return `${DATE_TOKEN}${item.toISOString()}`;
439
- }
440
- if (item instanceof Map) {
441
- mapUsed = true;
442
- return value;
443
- }
444
- if (item instanceof Set) {
445
- setUsed = true;
446
- return value;
447
- }
448
- if (typeof item === 'string' &&
449
- staticBase !== null &&
450
- item.startsWith(staticBase)) {
451
- customFileUsed = true;
452
- return `${FILE_TOKEN}${item.replace(staticBase + '/', '')}`;
453
- }
454
- return value;
455
- }, indent);
456
- return { serializedString, customDateUsed, customFileUsed, mapUsed, setUsed };
457
- };
458
429
  const deserializeJSONWithCustomFields = (data) => {
459
430
  return JSON.parse(data, (_, value) => {
460
431
  if (typeof value === 'string' && value.startsWith(DATE_TOKEN)) {
@@ -3387,141 +3358,403 @@ const getPreviewDomElement = () => {
3387
3358
  return document.getElementById(REMOTION_STUDIO_CONTAINER_ELEMENT);
3388
3359
  };
3389
3360
 
3361
+ let Root = null;
3362
+ let listeners = [];
3390
3363
  /**
3391
- * Copied from:
3392
- * https://github.com/software-mansion/react-native-reanimated/blob/master/src/reanimated2/Colors.ts
3364
+ * @description This function registers the root component of the Remotion project
3365
+ * @see [Documentation](https://www.remotion.dev/docs/register-root)
3393
3366
  */
3394
- // var INTEGER = '[-+]?\\d+';
3395
- const NUMBER = '[-+]?\\d*\\.?\\d+';
3396
- const PERCENTAGE = NUMBER + '%';
3397
- function call(...args) {
3398
- return '\\(\\s*(' + args.join(')\\s*,\\s*(') + ')\\s*\\)';
3399
- }
3400
- function getMatchers() {
3401
- const cachedMatchers = {
3402
- rgb: undefined,
3403
- rgba: undefined,
3404
- hsl: undefined,
3405
- hsla: undefined,
3406
- hex3: undefined,
3407
- hex4: undefined,
3408
- hex5: undefined,
3409
- hex6: undefined,
3410
- hex8: undefined,
3411
- };
3412
- if (cachedMatchers.rgb === undefined) {
3413
- cachedMatchers.rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER));
3414
- cachedMatchers.rgba = new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER));
3415
- cachedMatchers.hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
3416
- cachedMatchers.hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
3417
- cachedMatchers.hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
3418
- cachedMatchers.hex4 =
3419
- /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
3420
- cachedMatchers.hex6 = /^#([0-9a-fA-F]{6})$/;
3421
- cachedMatchers.hex8 = /^#([0-9a-fA-F]{8})$/;
3422
- }
3423
- return cachedMatchers;
3424
- }
3425
- function hue2rgb(p, q, t) {
3426
- if (t < 0) {
3427
- t += 1;
3428
- }
3429
- if (t > 1) {
3430
- t -= 1;
3431
- }
3432
- if (t < 1 / 6) {
3433
- return p + (q - p) * 6 * t;
3367
+ const registerRoot = (comp) => {
3368
+ if (!comp) {
3369
+ throw new Error(`You must pass a React component to registerRoot(), but ${JSON.stringify(comp)} was passed.`);
3434
3370
  }
3435
- if (t < 1 / 2) {
3436
- return q;
3371
+ if (Root) {
3372
+ throw new Error('registerRoot() was called more than once.');
3437
3373
  }
3438
- if (t < 2 / 3) {
3439
- return p + (q - p) * (2 / 3 - t) * 6;
3374
+ Root = comp;
3375
+ listeners.forEach((l) => {
3376
+ l(comp);
3377
+ });
3378
+ };
3379
+ const getRoot = () => {
3380
+ return Root;
3381
+ };
3382
+ const waitForRoot = (fn) => {
3383
+ if (Root) {
3384
+ fn(Root);
3385
+ return () => undefined;
3440
3386
  }
3441
- return p;
3442
- }
3443
- function hslToRgb(h, s, l) {
3444
- const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
3445
- const p = 2 * l - q;
3446
- const r = hue2rgb(p, q, h + 1 / 3);
3447
- const g = hue2rgb(p, q, h);
3448
- const b = hue2rgb(p, q, h - 1 / 3);
3449
- return ((Math.round(r * 255) << 24) |
3450
- (Math.round(g * 255) << 16) |
3451
- (Math.round(b * 255) << 8));
3452
- }
3453
- function parse255(str) {
3454
- const int = Number.parseInt(str, 10);
3455
- if (int < 0) {
3456
- return 0;
3387
+ listeners.push(fn);
3388
+ return () => {
3389
+ listeners = listeners.filter((l) => l !== fn);
3390
+ };
3391
+ };
3392
+
3393
+ const RemotionRoot = ({ children, numberOfAudioTags }) => {
3394
+ const [remotionRootId] = useState(() => String(random(null)));
3395
+ const [frame, setFrame] = useState({});
3396
+ const [playing, setPlaying] = useState(false);
3397
+ const imperativePlaying = useRef(false);
3398
+ const [fastRefreshes, setFastRefreshes] = useState(0);
3399
+ const [playbackRate, setPlaybackRate] = useState(1);
3400
+ const audioAndVideoTags = useRef([]);
3401
+ if (typeof window !== 'undefined') {
3402
+ // eslint-disable-next-line react-hooks/rules-of-hooks
3403
+ useLayoutEffect(() => {
3404
+ window.remotion_setFrame = (f, composition) => {
3405
+ const id = delayRender(`Setting the current frame to ${f}`);
3406
+ setFrame((s) => ({
3407
+ ...s,
3408
+ [composition]: f,
3409
+ }));
3410
+ requestAnimationFrame(() => continueRender(id));
3411
+ };
3412
+ window.remotion_isPlayer = false;
3413
+ }, []);
3457
3414
  }
3458
- if (int > 255) {
3459
- return 255;
3415
+ const timelineContextValue = useMemo(() => {
3416
+ return {
3417
+ frame,
3418
+ playing,
3419
+ imperativePlaying,
3420
+ rootId: remotionRootId,
3421
+ playbackRate,
3422
+ setPlaybackRate,
3423
+ audioAndVideoTags,
3424
+ };
3425
+ }, [frame, playbackRate, playing, remotionRootId]);
3426
+ const setTimelineContextValue = useMemo(() => {
3427
+ return {
3428
+ setFrame,
3429
+ setPlaying,
3430
+ };
3431
+ }, []);
3432
+ const nonceContext = useMemo(() => {
3433
+ let counter = 0;
3434
+ return {
3435
+ getNonce: () => counter++,
3436
+ fastRefreshes,
3437
+ };
3438
+ }, [fastRefreshes]);
3439
+ useEffect(() => {
3440
+ if (typeof __webpack_module__ !== 'undefined') {
3441
+ if (__webpack_module__.hot) {
3442
+ __webpack_module__.hot.addStatusHandler((status) => {
3443
+ if (status === 'idle') {
3444
+ setFastRefreshes((i) => i + 1);
3445
+ }
3446
+ });
3447
+ }
3448
+ }
3449
+ }, []);
3450
+ return (jsx(NonceContext.Provider, { value: nonceContext, children: jsx(TimelineContext.Provider, { value: timelineContextValue, children: jsx(SetTimelineContext.Provider, { value: setTimelineContextValue, children: jsx(EditorPropsProvider, { children: jsx(PrefetchProvider, { children: jsx(NativeLayersProvider, { children: jsx(CompositionManagerProvider, { numberOfAudioTags: numberOfAudioTags, children: jsx(DurationsContextProvider, { children: children }) }) }) }) }) }) }) }));
3451
+ };
3452
+
3453
+ const getEnvVariables = () => {
3454
+ if (getRemotionEnvironment().isRendering) {
3455
+ const param = window.remotion_envVariables;
3456
+ if (!param) {
3457
+ return {};
3458
+ }
3459
+ return { ...JSON.parse(param), NODE_ENV: process.env.NODE_ENV };
3460
3460
  }
3461
- return int;
3462
- }
3463
- function parse360(str) {
3464
- const int = Number.parseFloat(str);
3465
- return (((int % 360) + 360) % 360) / 360;
3466
- }
3467
- function parse1(str) {
3468
- const num = Number.parseFloat(str);
3469
- if (num < 0) {
3470
- return 0;
3461
+ if (getRemotionEnvironment().isStudio) {
3462
+ // For the Studio, we already set the environment variables in index-html.ts.
3463
+ // We just add NODE_ENV here.
3464
+ return {
3465
+ NODE_ENV: 'development',
3466
+ };
3471
3467
  }
3472
- if (num > 1) {
3473
- return 255;
3468
+ throw new Error('Can only call getEnvVariables() if environment is `rendering` or `preview`');
3469
+ };
3470
+ const setupEnvVariables = () => {
3471
+ const env = getEnvVariables();
3472
+ if (!window.process) {
3473
+ window.process = {};
3474
3474
  }
3475
- return Math.round(num * 255);
3476
- }
3477
- function parsePercentage(str) {
3478
- // parseFloat conveniently ignores the final %
3479
- const int = Number.parseFloat(str);
3480
- if (int < 0) {
3481
- return 0;
3475
+ if (!window.process.env) {
3476
+ window.process.env = {};
3482
3477
  }
3483
- if (int > 100) {
3484
- return 1;
3478
+ Object.keys(env).forEach((key) => {
3479
+ window.process.env[key] = env[key];
3480
+ });
3481
+ };
3482
+
3483
+ const WATCH_REMOTION_STATIC_FILES = 'remotion_staticFilesChanged';
3484
+ /**
3485
+ * @description Watch for changes in a specific static file.
3486
+ * @param {string} fileName - The name of the static file to watch for changes.
3487
+ * @param {WatcherCallback} callback - A callback function to be called when the file changes.
3488
+ * @returns {{cancel: () => void}} A function that can be used to cancel the event listener.
3489
+ * @see [Documentation](https://www.remotion.dev/docs/watchstaticfile)
3490
+ */
3491
+ const watchStaticFile = (fileName, callback) => {
3492
+ // Check if function is called in Remotion Studio
3493
+ if (!getRemotionEnvironment().isStudio) {
3494
+ console.warn('The API is only available while using the Remotion Studio.');
3495
+ return { cancel: () => undefined };
3485
3496
  }
3486
- return int / 100;
3487
- }
3488
- const names = {
3489
- transparent: 0x00000000,
3490
- // http://www.w3.org/TR/css3-color/#svg-color
3491
- aliceblue: 0xf0f8ffff,
3492
- antiquewhite: 0xfaebd7ff,
3493
- aqua: 0x00ffffff,
3494
- aquamarine: 0x7fffd4ff,
3495
- azure: 0xf0ffffff,
3496
- beige: 0xf5f5dcff,
3497
- bisque: 0xffe4c4ff,
3498
- black: 0x000000ff,
3499
- blanchedalmond: 0xffebcdff,
3500
- blue: 0x0000ffff,
3501
- blueviolet: 0x8a2be2ff,
3502
- brown: 0xa52a2aff,
3503
- burlywood: 0xdeb887ff,
3504
- burntsienna: 0xea7e5dff,
3505
- cadetblue: 0x5f9ea0ff,
3506
- chartreuse: 0x7fff00ff,
3507
- chocolate: 0xd2691eff,
3508
- coral: 0xff7f50ff,
3509
- cornflowerblue: 0x6495edff,
3510
- cornsilk: 0xfff8dcff,
3511
- crimson: 0xdc143cff,
3512
- cyan: 0x00ffffff,
3513
- darkblue: 0x00008bff,
3514
- darkcyan: 0x008b8bff,
3515
- darkgoldenrod: 0xb8860bff,
3516
- darkgray: 0xa9a9a9ff,
3517
- darkgreen: 0x006400ff,
3518
- darkgrey: 0xa9a9a9ff,
3519
- darkkhaki: 0xbdb76bff,
3520
- darkmagenta: 0x8b008bff,
3521
- darkolivegreen: 0x556b2fff,
3522
- darkorange: 0xff8c00ff,
3523
- darkorchid: 0x9932ccff,
3524
- darkred: 0x8b0000ff,
3497
+ let prevFileData = window.remotion_staticFiles.find((file) => file.name === fileName);
3498
+ // Check if the specified static file has updated or deleted
3499
+ const checkFile = (event) => {
3500
+ const staticFiles = event.detail.files;
3501
+ // Check for user specified file
3502
+ const newFileData = staticFiles.find((file) => file.name === fileName);
3503
+ if (!newFileData) {
3504
+ // File is deleted
3505
+ if (prevFileData !== undefined) {
3506
+ callback(null);
3507
+ }
3508
+ prevFileData = undefined;
3509
+ return;
3510
+ }
3511
+ if (prevFileData === undefined ||
3512
+ prevFileData.lastModified !== newFileData.lastModified) {
3513
+ callback(newFileData); // File is added or modified
3514
+ prevFileData = newFileData;
3515
+ }
3516
+ };
3517
+ window.addEventListener(WATCH_REMOTION_STATIC_FILES, checkFile);
3518
+ const cancel = () => {
3519
+ return window.removeEventListener(WATCH_REMOTION_STATIC_FILES, checkFile);
3520
+ };
3521
+ return { cancel };
3522
+ };
3523
+
3524
+ function useRemotionContexts() {
3525
+ const compositionManagerCtx = React.useContext(CompositionManager);
3526
+ const timelineContext = React.useContext(TimelineContext);
3527
+ const setTimelineContext = React.useContext(SetTimelineContext);
3528
+ const sequenceContext = React.useContext(SequenceContext);
3529
+ const nonceContext = React.useContext(NonceContext);
3530
+ const canUseRemotionHooksContext = React.useContext(CanUseRemotionHooks);
3531
+ const nativeLayersContext = React.useContext(NativeLayersContext);
3532
+ const preloadContext = React.useContext(PreloadContext);
3533
+ const resolveCompositionContext = React.useContext(ResolveCompositionContext);
3534
+ const renderAssetManagerContext = React.useContext(RenderAssetManager);
3535
+ const sequenceManagerContext = React.useContext(SequenceManager);
3536
+ return useMemo(() => ({
3537
+ compositionManagerCtx,
3538
+ timelineContext,
3539
+ setTimelineContext,
3540
+ sequenceContext,
3541
+ nonceContext,
3542
+ canUseRemotionHooksContext,
3543
+ nativeLayersContext,
3544
+ preloadContext,
3545
+ resolveCompositionContext,
3546
+ renderAssetManagerContext,
3547
+ sequenceManagerContext,
3548
+ }), [
3549
+ compositionManagerCtx,
3550
+ nonceContext,
3551
+ sequenceContext,
3552
+ setTimelineContext,
3553
+ timelineContext,
3554
+ canUseRemotionHooksContext,
3555
+ nativeLayersContext,
3556
+ preloadContext,
3557
+ resolveCompositionContext,
3558
+ renderAssetManagerContext,
3559
+ sequenceManagerContext,
3560
+ ]);
3561
+ }
3562
+ const RemotionContextProvider = (props) => {
3563
+ const { children, contexts } = props;
3564
+ return (jsx(CanUseRemotionHooks.Provider, { value: contexts.canUseRemotionHooksContext, children: jsx(NonceContext.Provider, { value: contexts.nonceContext, children: jsx(NativeLayersContext.Provider, { value: contexts.nativeLayersContext, children: jsx(PreloadContext.Provider, { value: contexts.preloadContext, children: jsx(CompositionManager.Provider, { value: contexts.compositionManagerCtx, children: jsx(SequenceManager.Provider, { value: contexts.sequenceManagerContext, children: jsx(RenderAssetManager.Provider, { value: contexts.renderAssetManagerContext, children: jsx(ResolveCompositionContext.Provider, { value: contexts.resolveCompositionContext, children: jsx(TimelineContext.Provider, { value: contexts.timelineContext, children: jsx(SetTimelineContext.Provider, { value: contexts.setTimelineContext, children: jsx(SequenceContext.Provider, { value: contexts.sequenceContext, children: children }) }) }) }) }) }) }) }) }) }) }));
3565
+ };
3566
+
3567
+ // Mark them as Internals so use don't assume this is public
3568
+ // API and are less likely to use it
3569
+ const Internals = {
3570
+ useUnsafeVideoConfig,
3571
+ Timeline: TimelinePosition,
3572
+ CompositionManager,
3573
+ SequenceManager,
3574
+ RemotionRoot,
3575
+ useVideo,
3576
+ getRoot,
3577
+ useMediaVolumeState,
3578
+ useMediaMutedState,
3579
+ useLazyComponent,
3580
+ truthy,
3581
+ SequenceContext,
3582
+ useRemotionContexts,
3583
+ RemotionContextProvider,
3584
+ CSSUtils,
3585
+ setupEnvVariables,
3586
+ MediaVolumeContext,
3587
+ SetMediaVolumeContext,
3588
+ getRemotionEnvironment,
3589
+ SharedAudioContext,
3590
+ SharedAudioContextProvider,
3591
+ invalidCompositionErrorMessage,
3592
+ isCompositionIdValid,
3593
+ getPreviewDomElement,
3594
+ compositionsRef,
3595
+ portalNode,
3596
+ waitForRoot,
3597
+ CanUseRemotionHooksProvider,
3598
+ CanUseRemotionHooks,
3599
+ PrefetchProvider,
3600
+ DurationsContextProvider,
3601
+ IsPlayerContextProvider,
3602
+ useIsPlayer,
3603
+ EditorPropsProvider,
3604
+ EditorPropsContext,
3605
+ usePreload,
3606
+ NonceContext,
3607
+ resolveVideoConfig,
3608
+ useResolvedVideoConfig,
3609
+ resolveCompositionsRef,
3610
+ ResolveCompositionConfig,
3611
+ REMOTION_STUDIO_CONTAINER_ELEMENT,
3612
+ RenderAssetManager,
3613
+ persistCurrentFrame,
3614
+ useTimelineSetFrame,
3615
+ FILE_TOKEN,
3616
+ DATE_TOKEN,
3617
+ NativeLayersProvider,
3618
+ ClipComposition,
3619
+ isIosSafari,
3620
+ WATCH_REMOTION_STATIC_FILES,
3621
+ };
3622
+
3623
+ /**
3624
+ * Copied from:
3625
+ * https://github.com/software-mansion/react-native-reanimated/blob/master/src/reanimated2/Colors.ts
3626
+ */
3627
+ // var INTEGER = '[-+]?\\d+';
3628
+ const NUMBER = '[-+]?\\d*\\.?\\d+';
3629
+ const PERCENTAGE = NUMBER + '%';
3630
+ function call(...args) {
3631
+ return '\\(\\s*(' + args.join(')\\s*,\\s*(') + ')\\s*\\)';
3632
+ }
3633
+ function getMatchers() {
3634
+ const cachedMatchers = {
3635
+ rgb: undefined,
3636
+ rgba: undefined,
3637
+ hsl: undefined,
3638
+ hsla: undefined,
3639
+ hex3: undefined,
3640
+ hex4: undefined,
3641
+ hex5: undefined,
3642
+ hex6: undefined,
3643
+ hex8: undefined,
3644
+ };
3645
+ if (cachedMatchers.rgb === undefined) {
3646
+ cachedMatchers.rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER));
3647
+ cachedMatchers.rgba = new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER));
3648
+ cachedMatchers.hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
3649
+ cachedMatchers.hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
3650
+ cachedMatchers.hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
3651
+ cachedMatchers.hex4 =
3652
+ /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
3653
+ cachedMatchers.hex6 = /^#([0-9a-fA-F]{6})$/;
3654
+ cachedMatchers.hex8 = /^#([0-9a-fA-F]{8})$/;
3655
+ }
3656
+ return cachedMatchers;
3657
+ }
3658
+ function hue2rgb(p, q, t) {
3659
+ if (t < 0) {
3660
+ t += 1;
3661
+ }
3662
+ if (t > 1) {
3663
+ t -= 1;
3664
+ }
3665
+ if (t < 1 / 6) {
3666
+ return p + (q - p) * 6 * t;
3667
+ }
3668
+ if (t < 1 / 2) {
3669
+ return q;
3670
+ }
3671
+ if (t < 2 / 3) {
3672
+ return p + (q - p) * (2 / 3 - t) * 6;
3673
+ }
3674
+ return p;
3675
+ }
3676
+ function hslToRgb(h, s, l) {
3677
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
3678
+ const p = 2 * l - q;
3679
+ const r = hue2rgb(p, q, h + 1 / 3);
3680
+ const g = hue2rgb(p, q, h);
3681
+ const b = hue2rgb(p, q, h - 1 / 3);
3682
+ return ((Math.round(r * 255) << 24) |
3683
+ (Math.round(g * 255) << 16) |
3684
+ (Math.round(b * 255) << 8));
3685
+ }
3686
+ function parse255(str) {
3687
+ const int = Number.parseInt(str, 10);
3688
+ if (int < 0) {
3689
+ return 0;
3690
+ }
3691
+ if (int > 255) {
3692
+ return 255;
3693
+ }
3694
+ return int;
3695
+ }
3696
+ function parse360(str) {
3697
+ const int = Number.parseFloat(str);
3698
+ return (((int % 360) + 360) % 360) / 360;
3699
+ }
3700
+ function parse1(str) {
3701
+ const num = Number.parseFloat(str);
3702
+ if (num < 0) {
3703
+ return 0;
3704
+ }
3705
+ if (num > 1) {
3706
+ return 255;
3707
+ }
3708
+ return Math.round(num * 255);
3709
+ }
3710
+ function parsePercentage(str) {
3711
+ // parseFloat conveniently ignores the final %
3712
+ const int = Number.parseFloat(str);
3713
+ if (int < 0) {
3714
+ return 0;
3715
+ }
3716
+ if (int > 100) {
3717
+ return 1;
3718
+ }
3719
+ return int / 100;
3720
+ }
3721
+ const names = {
3722
+ transparent: 0x00000000,
3723
+ // http://www.w3.org/TR/css3-color/#svg-color
3724
+ aliceblue: 0xf0f8ffff,
3725
+ antiquewhite: 0xfaebd7ff,
3726
+ aqua: 0x00ffffff,
3727
+ aquamarine: 0x7fffd4ff,
3728
+ azure: 0xf0ffffff,
3729
+ beige: 0xf5f5dcff,
3730
+ bisque: 0xffe4c4ff,
3731
+ black: 0x000000ff,
3732
+ blanchedalmond: 0xffebcdff,
3733
+ blue: 0x0000ffff,
3734
+ blueviolet: 0x8a2be2ff,
3735
+ brown: 0xa52a2aff,
3736
+ burlywood: 0xdeb887ff,
3737
+ burntsienna: 0xea7e5dff,
3738
+ cadetblue: 0x5f9ea0ff,
3739
+ chartreuse: 0x7fff00ff,
3740
+ chocolate: 0xd2691eff,
3741
+ coral: 0xff7f50ff,
3742
+ cornflowerblue: 0x6495edff,
3743
+ cornsilk: 0xfff8dcff,
3744
+ crimson: 0xdc143cff,
3745
+ cyan: 0x00ffffff,
3746
+ darkblue: 0x00008bff,
3747
+ darkcyan: 0x008b8bff,
3748
+ darkgoldenrod: 0xb8860bff,
3749
+ darkgray: 0xa9a9a9ff,
3750
+ darkgreen: 0x006400ff,
3751
+ darkgrey: 0xa9a9a9ff,
3752
+ darkkhaki: 0xbdb76bff,
3753
+ darkmagenta: 0x8b008bff,
3754
+ darkolivegreen: 0x556b2fff,
3755
+ darkorange: 0xff8c00ff,
3756
+ darkorchid: 0x9932ccff,
3757
+ darkred: 0x8b0000ff,
3525
3758
  darksalmon: 0xe9967aff,
3526
3759
  darkseagreen: 0x8fbc8fff,
3527
3760
  darkslateblue: 0x483d8bff,
@@ -3681,225 +3914,103 @@ function normalizeColor(color) {
3681
3914
  match[3] +
3682
3915
  match[3] + // b
3683
3916
  'ff', // a
3684
- 16) >>> 0);
3685
- }
3686
- }
3687
- // https://drafts.csswg.org/css-color-4/#hex-notation
3688
- if (matchers.hex8) {
3689
- if ((match = matchers.hex8.exec(color))) {
3690
- return Number.parseInt(match[1], 16) >>> 0;
3691
- }
3692
- }
3693
- if (matchers.hex4) {
3694
- if ((match = matchers.hex4.exec(color))) {
3695
- return (Number.parseInt(match[1] +
3696
- match[1] + // r
3697
- match[2] +
3698
- match[2] + // g
3699
- match[3] +
3700
- match[3] + // b
3701
- match[4] +
3702
- match[4], // a
3703
- 16) >>> 0);
3704
- }
3705
- }
3706
- if (matchers.hsl) {
3707
- if ((match = matchers.hsl.exec(color))) {
3708
- return ((hslToRgb(parse360(match[1]), // h
3709
- parsePercentage(match[2]), // s
3710
- parsePercentage(match[3])) |
3711
- 0x000000ff) >>> // a
3712
- 0);
3713
- }
3714
- }
3715
- if (matchers.hsla) {
3716
- if ((match = matchers.hsla.exec(color))) {
3717
- return ((hslToRgb(parse360(match[1]), // h
3718
- parsePercentage(match[2]), // s
3719
- parsePercentage(match[3])) |
3720
- parse1(match[4])) >>> // a
3721
- 0);
3722
- }
3723
- }
3724
- throw new Error(`invalid color string ${color} provided`);
3725
- }
3726
- const opacity = (c) => {
3727
- return ((c >> 24) & 255) / 255;
3728
- };
3729
- const red = (c) => {
3730
- return (c >> 16) & 255;
3731
- };
3732
- const green = (c) => {
3733
- return (c >> 8) & 255;
3734
- };
3735
- const blue = (c) => {
3736
- return c & 255;
3737
- };
3738
- const rgbaColor = (r, g, b, alpha) => {
3739
- return `rgba(${r}, ${g}, ${b}, ${alpha})`;
3740
- };
3741
- function processColor(color) {
3742
- const normalizedColor = normalizeColor(color);
3743
- return ((normalizedColor << 24) | (normalizedColor >>> 8)) >>> 0; // argb
3744
- }
3745
- const interpolateColorsRGB = (value, inputRange, colors) => {
3746
- const [r, g, b, a] = [red, green, blue, opacity].map((f) => {
3747
- const unrounded = interpolate(value, inputRange, colors.map((c) => f(c)), {
3748
- extrapolateLeft: 'clamp',
3749
- extrapolateRight: 'clamp',
3750
- });
3751
- if (f === opacity) {
3752
- return Number(unrounded.toFixed(3));
3753
- }
3754
- return Math.round(unrounded);
3755
- });
3756
- return rgbaColor(r, g, b, a);
3757
- };
3758
- /**
3759
- * @description This function allows you to map a range of values to colors using a concise syntax.
3760
- * @see [Documentation](https://www.remotion.dev/docs/interpolate-colors)
3761
- */
3762
- const interpolateColors = (input, inputRange, outputRange) => {
3763
- if (typeof input === 'undefined') {
3764
- throw new TypeError('input can not be undefined');
3765
- }
3766
- if (typeof inputRange === 'undefined') {
3767
- throw new TypeError('inputRange can not be undefined');
3768
- }
3769
- if (typeof outputRange === 'undefined') {
3770
- throw new TypeError('outputRange can not be undefined');
3771
- }
3772
- if (inputRange.length !== outputRange.length) {
3773
- throw new TypeError('inputRange (' +
3774
- inputRange.length +
3775
- ' values provided) and outputRange (' +
3776
- outputRange.length +
3777
- ' values provided) must have the same length');
3778
- }
3779
- const processedOutputRange = outputRange.map((c) => processColor(c));
3780
- return interpolateColorsRGB(input, inputRange, processedOutputRange);
3781
- };
3782
-
3783
- let Root = null;
3784
- let listeners = [];
3785
- /**
3786
- * @description This function registers the root component of the Remotion project
3787
- * @see [Documentation](https://www.remotion.dev/docs/register-root)
3788
- */
3789
- const registerRoot = (comp) => {
3790
- if (!comp) {
3791
- throw new Error(`You must pass a React component to registerRoot(), but ${JSON.stringify(comp)} was passed.`);
3792
- }
3793
- if (Root) {
3794
- throw new Error('registerRoot() was called more than once.');
3795
- }
3796
- Root = comp;
3797
- listeners.forEach((l) => {
3798
- l(comp);
3799
- });
3800
- };
3801
- const getRoot = () => {
3802
- return Root;
3803
- };
3804
- const waitForRoot = (fn) => {
3805
- if (Root) {
3806
- fn(Root);
3807
- return () => undefined;
3808
- }
3809
- listeners.push(fn);
3810
- return () => {
3811
- listeners = listeners.filter((l) => l !== fn);
3812
- };
3813
- };
3814
-
3815
- const RemotionRoot = ({ children, numberOfAudioTags }) => {
3816
- const [remotionRootId] = useState(() => String(random(null)));
3817
- const [frame, setFrame] = useState({});
3818
- const [playing, setPlaying] = useState(false);
3819
- const imperativePlaying = useRef(false);
3820
- const [fastRefreshes, setFastRefreshes] = useState(0);
3821
- const [playbackRate, setPlaybackRate] = useState(1);
3822
- const audioAndVideoTags = useRef([]);
3823
- if (typeof window !== 'undefined') {
3824
- // eslint-disable-next-line react-hooks/rules-of-hooks
3825
- useLayoutEffect(() => {
3826
- window.remotion_setFrame = (f, composition) => {
3827
- const id = delayRender(`Setting the current frame to ${f}`);
3828
- setFrame((s) => ({
3829
- ...s,
3830
- [composition]: f,
3831
- }));
3832
- requestAnimationFrame(() => continueRender(id));
3833
- };
3834
- window.remotion_isPlayer = false;
3835
- }, []);
3836
- }
3837
- const timelineContextValue = useMemo(() => {
3838
- return {
3839
- frame,
3840
- playing,
3841
- imperativePlaying,
3842
- rootId: remotionRootId,
3843
- playbackRate,
3844
- setPlaybackRate,
3845
- audioAndVideoTags,
3846
- };
3847
- }, [frame, playbackRate, playing, remotionRootId]);
3848
- const setTimelineContextValue = useMemo(() => {
3849
- return {
3850
- setFrame,
3851
- setPlaying,
3852
- };
3853
- }, []);
3854
- const nonceContext = useMemo(() => {
3855
- let counter = 0;
3856
- return {
3857
- getNonce: () => counter++,
3858
- fastRefreshes,
3859
- };
3860
- }, [fastRefreshes]);
3861
- useEffect(() => {
3862
- if (typeof __webpack_module__ !== 'undefined') {
3863
- if (__webpack_module__.hot) {
3864
- __webpack_module__.hot.addStatusHandler((status) => {
3865
- if (status === 'idle') {
3866
- setFastRefreshes((i) => i + 1);
3867
- }
3868
- });
3869
- }
3917
+ 16) >>> 0);
3870
3918
  }
3871
- }, []);
3872
- return (jsx(NonceContext.Provider, { value: nonceContext, children: jsx(TimelineContext.Provider, { value: timelineContextValue, children: jsx(SetTimelineContext.Provider, { value: setTimelineContextValue, children: jsx(EditorPropsProvider, { children: jsx(PrefetchProvider, { children: jsx(NativeLayersProvider, { children: jsx(CompositionManagerProvider, { numberOfAudioTags: numberOfAudioTags, children: jsx(DurationsContextProvider, { children: children }) }) }) }) }) }) }) }));
3873
- };
3874
-
3875
- const getEnvVariables = () => {
3876
- if (getRemotionEnvironment().isRendering) {
3877
- const param = window.remotion_envVariables;
3878
- if (!param) {
3879
- return {};
3919
+ }
3920
+ // https://drafts.csswg.org/css-color-4/#hex-notation
3921
+ if (matchers.hex8) {
3922
+ if ((match = matchers.hex8.exec(color))) {
3923
+ return Number.parseInt(match[1], 16) >>> 0;
3880
3924
  }
3881
- return { ...JSON.parse(param), NODE_ENV: process.env.NODE_ENV };
3882
3925
  }
3883
- if (getRemotionEnvironment().isStudio) {
3884
- // For the Studio, we already set the environment variables in index-html.ts.
3885
- // We just add NODE_ENV here.
3886
- return {
3887
- NODE_ENV: 'development',
3888
- };
3926
+ if (matchers.hex4) {
3927
+ if ((match = matchers.hex4.exec(color))) {
3928
+ return (Number.parseInt(match[1] +
3929
+ match[1] + // r
3930
+ match[2] +
3931
+ match[2] + // g
3932
+ match[3] +
3933
+ match[3] + // b
3934
+ match[4] +
3935
+ match[4], // a
3936
+ 16) >>> 0);
3937
+ }
3889
3938
  }
3890
- throw new Error('Can only call getEnvVariables() if environment is `rendering` or `preview`');
3891
- };
3892
- const setupEnvVariables = () => {
3893
- const env = getEnvVariables();
3894
- if (!window.process) {
3895
- window.process = {};
3939
+ if (matchers.hsl) {
3940
+ if ((match = matchers.hsl.exec(color))) {
3941
+ return ((hslToRgb(parse360(match[1]), // h
3942
+ parsePercentage(match[2]), // s
3943
+ parsePercentage(match[3])) |
3944
+ 0x000000ff) >>> // a
3945
+ 0);
3946
+ }
3896
3947
  }
3897
- if (!window.process.env) {
3898
- window.process.env = {};
3948
+ if (matchers.hsla) {
3949
+ if ((match = matchers.hsla.exec(color))) {
3950
+ return ((hslToRgb(parse360(match[1]), // h
3951
+ parsePercentage(match[2]), // s
3952
+ parsePercentage(match[3])) |
3953
+ parse1(match[4])) >>> // a
3954
+ 0);
3955
+ }
3899
3956
  }
3900
- Object.keys(env).forEach((key) => {
3901
- window.process.env[key] = env[key];
3957
+ throw new Error(`invalid color string ${color} provided`);
3958
+ }
3959
+ const opacity = (c) => {
3960
+ return ((c >> 24) & 255) / 255;
3961
+ };
3962
+ const red = (c) => {
3963
+ return (c >> 16) & 255;
3964
+ };
3965
+ const green = (c) => {
3966
+ return (c >> 8) & 255;
3967
+ };
3968
+ const blue = (c) => {
3969
+ return c & 255;
3970
+ };
3971
+ const rgbaColor = (r, g, b, alpha) => {
3972
+ return `rgba(${r}, ${g}, ${b}, ${alpha})`;
3973
+ };
3974
+ function processColor(color) {
3975
+ const normalizedColor = normalizeColor(color);
3976
+ return ((normalizedColor << 24) | (normalizedColor >>> 8)) >>> 0; // argb
3977
+ }
3978
+ const interpolateColorsRGB = (value, inputRange, colors) => {
3979
+ const [r, g, b, a] = [red, green, blue, opacity].map((f) => {
3980
+ const unrounded = interpolate(value, inputRange, colors.map((c) => f(c)), {
3981
+ extrapolateLeft: 'clamp',
3982
+ extrapolateRight: 'clamp',
3983
+ });
3984
+ if (f === opacity) {
3985
+ return Number(unrounded.toFixed(3));
3986
+ }
3987
+ return Math.round(unrounded);
3902
3988
  });
3989
+ return rgbaColor(r, g, b, a);
3990
+ };
3991
+ /**
3992
+ * @description This function allows you to map a range of values to colors using a concise syntax.
3993
+ * @see [Documentation](https://www.remotion.dev/docs/interpolate-colors)
3994
+ */
3995
+ const interpolateColors = (input, inputRange, outputRange) => {
3996
+ if (typeof input === 'undefined') {
3997
+ throw new TypeError('input can not be undefined');
3998
+ }
3999
+ if (typeof inputRange === 'undefined') {
4000
+ throw new TypeError('inputRange can not be undefined');
4001
+ }
4002
+ if (typeof outputRange === 'undefined') {
4003
+ throw new TypeError('outputRange can not be undefined');
4004
+ }
4005
+ if (inputRange.length !== outputRange.length) {
4006
+ throw new TypeError('inputRange (' +
4007
+ inputRange.length +
4008
+ ' values provided) and outputRange (' +
4009
+ outputRange.length +
4010
+ ' values provided) must have the same length');
4011
+ }
4012
+ const processedOutputRange = outputRange.map((c) => processColor(c));
4013
+ return interpolateColorsRGB(input, inputRange, processedOutputRange);
3903
4014
  };
3904
4015
 
3905
4016
  const validateFrame = ({ allowFloats, durationInFrames, frame, }) => {
@@ -3923,157 +4034,6 @@ const validateFrame = ({ allowFloats, durationInFrames, frame, }) => {
3923
4034
  }
3924
4035
  };
3925
4036
 
3926
- const WATCH_REMOTION_STATIC_FILES = 'remotion_staticFilesChanged';
3927
- /**
3928
- * @description Watch for changes in a specific static file.
3929
- * @param {string} fileName - The name of the static file to watch for changes.
3930
- * @param {WatcherCallback} callback - A callback function to be called when the file changes.
3931
- * @returns {{cancel: () => void}} A function that can be used to cancel the event listener.
3932
- * @see [Documentation](https://www.remotion.dev/docs/watchstaticfile)
3933
- */
3934
- const watchStaticFile = (fileName, callback) => {
3935
- // Check if function is called in Remotion Studio
3936
- if (!getRemotionEnvironment().isStudio) {
3937
- console.warn('The API is only available while using the Remotion Studio.');
3938
- return { cancel: () => undefined };
3939
- }
3940
- let prevFileData = window.remotion_staticFiles.find((file) => file.name === fileName);
3941
- // Check if the specified static file has updated or deleted
3942
- const checkFile = (event) => {
3943
- const staticFiles = event.detail.files;
3944
- // Check for user specified file
3945
- const newFileData = staticFiles.find((file) => file.name === fileName);
3946
- if (!newFileData) {
3947
- // File is deleted
3948
- if (prevFileData !== undefined) {
3949
- callback(null);
3950
- }
3951
- prevFileData = undefined;
3952
- return;
3953
- }
3954
- if (prevFileData === undefined ||
3955
- prevFileData.lastModified !== newFileData.lastModified) {
3956
- callback(newFileData); // File is added or modified
3957
- prevFileData = newFileData;
3958
- }
3959
- };
3960
- window.addEventListener(WATCH_REMOTION_STATIC_FILES, checkFile);
3961
- const cancel = () => {
3962
- return window.removeEventListener(WATCH_REMOTION_STATIC_FILES, checkFile);
3963
- };
3964
- return { cancel };
3965
- };
3966
-
3967
- function useRemotionContexts() {
3968
- const compositionManagerCtx = React.useContext(CompositionManager);
3969
- const timelineContext = React.useContext(TimelineContext);
3970
- const setTimelineContext = React.useContext(SetTimelineContext);
3971
- const sequenceContext = React.useContext(SequenceContext);
3972
- const nonceContext = React.useContext(NonceContext);
3973
- const canUseRemotionHooksContext = React.useContext(CanUseRemotionHooks);
3974
- const nativeLayersContext = React.useContext(NativeLayersContext);
3975
- const preloadContext = React.useContext(PreloadContext);
3976
- const resolveCompositionContext = React.useContext(ResolveCompositionContext);
3977
- const renderAssetManagerContext = React.useContext(RenderAssetManager);
3978
- const sequenceManagerContext = React.useContext(SequenceManager);
3979
- return useMemo(() => ({
3980
- compositionManagerCtx,
3981
- timelineContext,
3982
- setTimelineContext,
3983
- sequenceContext,
3984
- nonceContext,
3985
- canUseRemotionHooksContext,
3986
- nativeLayersContext,
3987
- preloadContext,
3988
- resolveCompositionContext,
3989
- renderAssetManagerContext,
3990
- sequenceManagerContext,
3991
- }), [
3992
- compositionManagerCtx,
3993
- nonceContext,
3994
- sequenceContext,
3995
- setTimelineContext,
3996
- timelineContext,
3997
- canUseRemotionHooksContext,
3998
- nativeLayersContext,
3999
- preloadContext,
4000
- resolveCompositionContext,
4001
- renderAssetManagerContext,
4002
- sequenceManagerContext,
4003
- ]);
4004
- }
4005
- const RemotionContextProvider = (props) => {
4006
- const { children, contexts } = props;
4007
- return (jsx(CanUseRemotionHooks.Provider, { value: contexts.canUseRemotionHooksContext, children: jsx(NonceContext.Provider, { value: contexts.nonceContext, children: jsx(NativeLayersContext.Provider, { value: contexts.nativeLayersContext, children: jsx(PreloadContext.Provider, { value: contexts.preloadContext, children: jsx(CompositionManager.Provider, { value: contexts.compositionManagerCtx, children: jsx(SequenceManager.Provider, { value: contexts.sequenceManagerContext, children: jsx(RenderAssetManager.Provider, { value: contexts.renderAssetManagerContext, children: jsx(ResolveCompositionContext.Provider, { value: contexts.resolveCompositionContext, children: jsx(TimelineContext.Provider, { value: contexts.timelineContext, children: jsx(SetTimelineContext.Provider, { value: contexts.setTimelineContext, children: jsx(SequenceContext.Provider, { value: contexts.sequenceContext, children: children }) }) }) }) }) }) }) }) }) }) }));
4008
- };
4009
-
4010
- // Mark them as Internals so use don't assume this is public
4011
- // API and are less likely to use it
4012
- const Internals = {
4013
- useUnsafeVideoConfig,
4014
- Timeline: TimelinePosition,
4015
- CompositionManager,
4016
- SequenceManager,
4017
- RemotionRoot,
4018
- useVideo,
4019
- getRoot,
4020
- useMediaVolumeState,
4021
- useMediaMutedState,
4022
- useLazyComponent,
4023
- truthy,
4024
- SequenceContext,
4025
- useRemotionContexts,
4026
- RemotionContextProvider,
4027
- CSSUtils,
4028
- setupEnvVariables,
4029
- MediaVolumeContext,
4030
- SetMediaVolumeContext,
4031
- validateDurationInFrames,
4032
- validateFps,
4033
- validateDefaultAndInputProps,
4034
- validateDimension,
4035
- getRemotionEnvironment,
4036
- SharedAudioContext,
4037
- SharedAudioContextProvider,
4038
- invalidCompositionErrorMessage,
4039
- isCompositionIdValid,
4040
- getPreviewDomElement,
4041
- compositionsRef,
4042
- DELAY_RENDER_CALLSTACK_TOKEN,
4043
- portalNode,
4044
- waitForRoot,
4045
- CanUseRemotionHooksProvider,
4046
- CanUseRemotionHooks,
4047
- PrefetchProvider,
4048
- DurationsContextProvider,
4049
- IsPlayerContextProvider,
4050
- useIsPlayer,
4051
- validateFrame,
4052
- EditorPropsProvider,
4053
- EditorPropsContext,
4054
- usePreload,
4055
- processColor,
4056
- NonceContext,
4057
- resolveVideoConfig,
4058
- useResolvedVideoConfig,
4059
- resolveCompositionsRef,
4060
- ResolveCompositionConfig,
4061
- REMOTION_STUDIO_CONTAINER_ELEMENT,
4062
- RenderAssetManager,
4063
- bundleName: 'bundle.js',
4064
- bundleMapName: 'bundle.js.map',
4065
- persistCurrentFrame,
4066
- useTimelineSetFrame,
4067
- serializeJSONWithDate,
4068
- deserializeJSONWithCustomFields,
4069
- FILE_TOKEN,
4070
- DATE_TOKEN,
4071
- NativeLayersProvider,
4072
- ClipComposition,
4073
- isIosSafari,
4074
- WATCH_REMOTION_STATIC_FILES,
4075
- };
4076
-
4077
4037
  const flattenChildren = (children) => {
4078
4038
  const childrenArray = React.Children.toArray(children);
4079
4039
  return childrenArray.reduce((flatChildren, child) => {