@softistx/pulsarix-widget 0.8.4 → 0.9.1

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.
Files changed (116) hide show
  1. package/README.md +45 -22
  2. package/dist/chunks/{abnfDiagram-XWFEHMT6.b9yk4x5x.js → abnfDiagram-XWFEHMT6.xef4vppv.js} +1 -1
  3. package/dist/chunks/architecture-WOLXFQ4H.pp4drcrh.js +1 -0
  4. package/dist/chunks/{architectureDiagram-CSQXQB3N.qz18rz0g.js → architectureDiagram-CSQXQB3N.0bddzt5e.js} +1 -1
  5. package/dist/chunks/{blockDiagram-BEDRHYPZ.bb08b9nt.js → blockDiagram-BEDRHYPZ.wgdr8xfr.js} +1 -1
  6. package/dist/chunks/{c4Diagram-M2UUVUY5.px0epccd.js → c4Diagram-M2UUVUY5.t09pndbz.js} +1 -1
  7. package/dist/chunks/{chat-markdown-CrbWbK1O.k4nmgyey.js → chat-markdown-CQ4fSIYN.cv3fprzq.js} +2 -2
  8. package/dist/chunks/{classDiagram-v2-KXABOMEV.f02387t9.js → classDiagram-v2-KXABOMEV.9yfjtevj.js} +1 -1
  9. package/dist/chunks/{cose-bilkent-JH36ORCC.azq9k24r.js → cose-bilkent-JH36ORCC.qam7r9b1.js} +1 -1
  10. package/dist/chunks/cynefin-EF2NZ3EQ.wgr8qmb2.js +1 -0
  11. package/dist/chunks/{cynefinDiagram-NJNITYFG.zt7gprt1.js → cynefinDiagram-NJNITYFG.k6mhek0s.js} +1 -1
  12. package/dist/chunks/{dagre-KIHZ2IZ3.702bqbr9.js → dagre-KIHZ2IZ3.sqeg911s.js} +1 -1
  13. package/dist/chunks/{diagram-7YQZDPLS.m7vf21j6.js → diagram-7YQZDPLS.k1qvmctj.js} +1 -1
  14. package/dist/chunks/{diagram-QBROCOUO.33e5hv7x.js → diagram-QBROCOUO.v7fe7e4g.js} +1 -1
  15. package/dist/chunks/{diagram-RJJCUUZO.94k74bz7.js → diagram-RJJCUUZO.12s15pm6.js} +1 -1
  16. package/dist/chunks/{diagram-WERXNKYE.7fe849z6.js → diagram-WERXNKYE.tmrcv4we.js} +1 -1
  17. package/dist/chunks/{diagram-YHHI257C.qjjjfq7w.js → diagram-YHHI257C.7735ve6v.js} +1 -1
  18. package/dist/chunks/{diagram-YR4HJLHV.310x2we2.js → diagram-YR4HJLHV.nytxr7pa.js} +1 -1
  19. package/dist/chunks/{ebnfDiagram-N527522P.a4crteq1.js → ebnfDiagram-N527522P.6eqw92nv.js} +1 -1
  20. package/dist/chunks/{editor-shortcuts-dialog-B0ppoiza.x3p4h07t.js → editor-shortcuts-dialog-VmvMTjnq.mm7ab69f.js} +1 -1
  21. package/dist/chunks/editor.wb4jsrjy.js +4 -0
  22. package/dist/chunks/{elk-O5DQBFGD.dx61etan.js → elk-O5DQBFGD.a5rqryhg.js} +1 -1
  23. package/dist/chunks/{emoji-picker-CbvQZ2ZL.nst616hd.js → emoji-picker-bnO0yA8e.bymgjc9a.js} +1 -1
  24. package/dist/chunks/{erDiagram-K3K3BIDK.qzqv67zm.js → erDiagram-K3K3BIDK.exfeddaa.js} +1 -1
  25. package/dist/chunks/eventmodeling-K75KTNOO.nkahp6zg.js +1 -0
  26. package/dist/chunks/{flow-diagram-AiM6FiIm.73jr19pb.js → flow-diagram-Byy7DBZZ.pf5vdbkn.js} +1 -1
  27. package/dist/chunks/flowDiagram-Z6JWZHQI.54yz6gfm.js +1 -0
  28. package/dist/chunks/{ganttDiagram-3PRQTZWP.xngzb32h.js → ganttDiagram-3PRQTZWP.0tjaeqjw.js} +1 -1
  29. package/dist/chunks/gitGraph-VSP46ZUC.2a0am491.js +1 -0
  30. package/dist/chunks/{gitGraphDiagram-VXDFKS5L.1sm36z2q.js → gitGraphDiagram-VXDFKS5L.6vvbj88t.js} +1 -1
  31. package/dist/chunks/{grid-E2QIVN74.76pgtn2n.js → grid-E2QIVN74.frpdy6t3.js} +1 -1
  32. package/dist/chunks/illustration-BfueshiW.syv54ccw.js +1 -0
  33. package/dist/chunks/{index.fbeztcp3.js → index.0kv7tp87.js} +1 -1
  34. package/dist/chunks/{index.r0p3fm9f.js → index.3pn4wy4j.js} +1 -1
  35. package/dist/chunks/{index.0e4s8r4m.js → index.7q6v461v.js} +1 -1
  36. package/dist/chunks/{index.hvdnkr5m.js → index.93zpfh3k.js} +1 -1
  37. package/dist/chunks/{index.32jxrb9b.js → index.bs3ygyp2.js} +1 -1
  38. package/dist/chunks/{index.7gxz6d1f.js → index.d8b8y928.js} +2 -2
  39. package/dist/chunks/{index.t34t6kpe.js → index.f6jhkm5c.js} +1 -1
  40. package/dist/chunks/{index.8f3x951p.js → index.kh3f3gw8.js} +1 -1
  41. package/dist/chunks/{index.zm5x44tn.js → index.mcyw2bze.js} +1 -1
  42. package/dist/chunks/{index.7k5v3p25.js → index.newjn1k4.js} +1 -1
  43. package/dist/chunks/{index.1d7qpsyx.js → index.nrd5w1x0.js} +1 -1
  44. package/dist/chunks/{index.9bf5qrah.js → index.pyz71tqx.js} +1 -1
  45. package/dist/chunks/index.rn0vxns6.js +44 -0
  46. package/dist/chunks/{index.0k4tbjhp.js → index.sv013f1z.js} +1 -1
  47. package/dist/chunks/{index.dnnzjw18.js → index.xrg5yg8d.js} +1 -1
  48. package/dist/chunks/{index.wrjdgn4c.js → index.yexf86bf.js} +1 -1
  49. package/dist/chunks/{index.a1bxkgd3.js → index.yfbwd99n.js} +2 -2
  50. package/dist/chunks/{index.rfyzb2yv.js → index.zjykrx6y.js} +1 -1
  51. package/dist/chunks/info-OHQRW6UA.4824y3cd.js +1 -0
  52. package/dist/chunks/{infoDiagram-EZ3ZOAHP.pfd0fjwn.js → infoDiagram-EZ3ZOAHP.qh2bwz3m.js} +1 -1
  53. package/dist/chunks/{ishikawaDiagram-S3EKX5GW.h5kjez1x.js → ishikawaDiagram-S3EKX5GW.w2v6vnwd.js} +1 -1
  54. package/dist/chunks/{journeyDiagram-POQNLL5X.55cqc9p0.js → journeyDiagram-POQNLL5X.ftkfdsrw.js} +1 -1
  55. package/dist/chunks/{kanban-definition-BH5XI6FM.pkdvda4y.js → kanban-definition-BH5XI6FM.9scqhcx5.js} +1 -1
  56. package/dist/chunks/{markup-color-chrome-ykGNUl8y.0ds56d6x.js → markup-color-chrome-ykGNUl8y.8cysjsfb.js} +1 -1
  57. package/dist/chunks/{markup-custom-color-Dgm2hHI7.7darvajx.js → markup-custom-color-CytmKw-R.d25j0pcj.js} +1 -1
  58. package/dist/chunks/{mention-list-CkAUzPBG.mtjgmmzb.js → mention-list-5h2lZwEU.wffam6eb.js} +1 -1
  59. package/dist/chunks/{mermaid.core.j7s05j63.js → mermaid.core.tnh468qk.js} +2 -2
  60. package/dist/chunks/{mindmap-definition-WVAN44T4.x3jbxvft.js → mindmap-definition-WVAN44T4.gskntx1f.js} +1 -1
  61. package/dist/chunks/packet-JDAUHWVQ.w0pv2dxr.js +1 -0
  62. package/dist/chunks/{panel.9tp7gr60.js → panel.dq8vt40k.js} +1 -1
  63. package/dist/chunks/{pegDiagram-D4NLKWP3.xq15gqy9.js → pegDiagram-D4NLKWP3.yb58dpky.js} +1 -1
  64. package/dist/chunks/pie-XZMESJXO.zq72f2fq.js +1 -0
  65. package/dist/chunks/{pieDiagram-36ENHN4W.8h0wam54.js → pieDiagram-36ENHN4W.7pgn8ayz.js} +1 -1
  66. package/dist/chunks/{plated-illustration-COZYWJ81.xy7ba5mq.js → plated-illustration-VrnsTz7H.tcyq0sxa.js} +1 -1
  67. package/dist/chunks/{quadrantDiagram-ZQUDMS73.k28g8jpn.js → quadrantDiagram-ZQUDMS73.1a721ces.js} +1 -1
  68. package/dist/chunks/radar-ABXABTNO.288gs0b8.js +1 -0
  69. package/dist/chunks/railroad-I3PHUGI6.aadrd13j.js +1 -0
  70. package/dist/chunks/railroad-abnf-LNEFI6M7.6btgmncj.js +1 -0
  71. package/dist/chunks/railroad-ebnf-DWYD2UWJ.y44ppt8p.js +1 -0
  72. package/dist/chunks/railroad-peg-JR7BVNR7.328jgxkz.js +1 -0
  73. package/dist/chunks/{railroadDiagram-JIZHGYPL.e7p2vqgg.js → railroadDiagram-JIZHGYPL.xpgkt1zp.js} +1 -1
  74. package/dist/chunks/{render-VIF2ZAQL.w5ytncsg.js → render-VIF2ZAQL.khtqjmgm.js} +1 -1
  75. package/dist/chunks/{requirementDiagram-AXW2TVFA.arekdz02.js → requirementDiagram-AXW2TVFA.ms6anxwg.js} +1 -1
  76. package/dist/chunks/{sankeyDiagram-FBCJTAIF.1d04xcmb.js → sankeyDiagram-FBCJTAIF.40yzed7d.js} +1 -1
  77. package/dist/chunks/{sequenceDiagram-3LA2ROMG.j4xywwp1.js → sequenceDiagram-3LA2ROMG.z0h3shw2.js} +1 -1
  78. package/dist/chunks/{sizeCapture-2Q2CQKSF.862bnf6p.js → sizeCapture-2Q2CQKSF.4dh5g271.js} +1 -1
  79. package/dist/chunks/{stateDiagram-v2-ATKHQDJO.xvvtr0y2.js → stateDiagram-v2-ATKHQDJO.5ftcgs8s.js} +1 -1
  80. package/dist/chunks/{swimlanes-YQL5WMAO.dtnjb4xt.js → swimlanes-YQL5WMAO.r6vmskrb.js} +1 -1
  81. package/dist/chunks/swimlanesDiagram-UCCPES4V.exhrz16x.js +8 -0
  82. package/dist/chunks/{timeline-definition-7Z437IG3.zfhqzc4r.js → timeline-definition-7Z437IG3.eke70hfq.js} +1 -1
  83. package/dist/chunks/treeView-D4JQ5SDB.xz61fh4x.js +1 -0
  84. package/dist/chunks/treemap-SAJKECNS.8gv7pmqr.js +1 -0
  85. package/dist/chunks/{usecaseDiagram-RDK6N6HP.ewxnyz4c.js → usecaseDiagram-RDK6N6HP.d8p4tnc6.js} +1 -1
  86. package/dist/chunks/{vennDiagram-SHRQU5PJ.wkzf1f00.js → vennDiagram-SHRQU5PJ.4s46abxd.js} +1 -1
  87. package/dist/chunks/wardley-7MLQ67FV.6v9j3be8.js +1 -0
  88. package/dist/chunks/{wardleyDiagram-F3OXNVQS.srjfm4nb.js → wardleyDiagram-F3OXNVQS.mq49fny4.js} +1 -1
  89. package/dist/chunks/{xychartDiagram-GDYJKCDI.xfa2vexk.js → xychartDiagram-GDYJKCDI.d7he0fxa.js} +1 -1
  90. package/dist/index.js +17 -10
  91. package/dist/react.js +74 -0
  92. package/dist/server.js +20 -0
  93. package/dist/types/react.d.ts +27 -0
  94. package/dist/types/server.d.ts +15 -0
  95. package/docs/integration.md +78 -11
  96. package/package.json +18 -3
  97. package/dist/chunks/architecture-WOLXFQ4H.aft3rkrr.js +0 -1
  98. package/dist/chunks/cynefin-EF2NZ3EQ.dk039jny.js +0 -1
  99. package/dist/chunks/editor.arg3zy29.js +0 -4
  100. package/dist/chunks/eventmodeling-K75KTNOO.gmm1bcak.js +0 -1
  101. package/dist/chunks/flowDiagram-Z6JWZHQI.fzwqg115.js +0 -1
  102. package/dist/chunks/gitGraph-VSP46ZUC.0m8jykgw.js +0 -1
  103. package/dist/chunks/illustration-BOW28wq5.bkz28k1x.js +0 -1
  104. package/dist/chunks/index.e35b4yh5.js +0 -44
  105. package/dist/chunks/info-OHQRW6UA.e0a85drn.js +0 -1
  106. package/dist/chunks/packet-JDAUHWVQ.52409p3r.js +0 -1
  107. package/dist/chunks/pie-XZMESJXO.q5kre8cx.js +0 -1
  108. package/dist/chunks/radar-ABXABTNO.yk872k2n.js +0 -1
  109. package/dist/chunks/railroad-I3PHUGI6.9wfa6vs3.js +0 -1
  110. package/dist/chunks/railroad-abnf-LNEFI6M7.70zznk3b.js +0 -1
  111. package/dist/chunks/railroad-ebnf-DWYD2UWJ.4pvdng0p.js +0 -1
  112. package/dist/chunks/railroad-peg-JR7BVNR7.ev15ebp6.js +0 -1
  113. package/dist/chunks/swimlanesDiagram-UCCPES4V.0q8kd5qn.js +0 -8
  114. package/dist/chunks/treeView-D4JQ5SDB.3fzswdjp.js +0 -1
  115. package/dist/chunks/treemap-SAJKECNS.cgh74bhn.js +0 -1
  116. package/dist/chunks/wardley-7MLQ67FV.6q5tgt0s.js +0 -1
