@lightbird/ui 0.7.0 → 0.8.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.
package/dist/index.cjs CHANGED
@@ -1933,7 +1933,6 @@ var MAX_RETRIES = 3;
1933
1933
  var LightBirdPlayer = () => {
1934
1934
  const videoRef = React11.useRef(null);
1935
1935
  const containerRef = React11.useRef(null);
1936
- const canvasRef = React11.useRef(null);
1937
1936
  const subtitleInputRef = React11.useRef(null);
1938
1937
  const playerRef = React11.useRef(null);
1939
1938
  const subtitleFilesMapRef = React11.useRef(/* @__PURE__ */ new Map());
@@ -2425,19 +2424,17 @@ var LightBirdPlayer = () => {
2425
2424
  }, [toast2]);
2426
2425
  const captureScreenshot = React11.useCallback(() => {
2427
2426
  const video = videoRef.current;
2428
- const canvas = canvasRef.current;
2429
- if (!video || !canvas) return;
2430
- canvas.width = video.videoWidth;
2431
- canvas.height = video.videoHeight;
2432
- const ctx = canvas.getContext("2d");
2433
- if (!ctx) return;
2434
- ctx.filter = video.style.filter;
2435
- ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
2436
- const dataUrl = canvas.toDataURL("image/png");
2437
- const a = document.createElement("a");
2438
- a.href = dataUrl;
2439
- a.download = `lightbird-screenshot-${(/* @__PURE__ */ new Date()).toISOString()}.png`;
2440
- a.click();
2427
+ if (!video) return;
2428
+ const dataUrl = core.exportVideoFrame(video, { filter: video.style.filter });
2429
+ if (!dataUrl) {
2430
+ toast2({
2431
+ title: "Screenshot failed",
2432
+ description: "The frame could not be captured (the video may be cross-origin protected).",
2433
+ variant: "destructive"
2434
+ });
2435
+ return;
2436
+ }
2437
+ core.downloadDataUrl(dataUrl, core.frameExportFilename("png"));
2441
2438
  toast2({ title: "Screenshot Saved" });
2442
2439
  }, [toast2]);
2443
2440
  const handleABLoopCycle = React11.useCallback(() => {
@@ -2516,7 +2513,6 @@ var LightBirdPlayer = () => {
2516
2513
  crossOrigin: "anonymous"
2517
2514
  }
2518
2515
  ),
2519
- /* @__PURE__ */ jsxRuntime.jsx("canvas", { ref: canvasRef, className: "hidden" }),
2520
2516
  /* @__PURE__ */ jsxRuntime.jsx(SubtitleOverlay, { videoRef, activeSubtitle: subtitles.activeSubtitle }),
2521
2517
  /* @__PURE__ */ jsxRuntime.jsx(
2522
2518
  VideoOverlay,
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import { SortableContext, verticalListSortingStrategy, arrayMove, useSortable }
18
18
  import { CSS } from '@dnd-kit/utilities';
19
19
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
20
20
  import * as SelectPrimitive from '@radix-ui/react-select';
21
- import { exportPlaylist, formatShortcutKey, FLAG_MAGNET_LINK, loadShortcuts, ProgressEstimator, createVideoPlayer, CancellationError, hasAcceptedDisclaimer, acceptDisclaimer, initFeatureFlags, parseMediaError, captureVideoThumbnail, validateFile, parseM3U8, matchesShortcut, saveShortcuts, DEFAULT_SHORTCUTS } from '@lightbird/core';
21
+ import { exportPlaylist, formatShortcutKey, FLAG_MAGNET_LINK, loadShortcuts, ProgressEstimator, createVideoPlayer, CancellationError, hasAcceptedDisclaimer, acceptDisclaimer, exportVideoFrame, downloadDataUrl, frameExportFilename, initFeatureFlags, parseMediaError, captureVideoThumbnail, validateFile, parseM3U8, matchesShortcut, saveShortcuts, DEFAULT_SHORTCUTS } from '@lightbird/core';
22
22
  import * as DialogPrimitive from '@radix-ui/react-dialog';
23
23
  import { useBooleanFlagValue, OpenFeatureProvider } from '@openfeature/react-sdk';
24
24
  import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
@@ -1902,7 +1902,6 @@ var MAX_RETRIES = 3;
1902
1902
  var LightBirdPlayer = () => {
1903
1903
  const videoRef = useRef(null);
1904
1904
  const containerRef = useRef(null);
1905
- const canvasRef = useRef(null);
1906
1905
  const subtitleInputRef = useRef(null);
1907
1906
  const playerRef = useRef(null);
1908
1907
  const subtitleFilesMapRef = useRef(/* @__PURE__ */ new Map());
@@ -2394,19 +2393,17 @@ var LightBirdPlayer = () => {
2394
2393
  }, [toast2]);
2395
2394
  const captureScreenshot = useCallback(() => {
2396
2395
  const video = videoRef.current;
2397
- const canvas = canvasRef.current;
2398
- if (!video || !canvas) return;
2399
- canvas.width = video.videoWidth;
2400
- canvas.height = video.videoHeight;
2401
- const ctx = canvas.getContext("2d");
2402
- if (!ctx) return;
2403
- ctx.filter = video.style.filter;
2404
- ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
2405
- const dataUrl = canvas.toDataURL("image/png");
2406
- const a = document.createElement("a");
2407
- a.href = dataUrl;
2408
- a.download = `lightbird-screenshot-${(/* @__PURE__ */ new Date()).toISOString()}.png`;
2409
- a.click();
2396
+ if (!video) return;
2397
+ const dataUrl = exportVideoFrame(video, { filter: video.style.filter });
2398
+ if (!dataUrl) {
2399
+ toast2({
2400
+ title: "Screenshot failed",
2401
+ description: "The frame could not be captured (the video may be cross-origin protected).",
2402
+ variant: "destructive"
2403
+ });
2404
+ return;
2405
+ }
2406
+ downloadDataUrl(dataUrl, frameExportFilename("png"));
2410
2407
  toast2({ title: "Screenshot Saved" });
2411
2408
  }, [toast2]);
2412
2409
  const handleABLoopCycle = useCallback(() => {
@@ -2485,7 +2482,6 @@ var LightBirdPlayer = () => {
2485
2482
  crossOrigin: "anonymous"
2486
2483
  }
2487
2484
  ),
2488
- /* @__PURE__ */ jsx("canvas", { ref: canvasRef, className: "hidden" }),
2489
2485
  /* @__PURE__ */ jsx(SubtitleOverlay, { videoRef, activeSubtitle: subtitles.activeSubtitle }),
2490
2486
  /* @__PURE__ */ jsx(
2491
2487
  VideoOverlay,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightbird/ui",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Drop-in React video player component powered by LightBird. Full controls, playlist, subtitles, chapters — one import.",
5
5
  "license": "MIT",
6
6
  "author": "Punyam Singh",
@@ -65,7 +65,7 @@
65
65
  "clsx": "^2.1.1",
66
66
  "lucide-react": "^0.475.0",
67
67
  "tailwind-merge": "^3.0.1",
68
- "@lightbird/core": "0.7.0"
68
+ "@lightbird/core": "0.8.0"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "react": "^18.0.0 || ^19.0.0",