@pi-outpost/embed 0.7.0 → 0.9.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/README.md +13 -3
- package/dist/{PdfViewer-B7zZlWXk.js → PdfViewer-Bgsp04sQ.js} +1 -1
- package/dist/{PdfViewer-B6wt_XU8.cjs → PdfViewer-Brg-USBu.cjs} +1 -1
- package/dist/pi-outpost-embed.cjs +59 -57
- package/dist/pi-outpost-embed.js +12112 -7267
- package/dist/{workspacePath-CZQ7Q2Vh.js → workspacePath-BntMOlpq.js} +5 -2
- package/dist/workspacePath-CueaT8yG.cjs +1 -0
- package/package.json +1 -1
- package/dist/workspacePath-xNhEENtk.cjs +0 -1
package/README.md
CHANGED
|
@@ -38,6 +38,17 @@ widget.unmount(); // tear down the React tree
|
|
|
38
38
|
|
|
39
39
|
`mount(container, options?)` returns `{ unmount(), setTheme(theme) }`. The container itself stays in the DOM after `unmount()`, with an empty shadow root.
|
|
40
40
|
|
|
41
|
+
### Which theme wins
|
|
42
|
+
|
|
43
|
+
Strongest first:
|
|
44
|
+
|
|
45
|
+
1. `setTheme()`, a `{ type: "pi-outpost:set-theme", theme }` message, or the reader using the widget's own toggle — whatever was chosen while it was on screen;
|
|
46
|
+
2. the `theme` you pass to `mount()`. Naming it means you get it: a reader who once used the toggle on this origin does not overrule the page that embeds the widget;
|
|
47
|
+
3. a theme this browser remembered from an earlier visit;
|
|
48
|
+
4. the server's `branding.defaultTheme`, itself falling back to `"system"`.
|
|
49
|
+
|
|
50
|
+
So pass `theme` when your page has a look the widget has to match, and leave it out when the deployment's own `branding.defaultTheme` should decide.
|
|
51
|
+
|
|
41
52
|
## Server-rendered apps
|
|
42
53
|
|
|
43
54
|
Importing the package is safe anywhere, but `mount()` needs a real DOM: it attaches a shadow root to the element you give it. In Next.js, Remix or Astro, call it from an effect (client-side only):
|
|
@@ -53,10 +64,9 @@ In Next.js, the component doing this must be a client component (`"use client"`)
|
|
|
53
64
|
|
|
54
65
|
## Server-side configuration
|
|
55
66
|
|
|
56
|
-
|
|
67
|
+
Configure this on the pi-outpost server, whatever the deployment topology:
|
|
57
68
|
|
|
58
|
-
- **`server.allowedOrigins`** — the widget
|
|
59
|
-
- **CORS** — `/branding` and `/health` are plain HTTP endpoints with no CORS headers. They work with zero extra config when the widget and the backend share an origin (recommended: reverse-proxy pi-outpost under your own domain). A genuinely cross-origin deployment needs a CORS layer in front.
|
|
69
|
+
- **`server.allowedOrigins`** — the widget carries the *host page's* origin (e.g. `https://your-app.example.com`), not pi-outpost's own. Add it explicitly; even same-domain deployments need this (only `localhost`/`127.0.0.1` are trusted automatically). Listing it is all a cross-origin mount needs: the server answers those origins with the CORS headers the browser requires on every HTTP route, and applies the same allowlist to the WebSocket handshake. It grants no authority of its own — a token-protected route still wants its token.
|
|
60
70
|
|
|
61
71
|
## License
|
|
62
72
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as e } from "./workspacePath-BntMOlpq.js";
|
|
2
2
|
import { useCallback as t, useEffect as n, useRef as r, useState as i } from "react";
|
|
3
3
|
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
4
4
|
//#region ../ui/src/components/PdfViewer.tsx
|