@remotion/studio 4.0.200 → 4.0.202

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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @remotion/studio@4.0.199 build /Users/jonathanburger/remotion/packages/studio
2
+ > @remotion/studio@4.0.201 build /Users/jonathanburger/remotion/packages/studio
3
3
  > bun --env-file=../.env.bundle bundle.ts
4
4
 
@@ -243,9 +243,20 @@ const Canvas = ({ canvasContent, size, isRefreshing }) => {
243
243
  if (canvasContent.type === 'composition') {
244
244
  return;
245
245
  }
246
- const metadata = await (0, get_asset_metadata_1.getAssetMetadata)(canvasContent);
246
+ const metadata = await (0, get_asset_metadata_1.getAssetMetadata)(canvasContent, canvasContent.type === 'asset');
247
247
  setAssetResolution(metadata);
248
248
  }, [canvasContent]);
249
+ (0, react_1.useEffect)(() => {
250
+ if (canvasContent.type !== 'asset') {
251
+ return;
252
+ }
253
+ const file = (0, remotion_1.watchStaticFile)(canvasContent.asset, () => {
254
+ fetchMetadata();
255
+ });
256
+ return () => {
257
+ file.cancel();
258
+ };
259
+ }, [canvasContent, fetchMetadata]);
249
260
  (0, react_1.useEffect)(() => {
250
261
  fetchMetadata();
251
262
  }, [fetchMetadata]);
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import type { AssetMetadata } from '../helpers/get-asset-metadata';
3
3
  import type { AssetFileType } from './Preview';
4
4
  export declare const FilePreview: React.FC<{
5
- src: string;
6
- fileType: AssetFileType;
7
- currentAsset: string;
8
- assetMetadata: AssetMetadata | null;
5
+ readonly src: string;
6
+ readonly fileType: AssetFileType;
7
+ readonly currentAsset: string;
8
+ readonly assetMetadata: AssetMetadata | null;
9
9
  }>;
@@ -36,6 +36,6 @@ const StaticFilePreview = ({ currentAsset, assetMetadata }) => {
36
36
  if (!currentAsset) {
37
37
  return null;
38
38
  }
39
- return ((0, jsx_runtime_1.jsx)(FilePreview_1.FilePreview, { currentAsset: currentAsset, fileType: fileType, src: staticFileSrc, assetMetadata: assetMetadata }));
39
+ return ((0, jsx_runtime_1.jsx)(FilePreview_1.FilePreview, { currentAsset: currentAsset, fileType: fileType, src: `${staticFileSrc}?date=${assetMetadata && assetMetadata.type === 'found' ? assetMetadata.fetchedAt : 0}`, assetMetadata: assetMetadata }));
40
40
  };
41
41
  exports.StaticFilePreview = StaticFilePreview;
@@ -0,0 +1 @@
1
+ export declare const handleUploadFile: (file: File, assetPath: string) => Promise<void>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleUploadFile = void 0;
4
+ const NotificationCenter_1 = require("./Notifications/NotificationCenter");
5
+ const handleUploadFile = async (file, assetPath) => {
6
+ if (!file) {
7
+ (0, NotificationCenter_1.showNotification)('Please select a file first!', 3000);
8
+ return;
9
+ }
10
+ try {
11
+ const url = new URL('/api/add-asset', window.location.origin);
12
+ url.search = new URLSearchParams({
13
+ folder: assetPath,
14
+ file: file.name,
15
+ }).toString();
16
+ const response = await fetch(url, {
17
+ method: 'POST',
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);
30
+ }
31
+ };
32
+ exports.handleUploadFile = handleUploadFile;
@@ -4529,7 +4529,7 @@ var getSrcFromCanvasContent = (canvasContent) => {
4529
4529
  }
4530
4530
  return remotion_outputsBase + canvasContent.path;
4531
4531
  };
