Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions apps/docs-embed/components-to-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import * as path from "node:path";
import { glob } from "glob";

function escapeComponentContent(content: string): string {
return content
.replace(/\\/g, "\\\\")
.replace(/`/g, "\\`")
.replace(/\$\{/g, "\\${")
.replace(/\"use client\";/g, "")
.trim();
return (
content
.replace(/\\/g, "\\\\")
.replace(/`/g, "\\`")
.replace(/\$\{/g, "\\${")
// biome-ignore lint/complexity/noUselessEscapeInRegex: ignored using `--suppress`
.replace(/\"use client\";/g, "")
.trim()
);
}

function fileNameToExportName(fileName: string): string {
Expand Down
7 changes: 5 additions & 2 deletions apps/docs-embed/src/app/broadcast/[key]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { notFound } from "next/navigation";
import Audio from "@/components/broadcast/audio";
import Camera from "@/components/broadcast/camera";
import Container from "@/components/broadcast/container";
Expand All @@ -20,7 +21,6 @@ import {
CodeWithExampleServer,
getBroadcastKeys,
} from "@/components/code/code-server";
import { notFound } from "next/navigation";

export const dynamic = "force-static";

Expand All @@ -32,7 +32,9 @@ export async function generateStaticParams() {

export default ({
params,
}: { params: { key: BroadcastComponentKey | undefined } }) => {
}: {
params: { key: BroadcastComponentKey | undefined };
}) => {
if (!params.key) {
notFound();
}
Expand Down Expand Up @@ -76,6 +78,7 @@ export default ({
) : params.key === "video" ? (
<Video />
) : (
// biome-ignore lint/complexity/noUselessFragments: ignored using `--suppress`
<></>
)
}
Expand Down
2 changes: 1 addition & 1 deletion apps/docs-embed/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cn } from "@/lib/utils";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import { Toaster } from "sonner";
import { cn } from "@/lib/utils";
import "./globals.css";

const inter = Inter({ subsets: ["latin"] });
Expand Down
9 changes: 6 additions & 3 deletions apps/docs-embed/src/app/player/[key]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { notFound } from "next/navigation";
import {
CodeWithExampleServer,
type PlayerComponentKey,
getPlayerKeys,
type PlayerComponentKey,
} from "@/components/code/code-server";
import Clip from "@/components/player/clip";
import Container from "@/components/player/container";
Expand All @@ -23,7 +24,6 @@ import UseMediaContext from "@/components/player/use-media-context";
import Video from "@/components/player/video";
import VideoQuality from "@/components/player/video-quality";
import Volume from "@/components/player/volume";
import { notFound } from "next/navigation";

export const dynamic = "force-static";

Expand All @@ -35,7 +35,9 @@ export async function generateStaticParams() {

export default ({
params,
}: { params: { key: PlayerComponentKey | undefined } }) => {
}: {
params: { key: PlayerComponentKey | undefined };
}) => {
if (!params.key) {
notFound();
}
Expand Down Expand Up @@ -85,6 +87,7 @@ export default ({
) : params.key === "volume" ? (
<Volume />
) : (
// biome-ignore lint/complexity/noUselessFragments: ignored using `--suppress`
<></>
)
}
Expand Down
5 changes: 2 additions & 3 deletions apps/docs-embed/src/components/broadcast/fullscreen.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"use client";

import * as Broadcast from "@livepeer/react/broadcast";
import { getIngest } from "@livepeer/react/external";

import {
EnterFullscreenIcon,
ExitFullscreenIcon,
} from "@livepeer/react/assets";
import * as Broadcast from "@livepeer/react/broadcast";
import { getIngest } from "@livepeer/react/external";
import { streamKey } from "./stream-key";

export default () => {
Expand Down
3 changes: 1 addition & 2 deletions apps/docs-embed/src/components/broadcast/pip.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"use client";

import { PictureInPictureIcon } from "@livepeer/react/assets";
import * as Broadcast from "@livepeer/react/broadcast";
import { getIngest } from "@livepeer/react/external";

import { PictureInPictureIcon } from "@livepeer/react/assets";
import { streamKey } from "./stream-key";

export default () => {
Expand Down
8 changes: 5 additions & 3 deletions apps/docs-embed/src/components/code/code-server.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { notFound } from "next/navigation";
import * as broadcastComponents from "@/lib/broadcast-components";
import * as playerComponents from "@/lib/player-components";
import { codeToHtml } from "@/lib/shiki";
import { notFound } from "next/navigation";
import { ExpandableCode } from "./code";

export type PlayerComponentKey = keyof typeof playerComponents;
Expand Down Expand Up @@ -32,8 +32,10 @@ export const CodeWithExampleServer = async ({
}) => {
const stringComponent =
type === "player"
? playerComponents[component as PlayerComponentKey]
: broadcastComponents[component as BroadcastComponentKey];
? // biome-ignore lint/performance/noDynamicNamespaceImportAccess: ignored using `--suppress`
playerComponents[component as PlayerComponentKey]
: // biome-ignore lint/performance/noDynamicNamespaceImportAccess: ignored using `--suppress`
broadcastComponents[component as BroadcastComponentKey];

if (!stringComponent) {
notFound();
Expand Down
5 changes: 2 additions & 3 deletions apps/docs-embed/src/components/player/fullscreen.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"use client";

import { getSrc } from "@livepeer/react/external";
import * as Player from "@livepeer/react/player";

import {
EnterFullscreenIcon,
ExitFullscreenIcon,
} from "@livepeer/react/assets";
import { getSrc } from "@livepeer/react/external";
import * as Player from "@livepeer/react/player";
import { vodSource } from "./source";

export default () => {
Expand Down
3 changes: 1 addition & 2 deletions apps/docs-embed/src/components/player/pip.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"use client";

import { PictureInPictureIcon } from "@livepeer/react/assets";
import { getSrc } from "@livepeer/react/external";
import * as Player from "@livepeer/react/player";

import { PictureInPictureIcon } from "@livepeer/react/assets";
import { vodSource } from "./source";

export default () => {
Expand Down
3 changes: 1 addition & 2 deletions apps/docs-embed/src/components/player/play.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"use client";

import { PauseIcon, PlayIcon } from "@livepeer/react/assets";
import { getSrc } from "@livepeer/react/external";
import * as Player from "@livepeer/react/player";

import { PauseIcon, PlayIcon } from "@livepeer/react/assets";
import { vodSource } from "./source";

export default () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/docs-embed/src/components/player/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import * as Popover from "@radix-ui/react-popover";
import { CheckIcon, ChevronDownIcon, XIcon } from "lucide-react";
import React, {
type CSSProperties,
type PropsWithChildren,
forwardRef,
type PropsWithChildren,
} from "react";
import { vodSource } from "./source";

Expand Down
7 changes: 5 additions & 2 deletions apps/lvpr-tv/src/app/broadcast/[key]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getIngest } from "@livepeer/react/external";
import { BroadcastWithControls } from "@/components/broadcast/Broadcast";
import type { Booleanish } from "@/lib/types";
import { coerceToBoolean } from "@/lib/utils";
import { getIngest } from "@livepeer/react/external";

type BroadcastSearchParams = {
forceEnabled?: Booleanish;
Expand All @@ -13,7 +13,10 @@ type BroadcastSearchParams = {
export default async function BroadcastPage({
params,
searchParams,
}: { params: { key?: string }; searchParams: Partial<BroadcastSearchParams> }) {
}: {
params: { key?: string };
searchParams: Partial<BroadcastSearchParams>;
}) {
const ingestUrl = getIngest(params.key, {
baseUrl:
process.env.NEXT_PUBLIC_WEBRTC_INGEST_BASE_URL ??
Expand Down
2 changes: 1 addition & 1 deletion apps/lvpr-tv/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cn } from "@/lib/utils";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import { Toaster } from "sonner";
import { cn } from "@/lib/utils";
import "./globals.css";

const inter = Inter({ subsets: ["latin"] });
Expand Down
4 changes: 2 additions & 2 deletions apps/lvpr-tv/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ClipLength } from "@livepeer/react";
import { Suspense } from "react";
import {
PlayerLoading,
type PlayerProps,
Expand All @@ -6,8 +8,6 @@ import {
} from "@/components/player/Player";
import type { Booleanish } from "@/lib/types";
import { coerceToBoolean } from "@/lib/utils";
import type { ClipLength } from "@livepeer/react";
import { Suspense } from "react";
import { IframeMessenger } from "../components/IframeMessenger";

type Autoplay = Booleanish;
Expand Down
2 changes: 2 additions & 0 deletions apps/lvpr-tv/src/components/IframeMessenger.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import { useEffect } from "react";

interface PlayerError {
message: string;
code?: string;
Expand Down Expand Up @@ -40,6 +41,7 @@ function isAllowedOrigin(origin: string): boolean {
function isInIframe(): boolean {
try {
return typeof window !== "undefined" && window.self !== window.top;
// biome-ignore lint/correctness/noUnusedVariables: ignored using `--suppress`
} catch (e) {
return true;
}
Expand Down
6 changes: 5 additions & 1 deletion apps/lvpr-tv/src/components/broadcast/Broadcast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function BroadcastWithControls({
description="The stream key provided was invalid. Please check and try again."
/>
) : (
// biome-ignore lint/complexity/noUselessFragments: ignored using `--suppress`
<>
<Broadcast.Root
{...rest}
Expand Down Expand Up @@ -178,7 +179,10 @@ export function BroadcastWithControls({
export const BroadcastLoading = ({
title,
description,
}: { title?: React.ReactNode; description?: React.ReactNode }) => (
}: {
title?: React.ReactNode;
description?: React.ReactNode;
}) => (
<div className="h-full relative w-full px-3 md:px-3 py-3 gap-3 flex-col-reverse flex bg-white/10 overflow-hidden rounded-sm">
<div className="flex justify-between">
<div className="flex items-center gap-2">
Expand Down
3 changes: 1 addition & 2 deletions apps/lvpr-tv/src/components/broadcast/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import { SettingsIcon } from "@livepeer/react/assets";
import * as Broadcast from "@livepeer/react/broadcast";
import * as Popover from "@radix-ui/react-popover";

import { cn } from "@/lib/utils";
import { CheckIcon, ChevronDownIcon, XIcon } from "lucide-react";
import React from "react";
import { cn } from "@/lib/utils";

export const Settings = React.forwardRef(
(
Expand Down
5 changes: 2 additions & 3 deletions apps/lvpr-tv/src/components/player/Clip.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"use client";

import { toast } from "sonner";
import { ClipIcon, LoadingIcon } from "@livepeer/react/assets";

import * as Player from "@livepeer/react/player";

import { ClipIcon, LoadingIcon } from "@livepeer/react/assets";
import type { ClipPayload } from "livepeer/models/components";
import { useCallback, useTransition } from "react";
import { toast } from "sonner";
import { createClip } from "./actions";

export function Clip({ className }: { className?: string }) {
Expand Down
2 changes: 1 addition & 1 deletion apps/lvpr-tv/src/components/player/ForceError.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use client";

import { cn } from "@/lib/utils";
import {
type MediaScopedProps,
useMediaContext,
useStore,
} from "@livepeer/react/player";
import { cn } from "@/lib/utils";

const FORCE_ERROR_NAME = "ForceError";

Expand Down
16 changes: 10 additions & 6 deletions apps/lvpr-tv/src/components/player/Player.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Player from "@livepeer/react/player";
import type { ClipLength } from "@livepeer/react";

import {
EnterFullscreenIcon,
Expand All @@ -11,15 +11,14 @@ import {
UnmuteIcon,
} from "@livepeer/react/assets";
import { getSrc } from "@livepeer/react/external";
import * as Player from "@livepeer/react/player";
import { unstable_cache } from "next/cache";
import { cache } from "react";
import { Clip } from "./Clip";
import { CurrentSource } from "./CurrentSource";

import { livepeer } from "@/lib/livepeer";
import { cn } from "@/lib/utils";
import type { ClipLength } from "@livepeer/react";
import { PlayerErrorMonitor } from "../PlayerErrorMonitor";
import { Clip } from "./Clip";
import { CurrentSource } from "./CurrentSource";
import { ForceError } from "./ForceError";
import { Settings } from "./Settings";

Expand Down Expand Up @@ -361,7 +360,10 @@ export async function PlayerWithoutControls(props: PlayerProps) {
export const PlayerLoading = ({
title,
description,
}: { title?: React.ReactNode; description?: React.ReactNode }) => (
}: {
title?: React.ReactNode;
description?: React.ReactNode;
}) => (
<div className="relative h-full w-full px-3 py-2 gap-3 flex-col-reverse flex bg-white/10 overflow-hidden rounded-sm">
<div className="flex justify-between">
<div className="flex items-center gap-2">
Expand All @@ -387,9 +389,11 @@ export const PlayerLoading = ({
</div>
);

// biome-ignore lint/correctness/noUnusedVariables: ignored using `--suppress`
function isInIframe() {
try {
return typeof window !== "undefined" && window.self !== window.top;
// biome-ignore lint/correctness/noUnusedVariables: ignored using `--suppress`
} catch (e) {
// if accessing window.top throws an exception due to cross-origin policy,
// the catch block will also return true,
Expand Down
5 changes: 2 additions & 3 deletions apps/lvpr-tv/src/components/player/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"use client";

import { SettingsIcon } from "@livepeer/react/assets";
import * as Player from "@livepeer/react/player";
import * as Popover from "@radix-ui/react-popover";

import { cn } from "@/lib/utils";
import { SettingsIcon } from "@livepeer/react/assets";
import { CheckIcon, ChevronDownIcon, XIcon } from "lucide-react";
import React from "react";
import { cn } from "@/lib/utils";

export const Settings = React.forwardRef(
(
Expand Down
2 changes: 1 addition & 1 deletion apps/lvpr-tv/src/components/player/actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use server";

import { livepeer } from "@/lib/livepeer";
import type { ClipPayload } from "livepeer/models/components";
import { livepeer } from "@/lib/livepeer";

export const createClip = async (opts: ClipPayload) => {
try {
Expand Down
Loading
Loading