@softistx/pulsarix-widget 0.8.5 → 0.10.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.
Files changed (135) hide show
  1. package/README.md +76 -48
  2. package/dist/chunks/{abnfDiagram-XWFEHMT6.b9yk4x5x.js → abnfDiagram-XWFEHMT6.rxx9wyp3.js} +1 -1
  3. package/dist/chunks/architecture-WOLXFQ4H.hwrxbct0.js +1 -0
  4. package/dist/chunks/architectureDiagram-CSQXQB3N.mrm0pgc0.js +36 -0
  5. package/dist/chunks/{blockDiagram-BEDRHYPZ.bb08b9nt.js → blockDiagram-BEDRHYPZ.f4dfpk7e.js} +11 -11
  6. package/dist/chunks/{c4Diagram-M2UUVUY5.px0epccd.js → c4Diagram-M2UUVUY5.rz43j1my.js} +3 -3
  7. package/dist/chunks/{chat-markdown-CrbWbK1O.k4nmgyey.js → chat-markdown-BSu4FB_l.xgn4yj83.js} +29 -29
  8. package/dist/chunks/{classDiagram-v2-KXABOMEV.f02387t9.js → classDiagram-v2-KXABOMEV.m96cfcad.js} +8 -8
  9. package/dist/chunks/cose-bilkent-JH36ORCC.zz2rwyw6.js +1 -0
  10. package/dist/chunks/cynefin-EF2NZ3EQ.y29bn1cz.js +1 -0
  11. package/dist/chunks/{cynefinDiagram-NJNITYFG.zt7gprt1.js → cynefinDiagram-NJNITYFG.az2k68wq.js} +1 -1
  12. package/dist/chunks/{dagre-KIHZ2IZ3.702bqbr9.js → dagre-KIHZ2IZ3.mgwg8bc4.js} +2 -2
  13. package/dist/chunks/{diagram-7YQZDPLS.m7vf21j6.js → diagram-7YQZDPLS.x8fg6705.js} +2 -2
  14. package/dist/chunks/{diagram-QBROCOUO.33e5hv7x.js → diagram-QBROCOUO.db60dsss.js} +24 -24
  15. package/dist/chunks/{diagram-RJJCUUZO.94k74bz7.js → diagram-RJJCUUZO.a7e9w297.js} +4 -4
  16. package/dist/chunks/{diagram-WERXNKYE.7fe849z6.js → diagram-WERXNKYE.a04f53kd.js} +2 -2
  17. package/dist/chunks/diagram-YHHI257C.v19jhmrh.js +3 -0
  18. package/dist/chunks/{diagram-YR4HJLHV.310x2we2.js → diagram-YR4HJLHV.c5e87gmw.js} +1 -1
  19. package/dist/chunks/{ebnfDiagram-N527522P.a4crteq1.js → ebnfDiagram-N527522P.bjrxfgze.js} +1 -1
  20. package/dist/chunks/editor-shortcuts-dialog-Cz3T8435.5ve4nsaw.js +1 -0
  21. package/dist/chunks/editor.yak1qktd.js +4 -0
  22. package/dist/chunks/{elk-O5DQBFGD.dx61etan.js → elk-O5DQBFGD.1ydp0b7a.js} +13 -13
  23. package/dist/chunks/emoji-picker-00Bw2c2b.gzznrrz5.js +4 -0
  24. package/dist/chunks/{erDiagram-K3K3BIDK.qzqv67zm.js → erDiagram-K3K3BIDK.g171ckq1.js} +8 -8
  25. package/dist/chunks/eventmodeling-K75KTNOO.46qfxqj7.js +1 -0
  26. package/dist/chunks/{flow-diagram-AiM6FiIm.73jr19pb.js → flow-diagram-DGZOc1z1.3gbgbm5m.js} +6 -6
  27. package/dist/chunks/flowDiagram-Z6JWZHQI.f0eaj70g.js +1 -0
  28. package/dist/chunks/{ganttDiagram-3PRQTZWP.xngzb32h.js → ganttDiagram-3PRQTZWP.3b9dh4nr.js} +5 -5
  29. package/dist/chunks/gitGraph-VSP46ZUC.swware7n.js +1 -0
  30. package/dist/chunks/{gitGraphDiagram-VXDFKS5L.1sm36z2q.js → gitGraphDiagram-VXDFKS5L.thyp7vsd.js} +22 -22
  31. package/dist/chunks/{grid-E2QIVN74.76pgtn2n.js → grid-E2QIVN74.entqjpa3.js} +1 -1
  32. package/dist/chunks/illustration-BcaGDjvB.1q9xtmyq.js +1 -0
  33. package/dist/chunks/{index.r0p3fm9f.js → index.0g1t1pjx.js} +1 -1
  34. package/dist/chunks/{index.rfyzb2yv.js → index.35d4zbh8.js} +4 -4
  35. package/dist/chunks/index.5fcbba6e.js +2 -0
  36. package/dist/chunks/{index.7gxz6d1f.js → index.6pzexww5.js} +10 -10
  37. package/dist/chunks/{index.zm5x44tn.js → index.8vaktk8x.js} +1 -1
  38. package/dist/chunks/{index.dnnzjw18.js → index.8zg579vd.js} +2 -2
  39. package/dist/chunks/{index.0k4tbjhp.js → index.9n1y396a.js} +1 -1
  40. package/dist/chunks/{index.8f3x951p.js → index.a3njhfdd.js} +2 -2
  41. package/dist/chunks/{index.a6rz456z.js → index.cw97ff3b.js} +2 -2
  42. package/dist/chunks/{index.fv9af3wd.js → index.d57x7pg9.js} +6 -6
  43. package/dist/chunks/{index.fbeztcp3.js → index.g2ba0pke.js} +2 -2
  44. package/dist/chunks/index.h1xzvasx.js +2 -0
  45. package/dist/chunks/{index.hvdnkr5m.js → index.qr6a02kx.js} +2 -2
  46. package/dist/chunks/index.rkgfxpm3.js +44 -0
  47. package/dist/chunks/index.sw8gvntb.js +2 -0
  48. package/dist/chunks/{index.0e4s8r4m.js → index.v02zf4zg.js} +2 -2
  49. package/dist/chunks/{index.t34t6kpe.js → index.w1516g8q.js} +35 -35
  50. package/dist/chunks/{index.9bf5qrah.js → index.w4emtsqw.js} +2 -2
  51. package/dist/chunks/{index.nsckd1vt.js → index.yhmqh641.js} +2 -2
  52. package/dist/chunks/{index.1d7qpsyx.js → index.zkngte5k.js} +2 -2
  53. package/dist/chunks/{index.a1bxkgd3.js → index.zkx4ryzt.js} +104 -104
  54. package/dist/chunks/info-OHQRW6UA.1er9b42t.js +1 -0
  55. package/dist/chunks/{infoDiagram-EZ3ZOAHP.pfd0fjwn.js → infoDiagram-EZ3ZOAHP.833fvq8n.js} +2 -2
  56. package/dist/chunks/{ishikawaDiagram-S3EKX5GW.h5kjez1x.js → ishikawaDiagram-S3EKX5GW.q3evaw24.js} +5 -5
  57. package/dist/chunks/{journeyDiagram-POQNLL5X.55cqc9p0.js → journeyDiagram-POQNLL5X.9werrmpy.js} +5 -5
  58. package/dist/chunks/{kanban-definition-BH5XI6FM.pkdvda4y.js → kanban-definition-BH5XI6FM.f3ssda0m.js} +7 -7
  59. package/dist/chunks/markup-color-chrome-ykGNUl8y.pcgw4znz.js +1 -0
  60. package/dist/chunks/markup-custom-color-MM-HnrqY.sygnt3gs.js +1 -0
  61. package/dist/chunks/mention-list-6cR5VSPa.x0x55xzp.js +1 -0
  62. package/dist/chunks/{mermaid.core.j7s05j63.js → mermaid.core.5cqab0cw.js} +7 -7
  63. package/dist/chunks/{mindmap-definition-WVAN44T4.x3jbxvft.js → mindmap-definition-WVAN44T4.pjjxgse0.js} +6 -6
  64. package/dist/chunks/packet-JDAUHWVQ.t5jwb2rb.js +1 -0
  65. package/dist/chunks/panel.2vwd6k3h.js +7 -0
  66. package/dist/chunks/{pegDiagram-D4NLKWP3.xq15gqy9.js → pegDiagram-D4NLKWP3.mdacgbzb.js} +1 -1
  67. package/dist/chunks/pie-XZMESJXO.pe88zesw.js +1 -0
  68. package/dist/chunks/pieDiagram-36ENHN4W.fb0d6a9w.js +39 -0
  69. package/dist/chunks/plated-illustration-pTqcYOQg.6b9fm4a7.js +1 -0
  70. package/dist/chunks/{quadrantDiagram-ZQUDMS73.k28g8jpn.js → quadrantDiagram-ZQUDMS73.m5cgqatg.js} +4 -4
  71. package/dist/chunks/radar-ABXABTNO.jtbddwfq.js +1 -0
  72. package/dist/chunks/railroad-I3PHUGI6.kvyt0f9s.js +1 -0
  73. package/dist/chunks/railroad-abnf-LNEFI6M7.ybx0vspg.js +1 -0
  74. package/dist/chunks/railroad-ebnf-DWYD2UWJ.yx4c4enn.js +1 -0
  75. package/dist/chunks/railroad-peg-JR7BVNR7.mb71eyqe.js +1 -0
  76. package/dist/chunks/{railroadDiagram-JIZHGYPL.e7p2vqgg.js → railroadDiagram-JIZHGYPL.w2e1k61e.js} +1 -1
  77. package/dist/chunks/{render-VIF2ZAQL.w5ytncsg.js → render-VIF2ZAQL.exs2rt60.js} +1 -1
  78. package/dist/chunks/{requirementDiagram-AXW2TVFA.arekdz02.js → requirementDiagram-AXW2TVFA.mrxb120d.js} +4 -4
  79. package/dist/chunks/{sankeyDiagram-FBCJTAIF.1d04xcmb.js → sankeyDiagram-FBCJTAIF.csj5n1sg.js} +6 -6
  80. package/dist/chunks/{sequenceDiagram-3LA2ROMG.j4xywwp1.js → sequenceDiagram-3LA2ROMG.73qx1ab4.js} +11 -11
  81. package/dist/chunks/{sizeCapture-2Q2CQKSF.862bnf6p.js → sizeCapture-2Q2CQKSF.vfe8maj3.js} +1 -1
  82. package/dist/chunks/{stateDiagram-v2-ATKHQDJO.xvvtr0y2.js → stateDiagram-v2-ATKHQDJO.h4grfmy4.js} +8 -8
  83. package/dist/chunks/{swimlanes-YQL5WMAO.dtnjb4xt.js → swimlanes-YQL5WMAO.e2y8jam1.js} +1 -1
  84. package/dist/chunks/swimlanesDiagram-UCCPES4V.dtthssd5.js +8 -0
  85. package/dist/chunks/{timeline-definition-7Z437IG3.zfhqzc4r.js → timeline-definition-7Z437IG3.2zxa6hz5.js} +9 -9
  86. package/dist/chunks/treeView-D4JQ5SDB.3kgztv30.js +1 -0
  87. package/dist/chunks/treemap-SAJKECNS.xj47e2ae.js +1 -0
  88. package/dist/chunks/{usecaseDiagram-RDK6N6HP.ewxnyz4c.js → usecaseDiagram-RDK6N6HP.61cdyktj.js} +57 -57
  89. package/dist/chunks/{vennDiagram-SHRQU5PJ.wkzf1f00.js → vennDiagram-SHRQU5PJ.4tspw3rs.js} +7 -7
  90. package/dist/chunks/wardley-7MLQ67FV.pckbr6zr.js +1 -0
  91. package/dist/chunks/{wardleyDiagram-F3OXNVQS.srjfm4nb.js → wardleyDiagram-F3OXNVQS.q2p8tshx.js} +4 -4
  92. package/dist/chunks/{xychartDiagram-GDYJKCDI.xfa2vexk.js → xychartDiagram-GDYJKCDI.69desp9j.js} +5 -5
  93. package/dist/index.js +48 -21
  94. package/dist/react.js +74 -0
  95. package/dist/server.js +20 -0
  96. package/dist/types/config.d.ts +1 -1
  97. package/dist/types/mount.d.ts +1 -1
  98. package/dist/types/react.d.ts +27 -0
  99. package/dist/types/server.d.ts +15 -0
  100. package/docs/integration.md +109 -36
  101. package/package.json +20 -5
  102. package/dist/chunks/architecture-WOLXFQ4H.aft3rkrr.js +0 -1
  103. package/dist/chunks/architectureDiagram-CSQXQB3N.qz18rz0g.js +0 -36
  104. package/dist/chunks/cose-bilkent-JH36ORCC.azq9k24r.js +0 -1
  105. package/dist/chunks/cynefin-EF2NZ3EQ.dk039jny.js +0 -1
  106. package/dist/chunks/diagram-YHHI257C.qjjjfq7w.js +0 -3
  107. package/dist/chunks/editor-shortcuts-dialog-B0ppoiza.x3p4h07t.js +0 -1
  108. package/dist/chunks/editor.arg3zy29.js +0 -4
  109. package/dist/chunks/emoji-picker-CbvQZ2ZL.nst616hd.js +0 -4
  110. package/dist/chunks/eventmodeling-K75KTNOO.gmm1bcak.js +0 -1
  111. package/dist/chunks/flowDiagram-Z6JWZHQI.fzwqg115.js +0 -1
  112. package/dist/chunks/gitGraph-VSP46ZUC.0m8jykgw.js +0 -1
  113. package/dist/chunks/illustration-BOW28wq5.bkz28k1x.js +0 -1
  114. package/dist/chunks/index.32jxrb9b.js +0 -2
  115. package/dist/chunks/index.7k5v3p25.js +0 -2
  116. package/dist/chunks/index.e35b4yh5.js +0 -44
  117. package/dist/chunks/index.wrjdgn4c.js +0 -2
  118. package/dist/chunks/info-OHQRW6UA.e0a85drn.js +0 -1
  119. package/dist/chunks/markup-color-chrome-ykGNUl8y.0ds56d6x.js +0 -1
  120. package/dist/chunks/markup-custom-color-Dgm2hHI7.7darvajx.js +0 -1
  121. package/dist/chunks/mention-list-CkAUzPBG.mtjgmmzb.js +0 -1
  122. package/dist/chunks/packet-JDAUHWVQ.52409p3r.js +0 -1
  123. package/dist/chunks/panel.9tp7gr60.js +0 -7
  124. package/dist/chunks/pie-XZMESJXO.q5kre8cx.js +0 -1
  125. package/dist/chunks/pieDiagram-36ENHN4W.8h0wam54.js +0 -39
  126. package/dist/chunks/plated-illustration-COZYWJ81.xy7ba5mq.js +0 -1
  127. package/dist/chunks/radar-ABXABTNO.yk872k2n.js +0 -1
  128. package/dist/chunks/railroad-I3PHUGI6.9wfa6vs3.js +0 -1
  129. package/dist/chunks/railroad-abnf-LNEFI6M7.70zznk3b.js +0 -1
  130. package/dist/chunks/railroad-ebnf-DWYD2UWJ.4pvdng0p.js +0 -1
  131. package/dist/chunks/railroad-peg-JR7BVNR7.ev15ebp6.js +0 -1
  132. package/dist/chunks/swimlanesDiagram-UCCPES4V.0q8kd5qn.js +0 -8
  133. package/dist/chunks/treeView-D4JQ5SDB.3fzswdjp.js +0 -1
  134. package/dist/chunks/treemap-SAJKECNS.cgh74bhn.js +0 -1
  135. 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
  };
