@remotion/renderer 4.0.288 → 4.0.290

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.
@@ -1,44 +1,12 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
6
  exports.cleanDownloadMap = exports.makeDownloadMap = void 0;
40
- const node_fs_1 = __importStar(require("node:fs"));
7
+ const node_fs_1 = require("node:fs");
41
8
  const node_path_1 = __importDefault(require("node:path"));
9
+ const version_1 = require("remotion/version");
42
10
  const delete_directory_1 = require("../delete-directory");
43
11
  const offthread_video_server_1 = require("../offthread-video-server");
44
12
  const tmp_dir_1 = require("../tmp-dir");
@@ -47,19 +15,8 @@ const makeAndReturn = (dir, name) => {
47
15
  (0, node_fs_1.mkdirSync)(p);
48
16
  return p;
49
17
  };
50
- const dontInlineThis = 'package.json';
51
- let packageJsonPath = null;
52
- try {
53
- packageJsonPath = require.resolve('../../' + dontInlineThis);
54
- }
55
- catch (_a) { }
56
- const packageJson = packageJsonPath && node_fs_1.default.existsSync(packageJsonPath)
57
- ? JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, 'utf-8'))
58
- : null;
59
18
  const makeDownloadMap = () => {
60
- const dir = (0, tmp_dir_1.tmpDir)(packageJson
61
- ? `remotion-v${packageJson.version.replace(/\./g, '-')}-assets`
62
- : 'remotion-assets');
19
+ const dir = (0, tmp_dir_1.tmpDir)(`remotion-v${version_1.VERSION}-assets`);
63
20
  let prevented = false;
64
21
  return {
65
22
  isDownloadingMap: {},
@@ -43,6 +43,7 @@ export declare class HeadlessBrowser extends EventEmitter {
43
43
  indent: boolean;
44
44
  }): Promise<HeadlessBrowser>;
45
45
  connection: Connection;
46
+ id: string;
46
47
  runner: BrowserRunner;
47
48
  get _targets(): Map<string, Target>;
48
49
  constructor({ connection, defaultViewport, runner, }: {
@@ -63,6 +63,7 @@ class HeadlessBrowser extends EventEmitter_1.EventEmitter {
63
63
  _HeadlessBrowser_targets.set(this, void 0);
64
64
  __classPrivateFieldSet(this, _HeadlessBrowser_defaultViewport, defaultViewport, "f");
65
65
  this.connection = connection;
66
+ this.id = Math.random().toString(36).substring(2, 15);
66
67
  __classPrivateFieldSet(this, _HeadlessBrowser_defaultContext, new BrowserContext(this), "f");
67
68
  __classPrivateFieldSet(this, _HeadlessBrowser_contexts, new Map(), "f");
68
69
  __classPrivateFieldSet(this, _HeadlessBrowser_targets, new Map(), "f");
@@ -16,16 +16,22 @@ const collectAssets = async ({ frame, freePage, timeoutInMilliseconds, }) => {
16
16
  if (asset.type !== 'artifact') {
17
17
  return asset;
18
18
  }
19
- if (typeof asset.content !== 'string') {
20
- throw new Error(`Expected string content for artifact ${asset.id}, but got ${asset.content}`);
19
+ if (asset.contentType === 'binary' || asset.contentType === 'text') {
20
+ if (typeof asset.content !== 'string') {
21
+ throw new Error(`Expected string content for artifact ${asset.id}, but got ${asset.content}`);
22
+ }
23
+ const stringOrUintArray = asset.contentType === 'binary'
24
+ ? new TextEncoder().encode(atob(asset.content))
25
+ : asset.content;
26
+ return {
27
+ ...asset,
28
+ content: stringOrUintArray,
29
+ };
21
30
  }
22
- const stringOrUintArray = asset.binary
23
- ? new TextEncoder().encode(atob(asset.content))
24
- : asset.content;
25
- return {
26
- ...asset,
27
- content: stringOrUintArray,
28
- };
31
+ if (asset.contentType === 'thumbnail') {
32
+ return asset;
33
+ }
34
+ return asset;
29
35
  });
30
36
  return fixedArtifacts;
31
37
  };
@@ -3569,6 +3569,7 @@ class HeadlessBrowser extends EventEmitter {
3569
3569
  #defaultContext;
3570
3570
  #contexts;
3571
3571
  #targets;
3572
+ id;
3572
3573
  runner;
3573
3574
  get _targets() {
3574
3575
  return this.#targets;
@@ -3581,6 +3582,7 @@ class HeadlessBrowser extends EventEmitter {
3581
3582
  super();
3582
3583
  this.#defaultViewport = defaultViewport;
3583
3584
  this.connection = connection;
3585
+ this.id = Math.random().toString(36).substring(2, 15);
3584
3586
  this.#defaultContext = new BrowserContext(this);
3585
3587
  this.#contexts = new Map;
3586
3588
  this.#targets = new Map;
@@ -14501,8 +14503,9 @@ var attachDownloadListenerToEmitter = (downloadMap, onDownload) => {
14501
14503
  };
14502
14504
 
14503
14505
  // src/assets/download-map.ts
14504
- import fs12, { mkdirSync as mkdirSync2 } from "node:fs";
14506
+ import { mkdirSync as mkdirSync2 } from "node:fs";
14505
14507
  import path14 from "node:path";
14508
+ import { VERSION as VERSION2 } from "remotion/version";
14506
14509
 
14507
14510
  // src/offthread-video-server.ts
14508
14511
  import { URLSearchParams } from "node:url";
@@ -14931,14 +14934,8 @@ var makeAndReturn = (dir, name) => {
14931
14934
  mkdirSync2(p);
14932
14935
  return p;
14933
14936
  };
14934
- var dontInlineThis = "package.json";
14935
- var packageJsonPath = null;
14936
- try {
14937
- packageJsonPath = __require.resolve("../../" + dontInlineThis);
14938
- } catch {}
14939
- var packageJson = packageJsonPath && fs12.existsSync(packageJsonPath) ? JSON.parse(fs12.readFileSync(packageJsonPath, "utf-8")) : null;
14940
14937
  var makeDownloadMap = () => {
14941
- const dir = tmpDir(packageJson ? `remotion-v${packageJson.version.replace(/\./g, "-")}-assets` : "remotion-assets");
14938
+ const dir = tmpDir(`remotion-v${VERSION2}-assets`);
14942
14939
  let prevented = false;
14943
14940
  return {
14944
14941
  isDownloadingMap: {},
@@ -15990,7 +15987,7 @@ var seekToFrame = async ({
15990
15987
  };
15991
15988
 
15992
15989
  // src/set-props-and-env.ts
15993
- import { VERSION as VERSION2 } from "remotion/version";
15990
+ import { VERSION as VERSION3 } from "remotion/version";
15994
15991
 
15995
15992
  // src/goto-page-or-throw.ts
15996
15993
  var gotoPageOrThrow = async (page, urlToVisit, actualTimeout) => {
@@ -16179,7 +16176,7 @@ var innerSetPropsAndEnv = async ({
16179
16176
  throw new Error([
16180
16177
  `Incompatible site: When visiting ${urlToVisit}, a bundle was found, but one that is not compatible with this version of Remotion. Found version: ${siteVersion} - Required version: ${requiredVersion}. To resolve this error:`,
16181
16178
  "When using server-side rendering:",
16182
- ` ▸ Use 'bundle()' with '@remotion/bundler' of version ${VERSION2} to create a compatible bundle.`,
16179
+ ` ▸ Use 'bundle()' with '@remotion/bundler' of version ${VERSION3} to create a compatible bundle.`,
16183
16180
  "When using the Remotion Lambda:",
16184
16181
  " ▸ Use `npx remotion lambda sites create` to redeploy the site with the latest version.",
16185
16182
  " ℹ Use --site-name with the same name as before to overwrite your site.",
@@ -16187,13 +16184,13 @@ var innerSetPropsAndEnv = async ({
16187
16184
  ].join(`
16188
16185
  `));
16189
16186
  }
16190
- if (remotionVersion !== VERSION2 && true) {
16187
+ if (remotionVersion !== VERSION3 && true) {
16191
16188
  if (remotionVersion) {
16192
16189
  Log.warn({
16193
16190
  indent,
16194
16191
  logLevel
16195
16192
  }, [
16196
- `The site was bundled with version ${remotionVersion} of @remotion/bundler, while @remotion/renderer is on version ${VERSION2}. You may not have the newest bugfixes and features.`,
16193
+ `The site was bundled with version ${remotionVersion} of @remotion/bundler, while @remotion/renderer is on version ${VERSION3}. You may not have the newest bugfixes and features.`,
16197
16194
  `To resolve this warning:`,
16198
16195
  "▸ Use `npx remotion lambda sites create` to redeploy the site with the latest version.",
16199
16196
  " ℹ Use --site-name with the same name as before to overwrite your site.",
@@ -16204,7 +16201,7 @@ var innerSetPropsAndEnv = async ({
16204
16201
  Log.warn({
16205
16202
  indent,
16206
16203
  logLevel
16207
- }, `The site was bundled with an old version of Remotion, while @remotion/renderer is on version ${VERSION2}. You may not have the newest bugfixes and features. Re-bundle the site to fix this issue.`);
16204
+ }, `The site was bundled with an old version of Remotion, while @remotion/renderer is on version ${VERSION3}. You may not have the newest bugfixes and features. Re-bundle the site to fix this issue.`);
16208
16205
  }
16209
16206
  }
16210
16207
  };
@@ -16837,9 +16834,7 @@ __export(exports_perf, {
16837
16834
  getPerf: () => getPerf
16838
16835
  });
16839
16836
  var perf = {
16840
- "activate-target": [],
16841
16837
  capture: [],
16842
- save: [],
16843
16838
  "extract-frame": [],
16844
16839
  piping: []
16845
16840
  };
@@ -16903,7 +16898,7 @@ var validateSelectedPixelFormatAndCodecCombination = (pixelFormat, codec) => {
16903
16898
  };
16904
16899
 
16905
16900
  // src/render-frames.ts
16906
- import fs14 from "node:fs";
16901
+ import fs13 from "node:fs";
16907
16902
  import path20 from "node:path";
16908
16903
  import { NoReactInternals as NoReactInternals12 } from "remotion/no-react";
16909
16904
 
@@ -16957,7 +16952,7 @@ var cycleBrowserTabs = ({
16957
16952
  // src/combine-audio.ts
16958
16953
  import { rmSync as rmSync2, writeFileSync } from "fs";
16959
16954
  import { join as join3 } from "path";
16960
- import { VERSION as VERSION3 } from "remotion/version";
16955
+ import { VERSION as VERSION4 } from "remotion/version";
16961
16956
 
16962
16957
  // src/options/separate-audio.tsx
16963
16958
  var DEFAULT = null;
@@ -17221,7 +17216,7 @@ var encodeAudio = async ({
17221
17216
  audioBitrate ? audioBitrate : "320k",
17222
17217
  "-vn",
17223
17218
  addRemotionMetadata ? `-metadata` : null,
17224
- addRemotionMetadata ? `comment=Made with Remotion ${VERSION3}` : null,
17219
+ addRemotionMetadata ? `comment=Made with Remotion ${VERSION4}` : null,
17225
17220
  "-y",
17226
17221
  output
17227
17222
  ];
@@ -17297,7 +17292,7 @@ var combineAudioSeamlessly = async ({
17297
17292
  "copy",
17298
17293
  "-vn",
17299
17294
  addRemotionMetadata ? `-metadata` : null,
17300
- addRemotionMetadata ? `comment=Made with Remotion ${VERSION3}` : null,
17295
+ addRemotionMetadata ? `comment=Made with Remotion ${VERSION4}` : null,
17301
17296
  "-y",
17302
17297
  output
17303
17298
  ];
@@ -17722,8 +17717,31 @@ import path19 from "path";
17722
17717
  var onlyAudioAndVideoAssets = (assets) => {
17723
17718
  return assets.filter((asset) => asset.type === "audio" || asset.type === "video");
17724
17719
  };
17725
- var onlyArtifact = (assets) => {
17726
- return assets.filter((asset) => asset.type === "artifact");
17720
+ var onlyArtifact = ({
17721
+ assets,
17722
+ frameBuffer
17723
+ }) => {
17724
+ const artifacts = assets.filter((asset) => asset.type === "artifact");
17725
+ return artifacts.map((artifact) => {
17726
+ if (artifact.contentType === "binary" || artifact.contentType === "text") {
17727
+ return {
17728
+ frame: artifact.frame,
17729
+ content: artifact.content,
17730
+ filename: artifact.filename
17731
+ };
17732
+ }
17733
+ if (artifact.contentType === "thumbnail") {
17734
+ if (frameBuffer === null) {
17735
+ return null;
17736
+ }
17737
+ return {
17738
+ frame: artifact.frame,
17739
+ content: new Uint8Array(frameBuffer),
17740
+ filename: artifact.filename
17741
+ };
17742
+ }
17743
+ throw new Error("Unknown artifact type: " + artifact);
17744
+ }).filter(truthy);
17727
17745
  };
17728
17746
 
17729
17747
  // src/collect-assets.ts
@@ -17745,14 +17763,20 @@ var collectAssets = async ({
17745
17763
  if (asset.type !== "artifact") {
17746
17764
  return asset;
17747
17765
  }
17748
- if (typeof asset.content !== "string") {
17749
- throw new Error(`Expected string content for artifact ${asset.id}, but got ${asset.content}`);
17766
+ if (asset.contentType === "binary" || asset.contentType === "text") {
17767
+ if (typeof asset.content !== "string") {
17768
+ throw new Error(`Expected string content for artifact ${asset.id}, but got ${asset.content}`);
17769
+ }
17770
+ const stringOrUintArray = asset.contentType === "binary" ? new TextEncoder().encode(atob(asset.content)) : asset.content;
17771
+ return {
17772
+ ...asset,
17773
+ content: stringOrUintArray
17774
+ };
17750
17775
  }
17751
- const stringOrUintArray = asset.binary ? new TextEncoder().encode(atob(asset.content)) : asset.content;
17752
- return {
17753
- ...asset,
17754
- content: stringOrUintArray
17755
- };
17776
+ if (asset.contentType === "thumbnail") {
17777
+ return asset;
17778
+ }
17779
+ return asset;
17756
17780
  });
17757
17781
  return fixedArtifacts;
17758
17782
  };
@@ -17761,7 +17785,7 @@ var collectAssets = async ({
17761
17785
  import * as assert2 from "node:assert";
17762
17786
 
17763
17787
  // src/screenshot-task.ts
17764
- import fs13 from "node:fs";
17788
+ import fs12 from "node:fs";
17765
17789
  var screenshotTask = async ({
17766
17790
  format,
17767
17791
  height,
@@ -17774,16 +17798,14 @@ var screenshotTask = async ({
17774
17798
  }) => {
17775
17799
  const client = page._client();
17776
17800
  const target = page.target();
17777
- const perfTarget = startPerfMeasure("activate-target");
17778
17801
  await client.send("Target.activateTarget", {
17779
17802
  targetId: target._targetId
17780
17803
  });
17781
- stopPerfMeasure(perfTarget);
17782
- const shouldSetDefaultBackground = omitBackground;
17783
- if (shouldSetDefaultBackground)
17804
+ if (omitBackground) {
17784
17805
  await client.send("Emulation.setDefaultBackgroundColorOverride", {
17785
17806
  color: { r: 0, g: 0, b: 0, a: 0 }
17786
17807
  });
17808
+ }
17787
17809
  const cap = startPerfMeasure("capture");
17788
17810
  try {
17789
17811
  let result;
@@ -17819,13 +17841,13 @@ var screenshotTask = async ({
17819
17841
  result = value;
17820
17842
  }
17821
17843
  stopPerfMeasure(cap);
17822
- if (shouldSetDefaultBackground)
17844
+ if (omitBackground) {
17823
17845
  await client.send("Emulation.setDefaultBackgroundColorOverride");
17824
- const saveMarker = startPerfMeasure("save");
17846
+ }
17825
17847
  const buffer = Buffer.from(result.data, "base64");
17826
- if (path19)
17827
- await fs13.promises.writeFile(path19, buffer);
17828
- stopPerfMeasure(saveMarker);
17848
+ if (path19) {
17849
+ await fs12.promises.writeFile(path19, buffer);
17850
+ }
17829
17851
  return buffer;
17830
17852
  } catch (err) {
17831
17853
  if (err.message.includes("Unable to capture screenshot")) {
@@ -17858,18 +17880,27 @@ var screenshot = (options) => {
17858
17880
  }));
17859
17881
  };
17860
17882
 
17861
- // src/screenshot-dom-element.ts
17862
- var screenshotDOMElement = async ({
17863
- page,
17883
+ // src/take-frame.ts
17884
+ var takeFrame = async ({
17885
+ freePage,
17864
17886
  imageFormat,
17865
17887
  jpegQuality,
17866
- opts,
17867
- height,
17888
+ frame,
17868
17889
  width,
17869
- timeoutInMilliseconds,
17870
- scale
17890
+ height,
17891
+ output,
17892
+ scale,
17893
+ wantsBuffer,
17894
+ timeoutInMilliseconds
17871
17895
  }) => {
17872
- const { path: path19 } = opts;
17896
+ const collectedAssets = await collectAssets({
17897
+ frame,
17898
+ freePage,
17899
+ timeoutInMilliseconds
17900
+ });
17901
+ if (imageFormat === "none") {
17902
+ return { buffer: null, collectedAssets };
17903
+ }
17873
17904
  if (imageFormat === "png" || imageFormat === "pdf" || imageFormat === "webp") {
17874
17905
  await puppeteerEvaluateWithCatch({
17875
17906
  pageFunction: () => {
@@ -17877,7 +17908,7 @@ var screenshotDOMElement = async ({
17877
17908
  },
17878
17909
  args: [],
17879
17910
  frame: null,
17880
- page,
17911
+ page: freePage,
17881
17912
  timeoutInMilliseconds
17882
17913
  });
17883
17914
  } else {
@@ -17887,93 +17918,21 @@ var screenshotDOMElement = async ({
17887
17918
  },
17888
17919
  args: [],
17889
17920
  frame: null,
17890
- page,
17921
+ page: freePage,
17891
17922
  timeoutInMilliseconds
17892
17923
  });
17893
17924
  }
17894
- if (imageFormat === "none") {
17895
- throw new TypeError('Tried to make a screenshot with format "none"');
17896
- }
17897
17925
  const buf = await screenshot({
17898
- page,
17926
+ page: freePage,
17899
17927
  omitBackground: imageFormat === "png",
17900
- path: path19 ?? undefined,
17928
+ path: (wantsBuffer ? undefined : output) ?? undefined,
17901
17929
  type: imageFormat,
17902
17930
  jpegQuality,
17903
17931
  width,
17904
17932
  height,
17905
17933
  scale
17906
17934
  });
17907
- if (typeof buf === "string") {
17908
- throw new TypeError("Expected a buffer");
17909
- }
17910
- return buf;
17911
- };
17912
-
17913
- // src/provide-screenshot.ts
17914
- var provideScreenshot = ({
17915
- page,
17916
- imageFormat,
17917
- options,
17918
- jpegQuality,
17919
- height,
17920
- width,
17921
- timeoutInMilliseconds,
17922
- scale
17923
- }) => {
17924
- return screenshotDOMElement({
17925
- page,
17926
- opts: {
17927
- path: options.output
17928
- },
17929
- imageFormat,
17930
- jpegQuality,
17931
- height,
17932
- width,
17933
- timeoutInMilliseconds,
17934
- scale
17935
- });
17936
- };
17937
-
17938
- // src/take-frame.ts
17939
- var takeFrame = async ({
17940
- freePage,
17941
- imageFormat,
17942
- jpegQuality,
17943
- frame,
17944
- width,
17945
- height,
17946
- output,
17947
- scale,
17948
- wantsBuffer,
17949
- timeoutInMilliseconds
17950
- }) => {
17951
- const collectedAssets = await collectAssets({
17952
- frame,
17953
- freePage,
17954
- timeoutInMilliseconds
17955
- });
17956
- if (imageFormat === "none") {
17957
- return { buffer: null, collectedAssets };
17958
- }
17959
- const shouldMakeBuffer = wantsBuffer;
17960
- const buf = await provideScreenshot({
17961
- page: freePage,
17962
- imageFormat,
17963
- jpegQuality,
17964
- options: {
17965
- frame,
17966
- output: wantsBuffer ? null : output
17967
- },
17968
- height,
17969
- width,
17970
- timeoutInMilliseconds,
17971
- scale
17972
- });
17973
- if (shouldMakeBuffer) {
17974
- return { buffer: buf, collectedAssets };
17975
- }
17976
- return { buffer: null, collectedAssets };
17935
+ return { buffer: buf, collectedAssets };
17977
17936
  };
17978
17937
 
17979
17938
  // src/render-frame-with-option-to-reject.ts
@@ -18043,7 +18002,6 @@ var renderFrameWithOptionToReject = async ({
18043
18002
  if (outputDir && onFrameBuffer && imageFormat !== "none") {
18044
18003
  throw new Error("Pass either `outputDir` or `onFrameBuffer` to renderFrames(), not both.");
18045
18004
  }
18046
- const id = startPerfMeasure("save");
18047
18005
  const { buffer, collectedAssets } = await takeFrame({
18048
18006
  frame,
18049
18007
  freePage: page,
@@ -18069,12 +18027,14 @@ var renderFrameWithOptionToReject = async ({
18069
18027
  }
18070
18028
  onFrameBuffer(buffer, frame);
18071
18029
  }
18072
- stopPerfMeasure(id);
18073
18030
  const onlyAvailableAssets = assets.filter(truthy);
18074
18031
  const previousAudioRenderAssets = onlyAvailableAssets.map((a) => a.audioAndVideoAssets).flat(2);
18075
18032
  const previousArtifactAssets = onlyAvailableAssets.map((a) => a.artifactAssets).flat(2);
18076
18033
  const audioAndVideoAssets = onlyAudioAndVideoAssets(collectedAssets);
18077
- const artifactAssets = onlyArtifact(collectedAssets);
18034
+ const artifactAssets = onlyArtifact({
18035
+ assets: collectedAssets,
18036
+ frameBuffer: buffer
18037
+ });
18078
18038
  for (const artifact of artifactAssets) {
18079
18039
  for (const previousArtifact of previousArtifactAssets) {
18080
18040
  if (artifact.filename === previousArtifact.filename) {
@@ -18477,8 +18437,8 @@ var innerRenderFrames = async ({
18477
18437
  binariesDirectory
18478
18438
  }) => {
18479
18439
  if (outputDir) {
18480
- if (!fs14.existsSync(outputDir)) {
18481
- fs14.mkdirSync(outputDir, {
18440
+ if (!fs13.existsSync(outputDir)) {
18441
+ fs13.mkdirSync(outputDir, {
18482
18442
  recursive: true
18483
18443
  });
18484
18444
  }
@@ -18886,7 +18846,7 @@ var renderFrames = (options) => {
18886
18846
  };
18887
18847
 
18888
18848
  // src/render-media.ts
18889
- import fs16 from "node:fs";
18849
+ import fs15 from "node:fs";
18890
18850
  import os6 from "node:os";
18891
18851
  import path25 from "node:path";
18892
18852
  import { NoReactInternals as NoReactInternals14 } from "remotion/no-react";
@@ -19774,7 +19734,7 @@ var createFfmpegMergeFilter = ({
19774
19734
  };
19775
19735
 
19776
19736
  // src/ffmpeg-filter-file.ts
19777
- import fs15, { existsSync as existsSync5 } from "node:fs";
19737
+ import fs14, { existsSync as existsSync5 } from "node:fs";
19778
19738
  import path21 from "node:path";
19779
19739
  var makeFfmpegFilterFile = (complexFilter, downloadMap) => {
19780
19740
  return makeFfmpegFilterFileStr(complexFilter.filter, downloadMap);
@@ -19783,13 +19743,13 @@ var makeFfmpegFilterFileStr = async (complexFilter, downloadMap) => {
19783
19743
  const random2 = Math.random().toString().replace(".", "");
19784
19744
  const filterFile = path21.join(downloadMap.complexFilter, "complex-filter-" + random2 + ".txt");
19785
19745
  if (!existsSync5(downloadMap.complexFilter)) {
19786
- fs15.mkdirSync(downloadMap.complexFilter, { recursive: true });
19746
+ fs14.mkdirSync(downloadMap.complexFilter, { recursive: true });
19787
19747
  }
19788
- await fs15.promises.writeFile(filterFile, complexFilter);
19748
+ await fs14.promises.writeFile(filterFile, complexFilter);
19789
19749
  return {
19790
19750
  file: filterFile,
19791
19751
  cleanup: () => {
19792
- fs15.unlinkSync(filterFile);
19752
+ fs14.unlinkSync(filterFile);
19793
19753
  }
19794
19754
  };
19795
19755
  };
@@ -20401,9 +20361,9 @@ var createAudio = async ({
20401
20361
  };
20402
20362
 
20403
20363
  // src/make-metadata-args.ts
20404
- import { VERSION as VERSION4 } from "remotion/version";
20364
+ import { VERSION as VERSION5 } from "remotion/version";
20405
20365
  var makeMetadataArgs = (metadata) => {
20406
- const defaultComment = `Made with Remotion ${VERSION4}`;
20366
+ const defaultComment = `Made with Remotion ${VERSION5}`;
20407
20367
  const newMetadata = {
20408
20368
  comment: defaultComment
20409
20369
  };
@@ -21080,7 +21040,7 @@ var internalRenderMediaRaw = ({
21080
21040
  }
21081
21041
  const imageFormat = isAudioCodec(codec) ? "none" : provisionalImageFormat;
21082
21042
  validateSelectedPixelFormatAndImageFormatCombination(pixelFormat, imageFormat);
21083
- const workingDir = fs16.mkdtempSync(path25.join(os6.tmpdir(), "react-motion-render"));
21043
+ const workingDir = fs15.mkdtempSync(path25.join(os6.tmpdir(), "react-motion-render"));
21084
21044
  const preEncodedFileLocation = parallelEncoding ? path25.join(workingDir, "pre-encode." + getFileExtensionFromCodec(codec, audioCodec)) : null;
21085
21045
  if (onCtrlCExit && workingDir) {
21086
21046
  onCtrlCExit(`Delete ${workingDir}`, () => deleteDirectory(workingDir));
@@ -21365,10 +21325,10 @@ var internalRenderMediaRaw = ({
21365
21325
  }
21366
21326
  reject(err);
21367
21327
  }).finally(() => {
21368
- if (preEncodedFileLocation !== null && fs16.existsSync(preEncodedFileLocation)) {
21328
+ if (preEncodedFileLocation !== null && fs15.existsSync(preEncodedFileLocation)) {
21369
21329
  deleteDirectory(path25.dirname(preEncodedFileLocation));
21370
21330
  }
21371
- if (workingDir && fs16.existsSync(workingDir)) {
21331
+ if (workingDir && fs15.existsSync(workingDir)) {
21372
21332
  deleteDirectory(workingDir);
21373
21333
  }
21374
21334
  cleanupServerFn?.(false).catch((err) => {
@@ -21526,7 +21486,7 @@ var renderMedia = ({
21526
21486
  };
21527
21487
 
21528
21488
  // src/render-still.ts
21529
- import fs17, { statSync as statSync2 } from "node:fs";
21489
+ import fs16, { statSync as statSync2 } from "node:fs";
21530
21490
  import path26 from "node:path";
21531
21491
  import { NoReactInternals as NoReactInternals15 } from "remotion/no-react";
21532
21492
  var innerRenderStill = async ({
@@ -21578,7 +21538,7 @@ var innerRenderStill = async ({
21578
21538
  output = typeof output === "string" ? path26.resolve(process.cwd(), output) : null;
21579
21539
  validateJpegQuality(jpegQuality);
21580
21540
  if (output) {
21581
- if (fs17.existsSync(output)) {
21541
+ if (fs16.existsSync(output)) {
21582
21542
  if (!overwrite) {
21583
21543
  throw new Error(`Cannot render still - "overwrite" option was set to false, but the output destination ${output} already exists.`);
21584
21544
  }
@@ -21700,7 +21660,10 @@ var innerRenderStill = async ({
21700
21660
  wantsBuffer: !output,
21701
21661
  timeoutInMilliseconds
21702
21662
  });
21703
- const artifactAssets = onlyArtifact(collectedAssets);
21663
+ const artifactAssets = onlyArtifact({
21664
+ assets: collectedAssets,
21665
+ frameBuffer: buffer
21666
+ });
21704
21667
  const previousArtifactAssets = [];
21705
21668
  for (const artifact of artifactAssets) {
21706
21669
  for (const previousArtifact of previousArtifactAssets) {
@@ -22177,7 +22140,7 @@ var canConcatVideoSeamlessly = (codec) => {
22177
22140
  // src/combine-video-streams.ts
22178
22141
  import { rmSync as rmSync4, writeFileSync as writeFileSync2 } from "fs";
22179
22142
  import { join as join4 } from "path";
22180
- import { VERSION as VERSION5 } from "remotion/version";
22143
+ import { VERSION as VERSION6 } from "remotion/version";
22181
22144
  var combineVideoStreams = async ({
22182
22145
  fps,
22183
22146
  codec,
@@ -22217,7 +22180,7 @@ var combineVideoStreams = async ({
22217
22180
  codec === "h265" ? "-tag:v" : null,
22218
22181
  codec === "h265" ? "hvc1" : null,
22219
22182
  addRemotionMetadata ? `-metadata` : null,
22220
- addRemotionMetadata ? `comment=Made with Remotion ${VERSION5}` : null,
22183
+ addRemotionMetadata ? `comment=Made with Remotion ${VERSION6}` : null,
22221
22184
  "-y",
22222
22185
  output
22223
22186
  ].filter(truthy);
@@ -1,3 +1,7 @@
1
- import type { ArtifactAsset, AudioOrVideoAsset, TRenderAsset } from 'remotion/no-react';
1
+ import type { AudioOrVideoAsset, TRenderAsset } from 'remotion/no-react';
2
+ import type { EmittedArtifact } from './serialize-artifact';
2
3
  export declare const onlyAudioAndVideoAssets: (assets: TRenderAsset[]) => AudioOrVideoAsset[];
3
- export declare const onlyArtifact: (assets: TRenderAsset[]) => ArtifactAsset[];
4
+ export declare const onlyArtifact: ({ assets, frameBuffer, }: {
5
+ assets: TRenderAsset[];
6
+ frameBuffer: Buffer | null;
7
+ }) => EmittedArtifact[];
@@ -1,11 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.onlyArtifact = exports.onlyAudioAndVideoAssets = void 0;
4
+ const truthy_1 = require("./truthy");
4
5
  const onlyAudioAndVideoAssets = (assets) => {
5
6
  return assets.filter((asset) => asset.type === 'audio' || asset.type === 'video');
6
7
  };
7
8
  exports.onlyAudioAndVideoAssets = onlyAudioAndVideoAssets;
8
- const onlyArtifact = (assets) => {
9
- return assets.filter((asset) => asset.type === 'artifact');
9
+ const onlyArtifact = ({ assets, frameBuffer, }) => {
10
+ const artifacts = assets.filter((asset) => asset.type === 'artifact');
11
+ return artifacts
12
+ .map((artifact) => {
13
+ if (artifact.contentType === 'binary' ||
14
+ artifact.contentType === 'text') {
15
+ return {
16
+ frame: artifact.frame,
17
+ content: artifact.content,
18
+ filename: artifact.filename,
19
+ };
20
+ }
21
+ if (artifact.contentType === 'thumbnail') {
22
+ if (frameBuffer === null) {
23
+ // A thumbnail artifact was defined to be emitted, but the output was not a video.
24
+ // Also, in Lambda, there are extra frames which are not video frames.
25
+ // This could happen if a thumbnail is unconditionally emitted.
26
+ return null;
27
+ }
28
+ return {
29
+ frame: artifact.frame,
30
+ content: new Uint8Array(frameBuffer),
31
+ filename: artifact.filename,
32
+ };
33
+ }
34
+ throw new Error('Unknown artifact type: ' + artifact);
35
+ })
36
+ .filter(truthy_1.truthy);
10
37
  };
11
38
  exports.onlyArtifact = onlyArtifact;
package/dist/perf.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type PerfId = 'activate-target' | 'capture' | 'save' | 'extract-frame' | 'piping';
1
+ type PerfId = 'capture' | 'extract-frame' | 'piping';
2
2
  export declare const startPerfMeasure: (marker: PerfId) => number;
3
3
  export declare const stopPerfMeasure: (id: number) => void;
4
4
  export declare const getPerf: () => string[];
package/dist/perf.js CHANGED
@@ -2,9 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPerf = exports.stopPerfMeasure = exports.startPerfMeasure = void 0;
4
4
  const perf = {
5
- 'activate-target': [],
6
5
  capture: [],
7
- save: [],
8
6
  'extract-frame': [],
9
7
  piping: [],
10
8
  };
@@ -9,4 +9,4 @@ export declare const screenshot: (options: {
9
9
  width: number;
10
10
  height: number;
11
11
  scale: number;
12
- }) => Promise<Buffer | string>;
12
+ }) => Promise<Buffer>;
@@ -11,7 +11,6 @@ const handle_javascript_exception_1 = require("./error-handling/handle-javascrip
11
11
  const filter_asset_types_1 = require("./filter-asset-types");
12
12
  const get_frame_padded_index_1 = require("./get-frame-padded-index");
13
13
  const logger_1 = require("./logger");
14
- const perf_1 = require("./perf");
15
14
  const seek_to_frame_1 = require("./seek-to-frame");
16
15
  const take_frame_1 = require("./take-frame");
17
16
  const truthy_1 = require("./truthy");
@@ -51,7 +50,6 @@ const renderFrameWithOptionToReject = async ({ reject, width, height, compId, at
51
50
  if (outputDir && onFrameBuffer && imageFormat !== 'none') {
52
51
  throw new Error('Pass either `outputDir` or `onFrameBuffer` to renderFrames(), not both.');
53
52
  }
54
- const id = (0, perf_1.startPerfMeasure)('save');
55
53
  const { buffer, collectedAssets } = await (0, take_frame_1.takeFrame)({
56
54
  frame,
57
55
  freePage: page,
@@ -79,7 +77,6 @@ const renderFrameWithOptionToReject = async ({ reject, width, height, compId, at
79
77
  }
80
78
  onFrameBuffer(buffer, frame);
81
79
  }
82
- (0, perf_1.stopPerfMeasure)(id);
83
80
  const onlyAvailableAssets = assets.filter(truthy_1.truthy);
84
81
  const previousAudioRenderAssets = onlyAvailableAssets
85
82
  .map((a) => a.audioAndVideoAssets)
@@ -88,7 +85,10 @@ const renderFrameWithOptionToReject = async ({ reject, width, height, compId, at
88
85
  .map((a) => a.artifactAssets)
89
86
  .flat(2);
90
87
  const audioAndVideoAssets = (0, filter_asset_types_1.onlyAudioAndVideoAssets)(collectedAssets);
91
- const artifactAssets = (0, filter_asset_types_1.onlyArtifact)(collectedAssets);
88
+ const artifactAssets = (0, filter_asset_types_1.onlyArtifact)({
89
+ assets: collectedAssets,
90
+ frameBuffer: buffer,
91
+ });
92
92
  for (const artifact of artifactAssets) {
93
93
  for (const previousArtifact of previousArtifactAssets) {
94
94
  if (artifact.filename === previousArtifact.filename) {
@@ -209,7 +209,10 @@ const innerRenderStill = async ({ composition, imageFormat = image_format_1.DEFA
209
209
  wantsBuffer: !output,
210
210
  timeoutInMilliseconds,
211
211
  });
212
- const artifactAssets = (0, filter_asset_types_1.onlyArtifact)(collectedAssets);
212
+ const artifactAssets = (0, filter_asset_types_1.onlyArtifact)({
213
+ assets: collectedAssets,
214
+ frameBuffer: buffer,
215
+ });
213
216
  const previousArtifactAssets = [];
214
217
  for (const artifact of artifactAssets) {
215
218
  for (const previousArtifact of previousArtifactAssets) {
@@ -9,4 +9,4 @@ export declare const screenshotTask: ({ format, height, omitBackground, page, wi
9
9
  width: number;
10
10
  height: number;
11
11
  scale: number;
12
- }) => Promise<Buffer | string>;
12
+ }) => Promise<Buffer>;
@@ -10,16 +10,14 @@ const screenshotTask = async ({ format, height, omitBackground, page, width, pat
10
10
  var _a;
11
11
  const client = page._client();
12
12
  const target = page.target();
13
- const perfTarget = (0, perf_1.startPerfMeasure)('activate-target');
14
13
  await client.send('Target.activateTarget', {
15
14
  targetId: target._targetId,
16
15
  });
17
- (0, perf_1.stopPerfMeasure)(perfTarget);
18
- const shouldSetDefaultBackground = omitBackground;
19
- if (shouldSetDefaultBackground)
16
+ if (omitBackground) {
20
17
  await client.send('Emulation.setDefaultBackgroundColorOverride', {
21
18
  color: { r: 0, g: 0, b: 0, a: 0 },
22
19
  });
20
+ }
23
21
  const cap = (0, perf_1.startPerfMeasure)('capture');
24
22
  try {
25
23
  let result;
@@ -63,13 +61,13 @@ const screenshotTask = async ({ format, height, omitBackground, page, width, pat
63
61
  result = value;
64
62
  }
65
63
  (0, perf_1.stopPerfMeasure)(cap);
66
- if (shouldSetDefaultBackground)
64
+ if (omitBackground) {
67
65
  await client.send('Emulation.setDefaultBackgroundColorOverride');
68
- const saveMarker = (0, perf_1.startPerfMeasure)('save');
66
+ }
69
67
  const buffer = Buffer.from(result.data, 'base64');
70
- if (path)
68
+ if (path) {
71
69
  await node_fs_1.default.promises.writeFile(path, buffer);
72
- (0, perf_1.stopPerfMeasure)(saveMarker);
70
+ }
73
71
  return buffer;
74
72
  }
75
73
  catch (err) {
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.takeFrame = void 0;
4
4
  const collect_assets_1 = require("./collect-assets");
5
- const provide_screenshot_1 = require("./provide-screenshot");
5
+ const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
6
+ const puppeteer_screenshot_1 = require("./puppeteer-screenshot");
6
7
  const takeFrame = async ({ freePage, imageFormat, jpegQuality, frame, width, height, output, scale, wantsBuffer, timeoutInMilliseconds, }) => {
8
+ var _a;
7
9
  const collectedAssets = await (0, collect_assets_1.collectAssets)({
8
10
  frame,
9
11
  freePage,
@@ -12,23 +14,40 @@ const takeFrame = async ({ freePage, imageFormat, jpegQuality, frame, width, hei
12
14
  if (imageFormat === 'none') {
13
15
  return { buffer: null, collectedAssets };
14
16
  }
15
- const shouldMakeBuffer = wantsBuffer;
16
- const buf = await (0, provide_screenshot_1.provideScreenshot)({
17
+ if (imageFormat === 'png' ||
18
+ imageFormat === 'pdf' ||
19
+ imageFormat === 'webp') {
20
+ await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
21
+ pageFunction: () => {
22
+ document.body.style.background = 'transparent';
23
+ },
24
+ args: [],
25
+ frame: null,
26
+ page: freePage,
27
+ timeoutInMilliseconds,
28
+ });
29
+ }
30
+ else {
31
+ await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
32
+ pageFunction: () => {
33
+ document.body.style.background = 'black';
34
+ },
35
+ args: [],
36
+ frame: null,
37
+ page: freePage,
38
+ timeoutInMilliseconds,
39
+ });
40
+ }
41
+ const buf = await (0, puppeteer_screenshot_1.screenshot)({
17
42
  page: freePage,
18
- imageFormat,
43
+ omitBackground: imageFormat === 'png',
44
+ path: (_a = (wantsBuffer ? undefined : output)) !== null && _a !== void 0 ? _a : undefined,
45
+ type: imageFormat,
19
46
  jpegQuality,
20
- options: {
21
- frame,
22
- output: wantsBuffer ? null : output,
23
- },
24
- height,
25
47
  width,
26
- timeoutInMilliseconds,
48
+ height,
27
49
  scale,
28
50
  });
29
- if (shouldMakeBuffer) {
30
- return { buffer: buf, collectedAssets };
31
- }
32
- return { buffer: null, collectedAssets };
51
+ return { buffer: buf, collectedAssets };
33
52
  };
34
53
  exports.takeFrame = takeFrame;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/renderer"
4
4
  },
5
5
  "name": "@remotion/renderer",
6
- "version": "4.0.288",
6
+ "version": "4.0.290",
7
7
  "description": "Render Remotion videos using Node.js or Bun",
8
8
  "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
@@ -18,8 +18,8 @@
18
18
  "extract-zip": "2.0.1",
19
19
  "source-map": "^0.8.0-beta.0",
20
20
  "ws": "8.17.1",
21
- "remotion": "4.0.288",
22
- "@remotion/streaming": "4.0.288"
21
+ "remotion": "4.0.290",
22
+ "@remotion/streaming": "4.0.290"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": ">=16.8.0",
@@ -33,17 +33,17 @@
33
33
  "react-dom": "19.0.0",
34
34
  "@types/ws": "8.5.10",
35
35
  "eslint": "9.19.0",
36
- "@remotion/example-videos": "4.0.288",
37
- "@remotion/eslint-config-internal": "4.0.288"
36
+ "@remotion/example-videos": "4.0.290",
37
+ "@remotion/eslint-config-internal": "4.0.290"
38
38
  },
39
39
  "optionalDependencies": {
40
- "@remotion/compositor-darwin-arm64": "4.0.288",
41
- "@remotion/compositor-linux-arm64-gnu": "4.0.288",
42
- "@remotion/compositor-linux-arm64-musl": "4.0.288",
43
- "@remotion/compositor-linux-x64-gnu": "4.0.288",
44
- "@remotion/compositor-linux-x64-musl": "4.0.288",
45
- "@remotion/compositor-win32-x64-msvc": "4.0.288",
46
- "@remotion/compositor-darwin-x64": "4.0.288"
40
+ "@remotion/compositor-darwin-x64": "4.0.290",
41
+ "@remotion/compositor-darwin-arm64": "4.0.290",
42
+ "@remotion/compositor-linux-arm64-gnu": "4.0.290",
43
+ "@remotion/compositor-linux-x64-musl": "4.0.290",
44
+ "@remotion/compositor-linux-arm64-musl": "4.0.290",
45
+ "@remotion/compositor-linux-x64-gnu": "4.0.290",
46
+ "@remotion/compositor-win32-x64-msvc": "4.0.290"
47
47
  },
48
48
  "keywords": [
49
49
  "remotion",
@@ -1,8 +0,0 @@
1
- const out = await Bun.build({
2
- entrypoints: ['src/ensure-browser.ts'],
3
- target: 'node',
4
- });
5
-
6
- Bun.write('ensure-browser.mjs', await out.outputs[0].arrayBuffer());
7
-
8
- export {};
package/bundle.ts DELETED
@@ -1,27 +0,0 @@
1
- import {buildPackage} from '../.monorepo/builder';
2
-
3
- await buildPackage({
4
- formats: {
5
- cjs: 'use-tsc',
6
- esm: 'build',
7
- },
8
- external: 'dependencies',
9
- entrypoints: [
10
- {
11
- path: 'src/index.ts',
12
- target: 'node',
13
- },
14
- {
15
- path: 'src/client.ts',
16
- target: 'node',
17
- },
18
- {
19
- path: 'src/pure.ts',
20
- target: 'browser',
21
- },
22
- {
23
- path: 'src/error-handling.ts',
24
- target: 'node',
25
- },
26
- ],
27
- });
package/eslint.config.mjs DELETED
@@ -1,25 +0,0 @@
1
- import {remotionFlatConfig} from '@remotion/eslint-config-internal';
2
-
3
- const config = remotionFlatConfig({react: false});
4
-
5
- export default [
6
- {
7
- ...config,
8
- rules: {
9
- ...config.rules,
10
- '@typescript-eslint/no-use-before-define': 'off',
11
- 'no-restricted-imports': [
12
- 'error',
13
- {
14
- patterns: ['@remotion/*/src/*', 'remotion/src/*'],
15
- paths: ['remotion', 'react', 'react-dom'],
16
- },
17
- ],
18
- },
19
- ignores: ['src/browser/**'],
20
- },
21
- {
22
- ...config,
23
- files: ['src/test/**'],
24
- },
25
- ];
package/happydom.ts DELETED
@@ -1,6 +0,0 @@
1
- import {GlobalRegistrator} from '@happy-dom/global-registrator';
2
-
3
- GlobalRegistrator.register();
4
- window.origin = 'http://localhost:3000';
5
- // @ts-expect-error
6
- window.remotion_staticBase = '/static-abcdef';