@cloudpdf/viewer-react 3.0.0-next.14 → 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 +26 -33
- package/dist/index.cjs +22 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -11
- package/dist/index.d.ts +7 -11
- package/dist/index.js +7 -35
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @cloudpdf/viewer-react
|
|
2
2
|
|
|
3
|
-
The full EmbedPDF viewer as a React component,
|
|
4
|
-
WebAssembly and no Web Worker in your bundle
|
|
5
|
-
|
|
3
|
+
The full EmbedPDF viewer as a React component, with the CloudPDF engine as its default. There
|
|
4
|
+
is no WebAssembly and no Web Worker in your bundle for reading: rendering
|
|
5
|
+
happens on CloudPDF (the SaaS, or your own
|
|
6
6
|
[`@cloudpdf/server`](https://www.npmjs.com/package/@cloudpdf/server)), so the
|
|
7
7
|
only thing that crosses the network is HTTPS API traffic.
|
|
8
8
|
|
|
@@ -11,46 +11,39 @@ npm install @cloudpdf/viewer-react
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```tsx
|
|
14
|
-
import {
|
|
14
|
+
import { PDFViewer } from '@cloudpdf/viewer-react';
|
|
15
15
|
|
|
16
16
|
export function Report({ token }: { token: string }) {
|
|
17
|
-
return
|
|
18
|
-
<CloudPDFViewer
|
|
19
|
-
baseUrl="https://api.cloudpdf.com"
|
|
20
|
-
docToken={token}
|
|
21
|
-
style={{ height: '100vh' }}
|
|
22
|
-
/>
|
|
23
|
-
);
|
|
17
|
+
return <PDFViewer src={{ token }} style={{ height: '100vh' }} />;
|
|
24
18
|
}
|
|
25
19
|
```
|
|
26
20
|
|
|
27
|
-
`
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
`src` is the document: `{ token }` with a document token your backend creates
|
|
22
|
+
for the user (a string, or a function that gives a fresh one), `{ id }` when the
|
|
23
|
+
engine's own `token` already allows it, or `{ shareToken }` with a share link
|
|
24
|
+
from the dashboard. Another `src` opens in its place. For several documents at
|
|
25
|
+
once, pass `documents`: entries of `{ src, name, password, active }`.
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
The viewer connects to CloudPDF SaaS (`https://engine.cloudpdf.com`). Your own
|
|
28
|
+
[`@cloudpdf/server`](https://www.npmjs.com/package/@cloudpdf/server) goes in the
|
|
29
|
+
engine's settings: `engine: { baseUrl: 'https://pdf.example.com' }`, with the
|
|
30
|
+
engine's own `token` and `fetch` beside it.
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
[`@embedpdf/viewer-react`](https://www.npmjs.com/package/@embedpdf/viewer-react):
|
|
35
|
-
it renders that project's `<PDFViewer>` from its engine-agnostic entry and
|
|
36
|
-
injects the CloudPDF engine. Everything the open viewer accepts works here
|
|
37
|
-
unchanged — `chrome`, `commands`, `icons`, `strings`, `theme`,
|
|
38
|
-
children-as-slots, `onReady` — and its documentation applies verbatim.
|
|
32
|
+
## It is the open viewer, with its engine swapped
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
If you would rather wire the engine yourself — for a self-hosted server, or
|
|
47
|
-
alongside other engines — skip this package and use the open door directly:
|
|
34
|
+
This package is a **door** over [`@embedpdf/viewer-react`](https://www.npmjs.com/package/@embedpdf/viewer-react),
|
|
35
|
+
as that package is the same viewer with the built-in engine: the component is
|
|
36
|
+
the same `<PDFViewer>`, and so is every name around it. Everything the open viewer
|
|
37
|
+
accepts works here unchanged (`layout`, `commands`, `icons`, `strings`,
|
|
38
|
+
`theme`, `plugins`, your components inside it, the ready callback) and its
|
|
39
|
+
documentation applies verbatim. Only the documents are in the cloud's words.
|
|
48
40
|
|
|
49
41
|
```tsx
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
<PDFViewer src={{ token }} onReady={(viewer) => …}>
|
|
43
|
+
<ToolbarItem id="doc-status">
|
|
44
|
+
<MyStatusChip />
|
|
45
|
+
</ToolbarItem>
|
|
46
|
+
</PDFViewer>
|
|
54
47
|
```
|
|
55
48
|
|
|
56
49
|
## Documentation
|
package/dist/index.cjs
CHANGED
|
@@ -1,51 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
let
|
|
4
|
-
let react = require("react");
|
|
3
|
+
require("@cloudpdf/viewer");
|
|
4
|
+
let _embedpdf_viewer_react_component = require("@embedpdf/viewer-react/component");
|
|
5
5
|
//#region src/index.ts
|
|
6
6
|
/**
|
|
7
|
-
* @cloudpdf/viewer-react — the full viewer as a React component,
|
|
7
|
+
* @cloudpdf/viewer-react — the full viewer as a React component, with the CloudPDF engine as the
|
|
8
|
+
* default: the same `<PDFViewer>` as `@embedpdf/viewer-react`, whose documents live on your
|
|
8
9
|
* CloudPDF.
|
|
9
10
|
*
|
|
10
11
|
* ```tsx
|
|
11
|
-
* import {
|
|
12
|
+
* import { PDFViewer } from '@cloudpdf/viewer-react';
|
|
12
13
|
*
|
|
13
|
-
* <
|
|
14
|
-
* baseUrl="https://api.cloudpdf.com"
|
|
15
|
-
* docToken={token}
|
|
16
|
-
* style={{ height: '100vh' }}
|
|
17
|
-
* />
|
|
14
|
+
* <PDFViewer src={{ token }} style={{ height: '100vh' }} />
|
|
18
15
|
* ```
|
|
19
16
|
*
|
|
20
|
-
* A
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* `
|
|
24
|
-
* local PDFium engine (6 MB of wasm, the worker source, the main-thread recipe)
|
|
25
|
-
* is structurally absent from your bundle: not stubbed, not aliased away,
|
|
26
|
-
* simply never imported.
|
|
27
|
-
*
|
|
28
|
-
* Everything the open viewer accepts — `chrome`, `commands`, `icons`,
|
|
29
|
-
* `strings`, `theme`, children-as-slots, `onReady` — works here unchanged (see
|
|
30
|
-
* `@embedpdf/viewer-react`). This file adds the CloudPDF connection and the
|
|
31
|
-
* document shorthands, and subtracts nothing.
|
|
17
|
+
* A door like the open viewer's two (docs/conventions/viewer-doors.md): it imports the cloud
|
|
18
|
+
* door, which registers the cloud engine on `<embedpdf-viewer>`, re-exports the wrapper's parts,
|
|
19
|
+
* and narrows `<PDFViewer>` to the cloud's `ViewerConfig`. `engine` takes the cloud engine's
|
|
20
|
+
* settings (`baseUrl`, CloudPDF SaaS when left out), `src` a document token, an id or a share link.
|
|
32
21
|
*/
|
|
33
|
-
|
|
34
|
-
return (0, react.createElement)(_embedpdf_viewer_react_core.PDFViewer, (0, _cloudpdf_viewer_config.resolveCloudConfig)(props));
|
|
35
|
-
}
|
|
22
|
+
const PDFViewer = _embedpdf_viewer_react_component.PDFViewer;
|
|
36
23
|
//#endregion
|
|
37
|
-
exports.
|
|
38
|
-
Object.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
exports.PDFViewer = PDFViewer;
|
|
25
|
+
Object.keys(_cloudpdf_viewer).forEach(function(k) {
|
|
26
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function() {
|
|
29
|
+
return _cloudpdf_viewer[k];
|
|
30
|
+
}
|
|
31
|
+
});
|
|
43
32
|
});
|
|
44
|
-
Object.keys(
|
|
33
|
+
Object.keys(_embedpdf_viewer_react_component).forEach(function(k) {
|
|
45
34
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
46
35
|
enumerable: true,
|
|
47
36
|
get: function() {
|
|
48
|
-
return
|
|
37
|
+
return _embedpdf_viewer_react_component[k];
|
|
49
38
|
}
|
|
50
39
|
});
|
|
51
40
|
});
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["PDFViewerImpl"],"sources":["../src/index.ts"],"sourcesContent":["'use client';\n/**\n * @cloudpdf/viewer-react — the full viewer as a React component, with the CloudPDF engine as the\n * default: the same `<PDFViewer>` as `@embedpdf/viewer-react`, whose documents live on your\n * CloudPDF.\n *\n * ```tsx\n * import { PDFViewer } from '@cloudpdf/viewer-react';\n *\n * <PDFViewer src={{ token }} style={{ height: '100vh' }} />\n * ```\n *\n * A door like the open viewer's two (docs/conventions/viewer-doors.md): it imports the cloud\n * door, which registers the cloud engine on `<embedpdf-viewer>`, re-exports the wrapper's parts,\n * and narrows `<PDFViewer>` to the cloud's `ViewerConfig`. `engine` takes the cloud engine's\n * settings (`baseUrl`, CloudPDF SaaS when left out), `src` a document token, an id or a share link.\n */\nimport '@cloudpdf/viewer';\n\nimport type { ViewerConfig } from '@cloudpdf/viewer';\nimport {\n PDFViewer as PDFViewerImpl,\n type PDFViewerExtras,\n} from '@embedpdf/viewer-react/component';\n\nexport * from '@cloudpdf/viewer';\nexport * from '@embedpdf/viewer-react/component';\n\nexport type PDFViewerProps = ViewerConfig & PDFViewerExtras;\n\nexport const PDFViewer: (props: PDFViewerProps) => ReturnType<typeof PDFViewerImpl> = PDFViewerImpl;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,YAAyEA,iCAAAA"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export * from "@
|
|
1
|
+
import { ViewerConfig } from "@cloudpdf/viewer";
|
|
2
|
+
import { PDFViewer as PDFViewer$1, PDFViewerExtras } from "@embedpdf/viewer-react/component";
|
|
3
|
+
export * from "@cloudpdf/viewer";
|
|
4
|
+
export * from "@embedpdf/viewer-react/component";
|
|
4
5
|
//#region src/index.d.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* `engine` (this door supplies it) and `src` (a cloud document is named by
|
|
8
|
-
* `docToken`/`docId`, not by URL).
|
|
9
|
-
*/
|
|
10
|
-
type CloudPDFViewerProps = Omit<PDFViewerProps, 'engine' | 'documents' | 'src'> & CloudSource$1;
|
|
11
|
-
declare function CloudPDFViewer(props: CloudPDFViewerProps): import("react").FunctionComponentElement<PDFViewerProps>;
|
|
6
|
+
type PDFViewerProps = ViewerConfig & PDFViewerExtras;
|
|
7
|
+
declare const PDFViewer: (props: PDFViewerProps) => ReturnType<typeof PDFViewer$1>;
|
|
12
8
|
//#endregion
|
|
13
|
-
export {
|
|
9
|
+
export { PDFViewer, PDFViewerProps };
|
|
14
10
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export * from "@
|
|
1
|
+
import { ViewerConfig } from "@cloudpdf/viewer";
|
|
2
|
+
import { PDFViewer as PDFViewer$1, PDFViewerExtras } from "@embedpdf/viewer-react/component";
|
|
3
|
+
export * from "@cloudpdf/viewer";
|
|
4
|
+
export * from "@embedpdf/viewer-react/component";
|
|
4
5
|
//#region src/index.d.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* `engine` (this door supplies it) and `src` (a cloud document is named by
|
|
8
|
-
* `docToken`/`docId`, not by URL).
|
|
9
|
-
*/
|
|
10
|
-
type CloudPDFViewerProps = Omit<PDFViewerProps, 'engine' | 'documents' | 'src'> & CloudSource$1;
|
|
11
|
-
declare function CloudPDFViewer(props: CloudPDFViewerProps): import("react").FunctionComponentElement<PDFViewerProps>;
|
|
6
|
+
type PDFViewerProps = ViewerConfig & PDFViewerExtras;
|
|
7
|
+
declare const PDFViewer: (props: PDFViewerProps) => ReturnType<typeof PDFViewer$1>;
|
|
12
8
|
//#endregion
|
|
13
|
-
export {
|
|
9
|
+
export { PDFViewer, PDFViewerProps };
|
|
14
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,39 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
export * from "@
|
|
1
|
+
"use client";
|
|
2
|
+
import "@cloudpdf/viewer";
|
|
3
|
+
import { PDFViewer as PDFViewer$1 } from "@embedpdf/viewer-react/component";
|
|
4
|
+
export * from "@cloudpdf/viewer";
|
|
5
|
+
export * from "@embedpdf/viewer-react/component";
|
|
5
6
|
//#region src/index.ts
|
|
6
|
-
|
|
7
|
-
* @cloudpdf/viewer-react — the full viewer as a React component, wired to
|
|
8
|
-
* CloudPDF.
|
|
9
|
-
*
|
|
10
|
-
* ```tsx
|
|
11
|
-
* import { CloudPDFViewer } from '@cloudpdf/viewer-react';
|
|
12
|
-
*
|
|
13
|
-
* <CloudPDFViewer
|
|
14
|
-
* baseUrl="https://api.cloudpdf.com"
|
|
15
|
-
* docToken={token}
|
|
16
|
-
* style={{ height: '100vh' }}
|
|
17
|
-
* />
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* A cloud DOOR, and nothing more. It renders the open-source `<PDFViewer>` from
|
|
21
|
-
* `@embedpdf/viewer-react/core` — the ENGINE-AGNOSTIC door, where `engine` is
|
|
22
|
-
* required — and supplies that engine from the cloud vocabulary via
|
|
23
|
-
* `resolveCloudConfig`. Because the core door registers no default engine, the
|
|
24
|
-
* local PDFium engine (6 MB of wasm, the worker source, the main-thread recipe)
|
|
25
|
-
* is structurally absent from your bundle: not stubbed, not aliased away,
|
|
26
|
-
* simply never imported.
|
|
27
|
-
*
|
|
28
|
-
* Everything the open viewer accepts — `chrome`, `commands`, `icons`,
|
|
29
|
-
* `strings`, `theme`, children-as-slots, `onReady` — works here unchanged (see
|
|
30
|
-
* `@embedpdf/viewer-react`). This file adds the CloudPDF connection and the
|
|
31
|
-
* document shorthands, and subtracts nothing.
|
|
32
|
-
*/
|
|
33
|
-
function CloudPDFViewer(props) {
|
|
34
|
-
return createElement(PDFViewer, resolveCloudConfig$1(props));
|
|
35
|
-
}
|
|
7
|
+
const PDFViewer = PDFViewer$1;
|
|
36
8
|
//#endregion
|
|
37
|
-
export {
|
|
9
|
+
export { PDFViewer };
|
|
38
10
|
|
|
39
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["PDFViewerImpl"],"sources":["../src/index.ts"],"sourcesContent":["'use client';\n/**\n * @cloudpdf/viewer-react — the full viewer as a React component, with the CloudPDF engine as the\n * default: the same `<PDFViewer>` as `@embedpdf/viewer-react`, whose documents live on your\n * CloudPDF.\n *\n * ```tsx\n * import { PDFViewer } from '@cloudpdf/viewer-react';\n *\n * <PDFViewer src={{ token }} style={{ height: '100vh' }} />\n * ```\n *\n * A door like the open viewer's two (docs/conventions/viewer-doors.md): it imports the cloud\n * door, which registers the cloud engine on `<embedpdf-viewer>`, re-exports the wrapper's parts,\n * and narrows `<PDFViewer>` to the cloud's `ViewerConfig`. `engine` takes the cloud engine's\n * settings (`baseUrl`, CloudPDF SaaS when left out), `src` a document token, an id or a share link.\n */\nimport '@cloudpdf/viewer';\n\nimport type { ViewerConfig } from '@cloudpdf/viewer';\nimport {\n PDFViewer as PDFViewerImpl,\n type PDFViewerExtras,\n} from '@embedpdf/viewer-react/component';\n\nexport * from '@cloudpdf/viewer';\nexport * from '@embedpdf/viewer-react/component';\n\nexport type PDFViewerProps = ViewerConfig & PDFViewerExtras;\n\nexport const PDFViewer: (props: PDFViewerProps) => ReturnType<typeof PDFViewerImpl> = PDFViewerImpl;\n"],"mappings":";;;;;;AA8BA,MAAa,YAAyEA"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudpdf/viewer-react",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.15",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "The full viewer as a React component with the CloudPDF engine as its default: the same <PDFViewer> as @embedpdf/viewer-react, rendering on CloudPDF SaaS or your own @cloudpdf/server over HTTPS, the local engine loaded only when stamps need it.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
8
8
|
"module": "./dist/index.js",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
],
|
|
38
38
|
"license": "Apache-2.0",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@cloudpdf/viewer": "3.0.0-next.
|
|
41
|
-
"@embedpdf/viewer-react": "3.0.0-next.
|
|
40
|
+
"@cloudpdf/viewer": "3.0.0-next.15",
|
|
41
|
+
"@embedpdf/viewer-react": "3.0.0-next.15"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=18"
|