UNPKG

remotion

Version:

Make videos programmatically

36 lines (35 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateRenderAsset = exports.validateArtifactFilename = void 0; const validateArtifactFilename = (filename) => { if (typeof filename !== 'string') { throw new TypeError(`The "filename" must be a string, but you passed a value of type ${typeof filename}`); } if (filename.trim() === '') { throw new Error('The `filename` must not be empty'); } if (!filename.match(/^([0-9a-zA-Z-!_.*'()/:&$@=;+,?]+)/g)) { throw new Error('The `filename` must match "/^([0-9a-zA-Z-!_.*\'()/:&$@=;+,?]+)/g". Use forward slashes only, even on Windows.'); } }; exports.validateArtifactFilename = validateArtifactFilename; const validateContent = (content) => { if (typeof content !== 'string' && !(content instanceof Uint8Array)) { throw new TypeError(`The "content" must be a string or Uint8Array, but you passed a value of type ${typeof content}`); } if (typeof content === 'string' && content.trim() === '') { throw new Error('The `content` must not be empty'); } }; const validateRenderAsset = (artifact) => { // We don't have validation for it yet if (artifact.type !== 'artifact') { return; } (0, exports.validateArtifactFilename)(artifact.filename); if (artifact.contentType === 'thumbnail') { return; } validateContent(artifact.content); }; exports.validateRenderAsset = validateRenderAsset;