@remotion/renderer 4.0.0-alpha4 → 4.0.0-alpha5

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.
Files changed (121) hide show
  1. package/README.md +5 -43
  2. package/dist/assets/download-map.d.ts +0 -26
  3. package/dist/assets/download-map.js +0 -5
  4. package/dist/assets/get-audio-channels.d.ts +1 -2
  5. package/dist/assets/get-audio-channels.js +5 -9
  6. package/dist/audio-codec.d.ts +4 -3
  7. package/dist/audio-codec.js +3 -9
  8. package/dist/browser/BrowserFetcher.d.ts +0 -1
  9. package/dist/browser/BrowserFetcher.js +1 -2
  10. package/dist/browser/BrowserRunner.js +8 -2
  11. package/dist/browser/FrameManager.js +2 -3
  12. package/dist/browser/LaunchOptions.d.ts +1 -0
  13. package/dist/browser/Launcher.js +2 -1
  14. package/dist/browser/devtools-commands.d.ts +5 -1
  15. package/dist/browser/devtools-types.d.ts +78 -0
  16. package/dist/browser/is-target-closed-err.d.ts +1 -0
  17. package/dist/browser/is-target-closed-err.js +9 -0
  18. package/dist/call-ffmpeg.d.ts +14 -0
  19. package/dist/call-ffmpeg.js +37 -0
  20. package/dist/check-apple-silicon.js +2 -45
  21. package/dist/client.d.ts +67 -42
  22. package/dist/client.js +27 -1
  23. package/dist/codec-supports-media.d.ts +2 -1
  24. package/dist/codec-supports-media.js +20 -5
  25. package/dist/combine-videos.d.ts +0 -3
  26. package/dist/combine-videos.js +5 -9
  27. package/dist/compositor/compose.d.ts +3 -1
  28. package/dist/compositor/compose.js +34 -14
  29. package/dist/compositor/compositor.d.ts +12 -0
  30. package/dist/compositor/compositor.js +202 -0
  31. package/dist/compositor/get-executable-path.d.ts +1 -1
  32. package/dist/compositor/get-executable-path.js +27 -8
  33. package/dist/compositor/make-nonce.d.ts +1 -0
  34. package/dist/compositor/make-nonce.js +8 -0
  35. package/dist/compositor/payloads.d.ts +34 -7
  36. package/dist/create-ffmpeg-complex-filter.d.ts +5 -5
  37. package/dist/create-ffmpeg-complex-filter.js +2 -4
  38. package/dist/create-ffmpeg-merge-filter.d.ts +2 -5
  39. package/dist/create-ffmpeg-merge-filter.js +2 -10
  40. package/dist/create-silent-audio.d.ts +1 -4
  41. package/dist/create-silent-audio.js +3 -7
  42. package/dist/crf.js +8 -2
  43. package/dist/delete-directory.js +16 -16
  44. package/dist/file-extensions.d.ts +1 -12
  45. package/dist/file-extensions.js +1 -13
  46. package/dist/get-compositions.d.ts +3 -5
  47. package/dist/get-compositions.js +8 -11
  48. package/dist/get-extension-from-codec.d.ts +2 -2
  49. package/dist/get-frame-padded-index.d.ts +2 -1
  50. package/dist/guess-extension-for-media.d.ts +1 -3
  51. package/dist/guess-extension-for-media.js +4 -8
  52. package/dist/image-format.d.ts +12 -6
  53. package/dist/image-format.js +16 -13
  54. package/dist/index.d.ts +66 -59
  55. package/dist/index.js +15 -17
  56. package/dist/jpeg-quality.d.ts +1 -0
  57. package/dist/jpeg-quality.js +21 -0
  58. package/dist/merge-audio-track.d.ts +0 -2
  59. package/dist/merge-audio-track.js +3 -10
  60. package/dist/offthread-video-server.d.ts +8 -8
  61. package/dist/offthread-video-server.js +63 -56
  62. package/dist/open-browser.d.ts +1 -0
  63. package/dist/open-browser.js +7 -6
  64. package/dist/options/audio-bitrate.d.ts +2 -0
  65. package/dist/options/audio-bitrate.js +11 -0
  66. package/dist/options/crf.d.ts +2 -0
  67. package/dist/options/crf.js +11 -0
  68. package/dist/options/enforce-audio.d.ts +2 -0
  69. package/dist/options/enforce-audio.js +11 -0
  70. package/dist/options/jpeg-quality.d.ts +2 -0
  71. package/dist/options/jpeg-quality.js +11 -0
  72. package/dist/options/mute.d.ts +2 -0
  73. package/dist/options/mute.js +11 -0
  74. package/dist/options/option.d.ts +8 -0
  75. package/dist/options/option.js +2 -0
  76. package/dist/options/scale.d.ts +2 -0
  77. package/dist/options/scale.js +11 -0
  78. package/dist/options/video-bitrate.d.ts +2 -0
  79. package/dist/options/video-bitrate.js +11 -0
  80. package/dist/options/video-codec.d.ts +2 -0
  81. package/dist/options/video-codec.js +11 -0
  82. package/dist/perf.d.ts +1 -1
  83. package/dist/perf.js +9 -7
  84. package/dist/prepare-server.d.ts +3 -4
  85. package/dist/prepare-server.js +5 -5
  86. package/dist/preprocess-audio-track.d.ts +0 -4
  87. package/dist/preprocess-audio-track.js +4 -8
  88. package/dist/prespawn-ffmpeg.d.ts +6 -9
  89. package/dist/prespawn-ffmpeg.js +7 -12
  90. package/dist/prestitcher-memory-usage.d.ts +0 -4
  91. package/dist/prestitcher-memory-usage.js +2 -3
  92. package/dist/prores-profile.d.ts +1 -2
  93. package/dist/prores-profile.js +4 -4
  94. package/dist/provide-screenshot.d.ts +4 -5
  95. package/dist/provide-screenshot.js +2 -2
  96. package/dist/puppeteer-screenshot.d.ts +3 -3
  97. package/dist/puppeteer-screenshot.js +9 -32
  98. package/dist/render-frames.d.ts +13 -25
  99. package/dist/render-frames.js +29 -40
  100. package/dist/render-media.d.ts +16 -18
  101. package/dist/render-media.js +33 -43
  102. package/dist/render-still.d.ts +10 -8
  103. package/dist/render-still.js +14 -13
  104. package/dist/screenshot-dom-element.d.ts +4 -5
  105. package/dist/screenshot-dom-element.js +6 -3
  106. package/dist/screenshot-task.d.ts +2 -3
  107. package/dist/screenshot-task.js +38 -23
  108. package/dist/serve-handler/index.js +6 -4
  109. package/dist/serve-static.d.ts +2 -3
  110. package/dist/serve-static.js +24 -20
  111. package/dist/stitch-frames-to-video.d.ts +2 -12
  112. package/dist/stitch-frames-to-video.js +24 -33
  113. package/dist/take-frame-and-compose.d.ts +4 -5
  114. package/dist/take-frame-and-compose.js +12 -6
  115. package/dist/tmp-dir.js +1 -2
  116. package/dist/validate-concurrency.d.ts +2 -0
  117. package/dist/validate-concurrency.js +11 -5
  118. package/dist/validate-output-filename.d.ts +1 -1
  119. package/dist/validate-puppeteer-timeout.js +1 -0
  120. package/install-toolchain.mjs +36 -0
  121. package/package.json +11 -10
