@remotion/promo-pages 5.0.0-canary → 5.0.0-canary.3

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 (130) hide show
  1. package/dist/Homepage.js +1 -1
  2. package/dist/homepage/Pricing.js +1 -1
  3. package/package.json +15 -12
  4. package/.turbo/turbo-make.log +0 -8
  5. package/bundle.ts +0 -38
  6. package/eslint.config.mjs +0 -7
  7. package/index.html +0 -13
  8. package/public/fire.mp3 +0 -0
  9. package/public/img/cluster.png +0 -0
  10. package/public/img/code-sample-new.png +0 -0
  11. package/public/img/freelancers/alex.jpeg +0 -0
  12. package/public/img/freelancers/antoine.jpeg +0 -0
  13. package/public/img/freelancers/ayush.png +0 -0
  14. package/public/img/freelancers/benjamin.jpeg +0 -0
  15. package/public/img/freelancers/default.png +0 -0
  16. package/public/img/freelancers/florent.jpeg +0 -0
  17. package/public/img/freelancers/karel.jpeg +0 -0
  18. package/public/img/freelancers/lorenzo.jpeg +0 -0
  19. package/public/img/freelancers/mickael.jpeg +0 -0
  20. package/public/img/freelancers/mohit.jpeg +0 -0
  21. package/public/img/freelancers/pramod.jpg +0 -0
  22. package/public/img/freelancers/pranav.jpg +0 -0
  23. package/public/img/freelancers/rahul.png +0 -0
  24. package/public/img/freelancers/ray.jpeg +0 -0
  25. package/public/img/freelancers/stephen.png +0 -0
  26. package/public/img/freelancers/umungo.png +0 -0
  27. package/public/img/freelancers/yehor.jpeg +0 -0
  28. package/public/img/gt-planar-black.woff2 +0 -0
  29. package/public/img/gt-planar-bold.woff2 +0 -0
  30. package/public/img/gt-planar-medium.woff2 +0 -0
  31. package/public/img/gt-planar-regular.woff2 +0 -0
  32. package/public/img/logo-small.png +0 -0
  33. package/public/img/mp4.png +0 -0
  34. package/public/img/player-demo.mp4 +0 -0
  35. package/public/img/player-example-dark.png +0 -0
  36. package/public/img/player-example.png +0 -0
  37. package/public/img/writeinreact.png +0 -0
  38. package/public/partyhorn.mp3 +0 -0
  39. package/public/sad.mp3 +0 -0
  40. package/src/cn.ts +0 -6
  41. package/src/components/Homepage.tsx +0 -88
  42. package/src/components/homepage/BackgroundAnimation.tsx +0 -108
  43. package/src/components/homepage/ChooseTemplate.tsx +0 -57
  44. package/src/components/homepage/CodeExample.tsx +0 -89
  45. package/src/components/homepage/CommunityStats.tsx +0 -54
  46. package/src/components/homepage/CommunityStatsItems.tsx +0 -304
  47. package/src/components/homepage/Counter.tsx +0 -110
  48. package/src/components/homepage/Demo/Card.tsx +0 -273
  49. package/src/components/homepage/Demo/Cards.tsx +0 -129
  50. package/src/components/homepage/Demo/Comp.tsx +0 -157
  51. package/src/components/homepage/Demo/CurrentCountry.tsx +0 -97
  52. package/src/components/homepage/Demo/DemoError.tsx +0 -18
  53. package/src/components/homepage/Demo/DemoErrorIcon.tsx +0 -32
  54. package/src/components/homepage/Demo/DemoRender.tsx +0 -166
  55. package/src/components/homepage/Demo/DigitWheel.tsx +0 -179
  56. package/src/components/homepage/Demo/DisplayedEmoji.tsx +0 -81
  57. package/src/components/homepage/Demo/DoneCheckmark.tsx +0 -39
  58. package/src/components/homepage/Demo/DownloadNudge.tsx +0 -62
  59. package/src/components/homepage/Demo/DragAndDropNudge.tsx +0 -57
  60. package/src/components/homepage/Demo/EmojiCard.tsx +0 -198
  61. package/src/components/homepage/Demo/Minus.tsx +0 -21
  62. package/src/components/homepage/Demo/PlayPauseButton.tsx +0 -66
  63. package/src/components/homepage/Demo/PlayerControls.tsx +0 -48
  64. package/src/components/homepage/Demo/PlayerSeekBar.tsx +0 -325
  65. package/src/components/homepage/Demo/PlayerVolume.tsx +0 -83
  66. package/src/components/homepage/Demo/Progress.tsx +0 -38
  67. package/src/components/homepage/Demo/Spinner.tsx +0 -60
  68. package/src/components/homepage/Demo/Switcher.tsx +0 -54
  69. package/src/components/homepage/Demo/Temperature.tsx +0 -44
  70. package/src/components/homepage/Demo/TemperatureNumber.tsx +0 -68
  71. package/src/components/homepage/Demo/ThemeNudge.tsx +0 -72
  72. package/src/components/homepage/Demo/TimeDisplay.tsx +0 -43
  73. package/src/components/homepage/Demo/TrendingRepos.tsx +0 -106
  74. package/src/components/homepage/Demo/icons.tsx +0 -114
  75. package/src/components/homepage/Demo/index.tsx +0 -158
  76. package/src/components/homepage/Demo/math.ts +0 -43
  77. package/src/components/homepage/Demo/types.ts +0 -6
  78. package/src/components/homepage/Editor.tsx +0 -67
  79. package/src/components/homepage/EvaluateRemotion.tsx +0 -92
  80. package/src/components/homepage/FreePricing.tsx +0 -295
  81. package/src/components/homepage/GetStartedStrip.tsx +0 -77
  82. package/src/components/homepage/GitHubButton.tsx +0 -23
  83. package/src/components/homepage/IconForTemplate.tsx +0 -154
  84. package/src/components/homepage/IfYouKnowReact.tsx +0 -29
  85. package/src/components/homepage/InfoTooltip.tsx +0 -25
  86. package/src/components/homepage/MoreTemplatesButton.tsx +0 -29
  87. package/src/components/homepage/MuxVideo.tsx +0 -68
  88. package/src/components/homepage/NewsletterButton.tsx +0 -88
  89. package/src/components/homepage/Pricing.tsx +0 -49
  90. package/src/components/homepage/PricingBulletPoint.tsx +0 -50
  91. package/src/components/homepage/RealMp4Videos.tsx +0 -50
  92. package/src/components/homepage/Spacer.tsx +0 -5
  93. package/src/components/homepage/TemplateIcon.tsx +0 -36
  94. package/src/components/homepage/TextInput.tsx +0 -62
  95. package/src/components/homepage/TrustedByBanner.tsx +0 -194
  96. package/src/components/homepage/VideoApps.tsx +0 -231
  97. package/src/components/homepage/VideoAppsShowcase.tsx +0 -276
  98. package/src/components/homepage/VideoAppsTitle.tsx +0 -24
  99. package/src/components/homepage/VideoPlayerWithControls.tsx +0 -188
  100. package/src/components/homepage/WriteInReact.tsx +0 -34
  101. package/src/components/homepage/YouAreHere.tsx +0 -30
  102. package/src/components/homepage/custom.css +0 -57
  103. package/src/components/homepage/layout/Button.tsx +0 -93
  104. package/src/components/homepage/layout/colors.ts +0 -17
  105. package/src/components/homepage/layout/use-color-mode.tsx +0 -44
  106. package/src/components/homepage/layout/use-el-size.ts +0 -51
  107. package/src/components/homepage/layout/use-mobile-layout.ts +0 -8
  108. package/src/components/homepage/video-player.css +0 -24
  109. package/src/components/icons/blank.tsx +0 -13
  110. package/src/components/icons/clone.tsx +0 -10
  111. package/src/components/icons/code-hike.tsx +0 -15
  112. package/src/components/icons/cubes.tsx +0 -13
  113. package/src/components/icons/js.tsx +0 -17
  114. package/src/components/icons/next.tsx +0 -64
  115. package/src/components/icons/overlay.tsx +0 -24
  116. package/src/components/icons/remix.tsx +0 -24
  117. package/src/components/icons/skia.tsx +0 -13
  118. package/src/components/icons/stargazer.tsx +0 -13
  119. package/src/components/icons/still.tsx +0 -13
  120. package/src/components/icons/tailwind.tsx +0 -22
  121. package/src/components/icons/tiktok.tsx +0 -13
  122. package/src/components/icons/ts.tsx +0 -18
  123. package/src/components/icons/tts.tsx +0 -13
  124. package/src/components/icons/undo.tsx +0 -11
  125. package/src/components/icons/waveform.tsx +0 -13
  126. package/src/fonts.css +0 -30
  127. package/src/index.css +0 -74
  128. package/src/main.tsx +0 -12
  129. package/tsconfig.json +0 -15
  130. package/vite.config.ts +0 -9
