@remotion/renderer 4.0.403 → 4.0.405

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,6 +1,7 @@
1
1
  import type { LogLevel } from '../log-level';
2
2
  import type { CompositorCommand } from './payloads';
3
3
  export type Compositor = {
4
+ shutDownOrKill: () => Promise<void>;
4
5
  finishCommands: () => Promise<void>;
5
6
  executeCommand: <T extends keyof CompositorCommand>(type: T, payload: CompositorCommand[T]) => Promise<Uint8Array>;
6
7
  waitForDone: () => Promise<void>;
@@ -107,42 +107,61 @@ const startCompositor = ({ type, payload, logLevel, indent, binariesDirectory =
107
107
  clear();
108
108
  stderrChunks = [];
109
109
  });
110
- return {
111
- waitForDone: () => {
112
- return new Promise((res, rej) => {
113
- if (runningStatus.type === 'quit-without-error') {
114
- rej(new Error(`Compositor quit${runningStatus.signal
115
- ? ` with signal ${runningStatus.signal}`
116
- : ''}`));
117
- return;
118
- }
119
- if (runningStatus.type === 'quit-with-error') {
120
- rej(new Error(`Compositor quit${runningStatus.signal
121
- ? ` with signal ${runningStatus.signal}`
122
- : ''}: ${runningStatus.error}`));
110
+ const waitForDone = () => {
111
+ return new Promise((res, rej) => {
112
+ if (runningStatus.type === 'quit-without-error') {
113
+ rej(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ''}`));
114
+ return;
115
+ }
116
+ if (runningStatus.type === 'quit-with-error') {
117
+ rej(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ''}: ${runningStatus.error}`));
118
+ return;
119
+ }
120
+ resolve = res;
121
+ reject = rej;
122
+ });
123
+ };
124
+ const finishCommands = async () => {
125
+ // Prevent this function from throwing an error if instead a rejected promise should be returned
126
+ await Promise.resolve();
127
+ if (runningStatus.type === 'quit-with-error') {
128
+ return Promise.reject(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ''}: ${runningStatus.error}`));
129
+ }
130
+ if (runningStatus.type === 'quit-without-error') {
131
+ return Promise.reject(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ''}`));
132
+ }
133
+ return new Promise((res, rej) => {
134
+ child.stdin.write('EOF\n', (e) => {
135
+ if (e) {
136
+ rej(e);
123
137
  return;
124
138
  }
125
- resolve = res;
126
- reject = rej;
139
+ res();
127
140
  });
128
- },
129
- finishCommands: () => {
130
- if (runningStatus.type === 'quit-with-error') {
131
- return Promise.reject(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ''}: ${runningStatus.error}`));
132
- }
133
- if (runningStatus.type === 'quit-without-error') {
134
- return Promise.reject(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ''}`));
135
- }
136
- return new Promise((res, rej) => {
137
- child.stdin.write('EOF\n', (e) => {
138
- if (e) {
139
- rej(e);
140
- return;
141
- }
142
- res();
143
- });
141
+ });
142
+ };
143
+ const shutDownOrKill = () => {
144
+ const shutDownCase = async () => {
145
+ await finishCommands();
146
+ await waitForDone();
147
+ };
148
+ let timeout = null;
149
+ const killCase = async () => {
150
+ await new Promise((res) => {
151
+ timeout = setTimeout(res, 5000);
144
152
  });
145
- },
153
+ child.kill('SIGKILL');
154
+ };
155
+ return Promise.race([shutDownCase(), killCase()]).finally(() => {
156
+ if (timeout !== null) {
157
+ clearTimeout(timeout);
158
+ }
159
+ });
160
+ };
161
+ return {
162
+ shutDownOrKill,
163
+ waitForDone,
164
+ finishCommands,
146
165
  executeCommand: (command, params) => {
147
166
  return new Promise((_resolve, _reject) => {
148
167
  if (runningStatus.type === 'quit-without-error') {
@@ -14801,39 +14801,61 @@ ${parsed.backtrace}`));
14801
14801
  clear();
14802
14802
  stderrChunks = [];
14803
14803
  });
14804
- return {
14805
- waitForDone: () => {
14806
- return new Promise((res, rej) => {
14807
- if (runningStatus.type === "quit-without-error") {
14808
- rej(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ""}`));
14809
- return;
14810
- }
14811
- if (runningStatus.type === "quit-with-error") {
14812
- rej(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ""}: ${runningStatus.error}`));
14813
- return;
14814
- }
14815
- resolve2 = res;
14816
- reject = rej;
14817
- });
14818
- },
14819
- finishCommands: () => {
14820
- if (runningStatus.type === "quit-with-error") {
14821
- return Promise.reject(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ""}: ${runningStatus.error}`));
14822
- }
14804
+ const waitForDone = () => {
14805
+ return new Promise((res, rej) => {
14823
14806
  if (runningStatus.type === "quit-without-error") {
14824
- return Promise.reject(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ""}`));
14807
+ rej(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ""}`));
14808
+ return;
14809
+ }
14810
+ if (runningStatus.type === "quit-with-error") {
14811
+ rej(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ""}: ${runningStatus.error}`));
14812
+ return;
14825
14813
  }
14826
- return new Promise((res, rej) => {
14827
- child.stdin.write(`EOF
14814
+ resolve2 = res;
14815
+ reject = rej;
14816
+ });
14817
+ };
14818
+ const finishCommands = async () => {
14819
+ await Promise.resolve();
14820
+ if (runningStatus.type === "quit-with-error") {
14821
+ return Promise.reject(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ""}: ${runningStatus.error}`));
14822
+ }
14823
+ if (runningStatus.type === "quit-without-error") {
14824
+ return Promise.reject(new Error(`Compositor quit${runningStatus.signal ? ` with signal ${runningStatus.signal}` : ""}`));
14825
+ }
14826
+ return new Promise((res, rej) => {
14827
+ child.stdin.write(`EOF
14828
14828
  `, (e) => {
14829
- if (e) {
14830
- rej(e);
14831
- return;
14832
- }
14833
- res();
14834
- });
14829
+ if (e) {
14830
+ rej(e);
14831
+ return;
14832
+ }
14833
+ res();
14835
14834
  });
14836
- },
14835
+ });
14836
+ };
14837
+ const shutDownOrKill = () => {
14838
+ const shutDownCase = async () => {
14839
+ await finishCommands();
14840
+ await waitForDone();
14841
+ };
14842
+ let timeout = null;
14843
+ const killCase = async () => {
14844
+ await new Promise((res) => {
14845
+ timeout = setTimeout(res, 5000);
14846
+ });
14847
+ child.kill("SIGKILL");
14848
+ };
14849
+ return Promise.race([shutDownCase(), killCase()]).finally(() => {
14850
+ if (timeout !== null) {
14851
+ clearTimeout(timeout);
14852
+ }
14853
+ });
14854
+ };
14855
+ return {
14856
+ shutDownOrKill,
14857
+ waitForDone,
14858
+ finishCommands,
14837
14859
  executeCommand: (command, params) => {
14838
14860
  return new Promise((_resolve, _reject) => {
14839
14861
  if (runningStatus.type === "quit-without-error") {
@@ -14941,13 +14963,8 @@ var startOffthreadVideoServer = ({
14941
14963
  binariesDirectory
14942
14964
  });
14943
14965
  return {
14944
- close: async () => {
14945
- try {
14946
- await compositor.finishCommands();
14947
- return compositor.waitForDone();
14948
- } catch (err) {
14949
- return Promise.reject(err);
14950
- }
14966
+ close: () => {
14967
+ return compositor.shutDownOrKill();
14951
14968
  },
14952
14969
  listener: (req, response) => {
14953
14970
  if (!req.url) {
@@ -50,18 +50,8 @@ const startOffthreadVideoServer = ({ downloadMap, logLevel, indent, offthreadVid
50
50
  binariesDirectory,
51
51
  });
52
52
  return {
53
- close: async () => {
54
- // Note: This is being used as a promise:
55
- // .close().then()
56
- // but if finishCommands() fails, it acts like a sync function,
57
- // therefore we have to catch an error and put a promise rejection
58
- try {
59
- await compositor.finishCommands();
60
- return compositor.waitForDone();
61
- }
62
- catch (err) {
63
- return Promise.reject(err);
64
- }
53
+ close: () => {
54
+ return compositor.shutDownOrKill();
65
55
  },
66
56
  listener: (req, response) => {
67
57
  if (!req.url) {
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.403",
6
+ "version": "4.0.405",
7
7
  "description": "Render Remotion videos using Node.js or Bun",
8
8
  "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
@@ -22,11 +22,11 @@
22
22
  "dependencies": {
23
23
  "execa": "5.1.1",
24
24
  "extract-zip": "2.0.1",
25
- "remotion": "4.0.403",
26
- "@remotion/streaming": "4.0.403",
25
+ "remotion": "4.0.405",
26
+ "@remotion/streaming": "4.0.405",
27
27
  "source-map": "^0.8.0-beta.0",
28
28
  "ws": "8.17.1",
29
- "@remotion/licensing": "4.0.403"
29
+ "@remotion/licensing": "4.0.405"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">=16.8.0",
@@ -39,19 +39,19 @@
39
39
  "react": "19.2.3",
40
40
  "react-dom": "19.2.3",
41
41
  "@types/ws": "8.5.10",
42
- "@remotion/example-videos": "4.0.403",
43
- "@remotion/eslint-config-internal": "4.0.403",
42
+ "@remotion/example-videos": "4.0.405",
43
+ "@remotion/eslint-config-internal": "4.0.405",
44
44
  "eslint": "9.19.0",
45
45
  "@types/node": "20.12.14"
46
46
  },
47
47
  "optionalDependencies": {
48
- "@remotion/compositor-darwin-arm64": "4.0.403",
49
- "@remotion/compositor-darwin-x64": "4.0.403",
50
- "@remotion/compositor-linux-arm64-gnu": "4.0.403",
51
- "@remotion/compositor-linux-arm64-musl": "4.0.403",
52
- "@remotion/compositor-linux-x64-gnu": "4.0.403",
53
- "@remotion/compositor-linux-x64-musl": "4.0.403",
54
- "@remotion/compositor-win32-x64-msvc": "4.0.403"
48
+ "@remotion/compositor-darwin-arm64": "4.0.405",
49
+ "@remotion/compositor-darwin-x64": "4.0.405",
50
+ "@remotion/compositor-linux-arm64-gnu": "4.0.405",
51
+ "@remotion/compositor-linux-arm64-musl": "4.0.405",
52
+ "@remotion/compositor-linux-x64-gnu": "4.0.405",
53
+ "@remotion/compositor-linux-x64-musl": "4.0.405",
54
+ "@remotion/compositor-win32-x64-msvc": "4.0.405"
55
55
  },
56
56
  "keywords": [
57
57
  "remotion",