add vidsrc source+embed and StreamBucket embed

This commit is contained in:
Jonathan Barrow
2023-09-30 17:44:32 -04:00
parent c82a1f94b3
commit 849347afbe
19 changed files with 385 additions and 5 deletions

View File

@@ -34,6 +34,7 @@ export function makeFullFetcher(fetcher: Fetcher): UseableFetcher {
query: ops?.query ?? {},
baseUrl: ops?.baseUrl ?? '',
body: ops?.body,
returnRaw: ops?.returnRaw,
});
};
}

View File

@@ -17,6 +17,7 @@ export type FetchReply = {
text(): Promise<string>;
json(): Promise<any>;
headers: FetchHeaders;
url: string;
};
export type FetchLike = (url: string, ops?: FetchOps | undefined) => Promise<FetchReply>;

View File

@@ -17,6 +17,10 @@ export function makeStandardFetcher(f: FetchLike): Fetcher {
body: seralizedBody.body,
});
if (ops.returnRaw) {
return res;
}
const isJson = res.headers.get('content-type')?.includes('application/json');
if (isJson) return res.json();
return res.text();

View File

@@ -4,8 +4,9 @@ export type FetcherOptions = {
baseUrl?: string;
headers?: Record<string, string>;
query?: Record<string, string>;
method?: 'GET' | 'POST';
method?: 'HEAD' | 'GET' | 'POST';
body?: Record<string, any> | string | FormData | URLSearchParams;
returnRaw?: boolean;
};
export type DefaultedFetcherOptions = {
@@ -13,7 +14,8 @@ export type DefaultedFetcherOptions = {
body?: Record<string, any> | string | FormData;
headers: Record<string, string>;
query: Record<string, string>;
method: 'GET' | 'POST';
method: 'HEAD' | 'GET' | 'POST';
returnRaw?: boolean;
};
export type Fetcher<T = any> = {