@page-speed/lightbox 0.1.2 → 0.1.4

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.
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -9064,10 +9064,10 @@ var require_pdf = __commonJS({
9064
9064
  value: true
9065
9065
  });
9066
9066
  exports2.GlobalWorkerOptions = void 0;
9067
- const GlobalWorkerOptions2 = /* @__PURE__ */ Object.create(null);
9068
- exports2.GlobalWorkerOptions = GlobalWorkerOptions2;
9069
- GlobalWorkerOptions2.workerPort = null;
9070
- GlobalWorkerOptions2.workerSrc = "";
9067
+ const GlobalWorkerOptions = /* @__PURE__ */ Object.create(null);
9068
+ exports2.GlobalWorkerOptions = GlobalWorkerOptions;
9069
+ GlobalWorkerOptions.workerPort = null;
9070
+ GlobalWorkerOptions.workerSrc = "";
9071
9071
  }),
9072
9072
  /* 15 */
9073
9073
  /***/
@@ -18069,7 +18069,7 @@ var require_pdf = __commonJS({
18069
18069
  }
18070
18070
  });
18071
18071
 
18072
- // node_modules/.pnpm/@page-speed+pdf-viewer@0.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@page-speed/pdf-viewer/dist/index.js
18072
+ // node_modules/.pnpm/@page-speed+pdf-viewer@0.1.2_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@page-speed/pdf-viewer/dist/index.js
18073
18073
  var dist_exports = {};