@@ -61,7 +61,7 @@ export declare const METADATA_VALUE_MAX = 512;
61
61
  export declare const METADATA_MAX_BYTES = 2048;
62
62
  /** The attributes the element observes, in their HTML spelling. */
63
63
  export declare const OBSERVED_ATTRIBUTES: readonly ["project-key", "locale", "theme", "launcher", "launcher-side", "launcher-offset", "accent-color", "inherit-theme", "api-base", "mask-text", "attachments", "privacy-url", "prefill-email", "prefill-title", "metadata", "identity"];
64
- /** A launcher offset: a number from 0 to 1 (a fraction of the free height), else the default 0.5. */
64
+ /** A launcher offset: a number from 0 to 1 (a fraction of the free height), else the default 0.72. */
65
65
  export declare function offsetOf(value: string | number | null | undefined): number;
66
66
  /** A hex colour (#rgb or #rrggbb): the only form accepted as a seed. */
67
67
  export declare function isHexColor(value: string | null): value is string;
@@ -16,7 +16,7 @@ export interface MountOptions {
16
16
  /**
17
17
  * The edge tab: `false` for none, `"auto"`, `"pill"` and `"icon"` (kept for compatibility) for the
18
18
  * default one, or `{ side, offset }` for its starting edge (`"right"` default or `"left"`) and
19
- * height (a fraction from 0, top, to 1, bottom; 0.5 default). The reporter can move it along the
19
+ * height (a fraction from 0, top, to 1, bottom; 0.72 default). The reporter can move it along the
20
20
  * edge, and what they chose wins.
21
21
  */
22
22
  launcher?: boolean | LauncherMode | Partial<LauncherPlacement>;
@@ -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()}>New request</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";
@@ -296,24 +363,24 @@ Content-Security-Policy:
296
363
 
