@embedpdf/viewer-react 3.0.0-next.13 → 3.0.0-next.15
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/README.md +38 -8
- package/dist/component.cjs +19 -0
- package/dist/component.d.cts +2 -0
- package/dist/component.d.ts +2 -0
- package/dist/component.js +3 -0
- package/dist/core.cjs +20 -6
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -5
- package/dist/core.d.ts +2 -5
- package/dist/core.js +3 -4
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +21 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -8
- package/dist/index.d.ts +3 -8
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -0
- package/dist/parts-BNOPi71I.js +315 -0
- package/dist/parts-BNOPi71I.js.map +1 -0
- package/dist/parts-CDiQnn2K.d.cts +134 -0
- package/dist/parts-DraHrZwl.cjs +368 -0
- package/dist/parts-DraHrZwl.cjs.map +1 -0
- package/dist/parts-U3eTUt92.d.ts +134 -0
- package/package.json +18 -4
- package/dist/component-B4Bvq3Dk.js +0 -31
- package/dist/component-B4Bvq3Dk.js.map +0 -1
- package/dist/component-B8nwtJtn.d.cts +0 -29
- package/dist/component-CGxTTf8T.d.ts +0 -29
- package/dist/component-DmxO8uud.cjs +0 -36
- package/dist/component-DmxO8uud.cjs.map +0 -1
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ElementConfig, EmbedPdfViewerElement, ViewerHandle } from "@embedpdf/viewer/core";
|
|
2
|
-
import { CSSProperties, ReactNode, Ref } from "react";
|
|
3
|
-
//#region src/component.d.ts
|
|
4
|
-
/** The framework-side props — everything that is not viewer config. */
|
|
5
|
-
interface PDFViewerExtras {
|
|
6
|
-
className?: string;
|
|
7
|
-
style?: CSSProperties;
|
|
8
|
-
/** Light-DOM slot children: `<Anything slot="socket-name" />`. */
|
|
9
|
-
children?: ReactNode;
|
|
10
|
-
/** The underlying element, if you need the imperative surface. */
|
|
11
|
-
elementRef?: Ref<EmbedPdfViewerElement>;
|
|
12
|
-
/** The DRIVE surface, once the viewer is live (v2's onReady, reborn):
|
|
13
|
-
* capabilities via `viewer.get(Token)`, `watch`, and the command trio. */
|
|
14
|
-
onReady?: (viewer: ViewerHandle) => void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Props for the shared implementation. Each entry re-exports <PDFViewer>
|
|
18
|
-
* narrowed to ITS door's config — see `PDFViewerProps` in ./index.ts (engine
|
|
19
|
-
* optional) and ./core.ts (engine required).
|
|
20
|
-
*/
|
|
21
|
-
type PDFViewerImplProps = ElementConfig & PDFViewerExtras;
|
|
22
|
-
declare function PDFViewer({ className, style, children, elementRef, onReady, ...config }: PDFViewerImplProps): import("react").ReactElement<{
|
|
23
|
-
ref: (el: EmbedPdfViewerElement | null) => void;
|
|
24
|
-
className: string | undefined;
|
|
25
|
-
style: CSSProperties | undefined;
|
|
26
|
-
}, string | import("react").JSXElementConstructor<any>>;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { PDFViewerExtras as n, PDFViewer as t };
|
|
29
|
-
//# sourceMappingURL=component-B8nwtJtn.d.cts.map
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, ReactNode, Ref } from "react";
|
|
2
|
-
import { ElementConfig, EmbedPdfViewerElement, ViewerHandle } from "@embedpdf/viewer/core";
|
|
3
|
-
//#region src/component.d.ts
|
|
4
|
-
/** The framework-side props — everything that is not viewer config. */
|
|
5
|
-
interface PDFViewerExtras {
|
|
6
|
-
className?: string;
|
|
7
|
-
style?: CSSProperties;
|
|
8
|
-
/** Light-DOM slot children: `<Anything slot="socket-name" />`. */
|
|
9
|
-
children?: ReactNode;
|
|
10
|
-
/** The underlying element, if you need the imperative surface. */
|
|
11
|
-
elementRef?: Ref<EmbedPdfViewerElement>;
|
|
12
|
-
/** The DRIVE surface, once the viewer is live (v2's onReady, reborn):
|
|
13
|
-
* capabilities via `viewer.get(Token)`, `watch`, and the command trio. */
|
|
14
|
-
onReady?: (viewer: ViewerHandle) => void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Props for the shared implementation. Each entry re-exports <PDFViewer>
|
|
18
|
-
* narrowed to ITS door's config — see `PDFViewerProps` in ./index.ts (engine
|
|
19
|
-
* optional) and ./core.ts (engine required).
|
|
20
|
-
*/
|
|
21
|
-
type PDFViewerImplProps = ElementConfig & PDFViewerExtras;
|
|
22
|
-
declare function PDFViewer({ className, style, children, elementRef, onReady, ...config }: PDFViewerImplProps): import("react").ReactElement<{
|
|
23
|
-
ref: (el: EmbedPdfViewerElement | null) => void;
|
|
24
|
-
className: string | undefined;
|
|
25
|
-
style: CSSProperties | undefined;
|
|
26
|
-
}, string | import("react").JSXElementConstructor<any>>;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { PDFViewerExtras as n, PDFViewer as t };
|
|
29
|
-
//# sourceMappingURL=component-CGxTTf8T.d.ts.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
let react = require("react");
|
|
2
|
-
//#region src/component.ts
|
|
3
|
-
function PDFViewer({ className, style, children, elementRef, onReady, ...config }) {
|
|
4
|
-
const ref = (0, react.useRef)(null);
|
|
5
|
-
const configRef = (0, react.useRef)(config);
|
|
6
|
-
configRef.current = config;
|
|
7
|
-
const onReadyRef = (0, react.useRef)(onReady);
|
|
8
|
-
onReadyRef.current = onReady;
|
|
9
|
-
(0, react.useLayoutEffect)(() => {
|
|
10
|
-
const el = ref.current;
|
|
11
|
-
if (!el) return;
|
|
12
|
-
const onEvent = () => el.viewer && onReadyRef.current?.(el.viewer);
|
|
13
|
-
el.addEventListener("epdf:ready", onEvent);
|
|
14
|
-
el.config = configRef.current;
|
|
15
|
-
if (el.viewer) onEvent();
|
|
16
|
-
return () => el.removeEventListener("epdf:ready", onEvent);
|
|
17
|
-
}, []);
|
|
18
|
-
return (0, react.createElement)("embedpdf-viewer", {
|
|
19
|
-
ref: (el) => {
|
|
20
|
-
ref.current = el;
|
|
21
|
-
if (typeof elementRef === "function") elementRef(el);
|
|
22
|
-
else if (elementRef) elementRef.current = el;
|
|
23
|
-
},
|
|
24
|
-
className,
|
|
25
|
-
style
|
|
26
|
-
}, children);
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
|
-
Object.defineProperty(exports, "PDFViewer", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function() {
|
|
32
|
-
return PDFViewer;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=component-DmxO8uud.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-DmxO8uud.cjs","names":[],"sources":["../src/component.ts"],"sourcesContent":["/**\n * <PDFViewer> — the React face of the <embedpdf-viewer> custom element, and\n * deliberately ENGINE-BLIND: this module imports the viewer for TYPES ONLY, so\n * it holds no runtime edge to any engine. Which engine ships is decided by the\n * ENTRY that re-exports it:\n *\n * ./index.ts → `@embedpdf/viewer` — local PDFium engine, registered as\n * the default (the zero-config door)\n * ./core.ts → `@embedpdf/viewer/core` — no default engine; you inject one,\n * and PDFium is structurally absent\n *\n * That side-effect import is the ENTIRE difference between the two doors, and\n * it lives only in those two files. A runtime import here would weld PDFium\n * into every consumer's bundle — cloud builds included — so an import-boundary\n * lint rule (see eslint.config.js) holds this module to `import type`.\n *\n * ```tsx\n * <PDFViewer src=\"/report.pdf\" style={{ height: '100vh' }}>\n * <DocPicker slot=\"doc-picker\" /> // ← children-as-slots\n * </PDFViewer>\n * ```\n *\n * The wrapper is deliberately thin (the v2 pattern): it renders the\n * <embedpdf-viewer> custom element, hands it the config before its deferred\n * first mount, and passes children straight through as LIGHT DOM — the\n * browser projects a child with `slot=\"name\"` into the chrome's matching\n * `custom()` socket while the child stays in the host React tree, so its\n * context, state, and page CSS all keep working. There is no reactSlot()\n * bridge because none is needed: a slot IS a child.\n *\n * Config is init-only (the element's contract). Later prop changes are\n * ignored; remount with a `key` to rebuild the viewer.\n */\n// `ElementConfig` is the KERNEL's config — the widest of all, with the engine\n// seam left `unknown` — so the shared implementation sits above every door and\n// each entry re-types it NARROWER by plain assignment (parameter types are\n// contravariant, so this direction needs no cast). Every import here is\n// type-only, which is what keeps this module engine-blind.\nimport type { ElementConfig, EmbedPdfViewerElement, ViewerHandle } from '@embedpdf/viewer/core';\nimport {\n createElement,\n useLayoutEffect,\n useRef,\n type CSSProperties,\n type MutableRefObject,\n type ReactNode,\n type Ref,\n} from 'react';\n\n/** The framework-side props — everything that is not viewer config. */\nexport interface PDFViewerExtras {\n className?: string;\n style?: CSSProperties;\n /** Light-DOM slot children: `<Anything slot=\"socket-name\" />`. */\n children?: ReactNode;\n /** The underlying element, if you need the imperative surface. */\n elementRef?: Ref<EmbedPdfViewerElement>;\n /** The DRIVE surface, once the viewer is live (v2's onReady, reborn):\n * capabilities via `viewer.get(Token)`, `watch`, and the command trio. */\n onReady?: (viewer: ViewerHandle) => void;\n}\n\n/**\n * Props for the shared implementation. Each entry re-exports <PDFViewer>\n * narrowed to ITS door's config — see `PDFViewerProps` in ./index.ts (engine\n * optional) and ./core.ts (engine required).\n */\nexport type PDFViewerImplProps = ElementConfig & PDFViewerExtras;\n\nexport function PDFViewer({\n className,\n style,\n children,\n elementRef,\n onReady,\n ...config\n}: PDFViewerImplProps) {\n const ref = useRef<EmbedPdfViewerElement | null>(null);\n const configRef = useRef(config);\n configRef.current = config;\n const onReadyRef = useRef(onReady);\n onReadyRef.current = onReady;\n\n // Layout effects run in the insertion task, BEFORE the element's deferred\n // (microtask) declarative mount — so the viewer boots exactly once, with\n // this config, and the ready listener is in place before it can fire.\n // Empty deps: config is init-only by contract.\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const onEvent = () => el.viewer && onReadyRef.current?.(el.viewer);\n el.addEventListener('epdf:ready', onEvent);\n el.config = configRef.current;\n // A remount-with-key that reuses a live element cannot miss the event.\n if (el.viewer) onEvent();\n return () => el.removeEventListener('epdf:ready', onEvent);\n }, []);\n\n return createElement(\n 'embedpdf-viewer',\n {\n ref: (el: EmbedPdfViewerElement | null) => {\n ref.current = el;\n if (typeof elementRef === 'function') elementRef(el);\n else if (elementRef)\n (elementRef as MutableRefObject<EmbedPdfViewerElement | null>).current = el;\n },\n className,\n style,\n },\n children,\n );\n}\n"],"mappings":";;AAqEA,SAAgB,UAAU,EACxB,WACA,OACA,UACA,YACA,SACA,GAAG,UACkB;CACrB,MAAM,OAAA,GAAA,MAAA,OAAA,CAA2C,IAAI;CACrD,MAAM,aAAA,GAAA,MAAA,OAAA,CAAmB,MAAM;CAC/B,UAAU,UAAU;CACpB,MAAM,cAAA,GAAA,MAAA,OAAA,CAAoB,OAAO;CACjC,WAAW,UAAU;CAMrB,CAAA,GAAA,MAAA,gBAAA,OAAsB;EACpB,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,MAAM,gBAAgB,GAAG,UAAU,WAAW,UAAU,GAAG,MAAM;EACjE,GAAG,iBAAiB,cAAc,OAAO;EACzC,GAAG,SAAS,UAAU;EAEtB,IAAI,GAAG,QAAQ,QAAQ;EACvB,aAAa,GAAG,oBAAoB,cAAc,OAAO;CAC3D,GAAG,CAAC,CAAC;CAEL,QAAA,GAAA,MAAA,cAAA,CACE,mBACA;EACE,MAAM,OAAqC;GACzC,IAAI,UAAU;GACd,IAAI,OAAO,eAAe,YAAY,WAAW,EAAE;QAC9C,IAAI,YACP,WAA+D,UAAU;EAC7E;EACA;EACA;CACF,GACA,QACF;AACF"}
|