UNPKG

@remotion/studio

Version:

APIs for interacting with the Remotion Studio

34 lines (33 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.calcNewProps = void 0; const remotion_1 = require("remotion"); const calcNewProps = (compositionId, defaultProps) => { var _a; if (!(0, remotion_1.getRemotionEnvironment)().isStudio) { throw new Error('saveDefaultProps can only be called in the Remotion Studio.'); } const { compositionsRef } = remotion_1.Internals; const compositionsStore = compositionsRef.current; if (!compositionsStore) { throw new Error('No compositions ref found. Are you in the Remotion Studio and are the Remotion versions aligned?'); } const compositions = compositionsStore.getCompositions(); const composition = compositions.find((c) => c.id === compositionId); if (!composition) { throw new Error(`No composition with the ID ${compositionId} found. Available compositions: ${compositions.map((c) => c.id).join(', ')}`); } const savedDefaultProps = (_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {}; const generatedDefaultProps = defaultProps({ schema: composition.schema, savedDefaultProps, // Kept for backwards compatibility - since all props are now // immediately saved, this is the same as savedDefaultProps. unsavedDefaultProps: savedDefaultProps, }); return { composition, generatedDefaultProps, }; }; exports.calcNewProps = calcNewProps;