Add .gitignore to exclude all node packages and lock files

This commit is contained in:
Adolfo Reyna
2026-02-23 21:56:04 -05:00
parent faae96c9ed
commit dcc5c6c044
9747 changed files with 1555105 additions and 2 deletions
@@ -0,0 +1,4 @@
import type { CompositionProps, StillProps } from 'remotion';
import type { AnyZodObject } from 'zod';
export declare const createComposition: <Schema extends AnyZodObject, Props extends Record<string, unknown>>({ ...other }: CompositionProps<Schema, Props>) => () => import("react/jsx-runtime").JSX.Element;
export declare const createStill: <Schema extends AnyZodObject, Props extends Record<string, unknown>>({ ...other }: StillProps<Schema, Props>) => () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createStill = exports.createComposition = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const remotion_1 = require("remotion");
const createComposition = ({ ...other }) => () => {
// @ts-expect-error
return (0, jsx_runtime_1.jsx)(remotion_1.Composition, { ...other });
};
exports.createComposition = createComposition;
const createStill = ({ ...other }) => () => {
// @ts-expect-error
return (0, jsx_runtime_1.jsx)(remotion_1.Still, { ...other });
};
exports.createStill = createStill;
@@ -0,0 +1,3 @@
import type { DeleteStaticFileResponse } from '@remotion/studio-shared';
export declare const deleteStaticFile: (relativePath: string) => Promise<DeleteStaticFileResponse>;
export { DeleteStaticFileResponse };
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteStaticFile = void 0;
const remotion_1 = require("remotion");
const call_api_1 = require("../components/call-api");
const deleteStaticFile = async (relativePath) => {
if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
throw new Error('deleteStaticFile() is only available in the Studio');
}
if (window.remotion_isReadOnlyStudio) {
throw new Error('deleteStaticFile() is not available in Read-Only Studio');
}
if (relativePath.startsWith(window.remotion_staticBase)) {
relativePath = relativePath.substring(window.remotion_staticBase.length + 1);
}
const res = await (0, call_api_1.callApi)('/api/delete-static-file', { relativePath });
return res;
};
exports.deleteStaticFile = deleteStaticFile;
@@ -0,0 +1,7 @@
import type { JSONPath } from '../components/RenderModal/SchemaEditor/zod-types';
export declare const focusDefaultPropsPath: ({ path, scrollBehavior, }: {
path: JSONPath;
scrollBehavior?: ScrollBehavior;
}) => {
success: boolean;
};
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.focusDefaultPropsPath = void 0;
const scroll_to_default_props_path_1 = require("../components/RenderModal/SchemaEditor/scroll-to-default-props-path");
const focusDefaultPropsPath = ({ path, scrollBehavior, }) => {
const currentlyActive = document.querySelector(`.${scroll_to_default_props_path_1.DEFAULT_PROPS_PATH_ACTIVE_CLASSNAME}`);
if (currentlyActive !== null) {
currentlyActive.classList.remove(scroll_to_default_props_path_1.DEFAULT_PROPS_PATH_ACTIVE_CLASSNAME);
}
const query = document.querySelector(`.${scroll_to_default_props_path_1.DEFAULT_PROPS_PATH_CLASSNAME}[data-json-path="${path.join('.')}"]`);
if (query === null) {
return {
success: false,
};
}
query.scrollIntoView({ behavior: scrollBehavior });
query.classList.add(scroll_to_default_props_path_1.DEFAULT_PROPS_PATH_ACTIVE_CLASSNAME);
return {
success: true,
};
};
exports.focusDefaultPropsPath = focusDefaultPropsPath;
@@ -0,0 +1,17 @@
export declare const getStaticFiles: () => StaticFile[];
export type StaticFile = {
/**
* A string that you can pass to the `src` attribute of an `<Audio>`, `<Img>`, `<Video>`, `<Html5Audio>`, `<Html5Video>` or `<OffthreadVideo>` element.
*/
src: string;
/**
* The filepath of the file, relative to the public folder.
* Example: `subfolder/image.png`
*/
name: string;
sizeInBytes: number;
/**
* UNIX timestamp in milliseconds
*/
lastModified: number;
};
@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStaticFiles = void 0;
let warnedServer = false;
let warnedPlayer = false;
const warnServerOnce = () => {
if (warnedServer) {
return;
}
warnedServer = true;
// eslint-disable-next-line no-console
console.warn('Called getStaticFiles() on the server. The API is only available in the browser. An empty array was returned.');
};
const warnPlayerOnce = () => {
if (warnedPlayer) {
return;
}
warnedPlayer = true;
// eslint-disable-next-line no-console
console.warn('Called getStaticFiles() while using the Remotion Player. The API is only available while using the Remotion Studio. An empty array was returned.');
};
/*
* @description Gets an array containing all files in the `public/` folder. You can reference them by using `staticFile()`.
* @see [Documentation](https://www.remotion.dev/docs/studio/get-static-files)
*/
const getStaticFiles = () => {
if (typeof document === 'undefined') {
warnServerOnce();
return [];
}
if (window.remotion_isPlayer) {
warnPlayerOnce();
return [];
}
return window.remotion_staticFiles;
};
exports.getStaticFiles = getStaticFiles;
@@ -0,0 +1,2 @@
import type { ZodType } from '../components/get-zod-if-possible';
export declare const getZodSchemaFromPrimitive: (value: unknown, z: ZodType) => import("zod").ZodString | import("zod").ZodNumber;
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getZodSchemaFromPrimitive = void 0;
const getZodSchemaFromPrimitive = (value, z) => {
if (typeof value === 'string') {
return z.string();
}
if (typeof value === 'number') {
return z.number();
}
let stringified;
try {
stringified = JSON.stringify(value);
}
catch (_a) { }
throw new Error(`visualControl(): Specify a schema for this value: ${stringified !== null && stringified !== void 0 ? stringified : '[non-serializable value]'}. See https://remotion.dev/docs/studio/visual-control`);
};
exports.getZodSchemaFromPrimitive = getZodSchemaFromPrimitive;
@@ -0,0 +1,6 @@
/**
* Selects a composition in the Remotion Studio.
* @param compositionId - The ID of the composition to select.
* @see [Documentation](/docs/studio/go-to-composition)
*/
export declare const goToComposition: (compositionId: string) => void;
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.goToComposition = void 0;
const remotion_1 = require("remotion");
/**
* Selects a composition in the Remotion Studio.
* @param compositionId - The ID of the composition to select.
* @see [Documentation](/docs/studio/go-to-composition)
*/
const goToComposition = (compositionId) => {
var _a;
(_a = remotion_1.Internals.compositionSelectorRef.current) === null || _a === void 0 ? void 0 : _a.selectComposition(compositionId);
};
exports.goToComposition = goToComposition;
@@ -0,0 +1,11 @@
import type { _InternalTypes } from 'remotion';
import type { AnyZodObject } from 'zod';
export type UpdateDefaultPropsFunction = (currentValues: {
schema: AnyZodObject | null;
savedDefaultProps: Record<string, unknown>;
unsavedDefaultProps: Record<string, unknown>;
}) => Record<string, unknown>;
export declare const calcNewProps: (compositionId: string, defaultProps: UpdateDefaultPropsFunction) => {
composition: _InternalTypes["AnyComposition"];
generatedDefaultProps: Record<string, unknown>;
};
@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.calcNewProps = void 0;
const remotion_1 = require("remotion");
const calcNewProps = (compositionId, defaultProps) => {
var _a, _b;
if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
throw new Error('saveDefaultProps can only be called in the Remotion Studio.');
}
const { compositionsRef, editorPropsProviderRef } = 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 propsStore = editorPropsProviderRef.current;
if (!propsStore) {
throw new Error('No props store found. Are you in the Remotion Studio and are the Remotion versions aligned?');
}
const savedDefaultProps = (_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {};
const unsavedDefaultProps = (_b = propsStore.getProps()[compositionId]) !== null && _b !== void 0 ? _b : savedDefaultProps;
const generatedDefaultProps = defaultProps({
schema: composition.schema,
savedDefaultProps,
unsavedDefaultProps,
});
return {
composition,
generatedDefaultProps,
};
};
exports.calcNewProps = calcNewProps;
@@ -0,0 +1,2 @@
import type { InstallPackageResponse } from '@remotion/studio-shared';
export declare const installPackages: (packageNames: string[]) => Promise<InstallPackageResponse>;
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.installPackages = void 0;
const remotion_1 = require("remotion");
const call_api_1 = require("../components/call-api");
const installPackages = (packageNames) => {
if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
throw new Error('installPackages() is only available in the Studio');
}
if (window.remotion_isReadOnlyStudio) {
throw new Error('installPackages() is not available in Read-Only Studio');
}
return (0, call_api_1.callApi)('/api/install-package', { packageNames });
};
exports.installPackages = installPackages;
@@ -0,0 +1 @@
export declare const pause: () => void;
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pause = void 0;
const remotion_1 = require("remotion");
/*
* @description Pause the current composition.
* @see [Documentation](https://www.remotion.dev/docs/studio/pause)
*/
const pause = () => {
var _a;
(_a = remotion_1.Internals.timeValueRef.current) === null || _a === void 0 ? void 0 : _a.pause();
};
exports.pause = pause;
@@ -0,0 +1,2 @@
import type { SyntheticEvent } from 'react';
export declare const play: (e?: SyntheticEvent | PointerEvent) => void;
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.play = void 0;
const remotion_1 = require("remotion");
/*
* @description Play the current composition.
* @see [Documentation](https://www.remotion.dev/docs/studio/play)
*/
const play = (e) => {
var _a;
(_a = remotion_1.Internals.timeValueRef.current) === null || _a === void 0 ? void 0 : _a.play(e);
};
exports.play = play;
@@ -0,0 +1 @@
export declare const reevaluateComposition: () => void;
@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.reevaluateComposition = void 0;
const remotion_1 = require("remotion");
const reevaluateComposition = () => {
var _a;
(_a = remotion_1.Internals.resolveCompositionsRef.current) === null || _a === void 0 ? void 0 : _a.reloadCurrentlySelectedComposition();
};
exports.reevaluateComposition = reevaluateComposition;
@@ -0,0 +1,6 @@
/**
* @description Restarts the Remotion Studio.
* @see [Documentation](https://www.remotion.dev/docs/studio/restart-studio)
*/
import type { RestartStudioResponse } from '@remotion/studio-shared';
export declare const restartStudio: () => Promise<RestartStudioResponse>;
@@ -0,0 +1,19 @@
"use strict";
/**
* @description Restarts the Remotion Studio.
* @see [Documentation](https://www.remotion.dev/docs/studio/restart-studio)
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.restartStudio = void 0;
const remotion_1 = require("remotion");
const call_api_1 = require("../components/call-api");
const restartStudio = () => {
if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
throw new Error('restartStudio() is only available in the Studio');
}
if (window.remotion_isReadOnlyStudio) {
throw new Error('restartStudio() is not available in read-only Studio');
}
return (0, call_api_1.callApi)('/api/restart-studio', {});
};
exports.restartStudio = restartStudio;
@@ -0,0 +1,5 @@
import type { UpdateDefaultPropsFunction } from './helpers/calc-new-props';
export declare const saveDefaultProps: ({ compositionId, defaultProps, }: {
compositionId: string;
defaultProps: UpdateDefaultPropsFunction;
}) => Promise<void>;
@@ -0,0 +1,80 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.saveDefaultProps = void 0;
const remotion_1 = require("remotion");
const extract_enum_json_paths_1 = require("../components/RenderModal/SchemaEditor/extract-enum-json-paths");
const actions_1 = require("../components/RenderQueue/actions");
const calc_new_props_1 = require("./helpers/calc-new-props");
/*
* @description Saves the defaultProps for a composition back to the root file.
* @see [Documentation](https://www.remotion.dev/docs/studio/save-default-props)
*/
const saveDefaultProps = async ({ compositionId, defaultProps, }) => {
if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
throw new Error('saveDefaultProps() is only available in the Studio');
}
if (window.remotion_isReadOnlyStudio) {
throw new Error('saveDefaultProps() is not available in read-only Studio');
}
try {
await Promise.resolve().then(() => __importStar(require('zod')));
}
catch (_a) {
throw new Error('"zod" is required to use saveDefaultProps(), but is not installed.');
}
const z = await Promise.resolve().then(() => __importStar(require('zod')));
let zodTypes = null;
try {
zodTypes = await Promise.resolve().then(() => __importStar(require('@remotion/zod-types')));
}
catch (_b) { }
const { generatedDefaultProps, composition } = (0, calc_new_props_1.calcNewProps)(compositionId, defaultProps);
const res = await (0, actions_1.callUpdateDefaultPropsApi)(compositionId, generatedDefaultProps, composition.schema
? (0, extract_enum_json_paths_1.extractEnumJsonPaths)({
schema: composition.schema,
zodRuntime: z,
currentPath: [],
zodTypes,
})
: []);
if (res.success) {
return Promise.resolve();
}
const err = new Error(res.reason);
err.stack = res.stack;
return Promise.reject(err);
};
exports.saveDefaultProps = saveDefaultProps;
@@ -0,0 +1,7 @@
import type { CompletedClientRender } from '@remotion/studio-shared';
export declare const saveOutputFile: ({ blob, filePath, }: {
blob: Blob;
filePath: string;
}) => Promise<void>;
export declare const registerClientRender: (render: CompletedClientRender) => Promise<void>;
export declare const unregisterClientRender: (id: string) => Promise<void>;
@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unregisterClientRender = exports.registerClientRender = exports.saveOutputFile = void 0;
const throwIfNotOk = async (response) => {
if (!response.ok) {
try {
const jsonResponse = await response.json();
throw new Error(jsonResponse.error);
}
catch (parseError) {
if (parseError instanceof Error && parseError.message) {
throw parseError;
}
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
}
};
const saveOutputFile = async ({ blob, filePath, }) => {
const url = new URL('/api/upload-output', window.location.origin);
url.search = new URLSearchParams({ filePath }).toString();
const response = await fetch(url, {
method: 'POST',
body: blob,
});
await throwIfNotOk(response);
};
exports.saveOutputFile = saveOutputFile;
const registerClientRender = async (render) => {
const response = await fetch('/api/register-client-render', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(render),
});
await throwIfNotOk(response);
};
exports.registerClientRender = registerClientRender;
const unregisterClientRender = async (id) => {
const response = await fetch('/api/unregister-client-render', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ id }),
});
await throwIfNotOk(response);
};
exports.unregisterClientRender = unregisterClientRender;
@@ -0,0 +1 @@
export declare const seek: (frame: number) => void;
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.seek = void 0;
const remotion_1 = require("remotion");
/*
* @description Jump to a different time in the timeline.
* @see [Documentation](https://www.remotion.dev/docs/studio/seek)
*/
const seek = (frame) => {
var _a;
(_a = remotion_1.Internals.timeValueRef.current) === null || _a === void 0 ? void 0 : _a.seek(Math.max(0, frame));
};
exports.seek = seek;
@@ -0,0 +1,2 @@
import type { SyntheticEvent } from 'react';
export declare const toggle: (e?: SyntheticEvent | PointerEvent) => void;
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toggle = void 0;
const remotion_1 = require("remotion");
/*
* @description Toggle playback of the current composition.
* @see [Documentation](https://www.remotion.dev/docs/studio/toggle)
*/
const toggle = (e) => {
var _a;
(_a = remotion_1.Internals.timeValueRef.current) === null || _a === void 0 ? void 0 : _a.toggle(e);
};
exports.toggle = toggle;
@@ -0,0 +1,5 @@
import type { UpdateDefaultPropsFunction } from './helpers/calc-new-props';
export declare const updateDefaultProps: ({ compositionId, defaultProps, }: {
compositionId: string;
defaultProps: UpdateDefaultPropsFunction;
}) => void;
@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateDefaultProps = void 0;
const remotion_1 = require("remotion");
const calc_new_props_1 = require("./helpers/calc-new-props");
const updateDefaultProps = ({ compositionId, defaultProps, }) => {
const { generatedDefaultProps, composition } = (0, calc_new_props_1.calcNewProps)(compositionId, defaultProps);
const propsStore = remotion_1.Internals.editorPropsProviderRef.current;
if (!propsStore) {
throw new Error('No props store found. Are you in the Remotion Studio and are the Remotion versions aligned?');
}
propsStore.setProps((prev) => {
return {
...prev,
[composition.id]: generatedDefaultProps,
};
});
window.dispatchEvent(new CustomEvent(remotion_1.Internals.PROPS_UPDATED_EXTERNALLY, {
detail: {
resetUnsaved: null,
},
}));
};
exports.updateDefaultProps = updateDefaultProps;
@@ -0,0 +1,2 @@
import { type VisualControlRef } from '../visual-controls/VisualControls';
export declare const visualControl: VisualControlRef['globalVisualControl'];
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.visualControl = void 0;
const remotion_1 = require("remotion");
const VisualControls_1 = require("../visual-controls/VisualControls");
const visualControl = (key, value, schema) => {
if ((0, remotion_1.getRemotionEnvironment)().isRendering) {
return value;
}
if (!VisualControls_1.visualControlRef.current) {
return value;
}
return VisualControls_1.visualControlRef.current.globalVisualControl(key, value, schema);
};
exports.visualControl = visualControl;
@@ -0,0 +1,7 @@
import { type StaticFile } from './get-static-files';
type WatcherCallback = (newFiles: StaticFile[]) => void;
export declare const WATCH_REMOTION_STATIC_FILES = "remotion_staticFilesChanged";
export declare const watchPublicFolder: (callback: WatcherCallback) => {
cancel: () => void;
};
export {};
@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.watchPublicFolder = exports.WATCH_REMOTION_STATIC_FILES = void 0;
const remotion_1 = require("remotion");
const get_static_files_1 = require("./get-static-files");
exports.WATCH_REMOTION_STATIC_FILES = 'remotion_staticFilesChanged';
/*
* @description Watches for changes in the public directory and calls a callback function when a file is added, removed, or modified.
* @see [Documentation](https://www.remotion.dev/docs/studio/watch-public-folder)
*/
const watchPublicFolder = (callback) => {
if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
// eslint-disable-next-line no-console
console.warn('The watchPublicFolder() API is only available while using the Remotion Studio.');
return { cancel: () => undefined };
}
if (window.remotion_isReadOnlyStudio) {
throw new Error('watchPublicFolder() is not available in read-only Studio');
}
const emitUpdate = () => {
callback((0, get_static_files_1.getStaticFiles)());
};
window.addEventListener(exports.WATCH_REMOTION_STATIC_FILES, emitUpdate);
const cancel = () => {
return window.removeEventListener(exports.WATCH_REMOTION_STATIC_FILES, emitUpdate);
};
return { cancel };
};
exports.watchPublicFolder = watchPublicFolder;
@@ -0,0 +1,9 @@
import type { StaticFile } from './get-static-files';
type WatcherCallback = (newData: StaticFile | null) => void;
export type WatchRemotionStaticFilesPayload = {
files: StaticFile[];
};
export declare const watchStaticFile: (fileName: string, callback: WatcherCallback) => {
cancel: () => void;
};
export {};
@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.watchStaticFile = void 0;
const remotion_1 = require("remotion");
const watch_public_folder_1 = require("./watch-public-folder");
/*
* @description Watches for changes in a specific static file and invokes a callback function when the file changes, enabling dynamic updates in your Remotion projects.
* @see [Documentation](https://www.remotion.dev/docs/studio/watch-static-file)
*/
const watchStaticFile = (fileName, callback) => {
if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
// eslint-disable-next-line no-console
console.warn('watchStaticFile() is only available while using the Remotion Studio.');
return { cancel: () => undefined };
}
if (window.remotion_isReadOnlyStudio) {
// eslint-disable-next-line no-console
console.warn('watchStaticFile() is only available in an interactive Studio.');
return { cancel: () => undefined };
}
const withoutStaticBase = fileName.startsWith(window.remotion_staticBase)
? fileName.replace(window.remotion_staticBase, '')
: fileName;
const withoutLeadingSlash = withoutStaticBase.startsWith('/')
? withoutStaticBase.slice(1)
: withoutStaticBase;
let prevFileData = window.remotion_staticFiles.find((file) => file.name === withoutLeadingSlash);
const { cancel } = (0, watch_public_folder_1.watchPublicFolder)((staticFiles) => {
// Check for user specified file
const newFileData = staticFiles.find((file) => file.name === withoutLeadingSlash);
if (!newFileData) {
// File is deleted
if (prevFileData !== undefined) {
callback(null);
}
prevFileData = undefined;
return;
}
if (prevFileData === undefined ||
prevFileData.lastModified !== newFileData.lastModified) {
callback(newFileData); // File is added or modified
prevFileData = newFileData;
}
});
return { cancel };
};
exports.watchStaticFile = watchStaticFile;
@@ -0,0 +1,4 @@
export declare const writeStaticFile: ({ contents, filePath, }: {
contents: string | ArrayBuffer;
filePath: string;
}) => Promise<void>;
@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeStaticFile = void 0;
const writeStaticFile = async ({ contents, filePath, }) => {
if (window.remotion_isReadOnlyStudio) {
throw new Error('writeStaticFile() is not available in read-only Studio');
}
const url = new URL(`${window.remotion_staticBase}/api/add-asset`, window.location.origin);
if (filePath.includes('\\')) {
return Promise.reject(new Error('File path cannot contain backslashes'));
}
url.search = new URLSearchParams({
filePath,
}).toString();
const response = await fetch(url, {
method: 'POST',
body: contents,
});
if (!response.ok) {
const jsonResponse = await response.json();
throw new Error(jsonResponse.error);
}
};
exports.writeStaticFile = writeStaticFile;