297
364
  Script-tag attributes and `init` / `mount` options (all optional except the key):
298
365
 
299
- | Attribute / option | Effect |
300
- | ---------------------------------------------------- | ----------------------------------------------------------------- |
301
- | `data-project-key` / `projectKey` | the public key (required) |
302
- | `data-api-base` / `apiBase` | the pulsarix origin; required on the npm route |
303
- | `data-locale` / `locale` | `en` (default) or `fr` |
304
- | `data-theme` / `theme` | `light`, `dark` or `auto` (default) |
305
- | `data-launcher-side` / `launcher.side` | `right` (default) or `left` (section 11) |
306
- | `data-launcher-offset` / `launcher.offset` | a fraction from 0 (top) to 1 (bottom), `0.5` default (section 11) |
307
- | `data-accent-color` / `accentColor` | a hex seed for the theme |
308
- | `data-inherit-theme="false"` / `inheritTheme: false` | keep the widget's own look (section 9) |
309
- | `target` (`mount()` only) | the element to append the widget to; `document.body` by default |
310
- | `data-launcher` / `launcher` | `false` for none; any other value gives the edge tab (section 11) |
311
- | `data-attachments="false"` | no screenshot and no file controls |
312
- | `data-mask-text="true"` | "Mask the text on the page" starts on |
313
- | `data-privacy-url` / `privacyUrl` | an http(s) link to your privacy page |
314
- | `data-prefill-email`, `data-prefill-title` | starting values of the form |
315
- | `data-identity` / `identity` | the signed token (section 3) |
316
- | `data-metadata` / `metadata` | a JSON object of strings stored with each report |
366
+ | Attribute / option | Effect |
367
+ | ---------------------------------------------------- | ------------------------------------------------------------------ |
368
+ | `data-project-key` / `projectKey` | the public key (required) |
369
+ | `data-api-base` / `apiBase` | the pulsarix origin; required on the npm route |
370
+ | `data-locale` / `locale` | `en` (default) or `fr` |
371
+ | `data-theme` / `theme` | `light`, `dark` or `auto` (default) |
372
+ | `data-launcher-side` / `launcher.side` | `right` (default) or `left` (section 11) |
373
+ | `data-launcher-offset` / `launcher.offset` | a fraction from 0 (top) to 1 (bottom), `0.72` default (section 11) |
374
+ | `data-accent-color` / `accentColor` | a hex seed for the theme |
375
+ | `data-inherit-theme="false"` / `inheritTheme: false` | keep the widget's own look (section 9) |
376
+ | `target` (`mount()` only) | the element to append the widget to; `document.body` by default |
377
+ | `data-launcher` / `launcher` | `false` for none; any other value gives the edge tab (section 11) |
378
+ | `data-attachments="false"` | no screenshot and no file controls |
379
+ | `data-mask-text="true"` | "Mask the text on the page" starts on |
380
+ | `data-privacy-url` / `privacyUrl` | an http(s) link to your privacy page |
381
+ | `data-prefill-email`, `data-prefill-title` | starting values of the form |
382
+ | `data-identity` / `identity` | the signed token (section 3) |
383
+ | `data-metadata` / `metadata` | a JSON object of strings stored with each report |
317
384
 