package/README.md CHANGED
@@ -1,47 +1,9 @@
1
- # Rust development
1
+ # Renderer
2
2
 
3
- To participate in the development of the Rust parts of Remotion, you need to do additional steps. If you don't want to change the Rust code, you don't have to set anything up.
3
+ Contains TypeScript + Rust code for rendering a Remotion video.
4
4
 
5
- ## Setup
5
+ See the public APIs here: https://remotion.dev/docs/renderer
6
6
 
7
- These are instructions for macOS. Contributions for other platforms are appreciated.
7
+ ## Development
8
8
 
9
- First, install Cargo, if you don't have it, or upgrade to a version that supports `edition-2021`:
10
-
11
- ```
12
- curl https://sh.rustup.rs -sSf | sh
13
- ```
14
-
15
- Second, install components that allow for cross-compilation:
16
-
17
- ```sh
18
- sh install_platforms.sh
19
- ```
20
-
21
- Third, install linkers for cross compilation:
22
-
23
- ```sh
24
- brew install MaterializeInc/crosstools/x86_64-unknown-linux-gnu
25
- brew install MaterializeInc/crosstools/aarch64-unknown-linux-gnu
26
- brew install messense/macos-cross-toolchains/x86_64-unknown-linux-musl
27
- brew install messense/macos-cross-toolchains/aarch64-unknown-linux-musl
28
- brew install mingw-w64
29
- ```
30
-
31
- > This will take a few minutes.
32
-
33
- ## Building
34
-
35
- To build the Rust parts for your operating system, run:
36
-
37
- ```
38
- node build.mjs
39
- ```
40
-
41
- To build the Rust binaries for all supported platforms, run:
42
-
43
- ```
44
- node build.mjs --all
45
- ```
46
-
47
- The resulting artifacts should be checked into Git.
9
+ For developing the Rust parts, see https://remotion.dev/docs/contributing/rust.
@@ -1,21 +1,4 @@
1
- /// <reference types="node" />
2
1
  import type { TAsset } from 'remotion';