4532
- var getAssetMetadata = async (canvasContent) => {
4532
+ var getAssetMetadata = async (canvasContent, addTime) => {
4533
4533
  const src = getSrcFromCanvasContent(canvasContent);
4534
4534
  const file2 = await fetch(src, {
4535
4535
  method: "HEAD"
@@ -4544,13 +4544,16 @@ var getAssetMetadata = async (canvasContent) => {
4544
4544
  if (!size) {
4545
4545
  throw new Error("Unexpected error: content-length is null");
4546
4546
  }
4547
+ const fetchedAt = Date.now();
4548
+ const srcWithTime = addTime ? `${src}?date=${fetchedAt}` : src;
4547
4549
  const fileType = getPreviewFileType(src);
4548
4550
  if (fileType === "video") {
4549
- const resolution = await getVideoMetadata(src);
4551
+ const resolution = await getVideoMetadata(srcWithTime);
4550
4552
  return {
4551
4553
  type: "found",
4552
4554
  size: Number(size),
4553
- dimensions: { width: resolution.width, height: resolution.height }
4555
+ dimensions: { width: resolution.width, height: resolution.height },
4556
+ fetchedAt
4554
4557
  };
4555
4558
  }
4556
4559
  if (fileType === "image") {
@@ -4560,20 +4563,22 @@ var getAssetMetadata = async (canvasContent) => {
4560
4563
  resolve({
4561
4564
  type: "found",
4562
4565
  size: Number(size),
4563
- dimensions: { width: img.width, height: img.height }
4566
+ dimensions: { width: img.width, height: img.height },
4567
+ fetchedAt
4564
4568
  });
4565
4569
  };
4566
4570
  img.onerror = () => {
4567
4571
  reject(new Error("Failed to load image"));
4568
4572
  };
4569
- img.src = src;
4573
+ img.src = srcWithTime;
4570
4574
  });
4571
4575
  return resolution;
4572
4576
  }
4573
4577
  return {
4574
4578
  type: "found",
4575
4579
  dimensions: "none",
4576
- size: Number(size)
4580
+ size: Number(size),
4581
+ fetchedAt
4577
4582
  };
4578
4583
  };
4579
4584
 
@@ -5029,7 +5034,7 @@ var StaticFilePreview = ({ currentAsset, assetMetadata }) => {
5029
5034
  return jsx48(FilePreview, {
5030
5035
  currentAsset,
5031
5036
  fileType,
5032
- src: staticFileSrc,
5037
+ src: `${staticFileSrc}?date=${assetMetadata && assetMetadata.type === "found" ? assetMetadata.fetchedAt : 0}`,
5033
5038
  assetMetadata
5034
5039
  });
5035
5040
  };
@@ -8663,7 +8668,7 @@ useEffect as useEffect32,
8663
8668
  useMemo as useMemo48,
8664
8669
  useState as useState34
8665
8670
  } from "react";
8666
- import {Internals as Internals22} from "remotion";
8671
+ import {Internals as Internals22, watchStaticFile} from "remotion";
8667
8672
 
8668
8673
  // src/helpers/get-effective-translation.ts
8669
8674
  var getEffectiveXTranslation = ({
@@ -9713,9 +9718,20 @@ var Canvas = ({ canvasContent, size: size2, isRefreshing }) => {
9713
9718
  if (canvasContent.type === "composition") {
9714
9719
  return;
9715
9720
  }
9716
- const metadata = await getAssetMetadata(canvasContent);
9721
+ const metadata = await getAssetMetadata(canvasContent, canvasContent.type === "asset");
9717
9722
  setAssetResolution(metadata);
9718
9723
  }, [canvasContent]);
9724
+ useEffect32(() => {
9725
+ if (canvasContent.type !== "asset") {
9726
+ return;
9727
+ }
9728
+ const file2 = watchStaticFile(canvasContent.asset, () => {
9729
+ fetchMetadata();
9730
+ });
9731
+ return () => {
9732
+ file2.cancel();
9733
+ };
9734
+ }, [canvasContent, fetchMetadata]);
9719
9735
  useEffect32(() => {
9720
9736
  fetchMetadata();
9721
9737
  }, [fetchMetadata]);
@@ -7,5 +7,6 @@ export type AssetMetadata = {
7
7
  type: 'found';
8
8
  size: number;
9
9
  dimensions: Dimensions | 'none' | null;
10
+ fetchedAt: number;
10
11
  };
11
- export declare const getAssetMetadata: (canvasContent: CanvasContent) => Promise<AssetMetadata>;
12
+ export declare const getAssetMetadata: (canvasContent: CanvasContent, addTime: boolean) => Promise<AssetMetadata>;
@@ -14,7 +14,7 @@ const getSrcFromCanvasContent = (canvasContent) => {
14
14
  }
15
15
  return exports.remotion_outputsBase + canvasContent.path;
16
16
  };
17
- const getAssetMetadata = async (canvasContent) => {
17
+ const getAssetMetadata = async (canvasContent, addTime) => {
18
18
  const src = getSrcFromCanvasContent(canvasContent);
19
19
  const file = await fetch(src, {
20
20
  method: 'HEAD',
@@ -29,13 +29,16 @@ const getAssetMetadata = async (canvasContent) => {
29
29
  if (!size) {
30
30
  throw new Error('Unexpected error: content-length is null');
31
31
  }
32
+ const fetchedAt = Date.now();
33
+ const srcWithTime = addTime ? `${src}?date=${fetchedAt}` : src;
32
34
  const fileType = (0, Preview_1.getPreviewFileType)(src);
33
35
  if (fileType === 'video') {
34
- const resolution = await (0, media_utils_1.getVideoMetadata)(src);
36
+ const resolution = await (0, media_utils_1.getVideoMetadata)(srcWithTime);
35
37
  return {
36
38
  type: 'found',
37
39
  size: Number(size),
38
40
  dimensions: { width: resolution.width, height: resolution.height },
41
+ fetchedAt,
39
42
  };
40
43
  }
41
44
  if (fileType === 'image') {
@@ -46,12 +49,13 @@ const getAssetMetadata = async (canvasContent) => {
46
49
  type: 'found',
47
50
  size: Number(size),
48
51
  dimensions: { width: img.width, height: img.height },
52
+ fetchedAt,
49
53
  });
50
54
  };
51
55
  img.onerror = () => {
52
56
  reject(new Error('Failed to load image'));
53
57
  };
54
- img.src = src;
58
+ img.src = srcWithTime;
55
59
  });
56
60
  return resolution;
57
61
  }
@@ -59,6 +63,7 @@ const getAssetMetadata = async (canvasContent) => {
59
63
  type: 'found',
60
64
  dimensions: 'none',
61
65
  size: Number(size),
66
+ fetchedAt,
62
67
  };
63
68
  };
64
69
  exports.getAssetMetadata = getAssetMetadata;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/studio"
4
4
  },
