Skip to content

🎥 Make videos programmatically with React

Merge remote-tracking branch 'origin/main' into codex/element-library-discovery

JonnyBurgercb3aa3d4dc0c
diff --cc packages/docs/src/components/Elements/ThirdPartyElementLibraries.tsx
index 8ed117267c,b26ab446a0..919f986d35
--- a/packages/docs/src/components/Elements/ThirdPartyElementLibraries.tsx
+++ b/packages/docs/src/components/Elements/ThirdPartyElementLibraries.tsx
@@@ -1,9 -1,9 +1,10 @@@
import {
addElementLibraryToStudio,
+ isInsideStudio,
type AddElementLibraryToStudioErrorCode,
} from '@remotion/studio-protocol';
-import React, {useCallback, useId, useState} from 'react';
+import React, {useCallback, useId, useLayoutEffect, useState} from 'react';
+ import {BlueButton} from '../../../components/layout/Button';
import {
thirdPartyElementLibraries,
type ThirdPartyElementLibrary,
diff --cc packages/example/e2e/studio-protocol.test.mts
index c3312038b7,c3312038b7..ed9292f9f4
--- a/packages/example/e2e/studio-protocol.test.mts
+++ b/packages/example/e2e/studio-protocol.test.mts
@@@ -1,3 -1,3 +1,4 @@@
++import {expect, test} from '@playwright/test';
import type {ChildProcess} from 'node:child_process';
import {spawn} from 'node:child_process';
import fs from 'node:fs';
@@@ -5,7 -5,7 +6,6 @@@ import {createServer} from 'node:http'
import os from 'node:os';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
--import {expect, test} from '@playwright/test';
import {remotionBin} from './constants.mts';
const waitForUrl = async (url: string, process: ChildProcess) => {
@@@ -888,19 -888,19 +888,10 @@@ const CloseupPlaceholder = () =>
addLibraryDialog.getByText('Add Element Library', {exact: true}),
).toBeVisible();
await expect(
-- addLibraryDialog.getByText(senderUrl, {exact: true}),
-- ).toBeVisible();
-- await expect(
-- addLibraryDialog.getByText(protocolLibraryUrl, {exact: true}),
-- ).toBeVisible();
-- const libraryDetails = addLibraryDialog.getByLabel(
-- 'Element Library details',
-- );
-- await expect(
-- libraryDetails.getByText('Display name', {exact: true}),
-- ).toBeVisible();
-- await expect(
-- libraryDetails.getByText('Protocol Library', {exact: true}),
++ addLibraryDialog.getByText(
++ `${senderUrl.replace(/^https?:\/\//, '')} wants to add ${protocolLibraryUrl.replace(/^https?:\/\//, '')} as an Element library.`,
++ {exact: true},
++ ),
).toBeVisible();
await expect(decoyStudioPage.getByText('Add Element Library')).toHaveCount(
0,
diff --cc packages/studio/src/components/Modals.tsx
index d3e9039d03,67d597a258..f8560207c1
--- a/packages/studio/src/components/Modals.tsx
+++ b/packages/studio/src/components/Modals.tsx
@@@ -175,49 -167,25 +171,50 @@@ export const Modals: React.FC<
return;
}
+ let normalizedUrl: string | null = null;
+ try {
+ const parsedUrl = new URL(request.url);
+ if (parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:') {
+ normalizedUrl = parsedUrl.href;
+ }
+ } catch {
+ // The response below explains that the URL is invalid.
+ }
+
+ const displayName = request.displayName?.trim() ?? null;
const canAddLibrary =
- previewServerState.type === 'connected' && !readOnlyStudio;
+ !isBrowserStudio &&
+ !readOnlyStudio &&
+ previewServerState.type === 'connected';
- const result: AddElementLibraryToStudioResult = canAddLibrary
- ? {
- success: true,
- status: 'awaiting-confirmation',
- target: {
- projectName: window.remotion_projectName,
- studioOrigin: window.location.origin,
- studioVersion: window.remotion_version,
- },
- }
- : {
- success: false,
- code: 'no-configurable-target',
- message: 'Open a writable Remotion Studio, then try again.',
- };
+ const result: AddElementLibraryToStudioResult =
+ normalizedUrl === null
+ ? {
+ success: false,
+ code: 'invalid-url',
+ message:
+ 'The Element Library URL must be an absolute HTTP or HTTPS URL.',
+ }
+ : displayName === ''
+ ? {
+ success: false,
+ code: 'invalid-display-name',
+ message: 'The Element Library display name must not be empty.',
+ }
+ : !canAddLibrary
+ ? {
+ success: false,
+ code: 'no-configurable-target',
- message:
- 'Focus a writable Remotion Studio tab, then try again.',
++ message: 'Open a writable Remotion Studio, then try again.',
+ }
+ : {
+ success: true,
+ status: 'awaiting-confirmation',
+ target: {
+ projectName: window.remotion_projectName,
+ studioOrigin: window.location.origin,
+ studioVersion: window.remotion_version,
+ },
+ };
const timeout = window.setTimeout(() => responsePort.close(), 1000);
responsePort.onmessage = () => {