3
- declare type EncodingStatus = {
4
- type: 'encoding';
5
- } | {
6
- type: 'done';
7
- src: string;
8
- } | undefined;
9
- export declare type SpecialVCodecForTransparency = 'vp9' | 'vp8' | 'none';
10
- export declare type NeedsResize = [number, number] | null;
11
- export declare type Vp9Result = {
12
- specialVcodecForTransparency: SpecialVCodecForTransparency;
13
- needsResize: NeedsResize;
14
- };
15
- export declare type VideoDurationResult = {
16
- duration: number | null;
17
- fps: number | null;
18
- };
19
2
  export declare type AudioChannelsAndDurationResultCache = {
20
3
  channels: number;
21
4
  duration: number | null;
@@ -37,14 +20,6 @@ export declare type DownloadMap = {
37
20
  [downloadDir: string]: (() => void)[];
38
21
  };
39
22
  };
40
- lastFrameMap: Record<string, {
41
- lastAccessed: number;
42
- data: Buffer;
43
- }>;
44
- isBeyondLastFrameMap: Record<string, number>;
45
- isVp9VideoCache: Record<string, Vp9Result>;
46
- ensureFileHasPresentationTimestamp: Record<string, EncodingStatus>;
47
- videoDurationResultCache: Record<string, VideoDurationResult>;
48
23
  durationOfAssetCache: Record<string, AudioChannelsAndDurationResultCache>;
49
24
  downloadDir: string;
50
25
  preEncode: string;
@@ -66,4 +41,3 @@ export declare type RenderAssetInfo = {
66
41
  };
67
42
  export declare const makeDownloadMap: () => DownloadMap;
68
43
  export declare const cleanDownloadMap: (downloadMap: DownloadMap) => void;