5
5
  "name": "@remotion/studio",
6
- "version": "4.0.200",
6
+ "version": "4.0.202",
7
7
  "description": "APIs for interacting with the Remotion Studio",
8
8
  "main": "dist",
9
9
  "sideEffects": false,
@@ -18,18 +18,18 @@
18
18
  "memfs": "3.4.3",
19
19
  "source-map": "0.7.3",
20
20
  "open": "^8.4.2",
21
- "remotion": "4.0.200",
22
- "@remotion/player": "4.0.200",
23
- "@remotion/media-utils": "4.0.200",
24
- "@remotion/renderer": "4.0.200",
25
- "@remotion/studio-shared": "4.0.200"
21
+ "remotion": "4.0.202",
22
+ "@remotion/media-utils": "4.0.202",
23
+ "@remotion/player": "4.0.202",
24
+ "@remotion/studio-shared": "4.0.202",
25
+ "@remotion/renderer": "4.0.202"
26
26
  },
27
27
  "devDependencies": {
28
28
  "react": "18.3.1",
29
29
  "react-dom": "18.3.1",
30
30
  "@types/semver": "^7.3.4",
31
31
  "zod": "3.22.3",
32
- "@remotion/zod-types": "4.0.200"
32
+ "@remotion/zod-types": "4.0.202"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"