@remotion/studio
Version:
APIs for interacting with the Remotion Studio
49 lines (48 loc) • 2.08 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const client_1 = __importDefault(require("react-dom/client"));
const remotion_1 = require("remotion");
const no_react_1 = require("remotion/no-react");
const NoRegisterRoot_1 = require("./components/NoRegisterRoot");
const entry_basic_1 = require("./error-overlay/entry-basic");
const client_2 = require("./hot-middleware-client/client");
const Studio_1 = require("./Studio");
remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultPreviewCSS(null, '#1f2428'));
if (!window.__remotionOverlayStarted) {
window.__remotionOverlayStarted = true;
try {
(0, entry_basic_1.startErrorOverlay)();
(0, client_2.enableHotMiddleware)();
}
catch (err) {
// eslint-disable-next-line no-console
console.error('Failed to initialize error overlay', err);
}
}
let root = null;
const getRootForElement = () => {
if (root) {
return root;
}
root = client_1.default.createRoot(remotion_1.Internals.getPreviewDomElement());
return root;
};
const renderToDOM = (content) => {
if (!client_1.default.createRoot) {
if (no_react_1.NoReactInternals.ENABLE_V5_BREAKING_CHANGES) {
throw new Error('Remotion 5.0 does only support React 18+. However, ReactDOM.createRoot() is undefined.');
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
client_1.default.render(content, remotion_1.Internals.getPreviewDomElement());
return;
}
getRootForElement().render(content);
};
renderToDOM(jsx_runtime_1.jsx(NoRegisterRoot_1.NoRegisterRoot, {}));
remotion_1.Internals.waitForRoot((NewRoot) => {
renderToDOM(jsx_runtime_1.jsx(Studio_1.Studio, { readOnly: false, rootComponent: NewRoot, visualModeEnabled: Boolean(process.env.EXPERIMENTAL_VISUAL_MODE_ENABLED) }));
});