@remotion/browser-bundler 4.0.534 → 4.0.535

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/runtime.js CHANGED
@@ -1,27 +1,3 @@
1
- var __create = Object.create;
2
- var __getProtoOf = Object.getPrototypeOf;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __toESM = (mod, isNodeMode, target) => {
7
- target = mod != null ? __create(__getProtoOf(mod)) : {};
8
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
- for (let key of __getOwnPropNames(mod))
10
- if (!__hasOwnProp.call(to, key))
11
- __defProp(to, key, {
12
- get: () => mod[key],
13
- enumerable: true
14
- });
15
- return to;
16
- };
17
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
18
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
19
- }) : x)(function(x) {
20
- if (typeof require !== "undefined")
21
- return require.apply(this, arguments);
22
- throw Error('Dynamic require of "' + x + '" is not supported');
23
- });
24
-
25
1
  // src/create-browser-bundle-runtime.ts
26
2
  import { Internals as Internals2 } from "remotion";
27
3
 
@@ -37,34 +13,6 @@ import * as RemotionVersion from "remotion/version";
37
13
 
38
14
  // src/source-location-jsx.ts
39
15
  import { Internals } from "remotion";
40
- var withSourceLocation = (factory, {
41
- isCreateElement,
42
- sourceArgumentIndex
43
- }) => {
44
- const componentsToAddStacksTo = Internals.getComponentsToAddStacksTo();
45
- const sequenceComponent = Internals.getSequenceComponent();
46
- const internalStackProp = Internals.REMOTION_INTERNAL_STACK_PROP;
47
- return new Proxy(factory, {
48
- apply(target, thisArg, argArray) {
49
- const [component, props, ...rest] = argArray;
50
- if (!componentsToAddStacksTo.includes(component)) {
51
- return Reflect.apply(target, thisArg, argArray);
52
- }
53
- const source = sourceArgumentIndex === null ? null : argArray[sourceArgumentIndex];
54
- const stack = source && typeof source.fileName === "string" && typeof source.lineNumber === "number" && typeof source.columnNumber === "number" ? Internals.makeOriginalSourceStack({
55
- fileName: source.fileName,
56
- lineNumber: source.lineNumber,
57
- columnNumber: source.columnNumber
58
- }) : new Error().stack;
59
- const newProps = props?.[internalStackProp] ? { ...props } : { ...props ?? {}, [internalStackProp]: stack };
60
- if (component === sequenceComponent) {
61
- const children = isCreateElement ? rest.length === 0 ? newProps.children : rest : newProps.children;
62
- newProps._remotionInternalSingleChildComponent = Internals.getSingleChildComponent(children);
63
- }
64
- return Reflect.apply(target, thisArg, [component, newProps, ...rest]);
65
- }
66
- });
67
- };
68
16
  var withOverrides = (module, overrides) => {
69
17
  const wrapped = { ...module, ...overrides };
70
18
  if (module.default !== null && typeof module.default === "object") {
@@ -79,26 +27,14 @@ var addSourceLocationsToJsxModules = ({
79
27
  }) => {
80
28
  return {
81
29
  react: withOverrides(react, {
82
- createElement: withSourceLocation(react.createElement, {
83
- isCreateElement: true,
84
- sourceArgumentIndex: null
85
- })
30
+ createElement: Internals.createElementSourceProxy(react.createElement, null, (fileName) => fileName)
86
31
  }),
87
32
  jsxRuntime: withOverrides(jsxRuntime, {
88
- jsx: withSourceLocation(jsxRuntime.jsx, {
89
- isCreateElement: false,
90
- sourceArgumentIndex: null
91
- }),
92
- jsxs: withSourceLocation(jsxRuntime.jsxs, {
93
- isCreateElement: false,
94
- sourceArgumentIndex: null
95
- })
33
+ jsx: Internals.createElementSourceProxy(jsxRuntime.jsx, null, (fileName) => fileName),
34
+ jsxs: Internals.createElementSourceProxy(jsxRuntime.jsxs, null, (fileName) => fileName)
96
35
  }),
97
36
  jsxDevRuntime: withOverrides(jsxDevRuntime, {
98
- jsxDEV: withSourceLocation(jsxDevRuntime.jsxDEV, {
99
- isCreateElement: false,
100
- sourceArgumentIndex: 4
101
- })
37
+ jsxDEV: Internals.createElementSourceProxy(jsxDevRuntime.jsxDEV, 4, (fileName) => fileName)
102
38
  })
103
39
  };
104
40
  };
@@ -379,7 +315,13 @@ var createBrowserBundleRuntime = () => {
379
315
  };
380
316
  };
381
317
  // src/create-browser-composition-observer.tsx
382
- import React2, { Suspense, useEffect, useMemo, useState } from "react";
318
+ import React2, {
319
+ Suspense,
320
+ useCallback,
321
+ useEffect,
322
+ useMemo,
323
+ useState
324
+ } from "react";
383
325
  import { createRoot } from "react-dom/client";
384
326
  import { Internals as Internals3 } from "remotion";
385
327
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -407,7 +349,17 @@ class RegistrationErrorBoundary extends React2.Component {
407
349
  }
408
350
  }