package/dist/react.js ADDED
@@ -0,0 +1,74 @@
1
+ // src/react.tsx
2
+ import { useEffect, useRef, useState } from "react";
3
+ var snapshot = (options) => ({
4
+ theme: options.theme,
5
+ locale: options.locale,
6
+ metadata: JSON.stringify(options.metadata ?? null),
7
+ identity: options.identity ?? null,
8
+ launcherVisible: options.launcherVisible ?? true
9
+ });
10
+ function usePulsarix(options) {
11
+ const [handle, setHandle] = useState(null);
12
+ const latest = useRef(options);
13
+ latest.current = options;
14
+ const applied = useRef(null);
15
+ const { projectKey, apiBase } = options;
16
+ useEffect(() => {
17
+ let cancelled = false;
18
+ let live;
19
+ import("./index.js").then(({ mount }) => {
20
+ if (cancelled)
21
+ return;
22
+ const { launcherVisible, onError: _onError, ...rest } = latest.current;
23
+ live = mount({ ...rest, identity: rest.identity ?? undefined });
24
+ applied.current = snapshot(latest.current);
25
+ if (launcherVisible === false)
26
+ live.setLauncherVisible(false);
27
+ setHandle(live);
28
+ }).catch((error) => {
29
+ if (cancelled)
30
+ return;
31
+ console.error("[pulsarix] the widget could not be loaded or mounted");
32
+ latest.current.onError?.(error);
33
+ });
34
+ return () => {
35
+ cancelled = true;
36
+ live?.destroy();
37
+ setHandle(null);
38
+ };
39
+ }, [projectKey, apiBase]);
40
+ const { theme, locale, identity, launcherVisible } = options;
41
+ const metadata = JSON.stringify(options.metadata ?? null);
42
+ useEffect(() => {
43
+ const last = applied.current;
44
+ if (!handle || !last)
45
+ return;
46
+ const next = snapshot(latest.current);
47
+ if (next.theme !== last.theme && next.theme)
48
+ handle.setTheme(next.theme);
49
+ if (next.locale !== last.locale && next.locale)
50
+ handle.setLocale(next.locale);
51
+ if (next.metadata !== last.metadata)
52
+ handle.setMetadata(latest.current.metadata ?? null);
53
+ if (next.identity !== last.identity)
54
+ handle.identify(next.identity);
55
+ if (next.launcherVisible !== last.launcherVisible)
56
+ handle.setLauncherVisible(next.launcherVisible);
57
+ applied.current = next;
58
+ }, [handle, theme, locale, metadata, identity, launcherVisible]);
59
+ return handle;
60
+ }
61
+ function PulsarixWidget({ onReady, ...options }) {
62
+ const handle = usePulsarix(options);
63
+ const ready = useRef(onReady);
64
+ ready.current = onReady;
65
+ useEffect(() => {
66
+ if (handle)
67
+ ready.current?.(handle);
68
+ }, [handle]);
69
+ return null;
70
+ }
71
+ export {
72
+ PulsarixWidget,
73
+ usePulsarix
74
+ };
package/dist/server.js CHANGED
@@ -55,6 +55,26 @@ function signPulsarixIdentity(options) {
55
55
  }