18074
18074
  __export(dist_exports, {
18075
18075
  PDFCanvas: () => PDFCanvas,
@@ -18091,12 +18091,12 @@ __export(dist_exports, {
18091
18091
  useZoom: () => useZoom
18092
18092
  });
18093
18093
  import { useEffect as useEffect42 } from "react";
18094
- import { useState as useState3, useEffect as useEffect5 } from "react";
18094
+ import { useState as useState3, useEffect as useEffect5, useRef as useRef3 } from "react";
18095
18095
  import { useState as useState22, useCallback as useCallback3 } from "react";
18096
- import { useRef as useRef3, useState as useState32, useCallback as useCallback22 } from "react";
18096
+ import { useRef as useRef22, useState as useState32, useCallback as useCallback22 } from "react";
18097
18097
  import { useState as useState4, useCallback as useCallback32 } from "react";
18098
18098
  import { useState as useState5, useCallback as useCallback4 } from "react";
18099
- import { useEffect as useEffect22, useRef as useRef22, useState as useState6 } from "react";
18099
+ import { useEffect as useEffect22, useRef as useRef32, useState as useState6 } from "react";
18100
18100
  import { jsx as jsx3 } from "react/jsx-runtime";
18101
18101
  import { jsx as jsx22, jsxs } from "react/jsx-runtime";
18102
18102
  import { useEffect as useEffect32, useState as useState7 } from "react";
@@ -18107,12 +18107,19 @@ function usePDFDocument(url, onError) {
18107
18107
  const [loading, setLoading] = useState3(true);
18108
18108
  const [error, setError] = useState3(null);
18109
18109
  const [pdfDoc, setPdfDoc] = useState3(null);
18110
+ const pdfjsInitialized = useRef3(false);
18110
18111
  useEffect5(() => {
18111
18112
  if (!url) return;
18113
+ if (typeof window === "undefined") return;
18112
18114
  setLoading(true);
18113
18115
  setError(null);
18114
18116
  const loadPDF = async () => {
18115
18117
  try {
18118
+ const pdfjsLib = await Promise.resolve().then(() => __toESM(require_pdf()));
18119
+ if (!pdfjsInitialized.current) {
18120
+ pdfjsLib.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjsLib.version}/pdf.worker.min.js`;
18121
+ pdfjsInitialized.current = true;
18122
+ }
18116
18123
  const loadingTask = pdfjsLib.getDocument({
18117
18124
  url,
18118
18125
  withCredentials: true,
@@ -18177,7 +18184,7 @@ function usePageState({
18177
18184
  };
18178
18185
  }
18179
18186
  function usePageRenderer(pdfDoc) {
18180
- const cacheRef = useRef3(/* @__PURE__ */ new Map());
18187
+ const cacheRef = useRef22(/* @__PURE__ */ new Map());
18181
18188
  const [rendering, setRendering] = useState32(false);
18182
18189
  const [pageInfo, setPageInfo] = useState32(null);
18183
18190
  const renderPage = useCallback22(
@@ -18335,7 +18342,7 @@ function PDFCanvas({
18335
18342
  scale,
18336
18343
  onRender
18337
18344
  }) {
18338
- const containerRef = useRef22(null);
18345
+ const containerRef = useRef32(null);
18339
18346
  const [canvas, setCanvas] = useState6(null);
18340
18347
  useEffect22(() => {
18341
18348
  const render = async () => {
@@ -18676,13 +18683,10 @@ function createProgressiveFetchHandler(onProgress) {
18676
18683
  return response.arrayBuffer();
18677
18684
  };
18678
18685
  }
18679
- var pdfjsLib, DEFAULT_SCALE, CACHE_SIZE, MIN_ZOOM, MAX_ZOOM, ZOOM_STEP, PDFViewer_default, linearizedPDFConfig;
18686
+ var DEFAULT_SCALE, CACHE_SIZE, MIN_ZOOM, MAX_ZOOM, ZOOM_STEP, PDFViewer_default, linearizedPDFConfig;
18680
18687
  var init_dist = __esm({
18681
- "node_modules/.pnpm/@page-speed+pdf-viewer@0.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@page-speed/pdf-viewer/dist/index.js"() {
18682
- pdfjsLib = __toESM(require_pdf());
18683
- if (typeof window !== "undefined") {
18684
- pdfjsLib.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjsLib.version}/pdf.worker.min.js`;
18685
- }
18688
+ "node_modules/.pnpm/@page-speed+pdf-viewer@0.1.2_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@page-speed/pdf-viewer/dist/index.js"() {
18689
+ "use client";
18686
18690
  DEFAULT_SCALE = 1.5;
18687
18691
  CACHE_SIZE = 50 * 1024 * 1024;
18688
18692
  MIN_ZOOM = 0.5;
@@ -19358,43 +19362,6 @@ var ImgBase = forwardRef(function Img(props, ref) {
19358
19362
  var Img2 = memo(ImgBase);
19359
19363
  Img2.displayName = "PageSpeedImg";
19360
19364
 
19361
- // src/styles/Lightbox.module.css
19362
- var Lightbox_default = {
19363
- lightboxPortal: "Lightbox_lightboxPortal2",
19364
- overlay: "Lightbox_overlay2",
19365
- horizontalLayoutRoot: "Lightbox_horizontalLayoutRoot2",
19366
- horizontalLayoutContainer: "Lightbox_horizontalLayoutContainer2",
19367
- mainContent: "Lightbox_mainContent2",
19368
- toolbar: "Lightbox_toolbar2",
19369
- media: "Lightbox_media2",
19370
- chrome: "Lightbox_chrome2",
19371
- chromeSection: "Lightbox_chromeSection2",
19372
- navButton: "Lightbox_navButton2",
19373
- closeButton: "Lightbox_closeButton2",
19374
- counter: "Lightbox_counter2",
19375
- captionContainer: "Lightbox_captionContainer2",
19376
- captionTitle: "Lightbox_captionTitle2",
19377
- captionText: "Lightbox_captionText2",
19378
- pdfContainer: "Lightbox_pdfContainer2",
19379
- pdfFallback: "Lightbox_pdfFallback2",
19380
- verticalSplitLayoutRoot: "Lightbox_verticalSplitLayoutRoot2",
19381
- verticalSplitLayoutContainer: "Lightbox_verticalSplitLayoutContainer2",
19382
- verticalSplitContent: "Lightbox_verticalSplitContent2",
19383
- verticalSplitSidebar: "Lightbox_verticalSplitSidebar2",
19384
- customSlideLayoutRoot: "Lightbox_customSlideLayoutRoot2",
19385
- customSlideLayoutContainer: "Lightbox_customSlideLayoutContainer2",
19386
- customSlideContent: "Lightbox_customSlideContent2",
19387
- customSlideChrome: "Lightbox_customSlideChrome2",
19388
- fullscreenLayoutRoot: "Lightbox_fullscreenLayoutRoot2",
19389
- fullscreenLayoutContainer: "Lightbox_fullscreenLayoutContainer2",
19390
- fullscreenContent: "Lightbox_fullscreenContent2",
19391
- fullscreenChrome: "Lightbox_fullscreenChrome2",
19392
- inlineLayoutRoot: "Lightbox_inlineLayoutRoot2",
19393
- inlineLayoutContainer: "Lightbox_inlineLayoutContainer2",
19394
- inlineContent: "Lightbox_inlineContent2",
19395
- inlineToolbar: "Lightbox_inlineToolbar2"
19396
- };
19397
-
19398
19365
  // src/renderers/ImageRenderer.tsx
19399
19366
  import { jsx } from "react/jsx-runtime";
19400
19367
  var toImgOptixFlowConfig = (config) => {
@@ -19411,7 +19378,7 @@ function ImageRenderer({ item, optixFlowConfig }) {
19411
19378
  return /* @__PURE__ */ jsx(
19412
19379
  Img2,
19413
19380
  {
19414
- className: Lightbox_default.media,
19381
+ className: "max-w-full max-h-full w-auto h-auto object-contain",
19415
19382
  src: item.src,
19416
19383
  alt: item.alt || item.title || "",
19417
19384
  loading: "lazy",
@@ -19427,7 +19394,7 @@ function VideoRenderer({ item }) {
19427
19394
  return /* @__PURE__ */ jsx2(
19428
19395
  "video",
19429
19396
  {
19430
- className: Lightbox_default.media,
19397
+ className: "max-w-full max-h-full w-auto h-auto object-contain rounded-lg",
19431
19398
  src: item.src,
19432
19399
  controls: true,
19433
19400
  playsInline: true
@@ -19449,10 +19416,10 @@ var LazyPDFViewer = React.lazy(loadPDFViewer);
19449
19416
  var AnyPDFViewer = LazyPDFViewer;
19450
19417
  function PDFRenderer({ item }) {
19451
19418
  if (!item.src) return null;
19452
- return /* @__PURE__ */ jsx5("div", { className: Lightbox_default.pdfContainer, children: /* @__PURE__ */ jsx5(
19419
+ return /* @__PURE__ */ jsx5("div", { className: "w-full h-full flex items-center justify-center p-4", children: /* @__PURE__ */ jsx5(
19453
19420
  Suspense,
19454
19421
  {
19455
- fallback: /* @__PURE__ */ jsx5("div", { className: Lightbox_default.pdfFallback, children: "Loading document..." }),
19422
+ fallback: /* @__PURE__ */ jsx5("div", { className: "flex items-center justify-center text-neutral-500 text-sm", children: "Loading document..." }),
19456
19423
  children: /* @__PURE__ */ jsx5(AnyPDFViewer, { url: item.src })
19457
19424
  }
19458
19425
  ) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@page-speed/lightbox",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "High-performance, feature-rich lightbox for OpenSite platform",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -80,6 +80,8 @@
80
80
  },
81
81
  "dependencies": {
82
82
  "@page-speed/img": "^0.4.3",
83
- "@page-speed/pdf-viewer": "0.1.0"
83
+ "@page-speed/pdf-viewer": "0.1.2",
84
+ "clsx": "^2.1.1",
85
+ "tailwind-merge": "^3.4.0"
84
86
  }
85
87
  }