| ; | |
| var __importDefault = (this && this.__importDefault) || function (mod) { | |
| return (mod && mod.__esModule) ? mod : { "default": mod }; | |
| }; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.getInputProps = void 0; | |
| const node_fs_1 = __importDefault(require("node:fs")); | |
| const node_os_1 = __importDefault(require("node:os")); | |
| const node_path_1 = __importDefault(require("node:path")); | |
| const client_1 = require("@remotion/renderer/client"); | |
| const log_1 = require("./log"); | |
| const parsed_cli_1 = require("./parsed-cli"); | |
| const { propsOption } = client_1.BrowserSafeApis.options; | |
| const getInputProps = (onUpdate, logLevel) => { | |
| const props = propsOption.getValue({ commandLine: parsed_cli_1.parsedCli }).value; | |
| if (!props) { | |
| return {}; | |
| } | |
| const jsonFile = node_path_1.default.resolve(process.cwd(), props); | |
| try { | |
| if (node_fs_1.default.existsSync(jsonFile)) { | |
| // Windows PowerShell 5.1 and some editors save UTF-8 with a BOM, | |
| // which JSON.parse() rejects. | |
| const rawJsonData = node_fs_1.default | |
| .readFileSync(jsonFile, 'utf-8') | |
| .replace(/^\uFEFF/, ''); | |
| if (onUpdate) { | |
| node_fs_1.default.watchFile(jsonFile, { interval: 100 }, () => { | |
| try { | |
| onUpdate(JSON.parse(node_fs_1.default.readFileSync(jsonFile, 'utf-8').replace(/^\uFEFF/, ''))); | |
| log_1.Log.info({ indent: false, logLevel }, `Updated input props from ${jsonFile}.`); | |
| } | |
| catch (_a) { | |
| log_1.Log.error({ indent: false, logLevel }, `${jsonFile} contains invalid JSON. Did not apply new input props.`); | |
| } | |
| }); | |
| } | |
| return JSON.parse(rawJsonData); | |
| } | |
| return JSON.parse(props); | |
| } | |
| catch (_a) { | |
| log_1.Log.error({ indent: false, logLevel }, 'You passed --props but it was neither valid JSON nor a file path to a valid JSON file. Provided value: ' + | |
| props); | |
| log_1.Log.info({ indent: false, logLevel }, 'Got the following value:', props); | |
| log_1.Log.error({ indent: false, logLevel }, 'Check that your input is parseable using `JSON.parse` and try again.'); | |
| if (node_os_1.default.platform() === 'win32') { | |
| const logOptions = { | |
| indent: false, | |
| logLevel, | |
| }; | |
| log_1.Log.warn(logOptions, 'Note: Windows handles escaping of quotes very weirdly in the command line.'); | |
| log_1.Log.warn(logOptions, 'This might have led to you having this problem.'); | |
| log_1.Log.warn(logOptions, 'Consider using the alternative API for --props which is to pass'); | |
| log_1.Log.warn(logOptions, 'a path to a JSON file:'); | |
| log_1.Log.warn(logOptions, ' --props=path/to/props.json'); | |
| } | |
| process.exit(1); | |
| } | |
| }; | |
| exports.getInputProps = getInputProps; | |
Xet Storage Details
- Size:
- 3 kB
- Xet hash:
- a8cf6d5b1a6c8f97961394fbe8f0e20600e812c00cd5a247da84d8d5ce8692c4
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.