@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 CHANGED
@@ -1,8 +1,8 @@
1
1
  # @cloudpdf/viewer-react
2
2
 
3
- The full EmbedPDF viewer as a React component, wired to CloudPDF. There is no
4
- WebAssembly and no Web Worker in your bundle — rendering happens on a CloudPDF
5
- deployment (the SaaS at `api.cloudpdf.com`, or your own
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 { CloudPDFViewer } from '@cloudpdf/viewer-react';
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
- `docToken` is a doc-scoped JWT minted by your backend; `docId` opens a document
28
- by id when the engine-level `token` already authorizes it. For several documents
29
- at once, pass `documents` exactly as the open-source viewer takes it.
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
- ## It is the open viewer, with one thing swapped
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
- This package is a thin **door** over
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
- ```tsx
41
- <CloudPDFViewer baseUrl={baseUrl} docToken={token} onReady={(viewer) => …}>
42
- <MyStatusChip slot="doc-status" />
43
- </CloudPDFViewer>
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
- import { PDFViewer } from '@embedpdf/viewer-react/core';
51
- import { cloudEngine } from '@cloudpdf/engine';
52
-
53
- <PDFViewer engine={() => cloudEngine({ baseUrl })} documents={docs} />;
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
- let _cloudpdf_viewer_config = require("@cloudpdf/viewer/config");
3
- let _embedpdf_viewer_react_core = require("@embedpdf/viewer-react/core");
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, wired to
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 { CloudPDFViewer } from '@cloudpdf/viewer-react';
12
+ * import { PDFViewer } from '@cloudpdf/viewer-react';
12
13
  *
13
- * <CloudPDFViewer
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 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.
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
- function CloudPDFViewer(props) {
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.CloudPDFViewer = CloudPDFViewer;
38
- Object.defineProperty(exports, "resolveCloudConfig", {
39
- enumerable: true,
40
- get: function() {
41
- return _cloudpdf_viewer_config.resolveCloudConfig;
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(_embedpdf_viewer_react_core).forEach(function(k) {
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 _embedpdf_viewer_react_core[k];
37
+ return _embedpdf_viewer_react_component[k];
49
38
  }
50
39
  });
51
40
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["PDFViewer"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @cloudpdf/viewer-react — the full viewer as a React component, wired to\n * CloudPDF.\n *\n * ```tsx\n * import { CloudPDFViewer } from '@cloudpdf/viewer-react';\n *\n * <CloudPDFViewer\n * baseUrl=\"https://api.cloudpdf.com\"\n * docToken={token}\n * style={{ height: '100vh' }}\n * />\n * ```\n *\n * A cloud DOOR, and nothing more. It renders the open-source `<PDFViewer>` from\n * `@embedpdf/viewer-react/core` — the ENGINE-AGNOSTIC door, where `engine` is\n * required — and supplies that engine from the cloud vocabulary via\n * `resolveCloudConfig`. Because the core door registers no default engine, the\n * local PDFium engine (6 MB of wasm, the worker source, the main-thread recipe)\n * is structurally absent from your bundle: not stubbed, not aliased away,\n * simply never imported.\n *\n * Everything the open viewer accepts — `chrome`, `commands`, `icons`,\n * `strings`, `theme`, children-as-slots, `onReady` — works here unchanged (see\n * `@embedpdf/viewer-react`). This file adds the CloudPDF connection and the\n * document shorthands, and subtracts nothing.\n */\nimport { resolveCloudConfig, type CloudSource } from '@cloudpdf/viewer/config';\nimport { PDFViewer, type PDFViewerProps } from '@embedpdf/viewer-react/core';\nimport { createElement } from 'react';\n\n// The open viewer's whole vocabulary rides along, so a cloud app imports ONE\n// package — same ladder as the cloud snippet.\nexport * from '@embedpdf/viewer-react/core';\nexport { resolveCloudConfig } from '@cloudpdf/viewer/config';\nexport type { CloudSource } from '@cloudpdf/viewer/config';\n\n/**\n * The cloud connection and document shorthands, plus every viewer option except\n * `engine` (this door supplies it) and `src` (a cloud document is named by\n * `docToken`/`docId`, not by URL).\n */\nexport type CloudPDFViewerProps = Omit<PDFViewerProps, 'engine' | 'documents' | 'src'> &\n CloudSource;\n\nexport function CloudPDFViewer(props: CloudPDFViewerProps) {\n return createElement(PDFViewer, resolveCloudConfig(props));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,eAAe,OAA4B;CACzD,QAAA,GAAA,MAAA,cAAA,CAAqBA,4BAAAA,YAAAA,GAAAA,wBAAAA,mBAAAA,CAA8B,KAAK,CAAC;AAC3D"}
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 { CloudSource, CloudSource as CloudSource$1, resolveCloudConfig } from "@cloudpdf/viewer/config";
2
- import { PDFViewerProps } from "@embedpdf/viewer-react/core";
3
- export * from "@embedpdf/viewer-react/core";
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
- * The cloud connection and document shorthands, plus every viewer option except
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 { CloudPDFViewer, CloudPDFViewerProps, type CloudSource, resolveCloudConfig };
9
+ export { PDFViewer, PDFViewerProps };
14
10
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,14 +1,10 @@
1
- import { CloudSource, CloudSource as CloudSource$1, resolveCloudConfig } from "@cloudpdf/viewer/config";
2
- import { PDFViewerProps } from "@embedpdf/viewer-react/core";
3
- export * from "@embedpdf/viewer-react/core";
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
- * The cloud connection and document shorthands, plus every viewer option except
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 { CloudPDFViewer, CloudPDFViewerProps, type CloudSource, resolveCloudConfig };
9
+ export { PDFViewer, PDFViewerProps };
14
10
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,39 +1,11 @@
1
- import { resolveCloudConfig, resolveCloudConfig as resolveCloudConfig$1 } from "@cloudpdf/viewer/config";
2
- import { PDFViewer } from "@embedpdf/viewer-react/core";
3
- import { createElement } from "react";
4
- export * from "@embedpdf/viewer-react/core";
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 { CloudPDFViewer, resolveCloudConfig };
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":["resolveCloudConfig"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @cloudpdf/viewer-react — the full viewer as a React component, wired to\n * CloudPDF.\n *\n * ```tsx\n * import { CloudPDFViewer } from '@cloudpdf/viewer-react';\n *\n * <CloudPDFViewer\n * baseUrl=\"https://api.cloudpdf.com\"\n * docToken={token}\n * style={{ height: '100vh' }}\n * />\n * ```\n *\n * A cloud DOOR, and nothing more. It renders the open-source `<PDFViewer>` from\n * `@embedpdf/viewer-react/core` — the ENGINE-AGNOSTIC door, where `engine` is\n * required — and supplies that engine from the cloud vocabulary via\n * `resolveCloudConfig`. Because the core door registers no default engine, the\n * local PDFium engine (6 MB of wasm, the worker source, the main-thread recipe)\n * is structurally absent from your bundle: not stubbed, not aliased away,\n * simply never imported.\n *\n * Everything the open viewer accepts — `chrome`, `commands`, `icons`,\n * `strings`, `theme`, children-as-slots, `onReady` — works here unchanged (see\n * `@embedpdf/viewer-react`). This file adds the CloudPDF connection and the\n * document shorthands, and subtracts nothing.\n */\nimport { resolveCloudConfig, type CloudSource } from '@cloudpdf/viewer/config';\nimport { PDFViewer, type PDFViewerProps } from '@embedpdf/viewer-react/core';\nimport { createElement } from 'react';\n\n// The open viewer's whole vocabulary rides along, so a cloud app imports ONE\n// package — same ladder as the cloud snippet.\nexport * from '@embedpdf/viewer-react/core';\nexport { resolveCloudConfig } from '@cloudpdf/viewer/config';\nexport type { CloudSource } from '@cloudpdf/viewer/config';\n\n/**\n * The cloud connection and document shorthands, plus every viewer option except\n * `engine` (this door supplies it) and `src` (a cloud document is named by\n * `docToken`/`docId`, not by URL).\n */\nexport type CloudPDFViewerProps = Omit<PDFViewerProps, 'engine' | 'documents' | 'src'> &\n CloudSource;\n\nexport function CloudPDFViewer(props: CloudPDFViewerProps) {\n return createElement(PDFViewer, resolveCloudConfig(props));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,eAAe,OAA4B;CACzD,OAAO,cAAc,WAAWA,qBAAmB,KAAK,CAAC;AAC3D"}
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.14",
3
+ "version": "3.0.0-next.15",
4
4
  "private": false,
5
- "description": "React wrapper for the full viewer wired to CloudPDF: the CloudPDFViewer component. A thin cloud door over @embedpdf/viewer-react/core - no wasm, no workers, rendering happens on a @cloudpdf/server deployment (or CloudPDF SaaS) over HTTPS.",
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.14",
41
- "@embedpdf/viewer-react": "3.0.0-next.14"
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"