318
385
  `metadata` carries facts about the session that help triage: at most 20 entries, keys of 64 characters,
319
386
  values of 512, 2 KB in all; the rest is dropped. The keys `capture-N-page` are reserved: the widget
@@ -511,6 +578,8 @@ Rules:
511
578
  64 characters, values of 512, 2 KB in all). A report already sent is not changed.
512
579
  - `setLocale` changes the widget's own strings at once. The built-in labels of `@softistx/material` (the close
513
580
  button, the file list, ...) are read once by its i18n context, so they change when the form is next idle:
581
+ - The impact row shows only when the type is "Report a problem" (bug); changing the type clears it.
582
+ - The form is one compact two-column grid without section headings: title beside the optional e-mail (anonymous reporters), then the type, the impact (bug only) and the description on full rows, then the attachments. The type comes first and words the description ("What happened?", "Your question", "Your idea", or "Your request" with no type). The launcher, its menu entry and the dialog title all read "New request".
514
583
  - On an idle form, the typed fields, the chosen type and impact are kept; files and a
515
584
  screenshot already attached are dropped.
516
585
  - While a report is being sent, on the confirmation screen, or in the "My requests" view, nothing is rebuilt:
@@ -529,25 +598,25 @@ The edge tab that opens the dialog. Two options shape it; each has script-tag at
529
598
 