@@ -1,129 +0,0 @@
1
- import type {EmojiName} from '@remotion/animated-emoji';
2
- import React, {
3
- createRef,
4
- useCallback,
5
- useEffect,
6
- useRef,
7
- useState,
8
- } from 'react';
9
- import {AbsoluteFill, getRemotionEnvironment} from 'remotion';
10
- import {Card} from './Card';
11
- import type {RemoteData} from './Comp';
12
- import {CurrentCountry} from './CurrentCountry';
13
- import {EmojiCard, type EmojiCardRef} from './EmojiCard';
14
- import {getInitialPositions} from './math';
15
- import {Temperature} from './Temperature';
16
- import {TrendingRepos} from './TrendingRepos';
17
- import type {Location} from './types';
18
-
19
- export const Cards: React.FC<{
20
- readonly onUpdate: (newIndices: number[]) => void;
21
- readonly indices: number[];
22
- readonly theme: 'dark' | 'light';
23
- readonly location: Location | null;
24
- readonly trending: RemoteData | null;
25
- readonly onToggle: () => void;
26
- readonly onLeft: () => void;
27
- readonly onRight: () => void;
28
- readonly emojiName: EmojiName;
29
- }> = ({
30
- onUpdate,
31
- indices,
32
- theme,
33
- onToggle,
34
- onLeft: onLeftPress,
35
- onRight: onRightPress,
36
- emojiName,
37
- location,
38
- trending,
39
- }) => {
40
- const container = useRef<HTMLDivElement>(null);
41
-
42
- const [refs] = useState(() => {
43
- return new Array(4).fill(true).map(() => {
44
- return createRef<HTMLDivElement>();
45
- });
46
- });
47
-
48
- const positions = useRef(getInitialPositions());
49
- const shouldBePositions = useRef(getInitialPositions());
50
- const {isRendering} = getRemotionEnvironment();
51
-
52
- useEffect(() => {
53
- const {current} = container;
54
- if (!current) {
55
- return;
56
- }
57
-
58
- const onClick = (e: MouseEvent) => {
59
- if (e.target !== current) {
60
- return;
61
- }
62
-
63
- onToggle();
64
- };
65
-
66
- current.addEventListener('click', onClick);
67
-
68
- return () => {
69
- current.removeEventListener('click', onClick);
70
- };
71
- }, [onToggle]);
72
-
73
- const ref = useRef<EmojiCardRef>(null);
74
-
75
- const onLeft = useCallback(() => {
76
- ref.current?.onRight();
77
- onRightPress();
78
- }, [onRightPress]);
79
-
80
- const onRight = useCallback(() => {
81
- ref.current?.onLeft();
82
- onLeftPress();
83
- }, [onLeftPress]);
84
-
85
- return (
86
- <AbsoluteFill ref={container}>
87
- {new Array(4).fill(true).map((_, i) => {
88
- const index = indices[i];
89
- const content =
90
- index === 0 ? (
91
- <TrendingRepos trending={trending} theme={theme} />
92
- ) : index === 1 ? (
93
- <Temperature
94
- city={location?.city ?? null}
95
- theme={theme}
96
- temperatureInCelsius={trending?.temperatureInCelsius ?? null}
97
- />
98
- ) : index === 2 ? (
99
- <CurrentCountry
100
- countryPaths={trending?.countryPaths ?? null}
101
- countryLabel={trending?.countryLabel ?? null}
102
- theme={theme}
103
- />
104
- ) : (
105
- <EmojiCard ref={ref} emojiIndex={emojiName} />
106
- );
107
-
108
- return (
109
- <Card
110
- // eslint-disable-next-line react/no-array-index-key
111
- key={i}
112
- onUpdate={onUpdate}
113
- // @ts-expect-error
114
- refsToUse={refs}
115
- index={i}
116
- content={content}
117
- positions={positions}
118
- shouldBePositions={shouldBePositions}
119
- indices={indices}
120
- theme={theme}
121
- withSwitcher={index === 3 && !isRendering}
122
- onClickLeft={onLeft}
123
- onClickRight={onRight}
124
- />
125
- );
126
- })}
127
- </AbsoluteFill>
128
- );
129
- };
@@ -1,157 +0,0 @@
1
- import type {EmojiName} from '@remotion/animated-emoji';
2
- import React, {useCallback, useEffect, useMemo, useState} from 'react';
3
- import {
4
- AbsoluteFill,
5
- Audio,
6
- prefetch,
7
- staticFile,
8
- type CalculateMetadataFunction,
9
- } from 'remotion';
10
- import {Cards} from './Cards';
11
- import type {Location} from './types';
12
-
13
- export type RemoteData = {
14
- repos: string[];
15
- date: string | number;
16
- temperatureInCelsius: number;
17
- countryLabel: string;
18
- countryPaths: {
19
- d: string;
20
- class: string;
21
- }[];
22
- };
23
-
24
- export type LocationAndTrending = {
25
- readonly location: Location | null;
26
- readonly trending: RemoteData | null;
27
- };
28
-
29
- export const getDataAndProps = async () => {
30
- const location = (await fetch(
31
- 'https://bugs-git-homepage-player-remotion.vercel.app/api/location',
32
- ).then((res) => res.json())) as Location;
33
-
34
- const trending = await fetch(
35
- `https://bugs.remotion.dev/trending?lat=${location.latitude}&lng=${location.longitude}&country=${location.country}`,
36
- )
37
- .then((res) => res.json())
38
- .then((data) => {
39
- return {
40
- repos: data.trending.repos.slice(0, 3),
41
- date: data.trending.dateFetched,
42
- temperatureInCelsius: Math.round(data.temperature),
43
- countryLabel: data.countryLabel,
44
- countryPaths: data.countryPaths,
45
- };
46
- });
47
-
48
- return {trending, location};
49
- };
50
-
51
- export const calculateMetadata: CalculateMetadataFunction<DemoPlayerProps> = ({
52
- props,
53
- }) => {
54
- return {
55
- durationInFrames: 120,
56
- fps: 30,
57
- height: 360,
58
- width: 640,
59
- props: {
60
- ...props,
61
- },
62
- };
63
- };
64
-
65
- export type DemoPlayerProps = {
66
- readonly onToggle: () => void;
67
- readonly cardOrder: number[];
68
- readonly updateCardOrder: (newCardOrder: number[]) => void;
69
- readonly theme: 'dark' | 'light';
70
- readonly onClickLeft: () => void;
71
- readonly onClickRight: () => void;
72
- readonly emojiIndex: number;
73
- } & LocationAndTrending;
74
-
75
- const fireAudio = staticFile('fire.mp3');
76
- const partyHornAudio = staticFile('partyhorn.mp3');
77
- const sadAudio = staticFile('sad.mp3');
78
-
79
- export const HomepageVideoComp: React.FC<DemoPlayerProps> = ({
80
- theme,
81
- onToggle,
82
- cardOrder,
83
- updateCardOrder,
84
- location,
85
- trending,
86
- emojiIndex,
87
- onClickLeft,
88
- onClickRight,
89
- }) => {
90
- const [rerenders, setRerenders] = useState(0);
91
-
92
- const onUpdate = useCallback(
93
- (newIndices: number[]) => {
94
- setRerenders(rerenders + 1);
95
- updateCardOrder(newIndices);
96
- },
97
- [rerenders, updateCardOrder],
98
- );
99
-
100
- const emoji = useMemo((): EmojiName => {
101
- if ((emojiIndex + 10000 * 3) % 3 === 1) {
102
- return 'melting';
103
- }
104
-
105
- if ((emojiIndex + 10000 * 3) % 3 === 2) {
106
- return 'fire';
107
- }
108
-
109
- return 'partying-face';
110
- }, [emojiIndex]);
111
-
112
- const audioSrc = useMemo(() => {
113
- if (emoji === 'fire') {
114
- return fireAudio;
115
- }
116
-
117
- if (emoji === 'partying-face') {
118
- return partyHornAudio;
119
- }
120
-
121
- return sadAudio;
122
- }, [emoji]);
123
-
124
- useEffect(() => {
125
- const a = prefetch(fireAudio);
126
- const b = prefetch(partyHornAudio);
127
- const c = prefetch(sadAudio);
128
-
129
- return () => {
130
- a.free();
131
- b.free();
132
- c.free();
133
- };
134
- }, []);
135
-
136
- return (
137
- <AbsoluteFill
138
- style={{
139
- backgroundColor: theme === 'dark' ? '#222' : '#fafafa',
140
- }}
141
- >
142
- <Cards
143
- key={rerenders}
144
- onUpdate={onUpdate}
145
- indices={cardOrder}
146
- theme={theme}
147
- location={location}
148
- trending={trending}
149
- onToggle={onToggle}
150
- onLeft={onClickLeft}
151
- onRight={onClickRight}
152
- emojiName={emoji}
153
- />
154
- {audioSrc ? <Audio src={audioSrc} /> : null}
155
- </AbsoluteFill>
156
- );
157
- };
@@ -1,97 +0,0 @@
1
- import {getBoundingBox, resetPath} from '@remotion/paths';
2
- import React from 'react';
3
- import {
4
- AbsoluteFill,
5
- interpolate,
6
- spring,
7
- useCurrentFrame,
8
- useVideoConfig,
9
- } from 'remotion';
10
-
11
- export const CurrentCountry: React.FC<{
12
- readonly theme: 'dark' | 'light';
13
- readonly countryPaths:
14
- | {
15
- d: string;
16
- class: string;
17
- }[]
18
- | null;
19
- readonly countryLabel: string | null;
20
- }> = ({theme, countryPaths, countryLabel}) => {
21
- const {fps} = useVideoConfig();
22
- const frame = useCurrentFrame();
23
-
24
- if (!countryPaths) {
25
- return null;
26
- }
27
-
28
- const joined = countryPaths.map((p) => p.d).join(' ');
29
- const reset = resetPath(joined);
30
- const boundingBox = getBoundingBox(reset);
31
-
32
- const progress = spring({
33
- fps,
34
- frame,
35
- delay: 10,
36
- });
37
-
38
- return (
39
- <AbsoluteFill style={{overflow: 'hidden'}}>
40
- <AbsoluteFill
41
- style={{
42
- transform: `scale(${progress})`,
43
- }}
44
- >
45
- <svg
46
- viewBox={boundingBox.viewBox}
47
- style={{
48
- scale: '0.8',
49
- }}
50
- >
51
- <path fill={theme === 'light' ? '#bbb' : '#222'} d={reset} />
52
- </svg>
53
- </AbsoluteFill>
54
- <AbsoluteFill
55
- style={{
56
- alignItems: 'center',
57
- justifyContent: 'center',
58
- }}
59
- >
60
- <div
61
- style={{
62
- color: '#0b84f3',
63
- fontFamily: 'GTPlanar',
64
- fontWeight: '500',
65
- fontSize: 13,
66
- textAlign: 'center',
67
- marginTop: -10,
68
- width: '100%',
69
- paddingLeft: 20,
70
- paddingRight: 20,
71
- transform:
72
- 'translateX(' + interpolate(progress, [0, 1], [-100, 0]) + '%)',
73
- }}
74
- >
75
- Your country
76
- </div>
77
- <div
78
- style={{
79
- lineHeight: 1.1,
80
- fontFamily: 'GTPlanar',
81
- textAlign: 'center',
82
- fontWeight: '500',
83
- fontSize: 30,
84
- color: theme === 'dark' ? 'white' : 'black',
85
- width: '100%',
86
- paddingLeft: 20,
87
- paddingRight: 20,
88
- transform:
89
- 'translateX(' + interpolate(progress, [0, 1], [100, 0]) + '%)',
90
- }}
91
- >
92
- {countryLabel}
93
- </div>
94
- </AbsoluteFill>
95
- </AbsoluteFill>
96
- );
97
- };
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import {FONTS, RED} from '../layout/colors';
3
-
4
- export const DemoError: React.FC = () => {
5
- return (
6
- <div
7
- style={{
8
- color: RED,
9
- fontFamily: FONTS.GTPLANAR,
10
- position: 'absolute',
11
- paddingTop: 15,
12
- }}
13
- >
14
- Sorry, we limit the amount of renders possible per day on this page. Come
15
- back tomorrow!
16
- </div>
17
- );
18
- };
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import {RED} from '../layout/colors';
3
-
4
- export const DemoErrorIcon: React.FC = () => {
5
- return (
6
- <div
7
- style={{
8
- height: 26,
9
- width: 26,
10
- borderRadius: 13,
11
- display: 'flex',
12
- alignItems: 'center',
13
- justifyContent: 'center',
14
- animation: 'jump 0.2s ease-out',
15
- }}
16
- >
17
- <svg
18
- style={{
19
- flexShrink: 0,
20
- width: 26,
21
- }}
22
- xmlns="http://www.w3.org/2000/svg"
23
- viewBox="0 0 512 512"
24
- >
25
- <path
26
- fill={RED}
27
- d="M17.1 292c-12.9-22.3-12.9-49.7 0-72L105.4 67.1c12.9-22.3 36.6-36 62.4-36l176.6 0c25.7 0 49.5 13.7 62.4 36L494.9 220c12.9 22.3 12.9 49.7 0 72L406.6 444.9c-12.9 22.3-36.6 36-62.4 36l-176.6 0c-25.7 0-49.5-13.7-62.4-36L17.1 292zM256 128c-13.3 0-24 10.7-24 24l0 112c0 13.3 10.7 24 24 24s24-10.7 24-24l0-112c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"
28
- />
29
- </svg>
30
- </div>
31
- );
32
- };
@@ -1,166 +0,0 @@
1
- import type {EnhancedErrorInfo} from '@remotion/lambda';
2
- import React, {useCallback} from 'react';
3
- import {z} from 'zod';
4
- import {PALETTE} from '../layout/colors';
5
- import {DemoErrorIcon} from './DemoErrorIcon';
6
- import {DoneCheckmark} from './DoneCheckmark';
7
- import {Progress} from './Progress';
8
- import {Spinner} from './Spinner';
9
-
10
- const countryPath = z.object({
11
- d: z.string(),
12
- class: z.string(),
13
- });
14
-
15
- const remoteData = z.object({
16
- repos: z.array(z.string()),
17
- date: z.string().or(z.number()),
18
- temperatureInCelsius: z.number(),
19
- countryLabel: z.string(),
20
- countryPaths: z.array(countryPath),
21
- });
22
-
23
- const location = z.object({
24
- country: z.string(),
25
- city: z.string(),
26
- latitude: z.number().or(z.string()),
27
- longitude: z.number().or(z.string()),
28
- });
29
-
30
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
- const data = z.object({
32
- trending: remoteData,
33
- location,
34
- emojiIndex: z.number(),
35
- theme: z.enum(['light', 'dark']),
36
- cardOrder: z.array(z.number()),
37
- });
38
-
39
- type State =
40
- | {
41
- type: 'idle';
42
- }
43
- | {
44
- type: 'invoking';
45
- }
46
- | {
47
- type: 'progress';
48
- progress: number;
49
- }
50
- | {
51
- type: 'done';
52
- }
53
- | {
54
- type: 'error';
55
- };
56
-
57
- const style: React.CSSProperties = {
58
- appearance: 'none',
59
- border: 'none',
60
- outline: 'none',
61
- backgroundColor: 'transparent',
62
- cursor: 'pointer',
63
- width: 55,
64
- height: 50,
65
- display: 'flex',
66
- alignItems: 'center',
67
- justifyContent: 'center',
68
- };
69
-
70
- export const RenderButton: React.FC<{
71
- readonly renderData: z.infer<typeof data> | null;
72
- readonly onError: () => void;
73
- }> = ({renderData, onError}) => {
74
- const [state, setState] = React.useState<State>({
75
- type: 'idle',
76
- });
77
-
78
- const triggerRender = useCallback(async () => {
79
- if (renderData === null) {
80
- return;
81
- }
82
-
83
- try {
84
- setState({type: 'invoking'});
85
-
86
- const {renderId, bucketName} = await (
87
- await fetch('https://bugs.remotion.dev/render', {
88
- method: 'post',
89
- headers: {'content-type': 'application/json'},
90
- body: JSON.stringify(renderData),
91
- })
92
- ).json();
93
- setState({type: 'progress', progress: 0});
94
-
95
- let done = false;
96
-
97
- while (!done) {
98
- const progress = (await (
99
- await fetch('https://bugs.remotion.dev/progress', {
100
- method: 'post',
101
- headers: {'content-type': 'application/json'},
102
- body: JSON.stringify({renderId, bucketName}),
103
- })
104
- ).json()) as {
105
- overallProgress: number;
106
- outputFile: string | null;
107
- errors: EnhancedErrorInfo[];
108
- fatalErrorEncountered: boolean;
109
- };
110
- setState({
111
- type: 'progress',
112
- progress: progress.overallProgress,
113
- });
114
-
115
- if (progress.outputFile) {
116
- done = true;
117
- const a = document.createElement('a');
118
- a.href = progress.outputFile;
119
- a.download = 'remotion.dev.mp4';
120
- a.click();
121
- setState({type: 'done'});
122
- }
123
-
124
- if (progress.fatalErrorEncountered) {
125
- done = true;
126
- }
127
- }
128
- } catch {
129
- setState({type: 'error'});
130
- onError();
131
- }
132
- }, [onError, renderData]);
133
-
134
- return (
135
- <button
136
- type="button"
137
- onClick={triggerRender}
138
- style={style}
139
- disabled={!renderData || state.type !== 'idle'}
140
- >
141
- {state.type === 'error' ? (
142
- <DemoErrorIcon />
143
- ) : state.type === 'done' ? (
144
- <DoneCheckmark />
145
- ) : state.type === 'progress' ? (
146
- <Progress progress={state.progress} />
147
- ) : state.type === 'invoking' ? (
148
- <Spinner size={20} duration={1} />
149
- ) : (
150
- <svg
151
- style={{
152
- width: 18,
153
- opacity: renderData ? 1 : 0.5,
154
- }}
155
- xmlns="http://www.w3.org/2000/svg"
156
- viewBox="0 0 384 512"
157
- >
158
- <path
159
- fill={PALETTE.TEXT_COLOR}
160
- d="M214.6 342.6L192 365.3l-22.6-22.6-128-128L18.7 192 64 146.7l22.6 22.6L160 242.7 160 64l0-32 64 0 0 32 0 178.7 73.4-73.4L320 146.7 365.3 192l-22.6 22.6-128 128zM32 416l320 0 32 0 0 64-32 0L32 480 0 480l0-64 32 0z"
161
- />
162
- </svg>
163
- )}
164
- </button>
165
- );
166
- };