69
- export {};
@@ -48,11 +48,6 @@ const makeDownloadMap = () => {
48
48
  isDownloadingMap: {},
49
49
  hasBeenDownloadedMap: {},
50
50
  listeners: {},
51
- lastFrameMap: {},
52
- isBeyondLastFrameMap: {},
53
- ensureFileHasPresentationTimestamp: {},
54
- isVp9VideoCache: {},
55
- videoDurationResultCache: {},
56
51
  durationOfAssetCache: {},
57
52
  id: String(Math.random()),
58
53
  assetDir: dir,
@@ -1,3 +1,2 @@
1
- import type { FfmpegExecutable } from '../ffmpeg-executable';
2
1
  import type { AudioChannelsAndDurationResultCache, DownloadMap } from './download-map';
3
- export declare const getAudioChannelsAndDuration: (downloadMap: DownloadMap, src: string, ffprobeExecutable: FfmpegExecutable, remotionRoot: string) => Promise<AudioChannelsAndDurationResultCache>;
2
+ export declare const getAudioChannelsAndDuration: (downloadMap: DownloadMap, src: string) => Promise<AudioChannelsAndDurationResultCache>;
@@ -1,14 +1,10 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getAudioChannelsAndDuration = void 0;
7
- const execa_1 = __importDefault(require("execa"));
8
- const ffmpeg_flags_1 = require("../ffmpeg-flags");
4
+ const call_ffmpeg_1 = require("../call-ffmpeg");
9
5
  const p_limit_1 = require("../p-limit");
10
6
  const limit = (0, p_limit_1.pLimit)(1);
11
- async function getAudioChannelsAndDurationUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot) {
7
+ async function getAudioChannelsAndDurationUnlimited(downloadMap, src) {
12
8
  if (downloadMap.durationOfAssetCache[src]) {
13
9
  return downloadMap.durationOfAssetCache[src];
14
10
  }
@@ -20,7 +16,7 @@ async function getAudioChannelsAndDurationUnlimited(downloadMap, src, ffprobeExe
20
16
  ]
21
17
  .reduce((acc, val) => acc.concat(val), [])
22
18
  .filter(Boolean);
23
- const task = await (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)(ffprobeExecutable, remotionRoot, 'ffprobe'), args);
19
+ const task = await (0, call_ffmpeg_1.callFf)('ffprobe', args);
24
20
  const channels = task.stdout.match(/channels=([0-9]+)/);
25
21
  const duration = task.stdout.match(/duration=([0-9.]+)/);
26
22
  const result = {
@@ -30,7 +26,7 @@ async function getAudioChannelsAndDurationUnlimited(downloadMap, src, ffprobeExe
30
26
  downloadMap.durationOfAssetCache[src] = result;
31
27
  return result;
32
28
  }
33
- const getAudioChannelsAndDuration = (downloadMap, src, ffprobeExecutable, remotionRoot) => {
34
- return limit(() => getAudioChannelsAndDurationUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot));
29
+ const getAudioChannelsAndDuration = (downloadMap, src) => {
30
+ return limit(() => getAudioChannelsAndDurationUnlimited(downloadMap, src));
35
31
  };
36
32
  exports.getAudioChannelsAndDuration = getAudioChannelsAndDuration;
@@ -5,7 +5,7 @@ export declare const supportedAudioCodecs: {
5
5
  readonly h264: readonly ["aac", "pcm-16"];
6
6
  readonly 'h264-mkv': readonly ["pcm-16"];
7
7
  readonly aac: readonly ["aac", "pcm-16"];
8
- readonly gif: readonly [];
8
+ readonly gif: const[];
9
9
  readonly h265: readonly ["aac", "pcm-16"];
10
10
  readonly mp3: readonly ["mp3", "pcm-16"];
11
11
  readonly prores: readonly ["aac", "pcm-16"];
@@ -13,8 +13,8 @@ export declare const supportedAudioCodecs: {
13
13
  readonly vp9: readonly ["opus", "pcm-16"];
14
14
  readonly wav: readonly ["pcm-16"];
15
15
  };
16
- export declare const audioCodecNames: readonly ["pcm_s16le", "aac", "libmp3lame", "libopus"];
17
- export declare type FfmpegAudioCodecName = typeof audioCodecNames[number];
16
+ declare const audioCodecNames: readonly ["pcm_s16le", "aac", "libmp3lame", "libopus"];
17
+ declare type FfmpegAudioCodecName = typeof audioCodecNames[number];
18
18
  export declare const mapAudioCodecToFfmpegAudioCodecName: (audioCodec: AudioCodec) => FfmpegAudioCodecName;
19
19
  export declare const defaultAudioCodecs: {
20
20
  [key in Codec]: {
@@ -25,3 +25,4 @@ export declare const getDefaultAudioCodec: ({ codec, preferLossless, }: {
25
25
  codec: Codec;
26
26
  preferLossless: boolean;
27
27
  }) => AudioCodec | null;
28
+ export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultAudioCodec = exports.defaultAudioCodecs = exports.mapAudioCodecToFfmpegAudioCodecName = exports.audioCodecNames = exports.supportedAudioCodecs = exports.validAudioCodecs = void 0;
3
+ exports.getDefaultAudioCodec = exports.defaultAudioCodecs = exports.mapAudioCodecToFfmpegAudioCodecName = exports.supportedAudioCodecs = exports.validAudioCodecs = void 0;
4
4
  exports.validAudioCodecs = ['pcm-16', 'aac', 'mp3', 'opus'];
5
5
  exports.supportedAudioCodecs = {
6
6
  h264: ['aac', 'pcm-16'],
@@ -18,12 +18,7 @@ const _satisfies = exports.supportedAudioCodecs;
18
18
  if (_satisfies) {
19
19
  // Just for type checking
20
20
  }
21
- exports.audioCodecNames = [
22
- 'pcm_s16le',
23
- 'aac',
24
- 'libmp3lame',
25
- 'libopus',
26
- ];
21
+ const audioCodecNames = ['pcm_s16le', 'aac', 'libmp3lame', 'libopus'];
27
22
  const mapAudioCodecToFfmpegAudioCodecName = (audioCodec) => {
28
23
  if (audioCodec === 'aac') {
29
24
  return 'aac';
@@ -67,8 +62,7 @@ exports.defaultAudioCodecs = {
67
62
  },
68
63
  prores: {
69
64
  lossless: 'pcm-16',
70
- // V4.0: Make pcm the default
71
- compressed: 'aac',
65
+ compressed: 'pcm-16',
72
66
  },
73
67
  vp8: {
74
68
  lossless: 'pcm-16',
@@ -38,5 +38,4 @@ export declare const localRevisions: (downloadsFolder: string, product: Product,
38
38
  export declare const removeBrowser: (revision: string, folderPath: string) => Promise<void>;
39
39
  export declare const getFolderPath: (revision: string, downloadsFolder: string, platform: Platform) => string;
40
40
  export declare const getRevisionInfo: (revision: string, product: Product) => BrowserFetcherRevisionInfo;
41
- export declare function _downloadFile(url: string, destinationPath: string, progressCallback: (x: number, y: number) => void): Promise<number>;
42
41
  export {};
@@ -41,7 +41,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
41
41
  return (mod && mod.__esModule) ? mod : { "default": mod };
42
42
  };
43
43
  Object.defineProperty(exports, "__esModule", { value: true });
44
- exports._downloadFile = exports.getRevisionInfo = exports.getFolderPath = exports.removeBrowser = exports.localRevisions = exports.download = exports.getDownloadHost = exports.getDownloadsFolder = exports.getPlatform = void 0;
44
+ exports.getRevisionInfo = exports.getFolderPath = exports.removeBrowser = exports.localRevisions = exports.download = exports.getDownloadHost = exports.getDownloadsFolder = exports.getPlatform = void 0;
45
45
  const childProcess = __importStar(require("child_process"));
46
46
  const fs = __importStar(require("fs"));
47
47
  const http = __importStar(require("http"));
@@ -331,7 +331,6 @@ function _downloadFile(url, destinationPath, progressCallback) {
331
331
  });
332
332
  return promise;
333
333
  }
334
- exports._downloadFile = _downloadFile;
335
334
  function install(archivePath, folderPath) {
336
335
  if (archivePath.endsWith('.zip')) {
337
336
  return (0, extract_zip_1.default)(archivePath, { dir: folderPath });
@@ -105,8 +105,14 @@ class BrowserRunner {
105
105
  stdio,
106
106
  });
107
107
  if (dumpio) {
108
- (_a = this.proc.stderr) === null || _a === void 0 ? void 0 : _a.pipe(process.stderr);
109
- (_b = this.proc.stdout) === null || _b === void 0 ? void 0 : _b.pipe(process.stdout);
108
+ (_a = this.proc.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (d) => {
109
+ process.stdout.write(options.indentationString);
110
+ process.stdout.write(d.toString().trimStart());
111
+ });
112
+ (_b = this.proc.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (d) => {
113
+ process.stderr.write(options.indentationString);
114
+ process.stderr.write(d.toString().trimStart());
115
+ });
110
116
  }
111
117
  __classPrivateFieldSet(this, _BrowserRunner_closed, false, "f");
112
118
  __classPrivateFieldSet(this, _BrowserRunner_processClosing, new Promise((fulfill, reject) => {
@@ -33,6 +33,7 @@ const Connection_1 = require("./Connection");
33
33
  const DOMWorld_1 = require("./DOMWorld");
34
34
  const EventEmitter_1 = require("./EventEmitter");
35
35
  const ExecutionContext_1 = require("./ExecutionContext");
36
+ const is_target_closed_err_1 = require("./is-target-closed-err");
36
37
  const LifecycleWatcher_1 = require("./LifecycleWatcher");
37
38
  const NetworkManager_1 = require("./NetworkManager");
38
39
  const util_1 = require("./util");
@@ -135,9 +136,7 @@ class FrameManager extends EventEmitter_1.EventEmitter {
135
136
  }
136
137
  catch (error) {
137
138
  // The target might have been closed before the initialization finished.
138
- if ((0, util_1.isErrorLike)(error) &&
139
- (error.message.includes('Target closed') ||
140
- error.message.includes('Session closed'))) {
139
+ if ((0, util_1.isErrorLike)(error) && (0, is_target_closed_err_1.isTargetClosedErr)(error)) {
141
140
  return;
142
141
  }
143
142
  throw error;
@@ -29,5 +29,6 @@ export interface LaunchOptions {
29
29
  env?: Record<string, string | undefined>;
30
30
  pipe?: boolean;
31
31
  product?: Product;
32
+ indentationString: string;
32
33
  }
33
34
  export declare type PuppeteerNodeLaunchOptions = BrowserLaunchArgumentOptions & LaunchOptions & BrowserConnectOptions;
@@ -57,7 +57,7 @@ class ChromeLauncher {
57
57
  this._preferredRevision = preferredRevision;
58
58
  }
59
59
  async launch(options) {
60
- const { args = [], dumpio = false, executablePath, pipe = false, env = process.env, defaultViewport, timeout = 60000, debuggingPort, } = options;
60
+ const { args = [], dumpio = false, executablePath, pipe = false, env = process.env, defaultViewport, timeout = 60000, debuggingPort, indentationString, } = options;
61
61
  const chromeArguments = args;
62
62
  if (!chromeArguments.some((argument) => {
63
63
  return argument.startsWith('--remote-debugging-');
@@ -91,6 +91,7 @@ class ChromeLauncher {
91
91
  dumpio,
92
92
  env,
93
93
  pipe: false,
94
+ indentationString,
94
95
  });
95
96
  let browser;
96
97
  try {
@@ -1,4 +1,4 @@
1
- import type { ActivateTargetRequest, AddScriptToEvaluateOnNewDocumentRequest, AddScriptToEvaluateOnNewDocumentResponse, CallFunctionOnRequest, CallFunctionOnResponse, CaptureScreenshotRequest, CaptureScreenshotResponse, CloseTargetRequest, CloseTargetResponse, CreateIsolatedWorldRequest, CreateIsolatedWorldResponse, DetachFromTargetRequest, DevtoolsRemoteObject, EnableRequest, ExceptionDetails, GetFrameTreeResponse, NavigateRequest, NavigateResponse, ReleaseObjectRequest, SetAutoAttachRequest, SetDefaultBackgroundColorOverrideRequest, SetDeviceMetricsOverrideRequest, SetLifecycleEventsEnabledRequest } from './devtools-types';
1
+ import type { ActivateTargetRequest, AddScriptToEvaluateOnNewDocumentRequest, AddScriptToEvaluateOnNewDocumentResponse, CallFunctionOnRequest, CallFunctionOnResponse, CaptureScreenshotRequest, CaptureScreenshotResponse, CloseTargetRequest, CloseTargetResponse, CreateIsolatedWorldRequest, CreateIsolatedWorldResponse, DetachFromTargetRequest, DevtoolsRemoteObject, EnableRequest, ExceptionDetails, GetFrameTreeResponse, NavigateRequest, NavigateResponse, PrintPDFRequest, PrintPDFResponse, ReleaseObjectRequest, SetAutoAttachRequest, SetDefaultBackgroundColorOverrideRequest, SetDeviceMetricsOverrideRequest, SetLifecycleEventsEnabledRequest } from './devtools-types';
2
2
  export interface Commands {
3
3
  /**
4
4
  * Does nothing.
@@ -216,6 +216,10 @@ export interface Commands {
216
216
  paramsType: [CaptureScreenshotRequest?];
217
217
  returnType: CaptureScreenshotResponse;
218
218
  };
219
+ 'Page.printToPDF': {
220
+ paramsType: [PrintPDFRequest];
221
+ returnType: PrintPDFResponse;
222
+ };
219
223
  'Target.activateTarget': {
220
224
  paramsType: [ActivateTargetRequest];
221
225
  returnType: void;
@@ -537,6 +537,84 @@ export interface CaptureScreenshotResponse {
537
537
  */
538
538
  data: string;
539
539
  }
540
+ export interface PrintPDFRequest {
541
+ /**
542
+ * Paper orientation. Defaults to false.
543
+ */
544
+ landscape?: boolean;
545
+ /**
546
+ * Display header and footer. Defaults to false.
547
+ */
548
+ displayHeaderFooter?: boolean;
549
+ /**
550
+ * Print background graphics. Defaults to false.
551
+ */
552
+ printBackground?: boolean;
553
+ /**
554
+ * Scale of the webpage rendering. Defaults to 1.
555
+ */
556
+ scale?: number;
557
+ /**
558
+ * Paper width in inches. Defaults to 8.5 inches.
559
+ */
560
+ paperWidth?: number;
561
+ /**
562
+ * Paper height in inches. Defaults to 11 inches.
563
+ */
564
+ paperHeight?: number;
565
+ /**
566
+ * Top margin in inches. Defaults to 1cm (~0.4 inches).
567
+ */
568
+ marginTop?: number;
569
+ /**
570
+ * Bottom margin in inches. Defaults to 1cm (~0.4 inches).
571
+ */
572
+ marginBottom?: number;
573
+ /**
574
+ * Left margin in inches. Defaults to 1cm (~0.4 inches).
575
+ */
576
+ marginLeft?: number;
577
+ /**
578
+ * Right margin in inches. Defaults to 1cm (~0.4 inches).
579
+ */
580
+ marginRight?: number;
581
+ /**
582
+ * Paper ranges to print, one based, e.g., '1-5, 8, 11-13'.
583
+ * Pages are printed in the document order, not in the order specified,
584
+ * and no more than once. Defaults to empty string,
585
+ * which implies the entire document is printed.
586
+ * The page numbers are quietly capped to actual page count of the document,
587
+ * and ranges beyond the end of the document are ignored.
588
+ * If this results in no pages to print, an error is reported.
589
+ * It is an error to specify a range with start greater than end.
590
+ */
591
+ pageRanges?: string;
592
+ /**
593
+ * HTML template for the print header.
594
+ * Should be valid HTML markup with following classes used to inject printing values into them:
595
+ * date: formatted print date
596
+ * title: document title
597
+ * url: document location
598
+ * pageNumber: current page number
599
+ * totalPages: total pages in the document
600
+ * For example, <span class=title></span> would generate span containing the title.
601
+ */
602
+ headerTemplate?: string;
603
+ /**
604
+ * HTML template for the print footer. Should use the same format as the headerTemplate.
605
+ */
606
+ footerTemplate?: string;
607
+ /**
608
+ * Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.
609
+ */
610
+ preferCSSPageSize?: boolean;
611
+ }
612
+ export interface PrintPDFResponse {
613
+ /**
614
+ * Base64-encoded pdf data. Empty if |returnAsStream| is specified. (Encoded as a base64 string when passed over JSON)
615
+ */
616
+ data: string;
617
+ }
540
618
  export interface RequestWillBeSentEvent {
541
619
  /**
542
620
  * Request identifier.
@@ -0,0 +1 @@
1
+ export declare const isTargetClosedErr: (error: Error | undefined) => boolean | undefined;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTargetClosedErr = void 0;
4
+ const isTargetClosedErr = (error) => {
5
+ var _a, _b;
6
+ return (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('Target closed')) ||
7
+ ((_b = error === null || error === void 0 ? void 0 : error.message) === null || _b === void 0 ? void 0 : _b.includes('Session closed')));
8
+ };
9
+ exports.isTargetClosedErr = isTargetClosedErr;
@@ -0,0 +1,14 @@
1
+ import execa from 'execa';
2
+ export declare const dynamicLibraryPathOptions: () => {
3
+ env: {
4
+ DYLD_LIBRARY_PATH: string;
5
+ RUST_BACKTRACE: string;
6
+ } | {
7
+ PATH: string;
8
+ RUST_BACKTRACE: string;
9
+ } | {
10
+ LD_LIBRARY_PATH: string;
11
+ RUST_BACKTRACE: string;
12
+ };
13
+ };
14
+ export declare const callFf: (bin: 'ffmpeg' | 'ffprobe', args: (string | null)[], options?: execa.Options<string>) => execa.ExecaChildProcess<string>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.callFf = exports.dynamicLibraryPathOptions = void 0;
7
+ const execa_1 = __importDefault(require("execa"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const get_executable_path_1 = require("./compositor/get-executable-path");
10
+ const truthy_1 = require("./truthy");
11
+ const dynamicLibraryPathOptions = () => {
12
+ const lib = path_1.default.join((0, get_executable_path_1.getExecutablePath)('ffmpeg-cwd'), 'remotion', 'lib');
13
+ return {
14
+ env: {
15
+ RUST_BACKTRACE: 'full',
16
+ ...(process.platform === 'darwin'
17
+ ? {
18
+ DYLD_LIBRARY_PATH: lib,
19
+ }
20
+ : process.platform === 'win32'
21
+ ? {
22
+ PATH: `${process.env.PATH};${lib}`,
23
+ }
24
+ : {
25
+ LD_LIBRARY_PATH: lib,
26
+ }),
27
+ },
28
+ };
29
+ };
30
+ exports.dynamicLibraryPathOptions = dynamicLibraryPathOptions;
31
+ const callFf = (bin, args, options) => {
32
+ return (0, execa_1.default)((0, get_executable_path_1.getExecutablePath)(bin), args.filter(truthy_1.truthy), {
33
+ ...(0, exports.dynamicLibraryPathOptions)(),
34
+ ...options,
35
+ });
36
+ };
37
+ exports.callFf = callFf;
@@ -1,55 +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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.checkNodeVersionAndWarnAboutRosetta = void 0;
27
- const os = __importStar(require("os"));
28
4
  const checkNodeVersionAndWarnAboutRosetta = () => {
29
- // see https://github.com/nodejs/node/issues/41900#issuecomment-1113511254
30
- const cpus = os.cpus();
31
- const isAppleSilicon = cpus[0].model.includes('Apple');
32
- const isArm64 = os.arch() === 'arm64';
33
5
  const version = process.version.replace('v', '').split('.');
34
6
  const majorVersion = Number(version[0]);
35
- const requiredNodeVersion = 14;
36
- if (majorVersion < 13) {
7
+ const requiredNodeVersion = 16;
8
+ if (majorVersion < 16) {
37
9
  throw new Error(`Remotion requires at least Node ${requiredNodeVersion}. You currently have ${process.version}. Update your node version to ${requiredNodeVersion} to use Remotion.`);
38
10
  }
39
- if (isAppleSilicon && !isArm64) {
40
- const recommendedNodeVersion = 16;
41
- const recommendNodeUpgrade = majorVersion < recommendedNodeVersion;
42
- console.warn([
43
- `⚠️ Apple Silicon detected but Node.JS running under Rosetta. This will cause performance issues.\n`,
44
- `Recommended actions:\n`,
45
- recommendNodeUpgrade
46
- ? ` - Upgrade to Node ${recommendedNodeVersion} or later\n`
47
- : ' - Run Node using `arch -arm64` architecture\n',
48
- 'See https://remotion.dev/docs/troubleshooting/rosetta for more information.',
49
- '---',
50
- ]
51
- .filter(Boolean)
52
- .join('\n'));
53
- }
54
11
  };
55
12
  exports.checkNodeVersionAndWarnAboutRosetta = checkNodeVersionAndWarnAboutRosetta;