@uploadfilm/sdk 0.0.0-stage → 0.1.0

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 (218) hide show
  1. package/LICENSE +4 -0
  2. package/README.md +509 -2
  3. package/dist/ai/embed.d.ts +58 -0
  4. package/dist/ai/fake.d.ts +41 -0
  5. package/dist/ai/http.d.ts +17 -0
  6. package/dist/ai/index.d.ts +27 -0
  7. package/dist/ai/languages.d.ts +2 -0
  8. package/dist/ai/ollama.d.ts +23 -0
  9. package/dist/ai/openaiCompatible.d.ts +54 -0
  10. package/dist/ai/passages.d.ts +28 -0
  11. package/dist/ai/transcribe.d.ts +84 -0
  12. package/dist/ai/types.d.ts +141 -0
  13. package/dist/ai/usage.d.ts +66 -0
  14. package/dist/ai/whisperJson.d.ts +15 -0
  15. package/dist/ai/workersAi.d.ts +56 -0
  16. package/dist/ai.js +1 -0
  17. package/dist/ai.mjs +1 -0
  18. package/dist/cards/files.d.ts +91 -0
  19. package/dist/cards/index.d.ts +15 -0
  20. package/dist/cards/layouts.d.ts +121 -0
  21. package/dist/cards/probe.d.ts +69 -0
  22. package/dist/cards/proxies.d.ts +70 -0
  23. package/dist/cards/select.d.ts +68 -0
  24. package/dist/cards/volumes.d.ts +170 -0
  25. package/dist/cards/xml.d.ts +80 -0
  26. package/dist/cards.js +1 -0
  27. package/dist/cards.mjs +1 -0
  28. package/dist/copy/checksums.d.ts +66 -0
  29. package/dist/copy/engine.d.ts +24 -0
  30. package/dist/copy/errors.d.ts +109 -0
  31. package/dist/copy/index.d.ts +15 -0
  32. package/dist/copy/steps.d.ts +28 -0
  33. package/dist/copy/sweep.d.ts +24 -0
  34. package/dist/copy/types.d.ts +336 -0
  35. package/dist/embed/player.js +2 -0
  36. package/dist/host/adapters.d.ts +107 -0
  37. package/dist/host/detect.d.ts +68 -0
  38. package/dist/host/encoders.d.ts +34 -0
  39. package/dist/host/environment.d.ts +53 -0
  40. package/dist/host/index.d.ts +20 -0
  41. package/dist/host/linux.d.ts +94 -0
  42. package/dist/host/mac.d.ts +47 -0
  43. package/dist/host/network.d.ts +54 -0
  44. package/dist/host/node.d.ts +13 -0
  45. package/dist/host/policy.d.ts +101 -0
  46. package/dist/host/tuner.d.ts +48 -0
  47. package/dist/host/types.d.ts +118 -0
  48. package/dist/host-node.js +1 -0
  49. package/dist/host-node.mjs +1 -0
  50. package/dist/host.js +1 -0
  51. package/dist/host.mjs +1 -0
  52. package/dist/images/index.d.ts +11 -0
  53. package/dist/images/settings.d.ts +43 -0
  54. package/dist/images/types.d.ts +83 -0
  55. package/dist/images/url.d.ts +65 -0
  56. package/dist/index.d.ts +16 -0
  57. package/dist/index.js +1 -0
  58. package/dist/index.mjs +1 -0
  59. package/dist/player/adapters/hlsjs.d.ts +28 -0
  60. package/dist/player/bandwidthMemory.d.ts +28 -0
  61. package/dist/player/captions/index.d.ts +55 -0
  62. package/dist/player/embed/code.d.ts +195 -0
  63. package/dist/player/embed/constants.d.ts +4 -0
  64. package/dist/player/embed/controller.d.ts +62 -0
  65. package/dist/player/embed/element.d.ts +32 -0
  66. package/dist/player/embed/frame.d.ts +65 -0
  67. package/dist/player/embed/global.d.ts +14 -0
  68. package/dist/player/embed/index.d.ts +15 -0
  69. package/dist/player/embed/loader.d.ts +1 -0
  70. package/dist/player/embed/oembed.d.ts +74 -0
  71. package/dist/player/embed/protocol.d.ts +64 -0
  72. package/dist/player/engine.d.ts +215 -0
  73. package/dist/player/index.d.ts +18 -0
  74. package/dist/player/start.d.ts +62 -0
  75. package/dist/player/store.d.ts +10 -0
  76. package/dist/player/storyboard/index.d.ts +161 -0
  77. package/dist/player/stream.d.ts +206 -0
  78. package/dist/player/tracks.d.ts +41 -0
  79. package/dist/player.js +1 -0
  80. package/dist/player.mjs +1 -0
  81. package/dist/proxies/args.d.ts +19 -0
  82. package/dist/proxies/budget.d.ts +57 -0
  83. package/dist/proxies/camera.d.ts +104 -0
  84. package/dist/proxies/formats.d.ts +36 -0
  85. package/dist/proxies/index.d.ts +18 -0
  86. package/dist/proxies/jobs.d.ts +98 -0
  87. package/dist/proxies/node.d.ts +32 -0
  88. package/dist/proxies/plan.d.ts +89 -0
  89. package/dist/proxies/probe.d.ts +39 -0
  90. package/dist/proxies/render.d.ts +104 -0
  91. package/dist/proxies/safety.d.ts +45 -0
  92. package/dist/proxies/types.d.ts +83 -0
  93. package/dist/proxies/upload.d.ts +14 -0
  94. package/dist/react/BigPlay.d.ts +26 -0
  95. package/dist/react/Player.d.ts +58 -0
  96. package/dist/react/embed/index.d.ts +45 -0
  97. package/dist/react/examples/CustomControls.d.ts +8 -0
  98. package/dist/react/images/Image.d.ts +16 -0
  99. package/dist/react/images/index.d.ts +4 -0
  100. package/dist/react/images/useImage.d.ts +47 -0
  101. package/dist/react/index.d.ts +17 -0
  102. package/dist/react/storyboard/index.d.ts +58 -0
  103. package/dist/react/theme.d.ts +37 -0
  104. package/dist/react/useAdapterErrors.d.ts +8 -0
  105. package/dist/react/usePlaybackStart.d.ts +18 -0
  106. package/dist/react/usePlayer.d.ts +28 -0
  107. package/dist/react/useReducedMotion.d.ts +2 -0
  108. package/dist/react/useTimedTrack.d.ts +22 -0
  109. package/dist/react.js +1 -0
  110. package/dist/react.mjs +1 -0
  111. package/dist/server/auth/apiKeys.d.ts +30 -0
  112. package/dist/server/auth/cache.d.ts +21 -0
  113. package/dist/server/auth/deviceTokens.d.ts +38 -0
  114. package/dist/server/auth/envelope.d.ts +15 -0
  115. package/dist/server/auth/grants.d.ts +76 -0
  116. package/dist/server/auth/index.d.ts +19 -0
  117. package/dist/server/auth/jwt.d.ts +65 -0
  118. package/dist/server/auth/keyring.d.ts +31 -0
  119. package/dist/server/auth/kv.d.ts +12 -0
  120. package/dist/server/auth/repository.d.ts +45 -0
  121. package/dist/server/auth/revocations.d.ts +21 -0
  122. package/dist/server/auth/scope.d.ts +4 -0
  123. package/dist/server/auth/serviceAuth.d.ts +24 -0
  124. package/dist/server/auth/signedUrls.d.ts +28 -0
  125. package/dist/server/embed/index.d.ts +36 -0
  126. package/dist/server/embed/lifecycle.d.ts +53 -0
  127. package/dist/server/embed/playerScript.d.ts +4 -0
  128. package/dist/server/images/index.d.ts +15 -0
  129. package/dist/server/images/job.d.ts +80 -0
  130. package/dist/server/images/layout.d.ts +24 -0
  131. package/dist/server/images/params.d.ts +90 -0
  132. package/dist/server/images/route.d.ts +101 -0
  133. package/dist/server/images/sign.d.ts +55 -0
  134. package/dist/server/index.d.ts +42 -0
  135. package/dist/server/media/client.d.ts +66 -0
  136. package/dist/server/media/frameCheck.d.ts +62 -0
  137. package/dist/server/media/index.d.ts +10 -0
  138. package/dist/server/media/protocol.d.ts +318 -0
  139. package/dist/server/media/storyboard.d.ts +144 -0
  140. package/dist/server/media/transcript.d.ts +143 -0
  141. package/dist/server/pipeline/index.d.ts +12 -0
  142. package/dist/server/pipeline/match.d.ts +10 -0
  143. package/dist/server/pipeline/pipeline.d.ts +182 -0
  144. package/dist/server/pipeline/queues.d.ts +108 -0
  145. package/dist/server/pipeline/sources.d.ts +54 -0
  146. package/dist/server/r2/client.d.ts +150 -0
  147. package/dist/server/r2/crc32.d.ts +24 -0
  148. package/dist/server/r2/encoding.d.ts +35 -0
  149. package/dist/server/r2/errors.d.ts +9 -0
  150. package/dist/server/r2/integrity.d.ts +25 -0
  151. package/dist/server/r2/parts.d.ts +46 -0
  152. package/dist/server/r2/sign.d.ts +47 -0
  153. package/dist/server/redis/index.d.ts +39 -0
  154. package/dist/server/state/memory.d.ts +18 -0
  155. package/dist/server/state/r2.d.ts +73 -0
  156. package/dist/server/state/types.d.ts +57 -0
  157. package/dist/server/storage/chunked.d.ts +21 -0
  158. package/dist/server/storage/index.d.ts +12 -0
  159. package/dist/server/storage/r2.d.ts +96 -0
  160. package/dist/server/storage/s3.d.ts +93 -0
  161. package/dist/server/testing/fake-r2.d.ts +390 -0
  162. package/dist/server/testing/index.d.ts +10 -0
  163. package/dist/server/testing/kv-contract.d.ts +14 -0
  164. package/dist/server/transfer/handler.d.ts +167 -0
  165. package/dist/server/transfer/keys.d.ts +45 -0
  166. package/dist/server/transfer/protocol.d.ts +141 -0
  167. package/dist/server/zip/client.d.ts +32 -0
  168. package/dist/server/zip/generations.d.ts +83 -0
  169. package/dist/server/zip/index.d.ts +12 -0
  170. package/dist/server/zip/planner.d.ts +94 -0
  171. package/dist/server/zip/sign.d.ts +22 -0
  172. package/dist/server-media.js +1 -0
  173. package/dist/server-media.mjs +1 -0
  174. package/dist/server-redis.js +1 -0
  175. package/dist/server-redis.mjs +1 -0
  176. package/dist/server-testing.js +1 -0
  177. package/dist/server-testing.mjs +1 -0
  178. package/dist/server.js +1 -0
  179. package/dist/server.mjs +1 -0
  180. package/dist/storage/browserFile.d.ts +19 -0
  181. package/dist/storage/index.d.ts +12 -0
  182. package/dist/storage/local.d.ts +9 -0
  183. package/dist/storage/presigned.d.ts +22 -0
  184. package/dist/sync/ffmpeg.d.ts +44 -0
  185. package/dist/sync/index.d.ts +17 -0
  186. package/dist/sync/match.d.ts +28 -0
  187. package/dist/sync/probe.d.ts +30 -0
  188. package/dist/sync/timecode.d.ts +50 -0
  189. package/dist/sync/transcript.d.ts +35 -0
  190. package/dist/sync/types.d.ts +172 -0
  191. package/dist/sync/waveform.d.ts +89 -0
  192. package/dist/sync.js +1 -0
  193. package/dist/sync.mjs +1 -0
  194. package/dist/transfer/claims.d.ts +41 -0
  195. package/dist/transfer/client.d.ts +256 -0
  196. package/dist/transfer/download.d.ts +192 -0
  197. package/dist/transfer/engine.d.ts +382 -0
  198. package/dist/transfer/errors.d.ts +50 -0
  199. package/dist/transfer/index.d.ts +39 -0
  200. package/dist/transfer/integrity.d.ts +93 -0
  201. package/dist/transfer/limits.d.ts +34 -0
  202. package/dist/transfer/node.d.ts +63 -0
  203. package/dist/transfer/pool.d.ts +83 -0
  204. package/dist/transfer/protocol.d.ts +167 -0
  205. package/dist/transfer/signer.d.ts +29 -0
  206. package/dist/transfer/storage.d.ts +110 -0
  207. package/dist/transfer/timing.d.ts +132 -0
  208. package/dist/transfer/transports/electronNet.d.ts +62 -0
  209. package/dist/transfer/transports/fetch.d.ts +15 -0
  210. package/dist/transfer/transports/retryAfter.d.ts +12 -0
  211. package/dist/transfer/transports/undici.d.ts +72 -0
  212. package/dist/transfer/tuner.d.ts +56 -0
  213. package/dist/zip/index.d.ts +13 -0
  214. package/dist/zip/layout.d.ts +129 -0
  215. package/dist/zip/names.d.ts +34 -0
  216. package/dist/zip/plan.d.ts +115 -0
  217. package/dist/zip/sw.d.ts +7 -0
  218. package/package.json +265 -4
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `<Image>`: the default render of {@link useImage}. A `<picture>` with one `<source>` per modern format (AVIF, WebP)
3
+ * and an `<img>` fallback; srcset + sizes, intrinsic width/height (no layout shift), lazy by default, and the
4
+ * placeholder (dominant colour + blurred LQIP) until it has loaded. Drop it and use the hook for any other markup.
5
+ */
6
+ import { type ImgHTMLAttributes } from "react";
7
+ import type { ImageManifest, ImageSource } from "../../images/types";
8
+ import { type UseImageOptions } from "./useImage";
9
+ type Native = Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "srcSet" | "sizes" | "width" | "height" | "loading" | "placeholder">;
10
+ export interface ImageProps extends Native, UseImageOptions {
11
+ source: ImageSource | ImageManifest;
12
+ /** Required: describe the image, or "" for decoration. */
13
+ alt: string;
14
+ }
15
+ export declare const Image: import("react").ForwardRefExoticComponent<ImageProps & import("react").RefAttributes<HTMLImageElement>>;
16
+ export {};
@@ -0,0 +1,4 @@
1
+ export { Image } from "./Image";
2
+ export type { ImageProps } from "./Image";
3
+ export { useImage } from "./useImage";
4
+ export type { UseImageOptions, UseImageResult } from "./useImage";
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Headless image hook: from a manifest (variants made at upload) or an ImageSource (signed on-the-fly URLs) to
3
+ * everything a `<picture>` needs — per-format `<source>` props, the `<img>` props (src, srcset, sizes, intrinsic size,
4
+ * lazy loading) and the placeholder (dominant colour + blurred LQIP) until the image has loaded.
5
+ *
6
+ * const img = useImage(manifest, { base: "https://img.example.com", sizes: "(min-width: 800px) 50vw, 100vw" });
7
+ * <picture>{img.sources.map((s) => <source key={s.type} {...s} />)}<img {...img.imgProps} alt="" /></picture>
8
+ */
9
+ import { type CSSProperties, type RefCallback } from "react";
10
+ import type { ImageManifest, ImageSource } from "../../images/types";
11
+ import { type ImageUrlOptions } from "../../images/url";
12
+ export interface UseImageOptions extends ImageUrlOptions {
13
+ /** The `sizes` attribute: how wide the image is shown (default "100vw"). */
14
+ sizes?: string;
15
+ /** "lqip" (colour + blur, default), "colour" (dominant colour only) or "none". */
16
+ placeholder?: "lqip" | "colour" | "none";
17
+ /** Above the fold: eager loading and fetchpriority=high instead of lazy. */
18
+ priority?: boolean;
19
+ /** Width picked for the `<img src>` fallback (browsers without srcset). Default 1280. */
20
+ fallbackWidth?: number;
21
+ }
22
+ export interface UseImageResult {
23
+ sources: {
24
+ type: string;
25
+ srcSet: string;
26
+ sizes: string;
27
+ }[];
28
+ imgProps: {
29
+ src: string;
30
+ srcSet?: string;
31
+ sizes?: string;
32
+ width: number;
33
+ height: number;
34
+ loading: "lazy" | "eager";
35
+ decoding: "async";
36
+ fetchPriority?: "high";
37
+ style: CSSProperties;
38
+ onLoad: () => void;
39
+ ref: RefCallback<HTMLImageElement>;
40
+ };
41
+ /** True once the browser has the image (the placeholder is gone). */
42
+ loaded: boolean;
43
+ /** The placeholder style on its own (for a custom wrapper). */
44
+ placeholder: CSSProperties;
45
+ aspectRatio: number;
46
+ }
47
+ export declare function useImage(src: ImageSource | ImageManifest, o?: UseImageOptions): UseImageResult;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `@uploadfilm/sdk/react`: hooks first, optional default components (each one a thin render of a public hook). RFC §2.3.
3
+ * React is an optional peer dependency; Video.js is injected into the default skin (no hard import), and this entry
4
+ * ships no CSS files (the skin's stylesheet is Video.js's own; small rules are inlined as <style> strings).
5
+ */
6
+ export declare const SDK_ENTRY: "react";
7
+ export { usePlayer, usePlayerState, type PlayerCallbacks, type UsePlayerOptions } from "./usePlayer";
8
+ export { useTimedTrack, useCaptions } from "./useTimedTrack";
9
+ export { useAdapterErrors } from "./useAdapterErrors";
10
+ export { usePlaybackStart, bothRefs } from "./usePlaybackStart";
11
+ export { useReducedMotion } from "./useReducedMotion";
12
+ export { useBigPlay, BigPlayButton } from "./BigPlay";
13
+ export { Player, type PlayerProps, type VideoJsComponents } from "./Player";
14
+ export { TimelinePreview, formatPreviewTime, useThumbnailsTrack, useTimelinePreview, type TimelinePreviewProps, type TimelinePreviewState, type UseTimelinePreviewOptions, } from "./storyboard";
15
+ export { DEFAULT_THEME, skinStyle, SPINNER_CSS, HIDE_BAR_CSS, BIG_PLAY_CSS, type PlayerTheme } from "./theme";
16
+ export { EmbedFrame, useEmbedController, type EmbedFrameProps, type UseEmbedControllerOptions, } from "./embed";
17
+ export * from "./images";
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Timeline hover previews for React, headless first:
3
+ *
4
+ * useTimelinePreview(source, time) the thumbnail for `time` (null: nothing to show), and style objects to draw it;
5
+ * for fully custom preview cards
6
+ * <TimelinePreview> an optional default card made with the hook (thumbnail + time)
7
+ *
8
+ * `source` is what @uploadfilm/sdk/player's createTimelinePreviews takes: the storyboard's VTT URL, or a descriptor
9
+ * (`storyboardDescriptor(base, index)` from @uploadfilm/sdk/server/media) with its layout. One loader per source,
10
+ * shared by every hook given an equal source; sheets load when first needed, their neighbours just after.
11
+ */
12
+ import { type CSSProperties, type ReactNode } from "react";
13
+ import { type StoryboardSource, type TimelinePreview as Preview, type TimelinePreviews, type TimelinePreviewsOptions } from "@uploadfilm/sdk/player";
14
+ export interface UseTimelinePreviewOptions extends TimelinePreviewsOptions {
15
+ /** Draw the thumbnail this many pixels wide (default: its own size, ~160). */
16
+ width?: number;
17
+ }
18
+ export interface TimelinePreviewState {
19
+ /** The thumbnail for the time asked (null: no time, track not read yet, or none). */
20
+ preview: Preview | null;
21
+ /** Style objects for the thumbnail at `width`: a clipping box and the sprite inside it. */
22
+ style: {
23
+ outer: CSSProperties;
24
+ inner: CSSProperties;
25
+ } | null;
26
+ ready: boolean;
27
+ error: Error | null;
28
+ /** The loader itself (getPreviewAt for any other time, cues). */
29
+ previews: TimelinePreviews | null;
30
+ }
31
+ /**
32
+ * The thumbnail for `time` (seconds; null or undefined while the pointer isn't over the timeline). Re-renders when the
33
+ * track is read and when the sheet it needs has loaded.
34
+ */
35
+ export declare function useTimelinePreview(source: StoryboardSource | null | undefined, time: number | null | undefined, options?: UseTimelinePreviewOptions): TimelinePreviewState;
36
+ /**
37
+ * A thumbnails track for a skin that draws previews itself from a <track kind="metadata" label="thumbnails"> (Video.js):
38
+ * the storyboard read by the SDK's loader (http(s) sheets only, malformed cues dropped) and handed over as a blob: URL
39
+ * with absolute sheet URLs, so the skin finds the sheets whatever it resolves cue URLs against. null until it is read,
40
+ * or when it can't be. A new source gives a new URL (key the <track> by it); the old one is revoked.
41
+ */
42
+ export declare function useThumbnailsTrack(source: StoryboardSource | null | undefined, options?: TimelinePreviewsOptions): string | null;
43
+ /** mm:ss, or h:mm:ss from an hour. */
44
+ export declare function formatPreviewTime(t: number): string;
45
+ export interface TimelinePreviewProps extends UseTimelinePreviewOptions {
46
+ source: StoryboardSource | null | undefined;
47
+ /** Seconds; null hides the card. */
48
+ time: number | null | undefined;
49
+ /** Under the thumbnail (default: the time, formatted). Pass null for none. */
50
+ label?: ReactNode;
51
+ className?: string;
52
+ style?: CSSProperties;
53
+ }
54
+ /**
55
+ * A default preview card: the thumbnail (a dark placeholder while its sheet loads) and the time under it. Position it
56
+ * yourself over your timeline (it renders in place); for anything else, use useTimelinePreview.
57
+ */
58
+ export declare function TimelinePreview({ source, time, label, className, style, ...options }: TimelinePreviewProps): import("react").JSX.Element | null;
@@ -0,0 +1,37 @@
1
+ import type { CSSProperties } from "react";
2
+ /**
3
+ * The default skin's look: Video.js 10's skin custom properties (its guides/customize-skins.md). Import the skin's
4
+ * stylesheet yourself (`import "@videojs/react/video/skin.css"`): this package ships no CSS files.
5
+ */
6
+ export interface PlayerTheme {
7
+ /** Progress, volume and focus colour. Default white. */
8
+ accentColor?: string;
9
+ /** Text on the accent colour. Default black. */
10
+ accentTextColor?: string;
11
+ fontFamily?: string;
12
+ borderRadius?: string;
13
+ /** How the picture fills the frame. Default "contain" (letterboxed at any aspect). */
14
+ objectFit?: "contain" | "cover" | "fill";
15
+ objectPosition?: string;
16
+ }
17
+ export declare const DEFAULT_THEME: Required<PlayerTheme>;
18
+ /** The skin's style: fills its box (position it yourself), with the theme's custom properties. */
19
+ export declare function skinStyle(theme?: PlayerTheme): CSSProperties;
20
+ /**
21
+ * The buffering spinner on its own, without the skin's frosted, dimmed layer over the whole frame (over a black frame,
22
+ * or a picture, it read as broken). No poster is held while loading: often another frame than the first, the picture
23
+ * appearing after it read as a jump back.
24
+ */
25
+ export declare const SPINNER_CSS = ".media-buffering-indicator::before{display:none!important}";
26
+ /**
27
+ * `uf-hide-bar` on the skin: the controls and their gradient go (hotkeys and click-to-play stay). `uf-big-play`: the
28
+ * skin's own title goes while the big play button shows its own.
29
+ */
30
+ export declare const HIDE_BAR_CSS = ".uf-hide-bar .video-controls,.uf-hide-bar .video-controls-backdrop,.uf-big-play .media-title{display:none!important}";
31
+ /**
32
+ * The big play button: the same frosted glass as the skin's control bar (its blur, saturation, inset highlight and
33
+ * shadow), sized from the frame. Only the button takes clicks. `data-gone` (pressed, or playing) fades it out in 120 ms
34
+ * and stops it taking clicks; coming back (play() refused) is immediate. Plain size and colour fallbacks come first
35
+ * for browsers without cqmin / oklch. Layout rules included (UploadFilm's used Tailwind classes for those).
36
+ */
37
+ export declare const BIG_PLAY_CSS = "\n.uf-bp{container-type:size;position:absolute;inset:0;z-index:10;display:flex;align-items:center;justify-content:center;pointer-events:none;\nbackground-image:linear-gradient(to top,rgb(0 0 0/.5),transparent,rgb(0 0 0/.4))}\n.uf-bp-title{position:absolute;top:0;left:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:12px 16px;text-align:left;font-size:15px;font-weight:500;color:#fff;filter:drop-shadow(0 1px 2px rgb(0 0 0/.1)) drop-shadow(0 1px 1px rgb(0 0 0/.06))}\n.uf-bp-btn{width:64px;height:64px;width:clamp(52px,20cqmin,84px);height:clamp(52px,20cqmin,84px);border-radius:9999px;border:0;padding:0;cursor:pointer;color:#fff;pointer-events:auto;\ndisplay:flex;align-items:center;justify-content:center;\nbackground:rgba(0,0,0,.35);background:linear-gradient(135deg,oklch(100% 0 0/.28),oklch(100% 0 0/.08) 55%,oklch(0% 0 0/.22)),oklch(0% 0 0/.35);\n-webkit-backdrop-filter:blur(16px) saturate(150%);backdrop-filter:blur(16px) saturate(150%);\nbox-shadow:inset 1.5px 1.5px 0 0 rgba(255,255,255,.55),inset 0 0 0 1px rgba(255,255,255,.18),0 8px 28px -4px rgba(0,0,0,.45);\nbox-shadow:inset 1.5px 1.5px 0 0 oklch(100% 0 0/.55),inset 0 0 0 1px oklch(100% 0 0/.18),inset -1px -1px 0 0 oklch(100% 0 0/.08),0 8px 28px -4px oklch(0% 0 0/.45),0 1px 3px 0 oklch(0% 0 0/.3);\ntransition:transform .18s cubic-bezier(.2,.8,.2,1),background-color .15s,opacity .12s linear,visibility 0s linear .12s;-webkit-tap-highlight-color:transparent}\n.uf-bp-btn:hover{transform:scale(1.07)}\n.uf-bp-btn:active{transform:scale(.94);transition-duration:.08s}\n.uf-bp-btn:focus-visible{outline:2px solid #fff;outline-offset:3px}\n.uf-bp-btn svg{width:38%;height:38%;margin-left:5%;fill:currentColor;filter:drop-shadow(0 1px 2px oklch(0% 0 0/.35));stroke:currentColor;stroke-width:2.5;stroke-linejoin:round}\n.uf-bp{transition:opacity .12s linear,visibility 0s}\n.uf-bp[data-gone]{opacity:0;visibility:hidden;pointer-events:none;transition:opacity .12s linear,visibility 0s linear .12s}\n.uf-bp[data-gone] .uf-bp-btn{pointer-events:none}\n.uf-bp[data-gone] .uf-bp-btn{transform:scale(.9)}\n@media (prefers-reduced-motion:reduce){.uf-bp,.uf-bp-btn{transition:none!important}.uf-bp-btn:hover,.uf-bp-btn:active,.uf-bp[data-gone] .uf-bp-btn{transform:none}}\n@media (forced-colors:active){.uf-bp-btn{background:Canvas;color:CanvasText;border:1px solid CanvasText;-webkit-backdrop-filter:none;backdrop-filter:none}}\n";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Video.js's HLS adapter (HlsJsVideo) reports hls.js's fatal errors on itself, not on the <video>: a `onError` on the
3
+ * element never hears that a stream failed, and the player sat on a spinner instead of recovering or falling back to
4
+ * the MP4 (found in production on 2026-11-06). This returns a `mediaRef` callback that subscribes to the adapter's
5
+ * "error" and calls `onError` (always the latest one). Moved from UploadFilm's web/app/useAdapterErrors.ts.
6
+ * (usePlayer does this through player.bindAdapter; this hook is for players wired by hand.)
7
+ */
8
+ export declare function useAdapterErrors(onError: () => void): (adapter: EventTarget | null) => void;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * How a player wired by hand starts (UploadFilm's share and embed players use it; usePlayer does the same inside):
3
+ *
4
+ * - `engine`: hls.js settings with this browser's start estimate (startEstimate), read when the player opens: a link
5
+ * measured fast starts at 1080p, a weak one at 360p, a new browser at 720p. Video.js: `source={{ ..., engine }}`.
6
+ * - `mediaRef` / `onTimeUpdate`: the bandwidth memory (BandwidthMemory).
7
+ *
8
+ * Moved from UploadFilm's web/app/usePlaybackStart.ts.
9
+ */
10
+ export declare function usePlaybackStart(): {
11
+ engine: {
12
+ hlsJs: never;
13
+ };
14
+ mediaRef: (a: unknown) => void;
15
+ onTimeUpdate: (t: number) => void;
16
+ };
17
+ /** Two ref callbacks as one (the adapter's errors and the bandwidth memory both want the HLS adapter). */
18
+ export declare function bothRefs<T>(a: (x: T | null) => void, b: (x: T | null) => void): (x: T | null) => void;
@@ -0,0 +1,28 @@
1
+ import { type Player, type PlayerEvents, type PlayerOptions, type PlayerState } from "@uploadfilm/sdk/player";
2
+ /** Callbacks for the engine's events, always the latest ones (no need to memoise them). */
3
+ export type PlayerCallbacks = {
4
+ onReady?: () => void;
5
+ onStall?: () => void;
6
+ onCantPlay?: () => void;
7
+ onFailed?: () => void;
8
+ /** Every engine event, for analytics or an embed control API. */
9
+ onEvent?: <K extends keyof PlayerEvents>(event: K, payload: PlayerEvents[K]) => void;
10
+ };
11
+ export type UsePlayerOptions = PlayerOptions & PlayerCallbacks;
12
+ /**
13
+ * The headless player for React: creates the engine once per mount (options are read then; `sources` and `tracks`
14
+ * follow later renders), decides HLS or MP4 in a layout effect (inside the click that opened it: Safari counts it as
15
+ * permission to play with sound), and destroys it on unmount. Render your own markup from `state` and wire:
16
+ *
17
+ * - `videoRef` on the <video> (or on Video.js's <Video>/<HlsJsVideo> with `loader: "external"`),
18
+ * - `adapterRef` on Video.js's <HlsJsVideo mediaRef> (its hls.js errors and the bandwidth memory).
19
+ */
20
+ export declare function usePlayer(options: UsePlayerOptions): {
21
+ player: Player;
22
+ state: PlayerState;
23
+ videoRef: (v: HTMLVideoElement | null) => void;
24
+ adapterRef: (a: unknown) => void;
25
+ };
26
+ /** The player's state (or a slice of it: re-renders only when the slice changes). */
27
+ export declare function usePlayerState(player: Player): PlayerState;
28
+ export declare function usePlayerState<T>(player: Player, select: (s: PlayerState) => T): T;
@@ -0,0 +1,2 @@
1
+ /** The viewer's "reduce motion" preference, live (false on the server and until mounted). */
2
+ export declare function useReducedMotion(): boolean;
@@ -0,0 +1,22 @@
1
+ import { type Cue, type Player } from "@uploadfilm/sdk/player";
2
+ /**
3
+ * A timed track for custom controls: its cues sorted, the active ones, each cue's place on the timeline (0–1, for
4
+ * markers on a progress bar), and next/previous to jump between them.
5
+ */
6
+ export declare function useTimedTrack<D = unknown>(player: Player, id: string): {
7
+ track: import("@uploadfilm/sdk/player").TimedTrack<unknown> | undefined;
8
+ cues: Cue<D>[];
9
+ active: Cue<D>[];
10
+ markers: {
11
+ cue: Cue<D>;
12
+ at: number | null;
13
+ }[];
14
+ next: () => void;
15
+ previous: () => void;
16
+ };
17
+ /** The caption cues to draw for the selected caption track (inline cues; `src` tracks are drawn by the browser). */
18
+ export declare function useCaptions(player: Player): {
19
+ track: string | null;
20
+ cues: Cue<unknown>[];
21
+ select: (id: string | null) => void;
22
+ };
package/dist/react.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e=require("react"),t=require("@uploadfilm/sdk/player"),r=require("react/jsx-runtime");const n="undefined"==typeof window?e.useEffect:e.useLayoutEffect,o=["sourcechange","error","recover","fallback","offline","online","ready","stall","cantplay","failed","cuechange","loadedmetadata","play","playing","pause","ended","timeupdate","volumechange","seeked"];function s(r){const s=e.useRef(r);s.current=r;const[a,c]=e.useState(()=>t.createPlayer(r));e.useEffect(()=>(a.destroyed&&c(t.createPlayer(s.current)),()=>a.destroy()),[a]),n(()=>a.start(),[a]),e.useEffect(()=>{a.setSources(r.sources)},[a,r.sources.hls,r.sources.mp4,r.sources.original?.url,r.sources.original?.type]);const l=r.tracks?JSON.stringify(r.tracks):null,u=e.useRef(null);e.useEffect(()=>{const e=u.current;u.current={player:a,key:l},s.current.tracks&&(e?.player===a?e.key!==l:a.getState().tracks!==s.current.tracks)&&a.setTracks(s.current.tracks)},[a,l]),e.useEffect(()=>{const e=o.map(e=>a.on(e,t=>{const r=s.current;"ready"===e?r.onReady?.():"stall"===e?r.onStall?.():"cantplay"===e?r.onCantPlay?.():"failed"===e&&r.onFailed?.(),r.onEvent?.(e,t)}));return()=>e.forEach(e=>e())},[a]);const d=e.useRef(null),p=e.useCallback(e=>{d.current?.(),d.current=e?a.attach(e):null},[a]),f=e.useCallback(e=>a.bindAdapter(e??null),[a]),h=i(a);return{player:a,state:h,videoRef:p,adapterRef:f}}function i(t,r){const n=e.useRef(null),o=()=>{const e=t.getState();if(!r)return e;const o=r(e),s=n.current;return s&&function(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||!e||!t||Array.isArray(e)!==Array.isArray(t))return!1;const r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(r=>Object.is(e[r],t[r]))}(s.value,o)?s.value:(n.current={value:o},o)};return e.useSyncExternalStore(t.subscribe,o,o)}const a={accentColor:"#ffffff",accentTextColor:"#000000",fontFamily:"Inter, system-ui, sans-serif",borderRadius:"0",objectFit:"contain",objectPosition:"center"};function c(e={}){const t={...a,...e};return{position:"absolute",inset:0,width:"100%",height:"100%","--media-object-fit":t.objectFit,"--media-object-position":t.objectPosition,"--media-border-radius":t.borderRadius,"--media-accent-color":t.accentColor,"--media-accent-text-color":t.accentTextColor,"--media-font-family":t.fontFamily}}const l=".media-buffering-indicator::before{display:none!important}",u=".uf-hide-bar .video-controls,.uf-hide-bar .video-controls-backdrop,.uf-big-play .media-title{display:none!important}",d="\n.uf-bp{container-type:size;position:absolute;inset:0;z-index:10;display:flex;align-items:center;justify-content:center;pointer-events:none;\nbackground-image:linear-gradient(to top,rgb(0 0 0/.5),transparent,rgb(0 0 0/.4))}\n.uf-bp-title{position:absolute;top:0;left:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:12px 16px;text-align:left;font-size:15px;font-weight:500;color:#fff;filter:drop-shadow(0 1px 2px rgb(0 0 0/.1)) drop-shadow(0 1px 1px rgb(0 0 0/.06))}\n.uf-bp-btn{width:64px;height:64px;width:clamp(52px,20cqmin,84px);height:clamp(52px,20cqmin,84px);border-radius:9999px;border:0;padding:0;cursor:pointer;color:#fff;pointer-events:auto;\ndisplay:flex;align-items:center;justify-content:center;\nbackground:rgba(0,0,0,.35);background:linear-gradient(135deg,oklch(100% 0 0/.28),oklch(100% 0 0/.08) 55%,oklch(0% 0 0/.22)),oklch(0% 0 0/.35);\n-webkit-backdrop-filter:blur(16px) saturate(150%);backdrop-filter:blur(16px) saturate(150%);\nbox-shadow:inset 1.5px 1.5px 0 0 rgba(255,255,255,.55),inset 0 0 0 1px rgba(255,255,255,.18),0 8px 28px -4px rgba(0,0,0,.45);\nbox-shadow:inset 1.5px 1.5px 0 0 oklch(100% 0 0/.55),inset 0 0 0 1px oklch(100% 0 0/.18),inset -1px -1px 0 0 oklch(100% 0 0/.08),0 8px 28px -4px oklch(0% 0 0/.45),0 1px 3px 0 oklch(0% 0 0/.3);\ntransition:transform .18s cubic-bezier(.2,.8,.2,1),background-color .15s,opacity .12s linear,visibility 0s linear .12s;-webkit-tap-highlight-color:transparent}\n.uf-bp-btn:hover{transform:scale(1.07)}\n.uf-bp-btn:active{transform:scale(.94);transition-duration:.08s}\n.uf-bp-btn:focus-visible{outline:2px solid #fff;outline-offset:3px}\n.uf-bp-btn svg{width:38%;height:38%;margin-left:5%;fill:currentColor;filter:drop-shadow(0 1px 2px oklch(0% 0 0/.35));stroke:currentColor;stroke-width:2.5;stroke-linejoin:round}\n.uf-bp{transition:opacity .12s linear,visibility 0s}\n.uf-bp[data-gone]{opacity:0;visibility:hidden;pointer-events:none;transition:opacity .12s linear,visibility 0s linear .12s}\n.uf-bp[data-gone] .uf-bp-btn{pointer-events:none}\n.uf-bp[data-gone] .uf-bp-btn{transform:scale(.9)}\n@media (prefers-reduced-motion:reduce){.uf-bp,.uf-bp-btn{transition:none!important}.uf-bp-btn:hover,.uf-bp-btn:active,.uf-bp[data-gone] .uf-bp-btn{transform:none}}\n@media (forced-colors:active){.uf-bp-btn{background:Canvas;color:CanvasText;border:1px solid CanvasText;-webkit-backdrop-filter:none;backdrop-filter:none}}\n";function p(t,r={}){const[n,o]=e.useState(!1),[s,i]=e.useState(!1),a=e.useRef(null);e.useEffect(()=>{const e=[t.on("play",()=>{o(!0),i(!0)}),t.on("pause",()=>i(!1))];return()=>e.forEach(e=>e())},[t]);return{started:n,pressed:s,hidden:s,play:()=>{const e=r.focusTarget?.();e?e.focus({preventScroll:!0}):a.current?.blur(),i(!0);const n=t.element,o=()=>{i(!1),requestAnimationFrame(()=>{const t=document.activeElement;t&&t!==document.body&&t!==e||a.current?.focus({preventScroll:!0})})};if(!n)return o();n.play().catch(o)},reset:()=>{o(!1),i(!1)},buttonRef:a,setPressed:i}}function f({onPlay:e,hidden:t,title:n,buttonRef:o}){return r.jsxs("div",{"data-gone":t?"":void 0,"aria-hidden":t||void 0,className:"uf-bp",children:[r.jsx("style",{children:d}),n&&r.jsx("span",{className:"uf-bp-title",children:n}),r.jsx("button",{ref:o,type:"button",onClick:e,tabIndex:t?-1:void 0,"aria-label":n?`Play ${n}`:"Play",className:"uf-bp-btn",children:r.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":!0,children:r.jsx("path",{d:"M8 5.5v13l11-6.5z"})})})]})}const h=e=>null==e?"":"string"==typeof e?e:JSON.stringify(e);function b(r){const n=e.useRef(r);return n.current=r,e.useMemo(()=>({prefetch:r.prefetch,credentials:r.credentials,fetch:(e,t)=>(n.current.fetch??fetch)(e,t),loadImage:e=>(n.current.loadImage??t.defaultLoadImage)(e)}),[r.prefetch,r.credentials])}function m(r,n,o={}){const s=h(r),i=b(o),a=e.useMemo(()=>null==r?null:t.createTimelinePreviews(r,i),[s,i]),c=e.useMemo(()=>({subscribe:()=>()=>{},get:()=>null}),[]);e.useSyncExternalStore(a?a.store.subscribe:c.subscribe,a?a.store.getState:c.get,a?a.store.getState:c.get),e.useEffect(()=>{a&&a.load()},[a]);const l=a&&null!=n&&Number.isFinite(n)?a.getPreviewAt(n):null;return{preview:l,style:l?t.spriteStyle(l,o.width):null,ready:!!a?.ready,error:a?.error??null,previews:a}}function g(r,n={}){const o=h(r),s=b({prefetch:0,...n}),i=e.useMemo(()=>null==r?null:t.createTimelinePreviews(r,s),[o,s]),[a,c]=e.useState(null);return e.useEffect(()=>{if(c(null),!i)return;let e=null,r=!0;return i.load().then(()=>{const n=globalThis.URL;r&&i.ready&&i.cues().length&&"function"==typeof n.createObjectURL&&(e=n.createObjectURL(new Blob([t.thumbnailsVtt(i.cues())],{type:"text/vtt"})),c(e))}),()=>{r=!1,e&&URL.revokeObjectURL(e)}},[i]),a}function y(e){const t=Math.max(0,Math.floor(e)),r=Math.floor(t/3600),n=Math.floor(t/60)%60,o=String(t%60).padStart(2,"0");return r?`${r}:${String(n).padStart(2,"0")}:${o}`:`${n}:${o}`}function x({p:e,components:t,theme:n,poster:o,title:s,muted:i,loop:a,preload:d="auto",bigPlay:h,hideBar:b,mediaProps:m,className:y,style:x,children:v,storyboard:w}){const k=g(t?w:null),S=k?r.jsx("track",{kind:"metadata",label:"thumbnails",src:k,default:!0},k):null,{player:j,state:E,videoRef:R,adapterRef:C}=e,P=p(j,{focusTarget:()=>j.element?.closest(".media-container")??null}),T=!!h&&!P.started,L={...m,ref:R,src:E.src??void 0,autoPlay:E.autoPlay,playsInline:!0,preload:d,muted:i,loop:a},M=T?r.jsx(f,{onPlay:P.play,hidden:P.pressed,title:s,buttonRef:P.buttonRef}):null;if(!t)return r.jsxs("div",{className:y,style:{position:"relative",...x},"data-uf-player":"",children:[E.mode&&r.jsx("video",{...L,src:void 0,poster:o,controls:!b&&!T,style:{width:"100%",height:"100%",display:"block",background:"#000"}}),v,M]});const{VideoPlayer:z,VideoSkin:N,Video:$,HlsJsVideo:A}=t,I=[b&&"uf-hide-bar",T&&"uf-big-play"].filter(Boolean).join(" ")||void 0;return r.jsxs("div",{className:y,style:{position:"relative",...x},"data-uf-player":"",children:[r.jsx("style",{children:b||T?u+l:l}),r.jsx(z,{poster:o,title:s,children:r.jsxs(N,{style:c(n),className:I,children:[E.mode?"hls"===E.mode&&A?r.jsx(A,{...L,mediaRef:C,src:void 0,source:{src:E.src,type:"application/vnd.apple.mpegurl",engine:{hlsJs:j.hlsConfig}},children:S},"hls"):r.jsx($,{...L,children:S},"mp4"):null,v]})}),M]})}const v=["ready","play","pause","ended","timeupdate","volumechange"];const w=e.forwardRef(function({base:e,embedId:n,options:o=t.DEFAULT_EMBED_OPTIONS,size:s,title:i,paths:a=t.DEFAULT_EMBED_PATHS,loading:c="lazy",className:l,style:u},d){const{w:p,h:f}=t.aspectOf(s?.w,s?.h);return r.jsx("div",{className:l,style:{position:"relative",width:"100%",aspectRatio:`${p}/${f}`,...u},children:r.jsx("iframe",{ref:d,src:t.playerUrl(e,n,o,a),title:i,style:{position:"absolute",inset:0,width:"100%",height:"100%",border:0},allow:t.IFRAME_ALLOW,allowFullScreen:!0,loading:c,referrerPolicy:"strict-origin-when-cross-origin"})})}),k=Object.freeze({avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",svg:"image/svg+xml"}),S=["avif","webp","png","jpeg","gif"],j=new Set(["jpeg","png","gif"]);function E(e,t={}){if(e.url)return e.url;const r=t.base;if("function"==typeof r)return r(e.key);if("string"==typeof r)return`${r.replace(/\/+$/,"")}/${n=e.key,n.split("/").map(encodeURIComponent).join("/")}`;var n;throw new Error("imageUrl: no base URL for a stored rendition (pass { base })")}const R=e=>1===e.v&&"object"==typeof e.source;function C(e,t){return e.variants.filter(e=>e.format===t).sort((e,t)=>e.width-t.width)}function P(e){const t=new Set(e.variants.map(e=>e.format));return S.filter(e=>t.has(e))}function T(e){const t=P(e);return t.filter(e=>j.has(e)).pop()??t[t.length-1]}function L(e,t,r={}){return C(e,t).map(e=>`${E(e,r)} ${e.width}w`).join(", ")}function M(e,t={}){var r;if((e=R(r=e)?z(r):r).svg){return{sources:[],img:{src:E(e.svg,t),srcSet:"",width:e.width,height:e.height}}}const n=T(e);if(!n)throw new Error("pictureSources: the source has no renditions");const o=P(e).filter(e=>e!==n).map(r=>({type:k[r],srcSet:L(e,r,t)})),s=function(e,t){const r=t.format??T(e);if(!r)return;const n=Math.max(1,t.width)*Math.max(1,t.dpr??1),o=C(e,r);return o.find(e=>e.width>=n)??o[o.length-1]}(e,{width:t.fallbackWidth??1280,format:n});return{sources:o,img:{src:E(s,t),srcSet:L(e,n,t),width:e.width,height:e.height}}}function z(e){const t="svg"===e.source.kind&&0===e.variants.length?e.master:void 0;return{width:e.width,height:e.height,colourHex:e.colourHex,placeholder:e.placeholder,variants:e.variants,...t?{svg:t}:{}}}function N(t,r={}){const n=e.useMemo(()=>R(t)?z(t):t,[t]),{base:o,sizes:s="100vw",placeholder:i="lqip",priority:a=!1,fallbackWidth:c}=r,l=e.useMemo(()=>M(n,{base:o,fallbackWidth:c}),[n,o,c]),[u,d]=e.useState(!1),p=l.img.src,f=e.useRef(null),h=e=>!!e&&e.complete&&e.naturalWidth>0;e.useEffect(()=>d(h(f.current)),[p]);const b=e.useCallback(()=>d(!0),[]),m=e.useCallback(e=>{f.current=e,h(e)&&d(!0)},[]),g=e.useMemo(()=>{if("none"===i)return{};const e=function(e){const t={};e.colourHex&&/^#[0-9a-f]{6}$/i.test(e.colourHex)&&(t.backgroundColor=e.colourHex);const r=e.placeholder?.lqip;return r&&/^data:image\/(webp|jpeg|png);base64,[A-Za-z0-9+/=]+$/.test(r)&&(t.backgroundImage=`url("${r}")`,t.backgroundSize="cover",t.backgroundPosition="center"),t}(n);return"colour"===i?e.backgroundColor?{backgroundColor:e.backgroundColor}:{}:e},[n,i]),y={aspectRatio:`${l.img.width} / ${l.img.height}`,height:"auto",maxWidth:"100%",...u?{}:g};return{sources:l.sources.map(e=>({...e,sizes:s})),imgProps:{src:l.img.src,...l.img.srcSet?{srcSet:l.img.srcSet,sizes:s}:{},width:l.img.width,height:l.img.height,loading:a?"eager":"lazy",decoding:"async",...a?{fetchPriority:"high"}:{},style:y,onLoad:b,ref:m},loaded:u,placeholder:g,aspectRatio:l.img.height?l.img.width/l.img.height:1}}const $=e.forwardRef(function(t,n){const{source:o,base:s,sizes:i,placeholder:a,priority:c,fallbackWidth:l,alt:u,style:d,onLoad:p,...f}=t,h=N(o,{base:s,sizes:i,placeholder:a,priority:c,fallbackWidth:l}),{ref:b,onLoad:m,style:g,...y}=h.imgProps,x=e.useCallback(e=>{var t,r;b(e),r=e,"function"==typeof(t=n)?t(r):t&&(t.current=r)},[b,n]);return r.jsxs("picture",{children:[h.sources.map(e=>r.jsx("source",{type:e.type,srcSet:e.srcSet,sizes:e.sizes},e.type)),r.jsx("img",{...f,...y,alt:u,ref:x,style:{...g,...d},onLoad:e=>{m(),p?.(e)}})]})});exports.BIG_PLAY_CSS=d,exports.BigPlayButton=f,exports.DEFAULT_THEME=a,exports.EmbedFrame=w,exports.HIDE_BAR_CSS=u,exports.Image=$,exports.Player=function(e){const t=!!e.components&&!e.components.HlsJsVideo,n=s({...e,loader:e.components?"external":"engine",...t?{canPlayHls:()=>!1}:{}}),o=e.player??n;return r.jsx(x,{...e,p:o})},exports.SDK_ENTRY="react",exports.SPINNER_CSS=l,exports.TimelinePreview=function({source:e,time:t,label:n,className:o,style:s,...i}){const{preview:a,style:c}=m(e,t,i);return a&&c&&null!=t?r.jsxs("div",{className:o,"data-uf-timeline-preview":"","data-loaded":a.loaded?"":void 0,style:{display:"inline-flex",flexDirection:"column",alignItems:"center",gap:4,padding:2,borderRadius:6,background:"rgba(0,0,0,.8)",color:"#fff",font:"12px/1.2 system-ui, sans-serif",pointerEvents:"none",...s},children:[r.jsx("div",{style:{...c.outer,borderRadius:4,background:"#222"},children:a.loaded&&r.jsx("div",{style:c.inner})}),void 0===n?r.jsx("span",{children:y(t)}):n]}):null},exports.bothRefs=function(e,t){return r=>{e(r),t(r)}},exports.formatPreviewTime=y,exports.skinStyle=c,exports.useAdapterErrors=function(t){const r=e.useRef(t);e.useLayoutEffect(()=>{r.current=t});const n=e.useRef(null);return e.useCallback(e=>{if(n.current&&n.current.target.removeEventListener("error",n.current.listener),n.current=null,!e||"function"!=typeof e.addEventListener)return;const t=()=>r.current();e.addEventListener("error",t),n.current={target:e,listener:t}},[])},exports.useBigPlay=p,exports.useCaptions=function(e){const t=i(e,e=>e.textTrack),r=i(e,e=>t?e.activeCues[t]:void 0);return{track:t,cues:r??[],select:e.selectTextTrack}},exports.useEmbedController=function(r={}){const[n,o]=e.useState(null),[s,i]=e.useState(null),[a,c]=e.useState(!1),[l,u]=e.useState({currentTime:0,duration:0,paused:!0,muted:!0}),d=e.useRef(r.onEvent);d.current=r.onEvent;const p=e.useCallback(e=>o(e),[]);return e.useEffect(()=>{if(!n||!n.contentWindow)return;const e=new t.EmbedController(n),r=()=>{c(e.ready),u(e.state)};for(const t of v)e.on(t,e=>{r(),d.current?.(t,e)});const o=e=>{e.source===n.contentWindow&&r()};window.addEventListener("message",o),n.addEventListener("load",r);const s="function"==typeof MutationObserver?new MutationObserver(r):null;return s?.observe(n,{attributes:!0,attributeFilter:["src"]}),i(e),r(),()=>{window.removeEventListener("message",o),n.removeEventListener("load",r),s?.disconnect(),e.destroy(),i(null),c(!1)}},[n]),{ref:p,controller:s,ready:a,state:l}},exports.useImage=N,exports.usePlaybackStart=function(){const r=e.useMemo(()=>({hlsJs:t.hlsJsConfig()}),[]),n=e.useMemo(()=>new t.BandwidthMemory,[]);return{engine:r,mediaRef:e.useCallback(e=>n.attach(e),[n]),onTimeUpdate:e.useCallback(e=>n.time(e),[n])}},exports.usePlayer=s,exports.usePlayerState=i,exports.useReducedMotion=function(){const[t,r]=e.useState(!1);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");r(e.matches);const t=()=>r(e.matches);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),t},exports.useThumbnailsTrack=g,exports.useTimedTrack=function(r,n){const o=i(r,e=>e.tracks.find(e=>e.id===n)),s=i(r,e=>e.activeCues[n]),a=i(r,e=>e.duration),c=e.useMemo(()=>t.sortCues(o?.cues??[]),[o]),l=e.useMemo(()=>c.map(e=>({cue:e,at:t.cuePosition(e,a)})),[c,a]);return{track:o,cues:c,active:s??[],markers:l,next:()=>{const e=t.nextCue(c,r.getState().currentTime);e&&r.seek(e.start)},previous:()=>{const e=t.previousCue(c,r.getState().currentTime);r.seek(e?e.start:0)}}},exports.useTimelinePreview=m;
package/dist/react.mjs ADDED
@@ -0,0 +1 @@
1
+ import{useRef as e,useState as t,useEffect as n,useCallback as r,useSyncExternalStore as o,useLayoutEffect as i,useMemo as a,forwardRef as s}from"react";import{createPlayer as c,sortCues as l,cuePosition as u,previousCue as d,nextCue as p,hlsJsConfig as f,BandwidthMemory as h,createTimelinePreviews as b,thumbnailsVtt as g,spriteStyle as m,defaultLoadImage as y,aspectOf as v,IFRAME_ALLOW as w,playerUrl as k,DEFAULT_EMBED_OPTIONS as x,DEFAULT_EMBED_PATHS as S,EmbedController as j}from"@uploadfilm/sdk/player";import{jsxs as R,jsx as P}from"react/jsx-runtime";const C="undefined"==typeof window?n:i,L=["sourcechange","error","recover","fallback","offline","online","ready","stall","cantplay","failed","cuechange","loadedmetadata","play","playing","pause","ended","timeupdate","volumechange","seeked"];function z(o){const i=e(o);i.current=o;const[a,s]=t(()=>c(o));n(()=>(a.destroyed&&s(c(i.current)),()=>a.destroy()),[a]),C(()=>a.start(),[a]),n(()=>{a.setSources(o.sources)},[a,o.sources.hls,o.sources.mp4,o.sources.original?.url,o.sources.original?.type]);const l=o.tracks?JSON.stringify(o.tracks):null,u=e(null);n(()=>{const e=u.current;u.current={player:a,key:l},i.current.tracks&&(e?.player===a?e.key!==l:a.getState().tracks!==i.current.tracks)&&a.setTracks(i.current.tracks)},[a,l]),n(()=>{const e=L.map(e=>a.on(e,t=>{const n=i.current;"ready"===e?n.onReady?.():"stall"===e?n.onStall?.():"cantplay"===e?n.onCantPlay?.():"failed"===e&&n.onFailed?.(),n.onEvent?.(e,t)}));return()=>e.forEach(e=>e())},[a]);const d=e(null),p=r(e=>{d.current?.(),d.current=e?a.attach(e):null},[a]),f=r(e=>a.bindAdapter(e??null),[a]),h=E(a);return{player:a,state:h,videoRef:p,adapterRef:f}}function E(t,n){const r=e(null),i=()=>{const e=t.getState();if(!n)return e;const o=n(e),i=r.current;return i&&function(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||!e||!t||Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.is(e[n],t[n]))}(i.value,o)?i.value:(r.current={value:o},o)};return o(t.subscribe,i,i)}function $(e,t){const n=E(e,e=>e.tracks.find(e=>e.id===t)),r=E(e,e=>e.activeCues[t]),o=E(e,e=>e.duration),i=a(()=>l(n?.cues??[]),[n]),s=a(()=>i.map(e=>({cue:e,at:u(e,o)})),[i,o]);return{track:n,cues:i,active:r??[],markers:s,next:()=>{const t=p(i,e.getState().currentTime);t&&e.seek(t.start)},previous:()=>{const t=d(i,e.getState().currentTime);e.seek(t?t.start:0)}}}function T(e){const t=E(e,e=>e.textTrack),n=E(e,e=>t?e.activeCues[t]:void 0);return{track:t,cues:n??[],select:e.selectTextTrack}}function N(t){const n=e(t);i(()=>{n.current=t});const o=e(null);return r(e=>{if(o.current&&o.current.target.removeEventListener("error",o.current.listener),o.current=null,!e||"function"!=typeof e.addEventListener)return;const t=()=>n.current();e.addEventListener("error",t),o.current={target:e,listener:t}},[])}function O(){const e=a(()=>({hlsJs:f()}),[]),t=a(()=>new h,[]);return{engine:e,mediaRef:r(e=>t.attach(e),[t]),onTimeUpdate:r(e=>t.time(e),[t])}}function M(e,t){return n=>{e(n),t(n)}}function F(){const[e,r]=t(!1);return n(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");r(e.matches);const t=()=>r(e.matches);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),e}const I={accentColor:"#ffffff",accentTextColor:"#000000",fontFamily:"Inter, system-ui, sans-serif",borderRadius:"0",objectFit:"contain",objectPosition:"center"};function U(e={}){const t={...I,...e};return{position:"absolute",inset:0,width:"100%",height:"100%","--media-object-fit":t.objectFit,"--media-object-position":t.objectPosition,"--media-border-radius":t.borderRadius,"--media-accent-color":t.accentColor,"--media-accent-text-color":t.accentTextColor,"--media-font-family":t.fontFamily}}const W=".media-buffering-indicator::before{display:none!important}",A=".uf-hide-bar .video-controls,.uf-hide-bar .video-controls-backdrop,.uf-big-play .media-title{display:none!important}",H="\n.uf-bp{container-type:size;position:absolute;inset:0;z-index:10;display:flex;align-items:center;justify-content:center;pointer-events:none;\nbackground-image:linear-gradient(to top,rgb(0 0 0/.5),transparent,rgb(0 0 0/.4))}\n.uf-bp-title{position:absolute;top:0;left:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:12px 16px;text-align:left;font-size:15px;font-weight:500;color:#fff;filter:drop-shadow(0 1px 2px rgb(0 0 0/.1)) drop-shadow(0 1px 1px rgb(0 0 0/.06))}\n.uf-bp-btn{width:64px;height:64px;width:clamp(52px,20cqmin,84px);height:clamp(52px,20cqmin,84px);border-radius:9999px;border:0;padding:0;cursor:pointer;color:#fff;pointer-events:auto;\ndisplay:flex;align-items:center;justify-content:center;\nbackground:rgba(0,0,0,.35);background:linear-gradient(135deg,oklch(100% 0 0/.28),oklch(100% 0 0/.08) 55%,oklch(0% 0 0/.22)),oklch(0% 0 0/.35);\n-webkit-backdrop-filter:blur(16px) saturate(150%);backdrop-filter:blur(16px) saturate(150%);\nbox-shadow:inset 1.5px 1.5px 0 0 rgba(255,255,255,.55),inset 0 0 0 1px rgba(255,255,255,.18),0 8px 28px -4px rgba(0,0,0,.45);\nbox-shadow:inset 1.5px 1.5px 0 0 oklch(100% 0 0/.55),inset 0 0 0 1px oklch(100% 0 0/.18),inset -1px -1px 0 0 oklch(100% 0 0/.08),0 8px 28px -4px oklch(0% 0 0/.45),0 1px 3px 0 oklch(0% 0 0/.3);\ntransition:transform .18s cubic-bezier(.2,.8,.2,1),background-color .15s,opacity .12s linear,visibility 0s linear .12s;-webkit-tap-highlight-color:transparent}\n.uf-bp-btn:hover{transform:scale(1.07)}\n.uf-bp-btn:active{transform:scale(.94);transition-duration:.08s}\n.uf-bp-btn:focus-visible{outline:2px solid #fff;outline-offset:3px}\n.uf-bp-btn svg{width:38%;height:38%;margin-left:5%;fill:currentColor;filter:drop-shadow(0 1px 2px oklch(0% 0 0/.35));stroke:currentColor;stroke-width:2.5;stroke-linejoin:round}\n.uf-bp{transition:opacity .12s linear,visibility 0s}\n.uf-bp[data-gone]{opacity:0;visibility:hidden;pointer-events:none;transition:opacity .12s linear,visibility 0s linear .12s}\n.uf-bp[data-gone] .uf-bp-btn{pointer-events:none}\n.uf-bp[data-gone] .uf-bp-btn{transform:scale(.9)}\n@media (prefers-reduced-motion:reduce){.uf-bp,.uf-bp-btn{transition:none!important}.uf-bp-btn:hover,.uf-bp-btn:active,.uf-bp[data-gone] .uf-bp-btn{transform:none}}\n@media (forced-colors:active){.uf-bp-btn{background:Canvas;color:CanvasText;border:1px solid CanvasText;-webkit-backdrop-filter:none;backdrop-filter:none}}\n";function J(r,o={}){const[i,a]=t(!1),[s,c]=t(!1),l=e(null);n(()=>{const e=[r.on("play",()=>{a(!0),c(!0)}),r.on("pause",()=>c(!1))];return()=>e.forEach(e=>e())},[r]);return{started:i,pressed:s,hidden:s,play:()=>{const e=o.focusTarget?.();e?e.focus({preventScroll:!0}):l.current?.blur(),c(!0);const t=r.element,n=()=>{c(!1),requestAnimationFrame(()=>{const t=document.activeElement;t&&t!==document.body&&t!==e||l.current?.focus({preventScroll:!0})})};if(!t)return n();t.play().catch(n)},reset:()=>{a(!1),c(!1)},buttonRef:l,setPressed:c}}function q({onPlay:e,hidden:t,title:n,buttonRef:r}){return R("div",{"data-gone":t?"":void 0,"aria-hidden":t||void 0,className:"uf-bp",children:[P("style",{children:H}),n&&P("span",{className:"uf-bp-title",children:n}),P("button",{ref:r,type:"button",onClick:e,tabIndex:t?-1:void 0,"aria-label":n?`Play ${n}`:"Play",className:"uf-bp-btn",children:P("svg",{viewBox:"0 0 24 24","aria-hidden":!0,children:P("path",{d:"M8 5.5v13l11-6.5z"})})})]})}const V=e=>null==e?"":"string"==typeof e?e:JSON.stringify(e);function B(t){const n=e(t);return n.current=t,a(()=>({prefetch:t.prefetch,credentials:t.credentials,fetch:(e,t)=>(n.current.fetch??fetch)(e,t),loadImage:e=>(n.current.loadImage??y)(e)}),[t.prefetch,t.credentials])}function D(e,t,r={}){const i=V(e),s=B(r),c=a(()=>null==e?null:b(e,s),[i,s]),l=a(()=>({subscribe:()=>()=>{},get:()=>null}),[]);o(c?c.store.subscribe:l.subscribe,c?c.store.getState:l.get,c?c.store.getState:l.get),n(()=>{c&&c.load()},[c]);const u=c&&null!=t&&Number.isFinite(t)?c.getPreviewAt(t):null;return{preview:u,style:u?m(u,r.width):null,ready:!!c?.ready,error:c?.error??null,previews:c}}function Z(e,r={}){const o=V(e),i=B({prefetch:0,...r}),s=a(()=>null==e?null:b(e,i),[o,i]),[c,l]=t(null);return n(()=>{if(l(null),!s)return;let e=null,t=!0;return s.load().then(()=>{const n=globalThis.URL;t&&s.ready&&s.cues().length&&"function"==typeof n.createObjectURL&&(e=n.createObjectURL(new Blob([g(s.cues())],{type:"text/vtt"})),l(e))}),()=>{t=!1,e&&URL.revokeObjectURL(e)}},[s]),c}function G(e){const t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t/60)%60,o=String(t%60).padStart(2,"0");return n?`${n}:${String(r).padStart(2,"0")}:${o}`:`${r}:${o}`}function K({source:e,time:t,label:n,className:r,style:o,...i}){const{preview:a,style:s}=D(e,t,i);return a&&s&&null!=t?R("div",{className:r,"data-uf-timeline-preview":"","data-loaded":a.loaded?"":void 0,style:{display:"inline-flex",flexDirection:"column",alignItems:"center",gap:4,padding:2,borderRadius:6,background:"rgba(0,0,0,.8)",color:"#fff",font:"12px/1.2 system-ui, sans-serif",pointerEvents:"none",...o},children:[P("div",{style:{...s.outer,borderRadius:4,background:"#222"},children:a.loaded&&P("div",{style:s.inner})}),void 0===n?P("span",{children:G(t)}):n]}):null}function Q(e){const t=!!e.components&&!e.components.HlsJsVideo,n=z({...e,loader:e.components?"external":"engine",...t?{canPlayHls:()=>!1}:{}}),r=e.player??n;return P(X,{...e,p:r})}function X({p:e,components:t,theme:n,poster:r,title:o,muted:i,loop:a,preload:s="auto",bigPlay:c,hideBar:l,mediaProps:u,className:d,style:p,children:f,storyboard:h}){const b=Z(t?h:null),g=b?P("track",{kind:"metadata",label:"thumbnails",src:b,default:!0},b):null,{player:m,state:y,videoRef:v,adapterRef:w}=e,k=J(m,{focusTarget:()=>m.element?.closest(".media-container")??null}),x=!!c&&!k.started,S={...u,ref:v,src:y.src??void 0,autoPlay:y.autoPlay,playsInline:!0,preload:s,muted:i,loop:a},j=x?P(q,{onPlay:k.play,hidden:k.pressed,title:o,buttonRef:k.buttonRef}):null;if(!t)return R("div",{className:d,style:{position:"relative",...p},"data-uf-player":"",children:[y.mode&&P("video",{...S,src:void 0,poster:r,controls:!l&&!x,style:{width:"100%",height:"100%",display:"block",background:"#000"}}),f,j]});const{VideoPlayer:C,VideoSkin:L,Video:z,HlsJsVideo:E}=t,$=[l&&"uf-hide-bar",x&&"uf-big-play"].filter(Boolean).join(" ")||void 0;return R("div",{className:d,style:{position:"relative",...p},"data-uf-player":"",children:[P("style",{children:l||x?A+W:W}),P(C,{poster:r,title:o,children:R(L,{style:U(n),className:$,children:[y.mode?"hls"===y.mode&&E?P(E,{...S,mediaRef:w,src:void 0,source:{src:y.src,type:"application/vnd.apple.mpegurl",engine:{hlsJs:m.hlsConfig}},children:g},"hls"):P(z,{...S,children:g},"mp4"):null,f]})}),j]})}const Y=["ready","play","pause","ended","timeupdate","volumechange"];function _(o={}){const[i,a]=t(null),[s,c]=t(null),[l,u]=t(!1),[d,p]=t({currentTime:0,duration:0,paused:!0,muted:!0}),f=e(o.onEvent);f.current=o.onEvent;const h=r(e=>a(e),[]);return n(()=>{if(!i||!i.contentWindow)return;const e=new j(i),t=()=>{u(e.ready),p(e.state)};for(const n of Y)e.on(n,e=>{t(),f.current?.(n,e)});const n=e=>{e.source===i.contentWindow&&t()};window.addEventListener("message",n),i.addEventListener("load",t);const r="function"==typeof MutationObserver?new MutationObserver(t):null;return r?.observe(i,{attributes:!0,attributeFilter:["src"]}),c(e),t(),()=>{window.removeEventListener("message",n),i.removeEventListener("load",t),r?.disconnect(),e.destroy(),c(null),u(!1)}},[i]),{ref:h,controller:s,ready:l,state:d}}const ee=s(function({base:e,embedId:t,options:n=x,size:r,title:o,paths:i=S,loading:a="lazy",className:s,style:c},l){const{w:u,h:d}=v(r?.w,r?.h);return P("div",{className:s,style:{position:"relative",width:"100%",aspectRatio:`${u}/${d}`,...c},children:P("iframe",{ref:l,src:k(e,t,n,i),title:o,style:{position:"absolute",inset:0,width:"100%",height:"100%",border:0},allow:w,allowFullScreen:!0,loading:a,referrerPolicy:"strict-origin-when-cross-origin"})})}),te=Object.freeze({avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",svg:"image/svg+xml"}),ne=["avif","webp","png","jpeg","gif"],re=new Set(["jpeg","png","gif"]);function oe(e,t={}){if(e.url)return e.url;const n=t.base;if("function"==typeof n)return n(e.key);if("string"==typeof n)return`${n.replace(/\/+$/,"")}/${r=e.key,r.split("/").map(encodeURIComponent).join("/")}`;var r;throw new Error("imageUrl: no base URL for a stored rendition (pass { base })")}const ie=e=>1===e.v&&"object"==typeof e.source;function ae(e,t){return e.variants.filter(e=>e.format===t).sort((e,t)=>e.width-t.width)}function se(e){const t=new Set(e.variants.map(e=>e.format));return ne.filter(e=>t.has(e))}function ce(e){const t=se(e);return t.filter(e=>re.has(e)).pop()??t[t.length-1]}function le(e,t,n={}){return ae(e,t).map(e=>`${oe(e,n)} ${e.width}w`).join(", ")}function ue(e,t={}){var n;if((e=ie(n=e)?de(n):n).svg){return{sources:[],img:{src:oe(e.svg,t),srcSet:"",width:e.width,height:e.height}}}const r=ce(e);if(!r)throw new Error("pictureSources: the source has no renditions");const o=se(e).filter(e=>e!==r).map(n=>({type:te[n],srcSet:le(e,n,t)})),i=function(e,t){const n=t.format??ce(e);if(!n)return;const r=Math.max(1,t.width)*Math.max(1,t.dpr??1),o=ae(e,n);return o.find(e=>e.width>=r)??o[o.length-1]}(e,{width:t.fallbackWidth??1280,format:r});return{sources:o,img:{src:oe(i,t),srcSet:le(e,r,t),width:e.width,height:e.height}}}function de(e){const t="svg"===e.source.kind&&0===e.variants.length?e.master:void 0;return{width:e.width,height:e.height,colourHex:e.colourHex,placeholder:e.placeholder,variants:e.variants,...t?{svg:t}:{}}}function pe(o,i={}){const s=a(()=>ie(o)?de(o):o,[o]),{base:c,sizes:l="100vw",placeholder:u="lqip",priority:d=!1,fallbackWidth:p}=i,f=a(()=>ue(s,{base:c,fallbackWidth:p}),[s,c,p]),[h,b]=t(!1),g=f.img.src,m=e(null),y=e=>!!e&&e.complete&&e.naturalWidth>0;n(()=>b(y(m.current)),[g]);const v=r(()=>b(!0),[]),w=r(e=>{m.current=e,y(e)&&b(!0)},[]),k=a(()=>{if("none"===u)return{};const e=function(e){const t={};e.colourHex&&/^#[0-9a-f]{6}$/i.test(e.colourHex)&&(t.backgroundColor=e.colourHex);const n=e.placeholder?.lqip;return n&&/^data:image\/(webp|jpeg|png);base64,[A-Za-z0-9+/=]+$/.test(n)&&(t.backgroundImage=`url("${n}")`,t.backgroundSize="cover",t.backgroundPosition="center"),t}(s);return"colour"===u?e.backgroundColor?{backgroundColor:e.backgroundColor}:{}:e},[s,u]),x={aspectRatio:`${f.img.width} / ${f.img.height}`,height:"auto",maxWidth:"100%",...h?{}:k};return{sources:f.sources.map(e=>({...e,sizes:l})),imgProps:{src:f.img.src,...f.img.srcSet?{srcSet:f.img.srcSet,sizes:l}:{},width:f.img.width,height:f.img.height,loading:d?"eager":"lazy",decoding:"async",...d?{fetchPriority:"high"}:{},style:x,onLoad:v,ref:w},loaded:h,placeholder:k,aspectRatio:f.img.height?f.img.width/f.img.height:1}}const fe=s(function(e,t){const{source:n,base:o,sizes:i,placeholder:a,priority:s,fallbackWidth:c,alt:l,style:u,onLoad:d,...p}=e,f=pe(n,{base:o,sizes:i,placeholder:a,priority:s,fallbackWidth:c}),{ref:h,onLoad:b,style:g,...m}=f.imgProps,y=r(e=>{var n,r;h(e),r=e,"function"==typeof(n=t)?n(r):n&&(n.current=r)},[h,t]);return R("picture",{children:[f.sources.map(e=>P("source",{type:e.type,srcSet:e.srcSet,sizes:e.sizes},e.type)),P("img",{...p,...m,alt:l,ref:y,style:{...g,...u},onLoad:e=>{b(),d?.(e)}})]})}),he="react";export{H as BIG_PLAY_CSS,q as BigPlayButton,I as DEFAULT_THEME,ee as EmbedFrame,A as HIDE_BAR_CSS,fe as Image,Q as Player,he as SDK_ENTRY,W as SPINNER_CSS,K as TimelinePreview,M as bothRefs,G as formatPreviewTime,U as skinStyle,N as useAdapterErrors,J as useBigPlay,T as useCaptions,_ as useEmbedController,pe as useImage,O as usePlaybackStart,z as usePlayer,E as usePlayerState,F as useReducedMotion,Z as useThumbnailsTrack,$ as useTimedTrack,D as useTimelinePreview};
@@ -0,0 +1,30 @@
1
+ import type { ApiKeyRecord, ApiKeyRepository } from "./repository";
2
+ export interface GeneratedApiKey {
3
+ /** The key itself: shown to its owner once, never stored. */
4
+ raw: string;
5
+ /** SHA-256 (hex) of `raw`: what's stored and looked up. */
6
+ hash: string;
7
+ /** `raw`'s first prefix.length + shownChars characters, for lists. */
8
+ prefix: string;
9
+ last4: string;
10
+ }
11
+ export declare const API_KEY_PREFIX: RegExp;
12
+ export interface ApiKeyOptions {
13
+ /** Like "uf_live_": lowercase letters/digits in "_"-separated words, ending in "_". */
14
+ prefix: string;
15
+ /** Random bytes in the key. Default 24. What stays secret after the shown characters and last4 must be ≥ 128 bits. */
16
+ randomBytes?: number;
17
+ /** Characters after the prefix kept in the display prefix. Default 6. */
18
+ shownChars?: number;
19
+ }
20
+ export declare function hashApiKey(raw: string): Promise<string>;
21
+ export declare function generateApiKey(o: ApiKeyOptions): Promise<GeneratedApiKey>;
22
+ /** Is this string shaped like one of our keys (prefix, then base64url)? Says nothing about validity. */
23
+ export declare function looksLikeApiKey(raw: unknown, prefix: string): raw is string;
24
+ /** Constant-time: does `raw` hash to `hash` (hex)? */
25
+ export declare function apiKeyMatches(raw: string, hash: string): Promise<boolean>;
26
+ /**
27
+ * The active record a presented key belongs to, via the product's repository (which should also touch last-used),
28
+ * re-checked in constant time against the stored hash. Null for anything else.
29
+ */
30
+ export declare function authenticateApiKey(repo: ApiKeyRepository, raw: unknown, prefix: string): Promise<ApiKeyRecord | null>;
@@ -0,0 +1,21 @@
1
+ import { type KeyValueStore } from "./kv";
2
+ export interface CachedVerdict<C> {
3
+ kid: string;
4
+ claims: C;
5
+ }
6
+ export interface TokenCache<C extends {
7
+ exp: number;
8
+ }> {
9
+ /**
10
+ * `binding` names the exact key material that verified the token (verifyToken passes a fingerprint of the
11
+ * kid's subkey), so a verdict never carries over to another keyring, or to a kid whose secret was replaced.
12
+ */
13
+ remember(token: string, verdict: CachedVerdict<C>, ttlSeconds: number, binding: string): Promise<void>;
14
+ recall(token: string, binding: string): Promise<CachedVerdict<C> | null>;
15
+ }
16
+ export declare function tokenCache<C extends {
17
+ exp: number;
18
+ }>(kv: KeyValueStore, opts?: {
19
+ namespace?: string;
20
+ now?: () => number;
21
+ }): TokenCache<C>;
@@ -0,0 +1,38 @@
1
+ /** HMAC-SHA256 of a UTF-8 message under the product's device-token secret, returning the 32-byte MAC. */
2
+ export type SyncMac = (message: string) => Uint8Array;
3
+ export declare const DEVICE_ID: RegExp;
4
+ export type ParsedDeviceToken = {
5
+ kind: "v1";
6
+ deviceId: string;
7
+ gen: number;
8
+ message: string;
9
+ sig: string;
10
+ } | {
11
+ kind: "legacy";
12
+ deviceId: string;
13
+ gen: 1;
14
+ message: string;
15
+ sig: string;
16
+ };
17
+ export declare const deviceTokenMessage: (deviceId: string, gen: number) => string;
18
+ /** Mints `v1.<deviceId>.<gen>.<mac>` with a synchronous HMAC. */
19
+ export declare function mintDeviceToken(deviceId: string, gen: number, mac: SyncMac): string;
20
+ /** The same token over WebCrypto. */
21
+ export declare function mintDeviceTokenAsync(secret: string, deviceId: string, gen: number): Promise<string>;
22
+ /**
23
+ * The shape of a token, before any MAC check; null when it's neither form. Generations are canonical decimals ("1",
24
+ * never "01"), as minted.
25
+ */
26
+ export declare function parseDeviceToken(raw: unknown): ParsedDeviceToken | null;
27
+ /** The parsed token when its MAC is right (the generation is still the product's to check), else null. */
28
+ export declare function verifyDeviceTokenSync(raw: unknown, mac: SyncMac): ParsedDeviceToken | null;
29
+ export declare function verifyDeviceToken(secret: string, raw: unknown): Promise<ParsedDeviceToken | null>;
30
+ /**
31
+ * The bearer credential on a request: `Authorization: Bearer <token>` (any case, surrounding spaces trimmed), else
32
+ * the value of `fallbackHeader` when given (e.g. an API-key header), else null.
33
+ */
34
+ export declare function bearerFrom(req: {
35
+ headers: {
36
+ get(name: string): string | null;
37
+ };
38
+ }, fallbackHeader?: string): string | null;
@@ -0,0 +1,15 @@
1
+ import { type Keyring } from "./keyring";
2
+ export declare function sealBytes(key: Uint8Array | CryptoKey, plaintext: Uint8Array | string, aad?: Uint8Array | string): Promise<Uint8Array>;
3
+ /** The plaintext, or null when anything is off (version, length, key, AAD, a flipped bit). */
4
+ export declare function openBytes(key: Uint8Array | CryptoKey, sealed: Uint8Array, aad?: Uint8Array | string): Promise<Uint8Array | null>;
5
+ export interface EnvelopeOptions {
6
+ /** What the secret is for ("webhook-secret"); a value sealed for one purpose never opens as another. */
7
+ purpose: string;
8
+ /** Binds the value to its place (e.g. the row id). */
9
+ aad?: string;
10
+ }
11
+ export declare function sealEnvelope(keys: Keyring, plaintext: Uint8Array | string, o: EnvelopeOptions): Promise<string>;
12
+ export declare function openEnvelope(keys: Keyring, sealed: unknown, o: EnvelopeOptions): Promise<Uint8Array | null>;
13
+ export declare function openEnvelopeText(keys: Keyring, sealed: unknown, o: EnvelopeOptions): Promise<string | null>;
14
+ /** The same value with its data key re-wrapped under the keyring's current kid; null if it doesn't open. */
15
+ export declare function rewrapEnvelope(keys: Keyring, sealed: unknown, o: EnvelopeOptions): Promise<string | null>;
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Sealed grants, domain-separated HMAC and the byte helpers every other auth module builds on.
3
+ *
4
+ * SELF-CONTAINED ON PURPOSE: this file imports nothing and uses only erasable TypeScript, so plain Node (type
5
+ * stripping, no loader), workerd and a bundler can all load it directly by path. UploadFilm's shared/stream.ts will
6
+ * re-export it, and that file is loaded by `node --test` in worker/media and copied alone into the ffmpeg container.
7
+ * Keep it that way: no imports, no enums, no parameter properties, no namespaces.
8
+ *
9
+ * Plain WebCrypto, so it runs in Node ≥ 20, Cloudflare Workers and the browser alike.
10
+ *
11
+ * Byte-compatible with UploadFilm's shared/stream.ts (sealGrant/openGrant/hmacHex/sameHex/b64url/fromB64url): tokens
12
+ * and signatures made by either open/verify with the other (sdks/sdk/test/auth/grantsParity.test.ts pins this).
13
+ */
14
+ /** Shortest secret any helper here accepts (characters of the string, as UploadFilm has always checked). */
15
+ export declare const MIN_SECRET_LENGTH = 32;
16
+ /** base64url without padding. */
17
+ export declare function b64url(u: Uint8Array): string;
18
+ /**
19
+ * base64url (padding optional) → bytes; null when it isn't base64url. Lenient like atob: the unused low bits of the last
20
+ * character are ignored. Use {@link fromB64urlStrict} wherever two spellings of the same bytes must not both pass.
21
+ */
22
+ export declare function fromB64url(s: string): Uint8Array | null;
23
+ /** Only the one canonical spelling (no padding, unused bits zero): a token can't be re-spelled to dodge a cache or a revocation. */
24
+ export declare function fromB64urlStrict(s: string): Uint8Array | null;
25
+ export declare const utf8: (s: string) => Uint8Array<ArrayBuffer>;
26
+ export declare const fromUtf8: (u: Uint8Array) => string;
27
+ /** A copy backed by a plain ArrayBuffer (what WebCrypto's BufferSource wants). */
28
+ export declare function ownBytes(u: Uint8Array | string): Uint8Array<ArrayBuffer>;
29
+ export declare const toHex: (u: Uint8Array) => string;
30
+ export declare function randomBytes(n: number): Uint8Array<ArrayBuffer>;
31
+ /**
32
+ * Constant-time byte comparison: when the lengths match, every byte of both is read whatever differs. A length mismatch
33
+ * returns early (lengths of MACs and hashes are public).
34
+ */
35
+ export declare function timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean;
36
+ /** Constant-time comparison of two strings of equal length (hex signatures, hashes). */
37
+ export declare function sameHex(a: string, b: string): boolean;
38
+ export declare function sha256(data: Uint8Array | string): Promise<Uint8Array<ArrayBuffer>>;
39
+ export declare function sha256Hex(data: Uint8Array | string): Promise<string>;
40
+ /** HMAC-SHA256 of `message` with a raw key. */
41
+ export declare function hmacSha256(key: Uint8Array | string, message: Uint8Array | string): Promise<Uint8Array<ArrayBuffer>>;
42
+ /**
43
+ * HMAC-SHA256 (hex) of a request body under a domain (`<domain>\n<body>`), for service-to-service calls. The domain
44
+ * keeps one kind of signed message from ever passing as another (a job request vs. its completion report).
45
+ */
46
+ export declare function hmacHex(secret: string, domain: string, body: string): Promise<string>;
47
+ /** Checks a {@link hmacHex} signature in constant time. False on anything malformed. */
48
+ export declare function verifyHmacHex(secret: string, domain: string, body: string, sig: string): Promise<boolean>;
49
+ /**
50
+ * Read access to one prefix until `exp` (unix seconds). `copy`: an object whose existence the server re-checks before
51
+ * serving (turning a gated embed off deletes it, which ends the grant too).
52
+ */
53
+ export interface Grant {
54
+ prefix: string;
55
+ exp: number;
56
+ copy?: string;
57
+ }
58
+ export interface GrantSealerOptions {
59
+ /** HKDF salt naming the product's grant family (UploadFilm: "uploadfilm-stream"). */
60
+ salt: string;
61
+ /** The product's rule for a well-formed grant (key shapes). Required: there is no "anything goes" default. */
62
+ isValid: (g: Grant) => boolean;
63
+ /** Tolerated clock skew when checking `exp`, seconds. Default 0 (UploadFilm's behaviour). */
64
+ skewSeconds?: number;
65
+ }
66
+ export interface GrantSealer {
67
+ /** AES-GCM over the grant's JSON: 12-byte IV ‖ ciphertext ‖ 16-byte tag, base64url. Throws on a malformed grant. */
68
+ sealGrant(secret: string, g: Grant, purpose?: string): Promise<string>;
69
+ /** The grant inside a token if it opens with this secret and purpose, is well formed and hasn't expired; else null. */
70
+ openGrant(secret: string, token: string, now?: number, purpose?: string): Promise<Grant | null>;
71
+ }
72
+ /**
73
+ * Grants sealed with AES-256-GCM under a key derived (HKDF-SHA256) from the secret, the salt and a purpose. A token for
74
+ * one purpose never opens under another; tampering, truncation or another secret fails to open.
75
+ */
76
+ export declare function grantSealer(opts: GrantSealerOptions): GrantSealer;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The auth kit (docs/platform/RFC.md §3.1): token mechanics shared by every product; the product chooses policy
3
+ * (lifetimes, scopes, who gets what, where keys live). WebCrypto only, no runtime dependencies: Node ≥ 20 and
4
+ * Cloudflare Workers. Every verifier fails closed; every compare of a secret value is constant-time; every token kind
5
+ * is domain-separated (its own HKDF subkey, HMAC domain or AEAD purpose).
6
+ */
7
+ export { MIN_SECRET_LENGTH, b64url, fromB64url, fromB64urlStrict, grantSealer, hmacHex, hmacSha256, randomBytes, sameHex, sha256, sha256Hex, timingSafeEqual, toHex, verifyHmacHex, type Grant, type GrantSealer, type GrantSealerOptions, } from "./grants";
8
+ export { KID, keyring, subkey, type KeyPurpose, type Keyring, type KeyringKey } from "./keyring";
9
+ export { KV_ID, parseTtl, type KeyValueStore } from "./kv";
10
+ export { isGrantedScope, isWantedScope, scopeAllows } from "./scope";
11
+ export { MAX_TOKEN_LENGTH, issueToken, verifyToken, type IssueOptions, type TokenClaims, type VerifyFailure, type VerifyOptions, type VerifyResult, } from "./jwt";
12
+ export { revocationList, type RevocationList } from "./revocations";
13
+ export { tokenCache, type CachedVerdict, type TokenCache } from "./cache";
14
+ export { DEVICE_ID, bearerFrom, deviceTokenMessage, mintDeviceToken, mintDeviceTokenAsync, parseDeviceToken, verifyDeviceToken, verifyDeviceTokenSync, type ParsedDeviceToken, type SyncMac, } from "./deviceTokens";
15
+ export { API_KEY_PREFIX, apiKeyMatches, authenticateApiKey, generateApiKey, hashApiKey, looksLikeApiKey, type ApiKeyOptions, type GeneratedApiKey, } from "./apiKeys";
16
+ export { memoryApiKeyRepository, type ApiKeyRecord, type ApiKeyRepository, type IssuedTokenRecord, type TokenRepository, } from "./repository";
17
+ export { signUrl, verifySignedUrl, type SignUrlOptions, type VerifyUrlOptions, type VerifyUrlResult, } from "./signedUrls";
18
+ export { openBytes, openEnvelope, openEnvelopeText, rewrapEnvelope, sealBytes, sealEnvelope, type EnvelopeOptions, } from "./envelope";
19
+ export { signServiceRequest, verifyServiceRequest, type ServiceVerifyOptions, type ServiceVerifyResult, } from "./serviceAuth";