409
351
  var RegistrationCommitted = ({ revision, onCommit }) => {
410
- useEffect(() => onCommit(revision), [onCommit, revision]);
352
+ useEffect(() => {
353
+ let cancelled = false;
354
+ queueMicrotask(() => {
355
+ if (!cancelled) {
356
+ onCommit(revision);
357
+ }
358
+ });
359
+ return () => {
360
+ cancelled = true;
361
+ };
362
+ }, [onCommit, revision]);
411
363
  return null;
412
364
  };
413
365
  var ObserveMetadata = ({
@@ -475,32 +427,18 @@ var ObserveComposition = ({
475
427
  }) => {
476
428
  const [registeredRevision, setRegisteredRevision] = useState(null);
477
429
  const [compositions, setCompositions] = useState([]);
478
- const setters = useMemo(() => ({
479
- registerComposition: (composition) => {
480
- setCompositions((current) => {
481
- if (current.some(({ id }) => id === composition.id)) {
482
- throw new Error(`A composition with ID "${composition.id}" was registered more than once.`);
483
- }
484
- return [...current, composition];
485
- });
486
- },
487
- unregisterComposition: (id) => {
488
- setCompositions((current) => current.filter((composition) => composition.id !== id));
489
- },
490
- registerFolder: () => {
491
- return;
492
- },
493
- unregisterFolder: () => {
494
- return;
495
- },
496
- setCanvasContent: () => {
497
- return;
498
- },
499
- setCurrentAssetMetadata: () => {
500
- return;
501
- },
502
- onlyRenderComposition: null
503
- }), []);
430
+ const [registrationError, setRegistrationError] = useState(null);
431
+ const onSnapshot = useCallback((snapshot) => {
432
+ const ids = new Set;
433
+ for (const composition of snapshot.compositions) {
434
+ if (ids.has(composition.id)) {
435
+ setRegistrationError(new Error(`A composition with ID "${composition.id}" was registered more than once.`));
436
+ return;
437
+ }
438
+ ids.add(composition.id);
439
+ }
440
+ setCompositions((current) => current.length === snapshot.compositions.length && current.every((composition, index) => composition === snapshot.compositions[index]) ? current : [...snapshot.compositions]);
441
+ }, []);
504
442
  const registration = useMemo(() => /* @__PURE__ */ jsxs(Suspense, {
505
443
  fallback: null,
506
444
  children: [
@@ -511,10 +449,13 @@ var ObserveComposition = ({
511
449
  })
512
450
  ]
513
451
  }), [RegisteredRoot, revision]);
452
+ if (registrationError !== null) {
453
+ throw registrationError;
454
+ }
514
455
  return /* @__PURE__ */ jsx(Internals3.RemotionEnvironmentContext.Provider, {
515
456
  value: environment,
516
- children: /* @__PURE__ */ jsxs(Internals3.CompositionSetters.Provider, {
517
- value: setters,
457
+ children: /* @__PURE__ */ jsxs(Internals3.CompositionRegistryProvider, {
458
+ onSnapshot,
518
459
  children: [
519
460
  registration,
520
461
  /* @__PURE__ */ jsx(ObserveMetadata, {
@@ -691,29 +632,19 @@ var getBrowserComposition = async ({
691
632
  }
692
633
  });
693
634
  };
694
- const setters = {
695
- registerComposition: (composition) => {
696
- if (compositions.has(composition.id)) {
697
- throw new Error(`A composition with ID "${composition.id}" was registered more than once.`);
635
+ const onSnapshot = (snapshot) => {
636
+ const next = new Map;
637
+ for (const composition of snapshot.compositions) {
638
+ if (next.has(composition.id)) {
639
+ onError(new Error(`A composition with ID "${composition.id}" was registered more than once.`));
640
+ return;
698
641
  }
699
- compositions.set(composition.id, composition);
700
- },
701
- unregisterComposition: (id) => {
702
- compositions.delete(id);
703
- },
704
- registerFolder: () => {
705
- return;
706
- },
707
- unregisterFolder: () => {
708
- return;
709
- },
710
- setCanvasContent: () => {
711
- return;
712
- },
713
- setCurrentAssetMetadata: () => {
714
- return;
715
- },
716
- onlyRenderComposition: null
642
+ next.set(composition.id, composition);
643
+ }
644
+ compositions.clear();
645
+ for (const [id, composition] of next) {
646
+ compositions.set(id, composition);
647
+ }
717
648
  };
718
649
  reactRoot = createRoot2(container, {
719
650
  onCaughtError: onError,
@@ -729,8 +660,8 @@ var getBrowserComposition = async ({
729
660
  isRendering: false,
730
661
  isStudio: false
731
662
  },
732
- children: /* @__PURE__ */ jsx2(Internals4.CompositionSetters.Provider, {
733
- value: setters,
663
+ children: /* @__PURE__ */ jsx2(Internals4.CompositionRegistryProvider, {
664
+ onSnapshot,
734
665
  children: /* @__PURE__ */ jsxs2(Suspense2, {
735
666
  fallback: null,
736
667
  children: [
@@ -769,8 +700,8 @@ var loadBrowserBundle = ({ bundle }) => {
769
700
  return scope.getRoot();
770
701
  };
771
702
  export {
772
- loadBrowserBundle,
773
- getBrowserComposition,
703
+ createBrowserBundleRuntime,
774
704
  createBrowserCompositionObserver,
775
- createBrowserBundleRuntime
705
+ getBrowserComposition,
706
+ loadBrowserBundle
776
707
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/browser-bundler",
3
- "version": "4.0.534",
3
+ "version": "4.0.535",
4
4
  "description": "Compile virtual Remotion projects in the browser",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@rspack/browser": "2.1.1",
28
28
  "react-refresh": "0.18.0",
29
- "remotion": "4.0.534"
29
+ "remotion": "4.0.535"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">=18.0.0",
@@ -53,8 +53,8 @@
53
53
  "devDependencies": {
54
54
  "@rspack/plugin-react-refresh": "1.6.1",
55
55
  "@happy-dom/global-registrator": "14.5.1",
56
- "@remotion/eslint-config-internal": "4.0.534",
57
- "@remotion/player": "4.0.534",
56
+ "@remotion/eslint-config-internal": "4.0.535",
57
+ "@remotion/player": "4.0.535",
58
58
  "@testing-library/react": "16.1.0",
59
59
  "@types/react": "19.2.7",
60
60
  "@types/react-dom": "19.2.3",