@cueframe/kernel 0.0.1 → 0.1.0

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.
Files changed (122) hide show
  1. package/dist/_members/account-model/testing/conversationStoreContract.d.ts +1 -1
  2. package/dist/_members/authoring/providers/resourceApi.d.ts +1 -1
  3. package/dist/_members/authoring/transpileComponent.d.ts +1 -1
  4. package/dist/_members/cloud-import/CloudImportService.d.ts +35 -0
  5. package/dist/_members/cloud-import/ImportProvider.d.ts +73 -0
  6. package/dist/_members/cloud-import/MediaItemPreprocessor.d.ts +27 -0
  7. package/dist/_members/cloud-import/chunk-XKO6ZSWI.js +162 -0
  8. package/dist/_members/cloud-import/chunk-XKO6ZSWI.js.map +1 -0
  9. package/dist/_members/cloud-import/cloudConfig.d.ts +23 -0
  10. package/dist/_members/cloud-import/index.d.ts +9 -0
  11. package/dist/_members/cloud-import/index.js +241 -0
  12. package/dist/_members/cloud-import/index.js.map +1 -0
  13. package/dist/_members/cloud-import/multipartUpload.d.ts +12 -0
  14. package/dist/_members/cloud-import/multipartUpload.js +7 -0
  15. package/dist/_members/cloud-import/multipartUpload.js.map +1 -0
  16. package/dist/_members/composition/ops/compositionOps.d.ts +1 -1
  17. package/dist/_members/composition/ops/types.d.ts +1 -1
  18. package/dist/_members/composition/timeline/placement.d.ts +1 -1
  19. package/dist/_members/composition/validators/composition.d.ts +1 -1
  20. package/dist/_members/composition-ops/index.d.ts +1 -1
  21. package/dist/_members/composition-ops/opRecorder.d.ts +1 -1
  22. package/dist/_members/convex-api/api.d.ts +5 -0
  23. package/dist/_members/convex-api/dataModel.d.ts +6 -0
  24. package/dist/_members/core/render/exportSettings.d.ts +1 -1
  25. package/dist/_members/mcp/curation.d.ts +1 -1
  26. package/dist/_members/plane/conformance.d.ts +1 -1
  27. package/dist/_members/render-harness/localRender.d.ts +1 -1
  28. package/dist/animate.js +828 -79187
  29. package/dist/authoring/build-tools.js +8 -11
  30. package/dist/authoring/context.js +5 -5
  31. package/dist/authoring/models.js +1 -2
  32. package/dist/authoring/prompts.js +1 -1
  33. package/dist/authoring/tools.js +7 -7
  34. package/dist/authoring/transpileComponent.js +3 -2220
  35. package/dist/authoring.js +27 -29
  36. package/dist/brand-derivation.js +1 -1
  37. package/dist/chunk-6IU2UQI5.js +107 -0
  38. package/dist/{chunk-N67PDTKQ.js → chunk-ABL557OT.js} +1 -1
  39. package/dist/{chunk-DSNG6WLU.js → chunk-AYVJXDLB.js} +1 -4
  40. package/dist/{chunk-G3PBH53P.js → chunk-COYMZ76S.js} +1 -1
  41. package/dist/chunk-DSMLHYJ4.js +82 -0
  42. package/dist/{chunk-BRKJKB33.js → chunk-FYZVH3MC.js} +1 -1
  43. package/dist/{chunk-MVEE6HEC.js → chunk-GA23TRNR.js} +5 -7
  44. package/dist/{chunk-OIRUO5P7.js → chunk-GEA7E2FL.js} +1 -1
  45. package/dist/chunk-HCCBDJLW.js +68 -0
  46. package/dist/{chunk-QLAQHR3L.js → chunk-IBYQG46O.js} +1 -1
  47. package/dist/chunk-JQMPHKLU.js +126 -0
  48. package/dist/{chunk-ELLSET2N.js → chunk-LM4WDUQJ.js} +3 -6
  49. package/dist/{chunk-UEI3NLNK.js → chunk-MHOQTPOB.js} +1 -4
  50. package/dist/{chunk-ATAF24QG.js → chunk-MXFAADCQ.js} +1 -1
  51. package/dist/{chunk-TULRCY6U.js → chunk-NFEGPWGS.js} +1 -1
  52. package/dist/{chunk-MC5DLSEV.js → chunk-ODL7GQJG.js} +14 -14
  53. package/dist/{chunk-WZTTZHNR.js → chunk-OLFOPQCA.js} +12 -9
  54. package/dist/{chunk-P43IE4WB.js → chunk-P727GZVO.js} +2 -4
  55. package/dist/{chunk-S3P5BFFL.js → chunk-PMY24FUD.js} +2 -4
  56. package/dist/chunk-RF7U3SCL.js +606 -0
  57. package/dist/{chunk-JD77Y2WM.js → chunk-SW336CJP.js} +1 -4
  58. package/dist/{chunk-M3I5LMAB.js → chunk-UY4SWJVE.js} +1 -1
  59. package/dist/{chunk-52AHXNKM.js → chunk-VOO5FQSS.js} +5 -5
  60. package/dist/{chunk-NV4I6GJV.js → chunk-XWKZB5U5.js} +4 -4
  61. package/dist/{chunk-6QJ3V3VS.js → chunk-YX2GSJK7.js} +1 -1
  62. package/dist/{chunk-5I7VDCAC.js → chunk-ZB3C3HM7.js} +1 -1
  63. package/dist/chunk-ZT7MHRQU.js +104 -0
  64. package/dist/cloud-import/multipart.d.ts +1 -0
  65. package/dist/cloud-import/multipart.js +8 -0
  66. package/dist/cloud-import.d.ts +1 -0
  67. package/dist/cloud-import.js +234 -0
  68. package/dist/compose/renderer.js +18 -21
  69. package/dist/compose.js +18 -21
  70. package/dist/composition/graphics-plan.js +3 -3
  71. package/dist/composition/ops.js +4 -4
  72. package/dist/composition/primitive-catalog.js +1 -1
  73. package/dist/composition/projection.js +3 -3
  74. package/dist/composition/validators.js +2 -2
  75. package/dist/composition-ops.js +12 -12
  76. package/dist/composition.js +5 -5
  77. package/dist/{context-CEAKQ5T7.js → context-OKX3HHFS.js} +5 -5
  78. package/dist/convex-api/dataModel.d.ts +1 -0
  79. package/dist/convex-api/dataModel.js +0 -0
  80. package/dist/convex-api.d.ts +1 -0
  81. package/dist/convex-api.js +8 -0
  82. package/dist/core/render.js +2 -2
  83. package/dist/core.js +2 -2
  84. package/dist/mcp/adapter.js +1 -5
  85. package/dist/mcp/server.js +1 -2
  86. package/dist/mcp.js +2 -95
  87. package/dist/media-model/media-kind.js +9 -98
  88. package/dist/nle-export/xml.js +5 -22799
  89. package/dist/nle-export.js +18 -21
  90. package/dist/primitives/backgrounds.js +2 -3
  91. package/dist/primitives/captions.js +4 -243
  92. package/dist/primitives/effects.js +2 -3
  93. package/dist/primitives/hero-text.js +2 -3
  94. package/dist/primitives/layouts.js +2 -3
  95. package/dist/primitives/lib/index.js +8 -10
  96. package/dist/primitives/lib/preview.js +1 -2
  97. package/dist/primitives/lib/schema.js +1 -2
  98. package/dist/primitives/lib/text/fitText.js +1 -2
  99. package/dist/primitives/lib.js +8 -10
  100. package/dist/primitives/scenes.js +1 -2
  101. package/dist/primitives/text.js +2 -3
  102. package/dist/primitives/ui-blocks.js +4 -5
  103. package/dist/primitives.js +19 -21
  104. package/package.json +123 -13
  105. package/dist/TextureLoader-UQOFUSAP.js +0 -422
  106. package/dist/VideoTexture-AQWSPIJG.js +0 -62
  107. package/dist/chunk-7GISRVON.js +0 -14176
  108. package/dist/chunk-DIBOJJMU.js +0 -16838
  109. package/dist/chunk-EAUSEGB7.js +0 -420
  110. package/dist/chunk-FUWJOVVK.js +0 -3633
  111. package/dist/chunk-G75E7YA4.js +0 -11883
  112. package/dist/chunk-JCZQT7K3.js +0 -3266
  113. package/dist/chunk-KF5ETMKB.js +0 -544
  114. package/dist/chunk-NDKERSXY.js +0 -1296
  115. package/dist/chunk-V43Y7IE4.js +0 -3621
  116. package/dist/chunk-VIVQHIGZ.js +0 -4319
  117. package/dist/chunk-YA3OR2KK.js +0 -249
  118. package/dist/hls-HD4C5G6W.js +0 -33000
  119. package/dist/token-RGFIT24D.js +0 -69
  120. package/dist/token-util-GPLSGYVO.js +0 -5
  121. package/dist/vision_bundle-5Y376MAR.js +0 -4084
  122. package/dist/{chunk-6CMVBTTP.js → chunk-YIOY2XEO.js} +4 -4
