running:
bash create-vod-hls.sh beach.mkv
will produce:
beach/
|- playlist.m3u8
|- 360p.m3u8
| class ResourceLoader { | |
| static jsZipLoaded = false; | |
| static async loadJSZip() { | |
| if (this.jsZipLoaded) return Promise.resolve(); | |
| return new Promise((resolve, reject) => { | |
| if (typeof JSZip !== 'undefined') { | |
| this.jsZipLoaded = true; | |
| resolve(); |
running:
bash create-vod-hls.sh beach.mkv
will produce:
beach/
|- playlist.m3u8
|- 360p.m3u8
| export type Replace<T, R> = Omit<T, keyof R> & R; |
| import { TRPCError } from '@trpc/server'; | |
| import { TRPC_ERROR_CODE_KEY } from '@trpc/server/dist/rpc'; | |
| function trpcAssert( | |
| condition: unknown, | |
| msg: string, | |
| code: TRPC_ERROR_CODE_KEY = 'INTERNAL_SERVER_ERROR' | |
| ): asserts condition { | |
| if (!condition) { | |
| throw new TRPCError({ |
| // trpc.ts | |
| import { trpcTracingMiddleware } from "@baselime/node-opentelemetry"; | |
| const t = initTRPC.context<typeof createTRPCContext>().create({ | |
| ... | |
| }); | |
| // add the middleware to all the procedures you want to trace | |
| export const publicProcedure = t.procedure.use(trpcTracingMiddleware({ collectInput: true })) |
| // SERVER | |
| export const storageRouter = createTRPCRouter({ | |
| requestVideoUploadUrl: protectedProcedure | |
| .input(z.object({ videoId: z.string().uuid() })) | |
| .query(async ({ input }) => { | |
| const { videoId } = input | |
| const signedUrl = await getSignedUrl( | |
| r2, |
| import React, { createContext, useContext } from "react"; | |
| export function createSafeContext<ContextValue>(errorMessage: string) { | |
| const Context = createContext<ContextValue | null>(null); | |
| const useSafeContext = () => { | |
| const ctx = useContext(Context); | |
| if (ctx === null) { | |
| throw new Error(errorMessage); |
| import { useCallback, useEffect, useRef, useState } from "react"; | |
| /** | |
| * Custom React hook for double-click confirmation for critical actions. | |
| * | |
| * @param action - The action to be executed on the second click. | |
| * @param timeout - Time in milliseconds to reset the unlocked state. | |
| * @returns The current unlocked state and the trigger function. | |
| */ | |
| const useConfirmation = (action: () => void, timeout: number = 5000) => { |