56
56
  return token;
57
57
  }
58
+ function pulsarixSettingsFromEnv(env = process.env) {
59
+ const read = (name) => env[name]?.trim() || undefined;
60
+ const projectKey = read("PULSARIX_PROJECT_KEY");
61
+ const identitySecret = read("PULSARIX_IDENTITY_SECRET");
62
+ const apiBase = read("PULSARIX_API_BASE");
63
+ const missing = [
64
+ projectKey ? null : "PULSARIX_PROJECT_KEY",
65
+ identitySecret ? null : "PULSARIX_IDENTITY_SECRET",
66
+ apiBase ? null : "PULSARIX_API_BASE"
67
+ ].filter((name) => name !== null);
68
+ if (!projectKey || !identitySecret || !apiBase) {
69
+ throw new Error(`pulsarixSettingsFromEnv: missing environment variable${missing.length > 1 ? "s" : ""} ${missing.join(", ")}`);
70
+ }
71
+ return {
72
+ projectKey,
73
+ identitySecret,
74
+ apiBase: apiBase.replace(/\/+$/, "")
75
+ };
76
+ }
58
77
  export {
78
+ pulsarixSettingsFromEnv,
59
79
  signPulsarixIdentity
60
80
  };
@@ -0,0 +1,27 @@
1
+ import type { MountOptions, WidgetHandle } from "./mount";
2
+ export type { MountOptions, WidgetHandle } from "./mount";
3
+ export interface PulsarixOptions extends Omit<MountOptions, "identity"> {
4
+ /**
5
+ * The identity token the host's server signed for the signed-in user, or `null` or nothing when
6
+ * signed out. A change calls `identify()`; it never remounts.
7
+ */
8
+ identity?: string | null | undefined;
9
+ /** `false` hides the launcher, `true` shows it again; read at run time, never remounts. */
10
+ launcherVisible?: boolean | undefined;
11
+ /** Called when the widget fails to load or mount (the error is also logged, without values). */
12
+ onError?: ((error: unknown) => void) | undefined;
13
+ }
14
+ /**
15
+ * Mounts the widget once the component is on the client and returns its handle (`null` before
16
+ * that, and on the server). A change of `projectKey` or `apiBase` remounts it; `theme`, `locale`,
17
+ * `metadata`, `identity` and `launcherVisible` are applied to the live widget (no remount, so a
18
+ * report being typed is kept). The other options (`accentColor`, `launcher`, `prefill`, ...) are
19
+ * read at mount.
20
+ */
21
+ export declare function usePulsarix(options: PulsarixOptions): WidgetHandle | null;
22
+ export interface PulsarixWidgetProps extends PulsarixOptions {
23
+ /** Called with the handle once the widget is mounted (and again after a remount). */
24
+ onReady?: (handle: WidgetHandle) => void;
25
+ }
26
+ /** Mounts the widget; renders nothing in the React tree (the widget lives in its own element). */
27
+ export declare function PulsarixWidget({ onReady, ...options }: PulsarixWidgetProps): null;
@@ -20,3 +20,18 @@ export interface SignPulsarixIdentityOptions {
20
20
  * the API would refuse.
21
21
  */
22
22
  export declare function signPulsarixIdentity(options: SignPulsarixIdentityOptions): string;
23
+ /** The three settings a host's server needs, read from its environment. */
24
+ export interface PulsarixSettings {
25
+ /** `PULSARIX_PROJECT_KEY`: the widget key's public key (`pk_…`). Safe to hand to the page. */
26
+ projectKey: string;
27
+ /** `PULSARIX_IDENTITY_SECRET`: the identity secret. Server only, never sent to the page. */
28
+ identitySecret: string;
29
+ /** `PULSARIX_API_BASE`: the origin of the pulsarix host (`https://…`), without a trailing slash. */
30
+ apiBase: string;
31
+ }
32
+ /**
33
+ * Reads `PULSARIX_PROJECT_KEY`, `PULSARIX_IDENTITY_SECRET` and `PULSARIX_API_BASE` from `env`
34
+ * (`process.env` by default). Throws one `Error` naming every variable that is missing or blank,
35
+ * and never includes a value in a message, so the secret cannot reach a log through it.
36
+ */
37
+ export declare function pulsarixSettingsFromEnv(env?: Record<string, string | undefined>): PulsarixSettings;
@@ -53,17 +53,9 @@ origin is the host that served the loader; override it with `data-api-base`.
53
53
 
54
54
  ### npm `mount()`
55
55
 
56
- For an app that installs the package. The package is private on npmjs: point the `@softistx` scope at
57
- npmjs with a read token kept in an environment variable (never committed), as the README's "Install"
58
- shows (`.npmrc` form below), then:
59
-
60
- ```ini
61
- @softistx:registry=https://registry.npmjs.org
62
- //registry.npmjs.org/:_authToken=${NPM_SOFTISTX_READ_TOKEN}
63
- ```
56
+ For an app that installs the package (public on npmjs, no token needed):
64
57
 
65
58
  ```sh
66
- export NPM_SOFTISTX_READ_TOKEN=<your read token>
67
59
  bun add @softistx/pulsarix-widget # or: npm install @softistx/pulsarix-widget
68
60
  ```
69
61
 
@@ -183,7 +175,82 @@ A tab that stays open longer than the token lives gets `pulsarix:error` with
183
175
  Keep the secret in an environment variable on the server. It must never reach a page, a public
184
176
  environment variable, a repository or a log.
185
177
 
186
- ### React Router (loader)
178
+ ### React Router
179
+
180
+ The `@softistx/pulsarix-widget/react` entry mounts the widget from a component. `react` is an optional
181
+ peer: the entry is only needed in a React app, and the script tag and `mount()` do not use it. The entry
182
+ is safe to import during server rendering (it touches neither `window` nor `document`); the widget
183
+ loads on the client, inside an effect.
184
+
185
+ A server loader signs the identity (section 3) and reads the settings from the environment with
186
+ `pulsarixSettingsFromEnv()` (`PULSARIX_PROJECT_KEY`, `PULSARIX_IDENTITY_SECRET`, `PULSARIX_API_BASE`;
187
+ it throws, naming the missing variables and never a value, when one is absent). The component
188
+ mounts the widget once and applies later changes without remounting:
189
+
190
+ ```tsx
191
+ // app/routes/app.tsx. `Route` is React Router's generated type, `requireUser` your session helper.
192
+ import { PulsarixWidget } from "@softistx/pulsarix-widget/react";
193
+ import {
194
+ pulsarixSettingsFromEnv,
195
+ signPulsarixIdentity,
196
+ } from "@softistx/pulsarix-widget/server";
197
+ import { Outlet, useLoaderData } from "react-router";
198
+
199
+ export async function loader({ request }: Route.LoaderArgs) {
200
+ const user = await requireUser(request);
201
+ const { projectKey, identitySecret, apiBase } = pulsarixSettingsFromEnv();
202
+ return {
203
+ projectKey,
204
+ apiBase,
205
+ identity: signPulsarixIdentity({
206
+ secret: identitySecret,
207
+ publicKey: projectKey,
208
+ sub: user.id,
209
+ email: user.email,
210
+ name: user.name,
211
+ }),
212
+ };
213
+ }
214
+
215
+ export default function Layout() {
216
+ const { projectKey, apiBase, identity } = useLoaderData<typeof loader>();
217
+ return (
218
+ <>
219
+ <PulsarixWidget
220
+ projectKey={projectKey}
221
+ apiBase={apiBase}
222
+ identity={identity}
223
+ theme={resolvedMode} // "light" | "dark" | "auto", your own state
224
+ locale={locale} // "en" | "fr"
225
+ metadata={{ org: orgId, plan }}
226
+ />
227
+ <Outlet />
228
+ </>
229
+ );
230
+ }
231
+ ```
232
+
233
+ Only the `projectKey` and the `apiBase` go to the page; the identity secret stays in the loader.
234
+
235
+ | Prop | When it changes |
236
+ | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
237
+ | `projectKey`, `apiBase` | the widget is destroyed and mounted again |
238
+ | `theme`, `locale`, `metadata`, `identity`, `launcherVisible` | applied to the live widget (`setTheme`, `setLocale`, `setMetadata`, `identify`, `setLauncherVisible`); the open dialog and its draft are kept |
239
+ | `accentColor`, `launcher`, `prefill`, `privacyUrl`, ... | read at mount only |
240
+
241
+ `identity` set to `null` (or left out) signs the reporter out. `<PulsarixWidget onReady={(handle) => ...} />`
242
+ reports the handle (`open()`, `on()`, `holdLauncher()`, ...), and `usePulsarix(options)` is the same
243
+ binding as a hook that returns the handle, or `null` until the widget is mounted and on the server:
244
+
245
+ ```tsx
246
+ const widget = usePulsarix({ projectKey, apiBase, launcher: false });
247
+ // <button onClick={() => widget?.open()}>Report a problem</button>
248
+ ```
249
+
250
+ `onError(error)` is called when the widget fails to load or mount (the failure is also logged, without values).
251
+ It is safe in `StrictMode` (the double effect ends with one widget). One widget per page, as for `mount()`.
252
+
253
+ ### React Router (loader, without the component)
187
254
 
188
255
  ```tsx
189
256
  import { signPulsarixIdentity } from "@softistx/pulsarix-widget/server";
@@ -597,7 +664,7 @@ An open dialog is never hidden or closed by it, and `open()` still works while t
597
664
  With the script tag: `window.PulsarixWidget.setLauncherVisible(false)`. `launcher: false` still
598
665
  removes the launcher for good.
599
666
 
600
- The launcher also hides by itself while the host page shows a modal (an element with `aria-modal="true"` or a modal `<dialog>` (`dialog:modal`)), and returns when it closes, so at 360 px it never covers a modal's edge. It does not see modals inside another shadow root. Nothing to call.
667
+ The launcher also hides by itself while the host page shows a modal (an element with `aria-modal="true"`, a modal `<dialog>` (`dialog:modal`), or a shown `role="dialog"` or `role="alertdialog"` such as a Radix Dialog or Sheet, which sets no `aria-modal`), and returns when it closes, so at 360 px it never covers a modal's edge. It does not see modals inside another shadow root. Nothing to call.
601
668
 
602
669
  ### Sticky bottom bars: `holdLauncher()`
603
670
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softistx/pulsarix-widget",
3
- "version": "0.8.4",
3
+ "version": "0.9.1",
4
4
  "type": "module",
5
5
  "description": "Embeddable client-issue intake widget for pulsarix, rendered in a Shadow DOM",
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "publishConfig": {
12
12
  "registry": "https://registry.npmjs.org/",
13
- "access": "restricted"
13
+ "access": "public"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@biomejs/biome": "2.6.9",
@@ -18,7 +18,7 @@
18
18
  "@graphql-codegen/typescript": "^7.0.1",
19
19
  "@graphql-codegen/typescript-operations": "^7.0.3",
20
20
  "@happy-dom/global-registrator": "^21.0.4",
21
- "@softistx/material": "^3.335.1",
21
+ "@softistx/material": "^3.340.0",
22
22
  "@softistx/material-core": "^0.103.2",
23
23
  "@tailwindcss/cli": "^4.3.3",
24
24
  "@testing-library/dom": "^10.4.2",
@@ -35,6 +35,14 @@
35
35
  "tailwindcss": "^4.3.3",
36
36
  "typescript": "^7.0.2"
37
37
  },
38
+ "peerDependencies": {
39
+ "react": ">=18"
40
+ },
41
+ "peerDependenciesMeta": {
42
+ "react": {
43
+ "optional": true
44
+ }
45
+ },
38
46
  "scripts": {
39
47
  "build": "bun scripts/build.ts",
40
48
  "lint": "biome ci",
@@ -65,6 +73,11 @@
65
73
  "import": "./dist/index.js",
66
74
  "default": "./dist/index.js"
67
75
  },
76
+ "./react": {
77
+ "types": "./dist/types/react.d.ts",
78
+ "import": "./dist/react.js",
79
+ "default": "./dist/react.js"
80
+ },
68
81
  "./server": {
69
82
  "types": "./dist/types/server.d.ts",
70
83
  "import": "./dist/server.js",
@@ -78,6 +91,8 @@
78
91
  "dist/types/config.d.ts",
79
92
  "dist/types/element.d.ts",
80
93
  "dist/types/mount.d.ts",
94
+ "dist/react.js",
95
+ "dist/types/react.d.ts",
81
96
  "dist/server.js",
82
97
  "dist/types/server.d.ts",
83
98
  "docs/integration.md"
@@ -1 +0,0 @@
1
- import{ns}from"./index.7gxz6d1f.js";export{ns as createArchitectureServices};
@@ -1 +0,0 @@
1
- import{Qo}from"./index.7gxz6d1f.js";export{Qo as createCynefinServices};