@hussmartinez/pdf-sdk 0.4.1 → 0.4.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"processing-worker-B70FATD2.js","names":["ProcessingWorker"],"sources":["../../src/adapters/qpdf/processing-worker.ts"],"sourcesContent":["import ProcessingWorker from \"../../workers/processing.worker.ts?worker&inline\";\n\n/** Starts the inlined processing worker, from its own lazy chunk. */\nexport function createInlineWorker(): Worker {\n return new ProcessingWorker({ name: \"hm-pdf-processing\" });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAgB,qBAA6B;CAC3C,OAAO,IAAIA,cAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC3D"}
1
+ {"version":3,"file":"processing-worker-DjQv43DW.js","names":["ProcessingWorker"],"sources":["../../src/adapters/qpdf/processing-worker.ts"],"sourcesContent":["import ProcessingWorker from \"../../workers/processing.worker.ts?worker&inline\";\n\n/** Starts the inlined processing worker, from its own lazy chunk. */\nexport function createInlineWorker(): Worker {\n return new ProcessingWorker({ name: \"hm-pdf-processing\" });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAgB,qBAA6B;CAC3C,OAAO,IAAIA,cAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC3D"}
package/dist/react.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { T as isPdfError, _ as createPdfJsEngine, b as safeLinkUrl, g as createPdfProcessor, n as createPdfSession, r as cleanFileName, t as pdfMessages, y as linkDestination } from "./shared/en-DiJkcy2X.js";
2
+ import { T as isPdfError, _ as createPdfJsEngine, b as safeLinkUrl, g as createPdfProcessor, n as createPdfSession, r as cleanFileName, t as pdfMessages, y as linkDestination } from "./shared/en-CrXGi3kJ.js";
3
3
  import { createMessages, createShortcutRegistry, createToolRegistry, defineMessages, defineTool, plural } from "@hussmartinez/sdk-core";
4
4
  import { AnnouncerProvider, Button, DeleteIcon, DownloadIcon, IconButton, MoveDownIcon, MoveUpIcon, OpenIcon, PageAddIcon, RedoIcon, RotateLeftIcon, RotateRightIcon, Toolbar, ToolbarGroup, UiMessagesProvider, UndoIcon, useAnnounce, usePlatform } from "@hussmartinez/ui/react";
5
5
  import { Component, createContext, forwardRef, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
@@ -331,6 +331,22 @@ function PdfSessionProvider(props) {
331
331
  children
332
332
  });
333
333
  }
334
+ // src/react/scrollbar.ts
335
+ function scrollbarThickness(container) {
336
+ const probe = document.createElement("div");
337
+ probe.style.cssText = "position: absolute; top: 0; left: 0; width: 100px; height: 100px; overflow: scroll; visibility: hidden; pointer-events: none;";
338
+ probe.style.setProperty("scrollbar-width", getComputedStyle(container).getPropertyValue("scrollbar-width") || "auto");
339
+ container.append(probe);
340
+ const thickness = probe.offsetWidth - probe.clientWidth;
341
+ probe.remove();
342
+ return thickness;
343
+ }
344
+ function steadyWidth(container, measured, thickness) {
345
+ const style = getComputedStyle(container);
346
+ const borders = Number.parseFloat(style.borderLeftWidth) + Number.parseFloat(style.borderRightWidth);
347
+ const shown = container.offsetWidth - container.clientWidth - borders;
348
+ return Math.max(0, measured - Math.max(0, thickness - shown));
349
+ }
334
350
  // src/react/use-near-observer.ts
335
351
  function useNearObserver(root) {
336
352
  const observer = useRef(void 0);
@@ -604,8 +620,9 @@ function PdfThumbnails(props) {
604
620
  useEffect(() => {
605
621
  const element = root.current;
606
622
  if (!element) return;
623
+ const thickness = scrollbarThickness(element);
607
624
  const observer = new ResizeObserver(([entry]) => {
608
- if (entry) setWidth(entry.contentRect.width);
625
+ if (entry) setWidth(steadyWidth(element, entry.contentRect.width, thickness));
609
626
  });
610
627
  observer.observe(element);
611
628
  return () => observer.disconnect();
@@ -941,8 +958,10 @@ function PdfViewer(props) {
941
958
  useEffect(() => {
942
959
  const element = pages.current;
943
960
  if (!element) return;
961
+ const viewerElement = root.current;
962
+ const thickness = viewerElement ? scrollbarThickness(viewerElement) : 0;
944
963
  const observer = new ResizeObserver(([entry]) => {
945
- if (entry) setWidth(entry.contentRect.width);
964
+ if (entry) setWidth(viewerElement ? steadyWidth(viewerElement, entry.contentRect.width, thickness) : entry.contentRect.width);
946
965
  const viewer = root.current;
947
966
  const held = anchor.current;
948
967
  if (!viewer || !held) return;