@anaralabs/lector 3.11.1 → 3.12.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/_tsup-dts-rollup.d.ts +11 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22 -3
- package/package.json +1 -1
|
@@ -11,13 +11,12 @@ import type { PageViewport } from 'pdfjs-dist';
|
|
|
11
11
|
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
12
12
|
import { pdfjsDist } from 'pdfjs-dist';
|
|
13
13
|
import type { PDFPageProxy } from 'pdfjs-dist';
|
|
14
|
-
import
|
|
14
|
+
import { default as React_2 } from 'react';
|
|
15
15
|
import { ReactElement } from 'react';
|
|
16
16
|
import { ReactNode } from 'react';
|
|
17
17
|
import { RefAttributes } from 'react';
|
|
18
18
|
import { StoreApi } from 'zustand';
|
|
19
19
|
import type { TypedArray } from 'pdfjs-dist/types/src/display/api';
|
|
20
|
-
import { UseBoundStore } from 'zustand';
|
|
21
20
|
import { useFloating } from '@floating-ui/react';
|
|
22
21
|
import { useInteractions } from '@floating-ui/react';
|
|
23
22
|
import type { Virtualizer } from '@tanstack/react-virtual';
|
|
@@ -90,6 +89,15 @@ declare interface AnnotationLayerParams {
|
|
|
90
89
|
jumpOptions?: Parameters<ReturnType<typeof usePdfJump>["jumpToPage"]>[1];
|
|
91
90
|
}
|
|
92
91
|
|
|
92
|
+
declare const AnnotationsStoreProvider: ({ children, }: {
|
|
93
|
+
children?: React_2.ReactNode;
|
|
94
|
+
}) => React_2.FunctionComponentElement<{
|
|
95
|
+
children?: React_2.ReactNode;
|
|
96
|
+
initialValue: void;
|
|
97
|
+
}>;
|
|
98
|
+
export { AnnotationsStoreProvider }
|
|
99
|
+
export { AnnotationsStoreProvider as AnnotationsStoreProvider_alias_1 }
|
|
100
|
+
|
|
93
101
|
declare interface AnnotationState {
|
|
94
102
|
annotations: Annotation[];
|
|
95
103
|
addAnnotation: (annotation: Annotation) => void;
|
|
@@ -420,7 +428,7 @@ export declare const Thumbnails: ({ children, ...props }: HTMLProps<HTMLDivEleme
|
|
|
420
428
|
|
|
421
429
|
export declare const TotalPages: ({ ...props }: HTMLProps<HTMLDivElement>) => JSX.Element;
|
|
422
430
|
|
|
423
|
-
declare const useAnnotations:
|
|
431
|
+
declare const useAnnotations: () => AnnotationState;
|
|
424
432
|
export { useAnnotations }
|
|
425
433
|
export { useAnnotations as useAnnotations_alias_1 }
|
|
426
434
|
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export { SearchResults } from './_tsup-dts-rollup.js';
|
|
|
30
30
|
export { useSearch } from './_tsup-dts-rollup.js';
|
|
31
31
|
export { calculateHighlightRects } from './_tsup-dts-rollup.js';
|
|
32
32
|
export { Annotation } from './_tsup-dts-rollup.js';
|
|
33
|
+
export { AnnotationsStoreProvider } from './_tsup-dts-rollup.js';
|
|
33
34
|
export { useAnnotations } from './_tsup-dts-rollup.js';
|
|
34
35
|
export { usePageRendered } from './_tsup-dts-rollup.js';
|
|
35
36
|
export { LinkService } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import React, { createContext, memo, forwardRef, useMemo, cloneElement, useEffect, useRef, useState, useCallback, useContext, useLayoutEffect, createRef } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
import { useFloating, autoUpdate, offset, shift, useDismiss, useInteractions, inline, flip } from '@floating-ui/react';
|
|
6
|
-
import {
|
|
6
|
+
import { useStore, createStore } from 'zustand';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
import { useDebounce } from 'use-debounce';
|
|
9
9
|
import { v4 } from 'uuid';
|
|
@@ -431,7 +431,7 @@ var AnnotationTooltip = ({
|
|
|
431
431
|
)
|
|
432
432
|
] });
|
|
433
433
|
};
|
|
434
|
-
var
|
|
434
|
+
var createAnnotationStore = () => createStore((set) => ({
|
|
435
435
|
annotations: [],
|
|
436
436
|
addAnnotation: (annotation) => set((state) => ({
|
|
437
437
|
annotations: [...state.annotations, annotation]
|
|
@@ -451,6 +451,25 @@ var useAnnotations = create((set) => ({
|
|
|
451
451
|
})),
|
|
452
452
|
setAnnotations: (annotations) => set({ annotations })
|
|
453
453
|
}));
|
|
454
|
+
var AnnotationsStore = createZustandContext(
|
|
455
|
+
() => createAnnotationStore()
|
|
456
|
+
);
|
|
457
|
+
var fallbackStore = null;
|
|
458
|
+
var getFallbackStore = () => {
|
|
459
|
+
if (!fallbackStore) fallbackStore = createAnnotationStore();
|
|
460
|
+
return fallbackStore;
|
|
461
|
+
};
|
|
462
|
+
var AnnotationsStoreProvider = ({
|
|
463
|
+
children
|
|
464
|
+
}) => React.createElement(
|
|
465
|
+
AnnotationsStore.Provider,
|
|
466
|
+
{ initialValue: void 0 },
|
|
467
|
+
children
|
|
468
|
+
);
|
|
469
|
+
var useAnnotations = () => {
|
|
470
|
+
const ctx = AnnotationsStore.useContext();
|
|
471
|
+
return useStore(ctx ?? getFallbackStore());
|
|
472
|
+
};
|
|
454
473
|
var PDFPageNumberContext = createContext(0);
|
|
455
474
|
var usePDFPageNumber = () => {
|
|
456
475
|
return useContext(PDFPageNumberContext);
|
|
@@ -5962,4 +5981,4 @@ function mergeAdjacentRects(rects) {
|
|
|
5962
5981
|
// src/hooks/usePageRendered.ts
|
|
5963
5982
|
var usePageRendered = (pageNumber) => usePdf((state) => !!state.renderedPages[pageNumber]);
|
|
5964
5983
|
|
|
5965
|
-
export { AnnotationHighlightLayer, AnnotationLayer, AnnotationTooltip, CanvasLayer, ColoredHighlightLayer, CurrentPage, CurrentZoom, CustomLayer, HighlightLayer, LinkService, NextPage, Outline, OutlineChildItems, OutlineItem, PDFLinkServiceContext, Page, Pages, PreviousPage, Root, Search, SelectionTooltip, TextLayer, Thumbnail, Thumbnails, TotalPages, ZoomIn, ZoomOut, calculateHighlightRects, useAnnotations, useCreatePDFLinkService, usePDFLinkService, usePDFPageNumber, usePageRendered, usePdf, usePdfJump, useSearch, useSelectionDimensions };
|
|
5984
|
+
export { AnnotationHighlightLayer, AnnotationLayer, AnnotationTooltip, AnnotationsStoreProvider, CanvasLayer, ColoredHighlightLayer, CurrentPage, CurrentZoom, CustomLayer, HighlightLayer, LinkService, NextPage, Outline, OutlineChildItems, OutlineItem, PDFLinkServiceContext, Page, Pages, PreviousPage, Root, Search, SelectionTooltip, TextLayer, Thumbnail, Thumbnails, TotalPages, ZoomIn, ZoomOut, calculateHighlightRects, useAnnotations, useCreatePDFLinkService, usePDFLinkService, usePDFPageNumber, usePageRendered, usePdf, usePdfJump, useSearch, useSelectionDimensions };
|