@remotion/player 4.0.471 → 4.0.472

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.
@@ -42,7 +42,7 @@ export declare const PlayerInternals: {
42
42
  getCurrentFrame: () => number;
43
43
  muted: boolean;
44
44
  }) => void;
45
- useElementSize: (ref: import("react").RefObject<HTMLElement | null>, options: {
45
+ useElementSize: (source: HTMLElement | import("react").RefObject<HTMLElement | null> | null, options: {
46
46
  triggerOnWindowResize: boolean;
47
47
  shouldApplyCssTransforms: boolean;
48
48
  }) => import("./index.js").Size | null;
@@ -10,7 +10,9 @@ export type Size = {
10
10
  refresh: () => void;
11
11
  };
12
12
  export declare const updateAllElementsSizes: () => void;
13
- export declare const useElementSize: (ref: import("react").RefObject<HTMLElement | null>, options: {
13
+ type ElementSizeSource = React.RefObject<HTMLElement | null> | HTMLElement | null;
14
+ export declare const useElementSize: (source: ElementSizeSource, options: {
14
15
  triggerOnWindowResize: boolean;
15
16
  shouldApplyCssTransforms: boolean;
16
17
  }) => Size | null;
18
+ export {};
@@ -9,12 +9,22 @@ const updateAllElementsSizes = () => {
9
9
  }
10
10
  };
11
11
  exports.updateAllElementsSizes = updateAllElementsSizes;
12
- const useElementSize = (ref, options) => {
12
+ const getElement = (source) => {
13
+ if (!source) {
14
+ return null;
15
+ }
16
+ if ('current' in source) {
17
+ return source.current;
18
+ }
19
+ return source;
20
+ };
21
+ const useElementSize = (source, options) => {
13
22
  const [size, setSize] = (0, react_1.useState)(() => {
14
- if (!ref.current) {
23
+ const element = getElement(source);
24
+ if (!element) {
15
25
  return null;
16
26
  }
17
- const rect = ref.current.getClientRects();
27
+ const rect = element.getClientRects();
18
28
  if (!rect[0]) {
19
29
  return null;
20
30
  }
@@ -77,10 +87,11 @@ const useElementSize = (ref, options) => {
77
87
  });
78
88
  }, [options.shouldApplyCssTransforms]);
79
89
  const updateSize = (0, react_1.useCallback)(() => {
80
- if (!ref.current) {
90
+ const element = getElement(source);
91
+ if (!element) {
81
92
  return;
82
93
  }
83
- const rect = ref.current.getClientRects();
94
+ const rect = element.getClientRects();
84
95
  if (!rect[0]) {
85
96
  setSize(null);
86
97
  return;
@@ -107,21 +118,24 @@ const useElementSize = (ref, options) => {
107
118
  },
108
119
  };
109
120
  });
110
- }, [ref]);
121
+ }, [source]);
122
+ (0, react_1.useEffect)(() => {
123
+ updateSize();
124
+ }, [updateSize]);
111
125
  (0, react_1.useEffect)(() => {
112
126
  if (!observer) {
113
127
  return;
114
128
  }
115
- const { current } = ref;
116
- if (current) {
117
- observer.observe(current);
129
+ const element = getElement(source);
130
+ if (element) {
131
+ observer.observe(element);
118
132
  }
119
133
  return () => {
120
- if (current) {
121
- observer.unobserve(current);
134
+ if (element) {
135
+ observer.unobserve(element);
122
136
  }
123
137
  };
124
- }, [observer, ref, updateSize]);
138
+ }, [observer, source]);
125
139
  (0, react_1.useEffect)(() => {
126
140
  if (!options.triggerOnWindowResize) {
127
141
  return;
@@ -1186,12 +1186,22 @@ var updateAllElementsSizes = () => {
1186
1186
  listener();
1187
1187
  }
1188
1188
  };
1189
- var useElementSize = (ref, options) => {
1189
+ var getElement = (source) => {
1190
+ if (!source) {
1191
+ return null;
1192
+ }
1193
+ if ("current" in source) {
1194
+ return source.current;
1195
+ }
1196
+ return source;
1197
+ };
1198
+ var useElementSize = (source, options) => {
1190
1199
  const [size, setSize] = useState4(() => {
1191
- if (!ref.current) {
1200
+ const element = getElement(source);
1201
+ if (!element) {
1192
1202
  return null;
1193
1203
  }
1194
- const rect = ref.current.getClientRects();
1204
+ const rect = element.getClientRects();
1195
1205
  if (!rect[0]) {
1196
1206
  return null;
1197
1207
  }
@@ -1240,10 +1250,11 @@ var useElementSize = (ref, options) => {
1240
1250
  });
1241
1251
  }, [options.shouldApplyCssTransforms]);
1242
1252
  const updateSize = useCallback2(() => {
1243
- if (!ref.current) {
1253
+ const element = getElement(source);
1254
+ if (!element) {
1244
1255
  return;
1245
1256
  }
1246
- const rect = ref.current.getClientRects();
1257
+ const rect = element.getClientRects();
1247
1258
  if (!rect[0]) {
1248
1259
  setSize(null);
1249
1260
  return;
@@ -1264,21 +1275,24 @@ var useElementSize = (ref, options) => {
1264
1275
  }
1265
1276
  };
1266
1277
  });
1267
- }, [ref]);
1278
+ }, [source]);
1279
+ useEffect6(() => {
1280
+ updateSize();
1281
+ }, [updateSize]);
1268
1282
  useEffect6(() => {
1269
1283
  if (!observer) {
1270
1284
  return;
1271
1285
  }
1272
- const { current } = ref;
1273
- if (current) {
1274
- observer.observe(current);
1286
+ const element = getElement(source);
1287
+ if (element) {
1288
+ observer.observe(element);
1275
1289
  }
1276
1290
  return () => {
1277
- if (current) {
1278
- observer.unobserve(current);
1291
+ if (element) {
1292
+ observer.unobserve(element);
1279
1293
  }
1280
1294
  };
1281
- }, [observer, ref, updateSize]);
1295
+ }, [observer, source]);
1282
1296
  useEffect6(() => {
1283
1297
  if (!options.triggerOnWindowResize) {
1284
1298
  return;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/player"
4
4
  },
5
5
  "name": "@remotion/player",
6
- "version": "4.0.471",
6
+ "version": "4.0.472",
7
7
  "description": "React component for embedding a Remotion preview into your app",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "license": "SEE LICENSE IN LICENSE.md",
37
37
  "dependencies": {
38
- "remotion": "4.0.471"
38
+ "remotion": "4.0.472"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": ">=16.8.0",
@@ -49,7 +49,7 @@
49
49
  "react-dom": "19.2.3",
50
50
  "webpack": "5.105.0",
51
51
  "zod": "4.3.6",
52
- "@remotion/eslint-config-internal": "4.0.471",
52
+ "@remotion/eslint-config-internal": "4.0.472",
53
53
  "eslint": "9.19.0",
54
54
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
55
55
  },