@remotion/studio 4.0.143 → 4.0.144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/LICENSE.md +4 -0
- package/bundle.ts +45 -0
- package/dist/Studio.d.ts +2 -3
- package/dist/Studio.js +4 -1
- package/dist/api/get-static-files.d.ts +21 -0
- package/dist/api/get-static-files.js +37 -0
- package/dist/api/watch-static-file.d.ts +17 -0
- package/dist/api/watch-static-file.js +52 -0
- package/dist/components/AssetSelector.d.ts +1 -1
- package/dist/components/AssetSelector.js +26 -8
- package/dist/components/InitialCompositionLoader.js +2 -1
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +11 -11
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +2 -2
- package/dist/components/StaticFilePreview.js +2 -1
- package/dist/components/utils.js +12 -25
- package/dist/esm/index.mjs +67 -0
- package/dist/esm/internals.mjs +27014 -0
- package/dist/helpers/convert-env-variables.d.ts +2 -8
- package/dist/helpers/inject-css.d.ts +1 -0
- package/dist/helpers/inject-css.js +140 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -3
- package/dist/internals.d.ts +7 -0
- package/dist/internals.js +7 -0
- package/dist/previewEntry.js +8 -6
- package/internals.d.ts +1 -0
- package/internals.js +1 -0
- package/package.json +19 -13
- package/tsconfig.tsbuildinfo +1 -1
- package/styles.css +0 -123
package/.turbo/turbo-build.log
CHANGED
package/LICENSE.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Remotion License
|
|
2
2
|
|
|
3
|
+
In Remotion 5.0, the license will slightly change. [View the changes here](https://github.com/remotion-dev/remotion/pull/3750).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
3
7
|
Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion to create videos for free (even commercial), while a company license is required for for-profit organizations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
|
|
4
8
|
|
|
5
9
|
- [Free license](#free-license)
|
package/bundle.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {build} from 'bun';
|
|
2
|
+
|
|
3
|
+
const mainModule = await build({
|
|
4
|
+
entrypoints: ['src/index.ts'],
|
|
5
|
+
naming: '[name].mjs',
|
|
6
|
+
external: ['react', 'remotion', 'remotion/no-react', 'react/jsx-runtime'],
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const [file] = mainModule.outputs;
|
|
10
|
+
const text = (await file.text())
|
|
11
|
+
.replace(/jsxDEV/g, 'jsx')
|
|
12
|
+
.replace(/react\/jsx-dev-runtime/g, 'react/jsx-runtime');
|
|
13
|
+
|
|
14
|
+
await Bun.write('dist/esm/index.mjs', text);
|
|
15
|
+
|
|
16
|
+
const internalsModule = await build({
|
|
17
|
+
entrypoints: ['src/internals.ts'],
|
|
18
|
+
naming: 'internals.mjs',
|
|
19
|
+
external: [
|
|
20
|
+
'react',
|
|
21
|
+
'remotion',
|
|
22
|
+
'scheduler',
|
|
23
|
+
'react-dom',
|
|
24
|
+
'react',
|
|
25
|
+
'@remotion/media-utils',
|
|
26
|
+
'@remotion/studio-shared',
|
|
27
|
+
'@remotion/zod-types',
|
|
28
|
+
'@remotion/renderer',
|
|
29
|
+
'@remotion/player',
|
|
30
|
+
'@remotion/renderer/client',
|
|
31
|
+
'source-map',
|
|
32
|
+
'zod',
|
|
33
|
+
'remotion/no-react',
|
|
34
|
+
'react/jsx-runtime',
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
const [enableFile] = internalsModule.outputs;
|
|
38
|
+
const internalsText = (await enableFile.text())
|
|
39
|
+
.replace(/jsxDEV/g, 'jsx')
|
|
40
|
+
.replace(/@remotion\/renderer\/client/g, '@remotion/renderer/client.js')
|
|
41
|
+
.replace(/react\/jsx-dev-runtime/g, 'react/jsx-runtime');
|
|
42
|
+
|
|
43
|
+
await Bun.write('dist/esm/internals.mjs', internalsText);
|
|
44
|
+
|
|
45
|
+
export {};
|
package/dist/Studio.d.ts
CHANGED
package/dist/Studio.js
CHANGED
|
@@ -5,10 +5,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const react_dom_1 = require("react-dom");
|
|
7
7
|
const remotion_1 = require("remotion");
|
|
8
|
-
require("../styles.css");
|
|
9
8
|
const Editor_1 = require("./components/Editor");
|
|
10
9
|
const EditorContexts_1 = require("./components/EditorContexts");
|
|
11
10
|
const ServerDisconnected_1 = require("./components/Notifications/ServerDisconnected");
|
|
11
|
+
const inject_css_1 = require("./helpers/inject-css");
|
|
12
12
|
const getServerDisconnectedDomElement = () => {
|
|
13
13
|
return document.getElementById('server-disconnected-overlay');
|
|
14
14
|
};
|
|
@@ -17,6 +17,9 @@ const Studio = ({ rootComponent, readOnly }) => {
|
|
|
17
17
|
window.remotion_isStudio = true;
|
|
18
18
|
remotion_1.Internals.enableSequenceStackTraces();
|
|
19
19
|
}, []);
|
|
20
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
21
|
+
(0, inject_css_1.injectCSS)();
|
|
22
|
+
}, []);
|
|
20
23
|
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.RemotionRoot, { numberOfAudioTags: window.remotion_numberOfAudioTags, children: (0, jsx_runtime_1.jsxs)(EditorContexts_1.EditorContexts, { readOnlyStudio: readOnly, children: [(0, jsx_runtime_1.jsx)(Editor_1.Editor, { readOnlyStudio: readOnly, Root: rootComponent }), readOnly
|
|
21
24
|
? null
|
|
22
25
|
: (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(ServerDisconnected_1.ServerDisconnected, {}), getServerDisconnectedDomElement())] }) }));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description The function array containing all files in the public/ folder. You can reference them by using staticFile().
|
|
3
|
+
* @see [Documentation](https://www.remotion.dev/docs/getstaticfiles)
|
|
4
|
+
*/
|
|
5
|
+
export declare const getStaticFiles: () => StaticFile[];
|
|
6
|
+
export type StaticFile = {
|
|
7
|
+
/**
|
|
8
|
+
* A string that you can pass to the `src` attribute of an `<Audio>`, `<Img>` and `<Video>` element.
|
|
9
|
+
*/
|
|
10
|
+
src: string;
|
|
11
|
+
/**
|
|
12
|
+
* The filepath of the file, relative to the public folder.
|
|
13
|
+
* Example: `subfolder/image.png`
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
sizeInBytes: number;
|
|
17
|
+
/**
|
|
18
|
+
* UNIX timestamp in milliseconds
|
|
19
|
+
*/
|
|
20
|
+
lastModified: number;
|
|
21
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStaticFiles = void 0;
|
|
4
|
+
let warnedServer = false;
|
|
5
|
+
let warnedPlayer = false;
|
|
6
|
+
const warnServerOnce = () => {
|
|
7
|
+
if (warnedServer) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
warnedServer = true;
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
12
|
+
console.warn('Called getStaticFiles() on the server. The API is only available in the browser. An empty array was returned.');
|
|
13
|
+
};
|
|
14
|
+
const warnPlayerOnce = () => {
|
|
15
|
+
if (warnedPlayer) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
warnedPlayer = true;
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
console.warn('Called getStaticFiles() while using the Remotion Player. The API is only available while using the Remotion Studio. An empty array was returned.');
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @description The function array containing all files in the public/ folder. You can reference them by using staticFile().
|
|
24
|
+
* @see [Documentation](https://www.remotion.dev/docs/getstaticfiles)
|
|
25
|
+
*/
|
|
26
|
+
const getStaticFiles = () => {
|
|
27
|
+
if (typeof document === 'undefined') {
|
|
28
|
+
warnServerOnce();
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
if (window.remotion_isPlayer) {
|
|
32
|
+
warnPlayerOnce();
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
return window.remotion_staticFiles;
|
|
36
|
+
};
|
|
37
|
+
exports.getStaticFiles = getStaticFiles;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StaticFile } from './get-static-files';
|
|
2
|
+
type WatcherCallback = (newData: StaticFile | null) => void;
|
|
3
|
+
export declare const WATCH_REMOTION_STATIC_FILES = "remotion_staticFilesChanged";
|
|
4
|
+
export type WatchRemotionStaticFilesPayload = {
|
|
5
|
+
files: StaticFile[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* @description Watch for changes in a specific static file.
|
|
9
|
+
* @param {string} fileName - The name of the static file to watch for changes.
|
|
10
|
+
* @param {WatcherCallback} callback - A callback function to be called when the file changes.
|
|
11
|
+
* @returns {{cancel: () => void}} A function that can be used to cancel the event listener.
|
|
12
|
+
* @see [Documentation](https://www.remotion.dev/docs/watchstaticfile)
|
|
13
|
+
*/
|
|
14
|
+
export declare const watchStaticFile: (fileName: string, callback: WatcherCallback) => {
|
|
15
|
+
cancel: () => void;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.watchStaticFile = exports.WATCH_REMOTION_STATIC_FILES = void 0;
|
|
4
|
+
const remotion_1 = require("remotion");
|
|
5
|
+
exports.WATCH_REMOTION_STATIC_FILES = 'remotion_staticFilesChanged';
|
|
6
|
+
/**
|
|
7
|
+
* @description Watch for changes in a specific static file.
|
|
8
|
+
* @param {string} fileName - The name of the static file to watch for changes.
|
|
9
|
+
* @param {WatcherCallback} callback - A callback function to be called when the file changes.
|
|
10
|
+
* @returns {{cancel: () => void}} A function that can be used to cancel the event listener.
|
|
11
|
+
* @see [Documentation](https://www.remotion.dev/docs/watchstaticfile)
|
|
12
|
+
*/
|
|
13
|
+
const watchStaticFile = (fileName, callback) => {
|
|
14
|
+
// Check if function is called in Remotion Studio
|
|
15
|
+
if (!(0, remotion_1.getRemotionEnvironment)().isStudio) {
|
|
16
|
+
// eslint-disable-next-line no-console
|
|
17
|
+
console.warn('The API is only available while using the Remotion Studio.');
|
|
18
|
+
return { cancel: () => undefined };
|
|
19
|
+
}
|
|
20
|
+
const withoutStaticBase = fileName.startsWith(window.remotion_staticBase)
|
|
21
|
+
? fileName.replace(window.remotion_staticBase, '')
|
|
22
|
+
: fileName;
|
|
23
|
+
const withoutLeadingSlash = withoutStaticBase.startsWith('/')
|
|
24
|
+
? withoutStaticBase.slice(1)
|
|
25
|
+
: withoutStaticBase;
|
|
26
|
+
let prevFileData = window.remotion_staticFiles.find((file) => file.name === withoutLeadingSlash);
|
|
27
|
+
// Check if the specified static file has updated or deleted
|
|
28
|
+
const checkFile = (event) => {
|
|
29
|
+
const staticFiles = event.detail.files;
|
|
30
|
+
// Check for user specified file
|
|
31
|
+
const newFileData = staticFiles.find((file) => file.name === withoutLeadingSlash);
|
|
32
|
+
if (!newFileData) {
|
|
33
|
+
// File is deleted
|
|
34
|
+
if (prevFileData !== undefined) {
|
|
35
|
+
callback(null);
|
|
36
|
+
}
|
|
37
|
+
prevFileData = undefined;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (prevFileData === undefined ||
|
|
41
|
+
prevFileData.lastModified !== newFileData.lastModified) {
|
|
42
|
+
callback(newFileData); // File is added or modified
|
|
43
|
+
prevFileData = newFileData;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
window.addEventListener(exports.WATCH_REMOTION_STATIC_FILES, checkFile);
|
|
47
|
+
const cancel = () => {
|
|
48
|
+
return window.removeEventListener(exports.WATCH_REMOTION_STATIC_FILES, checkFile);
|
|
49
|
+
};
|
|
50
|
+
return { cancel };
|
|
51
|
+
};
|
|
52
|
+
exports.watchStaticFile = watchStaticFile;
|
|
@@ -29,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.AssetSelector = void 0;
|
|
30
30
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
31
|
const react_1 = __importStar(require("react"));
|
|
32
|
-
const
|
|
32
|
+
const get_static_files_1 = require("../api/get-static-files");
|
|
33
33
|
const client_id_1 = require("../helpers/client-id");
|
|
34
34
|
const colors_1 = require("../helpers/colors");
|
|
35
35
|
const create_folder_tree_1 = require("../helpers/create-folder-tree");
|
|
@@ -39,6 +39,7 @@ const folders_1 = require("../state/folders");
|
|
|
39
39
|
const z_index_1 = require("../state/z-index");
|
|
40
40
|
const AssetSelectorItem_1 = require("./AssetSelectorItem");
|
|
41
41
|
const styles_1 = require("./Menu/styles");
|
|
42
|
+
const NotificationCenter_1 = require("./Notifications/NotificationCenter");
|
|
42
43
|
const utils_1 = require("./utils");
|
|
43
44
|
const container = {
|
|
44
45
|
display: 'flex',
|
|
@@ -75,7 +76,7 @@ const AssetSelector = ({ readOnlyStudio }) => {
|
|
|
75
76
|
const shouldAllowUpload = connectionStatus === 'connected' && !readOnlyStudio;
|
|
76
77
|
const [{ publicFolderExists, staticFiles }, setState] = react_1.default.useState(() => {
|
|
77
78
|
return {
|
|
78
|
-
staticFiles: (0,
|
|
79
|
+
staticFiles: (0, get_static_files_1.getStaticFiles)(),
|
|
79
80
|
publicFolderExists: window.remotion_publicFolderExists,
|
|
80
81
|
};
|
|
81
82
|
});
|
|
@@ -85,7 +86,7 @@ const AssetSelector = ({ readOnlyStudio }) => {
|
|
|
85
86
|
(0, react_1.useEffect)(() => {
|
|
86
87
|
const onUpdate = () => {
|
|
87
88
|
setState({
|
|
88
|
-
staticFiles: (0,
|
|
89
|
+
staticFiles: (0, get_static_files_1.getStaticFiles)(),
|
|
89
90
|
publicFolderExists: window.remotion_publicFolderExists,
|
|
90
91
|
});
|
|
91
92
|
};
|
|
@@ -116,11 +117,28 @@ const AssetSelector = ({ readOnlyStudio }) => {
|
|
|
116
117
|
const onDragOver = (0, react_1.useCallback)((e) => {
|
|
117
118
|
e.preventDefault();
|
|
118
119
|
}, []);
|
|
119
|
-
const onDrop = (0, react_1.useCallback)((e) => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
const onDrop = (0, react_1.useCallback)(async (e) => {
|
|
121
|
+
try {
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
const { files } = e.dataTransfer;
|
|
125
|
+
const assetPath = dropLocation || '/';
|
|
126
|
+
for (const file of files) {
|
|
127
|
+
await (0, utils_1.handleUploadFile)(file, assetPath);
|
|
128
|
+
}
|
|
129
|
+
if (files.length === 1) {
|
|
130
|
+
(0, NotificationCenter_1.showNotification)(`Added ${files[0].name} to ${assetPath}`, 3000);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
(0, NotificationCenter_1.showNotification)(`Added ${files.length} files to ${assetPath}`, 3000);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
(0, NotificationCenter_1.showNotification)(`Error during upload: ${error}`, 3000);
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
setDropLocation(null);
|
|
141
|
+
}
|
|
124
142
|
}, [dropLocation]);
|
|
125
143
|
return ((0, jsx_runtime_1.jsx)("div", { style: container, onDragOver: shouldAllowUpload ? onDragOver : undefined, onDrop: shouldAllowUpload ? onDrop : undefined, children: staticFiles.length === 0 ? (publicFolderExists ? ((0, jsx_runtime_1.jsx)("div", { style: emptyState, children: (0, jsx_runtime_1.jsxs)("div", { style: label, children: ["To add assets, place a file in the", ' ', (0, jsx_runtime_1.jsx)("code", { style: styles_1.inlineCodeSnippet, children: "public" }), " folder of your project or drag and drop a file here."] }) })) : ((0, jsx_runtime_1.jsx)("div", { style: emptyState, children: (0, jsx_runtime_1.jsxs)("div", { style: label, children: ["To add assets, create a folder called", ' ', (0, jsx_runtime_1.jsx)("code", { style: styles_1.inlineCodeSnippet, children: "public" }), " in the root of your project and place a file in it."] }) }))) : ((0, jsx_runtime_1.jsx)("div", { className: "__remotion-vertical-scrollbar", style: {
|
|
126
144
|
...list,
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InitialCompositionLoader = exports.useSelectComposition = exports.useSelectAsset = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const remotion_1 = require("remotion");
|
|
6
|
+
const get_static_files_1 = require("../api/get-static-files");
|
|
6
7
|
const mobile_layout_1 = require("../helpers/mobile-layout");
|
|
7
8
|
const url_state_1 = require("../helpers/url-state");
|
|
8
9
|
const folders_1 = require("../state/folders");
|
|
@@ -110,7 +111,7 @@ const InitialCompositionLoader = () => {
|
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
112
113
|
if (newCanvas && newCanvas.type === 'asset') {
|
|
113
|
-
const staticFiles = (0,
|
|
114
|
+
const staticFiles = (0, get_static_files_1.getStaticFiles)();
|
|
114
115
|
const exists = staticFiles.find((file) => {
|
|
115
116
|
return file.name === newCanvas.asset;
|
|
116
117
|
});
|
|
@@ -3,15 +3,15 @@ import type { z } from 'zod';
|
|
|
3
3
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
4
|
import type { JSONPath } from './zod-types';
|
|
5
5
|
export declare const ZodStaticFileEditor: React.FC<{
|
|
6
|
-
schema: z.ZodTypeAny;
|
|
7
|
-
jsonPath: JSONPath;
|
|
8
|
-
value: string;
|
|
9
|
-
defaultValue: string;
|
|
10
|
-
setValue: UpdaterFunction<string>;
|
|
11
|
-
onSave: (updater: (oldState: string) => string) => void;
|
|
12
|
-
showSaveButton: boolean;
|
|
13
|
-
onRemove: null | (() => void);
|
|
14
|
-
saving: boolean;
|
|
15
|
-
saveDisabledByParent: boolean;
|
|
16
|
-
mayPad: boolean;
|
|
6
|
+
readonly schema: z.ZodTypeAny;
|
|
7
|
+
readonly jsonPath: JSONPath;
|
|
8
|
+
readonly value: string;
|
|
9
|
+
readonly defaultValue: string;
|
|
10
|
+
readonly setValue: UpdaterFunction<string>;
|
|
11
|
+
readonly onSave: (updater: (oldState: string) => string) => void;
|
|
12
|
+
readonly showSaveButton: boolean;
|
|
13
|
+
readonly onRemove: null | (() => void);
|
|
14
|
+
readonly saving: boolean;
|
|
15
|
+
readonly saveDisabledByParent: boolean;
|
|
16
|
+
readonly mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZodStaticFileEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
6
|
+
const get_static_files_1 = require("../../../api/get-static-files");
|
|
7
7
|
const Checkmark_1 = require("../../../icons/Checkmark");
|
|
8
8
|
const ComboBox_1 = require("../../NewComposition/ComboBox");
|
|
9
9
|
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
@@ -32,7 +32,7 @@ const ZodStaticFileEditor = ({ schema, jsonPath, setValue, defaultValue, value,
|
|
|
32
32
|
}
|
|
33
33
|
const isRoot = jsonPath.length === 0;
|
|
34
34
|
const comboBoxValues = (0, react_1.useMemo)(() => {
|
|
35
|
-
return (0,
|
|
35
|
+
return (0, get_static_files_1.getStaticFiles)().map((option) => {
|
|
36
36
|
return {
|
|
37
37
|
value: option.src,
|
|
38
38
|
label: option.name,
|
|
@@ -4,6 +4,7 @@ exports.StaticFilePreview = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const remotion_1 = require("remotion");
|
|
7
|
+
const get_static_files_1 = require("../api/get-static-files");
|
|
7
8
|
const client_id_1 = require("../helpers/client-id");
|
|
8
9
|
const colors_1 = require("../helpers/colors");
|
|
9
10
|
const FilePreview_1 = require("./FilePreview");
|
|
@@ -22,7 +23,7 @@ const errMsgStyle = {
|
|
|
22
23
|
const StaticFilePreview = ({ currentAsset, assetMetadata }) => {
|
|
23
24
|
const fileType = (0, Preview_1.getPreviewFileType)(currentAsset);
|
|
24
25
|
const staticFileSrc = (0, remotion_1.staticFile)(currentAsset);
|
|
25
|
-
const staticFiles = (0,
|
|
26
|
+
const staticFiles = (0, get_static_files_1.getStaticFiles)();
|
|
26
27
|
const connectionStatus = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx)
|
|
27
28
|
.previewServerState.type;
|
|
28
29
|
const exists = staticFiles.find((file) => file.name === currentAsset);
|
package/dist/components/utils.js
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleUploadFile = void 0;
|
|
4
|
-
const NotificationCenter_1 = require("./Notifications/NotificationCenter");
|
|
5
4
|
const handleUploadFile = async (file, assetPath) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
body: file,
|
|
19
|
-
});
|
|
20
|
-
if (response.ok) {
|
|
21
|
-
(0, NotificationCenter_1.showNotification)(`Added ${file.name} to ${assetPath}`, 3000);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
const jsonResponse = await response.json();
|
|
25
|
-
(0, NotificationCenter_1.showNotification)(`Upload failed: ${jsonResponse.error}`, 3000);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
(0, NotificationCenter_1.showNotification)(`Error during upload: ${error}`, 3000);
|
|
5
|
+
const url = new URL('/api/add-asset', window.location.origin);
|
|
6
|
+
url.search = new URLSearchParams({
|
|
7
|
+
folder: assetPath,
|
|
8
|
+
file: file.name,
|
|
9
|
+
}).toString();
|
|
10
|
+
const response = await fetch(url, {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
body: file,
|
|
13
|
+
});
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
const jsonResponse = await response.json();
|
|
16
|
+
throw new Error(jsonResponse.error);
|
|
30
17
|
}
|
|
31
18
|
};
|
|
32
19
|
exports.handleUploadFile = handleUploadFile;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/api/get-static-files.ts
|
|
2
|
+
var warnedServer = false;
|
|
3
|
+
var warnedPlayer = false;
|
|
4
|
+
var warnServerOnce = () => {
|
|
5
|
+
if (warnedServer) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
warnedServer = true;
|
|
9
|
+
console.warn("Called getStaticFiles() on the server. The API is only available in the browser. An empty array was returned.");
|
|
10
|
+
};
|
|
11
|
+
var warnPlayerOnce = () => {
|
|
12
|
+
if (warnedPlayer) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
warnedPlayer = true;
|
|
16
|
+
console.warn("Called getStaticFiles() while using the Remotion Player. The API is only available while using the Remotion Studio. An empty array was returned.");
|
|
17
|
+
};
|
|
18
|
+
var getStaticFiles = () => {
|
|
19
|
+
if (typeof document === "undefined") {
|
|
20
|
+
warnServerOnce();
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
if (window.remotion_isPlayer) {
|
|
24
|
+
warnPlayerOnce();
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
return window.remotion_staticFiles;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/api/watch-static-file.ts
|
|
31
|
+
import {getRemotionEnvironment} from "remotion";
|
|
32
|
+
var WATCH_REMOTION_STATIC_FILES = "remotion_staticFilesChanged";
|
|
33
|
+
var watchStaticFile = (fileName, callback) => {
|
|
34
|
+
if (!getRemotionEnvironment().isStudio) {
|
|
35
|
+
console.warn("The API is only available while using the Remotion Studio.");
|
|
36
|
+
return { cancel: () => {
|
|
37
|
+
return;
|
|
38
|
+
} };
|
|
39
|
+
}
|
|
40
|
+
const withoutStaticBase = fileName.startsWith(window.remotion_staticBase) ? fileName.replace(window.remotion_staticBase, "") : fileName;
|
|
41
|
+
const withoutLeadingSlash = withoutStaticBase.startsWith("/") ? withoutStaticBase.slice(1) : withoutStaticBase;
|
|
42
|
+
let prevFileData = window.remotion_staticFiles.find((file) => file.name === withoutLeadingSlash);
|
|
43
|
+
const checkFile = (event) => {
|
|
44
|
+
const staticFiles = event.detail.files;
|
|
45
|
+
const newFileData = staticFiles.find((file) => file.name === withoutLeadingSlash);
|
|
46
|
+
if (!newFileData) {
|
|
47
|
+
if (prevFileData !== undefined) {
|
|
48
|
+
callback(null);
|
|
49
|
+
}
|
|
50
|
+
prevFileData = undefined;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (prevFileData === undefined || prevFileData.lastModified !== newFileData.lastModified) {
|
|
54
|
+
callback(newFileData);
|
|
55
|
+
prevFileData = newFileData;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
window.addEventListener(WATCH_REMOTION_STATIC_FILES, checkFile);
|
|
59
|
+
const cancel = () => {
|
|
60
|
+
return window.removeEventListener(WATCH_REMOTION_STATIC_FILES, checkFile);
|
|
61
|
+
};
|
|
62
|
+
return { cancel };
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
watchStaticFile,
|
|
66
|
+
getStaticFiles
|
|
67
|
+
};
|