530
599
  The launcher is an icon button, 44 x 44 px on wide screens, docked flush to the viewport edge and
531
600
  rounded on the content side only. On phones (viewport 600 px or less) it is 24 x 44 px: the mark shrinks to 16 px, there is no peek, and
532
- the hit area is exactly the visible tab. To avoid any overlap, reserve `padding-inline-end` (`-start`
533
- for a left tab) of 24 px up to 600 px and 48 px above.
601
+ the hit area is exactly the visible tab (at rest too: the part of the tab that peeks off screen takes no clicks, and nothing invisible beside it does). The tab floats over the page and hosts reserve no lane for it: it is small, the
602
+ reporter can drag it along the edge, and it never covers an open host dialog or sheet.
534
603
  It wears the pulsarix mark and the unread badge. On wide screens it peeks 6 px less at rest; it slides
535
604
  fully in on hover, focus and while dragged. Its label is a tooltip only
536
- ("Report a problem", with "Drag to move" on a second line): shown on hover or keyboard focus after a short
605
+ ("New request", with "Drag to move" on a second line): shown on hover or keyboard focus after a short
537
606
  delay, hidden while dragging and on screens with no hover. The `launcher` option no longer changes its
538
607
  look: `"auto"`, `"pill"` and `"icon"` are still read so existing embeds keep working, and `false` removes it
