@remotion/browser-bundler 4.0.529 → 4.0.531

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.
@@ -1417,4 +1417,4 @@ require(${JSON.stringify(Y)});
1417
1417
  module.hot.accept(${JSON.stringify(Y)}, () => {
1418
1418
  require(${JSON.stringify(Y)});
1419
1419
  });
1420
- `}:{},onProgress:($)=>vB({type:"progress",...$}),configure:($)=>({context:NY(Q.rootDir),mode:"development",devtool:"inline-cheap-module-source-map",entry:{bundle:{asyncChunks:!1,import:J?[QG.entry,wD]:[Y]}},experiments:{buildHttp:{allowedUris:["https://esm.sh/",`${self.location.origin}/`],cacheLocation:!1,httpClient:kD({fetchImplementation:fetch})}},externals:Object.fromEntries([...Ug,...J?["react-refresh/runtime"]:[]].map((U)=>[U,`commonjs ${U}`])),module:{rules:[{parser:{worker:!1},test:/\.[cm]?[jt]sx?$/},...J?[{exclude:[/node_modules/,/__remotion_browser_bundler__/],test:/\.[jt]sx?$/,use:[{loader:"builtin:react-refresh-loader"}]}]:[],{test:/\.[jt]sx?$/,use:[{loader:"builtin:swc-loader",options:{env:{targets:"Chrome >= 111"},jsc:{parser:{syntax:"typescript",tsx:!0},transform:{react:{development:J,refresh:J,runtime:"automatic"}}}}}]}]},optimization:{emitOnErrors:!J,runtimeChunk:!1,splitChunks:!1},output:{chunkFilename:"[name].js",chunkFormat:"array-push",chunkLoading:"jsonp",filename:"bundle.js",path:"/dist",publicPath:"",hashFunction:"xxhash64",uniqueName:"remotion-browser-bundler",...J?{hotUpdateGlobal:WD}:{}},plugins:[...J?[PD({rspack:$,refreshRuntime:QG.runtime,refreshUtils:QG.utils}),new $.HotModuleReplacementPlugin,ID({rspack:$,bridgeName:mB})]:[],TD({rspack:$,development:J,external:["react","react-dom","remotion",...J?["react-refresh"]:[]],resolvedUrls:{},resolvedVersions:{...{react:"19.2.3","react-dom":"19.2.3",remotion:"4.0.529"},...X.dependencyVersions},resolvePackage:null}),new $.optimize.LimitChunkCountPlugin({maxChunks:1})],resolve:{extensions:[".tsx",".ts",".jsx",".js",".json"]}})}),hB=Q;let K=await C6.compile(Q);if(K.bundle===null)throw new ZG("Rspack compilation failed",K.errors);if(J&&(!K.hash||XG===null))throw Error("Rspack did not return a Fast Refresh build hash.");vB({type:"bundle",id:X.id,bundle:{code:K.bundle,warnings:K.warnings,fastRefresh:J&&K.hash&&XG!==null?{sessionId:XG,hash:K.hash,previousHash:_B,assets:K.assets.filter(($)=>$.name.includes(".hot-update."))}:null}}),_B=K.hash??null}catch(Q){vB({type:"error",id:X.id,error:DD(Q)})}})});
1420
+ `}:{},onProgress:($)=>vB({type:"progress",...$}),configure:($)=>({context:NY(Q.rootDir),mode:"development",devtool:"inline-cheap-module-source-map",entry:{bundle:{asyncChunks:!1,import:J?[QG.entry,wD]:[Y]}},experiments:{buildHttp:{allowedUris:["https://esm.sh/",`${self.location.origin}/`],cacheLocation:!1,httpClient:kD({fetchImplementation:fetch})}},externals:Object.fromEntries([...Ug,...J?["react-refresh/runtime"]:[]].map((U)=>[U,`commonjs ${U}`])),module:{rules:[{parser:{worker:!1},test:/\.[cm]?[jt]sx?$/},...J?[{exclude:[/node_modules/,/__remotion_browser_bundler__/],test:/\.[jt]sx?$/,use:[{loader:"builtin:react-refresh-loader"}]}]:[],{test:/\.[jt]sx?$/,use:[{loader:"builtin:swc-loader",options:{env:{targets:"Chrome >= 111"},jsc:{parser:{syntax:"typescript",tsx:!0},transform:{react:{development:J,refresh:J,runtime:"automatic"}}}}}]}]},optimization:{emitOnErrors:!J,runtimeChunk:!1,splitChunks:!1},output:{chunkFilename:"[name].js",chunkFormat:"array-push",chunkLoading:"jsonp",filename:"bundle.js",path:"/dist",publicPath:"",hashFunction:"xxhash64",uniqueName:"remotion-browser-bundler",...J?{hotUpdateGlobal:WD}:{}},plugins:[...J?[PD({rspack:$,refreshRuntime:QG.runtime,refreshUtils:QG.utils}),new $.HotModuleReplacementPlugin,ID({rspack:$,bridgeName:mB})]:[],TD({rspack:$,development:J,external:["react","react-dom","remotion",...J?["react-refresh"]:[]],resolvedUrls:{},resolvedVersions:{...{react:"19.2.3","react-dom":"19.2.3",remotion:"4.0.531"},...X.dependencyVersions},resolvePackage:null}),new $.optimize.LimitChunkCountPlugin({maxChunks:1})],resolve:{extensions:[".tsx",".ts",".jsx",".js",".json"]}})}),hB=Q;let K=await C6.compile(Q);if(K.bundle===null)throw new ZG("Rspack compilation failed",K.errors);if(J&&(!K.hash||XG===null))throw Error("Rspack did not return a Fast Refresh build hash.");vB({type:"bundle",id:X.id,bundle:{code:K.bundle,warnings:K.warnings,fastRefresh:J&&K.hash&&XG!==null?{sessionId:XG,hash:K.hash,previousHash:_B,assets:K.assets.filter(($)=>$.name.includes(".hot-update."))}:null}}),_B=K.hash??null}catch(Q){vB({type:"error",id:X.id,error:DD(Q)})}})});
@@ -1,5 +1,8 @@
1
1
  import * as React from 'react';
