@remotion/cloudrun 4.1.0-alpha10
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.
- package/.turbo/turbo-build.log +13 -0
- package/LICENSE.md +41 -0
- package/dist/admin/bundle-installer.d.ts +1 -0
- package/dist/admin/bundle-installer.js +32 -0
- package/dist/admin/bundle-renderLogic.d.ts +1 -0
- package/dist/admin/bundle-renderLogic.js +39 -0
- package/dist/api/check-if-service-exists.d.ts +18 -0
- package/dist/api/check-if-service-exists.js +49 -0
- package/dist/api/create-bucket.d.ts +13 -0
- package/dist/api/create-bucket.js +18 -0
- package/dist/api/delete-service.d.ts +12 -0
- package/dist/api/delete-service.js +19 -0
- package/dist/api/delete-site.d.ts +13 -0
- package/dist/api/delete-site.js +30 -0
- package/dist/api/deploy-service.d.ts +28 -0
- package/dist/api/deploy-service.js +90 -0
- package/dist/api/deploy-site.d.ts +35 -0
- package/dist/api/deploy-site.js +78 -0
- package/dist/api/download-file.d.ts +13 -0
- package/dist/api/download-file.js +30 -0
- package/dist/api/get-buckets.d.ts +10 -0
- package/dist/api/get-buckets.js +23 -0
- package/dist/api/get-or-create-bucket.d.ts +17 -0
- package/dist/api/get-or-create-bucket.js +42 -0
- package/dist/api/get-regions.d.ts +7 -0
- package/dist/api/get-regions.js +13 -0
- package/dist/api/get-service-info.d.ts +23 -0
- package/dist/api/get-service-info.js +34 -0
- package/dist/api/get-services.d.ts +14 -0
- package/dist/api/get-services.js +49 -0
- package/dist/api/get-sites.d.ts +23 -0
- package/dist/api/get-sites.js +49 -0
- package/dist/api/helpers/IService.d.ts +2 -0
- package/dist/api/helpers/IService.js +2 -0
- package/dist/api/helpers/construct-service-deploy-request.d.ts +32 -0
- package/dist/api/helpers/construct-service-deploy-request.js +36 -0
- package/dist/api/helpers/extract-mem-from-url.d.ts +1 -0
- package/dist/api/helpers/extract-mem-from-url.js +9 -0
- package/dist/api/helpers/extract-time-from-url.d.ts +1 -0
- package/dist/api/helpers/extract-time-from-url.js +13 -0
- package/dist/api/helpers/get-auth-client-for-url.d.ts +1 -0
- package/dist/api/helpers/get-auth-client-for-url.js +15 -0
- package/dist/api/helpers/get-cloud-logging-client.d.ts +1 -0
- package/dist/api/helpers/get-cloud-logging-client.js +15 -0
- package/dist/api/helpers/get-cloud-run-client.d.ts +2 -0
- package/dist/api/helpers/get-cloud-run-client.js +15 -0
- package/dist/api/helpers/get-cloud-storage-client.d.ts +2 -0
- package/dist/api/helpers/get-cloud-storage-client.js +14 -0
- package/dist/api/helpers/get-cloudrun-endpoint.d.ts +14 -0
- package/dist/api/helpers/get-cloudrun-endpoint.js +36 -0
- package/dist/api/helpers/get-resource-manager-client.d.ts +2 -0
- package/dist/api/helpers/get-resource-manager-client.js +15 -0
- package/dist/api/helpers/parse-service-name.d.ts +8 -0
- package/dist/api/helpers/parse-service-name.js +24 -0
- package/dist/api/iam-validation/testPermissions.d.ts +20 -0
- package/dist/api/iam-validation/testPermissions.js +48 -0
- package/dist/api/render-media-on-cloudrun.d.ts +78 -0
- package/dist/api/render-media-on-cloudrun.js +144 -0
- package/dist/api/render-still-on-cloudrun.d.ts +49 -0
- package/dist/api/render-still-on-cloudrun.js +76 -0
- package/dist/api/speculate-service-name.d.ts +13 -0
- package/dist/api/speculate-service-name.js +20 -0
- package/dist/api/test/service-names.test.d.ts +1 -0
- package/dist/api/test/service-names.test.js +28 -0
- package/dist/api/upload-dir.d.ts +18 -0
- package/dist/api/upload-dir.js +81 -0
- package/dist/cli/args.d.ts +19 -0
- package/dist/cli/args.js +11 -0
- package/dist/cli/commands/permissions.d.ts +2 -0
- package/dist/cli/commands/permissions.js +23 -0
- package/dist/cli/commands/regions.d.ts +2 -0
- package/dist/cli/commands/regions.js +10 -0
- package/dist/cli/commands/render/helpers/renderArgsCheck.d.ts +9 -0
- package/dist/cli/commands/render/helpers/renderArgsCheck.js +75 -0
- package/dist/cli/commands/render/index.d.ts +2 -0
- package/dist/cli/commands/render/index.js +228 -0
- package/dist/cli/commands/services/deploy.d.ts +2 -0
- package/dist/cli/commands/services/deploy.js +129 -0
- package/dist/cli/commands/services/index.d.ts +5 -0
- package/dist/cli/commands/services/index.js +64 -0
- package/dist/cli/commands/services/ls.d.ts +2 -0
- package/dist/cli/commands/services/ls.js +40 -0
- package/dist/cli/commands/services/rm.d.ts +2 -0
- package/dist/cli/commands/services/rm.js +63 -0
- package/dist/cli/commands/services/rmall.d.ts +2 -0
- package/dist/cli/commands/services/rmall.js +52 -0
- package/dist/cli/commands/sites/create.d.ts +2 -0
- package/dist/cli/commands/sites/create.js +138 -0
- package/dist/cli/commands/sites/index.d.ts +4 -0
- package/dist/cli/commands/sites/index.js +60 -0
- package/dist/cli/commands/sites/ls.d.ts +2 -0
- package/dist/cli/commands/sites/ls.js +40 -0
- package/dist/cli/commands/sites/rm.d.ts +2 -0
- package/dist/cli/commands/sites/rm.js +59 -0
- package/dist/cli/commands/sites/rmall.d.ts +2 -0
- package/dist/cli/commands/sites/rmall.js +38 -0
- package/dist/cli/commands/still.d.ts +2 -0
- package/dist/cli/commands/still.js +129 -0
- package/dist/cli/get-gcp-region.d.ts +2 -0
- package/dist/cli/get-gcp-region.js +19 -0
- package/dist/cli/help.d.ts +1 -0
- package/dist/cli/help.js +38 -0
- package/dist/cli/helpers/confirm.d.ts +4 -0
- package/dist/cli/helpers/confirm.js +12 -0
- package/dist/cli/helpers/date-string.d.ts +1 -0
- package/dist/cli/helpers/date-string.js +9 -0
- package/dist/cli/helpers/progress-bar.d.ts +23 -0
- package/dist/cli/helpers/progress-bar.js +81 -0
- package/dist/cli/helpers/quit.d.ts +1 -0
- package/dist/cli/helpers/quit.js +7 -0
- package/dist/cli/helpers/yes-or-no.d.ts +4 -0
- package/dist/cli/helpers/yes-or-no.js +44 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +56 -0
- package/dist/cli/log.d.ts +26 -0
- package/dist/cli/log.js +5 -0
- package/dist/defaults.d.ts +1 -0
- package/dist/defaults.js +17 -0
- package/dist/functions/helpers/get-composition-from-body.d.ts +2 -0
- package/dist/functions/helpers/get-composition-from-body.js +27 -0
- package/dist/functions/helpers/io.d.ts +11 -0
- package/dist/functions/helpers/io.js +17 -0
- package/dist/functions/helpers/payloads.d.ts +300 -0
- package/dist/functions/helpers/payloads.js +104 -0
- package/dist/functions/index.d.ts +3 -0
- package/dist/functions/index.js +39 -0
- package/dist/functions/render-media-single-thread.d.ts +3 -0
- package/dist/functions/render-media-single-thread.js +103 -0
- package/dist/functions/render-still-single-thread.d.ts +3 -0
- package/dist/functions/render-still-single-thread.js +82 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +31 -0
- package/dist/internals.d.ts +3 -0
- package/dist/internals.js +7 -0
- package/dist/pricing/gcp-regions.d.ts +5 -0
- package/dist/pricing/gcp-regions.js +77 -0
- package/dist/regions.d.ts +2 -0
- package/dist/regions.js +5 -0
- package/dist/shared/bundle-site.d.ts +2 -0
- package/dist/shared/bundle-site.js +5 -0
- package/dist/shared/constants.d.ts +13 -0
- package/dist/shared/constants.js +18 -0
- package/dist/shared/convert-to-serve-url.d.ts +4 -0
- package/dist/shared/convert-to-serve-url.js +14 -0
- package/dist/shared/docs-url.d.ts +1 -0
- package/dist/shared/docs-url.js +4 -0
- package/dist/shared/generate-service-name.d.ts +5 -0
- package/dist/shared/generate-service-name.js +20 -0
- package/dist/shared/get-etag.d.ts +1 -0
- package/dist/shared/get-etag.js +24 -0
- package/dist/shared/get-storage-operations.d.ts +10 -0
- package/dist/shared/get-storage-operations.js +36 -0
- package/dist/shared/make-storage-key.d.ts +1 -0
- package/dist/shared/make-storage-key.js +11 -0
- package/dist/shared/make-storage-url.d.ts +4 -0
- package/dist/shared/make-storage-url.js +7 -0
- package/dist/shared/random-hash.d.ts +3 -0
- package/dist/shared/random-hash.js +14 -0
- package/dist/shared/read-dir.d.ts +9 -0
- package/dist/shared/read-dir.js +57 -0
- package/dist/shared/sa-permissions.json +64 -0
- package/dist/shared/service-version-string.d.ts +1 -0
- package/dist/shared/service-version-string.js +8 -0
- package/dist/shared/validate-bucketname.d.ts +8 -0
- package/dist/shared/validate-bucketname.js +35 -0
- package/dist/shared/validate-cloudrun-url.d.ts +1 -0
- package/dist/shared/validate-cloudrun-url.js +10 -0
- package/dist/shared/validate-gcp-codec.d.ts +4 -0
- package/dist/shared/validate-gcp-codec.js +29 -0
- package/dist/shared/validate-gcp-region.d.ts +2 -0
- package/dist/shared/validate-gcp-region.js +10 -0
- package/dist/shared/validate-image-remotion-version.d.ts +1 -0
- package/dist/shared/validate-image-remotion-version.js +26 -0
- package/dist/shared/validate-privacy.d.ts +2 -0
- package/dist/shared/validate-privacy.js +12 -0
- package/dist/shared/validate-project-id.d.ts +1 -0
- package/dist/shared/validate-project-id.js +17 -0
- package/dist/shared/validate-region.d.ts +1 -0
- package/dist/shared/validate-region.js +15 -0
- package/dist/shared/validate-retries.d.ts +1 -0
- package/dist/shared/validate-retries.js +21 -0
- package/dist/shared/validate-serveurl.d.ts +1 -0
- package/dist/shared/validate-serveurl.js +30 -0
- package/dist/shared/validate-service-name.d.ts +1 -0
- package/dist/shared/validate-service-name.js +9 -0
- package/dist/shared/validate-site-name.d.ts +1 -0
- package/dist/shared/validate-site-name.js +17 -0
- package/package.json +57 -0
- package/readme.md +3 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ChromiumOptions, FrameRange, LogLevel } from '@remotion/renderer';
|
|
2
|
+
import type { CloudRunCrashResponse, RenderMediaOnCloudrunOutput } from '../functions/helpers/payloads';
|
|
3
|
+
import type { GcpRegion } from '../pricing/gcp-regions';
|
|
4
|
+
import type { CloudrunCodec } from '../shared/validate-gcp-codec';
|
|
5
|
+
export declare type RenderMediaOnCloudrunInput = {
|
|
6
|
+
cloudRunUrl?: string;
|
|
7
|
+
serviceName?: string;
|
|
8
|
+
region: GcpRegion;
|
|
9
|
+
serveUrl: string;
|
|
10
|
+
composition: string;
|
|
11
|
+
inputProps?: Record<string, unknown>;
|
|
12
|
+
privacy?: 'public' | 'private';
|
|
13
|
+
forceBucketName?: string;
|
|
14
|
+
outName?: string;
|
|
15
|
+
updateRenderProgress?: (progress: number, error?: boolean) => void;
|
|
16
|
+
codec: CloudrunCodec;
|
|
17
|
+
audioCodec?: 'mp3' | 'aac' | 'pcm-16' | 'opus';
|
|
18
|
+
jpegQuality?: number;
|
|
19
|
+
audioBitrate?: string | null;
|
|
20
|
+
videoBitrate?: string | null;
|
|
21
|
+
proResProfile?: '4444-xq' | '4444' | 'hq' | 'standard' | 'light' | 'proxy' | undefined;
|
|
22
|
+
crf?: number | undefined;
|
|
23
|
+
pixelFormat?: 'yuv420p' | 'yuva420p' | 'yuv422p' | 'yuv444p' | 'yuv420p10le' | 'yuv422p10le' | 'yuv444p10le' | 'yuva444p10le';
|
|
24
|
+
imageFormat?: 'png' | 'jpeg' | 'none';
|
|
25
|
+
scale?: number;
|
|
26
|
+
everyNthFrame?: number;
|
|
27
|
+
numberOfGifLoops?: number | null;
|
|
28
|
+
frameRange?: FrameRange;
|
|
29
|
+
envVariables?: Record<string, string>;
|
|
30
|
+
chromiumOptions?: ChromiumOptions;
|
|
31
|
+
muted?: boolean;
|
|
32
|
+
forceWidth?: number | null;
|
|
33
|
+
forceHeight?: number | null;
|
|
34
|
+
logLevel?: LogLevel;
|
|
35
|
+
delayRenderTimeoutInMilliseconds?: number;
|
|
36
|
+
concurrency?: number | string | null;
|
|
37
|
+
enforceAudioTrack?: boolean;
|
|
38
|
+
preferLossless?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* @description Triggers a render on a GCP Cloud Run service given a composition and a Cloud Run URL.
|
|
42
|
+
* @see [Documentation](https://remotion.dev/docs/lambda/renderMediaOnGcp)
|
|
43
|
+
* @param params.cloudRunUrl The URL of the Cloud Run service that should be used. Use either this or serviceName.
|
|
44
|
+
* @param params.serviceName The name of the Cloud Run service that should be used. Use either this or cloudRunUrl.
|
|
45
|
+
* @param params.region The region that the Cloud Run service is deployed in.
|
|
46
|
+
* @param params.serveUrl The URL of the deployed project
|
|
47
|
+
* @param params.composition The ID of the composition which should be rendered.
|
|
48
|
+
* @param params.inputProps The input props that should be passed to the composition.
|
|
49
|
+
* @param params.codec The media codec which should be used for encoding.
|
|
50
|
+
* @param params.forceBucketName The name of the bucket that the output file should be uploaded to.
|
|
51
|
+
* @param params.privacy Whether the output file should be public or private.
|
|
52
|
+
* @param params.outputFile The name of the output file.
|
|
53
|
+
* @param params.updateRenderProgress A callback that is called with the progress of the render.
|
|
54
|
+
* @param params.jpegQuality JPEG quality if JPEG was selected as the image format.
|
|
55
|
+
* @param params.audioCodec The encoding of the audio of the output video.
|
|
56
|
+
* @param params.audioBitrate The target bitrate for the audio of the generated video.
|
|
57
|
+
* @param params.videoBitrate The target bitrate of the generated video.
|
|
58
|
+
* @param params.proResProfile Sets a ProRes profile. Only applies to videos rendered with prores codec.
|
|
59
|
+
* @param params.crf Constant Rate Factor, controlling the quality.
|
|
60
|
+
* @param params.pixelFormat Custom pixel format to use. Usually used for special use cases like transparent videos.
|
|
61
|
+
* @param params.imageFormat Which image format the frames should be rendered in.
|
|
62
|
+
* @param params.scale Scales the output dimensions by a factor.
|
|
63
|
+
* @param params.everyNthFrame Only used if rendering gigs - renders only every nth frame.
|
|
64
|
+
* @param params.numberOfGifLoops Only used if rendering gigs - how many times the gif should loop. Null means infinite.
|
|
65
|
+
* @param params.frameRange Specify a single frame (a number) or a range of frames (a tuple [number, number]) to be rendered.
|
|
66
|
+
* @param params.envVariables Object containing environment variables to be injected in your project.
|
|
67
|
+
* @param params.chromiumOptions Allows you to set certain Chromium / Google Chrome flags.
|
|
68
|
+
* @param params.muted If set to true, no audio is rendered.
|
|
69
|
+
* @param params.forceWidth Overrides default composition width.
|
|
70
|
+
* @param params.forceHeight Overrides default composition height.
|
|
71
|
+
* @param params.logLevel Level of logging that Cloud Run service should perform. Default "info".
|
|
72
|
+
* @param params.delayRenderTimeoutInMilliseconds A number describing how long the render may take to resolve all delayRender() calls before it times out.
|
|
73
|
+
* @param params.concurrency By default, each Cloud Run service renders with concurrency 100% (equal to number of available cores). You may use the option to customize this value.
|
|
74
|
+
* @param params.enforceAudioTrack Render a silent audio track if there wouldn't be any otherwise.
|
|
75
|
+
* @param params.preferLossless Uses a lossless audio codec, if one is available for the codec. If you set audioCodec, it takes priority over preferLossless.
|
|
76
|
+
* @returns {Promise<RenderMediaOnCloudrunOutput>} See documentation for detailed structure
|
|
77
|
+
*/
|
|
78
|
+
export declare const renderMediaOnCloudrun: ({ cloudRunUrl, serviceName, region, serveUrl, composition, inputProps, codec, forceBucketName, privacy, outName, updateRenderProgress, jpegQuality, audioCodec, audioBitrate, videoBitrate, proResProfile, crf, pixelFormat, imageFormat, scale, everyNthFrame, numberOfGifLoops, frameRange, envVariables, chromiumOptions, muted, forceWidth, forceHeight, logLevel, delayRenderTimeoutInMilliseconds, concurrency, enforceAudioTrack, preferLossless, }: RenderMediaOnCloudrunInput) => Promise<RenderMediaOnCloudrunOutput | CloudRunCrashResponse>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderMediaOnCloudrun = void 0;
|
|
4
|
+
const renderer_1 = require("@remotion/renderer");
|
|
5
|
+
const remotion_1 = require("remotion");
|
|
6
|
+
const validate_gcp_codec_1 = require("../shared/validate-gcp-codec");
|
|
7
|
+
const validate_privacy_1 = require("../shared/validate-privacy");
|
|
8
|
+
const validate_serveurl_1 = require("../shared/validate-serveurl");
|
|
9
|
+
const get_or_create_bucket_1 = require("./get-or-create-bucket");
|
|
10
|
+
const get_auth_client_for_url_1 = require("./helpers/get-auth-client-for-url");
|
|
11
|
+
const get_cloudrun_endpoint_1 = require("./helpers/get-cloudrun-endpoint");
|
|
12
|
+
/**
|
|
13
|
+
* @description Triggers a render on a GCP Cloud Run service given a composition and a Cloud Run URL.
|
|
14
|
+
* @see [Documentation](https://remotion.dev/docs/lambda/renderMediaOnGcp)
|
|
15
|
+
* @param params.cloudRunUrl The URL of the Cloud Run service that should be used. Use either this or serviceName.
|
|
16
|
+
* @param params.serviceName The name of the Cloud Run service that should be used. Use either this or cloudRunUrl.
|
|
17
|
+
* @param params.region The region that the Cloud Run service is deployed in.
|
|
18
|
+
* @param params.serveUrl The URL of the deployed project
|
|
19
|
+
* @param params.composition The ID of the composition which should be rendered.
|
|
20
|
+
* @param params.inputProps The input props that should be passed to the composition.
|
|
21
|
+
* @param params.codec The media codec which should be used for encoding.
|
|
22
|
+
* @param params.forceBucketName The name of the bucket that the output file should be uploaded to.
|
|
23
|
+
* @param params.privacy Whether the output file should be public or private.
|
|
24
|
+
* @param params.outputFile The name of the output file.
|
|
25
|
+
* @param params.updateRenderProgress A callback that is called with the progress of the render.
|
|
26
|
+
* @param params.jpegQuality JPEG quality if JPEG was selected as the image format.
|
|
27
|
+
* @param params.audioCodec The encoding of the audio of the output video.
|
|
28
|
+
* @param params.audioBitrate The target bitrate for the audio of the generated video.
|
|
29
|
+
* @param params.videoBitrate The target bitrate of the generated video.
|
|
30
|
+
* @param params.proResProfile Sets a ProRes profile. Only applies to videos rendered with prores codec.
|
|
31
|
+
* @param params.crf Constant Rate Factor, controlling the quality.
|
|
32
|
+
* @param params.pixelFormat Custom pixel format to use. Usually used for special use cases like transparent videos.
|
|
33
|
+
* @param params.imageFormat Which image format the frames should be rendered in.
|
|
34
|
+
* @param params.scale Scales the output dimensions by a factor.
|
|
35
|
+
* @param params.everyNthFrame Only used if rendering gigs - renders only every nth frame.
|
|
36
|
+
* @param params.numberOfGifLoops Only used if rendering gigs - how many times the gif should loop. Null means infinite.
|
|
37
|
+
* @param params.frameRange Specify a single frame (a number) or a range of frames (a tuple [number, number]) to be rendered.
|
|
38
|
+
* @param params.envVariables Object containing environment variables to be injected in your project.
|
|
39
|
+
* @param params.chromiumOptions Allows you to set certain Chromium / Google Chrome flags.
|
|
40
|
+
* @param params.muted If set to true, no audio is rendered.
|
|
41
|
+
* @param params.forceWidth Overrides default composition width.
|
|
42
|
+
* @param params.forceHeight Overrides default composition height.
|
|
43
|
+
* @param params.logLevel Level of logging that Cloud Run service should perform. Default "info".
|
|
44
|
+
* @param params.delayRenderTimeoutInMilliseconds A number describing how long the render may take to resolve all delayRender() calls before it times out.
|
|
45
|
+
* @param params.concurrency By default, each Cloud Run service renders with concurrency 100% (equal to number of available cores). You may use the option to customize this value.
|
|
46
|
+
* @param params.enforceAudioTrack Render a silent audio track if there wouldn't be any otherwise.
|
|
47
|
+
* @param params.preferLossless Uses a lossless audio codec, if one is available for the codec. If you set audioCodec, it takes priority over preferLossless.
|
|
48
|
+
* @returns {Promise<RenderMediaOnCloudrunOutput>} See documentation for detailed structure
|
|
49
|
+
*/
|
|
50
|
+
const renderMediaOnCloudrun = async ({ cloudRunUrl, serviceName, region, serveUrl, composition, inputProps, codec, forceBucketName, privacy, outName, updateRenderProgress, jpegQuality, audioCodec, audioBitrate, videoBitrate, proResProfile, crf, pixelFormat, imageFormat, scale, everyNthFrame, numberOfGifLoops, frameRange, envVariables, chromiumOptions, muted, forceWidth, forceHeight, logLevel, delayRenderTimeoutInMilliseconds, concurrency, enforceAudioTrack, preferLossless, }) => {
|
|
51
|
+
const actualCodec = (0, validate_gcp_codec_1.validateCloudrunCodec)(codec);
|
|
52
|
+
(0, validate_serveurl_1.validateServeUrl)(serveUrl);
|
|
53
|
+
if (privacy)
|
|
54
|
+
(0, validate_privacy_1.validatePrivacy)(privacy);
|
|
55
|
+
const outputBucket = forceBucketName !== null && forceBucketName !== void 0 ? forceBucketName : (await (0, get_or_create_bucket_1.getOrCreateBucket)({ region })).bucketName;
|
|
56
|
+
const cloudRunEndpoint = await (0, get_cloudrun_endpoint_1.getCloudrunEndpoint)({
|
|
57
|
+
cloudRunUrl,
|
|
58
|
+
serviceName,
|
|
59
|
+
region,
|
|
60
|
+
});
|
|
61
|
+
const data = {
|
|
62
|
+
composition,
|
|
63
|
+
serveUrl,
|
|
64
|
+
codec: actualCodec,
|
|
65
|
+
serializedInputPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
|
|
66
|
+
indent: undefined,
|
|
67
|
+
staticBase: null,
|
|
68
|
+
data: inputProps !== null && inputProps !== void 0 ? inputProps : {},
|
|
69
|
+
}).serializedString,
|
|
70
|
+
jpegQuality: jpegQuality !== null && jpegQuality !== void 0 ? jpegQuality : renderer_1.RenderInternals.DEFAULT_JPEG_QUALITY,
|
|
71
|
+
audioCodec: audioCodec !== null && audioCodec !== void 0 ? audioCodec : null,
|
|
72
|
+
audioBitrate: audioBitrate !== null && audioBitrate !== void 0 ? audioBitrate : null,
|
|
73
|
+
videoBitrate: videoBitrate !== null && videoBitrate !== void 0 ? videoBitrate : null,
|
|
74
|
+
crf: crf !== null && crf !== void 0 ? crf : null,
|
|
75
|
+
pixelFormat: pixelFormat !== null && pixelFormat !== void 0 ? pixelFormat : renderer_1.RenderInternals.DEFAULT_PIXEL_FORMAT,
|
|
76
|
+
imageFormat: imageFormat !== null && imageFormat !== void 0 ? imageFormat : renderer_1.RenderInternals.DEFAULT_VIDEO_IMAGE_FORMAT,
|
|
77
|
+
scale: scale !== null && scale !== void 0 ? scale : 1,
|
|
78
|
+
proResProfile: proResProfile !== null && proResProfile !== void 0 ? proResProfile : null,
|
|
79
|
+
everyNthFrame: everyNthFrame !== null && everyNthFrame !== void 0 ? everyNthFrame : 1,
|
|
80
|
+
numberOfGifLoops: numberOfGifLoops !== null && numberOfGifLoops !== void 0 ? numberOfGifLoops : null,
|
|
81
|
+
frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : null,
|
|
82
|
+
envVariables: envVariables !== null && envVariables !== void 0 ? envVariables : {},
|
|
83
|
+
chromiumOptions,
|
|
84
|
+
muted: muted !== null && muted !== void 0 ? muted : false,
|
|
85
|
+
outputBucket,
|
|
86
|
+
privacy,
|
|
87
|
+
outName,
|
|
88
|
+
forceWidth,
|
|
89
|
+
forceHeight,
|
|
90
|
+
type: 'media',
|
|
91
|
+
logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
|
|
92
|
+
delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : renderer_1.RenderInternals.DEFAULT_TIMEOUT,
|
|
93
|
+
concurrency: concurrency !== null && concurrency !== void 0 ? concurrency : null,
|
|
94
|
+
enforceAudioTrack: enforceAudioTrack !== null && enforceAudioTrack !== void 0 ? enforceAudioTrack : false,
|
|
95
|
+
preferLossless: preferLossless !== null && preferLossless !== void 0 ? preferLossless : false,
|
|
96
|
+
};
|
|
97
|
+
const client = await (0, get_auth_client_for_url_1.getAuthClientForUrl)(cloudRunEndpoint);
|
|
98
|
+
const postResponse = await client.request({
|
|
99
|
+
url: cloudRunEndpoint,
|
|
100
|
+
method: 'POST',
|
|
101
|
+
data,
|
|
102
|
+
responseType: 'stream',
|
|
103
|
+
});
|
|
104
|
+
const renderResponse = await new Promise((resolve, reject) => {
|
|
105
|
+
// TODO: Add any sort of type safety
|
|
106
|
+
let response;
|
|
107
|
+
const startTime = Date.now();
|
|
108
|
+
const formattedStartTime = new Date().toISOString();
|
|
109
|
+
const stream = postResponse.data;
|
|
110
|
+
stream.on('data', (chunk) => {
|
|
111
|
+
const chunkResponse = JSON.parse(chunk.toString());
|
|
112
|
+
if (chunkResponse.response) {
|
|
113
|
+
response = chunkResponse.response;
|
|
114
|
+
}
|
|
115
|
+
else if (chunkResponse.onProgress) {
|
|
116
|
+
updateRenderProgress === null || updateRenderProgress === void 0 ? void 0 : updateRenderProgress(chunkResponse.onProgress);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
stream.on('end', () => {
|
|
120
|
+
if (!response) {
|
|
121
|
+
const crashTime = Date.now();
|
|
122
|
+
const formattedCrashTime = new Date().toISOString();
|
|
123
|
+
updateRenderProgress === null || updateRenderProgress === void 0 ? void 0 : updateRenderProgress(0, true);
|
|
124
|
+
resolve({
|
|
125
|
+
status: 'crash',
|
|
126
|
+
cloudRunEndpoint,
|
|
127
|
+
message: 'Service crashed without sending a response. Check the logs in GCP console.',
|
|
128
|
+
requestStartTime: formattedStartTime,
|
|
129
|
+
requestCrashTime: formattedCrashTime,
|
|
130
|
+
requestElapsedTimeInSeconds: (crashTime - startTime) / 1000,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else if (response.status !== 'success' && response.status !== 'crash') {
|
|
134
|
+
throw new Error(response.stack);
|
|
135
|
+
}
|
|
136
|
+
resolve(response);
|
|
137
|
+
});
|
|
138
|
+
stream.on('error', (error) => {
|
|
139
|
+
reject(error);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
return renderResponse;
|
|
143
|
+
};
|
|
144
|
+
exports.renderMediaOnCloudrun = renderMediaOnCloudrun;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ChromiumOptions, LogLevel, StillImageFormat } from '@remotion/renderer';
|
|
2
|
+
import type { RenderStillOnCloudrunOutput } from '../functions/helpers/payloads';
|
|
3
|
+
import type { GcpRegion } from '../pricing/gcp-regions';
|
|
4
|
+
export declare type RenderStillOnCloudrunInput = {
|
|
5
|
+
cloudRunUrl?: string;
|
|
6
|
+
serviceName?: string;
|
|
7
|
+
region: GcpRegion;
|
|
8
|
+
serveUrl: string;
|
|
9
|
+
composition: string;
|
|
10
|
+
inputProps?: Record<string, unknown>;
|
|
11
|
+
privacy?: 'public' | 'private';
|
|
12
|
+
forceBucketName?: string;
|
|
13
|
+
outName?: string;
|
|
14
|
+
imageFormat: StillImageFormat;
|
|
15
|
+
envVariables?: Record<string, string>;
|
|
16
|
+
frame?: number;
|
|
17
|
+
jpegQuality?: number;
|
|
18
|
+
chromiumOptions?: ChromiumOptions;
|
|
19
|
+
scale?: number;
|
|
20
|
+
forceWidth?: number | null;
|
|
21
|
+
forceHeight?: number | null;
|
|
22
|
+
logLevel?: LogLevel;
|
|
23
|
+
delayRenderTimeoutInMilliseconds?: number;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @description Triggers a render on a GCP Cloud Run service given a composition and a Cloud Run URL.
|
|
27
|
+
* @see [Documentation](https://remotion.dev/docs/cloudrun/renderstilloncloudrun)
|
|
28
|
+
* @param params.cloudRunUrl The URL of the Cloud Run service that should be used. Use either this or serviceName.
|
|
29
|
+
* @param params.serviceName The name of the Cloud Run service that should be used. Use either this or cloudRunUrl.
|
|
30
|
+
* @param params.region The region that the Cloud Run service is deployed in.
|
|
31
|
+
* @param params.serveUrl The URL of the deployed project
|
|
32
|
+
* @param params.composition The ID of the composition which should be rendered.
|
|
33
|
+
* @param params.inputProps The input props that should be passed to the composition.
|
|
34
|
+
* @param params.forceBucketName The name of the bucket that the output file should be uploaded to.
|
|
35
|
+
* @param params.privacy Whether the output file should be public or private.
|
|
36
|
+
* @param params.outName The name of the output file.
|
|
37
|
+
* @param params.imageFormat Which image format the frame should be rendered in.
|
|
38
|
+
* @param params.envVariables Object containing environment variables to be injected in your project.
|
|
39
|
+
* @param params.frame Which frame of the composition should be rendered. Frames are zero-indexed.
|
|
40
|
+
* @param params.jpegQuality JPEG quality if JPEG was selected as the image format.
|
|
41
|
+
* @param params.chromiumOptions Allows you to set certain Chromium / Google Chrome flags.
|
|
42
|
+
* @param params.scale Scales the output dimensions by a factor.
|
|
43
|
+
* @param params.forceWidth Overrides default composition width.
|
|
44
|
+
* @param params.forceHeight Overrides default composition height.
|
|
45
|
+
* @param params.logLevel Level of logging that Cloud Run service should perform. Default "info".
|
|
46
|
+
* @param params.delayRenderTimeoutInMilliseconds A number describing how long the render may take to resolve all delayRender() calls before it times out.
|
|
47
|
+
* @returns {Promise<RenderStillOnCloudrunOutput>} See documentation for detailed structure
|
|
48
|
+
*/
|
|
49
|
+
export declare const renderStillOnCloudrun: ({ cloudRunUrl, serviceName, region, serveUrl, composition, inputProps, forceBucketName, privacy, outName, imageFormat, envVariables, frame, jpegQuality, chromiumOptions, scale, forceWidth, forceHeight, logLevel, delayRenderTimeoutInMilliseconds, }: RenderStillOnCloudrunInput) => Promise<RenderStillOnCloudrunOutput>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderStillOnCloudrun = void 0;
|
|
4
|
+
const renderer_1 = require("@remotion/renderer");
|
|
5
|
+
const remotion_1 = require("remotion");
|
|
6
|
+
const validate_privacy_1 = require("../shared/validate-privacy");
|
|
7
|
+
const validate_serveurl_1 = require("../shared/validate-serveurl");
|
|
8
|
+
const get_or_create_bucket_1 = require("./get-or-create-bucket");
|
|
9
|
+
const get_auth_client_for_url_1 = require("./helpers/get-auth-client-for-url");
|
|
10
|
+
const get_cloudrun_endpoint_1 = require("./helpers/get-cloudrun-endpoint");
|
|
11
|
+
/**
|
|
12
|
+
* @description Triggers a render on a GCP Cloud Run service given a composition and a Cloud Run URL.
|
|
13
|
+
* @see [Documentation](https://remotion.dev/docs/cloudrun/renderstilloncloudrun)
|
|
14
|
+
* @param params.cloudRunUrl The URL of the Cloud Run service that should be used. Use either this or serviceName.
|
|
15
|
+
* @param params.serviceName The name of the Cloud Run service that should be used. Use either this or cloudRunUrl.
|
|
16
|
+
* @param params.region The region that the Cloud Run service is deployed in.
|
|
17
|
+
* @param params.serveUrl The URL of the deployed project
|
|
18
|
+
* @param params.composition The ID of the composition which should be rendered.
|
|
19
|
+
* @param params.inputProps The input props that should be passed to the composition.
|
|
20
|
+
* @param params.forceBucketName The name of the bucket that the output file should be uploaded to.
|
|
21
|
+
* @param params.privacy Whether the output file should be public or private.
|
|
22
|
+
* @param params.outName The name of the output file.
|
|
23
|
+
* @param params.imageFormat Which image format the frame should be rendered in.
|
|
24
|
+
* @param params.envVariables Object containing environment variables to be injected in your project.
|
|
25
|
+
* @param params.frame Which frame of the composition should be rendered. Frames are zero-indexed.
|
|
26
|
+
* @param params.jpegQuality JPEG quality if JPEG was selected as the image format.
|
|
27
|
+
* @param params.chromiumOptions Allows you to set certain Chromium / Google Chrome flags.
|
|
28
|
+
* @param params.scale Scales the output dimensions by a factor.
|
|
29
|
+
* @param params.forceWidth Overrides default composition width.
|
|
30
|
+
* @param params.forceHeight Overrides default composition height.
|
|
31
|
+
* @param params.logLevel Level of logging that Cloud Run service should perform. Default "info".
|
|
32
|
+
* @param params.delayRenderTimeoutInMilliseconds A number describing how long the render may take to resolve all delayRender() calls before it times out.
|
|
33
|
+
* @returns {Promise<RenderStillOnCloudrunOutput>} See documentation for detailed structure
|
|
34
|
+
*/
|
|
35
|
+
const renderStillOnCloudrun = async ({ cloudRunUrl, serviceName, region, serveUrl, composition, inputProps, forceBucketName, privacy, outName, imageFormat, envVariables, frame, jpegQuality, chromiumOptions, scale, forceWidth, forceHeight, logLevel, delayRenderTimeoutInMilliseconds, }) => {
|
|
36
|
+
(0, validate_serveurl_1.validateServeUrl)(serveUrl);
|
|
37
|
+
if (privacy)
|
|
38
|
+
(0, validate_privacy_1.validatePrivacy)(privacy);
|
|
39
|
+
const outputBucket = forceBucketName !== null && forceBucketName !== void 0 ? forceBucketName : (await (0, get_or_create_bucket_1.getOrCreateBucket)({ region })).bucketName;
|
|
40
|
+
const cloudRunEndpoint = await (0, get_cloudrun_endpoint_1.getCloudrunEndpoint)({
|
|
41
|
+
cloudRunUrl,
|
|
42
|
+
serviceName,
|
|
43
|
+
region,
|
|
44
|
+
});
|
|
45
|
+
const data = {
|
|
46
|
+
composition,
|
|
47
|
+
serveUrl,
|
|
48
|
+
serializedInputPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
|
|
49
|
+
indent: undefined,
|
|
50
|
+
staticBase: null,
|
|
51
|
+
data: inputProps !== null && inputProps !== void 0 ? inputProps : {},
|
|
52
|
+
}).serializedString,
|
|
53
|
+
outputBucket,
|
|
54
|
+
outName,
|
|
55
|
+
privacy: privacy !== null && privacy !== void 0 ? privacy : 'public',
|
|
56
|
+
imageFormat,
|
|
57
|
+
envVariables: envVariables !== null && envVariables !== void 0 ? envVariables : {},
|
|
58
|
+
jpegQuality,
|
|
59
|
+
chromiumOptions,
|
|
60
|
+
scale: scale !== null && scale !== void 0 ? scale : 1,
|
|
61
|
+
forceWidth,
|
|
62
|
+
forceHeight,
|
|
63
|
+
frame: frame !== null && frame !== void 0 ? frame : 0,
|
|
64
|
+
type: 'still',
|
|
65
|
+
logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
|
|
66
|
+
delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : renderer_1.RenderInternals.DEFAULT_TIMEOUT,
|
|
67
|
+
};
|
|
68
|
+
const client = await (0, get_auth_client_for_url_1.getAuthClientForUrl)(cloudRunEndpoint);
|
|
69
|
+
const renderResponse = await client.request({
|
|
70
|
+
url: cloudRunUrl,
|
|
71
|
+
method: 'POST',
|
|
72
|
+
data,
|
|
73
|
+
});
|
|
74
|
+
return renderResponse.data;
|
|
75
|
+
};
|
|
76
|
+
exports.renderStillOnCloudrun = renderStillOnCloudrun;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Speculate the name of a Cloud Run service that will be created when you call `deployService`, based on the service configuration.
|
|
3
|
+
* @see [Documentation](https://www.remotion.dev/docs/cloudrun/speculateservicename)
|
|
4
|
+
* @param memoryLimit The upper bound on the amount of RAM that the Cloud Run service can consume.
|
|
5
|
+
* @param cpuLimit The maximum number of CPU cores that the Cloud Run service can use to process requests.
|
|
6
|
+
* @param timeoutInSeconds How long the Cloud Run Service may run before it gets killed.
|
|
7
|
+
* @returns {string} The speculated Cloud Run service name
|
|
8
|
+
*/
|
|
9
|
+
export declare const speculateServiceName: ({ memoryLimit, cpuLimit, timeoutSeconds, }: {
|
|
10
|
+
memoryLimit: string;
|
|
11
|
+
cpuLimit: string;
|
|
12
|
+
timeoutSeconds: number;
|
|
13
|
+
}) => string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.speculateServiceName = void 0;
|
|
4
|
+
const generate_service_name_1 = require("../shared/generate-service-name");
|
|
5
|
+
/**
|
|
6
|
+
* @description Speculate the name of a Cloud Run service that will be created when you call `deployService`, based on the service configuration.
|
|
7
|
+
* @see [Documentation](https://www.remotion.dev/docs/cloudrun/speculateservicename)
|
|
8
|
+
* @param memoryLimit The upper bound on the amount of RAM that the Cloud Run service can consume.
|
|
9
|
+
* @param cpuLimit The maximum number of CPU cores that the Cloud Run service can use to process requests.
|
|
10
|
+
* @param timeoutInSeconds How long the Cloud Run Service may run before it gets killed.
|
|
11
|
+
* @returns {string} The speculated Cloud Run service name
|
|
12
|
+
*/
|
|
13
|
+
const speculateServiceName = ({ memoryLimit, cpuLimit, timeoutSeconds, }) => {
|
|
14
|
+
return (0, generate_service_name_1.generateServiceName)({
|
|
15
|
+
memoryLimit,
|
|
16
|
+
cpuLimit,
|
|
17
|
+
timeoutSeconds,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
exports.speculateServiceName = speculateServiceName;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const remotion_1 = require("remotion");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const parse_service_name_1 = require("../helpers/parse-service-name");
|
|
6
|
+
const speculate_service_name_1 = require("../speculate-service-name");
|
|
7
|
+
const dashedVersion = remotion_1.VERSION.replace(/\./g, '-');
|
|
8
|
+
const region = 'asia-east1';
|
|
9
|
+
process.env.REMOTION_GCP_PROJECT_ID = 'remotion-test-project';
|
|
10
|
+
(0, vitest_1.test)('Parse service names', () => {
|
|
11
|
+
const shortServiceName = (0, speculate_service_name_1.speculateServiceName)({
|
|
12
|
+
cpuLimit: '8.0',
|
|
13
|
+
memoryLimit: '100000k',
|
|
14
|
+
// max timeout
|
|
15
|
+
timeoutSeconds: 3600,
|
|
16
|
+
});
|
|
17
|
+
(0, vitest_1.expect)(shortServiceName).toBe(`remotion-${remotion_1.VERSION.replace(/\./g, '-')}-mem100000k-cpu8-0-t3600`);
|
|
18
|
+
const fullServiceName = `${(0, parse_service_name_1.getGcpParent)(region)}/services/${shortServiceName}`;
|
|
19
|
+
const parsed = (0, parse_service_name_1.parseServiceName)(fullServiceName, region);
|
|
20
|
+
(0, vitest_1.expect)(parsed).toEqual({
|
|
21
|
+
consoleUrl: `https://console.cloud.google.com/run/detail/asia-east1/remotion-${dashedVersion}-mem100000k-cpu8-0-t3600/logs`,
|
|
22
|
+
region: 'asia-east1',
|
|
23
|
+
remotionVersion: remotion_1.VERSION.replace(/\./g, '-'),
|
|
24
|
+
serviceName: `remotion-${dashedVersion}-mem100000k-cpu8-0-t3600`,
|
|
25
|
+
});
|
|
26
|
+
// Max length of service name is 49 characters, asking for less in case the version string gets longer
|
|
27
|
+
(0, vitest_1.expect)(shortServiceName.length).toBeLessThanOrEqual(47);
|
|
28
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare type UploadDirProgress = {
|
|
2
|
+
totalFiles: number;
|
|
3
|
+
filesUploaded: number;
|
|
4
|
+
totalSize: number;
|
|
5
|
+
sizeUploaded: number;
|
|
6
|
+
};
|
|
7
|
+
export declare type MockFile = {
|
|
8
|
+
name: string;
|
|
9
|
+
content: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const getDirFiles: (entry: string) => MockFile[];
|
|
12
|
+
export declare const uploadDir: ({ bucket, localDir, onProgress, keyPrefix, toUpload, }: {
|
|
13
|
+
bucket: string;
|
|
14
|
+
localDir: string;
|
|
15
|
+
keyPrefix: string;
|
|
16
|
+
onProgress: (progress: UploadDirProgress) => void;
|
|
17
|
+
toUpload: string[];
|
|
18
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,81 @@
|
|
|
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.uploadDir = exports.getDirFiles = void 0;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const make_storage_key_1 = require("../shared/make-storage-key");
|
|
10
|
+
const get_cloud_storage_client_1 = require("./helpers/get-cloud-storage-client");
|
|
11
|
+
const getDirFiles = (entry) => {
|
|
12
|
+
throw new TypeError('should only be executed in test ' + JSON.stringify(entry));
|
|
13
|
+
};
|
|
14
|
+
exports.getDirFiles = getDirFiles;
|
|
15
|
+
const uploadDir = async ({ bucket, localDir, onProgress, keyPrefix, toUpload, }) => {
|
|
16
|
+
const files = await getFiles(localDir, localDir, toUpload);
|
|
17
|
+
const progresses = {};
|
|
18
|
+
for (const file of files) {
|
|
19
|
+
progresses[file.name] = 0;
|
|
20
|
+
}
|
|
21
|
+
async function getFiles(directory, originalDirectory, filesToUpload) {
|
|
22
|
+
const dirents = await fs_1.promises.readdir(directory, { withFileTypes: true });
|
|
23
|
+
const _files = await Promise.all(dirents
|
|
24
|
+
.map((dirent) => {
|
|
25
|
+
const res = path_1.default.resolve(directory, dirent.name);
|
|
26
|
+
return [dirent, res];
|
|
27
|
+
})
|
|
28
|
+
.filter(([dirent, res]) => {
|
|
29
|
+
const relative = path_1.default.relative(originalDirectory, res);
|
|
30
|
+
if (dirent.isDirectory()) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (!filesToUpload.includes(relative)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
})
|
|
38
|
+
.map(async ([dirent, res]) => {
|
|
39
|
+
const { size } = await fs_1.promises.stat(res);
|
|
40
|
+
return dirent.isDirectory()
|
|
41
|
+
? getFiles(res, originalDirectory, filesToUpload)
|
|
42
|
+
: [
|
|
43
|
+
{
|
|
44
|
+
name: res,
|
|
45
|
+
size,
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
}));
|
|
49
|
+
return _files.flat(1);
|
|
50
|
+
}
|
|
51
|
+
const cloudStorageClient = (0, get_cloud_storage_client_1.getCloudStorageClient)();
|
|
52
|
+
const uploads = files.map((file) => {
|
|
53
|
+
const filePath = file.name;
|
|
54
|
+
const destination = (0, make_storage_key_1.makeStorageKey)(keyPrefix, localDir, filePath);
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
(0, fs_1.createReadStream)(filePath)
|
|
57
|
+
.pipe(cloudStorageClient
|
|
58
|
+
.bucket(bucket)
|
|
59
|
+
.file(destination)
|
|
60
|
+
.createWriteStream({ public: true }))
|
|
61
|
+
.on('error', (error) => reject(error))
|
|
62
|
+
.on('progress', (p) => {
|
|
63
|
+
var _a;
|
|
64
|
+
progresses[filePath] = (_a = p.bytesWritten) !== null && _a !== void 0 ? _a : 0;
|
|
65
|
+
})
|
|
66
|
+
.on('finish', () => resolve('done'));
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
const promise = Promise.all(uploads);
|
|
70
|
+
const interval = setInterval(() => {
|
|
71
|
+
onProgress({
|
|
72
|
+
totalSize: files.map((f) => f.size).reduce((a, b) => a + b, 0),
|
|
73
|
+
sizeUploaded: Object.values(progresses).reduce((a, b) => a + b, 0),
|
|
74
|
+
totalFiles: files.length,
|
|
75
|
+
filesUploaded: files.filter((f) => progresses[f.name] === f.size).length,
|
|
76
|
+
});
|
|
77
|
+
}, 1000);
|
|
78
|
+
await promise;
|
|
79
|
+
clearInterval(interval);
|
|
80
|
+
};
|
|
81
|
+
exports.uploadDir = uploadDir;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="minimist" />
|
|
2
|
+
import type { GcpRegion } from '../pricing/gcp-regions';
|
|
3
|
+
declare type servicesCommandLineOptions = {
|
|
4
|
+
help: boolean;
|
|
5
|
+
region: GcpRegion;
|
|
6
|
+
['project-id']: string;
|
|
7
|
+
['service-name']: string;
|
|
8
|
+
y: boolean;
|
|
9
|
+
yes: boolean;
|
|
10
|
+
force: boolean;
|
|
11
|
+
f: boolean;
|
|
12
|
+
['max-retries']: number;
|
|
13
|
+
['out-name']: string | undefined;
|
|
14
|
+
['output-bucket']: string;
|
|
15
|
+
['output-folder-path']: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const parsedCloudrunCli: servicesCommandLineOptions & import("minimist").ParsedArgs;
|
|
18
|
+
export declare const forceFlagProvided: boolean;
|
|
19
|
+
export {};
|
package/dist/cli/args.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.forceFlagProvided = exports.parsedCloudrunCli = void 0;
|
|
4
|
+
const cli_1 = require("@remotion/cli");
|
|
5
|
+
exports.parsedCloudrunCli = cli_1.CliInternals.minimist(process.argv.slice(2), {
|
|
6
|
+
boolean: cli_1.CliInternals.BooleanFlags,
|
|
7
|
+
});
|
|
8
|
+
exports.forceFlagProvided = exports.parsedCloudrunCli.f ||
|
|
9
|
+
exports.parsedCloudrunCli.force ||
|
|
10
|
+
exports.parsedCloudrunCli.yes ||
|
|
11
|
+
exports.parsedCloudrunCli.y;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.permissionsCommand = exports.PERMISSIONS_COMMAND = void 0;
|
|
4
|
+
const cli_1 = require("@remotion/cli");
|
|
5
|
+
const testPermissions_1 = require("../../api/iam-validation/testPermissions");
|
|
6
|
+
const log_1 = require("../log");
|
|
7
|
+
exports.PERMISSIONS_COMMAND = 'permissions';
|
|
8
|
+
const permissionsCommand = async () => {
|
|
9
|
+
try {
|
|
10
|
+
log_1.Log.info(cli_1.CliInternals.chalk.blueBright(`Checking permissions for ${process.env.REMOTION_GCP_CLIENT_EMAIL} in project ${process.env.REMOTION_GCP_PROJECT_ID}.`));
|
|
11
|
+
log_1.Log.info();
|
|
12
|
+
await (0, testPermissions_1.testPermissions)({
|
|
13
|
+
onTest: (res) => {
|
|
14
|
+
log_1.Log.info((0, testPermissions_1.logPermissionOutput)(res));
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
log_1.Log.error('Did not have the required permissions on GCP:');
|
|
20
|
+
log_1.Log.error(err);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.permissionsCommand = permissionsCommand;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.regionsCommand = exports.REGIONS_COMMAND = void 0;
|
|
4
|
+
const cli_1 = require("@remotion/cli");
|
|
5
|
+
const regions_1 = require("../../regions");
|
|
6
|
+
exports.REGIONS_COMMAND = 'regions';
|
|
7
|
+
const regionsCommand = () => {
|
|
8
|
+
cli_1.CliInternals.Log.info(regions_1.GCP_REGIONS.join(' '));
|
|
9
|
+
};
|
|
10
|
+
exports.regionsCommand = regionsCommand;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const renderArgsCheck: (subcommand: string, args: string[]) => Promise<{
|
|
2
|
+
serveUrl: string;
|
|
3
|
+
cloudRunUrl: any;
|
|
4
|
+
outName: string | undefined;
|
|
5
|
+
forceBucketName: any;
|
|
6
|
+
privacy: import("../../../../shared/constants").Privacy;
|
|
7
|
+
downloadName: string;
|
|
8
|
+
region: "asia-east1" | "asia-east2" | "asia-northeast1" | "asia-northeast2" | "asia-northeast3" | "asia-south1" | "asia-south2" | "asia-southeast1" | "asia-southeast2" | "australia-southeast1" | "australia-southeast2" | "europe-central2" | "europe-north1" | "europe-southwest1" | "europe-west1" | "europe-west2" | "europe-west3" | "europe-west4" | "europe-west6" | "europe-west8" | "europe-west9" | "me-west1" | "northamerica-northeast1" | "northamerica-northeast2" | "southamerica-east1" | "southamerica-west1" | "us-central1" | "us-east1" | "us-east4" | "us-east5" | "us-south1" | "us-west1" | "us-west2" | "us-west3" | "us-west4";
|
|
9
|
+
}>;
|