539
608
  (open the dialog with `open()`).
540
609
 
541
610
  Without a token the tab opens the report form directly. With a token it opens a small menu beside it
542
- with two items, "Report a problem" and "My requests" (with its unread badge); each opens one
611
+ with two items, "New request" and "My requests" (with its unread badge); each opens one
543
612
  view, never tabs. The tab keeps the localized label as its accessible name and carries the unread
544
- count in it ("Report a problem, 3 unread requests"). It has `aria-expanded`, `aria-controls` and
613
+ count in it ("New request, 3 unread requests"). It has `aria-expanded`, `aria-controls` and
545
614
  `aria-keyshortcuts="Alt+ArrowUp Alt+ArrowDown"`, a visible focus ring, and respects `prefers-reduced-motion`.
546
615
 
547
616
  ### Position: `launcher.side` and `launcher.offset`
548
617
 
549
618
  You choose where the tab starts: the edge (`"right"` default, or `"left"`) and a vertical fraction
550
- `offset` from `0` (top) to `1` (bottom), `0.5` by default. A value outside 0..1 is clamped, junk is the
619
+ `offset` from `0` (top) to `1` (bottom), `0.72` by default (low on the screen, where a host's right-edge controls are less likely). A value outside 0..1 is clamped, junk is the
551
620
  default.
552
621
 
553
622
  ```ts
@@ -577,7 +646,7 @@ Alt+ArrowUp and Alt+ArrowDown may clash with an assistive technology or a window
577
646
  `--pulsarix-launcher-bottom` / `--pulsarix-launcher-side` are removed. Use `launcher.side` and
578
647
  `launcher.offset` (a fraction of the height, no longer pixels or CSS lengths). The tab is flush to the
579
648
  edge, so there is no side distance. A host that reserved room for the round button can drop that
580
- reserve. To clear a sticky bar, use `holdLauncher()` (below). The `Position` and `LauncherOffset`
649
+ reserve (no lane is needed), including a `pe-6 min-[601px]:pe-12` lane added for the earlier tab. To clear a sticky bar, use `holdLauncher()` (below). The `Position` and `LauncherOffset`
581
650
  types are replaced by `LauncherSide` and `LauncherPlacement`.
582
651
 
583
652
  ### Visibility: `setLauncherVisible(visible)`
@@ -597,7 +666,11 @@ An open dialog is never hidden or closed by it, and `open()` still works while t
597
666
  With the script tag: `window.PulsarixWidget.setLauncherVisible(false)`. `launcher: false` still
598
667
  removes the launcher for good.
599
668
 
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.
669
+ 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.
670
+
671
+ The tab follows the host live, including a dialog opened or closed only by a `class` or `style` change. An always-visible, non-modal `role="dialog"` of the host (a chat panel, a banner, a popover) keeps the tab hidden for as
672
+ long as it is shown. Give such a panel `role="region"` or `role="complementary"` instead, or open the widget
673
+ yourself with `open()` while the tab is hidden.
601
674
 
602
675
  ### Sticky bottom bars: `holdLauncher()`
603
676
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softistx/pulsarix-widget",
3
- "version": "0.8.5",
3
+ "version": "0.10.0",
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,8 +18,8 @@
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",
22
- "@softistx/material-core": "^0.103.2",
21
+ "@softistx/material": "^3.344.0",
22
+ "@softistx/material-core": "^0.103.3",
23
23
  "@tailwindcss/cli": "^4.3.3",
24
24
  "@testing-library/dom": "^10.4.2",
25
25
  "@testing-library/react": "^16.3.3",
@@ -28,13 +28,21 @@
28
28
  "@types/react": "^19.3.3",
29
29
  "@types/react-dom": "^19.3.0",
30
30
  "graphql": "^17.1.0",
31
- "playwright-core": "^1.65.1",
31
+ "playwright-core": "^1.65.2",
32
32
  "react": "^19.3.1",
33
33
  "react-dom": "^19.3.1",
34
34
  "react-hook-form": "^7.92.0",
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};