2
- export declare const createBrowserModuleScope: (additionalModules: ReadonlyMap<string, unknown> | null) => {
2
+ export declare const createBrowserModuleScope: ({ additionalModules, addSourceLocations, }: {
3
+ additionalModules: ReadonlyMap<string, unknown> | null;
4
+ addSourceLocations: boolean;
5
+ }) => {
3
6
  resolveModule: (id: string) => unknown;
4
7
  beginUpdate: () => void;
5
8
  getRoot: () => React.FC<{}>;
package/dist/runtime.js CHANGED
@@ -23,7 +23,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
23
23
  });
24
24
 
25
25
  // src/create-browser-bundle-runtime.ts
26
- import { Internals } from "remotion";
26
+ import { Internals as Internals2 } from "remotion";
27
27
 
28
28
  // src/browser-module-scope.ts
29
29
  import * as React from "react";
@@ -34,7 +34,80 @@ import * as JSXRuntime from "react/jsx-runtime";
34
34
  import * as Remotion from "remotion";
35
35
  import * as RemotionNoReact from "remotion/no-react";
36
36
  import * as RemotionVersion from "remotion/version";
37
- var createBrowserModuleScope = (additionalModules) => {
37
+
38
+ // src/source-location-jsx.ts
39
+ 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
+ var withOverrides = (module, overrides) => {
69
+ const wrapped = { ...module, ...overrides };
70
+ if (module.default !== null && typeof module.default === "object") {
71
+ wrapped.default = { ...module.default, ...overrides };
72
+ }
73
+ return wrapped;
74
+ };
75
+ var addSourceLocationsToJsxModules = ({
76
+ react,
77
+ jsxRuntime,
78
+ jsxDevRuntime
79
+ }) => {
80
+ return {
81
+ react: withOverrides(react, {
82
+ createElement: withSourceLocation(react.createElement, {
83
+ isCreateElement: true,
84
+ sourceArgumentIndex: null
85
+ })
86
+ }),
87
+ 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
+ })
96
+ }),
97
+ jsxDevRuntime: withOverrides(jsxDevRuntime, {
98
+ jsxDEV: withSourceLocation(jsxDevRuntime.jsxDEV, {
99
+ isCreateElement: false,
100
+ sourceArgumentIndex: 4
101
+ })
102
+ })
103
+ };
104
+ };
105
+
106
+ // src/browser-module-scope.ts
107
+ var createBrowserModuleScope = ({
108
+ additionalModules,
109
+ addSourceLocations
110
+ }) => {
38
111
  let root = null;
39
112
  let registrations = 0;
40
113
  const registerRoot = (component) => {
@@ -47,12 +120,17 @@ var createBrowserModuleScope = (additionalModules) => {
47
120
  registrations++;
48
121
  root = component;
49
122
  };
123
+ const jsxModules = addSourceLocations ? addSourceLocationsToJsxModules({
124
+ react: React,
125
+ jsxRuntime: JSXRuntime,
126
+ jsxDevRuntime: JSXDevRuntime
127
+ }) : { react: React, jsxRuntime: JSXRuntime, jsxDevRuntime: JSXDevRuntime };
50
128
  const sharedModules = new Map([
51
- ["react", React],
129
+ ["react", jsxModules.react],
52
130
  ["react-dom", ReactDOM],
53
131
  ["react-dom/client", ReactDOMClient],
54
- ["react/jsx-runtime", JSXRuntime],
55
- ["react/jsx-dev-runtime", JSXDevRuntime],
132
+ ["react/jsx-runtime", jsxModules.jsxRuntime],
133
+ ["react/jsx-dev-runtime", jsxModules.jsxDevRuntime],
56
134
  ["remotion", { ...Remotion, registerRoot }],
57
135
  ["remotion/no-react", RemotionNoReact],
58
136
  ["remotion/version", RemotionVersion],
@@ -219,8 +297,11 @@ var createBrowserBundleRuntime = () => {
219
297
  if (renderers.length > 0 && !renderers.some((renderer) => renderer !== null && typeof renderer === "object" && ("scheduleRefresh" in renderer) && typeof renderer.scheduleRefresh === "function" && ("setRefreshHandler" in renderer) && typeof renderer.setRefreshHandler === "function")) {
220
298
  throw new Error("Fast Refresh requires development React DOM. Inject the React Refresh hook before importing the preview renderer.");
221
299
  }
222
- const initialScope = createBrowserModuleScope(new Map([["react-refresh/runtime", refresh]]));
223
- Internals.setComponentIdentityResolver((component) => refresh.getFamilyByType(component) ?? component);
300
+ const initialScope = createBrowserModuleScope({
301
+ additionalModules: new Map([["react-refresh/runtime", refresh]]),
302
+ addSourceLocations: true
303
+ });
304
+ Internals2.setComponentIdentityResolver((component) => refresh.getFamilyByType(component) ?? component);
224
305
  ownsComponentIdentityResolver = true;
225
306
  Object.defineProperty(globalThis, "require", {
226
307
  configurable: true,
@@ -254,7 +335,10 @@ var createBrowserBundleRuntime = () => {
254
335
  if (disposed) {
255
336
  throw new Error("The browser bundle runtime was disposed.");
256
337
  }
257
- refresh.performReactRefresh();
338
+ window.dispatchEvent(new Event(Internals2.REACT_REFRESH_STARTED_EVENT));
339
+ if (refresh.performReactRefresh() !== null) {
340
+ window.dispatchEvent(new Event(Internals2.REACT_REFRESH_FINISHED_EVENT));
341
+ }
258
342
  }
259
343
  if (disposed) {
260
344
  throw new Error("The browser bundle runtime was disposed.");
@@ -277,7 +361,7 @@ var createBrowserBundleRuntime = () => {
277
361
  }
278
362
  disposed = true;
279
363
  if (ownsComponentIdentityResolver) {
280
- Internals.setComponentIdentityResolver(null);
364
+ Internals2.setComponentIdentityResolver(null);
281
365
  }
282
366
  assets.dispose();
283
367
  Reflect.deleteProperty(globalThis, browserBundleHmrBridgeName);
@@ -297,7 +381,7 @@ var createBrowserBundleRuntime = () => {
297
381
  // src/create-browser-composition-observer.tsx
298
382
  import React2, { Suspense, useEffect, useMemo, useState } from "react";
299
383
  import { createRoot } from "react-dom/client";
300
- import { Internals as Internals2 } from "remotion";
384
+ import { Internals as Internals3 } from "remotion";
301
385
  import { jsx, jsxs } from "react/jsx-runtime";
302
386
  var environment = {
303
387
  isClientSideRendering: false,
@@ -346,7 +430,7 @@ var ObserveMetadata = ({
346
430
  const controller = new AbortController;
347
431
  const defaultProps = composition.defaultProps ?? {};
348
432
  try {
349
- const config = Internals2.resolveVideoConfig({
433
+ const config = Internals3.resolveVideoConfig({
350
434
  compositionId,
351
435
  compositionWidth: composition.width ?? null,
352
436
  compositionHeight: composition.height ?? null,
@@ -427,9 +511,9 @@ var ObserveComposition = ({
427
511
  })
428
512
  ]
429
513
  }), [RegisteredRoot, revision]);
430
- return /* @__PURE__ */ jsx(Internals2.RemotionEnvironmentContext.Provider, {
514
+ return /* @__PURE__ */ jsx(Internals3.RemotionEnvironmentContext.Provider, {
431
515
  value: environment,
432
- children: /* @__PURE__ */ jsxs(Internals2.CompositionSetters.Provider, {
516
+ children: /* @__PURE__ */ jsxs(Internals3.CompositionSetters.Provider, {
433
517
  value: setters,
434
518
  children: [
435
519
  registration,
@@ -515,7 +599,7 @@ var createBrowserCompositionObserver = ({
515
599
  // src/get-browser-composition.tsx
516
600
  import React3, { Suspense as Suspense2, useEffect as useEffect2 } from "react";
517
601
  import { createRoot as createRoot2 } from "react-dom/client";
518
- import { Internals as Internals3 } from "remotion";
602
+ import { Internals as Internals4 } from "remotion";
519
603
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
520
604
 
521
605
  class RegistrationErrorBoundary2 extends React3.Component {
@@ -584,7 +668,7 @@ var getBrowserComposition = async ({
584
668
  throw new Error(`No composition with ID "${compositionId}" was registered. Available IDs: ${[...compositions.keys()].join(", ") || "(none)"}.`);
585
669
  }
586
670
  const defaultProps = composition.defaultProps ?? {};
587
- const config = Internals3.resolveVideoConfig({
671
+ const config = Internals4.resolveVideoConfig({
588
672
  compositionId,
589
673
  compositionWidth: composition.width ?? null,
590
674
  compositionHeight: composition.height ?? null,
@@ -637,7 +721,7 @@ var getBrowserComposition = async ({
637
721
  });
638
722
  reactRoot.render(/* @__PURE__ */ jsx2(RegistrationErrorBoundary2, {
639
723
  onError,
640
- children: /* @__PURE__ */ jsx2(Internals3.RemotionEnvironmentContext.Provider, {
724
+ children: /* @__PURE__ */ jsx2(Internals4.RemotionEnvironmentContext.Provider, {
641
725
  value: {
642
726
  isClientSideRendering: false,
643
727
  isPlayer: false,
@@ -645,7 +729,7 @@ var getBrowserComposition = async ({
645
729
  isRendering: false,
646
730
  isStudio: false
647
731
  },
648
- children: /* @__PURE__ */ jsx2(Internals3.CompositionSetters.Provider, {
732
+ children: /* @__PURE__ */ jsx2(Internals4.CompositionSetters.Provider, {
649
733
  value: setters,
650
734
  children: /* @__PURE__ */ jsxs2(Suspense2, {
651
735
  fallback: null,
@@ -677,7 +761,10 @@ var loadBrowserBundle = ({ bundle }) => {
677
761
  if (bundle.fastRefresh) {
678
762
  throw new Error("Use createBrowserBundleRuntime() to load a Fast Refresh bundle.");
679
763
  }
680
- const scope = createBrowserModuleScope(null);
764
+ const scope = createBrowserModuleScope({
765
+ additionalModules: null,
766
+ addSourceLocations: false
767
+ });
681
768
  scope.evaluate(bundle.code);
682
769
  return scope.getRoot();
683
770
  };
@@ -0,0 +1,16 @@
1
+ import type * as React from 'react';
2
+ import type * as JSXDevRuntime from 'react/jsx-dev-runtime';
3
+ import type * as JSXRuntime from 'react/jsx-runtime';
4
+ type ModuleRecord = Record<string, unknown> & {
5
+ default?: unknown;
6
+ };
7
+ export declare const addSourceLocationsToJsxModules: ({ react, jsxRuntime, jsxDevRuntime, }: {
8
+ react: typeof React;
9
+ jsxRuntime: typeof JSXRuntime;
10
+ jsxDevRuntime: typeof JSXDevRuntime;
11
+ }) => {
12
+ react: ModuleRecord;
13
+ jsxRuntime: ModuleRecord;
14
+ jsxDevRuntime: ModuleRecord;
15
+ };
16
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/browser-bundler",
3
- "version": "4.0.529",
3
+ "version": "4.0.531",
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.529"
29
+ "remotion": "4.0.531"
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.529",
57
- "@remotion/player": "4.0.529",
56
+ "@remotion/eslint-config-internal": "4.0.531",
57
+ "@remotion/player": "4.0.531",
58
58
  "@testing-library/react": "16.1.0",
59
59
  "@types/react": "19.2.7",
60
60
  "@types/react-dom": "19.2.3",