@remotion/studio 4.0.145 → 4.0.147

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.
@@ -2942,6 +2942,28 @@ useMemo as useMemo22,
2942
2942
  useState as useState16
2943
2943
  } from "react";
2944
2944
 
2945
+ // src/api/write-static-file.ts
2946
+ var writeStaticFile = async ({
2947
+ contents,
2948
+ filePath
2949
+ }) => {
2950
+ const url = new URL("/api/add-asset", window.location.origin);
2951
+ if (filePath.includes("\\")) {
2952
+ return Promise.reject(new Error("File path cannot contain backslashes"));
2953
+ }
2954
+ url.search = new URLSearchParams({
2955
+ filePath
2956
+ }).toString();
2957
+ const response = await fetch(url, {
2958
+ method: "POST",
2959
+ body: contents
2960
+ });
2961
+ if (!response.ok) {
2962
+ const jsonResponse = await response.json();
2963
+ throw new Error(jsonResponse.error);
2964
+ }
2965
+ };
2966
+
2945
2967
  // src/helpers/use-asset-drag-events.ts
2946
2968
  import {useCallback as useCallback14, useEffect as useEffect11, useMemo as useMemo20, useRef as useRef9} from "react";
2947
2969
  import {NoReactInternals} from "remotion/no-react";
@@ -3280,7 +3302,7 @@ var updateAvailable = (signal) => {
3280
3302
  var getProjectInfo = (signal) => {
3281
3303
  return callApi("/api/project-info", {}, signal);
3282
3304
  };
3283
- var updateDefaultProps = (compositionId, defaultProps, enumPaths) => {
3305
+ var callUpdateDefaultPropsApi = (compositionId, defaultProps, enumPaths) => {
3284
3306
  return callApi("/api/update-default-props", {
3285
3307
  compositionId,
3286
3308
  defaultProps: NoReactInternals2.serializeJSONWithDate({
@@ -3598,23 +3620,6 @@ var AssetSelectorItem = ({ item, tabIndex, level, parentFolder }) => {
3598
3620
  }, undefined, false, undefined, this);
3599
3621
  };
3600
3622
 
3601
- // src/components/utils.ts
3602
- var handleUploadFile = async (file2, assetPath) => {
3603
- const url = new URL("/api/add-asset", window.location.origin);
3604
- url.search = new URLSearchParams({
3605
- folder: assetPath,
3606
- file: file2.name
3607
- }).toString();
3608
- const response = await fetch(url, {
3609
- method: "POST",
3610
- body: file2
3611
- });
3612
- if (!response.ok) {
3613
- const jsonResponse = await response.json();
3614
- throw new Error(jsonResponse.error);
3615
- }
3616
- };
3617
-
3618
3623
  // src/components/AssetSelector.tsx
3619
3624
  import {
3620
3625
  jsx as jsx33
@@ -3699,7 +3704,11 @@ var AssetSelector = ({ readOnlyStudio }) => {
3699
3704
  const { files } = e.dataTransfer;
3700
3705
  const assetPath = dropLocation || "/";
3701
3706
  for (const file2 of files) {
3702
- await handleUploadFile(file2, assetPath);
3707
+ const body = await file2.arrayBuffer();
3708
+ await writeStaticFile({
3709
+ contents: body,
3710
+ filePath: file2.name
3711
+ });
3703
3712
  }
3704
3713
  if (files.length === 1) {
3705
3714
  showNotification(`Added ${files[0].name} to ${assetPath}`, 3000);
@@ -14016,8 +14025,8 @@ var setPersistedShowWarningState = (val) => {
14016
14025
  };
14017
14026
  var DataEditor = ({
14018
14027
  unresolvedComposition,
14019
- inputProps,
14020
- setInputProps,
14028
+ defaultProps,
14029
+ setDefaultProps,
14021
14030
  mayShowSaveButton,
14022
14031
  propsEditType,
14023
14032
  saving,
@@ -14031,13 +14040,13 @@ var DataEditor = ({
14031
14040
  if (!inJSONEditor) {
14032
14041
  return null;
14033
14042
  }
14034
- const value = inputProps;
14043
+ const value = defaultProps;
14035
14044
  return NoReactInternals10.serializeJSONWithDate({
14036
14045
  data: value,
14037
14046
  indent: 2,
14038
14047
  staticBase: window.remotion_staticBase
14039
14048
  });
14040
- }, [inJSONEditor, inputProps]);
14049
+ }, [inJSONEditor, defaultProps]);
14041
14050
  const cliProps = getInputProps();
14042
14051
  const [canSaveDefaultPropsObjectState, setCanSaveDefaultProps] = useState44({
14043
14052
  [unresolvedComposition.id]: defaultTypeCanSaveState
@@ -14062,8 +14071,8 @@ var DataEditor = ({
14062
14071
  if (schema === "no-schema") {
14063
14072
  return "no-schema";
14064
14073
  }
14065
- return schema.safeParse(inputProps);
14066
- }, [inputProps, schema]);
14074
+ return schema.safeParse(defaultProps);
14075
+ }, [defaultProps, schema]);
14067
14076
  const setShowWarning = useCallback60((val) => {
14068
14077
  setShowWarningWithoutPersistance((prevVal) => {
14069
14078
  if (typeof val === "boolean") {
@@ -14145,12 +14154,12 @@ var DataEditor = ({
14145
14154
  showNotification("Cannot update default props: No Zod schema", 2000);
14146
14155
  return;
14147
14156
  }
14148
- updateDefaultProps(unresolvedComposition.id, inputProps, extractEnumJsonPaths(schema, z, [])).then((response) => {
14157
+ callUpdateDefaultPropsApi(unresolvedComposition.id, defaultProps, extractEnumJsonPaths(schema, z, [])).then((response) => {
14149
14158
  if (!response.success) {
14150
14159
  showNotification(`Cannot update default props: ${response.reason}`, 2000);
14151
14160
  }
14152
14161
  });
14153
- }, [unresolvedComposition.id, inputProps, schema, z]);
14162
+ }, [unresolvedComposition.id, defaultProps, schema, z]);
14154
14163
  useEffect41(() => {
14155
14164
  setSaving(false);
14156
14165
  }, [fastRefreshes, setSaving]);
@@ -14160,7 +14169,7 @@ var DataEditor = ({
14160
14169
  return;
14161
14170
  }
14162
14171
  setSaving(true);
14163
- updateDefaultProps(unresolvedComposition.id, updater(unresolvedComposition.defaultProps ?? {}), extractEnumJsonPaths(schema, z, [])).then((response) => {
14172
+ callUpdateDefaultPropsApi(unresolvedComposition.id, updater(unresolvedComposition.defaultProps ?? {}), extractEnumJsonPaths(schema, z, [])).then((response) => {
14164
14173
  if (!response.success) {
14165
14174
  console.log(response.stack);
14166
14175
  showNotification(`Cannot update default props: ${response.reason}. See console for more information.`, 2000);
@@ -14272,8 +14281,8 @@ var DataEditor = ({
14272
14281
  ]
14273
14282
  }, undefined, true, undefined, this),
14274
14283
  mode === "schema" ? jsx127(SchemaEditor, {
14275
- value: inputProps,
14276
- setValue: setInputProps,
14284
+ value: defaultProps,
14285
+ setValue: setDefaultProps,
14277
14286
  schema,
14278
14287
  zodValidationResult,
14279
14288
  defaultProps: unresolvedComposition.defaultProps,
@@ -14282,8 +14291,8 @@ var DataEditor = ({
14282
14291
  saving,
14283
14292
  saveDisabledByParent: !zodValidationResult.success
14284
14293
  }, undefined, false, undefined, this) : jsx127(RenderModalJSONPropsEditor, {
14285
- value: inputProps ?? {},
14286
- setValue: setInputProps,
14294
+ value: defaultProps ?? {},
14295
+ setValue: setDefaultProps,
14287
14296
  onSave: onUpdate,
14288
14297
  showSaveButton,
14289
14298
  serializedJSON,
@@ -15246,7 +15255,7 @@ var OptionsPanel = ({ readOnlyStudio }) => {
15246
15255
  const saveToolTip = useMemo80(() => {
15247
15256
  return process.env.KEYBOARD_SHORTCUTS_ENABLED ? `Save using ${cmdOrCtrlCharacter}+S` : "There are unsaved changes";
15248
15257
  }, []);
15249
- const setInputProps = useCallback70((newProps) => {
15258
+ const setDefaultProps = useCallback70((newProps) => {
15250
15259
  if (composition === null) {
15251
15260
  return;
15252
15261
  }
@@ -15256,7 +15265,7 @@ var OptionsPanel = ({ readOnlyStudio }) => {
15256
15265
  newProps
15257
15266
  });
15258
15267
  }, [composition, updateProps]);
15259
- const actualProps = useMemo80(() => {
15268
+ const currentDefaultProps = useMemo80(() => {
15260
15269
  if (composition === null) {
15261
15270
  return {};
15262
15271
  }
@@ -15266,8 +15275,8 @@ var OptionsPanel = ({ readOnlyStudio }) => {
15266
15275
  if (composition === null || composition.defaultProps === undefined) {
15267
15276
  return false;
15268
15277
  }
15269
- return !deepEqual(composition.defaultProps, actualProps);
15270
- }, [actualProps, composition]);
15278
+ return !deepEqual(composition.defaultProps, currentDefaultProps);
15279
+ }, [currentDefaultProps, composition]);
15271
15280
  return jsx141("div", {
15272
15281
  style: container27,
15273
15282
  className: "css-reset",
@@ -15297,8 +15306,8 @@ var OptionsPanel = ({ readOnlyStudio }) => {
15297
15306
  }, undefined, false, undefined, this),
15298
15307
  panel === `input-props` && composition ? jsx141(DataEditor, {
15299
15308
  unresolvedComposition: composition,
15300
- inputProps: actualProps,
15301
- setInputProps,
15309
+ defaultProps: currentDefaultProps,
15310
+ setDefaultProps,
15302
15311
  mayShowSaveButton: true,
15303
15312
  propsEditType: "default-props",
15304
15313
  saving,
@@ -25606,8 +25615,8 @@ var RenderModal = ({
25606
25615
  setLimitNumberOfGifLoops,
25607
25616
  setNumberOfGifLoopsSetting
25608
25617
  }, undefined, false, undefined, this) : tab === "data" ? jsx232(DataEditor, {
25609
- inputProps,
25610
- setInputProps,
25618
+ defaultProps: inputProps,
25619
+ setDefaultProps: setInputProps,
25611
25620
  unresolvedComposition,
25612
25621
  mayShowSaveButton: false,
25613
25622
  propsEditType: "input-props",
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export { StaticFile, getStaticFiles } from './api/get-static-files';
2
+ export { saveDefaultProps } from './api/save-default-props';
2
3
  export { watchStaticFile } from './api/watch-static-file';
4
+ export { writeStaticFile } from './api/write-static-file';
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.watchStaticFile = exports.getStaticFiles = void 0;
3
+ exports.writeStaticFile = exports.watchStaticFile = exports.saveDefaultProps = exports.getStaticFiles = void 0;
4
4
  var get_static_files_1 = require("./api/get-static-files");
5
5
  Object.defineProperty(exports, "getStaticFiles", { enumerable: true, get: function () { return get_static_files_1.getStaticFiles; } });
6
+ var save_default_props_1 = require("./api/save-default-props");
7
+ Object.defineProperty(exports, "saveDefaultProps", { enumerable: true, get: function () { return save_default_props_1.saveDefaultProps; } });
6
8
  var watch_static_file_1 = require("./api/watch-static-file");
7
9
  Object.defineProperty(exports, "watchStaticFile", { enumerable: true, get: function () { return watch_static_file_1.watchStaticFile; } });
10
+ var write_static_file_1 = require("./api/write-static-file");
11
+ Object.defineProperty(exports, "writeStaticFile", { enumerable: true, get: function () { return write_static_file_1.writeStaticFile; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/studio",
3
- "version": "4.0.145",
3
+ "version": "4.0.147",
4
4
  "description": "Remotion Editor",
5
5
  "main": "dist",
6
6
  "sideEffects": false,
@@ -18,11 +18,11 @@
18
18
  "memfs": "3.4.3",
19
19
  "source-map": "0.7.3",
20
20
  "open": "^8.4.2",
21
- "remotion": "4.0.145",
22
- "@remotion/player": "4.0.145",
23
- "@remotion/renderer": "4.0.145",
24
- "@remotion/media-utils": "4.0.145",
25
- "@remotion/studio-shared": "4.0.145"
21
+ "remotion": "4.0.147",
22
+ "@remotion/player": "4.0.147",
23
+ "@remotion/renderer": "4.0.147",
24
+ "@remotion/media-utils": "4.0.147",
25
+ "@remotion/studio-shared": "4.0.147"
26
26
  },
27
27
  "devDependencies": {
28
28
  "react": "18.2.0",
@@ -39,7 +39,7 @@
39
39
  "@types/semver": "^7.3.4",
40
40
  "prettier-plugin-organize-imports": "3.2.4",
41
41
  "zod": "^3.22.3",
42
- "@remotion/zod-types": "4.0.145"
42
+ "@remotion/zod-types": "4.0.147"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"