@@ -1,3633 +0,0 @@
1
- import {
2
- TransitionSeries,
3
- linearTiming
4
- } from "./chunk-EAUSEGB7.js";
5
-
6
- // ../execution/primitives/src/lib/preview.tsx
7
- import * as React2 from "react";
8
- import { AbsoluteFill } from "remotion";
9
-
10
- // ../../node_modules/.pnpm/@remotion+player@4.0.429_react-dom@19.2.7_react@19.2.7__react@19.2.7/node_modules/@remotion/player/dist/esm/index.mjs
11
- import { jsx, jsxs } from "react/jsx-runtime";
12
- import { jsx as jsx2, jsxs as jsxs2, Fragment } from "react/jsx-runtime";
13
- import { Internals } from "remotion";
14
- import React from "react";
15
- import { useContext as useContext2, useEffect, useState } from "react";
16
- import { Internals as Internals3 } from "remotion";
17
- import { useContext, useLayoutEffect } from "react";
18
- import { Internals as Internals2 } from "remotion";
19
- import { jsx as jsx3 } from "react/jsx-runtime";
20
- import { useCallback, useRef } from "react";
21
- import { Internals as Internals4 } from "remotion";
22
- import { useEffect as useEffect2, useState as useState2 } from "react";
23
- import { useContext as useContext4, useEffect as useEffect5, useRef as useRef5 } from "react";
24
- import { Internals as Internals6 } from "remotion";
25
- import { useEffect as useEffect3, useRef as useRef3 } from "react";
26
- import { useCallback as useCallback2, useContext as useContext3, useMemo, useRef as useRef2, useState as useState3 } from "react";
27
- import { Internals as Internals5 } from "remotion";
28
- import { useEffect as useEffect4, useRef as useRef4 } from "react";
29
- import { useCallback as useCallback3, useEffect as useEffect6, useMemo as useMemo2, useState as useState4 } from "react";
30
- import {
31
- forwardRef as forwardRef2,
32
- useEffect as useEffect13,
33
- useImperativeHandle as useImperativeHandle2,
34
- useLayoutEffect as useLayoutEffect2,
35
- useMemo as useMemo14,
36
- useRef as useRef12,
37
- useState as useState13
38
- } from "react";
39
- import { Composition, Internals as Internals15 } from "remotion";
40
- import React10, {
41
- Suspense,
42
- forwardRef,
43
- useCallback as useCallback11,
44
- useContext as useContext6,
45
- useEffect as useEffect12,
46
- useImperativeHandle,
47
- useMemo as useMemo12,
48
- useRef as useRef11,
49
- useState as useState11
50
- } from "react";
51
- import { Internals as Internals11 } from "remotion";
52
- import React3 from "react";
53
- import { jsx as jsx4 } from "react/jsx-runtime";
54
- import React4, { useEffect as useEffect7 } from "react";
55
- import { jsx as jsx5 } from "react/jsx-runtime";
56
- import { useCallback as useCallback8, useEffect as useEffect11, useMemo as useMemo9, useRef as useRef9, useState as useState10 } from "react";
57
- import { jsx as jsx6 } from "react/jsx-runtime";
58
- import { useCallback as useCallback5, useMemo as useMemo4, useRef as useRef6, useState as useState6 } from "react";
59
- import { Internals as Internals7 } from "remotion";
60
- import React5, { useCallback as useCallback4, useMemo as useMemo3, useState as useState5 } from "react";
61
- import { random } from "remotion";
62
- import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
63
- import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
64
- import {
65
- useCallback as useCallback6,
66
- useContext as useContext5,
67
- useEffect as useEffect9,
68
- useMemo as useMemo5,
69
- useState as useState8
70
- } from "react";
71
- import { Internals as Internals8 } from "remotion";
72
- import { useEffect as useEffect8, useRef as useRef7, useState as useState7 } from "react";
73
- import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
74
- import { useCallback as useCallback7, useEffect as useEffect10, useMemo as useMemo6, useRef as useRef8, useState as useState9 } from "react";
75
- import { Internals as Internals9, interpolate } from "remotion";
76
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
77
- import { useMemo as useMemo7 } from "react";
78
- import { Internals as Internals10 } from "remotion";
79
- import { jsxs as jsxs7 } from "react/jsx-runtime";
80
- import { useMemo as useMemo8 } from "react";
81
- import { jsx as jsx11, jsxs as jsxs8, Fragment as Fragment2 } from "react/jsx-runtime";
82
- import { useCallback as useCallback10, useMemo as useMemo11 } from "react";
83
- import { useCallback as useCallback9, useMemo as useMemo10, useRef as useRef10 } from "react";
84
- import { jsx as jsx12, jsxs as jsxs9, Fragment as Fragment3 } from "react/jsx-runtime";
85
- import { useCallback as useCallback12, useMemo as useMemo13, useState as useState12 } from "react";
86
- import { Internals as Internals13 } from "remotion";
87
- import { Internals as Internals12 } from "remotion";
88
- import { jsx as jsx13 } from "react/jsx-runtime";
89
- import { Internals as Internals14 } from "remotion";
90
- import { NoReactInternals } from "remotion/no-react";
91
- import { jsx as jsx14 } from "react/jsx-runtime";
92
- import {
93
- forwardRef as forwardRef4,
94
- useImperativeHandle as useImperativeHandle4,
95
- useLayoutEffect as useLayoutEffect3,
96
- useMemo as useMemo17,
97
- useRef as useRef14,
98
- useState as useState14
99
- } from "react";
100
- import { Internals as Internals17, random as random2 } from "remotion";
101
- import React13, {
102
- forwardRef as forwardRef3,
103
- Suspense as Suspense2,
104
- useCallback as useCallback13,
105
- useImperativeHandle as useImperativeHandle3,
106
- useMemo as useMemo16,
107
- useRef as useRef13
108
- } from "react";
109
- import { Internals as Internals16 } from "remotion";
110
- import { useContext as useContext7, useMemo as useMemo15 } from "react";
111
- import { jsx as jsx15 } from "react/jsx-runtime";
112
- import { jsx as jsx16 } from "react/jsx-runtime";
113
- var ICON_SIZE = 25;
114
- var fullscreenIconSize = 16;
115
- var PlayIcon = () => {
116
- return /* @__PURE__ */ jsx("svg", {
117
- width: ICON_SIZE,
118
- height: ICON_SIZE,
119
- viewBox: "0 0 25 25",
120
- fill: "none",
121
- children: /* @__PURE__ */ jsx("path", {
122
- d: "M8 6.375C7.40904 8.17576 7.06921 10.2486 7.01438 12.3871C6.95955 14.5255 7.19163 16.6547 7.6875 18.5625C9.95364 18.2995 12.116 17.6164 14.009 16.5655C15.902 15.5147 17.4755 14.124 18.6088 12.5C17.5158 10.8949 15.9949 9.51103 14.1585 8.45082C12.3222 7.3906 10.2174 6.68116 8 6.375Z",
123
- fill: "white",
124
- stroke: "white",
125
- strokeWidth: "6.25",
126
- strokeLinejoin: "round"
127
- })
128
- });
129
- };
130
- var PauseIcon = () => {
131
- return /* @__PURE__ */ jsxs("svg", {
132
- viewBox: "0 0 100 100",
133
- width: ICON_SIZE,
134
- height: ICON_SIZE,
135
- children: [
136
- /* @__PURE__ */ jsx("rect", {
137
- x: "25",
138
- y: "20",
139
- width: "20",
140
- height: "60",
141
- fill: "#fff",
142
- ry: "5",
143
- rx: "5"
144
- }),
145
- /* @__PURE__ */ jsx("rect", {
146
- x: "55",
147
- y: "20",
148
- width: "20",
149
- height: "60",
150
- fill: "#fff",
151
- ry: "5",
152
- rx: "5"
153
- })
154
- ]
155
- });
156
- };
157
- var FullscreenIcon = ({
158
- isFullscreen
159
- }) => {
160
- const strokeWidth = 6;
161
- const viewSize = 32;
162
- const out = isFullscreen ? 0 : strokeWidth / 2;
163
- const middleInset = isFullscreen ? strokeWidth * 1.6 : strokeWidth / 2;
164
- const inset = isFullscreen ? strokeWidth * 1.6 : strokeWidth * 2;
165
- return /* @__PURE__ */ jsxs("svg", {
166
- viewBox: `0 0 ${viewSize} ${viewSize}`,
167
- height: fullscreenIconSize,
168
- width: fullscreenIconSize,
169
- children: [
170
- /* @__PURE__ */ jsx("path", {
171
- d: `
172
- M ${out} ${inset}
173
- L ${middleInset} ${middleInset}
174
- L ${inset} ${out}
175
- `,
176
- stroke: "#fff",
177
- strokeWidth,
178
- fill: "none"
179
- }),
180
- /* @__PURE__ */ jsx("path", {
181
- d: `
182
- M ${viewSize - out} ${inset}
183
- L ${viewSize - middleInset} ${middleInset}
184
- L ${viewSize - inset} ${out}
185
- `,
186
- stroke: "#fff",
187
- strokeWidth,
188
- fill: "none"
189
- }),
190
- /* @__PURE__ */ jsx("path", {
191
- d: `
192
- M ${out} ${viewSize - inset}
193
- L ${middleInset} ${viewSize - middleInset}
194
- L ${inset} ${viewSize - out}
195
- `,
196
- stroke: "#fff",
197
- strokeWidth,
198
- fill: "none"
199
- }),
200
- /* @__PURE__ */ jsx("path", {
201
- d: `
202
- M ${viewSize - out} ${viewSize - inset}
203
- L ${viewSize - middleInset} ${viewSize - middleInset}
204
- L ${viewSize - inset} ${viewSize - out}
205
- `,
206
- stroke: "#fff",
207
- strokeWidth,
208
- fill: "none"
209
- })
210
- ]
211
- });
212
- };
213
- var VolumeOffIcon = () => {
214
- return /* @__PURE__ */ jsx("svg", {
215
- width: ICON_SIZE,
216
- height: ICON_SIZE,
217
- viewBox: "0 0 24 24",
218
- children: /* @__PURE__ */ jsx("path", {
219
- d: "M3.63 3.63a.996.996 0 000 1.41L7.29 8.7 7 9H4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h3l3.29 3.29c.63.63 1.71.18 1.71-.71v-4.17l4.18 4.18c-.49.37-1.02.68-1.6.91-.36.15-.58.53-.58.92 0 .72.73 1.18 1.39.91.8-.33 1.55-.77 2.22-1.31l1.34 1.34a.996.996 0 101.41-1.41L5.05 3.63c-.39-.39-1.02-.39-1.42 0zM19 12c0 .82-.15 1.61-.41 2.34l1.53 1.53c.56-1.17.88-2.48.88-3.87 0-3.83-2.4-7.11-5.78-8.4-.59-.23-1.22.23-1.22.86v.19c0 .38.25.71.61.85C17.18 6.54 19 9.06 19 12zm-8.71-6.29l-.17.17L12 7.76V6.41c0-.89-1.08-1.33-1.71-.7zM16.5 12A4.5 4.5 0 0014 7.97v1.79l2.48 2.48c.01-.08.02-.16.02-.24z",
220
- fill: "#fff"
221
- })
222
- });
223
- };
224
- var VolumeOnIcon = () => {
225
- return /* @__PURE__ */ jsx("svg", {
226
- width: ICON_SIZE,
227
- height: ICON_SIZE,
228
- viewBox: "0 0 24 24",
229
- children: /* @__PURE__ */ jsx("path", {
230
- d: "M3 10v4c0 .55.45 1 1 1h3l3.29 3.29c.63.63 1.71.18 1.71-.71V6.41c0-.89-1.08-1.34-1.71-.71L7 9H4c-.55 0-1 .45-1 1zm13.5 2A4.5 4.5 0 0014 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 4.45v.2c0 .38.25.71.6.85C17.18 6.53 19 9.06 19 12s-1.82 5.47-4.4 6.5c-.36.14-.6.47-.6.85v.2c0 .63.63 1.07 1.21.85C18.6 19.11 21 15.84 21 12s-2.4-7.11-5.79-8.4c-.58-.23-1.21.22-1.21.85z",
231
- fill: "#fff"
232
- })
233
- });
234
- };
235
- var className = "__remotion_buffering_indicator";
236
- var remotionBufferingAnimation = "__remotion_buffering_animation";
237
- var playerStyle = {
238
- width: ICON_SIZE,
239
- height: ICON_SIZE,
240
- overflow: "hidden",
241
- lineHeight: "normal",
242
- fontSize: "inherit"
243
- };
244
- var studioStyle = {
245
- width: 14,
246
- height: 14,
247
- overflow: "hidden",
248
- lineHeight: "normal",
249
- fontSize: "inherit"
250
- };
251
- var BufferingIndicator = ({ type }) => {
252
- const style2 = type === "player" ? playerStyle : studioStyle;
253
- return /* @__PURE__ */ jsxs2(Fragment, {
254
- children: [
255
- /* @__PURE__ */ jsx2("style", {
256
- type: "text/css",
257
- children: `
258
- @keyframes ${remotionBufferingAnimation} {
259
- 0% {
260
- rotate: 0deg;
261
- }
262
- 100% {
263
- rotate: 360deg;
264
- }
265
- }
266
-
267
- .${className} {
268
- animation: ${remotionBufferingAnimation} 1s linear infinite;
269
- }
270
- `
271
- }),
272
- /* @__PURE__ */ jsx2("div", {
273
- style: style2,
274
- children: /* @__PURE__ */ jsx2("svg", {
275
- viewBox: type === "player" ? "0 0 22 22" : "0 0 18 18",
276
- style: style2,
277
- className,
278
- children: /* @__PURE__ */ jsx2("path", {
279
- d: type === "player" ? "M 11 4 A 7 7 0 0 1 15.1145 16.66312" : "M 9 2 A 7 7 0 0 1 13.1145 14.66312",
280
- stroke: "white",
281
- strokeLinecap: "round",
282
- fill: "none",
283
- strokeWidth: 3
284
- })
285
- })
286
- })
287
- ]
288
- });
289
- };
290
- var calculatePlayerSize = ({
291
- currentSize,
292
- width,
293
- height,
294
- compositionWidth,
295
- compositionHeight
296
- }) => {
297
- if (width !== void 0 && height === void 0) {
298
- return {
299
- aspectRatio: [compositionWidth, compositionHeight].join("/")
300
- };
301
- }
302
- if (height !== void 0 && width === void 0) {
303
- return {
304
- aspectRatio: [compositionWidth, compositionHeight].join("/")
305
- };
306
- }
307
- if (!currentSize) {
308
- return {
309
- width: compositionWidth,
310
- height: compositionHeight
311
- };
312
- }
313
- return {
314
- width: compositionWidth,
315
- height: compositionHeight
316
- };
317
- };
318
- var calculateCanvasTransformation = ({
319
- previewSize,
320
- compositionWidth,
321
- compositionHeight,
322
- canvasSize
323
- }) => {
324
- const scale = Internals.calculateScale({
325
- canvasSize,
326
- compositionHeight,
327
- compositionWidth,
328
- previewSize
329
- });
330
- const correction = 0 - (1 - scale) / 2;
331
- const xCorrection = correction * compositionWidth;
332
- const yCorrection = correction * compositionHeight;
333
- const width = compositionWidth * scale;
334
- const height = compositionHeight * scale;
335
- const centerX = canvasSize.width / 2 - width / 2;
336
- const centerY = canvasSize.height / 2 - height / 2;
337
- return {
338
- centerX,
339
- centerY,
340
- xCorrection,
341
- yCorrection,
342
- scale
343
- };
344
- };
345
- var calculateOuterStyle = ({
346
- config,
347
- style: style2,
348
- canvasSize,
349
- overflowVisible,
350
- layout
351
- }) => {
352
- if (!config) {
353
- return {};
354
- }
355
- return {
356
- position: "relative",
357
- overflow: overflowVisible ? "visible" : "hidden",
358
- ...calculatePlayerSize({
359
- compositionHeight: config.height,
360
- compositionWidth: config.width,
361
- currentSize: canvasSize,
362
- height: style2?.height,
363
- width: style2?.width
364
- }),
365
- opacity: layout ? 1 : 0,
366
- ...style2
367
- };
368
- };
369
- var calculateContainerStyle = ({
370
- config,
371
- layout,
372
- scale,
373
- overflowVisible
374
- }) => {
375
- if (!config) {
376
- return {};
377
- }
378
- if (!layout) {
379
- return {
380
- position: "absolute",
381
- width: config.width,
382
- height: config.height,
383
- display: "flex",
384
- transform: `scale(${scale})`,
385
- overflow: overflowVisible ? "visible" : "hidden"
386
- };
387
- }
388
- return {
389
- position: "absolute",
390
- width: config.width,
391
- height: config.height,
392
- display: "flex",
393
- transform: `scale(${scale})`,
394
- marginLeft: layout.xCorrection,
395
- marginTop: layout.yCorrection,
396
- overflow: overflowVisible ? "visible" : "hidden"
397
- };
398
- };
399
- var calculateOuter = ({
400
- layout,
401
- scale,
402
- config,
403
- overflowVisible
404
- }) => {
405
- if (!config) {
406
- return {};
407
- }
408
- if (!layout) {
409
- return {
410
- width: config.width * scale,
411
- height: config.height * scale,
412
- display: "flex",
413
- flexDirection: "column",
414
- position: "absolute",
415
- overflow: overflowVisible ? "visible" : "hidden"
416
- };
417
- }
418
- const { centerX, centerY } = layout;
419
- return {
420
- width: config.width * scale,
421
- height: config.height * scale,
422
- display: "flex",
423
- flexDirection: "column",
424
- position: "absolute",
425
- left: centerX,
426
- top: centerY,
427
- overflow: overflowVisible ? "visible" : "hidden"
428
- };
429
- };
430
- var PlayerEventEmitterContext = React.createContext(void 0);
431
- var ThumbnailEmitterContext = React.createContext(void 0);
432
- var PlayerEmitter = class {
433
- listeners = {
434
- ended: [],
435
- error: [],
436
- pause: [],
437
- play: [],
438
- ratechange: [],
439
- scalechange: [],
440
- seeked: [],
441
- timeupdate: [],
442
- frameupdate: [],
443
- fullscreenchange: [],
444
- volumechange: [],
445
- mutechange: [],
446
- waiting: [],
447
- resume: []
448
- };
449
- addEventListener(name, callback) {
450
- this.listeners[name].push(callback);
451
- }
452
- removeEventListener(name, callback) {
453
- this.listeners[name] = this.listeners[name].filter((l) => l !== callback);
454
- }
455
- dispatchEvent(dispatchName, context) {
456
- this.listeners[dispatchName].forEach((callback) => {
457
- callback({ detail: context });
458
- });
459
- }
460
- dispatchSeek = (frame) => {
461
- this.dispatchEvent("seeked", {
462
- frame
463
- });
464
- };
465
- dispatchVolumeChange = (volume) => {
466
- this.dispatchEvent("volumechange", {
467
- volume
468
- });
469
- };
470
- dispatchPause = () => {
471
- this.dispatchEvent("pause", void 0);
472
- };
473
- dispatchPlay = () => {
474
- this.dispatchEvent("play", void 0);
475
- };
476
- dispatchEnded = () => {
477
- this.dispatchEvent("ended", void 0);
478
- };
479
- dispatchRateChange = (playbackRate) => {
480
- this.dispatchEvent("ratechange", {
481
- playbackRate
482
- });
483
- };
484
- dispatchScaleChange = (scale) => {
485
- this.dispatchEvent("scalechange", {
486
- scale
487
- });
488
- };
489
- dispatchError = (error) => {
490
- this.dispatchEvent("error", {
491
- error
492
- });
493
- };
494
- dispatchTimeUpdate = (event) => {
495
- this.dispatchEvent("timeupdate", event);
496
- };
497
- dispatchFrameUpdate = (event) => {
498
- this.dispatchEvent("frameupdate", event);
499
- };
500
- dispatchFullscreenChange = (event) => {
501
- this.dispatchEvent("fullscreenchange", event);
502
- };
503
- dispatchMuteChange = (event) => {
504
- this.dispatchEvent("mutechange", event);
505
- };
506
- dispatchWaiting = (event) => {
507
- this.dispatchEvent("waiting", event);
508
- };
509
- dispatchResume = (event) => {
510
- this.dispatchEvent("resume", event);
511
- };
512
- };
513
- var ThumbnailEmitter = class {
514
- listeners = {
515
- error: [],
516
- waiting: [],
517
- resume: []
518
- };
519
- addEventListener(name, callback) {
520
- this.listeners[name].push(callback);
521
- }
522
- removeEventListener(name, callback) {
523
- this.listeners[name] = this.listeners[name].filter((l) => l !== callback);
524
- }
525
- dispatchEvent(dispatchName, context) {
526
- this.listeners[dispatchName].forEach((callback) => {
527
- callback({ detail: context });
528
- });
529
- }
530
- dispatchError = (error) => {
531
- this.dispatchEvent("error", {
532
- error
533
- });
534
- };
535
- dispatchWaiting = (event) => {
536
- this.dispatchEvent("waiting", event);
537
- };
538
- dispatchResume = (event) => {
539
- this.dispatchEvent("resume", event);
540
- };
541
- };
542
- var useBufferStateEmitter = (emitter) => {
543
- const bufferManager = useContext(Internals2.BufferingContextReact);
544
- if (!bufferManager) {
545
- throw new Error("BufferingContextReact not found");
546
- }
547
- useLayoutEffect(() => {
548
- const clear1 = bufferManager.listenForBuffering(() => {
549
- bufferManager.buffering.current = true;
550
- emitter.dispatchWaiting({});
551
- });
552
- const clear2 = bufferManager.listenForResume(() => {
553
- bufferManager.buffering.current = false;
554
- emitter.dispatchResume({});
555
- });
556
- return () => {
557
- clear1.remove();
558
- clear2.remove();
559
- };
560
- }, [bufferManager, emitter]);
561
- };
562
- var PlayerEmitterProvider = ({ children, currentPlaybackRate }) => {
563
- const [emitter] = useState(() => new PlayerEmitter());
564
- const bufferManager = useContext2(Internals3.BufferingContextReact);
565
- if (!bufferManager) {
566
- throw new Error("BufferingContextReact not found");
567
- }
568
- useEffect(() => {
569
- if (currentPlaybackRate) {
570
- emitter.dispatchRateChange(currentPlaybackRate);
571
- }
572
- }, [emitter, currentPlaybackRate]);
573
- useBufferStateEmitter(emitter);
574
- return /* @__PURE__ */ jsx3(PlayerEventEmitterContext.Provider, {
575
- value: emitter,
576
- children
577
- });
578
- };
579
- var useHoverState = (ref, hideControlsWhenPointerDoesntMove) => {
580
- const [hovered, setHovered] = useState2(false);
581
- useEffect2(() => {
582
- const { current } = ref;
583
- if (!current) {
584
- return;
585
- }
586
- let hoverTimeout;
587
- const addHoverTimeout = () => {
588
- if (hideControlsWhenPointerDoesntMove) {
589
- clearTimeout(hoverTimeout);
590
- hoverTimeout = setTimeout(() => {
591
- setHovered(false);
592
- }, hideControlsWhenPointerDoesntMove === true ? 3e3 : hideControlsWhenPointerDoesntMove);
593
- }
594
- };
595
- const onHover = () => {
596
- setHovered(true);
597
- addHoverTimeout();
598
- };
599
- const onLeave = () => {
600
- setHovered(false);
601
- clearTimeout(hoverTimeout);
602
- };
603
- const onMove = () => {
604
- setHovered(true);
605
- addHoverTimeout();
606
- };
607
- current.addEventListener("mouseenter", onHover);
608
- current.addEventListener("mouseleave", onLeave);
609
- current.addEventListener("mousemove", onMove);
610
- return () => {
611
- current.removeEventListener("mouseenter", onHover);
612
- current.removeEventListener("mouseleave", onLeave);
613
- current.removeEventListener("mousemove", onMove);
614
- clearTimeout(hoverTimeout);
615
- };
616
- }, [hideControlsWhenPointerDoesntMove, ref]);
617
- return hovered;
618
- };
619
- var usePlayer = () => {
620
- const [playing, setPlaying, imperativePlaying] = Internals5.Timeline.usePlayingState();
621
- const [hasPlayed, setHasPlayed] = useState3(false);
622
- const frame = Internals5.Timeline.useTimelinePosition();
623
- const playStart = useRef2(frame);
624
- const setFrame = Internals5.Timeline.useTimelineSetFrame();
625
- const setTimelinePosition = Internals5.Timeline.useTimelineSetFrame();
626
- const audioContext = useContext3(Internals5.SharedAudioContext);
627
- const { audioAndVideoTags } = useContext3(Internals5.TimelineContext);
628
- const frameRef = useRef2(frame);
629
- frameRef.current = frame;
630
- const video = Internals5.useVideo();
631
- const config = Internals5.useUnsafeVideoConfig();
632
- const emitter = useContext3(PlayerEventEmitterContext);
633
- const lastFrame = (config?.durationInFrames ?? 1) - 1;
634
- const isLastFrame = frame === lastFrame;
635
- const isFirstFrame = frame === 0;
636
- if (!emitter) {
637
- throw new TypeError("Expected Player event emitter context");
638
- }
639
- const bufferingContext = useContext3(Internals5.BufferingContextReact);
640
- if (!bufferingContext) {
641
- throw new Error("Missing the buffering context. Most likely you have a Remotion version mismatch.");
642
- }
643
- const { buffering } = bufferingContext;
644
- const seek = useCallback2((newFrame) => {
645
- if (video?.id) {
646
- setTimelinePosition((c) => ({ ...c, [video.id]: newFrame }));
647
- }
648
- frameRef.current = newFrame;
649
- emitter.dispatchSeek(newFrame);
650
- }, [emitter, setTimelinePosition, video?.id]);
651
- const play = useCallback2((e) => {
652
- if (imperativePlaying.current) {
653
- return;
654
- }
655
- setHasPlayed(true);
656
- if (isLastFrame) {
657
- seek(0);
658
- }
659
- audioContext?.audioContext?.resume();
660
- if (audioContext && audioContext.numberOfAudioTags > 0 && e) {
661
- audioContext.playAllAudios();
662
- }
663
- audioAndVideoTags.current.forEach((a) => a.play("player play() was called and playing audio from a click"));
664
- imperativePlaying.current = true;
665
- setPlaying(true);
666
- playStart.current = frameRef.current;
667
- emitter.dispatchPlay();
668
- }, [
669
- imperativePlaying,
670
- isLastFrame,
671
- audioContext,
672
- setPlaying,
673
- emitter,
674
- seek,
675
- audioAndVideoTags
676
- ]);
677
- const pause = useCallback2(() => {
678
- if (imperativePlaying.current) {
679
- imperativePlaying.current = false;
680
- setPlaying(false);
681
- emitter.dispatchPause();
682
- audioContext?.audioContext?.suspend();
683
- }
684
- }, [emitter, imperativePlaying, setPlaying, audioContext]);
685
- const pauseAndReturnToPlayStart = useCallback2(() => {
686
- if (imperativePlaying.current) {
687
- imperativePlaying.current = false;
688
- frameRef.current = playStart.current;
689
- if (config) {
690
- setTimelinePosition((c) => ({
691
- ...c,
692
- [config.id]: playStart.current
693
- }));
694
- setPlaying(false);
695
- emitter.dispatchPause();
696
- }
697
- }
698
- }, [config, emitter, imperativePlaying, setPlaying, setTimelinePosition]);
699
- const videoId = video?.id;
700
- const frameBack = useCallback2((frames) => {
701
- if (!videoId) {
702
- return null;
703
- }
704
- if (imperativePlaying.current) {
705
- return;
706
- }
707
- setFrame((c) => {
708
- const prevFrame = c[videoId] ?? window.remotion_initialFrame ?? 0;
709
- const newFrame = Math.max(0, prevFrame - frames);
710
- if (prevFrame === newFrame) {
711
- return c;
712
- }
713
- return {
714
- ...c,
715
- [videoId]: newFrame
716
- };
717
- });
718
- }, [imperativePlaying, setFrame, videoId]);
719
- const frameForward = useCallback2((frames) => {
720
- if (!videoId) {
721
- return null;
722
- }
723
- if (imperativePlaying.current) {
724
- return;
725
- }
726
- setFrame((c) => {
727
- const prevFrame = c[videoId] ?? window.remotion_initialFrame ?? 0;
728
- const newFrame = Math.min(lastFrame, prevFrame + frames);
729
- if (prevFrame === newFrame) {
730
- return c;
731
- }
732
- return {
733
- ...c,
734
- [videoId]: newFrame
735
- };
736
- });
737
- }, [videoId, imperativePlaying, lastFrame, setFrame]);
738
- const toggle = useCallback2((e) => {
739
- if (imperativePlaying.current) {
740
- pause();
741
- } else {
742
- play(e);
743
- }
744
- }, [imperativePlaying, pause, play]);
745
- const isPlaying = useCallback2(() => {
746
- return imperativePlaying.current;
747
- }, [imperativePlaying]);
748
- const getCurrentFrame = useCallback2(() => {
749
- return frameRef.current;
750
- }, [frameRef]);
751
- const isBuffering = useCallback2(() => {
752
- return buffering.current;
753
- }, [buffering]);
754
- const returnValue = useMemo(() => {
755
- return {
756
- frameBack,
757
- frameForward,
758
- isLastFrame,
759
- emitter,
760
- playing,
761
- play,
762
- pause,
763
- seek,
764
- isFirstFrame,
765
- getCurrentFrame,
766
- isPlaying,
767
- isBuffering,
768
- pauseAndReturnToPlayStart,
769
- hasPlayed,
770
- toggle
771
- };
772
- }, [
773
- emitter,
774
- frameBack,
775
- frameForward,
776
- hasPlayed,
777
- isFirstFrame,
778
- isLastFrame,
779
- getCurrentFrame,
780
- pause,
781
- pauseAndReturnToPlayStart,
782
- play,
783
- playing,
784
- seek,
785
- toggle,
786
- isPlaying,
787
- isBuffering
788
- ]);
789
- return returnValue;
790
- };
791
- var useBrowserMediaSession = ({
792
- browserMediaControlsBehavior,
793
- videoConfig,
794
- playbackRate
795
- }) => {
796
- const { playing, pause, play, emitter, getCurrentFrame, seek } = usePlayer();
797
- const hasEverPlayed = useRef3(false);
798
- useEffect3(() => {
799
- if (playing) {
800
- hasEverPlayed.current = true;
801
- }
802
- }, [playing]);
803
- useEffect3(() => {
804
- if (!navigator.mediaSession) {
805
- return;
806
- }
807
- if (browserMediaControlsBehavior.mode === "do-nothing") {
808
- return;
809
- }
810
- if (playing) {
811
- navigator.mediaSession.playbackState = "playing";
812
- } else if (hasEverPlayed.current) {
813
- navigator.mediaSession.playbackState = "paused";
814
- }
815
- }, [browserMediaControlsBehavior.mode, playing]);
816
- useEffect3(() => {
817
- if (!navigator.mediaSession) {
818
- return;
819
- }
820
- if (browserMediaControlsBehavior.mode === "do-nothing") {
821
- return;
822
- }
823
- const onTimeUpdate = () => {
824
- if (!videoConfig) {
825
- return;
826
- }
827
- if (navigator.mediaSession) {
828
- navigator.mediaSession.setPositionState({
829
- duration: videoConfig.durationInFrames / videoConfig.fps,
830
- playbackRate,
831
- position: getCurrentFrame() / videoConfig.fps
832
- });
833
- }
834
- };
835
- emitter.addEventListener("timeupdate", onTimeUpdate);
836
- return () => {
837
- emitter.removeEventListener("timeupdate", onTimeUpdate);
838
- };
839
- }, [
840
- browserMediaControlsBehavior.mode,
841
- emitter,
842
- getCurrentFrame,
843
- playbackRate,
844
- videoConfig
845
- ]);
846
- useEffect3(() => {
847
- if (!navigator.mediaSession) {
848
- return;
849
- }
850
- if (browserMediaControlsBehavior.mode === "do-nothing") {
851
- return;
852
- }
853
- navigator.mediaSession.setActionHandler("play", () => {
854
- if (browserMediaControlsBehavior.mode === "register-media-session") {
855
- play();
856
- }
857
- });
858
- navigator.mediaSession.setActionHandler("pause", () => {
859
- if (browserMediaControlsBehavior.mode === "register-media-session") {
860
- pause();
861
- }
862
- });
863
- navigator.mediaSession.setActionHandler("seekto", (event) => {
864
- if (browserMediaControlsBehavior.mode === "register-media-session" && event.seekTime !== void 0 && videoConfig) {
865
- seek(Math.round(event.seekTime * videoConfig.fps));
866
- }
867
- });
868
- navigator.mediaSession.setActionHandler("seekbackward", () => {
869
- if (browserMediaControlsBehavior.mode === "register-media-session" && videoConfig) {
870
- seek(Math.max(0, Math.round((getCurrentFrame() - 10) * videoConfig.fps)));
871
- }
872
- });
873
- navigator.mediaSession.setActionHandler("seekforward", () => {
874
- if (browserMediaControlsBehavior.mode === "register-media-session" && videoConfig) {
875
- seek(Math.max(videoConfig.durationInFrames - 1, Math.round((getCurrentFrame() + 10) * videoConfig.fps)));
876
- }
877
- });
878
- navigator.mediaSession.setActionHandler("previoustrack", () => {
879
- if (browserMediaControlsBehavior.mode === "register-media-session") {
880
- seek(0);
881
- }
882
- });
883
- return () => {
884
- navigator.mediaSession.metadata = null;
885
- navigator.mediaSession.setActionHandler("play", null);
886
- navigator.mediaSession.setActionHandler("pause", null);
887
- navigator.mediaSession.setActionHandler("seekto", null);
888
- navigator.mediaSession.setActionHandler("seekbackward", null);
889
- navigator.mediaSession.setActionHandler("seekforward", null);
890
- navigator.mediaSession.setActionHandler("previoustrack", null);
891
- };
892
- }, [
893
- browserMediaControlsBehavior.mode,
894
- getCurrentFrame,
895
- pause,
896
- play,
897
- seek,
898
- videoConfig
899
- ]);
900
- };
901
- var calculateNextFrame = ({
902
- time,
903
- currentFrame: startFrame,
904
- playbackSpeed,
905
- fps,
906
- actualLastFrame,
907
- actualFirstFrame,
908
- framesAdvanced,
909
- shouldLoop
910
- }) => {
911
- const op = playbackSpeed < 0 ? Math.ceil : Math.floor;
912
- const framesToAdvance = op(time * playbackSpeed / (1e3 / fps)) - framesAdvanced;
913
- const nextFrame = framesToAdvance + startFrame;
914
- const isCurrentFrameOutside = startFrame > actualLastFrame || startFrame < actualFirstFrame;
915
- const isNextFrameOutside = nextFrame > actualLastFrame || nextFrame < actualFirstFrame;
916
- const hasEnded = !shouldLoop && isNextFrameOutside && !isCurrentFrameOutside;
917
- if (playbackSpeed > 0) {
918
- if (isNextFrameOutside) {
919
- return {
920
- nextFrame: actualFirstFrame,
921
- framesToAdvance,
922
- hasEnded
923
- };
924
- }
925
- return { nextFrame, framesToAdvance, hasEnded };
926
- }
927
- if (isNextFrameOutside) {
928
- return { nextFrame: actualLastFrame, framesToAdvance, hasEnded };
929
- }
930
- return { nextFrame, framesToAdvance, hasEnded };
931
- };
932
- var getIsBackgrounded = () => {
933
- if (typeof document === "undefined") {
934
- return false;
935
- }
936
- return document.visibilityState === "hidden";
937
- };
938
- var useIsBackgrounded = () => {
939
- const isBackgrounded = useRef4(getIsBackgrounded());
940
- useEffect4(() => {
941
- const onVisibilityChange = () => {
942
- isBackgrounded.current = getIsBackgrounded();
943
- };
944
- document.addEventListener("visibilitychange", onVisibilityChange);
945
- return () => {
946
- document.removeEventListener("visibilitychange", onVisibilityChange);
947
- };
948
- }, []);
949
- return isBackgrounded;
950
- };
951
- var usePlayback = ({
952
- loop,
953
- playbackRate,
954
- moveToBeginningWhenEnded,
955
- inFrame,
956
- outFrame,
957
- browserMediaControlsBehavior,
958
- getCurrentFrame
959
- }) => {
960
- const config = Internals6.useUnsafeVideoConfig();
961
- const frame = Internals6.Timeline.useTimelinePosition();
962
- const { playing, pause, emitter, isPlaying } = usePlayer();
963
- const setFrame = Internals6.Timeline.useTimelineSetFrame();
964
- const isBackgroundedRef = useIsBackgrounded();
965
- const lastTimeUpdateEvent = useRef5(null);
966
- const context = useContext4(Internals6.BufferingContextReact);
967
- if (!context) {
968
- throw new Error("Missing the buffering context. Most likely you have a Remotion version mismatch.");
969
- }
970
- useBrowserMediaSession({
971
- browserMediaControlsBehavior,
972
- playbackRate,
973
- videoConfig: config
974
- });
975
- useEffect5(() => {
976
- if (!config) {
977
- return;
978
- }
979
- if (!playing) {
980
- return;
981
- }
982
- let hasBeenStopped = false;
983
- let reqAnimFrameCall = null;
984
- let startedTime = performance.now();
985
- let framesAdvanced = 0;
986
- const cancelQueuedFrame = () => {
987
- if (reqAnimFrameCall !== null) {
988
- if (reqAnimFrameCall.type === "raf") {
989
- cancelAnimationFrame(reqAnimFrameCall.id);
990
- } else {
991
- clearTimeout(reqAnimFrameCall.id);
992
- }
993
- }
994
- };
995
- const stop = () => {
996
- hasBeenStopped = true;
997
- cancelQueuedFrame();
998
- };
999
- const callback = () => {
1000
- if (hasBeenStopped) {
1001
- return;
1002
- }
1003
- if (!isPlaying()) {
1004
- return;
1005
- }
1006
- const time = performance.now() - startedTime;
1007
- const actualLastFrame = outFrame ?? config.durationInFrames - 1;
1008
- const actualFirstFrame = inFrame ?? 0;
1009
- const currentFrame = getCurrentFrame();
1010
- const { nextFrame, framesToAdvance, hasEnded } = calculateNextFrame({
1011
- time,
1012
- currentFrame,
1013
- playbackSpeed: playbackRate,
1014
- fps: config.fps,
1015
- actualFirstFrame,
1016
- actualLastFrame,
1017
- framesAdvanced,
1018
- shouldLoop: loop
1019
- });
1020
- framesAdvanced += framesToAdvance;
1021
- if (nextFrame !== getCurrentFrame() && (!hasEnded || moveToBeginningWhenEnded)) {
1022
- setFrame((c) => ({ ...c, [config.id]: nextFrame }));
1023
- }
1024
- if (hasEnded) {
1025
- stop();
1026
- pause();
1027
- emitter.dispatchEnded();
1028
- return;
1029
- }
1030
- queueNextFrame();
1031
- };
1032
- const queueNextFrame = () => {
1033
- if (context.buffering.current) {
1034
- const stopListening = context.listenForResume(() => {
1035
- stopListening.remove();
1036
- startedTime = performance.now();
1037
- framesAdvanced = 0;
1038
- queueNextFrame();
1039
- });
1040
- return;
1041
- }
1042
- if (isBackgroundedRef.current) {
1043
- reqAnimFrameCall = {
1044
- type: "timeout",
1045
- id: setTimeout(callback, 1e3 / config.fps)
1046
- };
1047
- return;
1048
- }
1049
- reqAnimFrameCall = { type: "raf", id: requestAnimationFrame(callback) };
1050
- };
1051
- queueNextFrame();
1052
- const onVisibilityChange = () => {
1053
- if (document.visibilityState === "visible") {
1054
- return;
1055
- }
1056
- cancelQueuedFrame();
1057
- callback();
1058
- };
1059
- window.addEventListener("visibilitychange", onVisibilityChange);
1060
- return () => {
1061
- window.removeEventListener("visibilitychange", onVisibilityChange);
1062
- stop();
1063
- };
1064
- }, [
1065
- config,
1066
- loop,
1067
- pause,
1068
- playing,
1069
- setFrame,
1070
- emitter,
1071
- playbackRate,
1072
- inFrame,
1073
- outFrame,
1074
- moveToBeginningWhenEnded,
1075
- isBackgroundedRef,
1076
- getCurrentFrame,
1077
- context,
1078
- isPlaying
1079
- ]);
1080
- useEffect5(() => {
1081
- const interval = setInterval(() => {
1082
- if (lastTimeUpdateEvent.current === getCurrentFrame()) {
1083
- return;
1084
- }
1085
- emitter.dispatchTimeUpdate({ frame: getCurrentFrame() });
1086
- lastTimeUpdateEvent.current = getCurrentFrame();
1087
- }, 250);
1088
- return () => clearInterval(interval);
1089
- }, [emitter, getCurrentFrame]);
1090
- useEffect5(() => {
1091
- emitter.dispatchFrameUpdate({ frame });
1092
- }, [emitter, frame]);
1093
- };
1094
- var elementSizeHooks = [];
1095
- var useElementSize = (ref, options) => {
1096
- const [size, setSize] = useState4(() => {
1097
- if (!ref.current) {
1098
- return null;
1099
- }
1100
- const rect = ref.current.getClientRects();
1101
- if (!rect[0]) {
1102
- return null;
1103
- }
1104
- return {
1105
- width: rect[0].width,
1106
- height: rect[0].height,
1107
- left: rect[0].x,
1108
- top: rect[0].y,
1109
- windowSize: {
1110
- height: window.innerHeight,
1111
- width: window.innerWidth
1112
- }
1113
- };
1114
- });
1115
- const observer = useMemo2(() => {
1116
- if (typeof ResizeObserver === "undefined") {
1117
- return null;
1118
- }
1119
- return new ResizeObserver((entries) => {
1120
- const { contentRect, target } = entries[0];
1121
- const newSize = target.getClientRects();
1122
- if (!newSize?.[0]) {
1123
- setSize(null);
1124
- return;
1125
- }
1126
- const probableCssParentScale = contentRect.width === 0 ? 1 : newSize[0].width / contentRect.width;
1127
- const width = options.shouldApplyCssTransforms || probableCssParentScale === 0 ? newSize[0].width : newSize[0].width * (1 / probableCssParentScale);
1128
- const height = options.shouldApplyCssTransforms || probableCssParentScale === 0 ? newSize[0].height : newSize[0].height * (1 / probableCssParentScale);
1129
- setSize((prevState) => {
1130
- const isSame = prevState && prevState.width === width && prevState.height === height && prevState.left === newSize[0].x && prevState.top === newSize[0].y && prevState.windowSize.height === window.innerHeight && prevState.windowSize.width === window.innerWidth;
1131
- if (isSame) {
1132
- return prevState;
1133
- }
1134
- return {
1135
- width,
1136
- height,
1137
- left: newSize[0].x,
1138
- top: newSize[0].y,
1139
- windowSize: {
1140
- height: window.innerHeight,
1141
- width: window.innerWidth
1142
- }
1143
- };
1144
- });
1145
- });
1146
- }, [options.shouldApplyCssTransforms]);
1147
- const updateSize = useCallback3(() => {
1148
- if (!ref.current) {
1149
- return;
1150
- }
1151
- const rect = ref.current.getClientRects();
1152
- if (!rect[0]) {
1153
- setSize(null);
1154
- return;
1155
- }
1156
- setSize((prevState) => {
1157
- const isSame = prevState && prevState.width === rect[0].width && prevState.height === rect[0].height && prevState.left === rect[0].x && prevState.top === rect[0].y && prevState.windowSize.height === window.innerHeight && prevState.windowSize.width === window.innerWidth;
1158
- if (isSame) {
1159
- return prevState;
1160
- }
1161
- return {
1162
- width: rect[0].width,
1163
- height: rect[0].height,
1164
- left: rect[0].x,
1165
- top: rect[0].y,
1166
- windowSize: {
1167
- height: window.innerHeight,
1168
- width: window.innerWidth
1169
- }
1170
- };
1171
- });
1172
- }, [ref]);
1173
- useEffect6(() => {
1174
- if (!observer) {
1175
- return;
1176
- }
1177
- const { current } = ref;
1178
- if (current) {
1179
- observer.observe(current);
1180
- }
1181
- return () => {
1182
- if (current) {
1183
- observer.unobserve(current);
1184
- }
1185
- };
1186
- }, [observer, ref, updateSize]);
1187
- useEffect6(() => {
1188
- if (!options.triggerOnWindowResize) {
1189
- return;
1190
- }
1191
- window.addEventListener("resize", updateSize);
1192
- return () => {
1193
- window.removeEventListener("resize", updateSize);
1194
- };
1195
- }, [options.triggerOnWindowResize, updateSize]);
1196
- useEffect6(() => {
1197
- elementSizeHooks.push(updateSize);
1198
- return () => {
1199
- elementSizeHooks = elementSizeHooks.filter((e) => e !== updateSize);
1200
- };
1201
- }, [updateSize]);
1202
- return useMemo2(() => {
1203
- if (!size) {
1204
- return null;
1205
- }
1206
- return { ...size, refresh: updateSize };
1207
- }, [size, updateSize]);
1208
- };
1209
- var playerCssClassname = (override) => {
1210
- return override ?? "__remotion-player";
1211
- };
1212
- var errorStyle = {
1213
- display: "flex",
1214
- justifyContent: "center",
1215
- alignItems: "center",
1216
- flex: 1,
1217
- height: "100%",
1218
- width: "100%"
1219
- };
1220
- var ErrorBoundary = class extends React3.Component {
1221
- state = { hasError: null };
1222
- static getDerivedStateFromError(error) {
1223
- return { hasError: error };
1224
- }
1225
- componentDidCatch(error) {
1226
- this.props.onError(error);
1227
- }
1228
- render() {
1229
- if (this.state.hasError) {
1230
- return /* @__PURE__ */ jsx4("div", {
1231
- style: errorStyle,
1232
- children: this.props.errorFallback({
1233
- error: this.state.hasError
1234
- })
1235
- });
1236
- }
1237
- return this.props.children;
1238
- }
1239
- };
1240
- var getHashOfDomain = async () => {
1241
- if (typeof window === "undefined") {
1242
- return null;
1243
- }
1244
- if (typeof window.crypto === "undefined") {
1245
- return null;
1246
- }
1247
- if (typeof window.crypto.subtle === "undefined") {
1248
- return null;
1249
- }
1250
- try {
1251
- const hashBuffer = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(window.location.hostname));
1252
- return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
1253
- } catch {
1254
- return null;
1255
- }
1256
- };
1257
- var style = {
1258
- backgroundColor: "red",
1259
- position: "absolute",
1260
- padding: 12,
1261
- fontFamily: "Arial"
1262
- };
1263
- var DOMAIN_BLACKLIST = [
1264
- "28d262b44cc61fa750f1686b16ad0604dabfe193fbc263eec05c89b7ad4c2cd6",
1265
- "4db1b0a94be33165dfefcb3ba03d04c7a2666dd27c496d3dc9fa41858e94925e",
1266
- "fbc48530bbf245da790f63675e84e06bab38c3b114fab07eb350025119922bdc",
1267
- "7baf10a8932757b1b3a22b3fce10a048747ac2f8eaf638603487e3705b07eb83",
1268
- "8a6c21a598d8c667272b5207c051b85997bf5b45d5fb712378be3f27cd72c6a6",
1269
- "a2f7aaac9c50a9255e7fc376110c4e0bfe153722dc66ed3c5d3bf2a135f65518"
1270
- ];
1271
- var ran = false;
1272
- var RenderWarningIfBlacklist = () => {
1273
- const [unlicensed, setUnlicensed] = React4.useState(false);
1274
- useEffect7(() => {
1275
- if (ran) {
1276
- return;
1277
- }
1278
- ran = true;
1279
- getHashOfDomain().then((hash) => {
1280
- if (hash && DOMAIN_BLACKLIST.includes(hash)) {
1281
- setUnlicensed(true);
1282
- }
1283
- }).catch(() => {
1284
- });
1285
- }, []);
1286
- useEffect7(() => {
1287
- if (!unlicensed) {
1288
- return;
1289
- }
1290
- const ensureBanner = () => {
1291
- const banner = document.querySelector(".warning-banner");
1292
- if (!banner) {
1293
- const div = document.createElement("div");
1294
- div.className = "warning-banner";
1295
- Object.assign(div.style, style, {
1296
- zIndex: "9999",
1297
- cssText: `${style.cssText} !important;`
1298
- });
1299
- div.innerHTML = `
1300
- <a href="https://github.com/remotion-dev/remotion/pull/4589" style="color: white;">
1301
- Remotion Unlicensed \u2013 Contact hi@remotion.dev
1302
- </a>
1303
- `;
1304
- document.body.appendChild(div);
1305
- }
1306
- };
1307
- const observer = new MutationObserver(() => ensureBanner());
1308
- observer.observe(document.body, { childList: true, subtree: true });
1309
- return () => {
1310
- observer.disconnect();
1311
- };
1312
- }, [unlicensed]);
1313
- if (!unlicensed) {
1314
- return null;
1315
- }
1316
- return /* @__PURE__ */ jsx5("div", {
1317
- style,
1318
- className: "warning-banner",
1319
- children: /* @__PURE__ */ jsx5("a", {
1320
- style: { color: "white" },
1321
- href: "https://github.com/remotion-dev/remotion/pull/4589",
1322
- children: "Remotion Unlicensed \u2013 Contact hi@remotion.dev"
1323
- })
1324
- });
1325
- };
1326
- var DefaultPlayPauseButton = ({ playing, buffering }) => {
1327
- if (playing && buffering) {
1328
- return /* @__PURE__ */ jsx6(BufferingIndicator, {
1329
- type: "player"
1330
- });
1331
- }
1332
- if (playing) {
1333
- return /* @__PURE__ */ jsx6(PauseIcon, {});
1334
- }
1335
- return /* @__PURE__ */ jsx6(PlayIcon, {});
1336
- };
1337
- var KNOB_SIZE = 12;
1338
- var BAR_HEIGHT = 5;
1339
- var DefaultVolumeSlider = ({
1340
- volume,
1341
- isVertical,
1342
- onBlur,
1343
- inputRef,
1344
- setVolume
1345
- }) => {
1346
- const sliderContainer = useMemo3(() => {
1347
- const paddingLeft = 5;
1348
- const common = {
1349
- paddingLeft,
1350
- height: ICON_SIZE,
1351
- width: VOLUME_SLIDER_WIDTH,
1352
- display: "inline-flex",
1353
- alignItems: "center"
1354
- };
1355
- if (isVertical) {
1356
- return {
1357
- ...common,
1358
- position: "absolute",
1359
- transform: `rotate(-90deg) translateX(${VOLUME_SLIDER_WIDTH / 2 + ICON_SIZE / 2}px)`
1360
- };
1361
- }
1362
- return {
1363
- ...common
1364
- };
1365
- }, [isVertical]);
1366
- const randomId = typeof React5.useId === "undefined" ? "volume-slider" : React5.useId();
1367
- const [randomClass] = useState5(() => `__remotion-volume-slider-${random(randomId)}`.replace(".", ""));
1368
- const onVolumeChange = useCallback4((e) => {
1369
- setVolume(parseFloat(e.target.value));
1370
- }, [setVolume]);
1371
- const inputStyle = useMemo3(() => {
1372
- const commonStyle = {
1373
- WebkitAppearance: "none",
1374
- backgroundColor: "rgba(255, 255, 255, 0.5)",
1375
- borderRadius: BAR_HEIGHT / 2,
1376
- cursor: "pointer",
1377
- height: BAR_HEIGHT,
1378
- width: VOLUME_SLIDER_WIDTH,
1379
- backgroundImage: `linear-gradient(
1380
- to right,
1381
- white ${volume * 100}%, rgba(255, 255, 255, 0) ${volume * 100}%
1382
- )`
1383
- };
1384
- if (isVertical) {
1385
- return {
1386
- ...commonStyle,
1387
- bottom: ICON_SIZE + VOLUME_SLIDER_WIDTH / 2
1388
- };
1389
- }
1390
- return commonStyle;
1391
- }, [isVertical, volume]);
1392
- const sliderStyle = `
1393
- .${randomClass}::-webkit-slider-thumb {
1394
- -webkit-appearance: none;
1395
- background-color: white;
1396
- border-radius: ${KNOB_SIZE / 2}px;
1397
- box-shadow: 0 0 2px black;
1398
- height: ${KNOB_SIZE}px;
1399
- width: ${KNOB_SIZE}px;
1400
- }
1401
-
1402
- .${randomClass}::-moz-range-thumb {
1403
- -webkit-appearance: none;
1404
- background-color: white;
1405
- border-radius: ${KNOB_SIZE / 2}px;
1406
- box-shadow: 0 0 2px black;
1407
- height: ${KNOB_SIZE}px;
1408
- width: ${KNOB_SIZE}px;
1409
- }
1410
- `;
1411
- return /* @__PURE__ */ jsxs3("div", {
1412
- style: sliderContainer,
1413
- children: [
1414
- /* @__PURE__ */ jsx7("style", {
1415
- dangerouslySetInnerHTML: {
1416
- __html: sliderStyle
1417
- }
1418
- }),
1419
- /* @__PURE__ */ jsx7("input", {
1420
- ref: inputRef,
1421
- "aria-label": "Change volume",
1422
- className: randomClass,
1423
- max: 1,
1424
- min: 0,
1425
- onBlur,
1426
- onChange: onVolumeChange,
1427
- step: 0.01,
1428
- type: "range",
1429
- value: volume,
1430
- style: inputStyle
1431
- })
1432
- ]
1433
- });
1434
- };
1435
- var renderDefaultVolumeSlider = (props) => {
1436
- return /* @__PURE__ */ jsx7(DefaultVolumeSlider, {
1437
- ...props
1438
- });
1439
- };
1440
- var VOLUME_SLIDER_WIDTH = 100;
1441
- var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, renderVolumeSlider }) => {
1442
- const [mediaMuted, setMediaMuted] = Internals7.useMediaMutedState();
1443
- const [mediaVolume, setMediaVolume] = Internals7.useMediaVolumeState();
1444
- const [focused, setFocused] = useState6(false);
1445
- const parentDivRef = useRef6(null);
1446
- const inputRef = useRef6(null);
1447
- const hover = useHoverState(parentDivRef, false);
1448
- const onBlur = useCallback5(() => {
1449
- setTimeout(() => {
1450
- if (inputRef.current && document.activeElement !== inputRef.current) {
1451
- setFocused(false);
1452
- }
1453
- }, 10);
1454
- }, []);
1455
- const isVolume0 = mediaVolume === 0;
1456
- const onClick = useCallback5(() => {
1457
- if (isVolume0) {
1458
- setMediaVolume(1);
1459
- setMediaMuted(false);
1460
- return;
1461
- }
1462
- setMediaMuted((mute) => !mute);
1463
- }, [isVolume0, setMediaMuted, setMediaVolume]);
1464
- const parentDivStyle = useMemo4(() => {
1465
- return {
1466
- display: "inline-flex",
1467
- background: "none",
1468
- border: "none",
1469
- justifyContent: "center",
1470
- alignItems: "center",
1471
- touchAction: "none",
1472
- ...displayVerticalVolumeSlider && { position: "relative" }
1473
- };
1474
- }, [displayVerticalVolumeSlider]);
1475
- const volumeContainer = useMemo4(() => {
1476
- return {
1477
- display: "inline",
1478
- width: ICON_SIZE,
1479
- height: ICON_SIZE,
1480
- cursor: "pointer",
1481
- appearance: "none",
1482
- background: "none",
1483
- border: "none",
1484
- padding: 0
1485
- };
1486
- }, []);
1487
- const renderDefaultMuteButton = useCallback5(({ muted, volume }) => {
1488
- const isMutedOrZero = muted || volume === 0;
1489
- return /* @__PURE__ */ jsx8("button", {
1490
- "aria-label": isMutedOrZero ? "Unmute sound" : "Mute sound",
1491
- title: isMutedOrZero ? "Unmute sound" : "Mute sound",
1492
- onClick,
1493
- onBlur,
1494
- onFocus: () => setFocused(true),
1495
- style: volumeContainer,
1496
- type: "button",
1497
- children: isMutedOrZero ? /* @__PURE__ */ jsx8(VolumeOffIcon, {}) : /* @__PURE__ */ jsx8(VolumeOnIcon, {})
1498
- });
1499
- }, [onBlur, onClick, volumeContainer]);
1500
- const muteButton = useMemo4(() => {
1501
- return renderMuteButton ? renderMuteButton({ muted: mediaMuted, volume: mediaVolume }) : renderDefaultMuteButton({ muted: mediaMuted, volume: mediaVolume });
1502
- }, [mediaMuted, mediaVolume, renderDefaultMuteButton, renderMuteButton]);
1503
- const volumeSlider = useMemo4(() => {
1504
- return (focused || hover) && !mediaMuted && !Internals7.isIosSafari() ? (renderVolumeSlider ?? renderDefaultVolumeSlider)({
1505
- isVertical: displayVerticalVolumeSlider,
1506
- volume: mediaVolume,
1507
- onBlur: () => setFocused(false),
1508
- inputRef,
1509
- setVolume: setMediaVolume
1510
- }) : null;
1511
- }, [
1512
- displayVerticalVolumeSlider,
1513
- focused,
1514
- hover,
1515
- mediaMuted,
1516
- mediaVolume,
1517
- renderVolumeSlider,
1518
- setMediaVolume
1519
- ]);
1520
- return /* @__PURE__ */ jsxs4("div", {
1521
- ref: parentDivRef,
1522
- style: parentDivStyle,
1523
- children: [
1524
- muteButton,
1525
- volumeSlider
1526
- ]
1527
- });
1528
- };
1529
- function useComponentVisible(initialIsVisible) {
1530
- const [isComponentVisible, setIsComponentVisible] = useState7(initialIsVisible);
1531
- const ref = useRef7(null);
1532
- useEffect8(() => {
1533
- const handleClickOutside = (event) => {
1534
- if (ref.current && !ref.current.contains(event.target)) {
1535
- setIsComponentVisible(false);
1536
- }
1537
- };
1538
- document.addEventListener("pointerup", handleClickOutside, true);
1539
- return () => {
1540
- document.removeEventListener("pointerup", handleClickOutside, true);
1541
- };
1542
- }, []);
1543
- return { ref, isComponentVisible, setIsComponentVisible };
1544
- }
1545
- var BOTTOM = 35;
1546
- var THRESHOLD = 70;
1547
- var rateDiv = {
1548
- height: 30,
1549
- paddingRight: 15,
1550
- paddingLeft: 12,
1551
- display: "flex",
1552
- flexDirection: "row",
1553
- alignItems: "center"
1554
- };
1555
- var checkmarkContainer = {
1556
- width: 22,
1557
- display: "flex",
1558
- alignItems: "center"
1559
- };
1560
- var checkmarkStyle = {
1561
- width: 14,
1562
- height: 14,
1563
- color: "black"
1564
- };
1565
- var Checkmark = () => /* @__PURE__ */ jsx9("svg", {
1566
- viewBox: "0 0 512 512",
1567
- style: checkmarkStyle,
1568
- children: /* @__PURE__ */ jsx9("path", {
1569
- fill: "currentColor",
1570
- d: "M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"
1571
- })
1572
- });
1573
- var formatPlaybackRate = (rate) => {
1574
- const str = rate.toString();
1575
- return str.includes(".") ? str : str + ".0";
1576
- };
1577
- var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }) => {
1578
- const onClick = useCallback6((e) => {
1579
- e.stopPropagation();
1580
- e.preventDefault();
1581
- onSelect(rate);
1582
- }, [onSelect, rate]);
1583
- const [hovered, setHovered] = useState8(false);
1584
- const onMouseEnter = useCallback6(() => {
1585
- setHovered(true);
1586
- }, []);
1587
- const onMouseLeave = useCallback6(() => {
1588
- setHovered(false);
1589
- }, []);
1590
- const isFocused = keyboardSelectedRate === rate;
1591
- const actualStyle = useMemo5(() => {
1592
- return {
1593
- ...rateDiv,
1594
- backgroundColor: hovered || isFocused ? "#eee" : "transparent"
1595
- };
1596
- }, [hovered, isFocused]);
1597
- return /* @__PURE__ */ jsxs5("div", {
1598
- onPointerEnter: onMouseEnter,
1599
- onPointerLeave: onMouseLeave,
1600
- tabIndex: 0,
1601
- style: actualStyle,
1602
- onClick,
1603
- children: [
1604
- /* @__PURE__ */ jsx9("div", {
1605
- style: checkmarkContainer,
1606
- children: rate === selectedRate ? /* @__PURE__ */ jsx9(Checkmark, {}) : null
1607
- }),
1608
- formatPlaybackRate(rate),
1609
- "x"
1610
- ]
1611
- }, rate);
1612
- };
1613
- var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
1614
- const { setPlaybackRate, playbackRate } = useContext5(Internals8.TimelineContext);
1615
- const [keyboardSelectedRate, setKeyboardSelectedRate] = useState8(playbackRate);
1616
- useEffect9(() => {
1617
- const listener = (e) => {
1618
- e.preventDefault();
1619
- if (e.key === "ArrowUp") {
1620
- const currentIndex = playbackRates.findIndex((rate) => rate === keyboardSelectedRate);
1621
- if (currentIndex === 0) {
1622
- return;
1623
- }
1624
- if (currentIndex === -1) {
1625
- setKeyboardSelectedRate(playbackRates[0]);
1626
- } else {
1627
- setKeyboardSelectedRate(playbackRates[currentIndex - 1]);
1628
- }
1629
- } else if (e.key === "ArrowDown") {
1630
- const currentIndex = playbackRates.findIndex((rate) => rate === keyboardSelectedRate);
1631
- if (currentIndex === playbackRates.length - 1) {
1632
- return;
1633
- }
1634
- if (currentIndex === -1) {
1635
- setKeyboardSelectedRate(playbackRates[playbackRates.length - 1]);
1636
- } else {
1637
- setKeyboardSelectedRate(playbackRates[currentIndex + 1]);
1638
- }
1639
- } else if (e.key === "Enter") {
1640
- setPlaybackRate(keyboardSelectedRate);
1641
- setIsComponentVisible(false);
1642
- }
1643
- };
1644
- window.addEventListener("keydown", listener);
1645
- return () => {
1646
- window.removeEventListener("keydown", listener);
1647
- };
1648
- }, [
1649
- playbackRates,
1650
- keyboardSelectedRate,
1651
- setPlaybackRate,
1652
- setIsComponentVisible
1653
- ]);
1654
- const onSelect = useCallback6((rate) => {
1655
- setPlaybackRate(rate);
1656
- setIsComponentVisible(false);
1657
- }, [setIsComponentVisible, setPlaybackRate]);
1658
- const playbackPopup = useMemo5(() => {
1659
- return {
1660
- position: "absolute",
1661
- right: 0,
1662
- width: 125,
1663
- maxHeight: canvasSize.height - THRESHOLD - BOTTOM,
1664
- bottom: 35,
1665
- background: "#fff",
1666
- borderRadius: 4,
1667
- overflow: "auto",
1668
- color: "black",
1669
- textAlign: "left"
1670
- };
1671
- }, [canvasSize.height]);
1672
- return /* @__PURE__ */ jsx9("div", {
1673
- style: playbackPopup,
1674
- children: playbackRates.map((rate) => {
1675
- return /* @__PURE__ */ jsx9(PlaybackrateOption, {
1676
- selectedRate: playbackRate,
1677
- onSelect,
1678
- rate,
1679
- keyboardSelectedRate
1680
- }, rate);
1681
- })
1682
- });
1683
- };
1684
- var label = {
1685
- fontSize: 13,
1686
- fontWeight: "bold",
1687
- color: "white",
1688
- border: "2px solid white",
1689
- borderRadius: 20,
1690
- paddingLeft: 8,
1691
- paddingRight: 8,
1692
- paddingTop: 2,
1693
- paddingBottom: 2
1694
- };
1695
- var playerButtonStyle = {
1696
- appearance: "none",
1697
- backgroundColor: "transparent",
1698
- border: "none",
1699
- cursor: "pointer",
1700
- paddingLeft: 0,
1701
- paddingRight: 0,
1702
- paddingTop: 6,
1703
- paddingBottom: 6,
1704
- height: 37,
1705
- display: "inline-flex",
1706
- marginBottom: 0,
1707
- marginTop: 0,
1708
- alignItems: "center"
1709
- };
1710
- var button = {
1711
- ...playerButtonStyle,
1712
- position: "relative"
1713
- };
1714
- var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
1715
- const { ref, isComponentVisible, setIsComponentVisible } = useComponentVisible(false);
1716
- const { playbackRate } = useContext5(Internals8.TimelineContext);
1717
- const onClick = useCallback6((e) => {
1718
- e.stopPropagation();
1719
- e.preventDefault();
1720
- setIsComponentVisible((prevIsComponentVisible) => !prevIsComponentVisible);
1721
- }, [setIsComponentVisible]);
1722
- return /* @__PURE__ */ jsx9("div", {
1723
- ref,
1724
- children: /* @__PURE__ */ jsxs5("button", {
1725
- type: "button",
1726
- "aria-label": "Change playback rate",
1727
- style: button,
1728
- onClick,
1729
- children: [
1730
- /* @__PURE__ */ jsxs5("div", {
1731
- style: label,
1732
- children: [
1733
- playbackRate,
1734
- "x"
1735
- ]
1736
- }),
1737
- isComponentVisible && /* @__PURE__ */ jsx9(PlaybackPopup, {
1738
- canvasSize,
1739
- playbackRates,
1740
- setIsComponentVisible
1741
- })
1742
- ]
1743
- })
1744
- });
1745
- };
1746
- var getFrameFromX = (clientX, durationInFrames, width) => {
1747
- const pos = clientX;
1748
- const frame = Math.round(interpolate(pos, [0, width], [0, durationInFrames - 1], {
1749
- extrapolateLeft: "clamp",
1750
- extrapolateRight: "clamp"
1751
- }));
1752
- return frame;
1753
- };
1754
- var BAR_HEIGHT2 = 5;
1755
- var KNOB_SIZE2 = 12;
1756
- var VERTICAL_PADDING = 4;
1757
- var containerStyle = {
1758
- userSelect: "none",
1759
- WebkitUserSelect: "none",
1760
- paddingTop: VERTICAL_PADDING,
1761
- paddingBottom: VERTICAL_PADDING,
1762
- boxSizing: "border-box",
1763
- cursor: "pointer",
1764
- position: "relative",
1765
- touchAction: "none"
1766
- };
1767
- var barBackground = {
1768
- height: BAR_HEIGHT2,
1769
- backgroundColor: "rgba(255, 255, 255, 0.25)",
1770
- width: "100%",
1771
- borderRadius: BAR_HEIGHT2 / 2
1772
- };
1773
- var findBodyInWhichDivIsLocated = (div) => {
1774
- let current = div;
1775
- while (current.parentElement) {
1776
- current = current.parentElement;
1777
- }
1778
- return current;
1779
- };
1780
- var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFrame }) => {
1781
- const containerRef = useRef8(null);
1782
- const barHovered = useHoverState(containerRef, false);
1783
- const size = useElementSize(containerRef, {
1784
- triggerOnWindowResize: true,
1785
- shouldApplyCssTransforms: true
1786
- });
1787
- const { seek, play, pause, playing } = usePlayer();
1788
- const frame = Internals9.Timeline.useTimelinePosition();
1789
- const [dragging, setDragging] = useState9({
1790
- dragging: false
1791
- });
1792
- const width = size?.width ?? 0;
1793
- const onPointerDown = useCallback7((e) => {
1794
- if (e.button !== 0) {
1795
- return;
1796
- }
1797
- const posLeft = containerRef.current?.getBoundingClientRect().left;
1798
- const _frame = getFrameFromX(e.clientX - posLeft, durationInFrames, width);
1799
- pause();
1800
- seek(_frame);
1801
- setDragging({
1802
- dragging: true,
1803
- wasPlaying: playing
1804
- });
1805
- onSeekStart();
1806
- }, [durationInFrames, width, pause, seek, playing, onSeekStart]);
1807
- const onPointerMove = useCallback7((e) => {
1808
- if (!size) {
1809
- throw new Error("Player has no size");
1810
- }
1811
- if (!dragging.dragging) {
1812
- return;
1813
- }
1814
- const posLeft = containerRef.current?.getBoundingClientRect().left;
1815
- const _frame = getFrameFromX(e.clientX - posLeft, durationInFrames, size.width);
1816
- seek(_frame);
1817
- }, [dragging.dragging, durationInFrames, seek, size]);
1818
- const onPointerUp = useCallback7(() => {
1819
- setDragging({
1820
- dragging: false
1821
- });
1822
- if (!dragging.dragging) {
1823
- return;
1824
- }
1825
- if (dragging.wasPlaying) {
1826
- play();
1827
- } else {
1828
- pause();
1829
- }
1830
- onSeekEnd();
1831
- }, [dragging, onSeekEnd, pause, play]);
1832
- useEffect10(() => {
1833
- if (!dragging.dragging) {
1834
- return;
1835
- }
1836
- const body = findBodyInWhichDivIsLocated(containerRef.current);
1837
- body.addEventListener("pointermove", onPointerMove);
1838
- body.addEventListener("pointerup", onPointerUp);
1839
- return () => {
1840
- body.removeEventListener("pointermove", onPointerMove);
1841
- body.removeEventListener("pointerup", onPointerUp);
1842
- };
1843
- }, [dragging.dragging, onPointerMove, onPointerUp]);
1844
- const knobStyle = useMemo6(() => {
1845
- return {
1846
- height: KNOB_SIZE2,
1847
- width: KNOB_SIZE2,
1848
- borderRadius: KNOB_SIZE2 / 2,
1849
- position: "absolute",
1850
- top: VERTICAL_PADDING - KNOB_SIZE2 / 2 + 5 / 2,
1851
- backgroundColor: "white",
1852
- left: Math.max(0, frame / Math.max(1, durationInFrames - 1) * width - KNOB_SIZE2 / 2),
1853
- boxShadow: "0 0 2px black",
1854
- opacity: Number(barHovered || dragging.dragging)
1855
- };
1856
- }, [barHovered, dragging.dragging, durationInFrames, frame, width]);
1857
- const fillStyle = useMemo6(() => {
1858
- return {
1859
- height: BAR_HEIGHT2,
1860
- backgroundColor: "rgba(255, 255, 255, 1)",
1861
- width: (frame - (inFrame ?? 0)) / (durationInFrames - 1) * width,
1862
- marginLeft: (inFrame ?? 0) / (durationInFrames - 1) * width,
1863
- borderRadius: BAR_HEIGHT2 / 2
1864
- };
1865
- }, [durationInFrames, frame, inFrame, width]);
1866
- const active = useMemo6(() => {
1867
- return {
1868
- height: BAR_HEIGHT2,
1869
- backgroundColor: "rgba(255, 255, 255, 0.25)",
1870
- width: ((outFrame ?? durationInFrames - 1) - (inFrame ?? 0)) / (durationInFrames - 1) * 100 + "%",
1871
- marginLeft: (inFrame ?? 0) / (durationInFrames - 1) * 100 + "%",
1872
- borderRadius: BAR_HEIGHT2 / 2,
1873
- position: "absolute"
1874
- };
1875
- }, [durationInFrames, inFrame, outFrame]);
1876
- return /* @__PURE__ */ jsxs6("div", {
1877
- ref: containerRef,
1878
- onPointerDown,
1879
- style: containerStyle,
1880
- children: [
1881
- /* @__PURE__ */ jsxs6("div", {
1882
- style: barBackground,
1883
- children: [
1884
- /* @__PURE__ */ jsx10("div", {
1885
- style: active
1886
- }),
1887
- /* @__PURE__ */ jsx10("div", {
1888
- style: fillStyle
1889
- })
1890
- ]
1891
- }),
1892
- /* @__PURE__ */ jsx10("div", {
1893
- style: knobStyle
1894
- })
1895
- ]
1896
- });
1897
- };
1898
- var formatTime = (timeInSeconds) => {
1899
- const minutes = Math.floor(timeInSeconds / 60);
1900
- const seconds = Math.floor(timeInSeconds - minutes * 60);
1901
- return `${String(minutes)}:${String(seconds).padStart(2, "0")}`;
1902
- };
1903
- var PlayerTimeLabel = ({ durationInFrames, maxTimeLabelWidth, fps }) => {
1904
- const frame = Internals10.Timeline.useTimelinePosition();
1905
- const timeLabel = useMemo7(() => {
1906
- return {
1907
- color: "white",
1908
- fontFamily: "sans-serif",
1909
- fontSize: 14,
1910
- maxWidth: maxTimeLabelWidth === null ? void 0 : maxTimeLabelWidth,
1911
- overflow: "hidden",
1912
- textOverflow: "ellipsis"
1913
- };
1914
- }, [maxTimeLabelWidth]);
1915
- const isLastFrame = frame === durationInFrames - 1;
1916
- const frameToDisplay = isLastFrame ? frame + 1 : frame;
1917
- return /* @__PURE__ */ jsxs7("div", {
1918
- style: timeLabel,
1919
- children: [
1920
- formatTime(frameToDisplay / fps),
1921
- " / ",
1922
- formatTime(durationInFrames / fps)
1923
- ]
1924
- });
1925
- };
1926
- var X_SPACER = 10;
1927
- var X_PADDING = 12;
1928
- var useVideoControlsResize = ({
1929
- allowFullscreen: allowFullScreen,
1930
- playerWidth
1931
- }) => {
1932
- const resizeInfo = useMemo8(() => {
1933
- const playPauseIconSize = ICON_SIZE;
1934
- const volumeIconSize = ICON_SIZE;
1935
- const _fullscreenIconSize = allowFullScreen ? fullscreenIconSize : 0;
1936
- const elementsSize = volumeIconSize + playPauseIconSize + _fullscreenIconSize + X_PADDING * 2 + X_SPACER * 2;
1937
- const maxTimeLabelWidth = playerWidth - elementsSize;
1938
- const maxTimeLabelWidthWithoutNegativeValue = Math.max(maxTimeLabelWidth, 0);
1939
- const availableTimeLabelWidthIfVolumeOpen = maxTimeLabelWidthWithoutNegativeValue - VOLUME_SLIDER_WIDTH;
1940
- const computedLabelWidth = availableTimeLabelWidthIfVolumeOpen < VOLUME_SLIDER_WIDTH ? maxTimeLabelWidthWithoutNegativeValue : availableTimeLabelWidthIfVolumeOpen;
1941
- const minWidthForHorizontalDisplay = computedLabelWidth + elementsSize + VOLUME_SLIDER_WIDTH;
1942
- const displayVerticalVolumeSlider = playerWidth < minWidthForHorizontalDisplay;
1943
- return {
1944
- maxTimeLabelWidth: maxTimeLabelWidthWithoutNegativeValue === 0 ? null : maxTimeLabelWidthWithoutNegativeValue,
1945
- displayVerticalVolumeSlider
1946
- };
1947
- }, [allowFullScreen, playerWidth]);
1948
- return resizeInfo;
1949
- };
1950
- var gradientSteps = [
1951
- 0,
1952
- 0.013,
1953
- 0.049,
1954
- 0.104,
1955
- 0.175,
1956
- 0.259,
1957
- 0.352,
1958
- 0.45,
1959
- 0.55,
1960
- 0.648,
1961
- 0.741,
1962
- 0.825,
1963
- 0.896,
1964
- 0.951,
1965
- 0.987
1966
- ];
1967
- var gradientOpacities = [
1968
- 0,
1969
- 8.1,
1970
- 15.5,
1971
- 22.5,
1972
- 29,
1973
- 35.3,
1974
- 41.2,
1975
- 47.1,
1976
- 52.9,
1977
- 58.8,
1978
- 64.7,
1979
- 71,
1980
- 77.5,
1981
- 84.5,
1982
- 91.9
1983
- ];
1984
- var globalGradientOpacity = 1 / 0.7;
1985
- var containerStyle2 = {
1986
- boxSizing: "border-box",
1987
- position: "absolute",
1988
- bottom: 0,
1989
- width: "100%",
1990
- paddingTop: 40,
1991
- paddingBottom: 10,
1992
- backgroundImage: `linear-gradient(to bottom,${gradientSteps.map((g, i) => {
1993
- return `hsla(0, 0%, 0%, ${g}) ${gradientOpacities[i] * globalGradientOpacity}%`;
1994
- }).join(", ")}, hsl(0, 0%, 0%) 100%)`,
1995
- backgroundSize: "auto 145px",
1996
- display: "flex",
1997
- paddingRight: X_PADDING,
1998
- paddingLeft: X_PADDING,
1999
- flexDirection: "column",
2000
- transition: "opacity 0.3s"
2001
- };
2002
- var controlsRow = {
2003
- display: "flex",
2004
- flexDirection: "row",
2005
- width: "100%",
2006
- alignItems: "center",
2007
- justifyContent: "center",
2008
- userSelect: "none",
2009
- WebkitUserSelect: "none"
2010
- };
2011
- var leftPartStyle = {
2012
- display: "flex",
2013
- flexDirection: "row",
2014
- userSelect: "none",
2015
- WebkitUserSelect: "none",
2016
- alignItems: "center"
2017
- };
2018
- var xSpacer = {
2019
- width: 12
2020
- };
2021
- var ySpacer = {
2022
- height: 8
2023
- };
2024
- var flex1 = {
2025
- flex: 1
2026
- };
2027
- var fullscreen = {};
2028
- var Controls = ({
2029
- durationInFrames,
2030
- isFullscreen,
2031
- fps,
2032
- showVolumeControls,
2033
- onFullscreenButtonClick,
2034
- allowFullscreen,
2035
- onExitFullscreenButtonClick,
2036
- spaceKeyToPlayOrPause,
2037
- onSeekEnd,
2038
- onSeekStart,
2039
- inFrame,
2040
- outFrame,
2041
- initiallyShowControls,
2042
- canvasSize,
2043
- renderPlayPauseButton,
2044
- renderFullscreenButton,
2045
- alwaysShowControls,
2046
- showPlaybackRateControl,
2047
- containerRef,
2048
- buffering,
2049
- hideControlsWhenPointerDoesntMove,
2050
- onPointerDown,
2051
- onDoubleClick,
2052
- renderMuteButton,
2053
- renderVolumeSlider,
2054
- playing,
2055
- toggle,
2056
- renderCustomControls
2057
- }) => {
2058
- const playButtonRef = useRef9(null);
2059
- const [supportsFullscreen, setSupportsFullscreen] = useState10(false);
2060
- const hovered = useHoverState(containerRef, hideControlsWhenPointerDoesntMove);
2061
- const { maxTimeLabelWidth, displayVerticalVolumeSlider } = useVideoControlsResize({
2062
- allowFullscreen,
2063
- playerWidth: canvasSize?.width ?? 0
2064
- });
2065
- const [shouldShowInitially, setInitiallyShowControls] = useState10(() => {
2066
- if (typeof initiallyShowControls === "boolean") {
2067
- return initiallyShowControls;
2068
- }
2069
- if (typeof initiallyShowControls === "number") {
2070
- if (initiallyShowControls % 1 !== 0) {
2071
- throw new Error("initiallyShowControls must be an integer or a boolean");
2072
- }
2073
- if (Number.isNaN(initiallyShowControls)) {
2074
- throw new Error("initiallyShowControls must not be NaN");
2075
- }
2076
- if (!Number.isFinite(initiallyShowControls)) {
2077
- throw new Error("initiallyShowControls must be finite");
2078
- }
2079
- if (initiallyShowControls <= 0) {
2080
- throw new Error("initiallyShowControls must be a positive integer");
2081
- }
2082
- return initiallyShowControls;
2083
- }
2084
- throw new TypeError("initiallyShowControls must be a number or a boolean");
2085
- });
2086
- const containerCss = useMemo9(() => {
2087
- const shouldShow = hovered || !playing || shouldShowInitially || alwaysShowControls;
2088
- return {
2089
- ...containerStyle2,
2090
- opacity: Number(shouldShow)
2091
- };
2092
- }, [hovered, shouldShowInitially, playing, alwaysShowControls]);
2093
- useEffect11(() => {
2094
- if (playButtonRef.current && spaceKeyToPlayOrPause) {
2095
- playButtonRef.current.focus({
2096
- preventScroll: true
2097
- });
2098
- }
2099
- }, [playing, spaceKeyToPlayOrPause]);
2100
- useEffect11(() => {
2101
- setSupportsFullscreen((typeof document !== "undefined" && (document.fullscreenEnabled || document.webkitFullscreenEnabled)) ?? false);
2102
- }, []);
2103
- useEffect11(() => {
2104
- if (shouldShowInitially === false) {
2105
- return;
2106
- }
2107
- const time = shouldShowInitially === true ? 2e3 : shouldShowInitially;
2108
- const timeout = setTimeout(() => {
2109
- setInitiallyShowControls(false);
2110
- }, time);
2111
- return () => {
2112
- clearInterval(timeout);
2113
- };
2114
- }, [shouldShowInitially]);
2115
- const playbackRates = useMemo9(() => {
2116
- if (showPlaybackRateControl === true) {
2117
- return [0.5, 0.8, 1, 1.2, 1.5, 1.8, 2, 2.5, 3];
2118
- }
2119
- if (Array.isArray(showPlaybackRateControl)) {
2120
- for (const rate of showPlaybackRateControl) {
2121
- if (typeof rate !== "number") {
2122
- throw new Error("Every item in showPlaybackRateControl must be a number");
2123
- }
2124
- if (rate <= 0) {
2125
- throw new Error("Every item in showPlaybackRateControl must be positive");
2126
- }
2127
- }
2128
- return showPlaybackRateControl;
2129
- }
2130
- return null;
2131
- }, [showPlaybackRateControl]);
2132
- const customControlsElement = renderCustomControls ? renderCustomControls() : null;
2133
- const ref = useRef9(null);
2134
- const flexRef = useRef9(null);
2135
- const onPointerDownIfContainer = useCallback8((e) => {
2136
- if (e.target === ref.current || e.target === flexRef.current) {
2137
- onPointerDown?.(e);
2138
- }
2139
- }, [onPointerDown]);
2140
- const onDoubleClickIfContainer = useCallback8((e) => {
2141
- if (e.target === ref.current || e.target === flexRef.current) {
2142
- onDoubleClick?.(e);
2143
- }
2144
- }, [onDoubleClick]);
2145
- return /* @__PURE__ */ jsxs8("div", {
2146
- ref,
2147
- style: containerCss,
2148
- onPointerDown: onPointerDownIfContainer,
2149
- onDoubleClick: onDoubleClickIfContainer,
2150
- children: [
2151
- /* @__PURE__ */ jsxs8("div", {
2152
- ref: flexRef,
2153
- style: controlsRow,
2154
- children: [
2155
- /* @__PURE__ */ jsxs8("div", {
2156
- style: leftPartStyle,
2157
- children: [
2158
- /* @__PURE__ */ jsx11("button", {
2159
- ref: playButtonRef,
2160
- type: "button",
2161
- style: playerButtonStyle,
2162
- onClick: toggle,
2163
- "aria-label": playing ? "Pause video" : "Play video",
2164
- title: playing ? "Pause video" : "Play video",
2165
- children: renderPlayPauseButton === null ? /* @__PURE__ */ jsx11(DefaultPlayPauseButton, {
2166
- buffering,
2167
- playing
2168
- }) : renderPlayPauseButton({
2169
- playing,
2170
- isBuffering: buffering
2171
- }) ?? /* @__PURE__ */ jsx11(DefaultPlayPauseButton, {
2172
- buffering,
2173
- playing
2174
- })
2175
- }),
2176
- showVolumeControls ? /* @__PURE__ */ jsxs8(Fragment2, {
2177
- children: [
2178
- /* @__PURE__ */ jsx11("div", {
2179
- style: xSpacer
2180
- }),
2181
- /* @__PURE__ */ jsx11(MediaVolumeSlider, {
2182
- renderMuteButton,
2183
- renderVolumeSlider,
2184
- displayVerticalVolumeSlider
2185
- })
2186
- ]
2187
- }) : null,
2188
- /* @__PURE__ */ jsx11("div", {
2189
- style: xSpacer
2190
- }),
2191
- /* @__PURE__ */ jsx11(PlayerTimeLabel, {
2192
- durationInFrames,
2193
- fps,
2194
- maxTimeLabelWidth
2195
- }),
2196
- /* @__PURE__ */ jsx11("div", {
2197
- style: xSpacer
2198
- })
2199
- ]
2200
- }),
2201
- /* @__PURE__ */ jsx11("div", {
2202
- style: flex1
2203
- }),
2204
- customControlsElement,
2205
- customControlsElement && playbackRates && canvasSize ? /* @__PURE__ */ jsx11("div", {
2206
- style: xSpacer
2207
- }) : null,
2208
- playbackRates && canvasSize && /* @__PURE__ */ jsx11(PlaybackrateControl, {
2209
- canvasSize,
2210
- playbackRates
2211
- }),
2212
- playbackRates && supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx11("div", {
2213
- style: xSpacer
2214
- }) : null,
2215
- /* @__PURE__ */ jsx11("div", {
2216
- style: fullscreen,
2217
- children: supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx11("button", {
2218
- type: "button",
2219
- "aria-label": isFullscreen ? "Exit fullscreen" : "Enter Fullscreen",
2220
- title: isFullscreen ? "Exit fullscreen" : "Enter Fullscreen",
2221
- style: playerButtonStyle,
2222
- onClick: isFullscreen ? onExitFullscreenButtonClick : onFullscreenButtonClick,
2223
- children: renderFullscreenButton === null ? /* @__PURE__ */ jsx11(FullscreenIcon, {
2224
- isFullscreen
2225
- }) : renderFullscreenButton({ isFullscreen })
2226
- }) : null
2227
- })
2228
- ]
2229
- }),
2230
- /* @__PURE__ */ jsx11("div", {
2231
- style: ySpacer
2232
- }),
2233
- /* @__PURE__ */ jsx11(PlayerSeekBar, {
2234
- onSeekEnd,
2235
- onSeekStart,
2236
- durationInFrames,
2237
- inFrame,
2238
- outFrame
2239
- })
2240
- ]
2241
- });
2242
- };
2243
- var IS_NODE = typeof document === "undefined";
2244
- var cancellablePromise = (promise) => {
2245
- let isCanceled = false;
2246
- const wrappedPromise = new Promise((resolve, reject) => {
2247
- promise.then((value) => {
2248
- if (isCanceled) {
2249
- reject({ isCanceled, value });
2250
- return;
2251
- }
2252
- resolve(value);
2253
- }).catch((error) => {
2254
- reject({ isCanceled, error });
2255
- });
2256
- });
2257
- return {
2258
- promise: wrappedPromise,
2259
- cancel: () => {
2260
- isCanceled = true;
2261
- }
2262
- };
2263
- };
2264
- var delay = (n) => new Promise((resolve) => setTimeout(resolve, n));
2265
- var useCancellablePromises = () => {
2266
- const pendingPromises = useRef10([]);
2267
- const appendPendingPromise = useCallback9((promise) => {
2268
- pendingPromises.current = [...pendingPromises.current, promise];
2269
- }, []);
2270
- const removePendingPromise = useCallback9((promise) => {
2271
- pendingPromises.current = pendingPromises.current.filter((p) => p !== promise);
2272
- }, []);
2273
- const clearPendingPromises = useCallback9(() => pendingPromises.current.map((p) => p.cancel()), []);
2274
- const api = useMemo10(() => ({
2275
- appendPendingPromise,
2276
- removePendingPromise,
2277
- clearPendingPromises
2278
- }), [appendPendingPromise, clearPendingPromises, removePendingPromise]);
2279
- return api;
2280
- };
2281
- var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFullscreen) => {
2282
- const api = useCancellablePromises();
2283
- const handleClick = useCallback10(async (e) => {
2284
- if (e instanceof PointerEvent ? e.pointerType === "touch" : e.nativeEvent.pointerType === "touch") {
2285
- onClick(e);
2286
- return;
2287
- }
2288
- api.clearPendingPromises();
2289
- const waitForClick = cancellablePromise(delay(200));
2290
- api.appendPendingPromise(waitForClick);
2291
- try {
2292
- await waitForClick.promise;
2293
- api.removePendingPromise(waitForClick);
2294
- onClick(e);
2295
- } catch (errorInfo) {
2296
- const info = errorInfo;
2297
- api.removePendingPromise(waitForClick);
2298
- if (!info.isCanceled) {
2299
- throw info.error;
2300
- }
2301
- }
2302
- }, [api, onClick]);
2303
- const handlePointerDown = useCallback10(() => {
2304
- document.addEventListener("pointerup", (newEvt) => {
2305
- handleClick(newEvt);
2306
- }, {
2307
- once: true
2308
- });
2309
- }, [handleClick]);
2310
- const handleDoubleClick = useCallback10(() => {
2311
- api.clearPendingPromises();
2312
- onDoubleClick();
2313
- }, [api, onDoubleClick]);
2314
- const returnValue = useMemo11(() => {
2315
- if (!doubleClickToFullscreen) {
2316
- return { handlePointerDown: onClick, handleDoubleClick: () => {
2317
- return;
2318
- } };
2319
- }
2320
- return { handlePointerDown, handleDoubleClick };
2321
- }, [doubleClickToFullscreen, handleDoubleClick, handlePointerDown, onClick]);
2322
- return returnValue;
2323
- };
2324
- var reactVersion = React10.version.split(".")[0];
2325
- if (reactVersion === "0") {
2326
- throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
2327
- }
2328
- var doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
2329
- var PlayerUI = ({
2330
- controls,
2331
- style: style2,
2332
- loop,
2333
- autoPlay,
2334
- allowFullscreen,
2335
- inputProps,
2336
- clickToPlay,
2337
- showVolumeControls,
2338
- doubleClickToFullscreen,
2339
- spaceKeyToPlayOrPause,
2340
- errorFallback,
2341
- playbackRate,
2342
- renderLoading,
2343
- renderPoster,
2344
- className: className2,
2345
- moveToBeginningWhenEnded,
2346
- showPosterWhenUnplayed,
2347
- showPosterWhenEnded,
2348
- showPosterWhenPaused,
2349
- showPosterWhenBuffering,
2350
- showPosterWhenBufferingAndPaused,
2351
- inFrame,
2352
- outFrame,
2353
- initiallyShowControls,
2354
- renderFullscreen: renderFullscreenButton,
2355
- renderPlayPauseButton,
2356
- renderMuteButton,
2357
- renderVolumeSlider,
2358
- renderCustomControls,
2359
- alwaysShowControls,
2360
- showPlaybackRateControl,
2361
- posterFillMode,
2362
- bufferStateDelayInMilliseconds,
2363
- hideControlsWhenPointerDoesntMove,
2364
- overflowVisible,
2365
- browserMediaControlsBehavior,
2366
- overrideInternalClassName,
2367
- noSuspense
2368
- }, ref) => {
2369
- const config = Internals11.useUnsafeVideoConfig();
2370
- const video = Internals11.useVideo();
2371
- const container = useRef11(null);
2372
- const canvasSize = useElementSize(container, {
2373
- triggerOnWindowResize: false,
2374
- shouldApplyCssTransforms: false
2375
- });
2376
- const [hasPausedToResume, setHasPausedToResume] = useState11(false);
2377
- const [shouldAutoplay, setShouldAutoPlay] = useState11(autoPlay);
2378
- const [isFullscreen, setIsFullscreen] = useState11(() => false);
2379
- const [seeking, setSeeking] = useState11(false);
2380
- const supportsFullScreen = useMemo12(() => {
2381
- if (typeof document === "undefined") {
2382
- return false;
2383
- }
2384
- return Boolean(document.fullscreenEnabled || document.webkitFullscreenEnabled);
2385
- }, []);
2386
- const player = usePlayer();
2387
- const playerToggle = player.toggle;
2388
- usePlayback({
2389
- loop,
2390
- playbackRate,
2391
- moveToBeginningWhenEnded,
2392
- inFrame,
2393
- outFrame,
2394
- getCurrentFrame: player.getCurrentFrame,
2395
- browserMediaControlsBehavior
2396
- });
2397
- useEffect12(() => {
2398
- if (hasPausedToResume && !player.playing) {
2399
- setHasPausedToResume(false);
2400
- player.play();
2401
- }
2402
- }, [hasPausedToResume, player]);
2403
- useEffect12(() => {
2404
- const { current } = container;
2405
- if (!current) {
2406
- return;
2407
- }
2408
- const onFullscreenChange = () => {
2409
- const newValue = document.fullscreenElement === current || document.webkitFullscreenElement === current;
2410
- setIsFullscreen(newValue);
2411
- };
2412
- document.addEventListener("fullscreenchange", onFullscreenChange);
2413
- document.addEventListener("webkitfullscreenchange", onFullscreenChange);
2414
- return () => {
2415
- document.removeEventListener("fullscreenchange", onFullscreenChange);
2416
- document.removeEventListener("webkitfullscreenchange", onFullscreenChange);
2417
- };
2418
- }, []);
2419
- const toggle = useCallback11((e) => {
2420
- playerToggle(e);
2421
- }, [playerToggle]);
2422
- const requestFullscreen = useCallback11(() => {
2423
- if (!allowFullscreen) {
2424
- throw new Error("allowFullscreen is false");
2425
- }
2426
- if (!supportsFullScreen) {
2427
- throw new Error("Browser doesnt support fullscreen");
2428
- }
2429
- if (!container.current) {
2430
- throw new Error("No player ref found");
2431
- }
2432
- if (container.current.webkitRequestFullScreen) {
2433
- container.current.webkitRequestFullScreen();
2434
- } else {
2435
- container.current.requestFullscreen();
2436
- }
2437
- }, [allowFullscreen, supportsFullScreen]);
2438
- const exitFullscreen = useCallback11(() => {
2439
- if (document.webkitExitFullscreen) {
2440
- document.webkitExitFullscreen();
2441
- } else {
2442
- document.exitFullscreen();
2443
- }
2444
- }, []);
2445
- useEffect12(() => {
2446
- const { current } = container;
2447
- if (!current) {
2448
- return;
2449
- }
2450
- const fullscreenChange = () => {
2451
- const element = document.webkitFullscreenElement ?? document.fullscreenElement;
2452
- if (element && element === container.current) {
2453
- player.emitter.dispatchFullscreenChange({
2454
- isFullscreen: true
2455
- });
2456
- } else {
2457
- player.emitter.dispatchFullscreenChange({
2458
- isFullscreen: false
2459
- });
2460
- }
2461
- };
2462
- current.addEventListener("webkitfullscreenchange", fullscreenChange);
2463
- current.addEventListener("fullscreenchange", fullscreenChange);
2464
- return () => {
2465
- current.removeEventListener("webkitfullscreenchange", fullscreenChange);
2466
- current.removeEventListener("fullscreenchange", fullscreenChange);
2467
- };
2468
- }, [player.emitter]);
2469
- const durationInFrames = config?.durationInFrames ?? 1;
2470
- const layout = useMemo12(() => {
2471
- if (!config || !canvasSize) {
2472
- return null;
2473
- }
2474
- return calculateCanvasTransformation({
2475
- canvasSize,
2476
- compositionHeight: config.height,
2477
- compositionWidth: config.width,
2478
- previewSize: "auto"
2479
- });
2480
- }, [canvasSize, config]);
2481
- const scale = layout?.scale ?? 1;
2482
- const initialScaleIgnored = useRef11(false);
2483
- useEffect12(() => {
2484
- if (!initialScaleIgnored.current) {
2485
- initialScaleIgnored.current = true;
2486
- return;
2487
- }
2488
- player.emitter.dispatchScaleChange(scale);
2489
- }, [player.emitter, scale]);
2490
- const { setMediaVolume, setMediaMuted } = useContext6(Internals11.SetMediaVolumeContext);
2491
- const { mediaMuted, mediaVolume } = useContext6(Internals11.MediaVolumeContext);
2492
- useEffect12(() => {
2493
- player.emitter.dispatchVolumeChange(mediaVolume);
2494
- }, [player.emitter, mediaVolume]);
2495
- const isMuted = mediaMuted || mediaVolume === 0;
2496
- useEffect12(() => {
2497
- player.emitter.dispatchMuteChange({
2498
- isMuted
2499
- });
2500
- }, [player.emitter, isMuted]);
2501
- const [showBufferIndicator, setShowBufferState] = useState11(false);
2502
- useEffect12(() => {
2503
- let timeout = null;
2504
- let stopped = false;
2505
- const onBuffer = () => {
2506
- stopped = false;
2507
- requestAnimationFrame(() => {
2508
- if (bufferStateDelayInMilliseconds === 0) {
2509
- setShowBufferState(true);
2510
- } else {
2511
- timeout = setTimeout(() => {
2512
- if (!stopped) {
2513
- setShowBufferState(true);
2514
- }
2515
- }, bufferStateDelayInMilliseconds);
2516
- }
2517
- });
2518
- };
2519
- const onResume = () => {
2520
- requestAnimationFrame(() => {
2521
- stopped = true;
2522
- setShowBufferState(false);
2523
- if (timeout) {
2524
- clearTimeout(timeout);
2525
- }
2526
- });
2527
- };
2528
- player.emitter.addEventListener("waiting", onBuffer);
2529
- player.emitter.addEventListener("resume", onResume);
2530
- return () => {
2531
- player.emitter.removeEventListener("waiting", onBuffer);
2532
- player.emitter.removeEventListener("resume", onResume);
2533
- setShowBufferState(false);
2534
- if (timeout) {
2535
- clearTimeout(timeout);
2536
- }
2537
- stopped = true;
2538
- };
2539
- }, [bufferStateDelayInMilliseconds, player.emitter]);
2540
- useImperativeHandle(ref, () => {
2541
- const methods = {
2542
- play: player.play,
2543
- pause: () => {
2544
- setHasPausedToResume(false);
2545
- player.pause();
2546
- },
2547
- toggle,
2548
- getContainerNode: () => container.current,
2549
- getCurrentFrame: player.getCurrentFrame,
2550
- isPlaying: player.isPlaying,
2551
- seekTo: (f) => {
2552
- const lastFrame = durationInFrames - 1;
2553
- const frameToSeekTo = Math.max(0, Math.min(lastFrame, f));
2554
- if (player.isPlaying()) {
2555
- const pauseToResume = frameToSeekTo !== lastFrame || loop;
2556
- setHasPausedToResume(pauseToResume);
2557
- player.pause();
2558
- }
2559
- if (frameToSeekTo === lastFrame && !loop) {
2560
- player.emitter.dispatchEnded();
2561
- }
2562
- player.seek(frameToSeekTo);
2563
- },
2564
- isFullscreen: () => {
2565
- const { current } = container;
2566
- if (!current) {
2567
- return false;
2568
- }
2569
- return document.fullscreenElement === current || document.webkitFullscreenElement === current;
2570
- },
2571
- requestFullscreen,
2572
- exitFullscreen,
2573
- getVolume: () => {
2574
- if (mediaMuted) {
2575
- return 0;
2576
- }
2577
- return mediaVolume;
2578
- },
2579
- setVolume: (vol) => {
2580
- if (typeof vol !== "number") {
2581
- throw new TypeError(`setVolume() takes a number, got value of type ${typeof vol}`);
2582
- }
2583
- if (isNaN(vol)) {
2584
- throw new TypeError(`setVolume() got a number that is NaN. Volume must be between 0 and 1.`);
2585
- }
2586
- if (vol < 0 || vol > 1) {
2587
- throw new TypeError(`setVolume() got a number that is out of range. Must be between 0 and 1, got ${typeof vol}`);
2588
- }
2589
- setMediaVolume(vol);
2590
- },
2591
- isMuted: () => isMuted,
2592
- mute: () => {
2593
- setMediaMuted(true);
2594
- },
2595
- unmute: () => {
2596
- setMediaMuted(false);
2597
- },
2598
- getScale: () => scale,
2599
- pauseAndReturnToPlayStart: () => {
2600
- player.pauseAndReturnToPlayStart();
2601
- }
2602
- };
2603
- return Object.assign(player.emitter, methods);
2604
- }, [
2605
- durationInFrames,
2606
- exitFullscreen,
2607
- loop,
2608
- mediaMuted,
2609
- isMuted,
2610
- mediaVolume,
2611
- player,
2612
- requestFullscreen,
2613
- setMediaMuted,
2614
- setMediaVolume,
2615
- toggle,
2616
- scale
2617
- ]);
2618
- const VideoComponent = video ? video.component : null;
2619
- const outerStyle = useMemo12(() => {
2620
- return calculateOuterStyle({
2621
- canvasSize,
2622
- config,
2623
- style: style2,
2624
- overflowVisible,
2625
- layout
2626
- });
2627
- }, [canvasSize, config, layout, overflowVisible, style2]);
2628
- const outer = useMemo12(() => {
2629
- return calculateOuter({ config, layout, scale, overflowVisible });
2630
- }, [config, layout, overflowVisible, scale]);
2631
- const containerStyle3 = useMemo12(() => {
2632
- return calculateContainerStyle({
2633
- config,
2634
- layout,
2635
- scale,
2636
- overflowVisible
2637
- });
2638
- }, [config, layout, overflowVisible, scale]);
2639
- const playerPause = player.pause;
2640
- const playerDispatchError = player.emitter.dispatchError;
2641
- const onError = useCallback11((error) => {
2642
- playerPause();
2643
- playerDispatchError(error);
2644
- }, [playerDispatchError, playerPause]);
2645
- const onFullscreenButtonClick = useCallback11((e) => {
2646
- e.stopPropagation();
2647
- requestFullscreen();
2648
- }, [requestFullscreen]);
2649
- const onExitFullscreenButtonClick = useCallback11((e) => {
2650
- e.stopPropagation();
2651
- exitFullscreen();
2652
- }, [exitFullscreen]);
2653
- const onSingleClick = useCallback11((e) => {
2654
- const rightClick = e instanceof MouseEvent ? e.button === 2 : e.nativeEvent.button;
2655
- if (rightClick) {
2656
- return;
2657
- }
2658
- toggle(e);
2659
- }, [toggle]);
2660
- const onSeekStart = useCallback11(() => {
2661
- setSeeking(true);
2662
- }, []);
2663
- const onSeekEnd = useCallback11(() => {
2664
- setSeeking(false);
2665
- }, []);
2666
- const onDoubleClick = useCallback11(() => {
2667
- if (isFullscreen) {
2668
- exitFullscreen();
2669
- } else {
2670
- requestFullscreen();
2671
- }
2672
- }, [exitFullscreen, isFullscreen, requestFullscreen]);
2673
- const { handlePointerDown, handleDoubleClick } = useClickPreventionOnDoubleClick(onSingleClick, onDoubleClick, doubleClickToFullscreen && allowFullscreen && supportsFullScreen);
2674
- useEffect12(() => {
2675
- if (shouldAutoplay) {
2676
- player.play();
2677
- setShouldAutoPlay(false);
2678
- }
2679
- }, [shouldAutoplay, player]);
2680
- const loadingMarkup = useMemo12(() => {
2681
- return renderLoading ? renderLoading({
2682
- height: outerStyle.height,
2683
- width: outerStyle.width,
2684
- isBuffering: showBufferIndicator
2685
- }) : null;
2686
- }, [outerStyle.height, outerStyle.width, renderLoading, showBufferIndicator]);
2687
- const currentScale = useMemo12(() => {
2688
- return {
2689
- type: "scale",
2690
- scale
2691
- };
2692
- }, [scale]);
2693
- if (!config) {
2694
- return null;
2695
- }
2696
- const poster = renderPoster ? renderPoster({
2697
- height: posterFillMode === "player-size" ? outerStyle.height : config.height,
2698
- width: posterFillMode === "player-size" ? outerStyle.width : config.width,
2699
- isBuffering: showBufferIndicator
2700
- }) : null;
2701
- if (poster === void 0) {
2702
- throw new TypeError("renderPoster() must return a React element, but undefined was returned");
2703
- }
2704
- const shouldShowPoster = poster && [
2705
- showPosterWhenPaused && !player.isPlaying() && !seeking,
2706
- showPosterWhenEnded && player.isLastFrame && !player.isPlaying(),
2707
- showPosterWhenUnplayed && !player.hasPlayed && !player.isPlaying(),
2708
- showPosterWhenBuffering && showBufferIndicator && player.isPlaying(),
2709
- showPosterWhenBufferingAndPaused && showBufferIndicator && !player.isPlaying()
2710
- ].some(Boolean);
2711
- const { left, top, width, height, ...outerWithoutScale } = outer;
2712
- const content = /* @__PURE__ */ jsxs9(Fragment3, {
2713
- children: [
2714
- /* @__PURE__ */ jsxs9("div", {
2715
- style: outer,
2716
- onPointerDown: clickToPlay ? handlePointerDown : void 0,
2717
- onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : void 0,
2718
- children: [
2719
- /* @__PURE__ */ jsxs9("div", {
2720
- style: containerStyle3,
2721
- className: playerCssClassname(overrideInternalClassName),
2722
- children: [
2723
- VideoComponent ? /* @__PURE__ */ jsx12(ErrorBoundary, {
2724
- onError,
2725
- errorFallback,
2726
- children: /* @__PURE__ */ jsx12(Internals11.CurrentScaleContext.Provider, {
2727
- value: currentScale,
2728
- children: /* @__PURE__ */ jsx12(VideoComponent, {
2729
- ...video?.props ?? {},
2730
- ...inputProps ?? {}
2731
- })
2732
- })
2733
- }) : null,
2734
- shouldShowPoster && posterFillMode === "composition-size" ? /* @__PURE__ */ jsx12("div", {
2735
- style: {
2736
- ...outerWithoutScale,
2737
- width: config.width,
2738
- height: config.height
2739
- },
2740
- onPointerDown: clickToPlay ? handlePointerDown : void 0,
2741
- onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : void 0,
2742
- children: poster
2743
- }) : null
2744
- ]
2745
- }),
2746
- /* @__PURE__ */ jsx12(RenderWarningIfBlacklist, {})
2747
- ]
2748
- }),
2749
- shouldShowPoster && posterFillMode === "player-size" ? /* @__PURE__ */ jsx12("div", {
2750
- style: outer,
2751
- onPointerDown: clickToPlay ? handlePointerDown : void 0,
2752
- onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : void 0,
2753
- children: poster
2754
- }) : null,
2755
- controls ? /* @__PURE__ */ jsx12(Controls, {
2756
- fps: config.fps,
2757
- playing: player.playing,
2758
- toggle: player.toggle,
2759
- durationInFrames: config.durationInFrames,
2760
- containerRef: container,
2761
- onFullscreenButtonClick,
2762
- isFullscreen,
2763
- allowFullscreen,
2764
- showVolumeControls,
2765
- onExitFullscreenButtonClick,
2766
- spaceKeyToPlayOrPause,
2767
- onSeekEnd,
2768
- onSeekStart,
2769
- inFrame,
2770
- outFrame,
2771
- initiallyShowControls,
2772
- canvasSize,
2773
- renderFullscreenButton,
2774
- renderPlayPauseButton,
2775
- alwaysShowControls,
2776
- showPlaybackRateControl,
2777
- buffering: showBufferIndicator,
2778
- hideControlsWhenPointerDoesntMove,
2779
- onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : void 0,
2780
- onPointerDown: clickToPlay ? handlePointerDown : void 0,
2781
- renderMuteButton,
2782
- renderVolumeSlider,
2783
- renderCustomControls
2784
- }) : null
2785
- ]
2786
- });
2787
- if (noSuspense || IS_NODE && !doesReactVersionSupportSuspense) {
2788
- return /* @__PURE__ */ jsx12("div", {
2789
- ref: container,
2790
- style: outerStyle,
2791
- className: className2,
2792
- children: content
2793
- });
2794
- }
2795
- return /* @__PURE__ */ jsx12("div", {
2796
- ref: container,
2797
- style: outerStyle,
2798
- className: className2,
2799
- children: /* @__PURE__ */ jsx12(Suspense, {
2800
- fallback: loadingMarkup,
2801
- children: content
2802
- })
2803
- });
2804
- };
2805
- var PlayerUI_default = forwardRef(PlayerUI);
2806
- var DEFAULT_VOLUME_PERSISTANCE_KEY = "remotion.volumePreference";
2807
- var persistVolume = (volume, logLevel, volumePersistenceKey) => {
2808
- if (typeof window === "undefined") {
2809
- return;
2810
- }
2811
- try {
2812
- window.localStorage.setItem(volumePersistenceKey ?? DEFAULT_VOLUME_PERSISTANCE_KEY, String(volume));
2813
- } catch (e) {
2814
- Internals12.Log.error({ logLevel, tag: null }, "Could not persist volume", e);
2815
- }
2816
- };
2817
- var getPreferredVolume = (volumePersistenceKey) => {
2818
- if (typeof window === "undefined") {
2819
- return 1;
2820
- }
2821
- try {
2822
- const val = window.localStorage.getItem(volumePersistenceKey ?? DEFAULT_VOLUME_PERSISTANCE_KEY);
2823
- return val ? Number(val) : 1;
2824
- } catch {
2825
- return 1;
2826
- }
2827
- };
2828
- var PLAYER_COMP_ID = "player-comp";
2829
- var SharedPlayerContexts = ({
2830
- children,
2831
- timelineContext,
2832
- fps,
2833
- compositionHeight,
2834
- compositionWidth,
2835
- durationInFrames,
2836
- component,
2837
- numberOfSharedAudioTags,
2838
- initiallyMuted,
2839
- logLevel,
2840
- audioLatencyHint,
2841
- volumePersistenceKey,
2842
- inputProps,
2843
- audioEnabled
2844
- }) => {
2845
- const compositionManagerContext = useMemo13(() => {
2846
- const context = {
2847
- compositions: [
2848
- {
2849
- component,
2850
- durationInFrames,
2851
- height: compositionHeight,
2852
- width: compositionWidth,
2853
- fps,
2854
- id: PLAYER_COMP_ID,
2855
- nonce: 777,
2856
- folderName: null,
2857
- parentFolderName: null,
2858
- schema: null,
2859
- calculateMetadata: null
2860
- }
2861
- ],
2862
- folders: [],
2863
- currentCompositionMetadata: {
2864
- defaultCodec: null,
2865
- defaultOutName: null,
2866
- defaultPixelFormat: null,
2867
- defaultProResProfile: null,
2868
- defaultVideoImageFormat: null,
2869
- durationInFrames,
2870
- fps,
2871
- height: compositionHeight,
2872
- width: compositionWidth,
2873
- props: inputProps
2874
- },
2875
- canvasContent: { type: "composition", compositionId: "player-comp" }
2876
- };
2877
- return context;
2878
- }, [
2879
- component,
2880
- durationInFrames,
2881
- compositionHeight,
2882
- compositionWidth,
2883
- fps,
2884
- inputProps
2885
- ]);
2886
- const [mediaMuted, setMediaMuted] = useState12(() => initiallyMuted);
2887
- const [mediaVolume, setMediaVolume] = useState12(() => getPreferredVolume(volumePersistenceKey ?? null));
2888
- const mediaVolumeContextValue = useMemo13(() => {
2889
- return {
2890
- mediaMuted,
2891
- mediaVolume
2892
- };
2893
- }, [mediaMuted, mediaVolume]);
2894
- const setMediaVolumeAndPersist = useCallback12((vol) => {
2895
- setMediaVolume(vol);
2896
- persistVolume(vol, logLevel, volumePersistenceKey ?? null);
2897
- }, [logLevel, volumePersistenceKey]);
2898
- const setMediaVolumeContextValue = useMemo13(() => {
2899
- return {
2900
- setMediaMuted,
2901
- setMediaVolume: setMediaVolumeAndPersist
2902
- };
2903
- }, [setMediaVolumeAndPersist]);
2904
- const logLevelContext = useMemo13(() => {
2905
- return {
2906
- logLevel,
2907
- mountTime: Date.now()
2908
- };
2909
- }, [logLevel]);
2910
- const env = useMemo13(() => {
2911
- return {
2912
- isPlayer: true,
2913
- isRendering: false,
2914
- isStudio: false,
2915
- isClientSideRendering: false,
2916
- isReadOnlyStudio: false
2917
- };
2918
- }, []);
2919
- return /* @__PURE__ */ jsx13(Internals13.RemotionEnvironmentContext.Provider, {
2920
- value: env,
2921
- children: /* @__PURE__ */ jsx13(Internals13.LogLevelContext.Provider, {
2922
- value: logLevelContext,
2923
- children: /* @__PURE__ */ jsx13(Internals13.CanUseRemotionHooksProvider, {
2924
- children: /* @__PURE__ */ jsx13(Internals13.TimelineContext.Provider, {
2925
- value: timelineContext,
2926
- children: /* @__PURE__ */ jsx13(Internals13.CompositionManager.Provider, {
2927
- value: compositionManagerContext,
2928
- children: /* @__PURE__ */ jsx13(Internals13.PrefetchProvider, {
2929
- children: /* @__PURE__ */ jsx13(Internals13.DurationsContextProvider, {
2930
- children: /* @__PURE__ */ jsx13(Internals13.MediaVolumeContext.Provider, {
2931
- value: mediaVolumeContextValue,
2932
- children: /* @__PURE__ */ jsx13(Internals13.SetMediaVolumeContext.Provider, {
2933
- value: setMediaVolumeContextValue,
2934
- children: /* @__PURE__ */ jsx13(Internals13.SharedAudioContextProvider, {
2935
- numberOfAudioTags: numberOfSharedAudioTags,
2936
- audioLatencyHint,
2937
- audioEnabled,
2938
- children: /* @__PURE__ */ jsx13(Internals13.BufferingProvider, {
2939
- children
2940
- })
2941
- })
2942
- })
2943
- })
2944
- })
2945
- })
2946
- })
2947
- })
2948
- })
2949
- })
2950
- });
2951
- };
2952
- var warningShown = false;
2953
- var acknowledgeRemotionLicenseMessage = (acknowledge, logLevel) => {
2954
- if (acknowledge) {
2955
- return;
2956
- }
2957
- if (warningShown) {
2958
- return;
2959
- }
2960
- warningShown = true;
2961
- Internals14.Log.warn({ logLevel, tag: null }, "Note: Some companies are required to obtain a license to use Remotion. See: https://remotion.dev/license\nPass the `acknowledgeRemotionLicense` prop to `<Player />` function to make this message disappear.");
2962
- };
2963
- var validateSingleFrame = (frame, variableName) => {
2964
- if (typeof frame === "undefined" || frame === null) {
2965
- return frame ?? null;
2966
- }
2967
- if (typeof frame !== "number") {
2968
- throw new TypeError(`"${variableName}" must be a number, but is ${JSON.stringify(frame)}`);
2969
- }
2970
- if (Number.isNaN(frame)) {
2971
- throw new TypeError(`"${variableName}" must not be NaN, but is ${JSON.stringify(frame)}`);
2972
- }
2973
- if (!Number.isFinite(frame)) {
2974
- throw new TypeError(`"${variableName}" must be finite, but is ${JSON.stringify(frame)}`);
2975
- }
2976
- if (frame % 1 !== 0) {
2977
- throw new TypeError(`"${variableName}" must be an integer, but is ${JSON.stringify(frame)}`);
2978
- }
2979
- return frame;
2980
- };
2981
- var validateInOutFrames = ({
2982
- inFrame,
2983
- durationInFrames,
2984
- outFrame
2985
- }) => {
2986
- const validatedInFrame = validateSingleFrame(inFrame, "inFrame");
2987
- const validatedOutFrame = validateSingleFrame(outFrame, "outFrame");
2988
- if (validatedInFrame === null && validatedOutFrame === null) {
2989
- return;
2990
- }
2991
- if (validatedInFrame !== null && validatedInFrame > durationInFrames - 1) {
2992
- throw new Error("inFrame must be less than (durationInFrames - 1), but is " + validatedInFrame);
2993
- }
2994
- if (validatedOutFrame !== null && validatedOutFrame > durationInFrames - 1) {
2995
- throw new Error("outFrame must be less than (durationInFrames - 1), but is " + validatedOutFrame);
2996
- }
2997
- if (validatedInFrame !== null && validatedInFrame < 0) {
2998
- throw new Error("inFrame must be greater than 0, but is " + validatedInFrame);
2999
- }
3000
- if (validatedOutFrame !== null && validatedOutFrame <= 0) {
3001
- throw new Error(`outFrame must be greater than 0, but is ${validatedOutFrame}. If you want to render a single frame, use <Thumbnail /> instead.`);
3002
- }
3003
- if (validatedOutFrame !== null && validatedInFrame !== null && validatedOutFrame <= validatedInFrame) {
3004
- throw new Error("outFrame must be greater than inFrame, but is " + validatedOutFrame + " <= " + validatedInFrame);
3005
- }
3006
- };
3007
- var validateInitialFrame = ({
3008
- initialFrame,
3009
- durationInFrames
3010
- }) => {
3011
- if (typeof durationInFrames !== "number") {
3012
- throw new Error(`\`durationInFrames\` must be a number, but is ${JSON.stringify(durationInFrames)}`);
3013
- }
3014
- if (typeof initialFrame === "undefined") {
3015
- return;
3016
- }
3017
- if (typeof initialFrame !== "number") {
3018
- throw new Error(`\`initialFrame\` must be a number, but is ${JSON.stringify(initialFrame)}`);
3019
- }
3020
- if (Number.isNaN(initialFrame)) {
3021
- throw new Error(`\`initialFrame\` must be a number, but is NaN`);
3022
- }
3023
- if (!Number.isFinite(initialFrame)) {
3024
- throw new Error(`\`initialFrame\` must be a number, but is Infinity`);
3025
- }
3026
- if (initialFrame % 1 !== 0) {
3027
- throw new Error(`\`initialFrame\` must be an integer, but is ${JSON.stringify(initialFrame)}`);
3028
- }
3029
- if (initialFrame > durationInFrames - 1) {
3030
- throw new Error(`\`initialFrame\` must be less or equal than \`durationInFrames - 1\`, but is ${JSON.stringify(initialFrame)}`);
3031
- }
3032
- };
3033
- var validatePlaybackRate = (playbackRate) => {
3034
- if (playbackRate === void 0) {
3035
- return;
3036
- }
3037
- if (playbackRate > 4) {
3038
- throw new Error(`The highest possible playback rate is 4. You passed: ${playbackRate}`);
3039
- }
3040
- if (playbackRate < -4) {
3041
- throw new Error(`The lowest possible playback rate is -4. You passed: ${playbackRate}`);
3042
- }
3043
- if (playbackRate === 0) {
3044
- throw new Error(`A playback rate of 0 is not supported.`);
3045
- }
3046
- };
3047
- var validateFps = NoReactInternals.validateFps;
3048
- var validateDimension = NoReactInternals.validateDimension;
3049
- var validateDurationInFrames = NoReactInternals.validateDurationInFrames;
3050
- var validateDefaultAndInputProps = NoReactInternals.validateDefaultAndInputProps;
3051
- var componentOrNullIfLazy = (props) => {
3052
- if ("component" in props) {
3053
- return props.component;
3054
- }
3055
- return null;
3056
- };
3057
- var PlayerFn = ({
3058
- durationInFrames,
3059
- compositionHeight,
3060
- compositionWidth,
3061
- fps,
3062
- inputProps,
3063
- style: style2,
3064
- controls = false,
3065
- loop = false,
3066
- autoPlay = false,
3067
- showVolumeControls = true,
3068
- allowFullscreen = true,
3069
- clickToPlay,
3070
- doubleClickToFullscreen = false,
3071
- spaceKeyToPlayOrPause = true,
3072
- moveToBeginningWhenEnded = true,
3073
- numberOfSharedAudioTags = 5,
3074
- errorFallback = () => "\u26A0\uFE0F",
3075
- playbackRate = 1,
3076
- renderLoading,
3077
- className: className2,
3078
- showPosterWhenUnplayed,
3079
- showPosterWhenEnded,
3080
- showPosterWhenPaused,
3081
- showPosterWhenBuffering,
3082
- showPosterWhenBufferingAndPaused,
3083
- initialFrame,
3084
- renderPoster,
3085
- inFrame,
3086
- outFrame,
3087
- initiallyShowControls,
3088
- renderFullscreenButton,
3089
- renderPlayPauseButton,
3090
- renderVolumeSlider,
3091
- renderCustomControls,
3092
- alwaysShowControls = false,
3093
- initiallyMuted = false,
3094
- showPlaybackRateControl = false,
3095
- posterFillMode = "player-size",
3096
- bufferStateDelayInMilliseconds,
3097
- hideControlsWhenPointerDoesntMove = true,
3098
- overflowVisible = false,
3099
- renderMuteButton,
3100
- browserMediaControlsBehavior: passedBrowserMediaControlsBehavior,
3101
- overrideInternalClassName,
3102
- logLevel = "info",
3103
- noSuspense,
3104
- acknowledgeRemotionLicense,
3105
- audioLatencyHint = "interactive",
3106
- volumePersistenceKey,
3107
- ...componentProps
3108
- }, ref) => {
3109
- if (typeof window !== "undefined") {
3110
- window.remotion_isPlayer = true;
3111
- }
3112
- if (componentProps.defaultProps !== void 0) {
3113
- throw new Error("The <Player /> component does not accept `defaultProps`, but some were passed. Use `inputProps` instead.");
3114
- }
3115
- const componentForValidation = componentOrNullIfLazy(componentProps);
3116
- if (componentForValidation?.type === Composition) {
3117
- throw new TypeError(`'component' should not be an instance of <Composition/>. Pass the React component directly, and set the duration, fps and dimensions as separate props. See https://www.remotion.dev/docs/player/examples for an example.`);
3118
- }
3119
- if (componentForValidation === Composition) {
3120
- throw new TypeError(`'component' must not be the 'Composition' component. Pass your own React component directly, and set the duration, fps and dimensions as separate props. See https://www.remotion.dev/docs/player/examples for an example.`);
3121
- }
3122
- useState13(() => acknowledgeRemotionLicenseMessage(Boolean(acknowledgeRemotionLicense), logLevel));
3123
- const component = Internals15.useLazyComponent({
3124
- compProps: componentProps,
3125
- componentName: "Player",
3126
- noSuspense: Boolean(noSuspense)
3127
- });
3128
- validateInitialFrame({ initialFrame, durationInFrames });
3129
- const [frame, setFrame] = useState13(() => ({
3130
- [PLAYER_COMP_ID]: initialFrame ?? 0
3131
- }));
3132
- const [playing, setPlaying] = useState13(false);
3133
- const [rootId] = useState13("player-comp");
3134
- const rootRef = useRef12(null);
3135
- const audioAndVideoTags = useRef12([]);
3136
- const imperativePlaying = useRef12(false);
3137
- const [currentPlaybackRate, setCurrentPlaybackRate] = useState13(playbackRate);
3138
- if (typeof compositionHeight !== "number") {
3139
- throw new TypeError(`'compositionHeight' must be a number but got '${typeof compositionHeight}' instead`);
3140
- }
3141
- if (typeof compositionWidth !== "number") {
3142
- throw new TypeError(`'compositionWidth' must be a number but got '${typeof compositionWidth}' instead`);
3143
- }
3144
- validateDimension(compositionHeight, "compositionHeight", "of the <Player /> component");
3145
- validateDimension(compositionWidth, "compositionWidth", "of the <Player /> component");
3146
- validateDurationInFrames(durationInFrames, {
3147
- component: "of the <Player/> component",
3148
- allowFloats: false
3149
- });
3150
- validateFps(fps, "as a prop of the <Player/> component", false);
3151
- validateDefaultAndInputProps(inputProps, "inputProps", null);
3152
- validateInOutFrames({
3153
- durationInFrames,
3154
- inFrame,
3155
- outFrame
3156
- });
3157
- if (typeof controls !== "boolean" && typeof controls !== "undefined") {
3158
- throw new TypeError(`'controls' must be a boolean or undefined but got '${typeof controls}' instead`);
3159
- }
3160
- if (typeof autoPlay !== "boolean" && typeof autoPlay !== "undefined") {
3161
- throw new TypeError(`'autoPlay' must be a boolean or undefined but got '${typeof autoPlay}' instead`);
3162
- }
3163
- if (typeof loop !== "boolean" && typeof loop !== "undefined") {
3164
- throw new TypeError(`'loop' must be a boolean or undefined but got '${typeof loop}' instead`);
3165
- }
3166
- if (typeof doubleClickToFullscreen !== "boolean" && typeof doubleClickToFullscreen !== "undefined") {
3167
- throw new TypeError(`'doubleClickToFullscreen' must be a boolean or undefined but got '${typeof doubleClickToFullscreen}' instead`);
3168
- }
3169
- if (typeof showVolumeControls !== "boolean" && typeof showVolumeControls !== "undefined") {
3170
- throw new TypeError(`'showVolumeControls' must be a boolean or undefined but got '${typeof showVolumeControls}' instead`);
3171
- }
3172
- if (typeof allowFullscreen !== "boolean" && typeof allowFullscreen !== "undefined") {
3173
- throw new TypeError(`'allowFullscreen' must be a boolean or undefined but got '${typeof allowFullscreen}' instead`);
3174
- }
3175
- if (typeof clickToPlay !== "boolean" && typeof clickToPlay !== "undefined") {
3176
- throw new TypeError(`'clickToPlay' must be a boolean or undefined but got '${typeof clickToPlay}' instead`);
3177
- }
3178
- if (typeof spaceKeyToPlayOrPause !== "boolean" && typeof spaceKeyToPlayOrPause !== "undefined") {
3179
- throw new TypeError(`'spaceKeyToPlayOrPause' must be a boolean or undefined but got '${typeof spaceKeyToPlayOrPause}' instead`);
3180
- }
3181
- if (typeof numberOfSharedAudioTags !== "number" || numberOfSharedAudioTags % 1 !== 0 || !Number.isFinite(numberOfSharedAudioTags) || Number.isNaN(numberOfSharedAudioTags) || numberOfSharedAudioTags < 0) {
3182
- throw new TypeError(`'numberOfSharedAudioTags' must be an integer but got '${numberOfSharedAudioTags}' instead`);
3183
- }
3184
- validatePlaybackRate(currentPlaybackRate);
3185
- useEffect13(() => {
3186
- setCurrentPlaybackRate(playbackRate);
3187
- }, [playbackRate]);
3188
- useImperativeHandle2(ref, () => rootRef.current, []);
3189
- useState13(() => {
3190
- Internals15.playbackLogging({
3191
- logLevel,
3192
- message: `[player] Mounting <Player>. User agent = ${typeof navigator === "undefined" ? "server" : navigator.userAgent}`,
3193
- tag: "player",
3194
- mountTime: Date.now()
3195
- });
3196
- });
3197
- const timelineContextValue = useMemo14(() => {
3198
- return {
3199
- frame,
3200
- playing,
3201
- rootId,
3202
- playbackRate: currentPlaybackRate,
3203
- imperativePlaying,
3204
- setPlaybackRate: (rate) => {
3205
- setCurrentPlaybackRate(rate);
3206
- },
3207
- audioAndVideoTags
3208
- };
3209
- }, [frame, currentPlaybackRate, playing, rootId]);
3210
- const setTimelineContextValue = useMemo14(() => {
3211
- return {
3212
- setFrame,
3213
- setPlaying
3214
- };
3215
- }, [setFrame]);
3216
- if (typeof window !== "undefined") {
3217
- useLayoutEffect2(() => {
3218
- Internals15.CSSUtils.injectCSS(Internals15.CSSUtils.makeDefaultPreviewCSS(`.${playerCssClassname(overrideInternalClassName)}`, "#fff"));
3219
- }, [overrideInternalClassName]);
3220
- }
3221
- const actualInputProps = useMemo14(() => inputProps ?? {}, [inputProps]);
3222
- const browserMediaControlsBehavior = useMemo14(() => {
3223
- return passedBrowserMediaControlsBehavior ?? {
3224
- mode: "prevent-media-session"
3225
- };
3226
- }, [passedBrowserMediaControlsBehavior]);
3227
- return /* @__PURE__ */ jsx14(Internals15.IsPlayerContextProvider, {
3228
- children: /* @__PURE__ */ jsx14(SharedPlayerContexts, {
3229
- timelineContext: timelineContextValue,
3230
- component,
3231
- compositionHeight,
3232
- compositionWidth,
3233
- durationInFrames,
3234
- fps,
3235
- numberOfSharedAudioTags,
3236
- initiallyMuted,
3237
- logLevel,
3238
- audioLatencyHint,
3239
- volumePersistenceKey,
3240
- inputProps: actualInputProps,
3241
- audioEnabled: true,
3242
- children: /* @__PURE__ */ jsx14(Internals15.SetTimelineContext.Provider, {
3243
- value: setTimelineContextValue,
3244
- children: /* @__PURE__ */ jsx14(PlayerEmitterProvider, {
3245
- currentPlaybackRate,
3246
- children: /* @__PURE__ */ jsx14(PlayerUI_default, {
3247
- ref: rootRef,
3248
- posterFillMode,
3249
- renderLoading,
3250
- autoPlay: Boolean(autoPlay),
3251
- loop: Boolean(loop),
3252
- controls: Boolean(controls),
3253
- errorFallback,
3254
- style: style2,
3255
- inputProps: actualInputProps,
3256
- allowFullscreen: Boolean(allowFullscreen),
3257
- moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded),
3258
- clickToPlay: typeof clickToPlay === "boolean" ? clickToPlay : Boolean(controls),
3259
- showVolumeControls: Boolean(showVolumeControls),
3260
- doubleClickToFullscreen: Boolean(doubleClickToFullscreen),
3261
- spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause),
3262
- playbackRate: currentPlaybackRate,
3263
- className: className2 ?? void 0,
3264
- showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed),
3265
- showPosterWhenEnded: Boolean(showPosterWhenEnded),
3266
- showPosterWhenPaused: Boolean(showPosterWhenPaused),
3267
- showPosterWhenBuffering: Boolean(showPosterWhenBuffering),
3268
- showPosterWhenBufferingAndPaused: Boolean(showPosterWhenBufferingAndPaused),
3269
- renderPoster,
3270
- inFrame: inFrame ?? null,
3271
- outFrame: outFrame ?? null,
3272
- initiallyShowControls: initiallyShowControls ?? true,
3273
- renderFullscreen: renderFullscreenButton ?? null,
3274
- renderPlayPauseButton: renderPlayPauseButton ?? null,
3275
- renderMuteButton: renderMuteButton ?? null,
3276
- renderVolumeSlider: renderVolumeSlider ?? null,
3277
- renderCustomControls: renderCustomControls ?? null,
3278
- alwaysShowControls,
3279
- showPlaybackRateControl,
3280
- bufferStateDelayInMilliseconds: bufferStateDelayInMilliseconds ?? 300,
3281
- hideControlsWhenPointerDoesntMove,
3282
- overflowVisible,
3283
- browserMediaControlsBehavior,
3284
- overrideInternalClassName: overrideInternalClassName ?? void 0,
3285
- noSuspense: Boolean(noSuspense)
3286
- })
3287
- })
3288
- })
3289
- })
3290
- });
3291
- };
3292
- var forward = forwardRef2;
3293
- var Player = forward(PlayerFn);
3294
- var useThumbnail = () => {
3295
- const emitter = useContext7(ThumbnailEmitterContext);
3296
- if (!emitter) {
3297
- throw new TypeError("Expected Player event emitter context");
3298
- }
3299
- const returnValue = useMemo15(() => {
3300
- return {
3301
- emitter
3302
- };
3303
- }, [emitter]);
3304
- return returnValue;
3305
- };
3306
- var reactVersion2 = React13.version.split(".")[0];
3307
- if (reactVersion2 === "0") {
3308
- throw new Error(`Version ${reactVersion2} of "react" is not supported by Remotion`);
3309
- }
3310
- var doesReactVersionSupportSuspense2 = parseInt(reactVersion2, 10) >= 18;
3311
- var ThumbnailUI = ({
3312
- style: style2,
3313
- inputProps,
3314
- errorFallback,
3315
- renderLoading,
3316
- className: className2,
3317
- overflowVisible,
3318
- noSuspense,
3319
- overrideInternalClassName
3320
- }, ref) => {
3321
- const config = Internals16.useUnsafeVideoConfig();
3322
- const video = Internals16.useVideo();
3323
- const container = useRef13(null);
3324
- const canvasSize = useElementSize(container, {
3325
- triggerOnWindowResize: false,
3326
- shouldApplyCssTransforms: false
3327
- });
3328
- const layout = useMemo16(() => {
3329
- if (!config || !canvasSize) {
3330
- return null;
3331
- }
3332
- return calculateCanvasTransformation({
3333
- canvasSize,
3334
- compositionHeight: config.height,
3335
- compositionWidth: config.width,
3336
- previewSize: "auto"
3337
- });
3338
- }, [canvasSize, config]);
3339
- const scale = layout?.scale ?? 1;
3340
- const thumbnail = useThumbnail();
3341
- useBufferStateEmitter(thumbnail.emitter);
3342
- useImperativeHandle3(ref, () => {
3343
- const methods = {
3344
- getContainerNode: () => container.current,
3345
- getScale: () => scale
3346
- };
3347
- return Object.assign(thumbnail.emitter, methods);
3348
- }, [scale, thumbnail.emitter]);
3349
- const VideoComponent = video ? video.component : null;
3350
- const outerStyle = useMemo16(() => {
3351
- return calculateOuterStyle({
3352
- config,
3353
- style: style2,
3354
- canvasSize,
3355
- overflowVisible,
3356
- layout
3357
- });
3358
- }, [canvasSize, config, layout, overflowVisible, style2]);
3359
- const outer = useMemo16(() => {
3360
- return calculateOuter({ config, layout, scale, overflowVisible });
3361
- }, [config, layout, overflowVisible, scale]);
3362
- const containerStyle3 = useMemo16(() => {
3363
- return calculateContainerStyle({
3364
- config,
3365
- layout,
3366
- scale,
3367
- overflowVisible
3368
- });
3369
- }, [config, layout, overflowVisible, scale]);
3370
- const onError = useCallback13((error) => {
3371
- thumbnail.emitter.dispatchError(error);
3372
- }, [thumbnail.emitter]);
3373
- const loadingMarkup = useMemo16(() => {
3374
- return renderLoading ? renderLoading({
3375
- height: outerStyle.height,
3376
- width: outerStyle.width,
3377
- isBuffering: false
3378
- }) : null;
3379
- }, [outerStyle.height, outerStyle.width, renderLoading]);
3380
- const currentScaleContext = useMemo16(() => {
3381
- return {
3382
- type: "scale",
3383
- scale
3384
- };
3385
- }, [scale]);
3386
- if (!config) {
3387
- return null;
3388
- }
3389
- const content = /* @__PURE__ */ jsx15("div", {
3390
- style: outer,
3391
- children: /* @__PURE__ */ jsx15("div", {
3392
- style: containerStyle3,
3393
- className: playerCssClassname(overrideInternalClassName),
3394
- children: VideoComponent ? /* @__PURE__ */ jsx15(ErrorBoundary, {
3395
- onError,
3396
- errorFallback,
3397
- children: /* @__PURE__ */ jsx15(Internals16.CurrentScaleContext.Provider, {
3398
- value: currentScaleContext,
3399
- children: /* @__PURE__ */ jsx15(VideoComponent, {
3400
- ...video?.props ?? {},
3401
- ...inputProps ?? {}
3402
- })
3403
- })
3404
- }) : null
3405
- })
3406
- });
3407
- if (noSuspense || IS_NODE && !doesReactVersionSupportSuspense2) {
3408
- return /* @__PURE__ */ jsx15("div", {
3409
- ref: container,
3410
- style: outerStyle,
3411
- className: className2,
3412
- children: content
3413
- });
3414
- }
3415
- return /* @__PURE__ */ jsx15("div", {
3416
- ref: container,
3417
- style: outerStyle,
3418
- className: className2,
3419
- children: /* @__PURE__ */ jsx15(Suspense2, {
3420
- fallback: loadingMarkup,
3421
- children: content
3422
- })
3423
- });
3424
- };
3425
- var ThumbnailUI_default = forwardRef3(ThumbnailUI);
3426
- var ThumbnailFn = ({
3427
- frameToDisplay,
3428
- style: style2,
3429
- inputProps,
3430
- compositionHeight,
3431
- compositionWidth,
3432
- durationInFrames,
3433
- fps,
3434
- className: className2,
3435
- errorFallback = () => "\u26A0\uFE0F",
3436
- renderLoading,
3437
- overflowVisible = false,
3438
- overrideInternalClassName,
3439
- logLevel = "info",
3440
- noSuspense,
3441
- ...componentProps
3442
- }, ref) => {
3443
- if (typeof window !== "undefined") {
3444
- useLayoutEffect3(() => {
3445
- window.remotion_isPlayer = true;
3446
- }, []);
3447
- }
3448
- const [thumbnailId] = useState14(() => String(random2(null)));
3449
- const rootRef = useRef14(null);
3450
- const timelineState = useMemo17(() => {
3451
- const value = {
3452
- playing: false,
3453
- frame: {
3454
- [PLAYER_COMP_ID]: frameToDisplay
3455
- },
3456
- rootId: thumbnailId,
3457
- imperativePlaying: {
3458
- current: false
3459
- },
3460
- playbackRate: 1,
3461
- setPlaybackRate: () => {
3462
- throw new Error("thumbnail");
3463
- },
3464
- audioAndVideoTags: { current: [] }
3465
- };
3466
- return value;
3467
- }, [frameToDisplay, thumbnailId]);
3468
- useImperativeHandle4(ref, () => rootRef.current, []);
3469
- const Component = Internals17.useLazyComponent({
3470
- compProps: componentProps,
3471
- componentName: "Thumbnail",
3472
- noSuspense: Boolean(noSuspense)
3473
- });
3474
- const [emitter] = useState14(() => new ThumbnailEmitter());
3475
- const passedInputProps = useMemo17(() => {
3476
- return inputProps ?? {};
3477
- }, [inputProps]);
3478
- return /* @__PURE__ */ jsx16(Internals17.IsPlayerContextProvider, {
3479
- children: /* @__PURE__ */ jsx16(SharedPlayerContexts, {
3480
- timelineContext: timelineState,
3481
- component: Component,
3482
- compositionHeight,
3483
- compositionWidth,
3484
- durationInFrames,
3485
- fps,
3486
- numberOfSharedAudioTags: 0,
3487
- initiallyMuted: true,
3488
- logLevel,
3489
- audioLatencyHint: "playback",
3490
- inputProps: passedInputProps,
3491
- audioEnabled: false,
3492
- children: /* @__PURE__ */ jsx16(ThumbnailEmitterContext.Provider, {
3493
- value: emitter,
3494
- children: /* @__PURE__ */ jsx16(ThumbnailUI_default, {
3495
- ref: rootRef,
3496
- className: className2,
3497
- errorFallback,
3498
- inputProps: passedInputProps,
3499
- renderLoading,
3500
- style: style2,
3501
- overflowVisible,
3502
- overrideInternalClassName,
3503
- noSuspense: Boolean(noSuspense)
3504
- })
3505
- })
3506
- })
3507
- });
3508
- };
3509
- var forward2 = forwardRef4;
3510
- var Thumbnail = forward2(ThumbnailFn);
3511
-
3512
- // ../execution/primitives/src/lib/preview.tsx
3513
- var TransitionPanel = ({
3514
- label: label2,
3515
- color
3516
- }) => /* @__PURE__ */ React2.createElement(
3517
- AbsoluteFill,
3518
- {
3519
- style: {
3520
- background: color,
3521
- color: "#fff",
3522
- display: "flex",
3523
- alignItems: "center",
3524
- justifyContent: "center",
3525
- fontFamily: "inherit",
3526
- fontSize: 96,
3527
- fontWeight: 600
3528
- }
3529
- },
3530
- label2
3531
- );
3532
- var TransitionPreviewComposition = ({ presentation, durationInFrames }) => {
3533
- const half = Math.max(1, Math.floor(durationInFrames / 2));
3534
- return /* @__PURE__ */ React2.createElement(TransitionSeries, null, /* @__PURE__ */ React2.createElement(TransitionSeries.Sequence, { durationInFrames: half }, /* @__PURE__ */ React2.createElement(TransitionPanel, { label: "A", color: "#0ea5e9" })), /* @__PURE__ */ React2.createElement(
3535
- TransitionSeries.Transition,
3536
- {
3537
- timing: linearTiming({ durationInFrames: half }),
3538
- presentation
3539
- }
3540
- ), /* @__PURE__ */ React2.createElement(TransitionSeries.Sequence, { durationInFrames: half }, /* @__PURE__ */ React2.createElement(TransitionPanel, { label: "B", color: "#9333ea" })));
3541
- };
3542
- var PrimitivePreview = ({
3543
- primitive,
3544
- exampleName,
3545
- paramsOverride,
3546
- width,
3547
- height,
3548
- autoPlay,
3549
- controls = false,
3550
- className: className2,
3551
- style: style2
3552
- }) => {
3553
- const example = React2.useMemo(() => {
3554
- const targetName = exampleName ?? primitive.preview.defaultExample;
3555
- if (targetName) {
3556
- const found = primitive.examples.find((e) => e.name === targetName);
3557
- if (found) return found;
3558
- }
3559
- return primitive.examples[0];
3560
- }, [primitive, exampleName]);
3561
- const inputProps = React2.useMemo(
3562
- () => ({ ...example?.params, ...paramsOverride }),
3563
- [example, paramsOverride]
3564
- );
3565
- const compWidth = width ?? primitive.preview.width ?? primitive.width;
3566
- const compHeight = height ?? primitive.preview.height ?? primitive.height;
3567
- const loop = primitive.preview.mode === "loop";
3568
- const shouldAutoPlay = autoPlay ?? loop;
3569
- if (!example) {
3570
- return /* @__PURE__ */ React2.createElement(
3571
- "div",
3572
- {
3573
- className: className2,
3574
- style: {
3575
- width: compWidth,
3576
- height: compHeight,
3577
- background: "#1a1a1a",
3578
- color: "#999",
3579
- display: "flex",
3580
- alignItems: "center",
3581
- justifyContent: "center",
3582
- fontFamily: "monospace",
3583
- fontSize: 12,
3584
- ...style2
3585
- }
3586
- },
3587
- "no example for ",
3588
- primitive.id
3589
- );
3590
- }
3591
- if (primitive.kind === "transition" && primitive.createPresentation) {
3592
- const presentation = primitive.createPresentation(inputProps);
3593
- return /* @__PURE__ */ React2.createElement(
3594
- Player,
3595
- {
3596
- component: TransitionPreviewComposition,
3597
- inputProps: {
3598
- presentation,
3599
- durationInFrames: primitive.durationInFrames
3600
- },
3601
- durationInFrames: primitive.durationInFrames,
3602
- fps: primitive.fps,
3603
- compositionWidth: primitive.width,
3604
- compositionHeight: primitive.height,
3605
- style: { width: compWidth, height: compHeight, ...style2 },
3606
- className: className2,
3607
- autoPlay: shouldAutoPlay,
3608
- loop,
3609
- controls
3610
- }
3611
- );
3612
- }
3613
- return /* @__PURE__ */ React2.createElement(
3614
- Player,
3615
- {
3616
- component: primitive.component,
3617
- inputProps,
3618
- durationInFrames: primitive.durationInFrames,
3619
- fps: primitive.fps,
3620
- compositionWidth: primitive.width,
3621
- compositionHeight: primitive.height,
3622
- style: { width: compWidth, height: compHeight, ...style2 },
3623
- className: className2,
3624
- autoPlay: shouldAutoPlay,
3625
- loop,
3626
- controls
3627
- }
3628
- );
3629
- };
3630
-
3631
- export {
3632
- PrimitivePreview
3633
- };