@remotion/lambda 4.0.254 → 4.0.256

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 (127) hide show
  1. package/dist/api/__mocks__/clean-items.d.ts +2 -0
  2. package/dist/api/__mocks__/clean-items.js +24 -0
  3. package/dist/api/__mocks__/create-function.d.ts +2 -0
  4. package/dist/api/__mocks__/create-function.js +21 -0
  5. package/dist/api/__mocks__/delete-function.d.ts +2 -0
  6. package/dist/api/__mocks__/delete-function.js +9 -0
  7. package/dist/api/__mocks__/get-functions.d.ts +2 -0
  8. package/dist/api/__mocks__/get-functions.js +9 -0
  9. package/dist/api/__mocks__/upload-dir.d.ts +3 -0
  10. package/dist/api/__mocks__/upload-dir.js +47 -0
  11. package/dist/api/mock-functions.d.ts +18 -0
  12. package/dist/api/mock-functions.js +36 -0
  13. package/dist/cli/helpers/__mocks__/quit.d.ts +1 -0
  14. package/dist/cli/helpers/__mocks__/quit.js +7 -0
  15. package/dist/cli/log.d.ts +4 -4
  16. package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +7 -0
  17. package/dist/functions/chunk-optimization/plan-frame-ranges.js +17 -0
  18. package/dist/functions/chunk-optimization/types.d.ts +8 -0
  19. package/dist/functions/chunk-optimization/types.js +2 -0
  20. package/dist/functions/helpers/__mocks__/get-browser-instance.d.ts +3 -0
  21. package/dist/functions/helpers/__mocks__/get-browser-instance.js +12 -0
  22. package/dist/functions/helpers/__mocks__/leak-detection.d.ts +4 -0
  23. package/dist/functions/helpers/__mocks__/leak-detection.js +9 -0
  24. package/dist/functions/helpers/__mocks__/timer.d.ts +2 -0
  25. package/dist/functions/helpers/__mocks__/timer.js +10 -0
  26. package/dist/functions/helpers/best-frames-per-lambda-param.d.ts +1 -0
  27. package/dist/functions/helpers/best-frames-per-lambda-param.js +17 -0
  28. package/dist/functions/helpers/calculate-chunk-times.d.ts +5 -0
  29. package/dist/functions/helpers/calculate-chunk-times.js +29 -0
  30. package/dist/functions/helpers/calculate-price-from-bucket.d.ts +15 -0
  31. package/dist/functions/helpers/calculate-price-from-bucket.js +30 -0
  32. package/dist/functions/helpers/can-concat-seamlessly.d.ts +3 -0
  33. package/dist/functions/helpers/can-concat-seamlessly.js +17 -0
  34. package/dist/functions/helpers/cleanup-props.d.ts +8 -0
  35. package/dist/functions/helpers/cleanup-props.js +23 -0
  36. package/dist/functions/helpers/concat-videos.d.ts +23 -0
  37. package/dist/functions/helpers/concat-videos.js +54 -0
  38. package/dist/functions/helpers/create-post-render-data.d.ts +17 -0
  39. package/dist/functions/helpers/create-post-render-data.js +67 -0
  40. package/dist/functions/helpers/find-output-file-in-bucket.d.ts +14 -0
  41. package/dist/functions/helpers/find-output-file-in-bucket.js +38 -0
  42. package/dist/functions/helpers/format-costs-info.d.ts +2 -0
  43. package/dist/functions/helpers/format-costs-info.js +23 -0
  44. package/dist/functions/helpers/get-overall-progress-s3.d.ts +10 -0
  45. package/dist/functions/helpers/get-overall-progress-s3.js +24 -0
  46. package/dist/functions/helpers/get-overall-progress.d.ts +9 -0
  47. package/dist/functions/helpers/get-overall-progress.js +23 -0
  48. package/dist/functions/helpers/get-progress.d.ts +15 -0
  49. package/dist/functions/helpers/get-progress.js +254 -0
  50. package/dist/functions/helpers/get-retry-stats.d.ts +5 -0
  51. package/dist/functions/helpers/get-retry-stats.js +2 -0
  52. package/dist/functions/helpers/inspect-errors.d.ts +4 -0
  53. package/dist/functions/helpers/inspect-errors.js +39 -0
  54. package/dist/functions/helpers/is-warm.d.ts +2 -0
  55. package/dist/functions/helpers/is-warm.js +10 -0
  56. package/dist/functions/helpers/leak-detection.d.ts +4 -0
  57. package/dist/functions/helpers/leak-detection.js +40 -0
  58. package/dist/functions/helpers/make-timeout-error.d.ts +10 -0
  59. package/dist/functions/helpers/make-timeout-error.js +31 -0
  60. package/dist/functions/helpers/make-timeout-message.d.ts +10 -0
  61. package/dist/functions/helpers/make-timeout-message.js +75 -0
  62. package/dist/functions/helpers/merge-chunks.d.ts +36 -0
  63. package/dist/functions/helpers/merge-chunks.js +84 -0
  64. package/dist/functions/helpers/min-max.d.ts +2 -0
  65. package/dist/functions/helpers/min-max.js +33 -0
  66. package/dist/functions/helpers/on-downloads-logger.d.ts +2 -0
  67. package/dist/functions/helpers/on-downloads-logger.js +29 -0
  68. package/dist/functions/helpers/overall-render-progress.d.ts +59 -0
  69. package/dist/functions/helpers/overall-render-progress.js +180 -0
  70. package/dist/functions/helpers/print-concurrency-curve.d.ts +1 -0
  71. package/dist/functions/helpers/print-concurrency-curve.js +8 -0
  72. package/dist/functions/helpers/print-logging-helper.d.ts +4 -0
  73. package/dist/functions/helpers/print-logging-helper.js +12 -0
  74. package/dist/functions/helpers/render-has-audio-video.d.ts +6 -0
  75. package/dist/functions/helpers/render-has-audio-video.js +21 -0
  76. package/dist/functions/helpers/request-context.d.ts +5 -0
  77. package/dist/functions/helpers/request-context.js +2 -0
  78. package/dist/functions/helpers/stream-renderer.d.ts +17 -0
  79. package/dist/functions/helpers/stream-renderer.js +148 -0
  80. package/dist/functions/launch.d.ts +10 -0
  81. package/dist/functions/launch.js +595 -0
  82. package/dist/functions/progress.d.ts +11 -0
  83. package/dist/functions/progress.js +51 -0
  84. package/dist/functions/renderer.d.ts +17 -0
  85. package/dist/functions/renderer.js +341 -0
  86. package/dist/functions/start.d.ts +13 -0
  87. package/dist/functions/start.js +112 -0
  88. package/dist/functions/still.d.ts +19 -0
  89. package/dist/functions/still.js +329 -0
  90. package/dist/shared/__mocks__/aws-clients.d.ts +2 -0
  91. package/dist/shared/__mocks__/aws-clients.js +62 -0
  92. package/dist/shared/__mocks__/bundle-site.d.ts +2 -0
  93. package/dist/shared/__mocks__/bundle-site.js +32 -0
  94. package/dist/shared/__mocks__/check-credentials.d.ts +1 -0
  95. package/dist/shared/__mocks__/check-credentials.js +5 -0
  96. package/dist/shared/__mocks__/get-account-id.d.ts +2 -0
  97. package/dist/shared/__mocks__/get-account-id.js +11 -0
  98. package/dist/shared/__mocks__/read-dir.d.ts +2 -0
  99. package/dist/shared/__mocks__/read-dir.js +13 -0
  100. package/dist/shared/call-lambda.d.ts +16 -0
  101. package/dist/shared/call-lambda.js +149 -0
  102. package/dist/shared/cleanup-serialized-input-props.d.ts +14 -0
  103. package/dist/shared/cleanup-serialized-input-props.js +34 -0
  104. package/dist/shared/docs-url.d.ts +1 -0
  105. package/dist/shared/docs-url.js +4 -0
  106. package/dist/shared/get-most-expensive-chunks.d.ts +8 -0
  107. package/dist/shared/get-most-expensive-chunks.js +28 -0
  108. package/dist/shared/invoke-webhook.d.ts +48 -0
  109. package/dist/shared/invoke-webhook.js +140 -0
  110. package/dist/shared/parse-lambda-timings-key.d.ts +5 -0
  111. package/dist/shared/parse-lambda-timings-key.js +2 -0
  112. package/dist/shared/return-values.d.ts +16 -0
  113. package/dist/shared/return-values.js +2 -0
  114. package/dist/shared/stackback.d.ts +6 -0
  115. package/dist/shared/stackback.js +59 -0
  116. package/dist/shared/validate-download-behavior.d.ts +1 -0
  117. package/dist/shared/validate-download-behavior.js +21 -0
  118. package/dist/shared/validate-frames-per-lambda.d.ts +4 -0
  119. package/dist/shared/validate-frames-per-lambda.js +29 -0
  120. package/dist/shared/validate-privacy.d.ts +2 -0
  121. package/dist/shared/validate-privacy.js +14 -0
  122. package/dist/shared/validate.d.ts +4 -0
  123. package/dist/shared/validate.js +8 -0
  124. package/dist/shared/why-is-node-running.d.ts +15 -0
  125. package/dist/shared/why-is-node-running.js +88 -0
  126. package/package.json +12 -12
  127. package/remotionlambda-arm64.zip +0 -0
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.streamRendererFunctionWithRetry = void 0;
4
+ const renderer_1 = require("@remotion/renderer");
5
+ const serverless_1 = require("@remotion/serverless");
6
+ const client_1 = require("@remotion/serverless/client");
7
+ const fs_1 = require("fs");
8
+ const path_1 = require("path");
9
+ const call_lambda_1 = require("../../shared/call-lambda");
10
+ const streamRenderer = ({ payload, functionName, outdir, overallProgress, files, logLevel, onArtifact, providerSpecifics, }) => {
11
+ if (payload.type !== client_1.ServerlessRoutines.renderer) {
12
+ throw new Error('Expected renderer type');
13
+ }
14
+ return new Promise((resolve) => {
15
+ const receivedStreamingPayload = ({ message }) => {
16
+ if (message.type === 'lambda-invoked') {
17
+ overallProgress.setLambdaInvoked(payload.chunk);
18
+ return;
19
+ }
20
+ if (message.type === 'frames-rendered') {
21
+ overallProgress.setFrames({
22
+ index: payload.chunk,
23
+ encoded: message.payload.encoded,
24
+ rendered: message.payload.rendered,
25
+ });
26
+ return;
27
+ }
28
+ if (message.type === 'video-chunk-rendered') {
29
+ const filename = (0, path_1.join)(outdir, `chunk:${String(payload.chunk).padStart(8, '0')}:video`);
30
+ (0, fs_1.writeFileSync)(filename, message.payload);
31
+ files.push(filename);
32
+ renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `Received video chunk for chunk ${payload.chunk}`);
33
+ return;
34
+ }
35
+ if (message.type === 'audio-chunk-rendered') {
36
+ const filename = (0, path_1.join)(outdir, `chunk:${String(payload.chunk).padStart(8, '0')}:audio`);
37
+ (0, fs_1.writeFileSync)(filename, message.payload);
38
+ renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `Received audio chunk for chunk ${payload.chunk}`);
39
+ files.push(filename);
40
+ return;
41
+ }
42
+ if (message.type === 'chunk-complete') {
43
+ renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `Finished chunk ${payload.chunk}`);
44
+ overallProgress.addChunkCompleted(payload.chunk, message.payload.start, message.payload.rendered);
45
+ return;
46
+ }
47
+ if (message.type === 'artifact-emitted') {
48
+ const artifact = (0, serverless_1.deserializeArtifact)(message.payload.artifact);
49
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `Received artifact on frame ${message.payload.artifact.frame}:`, artifact.filename, artifact.content.length + 'bytes.');
50
+ const { alreadyExisted } = onArtifact(artifact);
51
+ if (alreadyExisted) {
52
+ return resolve({
53
+ type: 'error',
54
+ error: `Chunk ${payload.chunk} emitted an asset filename ${message.payload.artifact.filename} at frame ${message.payload.artifact.frame} but there is already another artifact with the same name. https://remotion.dev/docs/artifacts`,
55
+ shouldRetry: false,
56
+ });
57
+ }
58
+ return;
59
+ }
60
+ if (message.type === 'error-occurred') {
61
+ overallProgress.addErrorWithoutUpload(message.payload.errorInfo);
62
+ overallProgress.setFrames({
63
+ encoded: 0,
64
+ index: payload.chunk,
65
+ rendered: 0,
66
+ });
67
+ renderer_1.RenderInternals.Log.error({
68
+ indent: false,
69
+ logLevel,
70
+ }, `Renderer function of chunk ${payload.chunk} failed with error: ${message.payload.error}`);
71
+ renderer_1.RenderInternals.Log.error({
72
+ indent: false,
73
+ logLevel,
74
+ }, `Will retry chunk = ${message.payload.shouldRetry}`);
75
+ resolve({
76
+ type: 'error',
77
+ error: message.payload.error,
78
+ shouldRetry: message.payload.shouldRetry,
79
+ });
80
+ return;
81
+ }
82
+ throw new Error(`Unknown message type ${message.type}`);
83
+ };
84
+ (0, call_lambda_1.callLambdaWithStreaming)({
85
+ functionName,
86
+ payload,
87
+ retriesRemaining: 1,
88
+ region: providerSpecifics.getCurrentRegionInFunction(),
89
+ timeoutInTest: 12000,
90
+ type: client_1.ServerlessRoutines.renderer,
91
+ receivedStreamingPayload,
92
+ })
93
+ .then(() => {
94
+ resolve({
95
+ type: 'success',
96
+ });
97
+ })
98
+ .catch((err) => {
99
+ var _a, _b;
100
+ const shouldRetry = (_b = (_a = err.stack) === null || _a === void 0 ? void 0 : _a.includes('Error: aborted')) !== null && _b !== void 0 ? _b : false;
101
+ resolve({
102
+ type: 'error',
103
+ error: err.stack,
104
+ shouldRetry,
105
+ });
106
+ });
107
+ });
108
+ };
109
+ const streamRendererFunctionWithRetry = async ({ payload, files, functionName, outdir, overallProgress, logLevel, onArtifact, providerSpecifics, }) => {
110
+ if (payload.type !== client_1.ServerlessRoutines.renderer) {
111
+ throw new Error('Expected renderer type');
112
+ }
113
+ const result = await streamRenderer({
114
+ files,
115
+ functionName,
116
+ outdir,
117
+ overallProgress,
118
+ payload,
119
+ logLevel,
120
+ onArtifact,
121
+ providerSpecifics,
122
+ });
123
+ if (result.type === 'error') {
124
+ if (!result.shouldRetry) {
125
+ throw new Error(result.error);
126
+ }
127
+ overallProgress.addRetry({
128
+ attempt: payload.attempt + 1,
129
+ time: Date.now(),
130
+ chunk: payload.chunk,
131
+ });
132
+ return (0, exports.streamRendererFunctionWithRetry)({
133
+ files,
134
+ functionName,
135
+ outdir,
136
+ overallProgress,
137
+ payload: {
138
+ ...payload,
139
+ attempt: payload.attempt + 1,
140
+ retriesLeft: payload.retriesLeft - 1,
141
+ },
142
+ logLevel,
143
+ onArtifact,
144
+ providerSpecifics,
145
+ });
146
+ }
147
+ };
148
+ exports.streamRendererFunctionWithRetry = streamRendererFunctionWithRetry;
@@ -0,0 +1,10 @@
1
+ import type { CloudProvider, ProviderSpecifics } from '@remotion/serverless';
2
+ import type { ServerlessPayload } from '@remotion/serverless/client';
3
+ type Options = {
4
+ expectedBucketOwner: string;
5
+ getRemainingTimeInMillis: () => number;
6
+ };
7
+ export declare const launchHandler: <Provider extends CloudProvider>(params: ServerlessPayload<Provider>, options: Options, providerSpecifics: ProviderSpecifics<Provider>) => Promise<{
8
+ type: "success";
9
+ }>;
10
+ export {};