@softistx/pulsarix-widget 0.3.2 → 0.4.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.
@@ -0,0 +1,475 @@
1
+ # Integrating the pulsarix widget in a host app
2
+
3
+ This guide takes a host app (the site or product that embeds the widget) from nothing to reports
4
+ and "My requests" working. Reference for every option and event: the [README](../README.md).
5
+
6
+ 1. [Get a project and a widget key](#1-get-a-project-and-a-widget-key)
7
+ 2. [Add the widget](#2-add-the-widget)
8
+ 3. [Identify your signed-in users](#3-identify-your-signed-in-users)
9
+ 4. [Content Security Policy](#4-content-security-policy)
10
+ 5. [Options and metadata](#5-options-and-metadata)
11
+ 6. [Events](#6-events)
12
+ 7. [Local development origins](#7-local-development-origins)
13
+ 8. [Troubleshooting](#8-troubleshooting)
14
+ 9. [Inheriting the host app's theme](#9-inheriting-the-host-apps-theme)
15
+ 10. [Changing theme, locale and metadata at run time](#10-changing-theme-locale-and-metadata-at-run-time)
16
+ 11. [The launcher: look, position and visibility](#11-the-launcher-look-position-and-visibility)
17
+
18
+ ## 1. Get a project and a widget key
19
+
20
+ In pulsarix, create (or open) the project that will receive the reports, then add a widget key to it.
21
+ A key has:
22
+
23
+ - a **public key**, `pk_live_…`: it goes in your page and is not secret;
24
+ - **allowedOrigins**: the exact origins that may send reports with that key, one per line, each
25
+ `https://host[:port]` (plain `http://` only for `localhost`, `127.0.0.1` and `[::1]`). No path, query,
26
+ fragment, credentials or wildcard; `https://app.example.com`, never `https://app.example.com/page`
27
+ or `https://*.example.com`. A request from any other origin, or with no `Origin`, is refused;
28
+ - an optional **identity secret** for signed-in users (section 3): in the key's "Signed-in users" card,
29
+ press "Generate secret". It is **shown once**: copy it into your server's environment right away
30
+ (for example `PULSARIX_IDENTITY_SECRET`). It cannot be read again; "Regenerate" makes a new one and
31
+ the old one stops working at once.
32
+
33
+ The key also has a switch (disabled keys refuse everything) and a "Screenshots and files" switch.
34
+
35
+ ## 2. Add the widget
36
+
37
+ ### Script tag
38
+
39
+ ```html
40
+ <script src="https://<pulsarix-host>/widget/v1/loader.js" async
41
+ data-project-key="pk_live_xxx"></script>
42
+ ```
43
+
44
+ The loader is tiny (at most 5 KB gzipped) and loads the widget bundle on first use. The widget's API
45
+ origin is the host that served the loader; override it with `data-api-base`.
46
+
47
+ ### npm `mount()`
48
+
49
+ For an app that installs the package (see the README's "Install" for the read token):
50
+
51
+ ```ts
52
+ import { mount } from "@softistx/pulsarix-widget";
53
+
54
+ const widget = mount({
55
+ projectKey: "pk_live_xxx",
56
+ apiBase: "https://<pulsarix-host>", // required on the npm route
57
+ locale: "fr",
58
+ });
59
+ ```
60
+
61
+ The module is browser-only: in an SSR framework import it on the client, inside an effect:
62
+
63
+ ```tsx
64
+ useEffect(() => {
65
+ let widget: { destroy(): void } | undefined;
66
+ import("@softistx/pulsarix-widget").then(({ mount }) => {
67
+ widget = mount({ projectKey, apiBase });
68
+ });
69
+ return () => widget?.destroy();
70
+ }, [projectKey, apiBase]);
71
+ ```
72
+
73
+ One widget per page: use the script tag or `mount()`, not both.
74
+
75
+ ## 3. Identify your signed-in users
76
+
77
+ Without an identity the widget is the anonymous report form. With one, reports are filed under the
78
+ reporter, who also gets a "My requests" tab (threads, replies, unread counts, "Delete my data").
79
+
80
+ Your server signs a short-lived token for the signed-in user with the key's identity secret; the browser
81
+ only carries the token. The helper does the signing:
82
+
83
+ ```ts
84
+ // server only
85
+ import { signPulsarixIdentity } from "@softistx/pulsarix-widget/server";
86
+
87
+ export function pulsarixTokenFor(user: {
88
+ id: string;
89
+ email: string;
90
+ name: string;
91
+ }) {
92
+ return signPulsarixIdentity({
93
+ secret: process.env.PULSARIX_IDENTITY_SECRET as string,
94
+ publicKey: process.env.PULSARIX_PUBLIC_KEY as string, // pk_live_xxx
95
+ sub: user.id,
96
+ email: user.email,
97
+ name: user.name,
98
+ ttlSeconds: 3600, // 1 hour (the default); 24 hours at most
99
+ });
100
+ }
101
+ ```
102
+
103
+ Import the signer only in server code (a loader, or a `*.server.ts` file), never in the browser. Then hand
104
+ the token to the widget, and clear it at sign-out. In a strict-TypeScript host the script tag's global is
105
+ not typed: declare it once with
106
+ `declare global { interface Window { PulsarixWidget?: { identify(token: string | null): void } } }`,
107
+ or use the npm route's typed handle:
108
+
109
+ ```ts
110
+ // browser, after sign-in or on each page load (script tag)
111
+ window.PulsarixWidget.identify(token);
112
+
113
+ // at sign-out
114
+ window.PulsarixWidget.identify(null);
115
+
116
+ // npm route: the handle mount() returned
117
+ widget.identify(token);
118
+ ```
119
+
120
+ or give it at the start: `data-identity="<token>"` on the script tag, or `identity` in `init` / `mount`.
121
+
122
+ Rules of the token (the helper enforces them and throws otherwise):
123
+
124
+ | Part | Rule |
125
+ | ----------- | ------------------------------------------------------------------------------ |
126
+ | `sub` | 1 to 200 characters, your stable user id; pulsarix keeps only a digest per key |
127
+ | `email` | optional, a valid address, 254 characters at most |
128
+ | `name` | optional, trimmed, 100 characters at most |
129
+ | `aud` | the key's public key (the helper's `publicKey`) |
130
+ | `iat`/`exp` | integer seconds; a life of 24 hours at most, 1 hour recommended |
131
+ | whole token | 2 048 characters at most |
132
+
133
+ The token is `<payload>.<signature>`, both base64url without padding; the signature is the
134
+ HMAC-SHA256 of the payload text, keyed with the secret **as the raw string** (not base64url-decoded).
135
+ The API allows 5 minutes of clock skew between your server and itself.
136
+
137
+ **Re-sign before expiry.** A token is not renewed by the widget. Sign a new one on each request that
138
+ renders a page, or from a small endpoint your page calls every half life, and call `identify(newToken)`.
139
+ A tab that stays open longer than the token lives gets `pulsarix:error` with
140
+ `intake.errors.identity-expired` (or `identity-invalid`) until you do.
141
+
142
+ Keep the secret in an environment variable on the server. It must never reach a page, a public
143
+ environment variable, a repository or a log.
144
+
145
+ ### React Router (loader)
146
+
147
+ ```tsx
148
+ import { signPulsarixIdentity } from "@softistx/pulsarix-widget/server";
149
+ import { Outlet, useLoaderData } from "react-router";
150
+ import { useEffect } from "react";
151
+
152
+ export async function loader({ request }: Route.LoaderArgs) {
153
+ const user = await requireUser(request);
154
+ return {
155
+ pulsarixIdentity: signPulsarixIdentity({
156
+ secret: process.env.PULSARIX_IDENTITY_SECRET as string,
157
+ publicKey: process.env.PULSARIX_PUBLIC_KEY as string,
158
+ sub: user.id,
159
+ email: user.email,
160
+ name: user.name,
161
+ }),
162
+ };
163
+ }
164
+
165
+ export default function Layout() {
166
+ const { pulsarixIdentity } = useLoaderData<typeof loader>();
167
+ useEffect(() => {
168
+ window.PulsarixWidget?.identify(pulsarixIdentity);
169
+ }, [pulsarixIdentity]);
170
+ return <Outlet />;
171
+ }
172
+ ```
173
+
174
+ A token given with `identify()` stays in the widget's memory; one in `data-identity` is an attribute of
175
+ the element and visible in the DOM, so prefer `identify()`.
176
+
177
+ ## 4. Content Security Policy
178
+
179
+ Allow the pulsarix host in `script-src` (the loader and the bundle) and in `connect-src` (the API calls,
180
+ the file uploads and the live stream of an open thread; the same origin for all three):
181
+
182
+ ```
183
+ Content-Security-Policy:
184
+ script-src 'self' 'nonce-<per-request>' https://<pulsarix-host>;
185
+ connect-src 'self' https://<pulsarix-host>;
186
+ ```
187
+
188
+ - Nothing else is needed for images or capture: thumbnails and the screenshot editor draw on canvases,
189
+ so there is no `img-src blob:`. Screen capture needs `display-capture` in your `Permissions-Policy`
190
+ (uploading an image works without it).
191
+ - The widget's styles are adopted into its shadow root: no `style-src 'unsafe-inline'`. The requests
192
+ thread injects one `<style>` element; under a strict `style-src` give your page a nonce, which the
193
+ widget reads from a `nonce` attribute on a `style` or `script` element or from this tag:
194
+
195
+ ```html
196
+ <meta property="csp-nonce" content="<per-request nonce>">
197
+ ```
198
+
199
+ ## 5. Options and metadata
200
+
201
+ Script-tag attributes and `init` / `mount` options (all optional except the key):
202
+
203
+ | Attribute / option | Effect |
204
+ | --------------------------------------------------- | ------------------------------------------------------------------ |
205
+ | `data-project-key` / `projectKey` | the public key (required) |
206
+ | `data-api-base` / `apiBase` | the pulsarix origin; required on the npm route |
207
+ | `data-locale` / `locale` | `en` (default) or `fr` |
208
+ | `data-theme` / `theme` | `light`, `dark` or `auto` (default) |
209
+ | `data-position` / `position` | `bottom-right` (default) or `bottom-left` |
210
+ | `data-accent-color` / `accentColor` | a hex seed for the theme |
211
+ | `data-launcher` / `launcher` | `auto` (default), `pill`, `icon`, or `false` for none (section 11) |
212
+ | `data-offset-bottom`, `data-offset-side` / `offset` | launcher distance from the bottom and its side (section 11) |
213
+ | `data-attachments="false"` | no screenshot and no file controls |
214
+ | `data-mask-text="true"` | "Mask the text on the page" starts on |
215
+ | `data-privacy-url` / `privacyUrl` | an http(s) link to your privacy page |
216
+ | `data-prefill-email`, `data-prefill-title` | starting values of the form |
217
+ | `data-identity` / `identity` | the signed token (section 3) |
218
+ | `data-metadata` / `metadata` | a JSON object of strings stored with each report |
219
+
220
+ `metadata` carries facts about the session that help triage: at most 20 entries, keys of 64 characters,
221
+ values of 512, 2 KB in all; the rest is dropped.
222
+
223
+ ```html
224
+ <script src="https://<pulsarix-host>/widget/v1/loader.js" async
225
+ data-project-key="pk_live_xxx"
226
+ data-locale="fr"
227
+ data-metadata='{"plan":"pro","build":"2026.11.3"}'></script>
228
+ ```
229
+
230
+ ```ts
231
+ PulsarixWidget.init({
232
+ projectKey: "pk_live_xxx",
233
+ metadata: { plan: "pro", build: "2026.11.3" },
234
+ prefill: { email: user.email },
235
+ });
236
+ ```
237
+
238
+ The page address is sent without its query or fragment.
239
+
240
+ ## 6. Events
241
+
242
+ Heard on the element and with `on(name, callback)`, which returns the function that unsubscribes:
243
+
244
+ | Event | `detail` | When |
245
+ | ----------------- | --------------------- | ------------------------------------------------------------------------------ |
246
+ | `pulsarix:ready` | none | the widget is mounted (asynchronous) |
247
+ | `pulsarix:open` | none | the dialog opened |
248
+ | `pulsarix:close` | none | the dialog closed |
249
+ | `pulsarix:submit` | `{ reportId, files }` | a report was sent |
250
+ | `pulsarix:reply` | `{ requestId }` | the team replied to one of the reporter's requests |
251
+ | `pulsarix:unread` | `{ count }` | the reporter's unread replies changed |
252
+ | `pulsarix:erase` | `{ requests }` | the reporter erased their data |
253
+ | `pulsarix:error` | `{ code }` | a failure; the API's `intake.errors.*`, `network`, `config` or `http-<status>` |
254
+
255
+ ```ts
256
+ const off = PulsarixWidget.on("pulsarix:submit", (e) =>
257
+ analytics.track("report", e.detail.reportId),
258
+ );
259
+ PulsarixWidget.on("pulsarix:error", (e) =>
260
+ console.warn("pulsarix", e.detail.code),
261
+ );
262
+ ```
263
+
264
+ ## 7. Local development origins
265
+
266
+ A key only accepts the origins on its allow-list, so list the one your dev server uses, with its port:
267
+
268
+ ```
269
+ https://app.example.com
270
+ http://localhost:5173
271
+ http://127.0.0.1:5173
272
+ ```
273
+
274
+ Plain `http` is accepted for `localhost`, `127.0.0.1` and `[::1]` only; any other dev host (a LAN
275
+ address, `*.local`) needs `https`. Use a separate key for development and production so a dev origin
276
+ never sits on the production key.
277
+
278
+ ## 8. Troubleshooting
279
+
280
+ | Symptom or code | Cause | Fix |
281
+ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
282
+ | `intake.errors.unknown-key` (404), `http-404` | the public key is mistyped, revoked, or not a key | copy the key again from the project |
283
+ | `intake.errors.origin-not-allowed` (403) | the page's origin is not on the key's `allowedOrigins`, or the request has no `Origin` | add the exact origin (scheme, host, port; no path); see section 7 |
284
+ | `network` with no console message from the API | the browser hid a CORS refusal: the origin is not allowed, or the key is unknown | check the browser's network tab, then `allowedOrigins`; the origin must match exactly, `www.` and ports included |
285
+ | `intake.errors.key-disabled` (403) | the key's switch is off | switch it on in the project |
286
+ | `intake.errors.identity-invalid` (401) | the token is forged, signed with another secret, for another key (`aud`), not yet valid (clock), older than its `exp`, longer than 24 hours, over 2 048 characters, or the key has no identity secret. The API gives one answer for all of these | sign with `signPulsarixIdentity` using the key's current secret and its own public key; check the server clock; generate a secret if the key has none; regenerate invalidates every older token |
287
+ | `intake.errors.identity-expired` | an open live thread outlived its token | sign a new token and call `identify(newToken)`; re-sign every half life |
288
+ | `intake.errors.too-many-requests` (429) | a rate limit: reports per address, per key, per e-mail, per identified reporter, or reads | wait the time the message gives (`retryAfter`); do not retry in a loop |
289
+ | `intake.errors.too-fast` (400) | the form was sent less than 3 seconds after opening | the widget waits it out; only a script that posts the form hits it |
290
+ | `intake.errors.key-not-found` (404), `intake.errors.not-found` (404) | the key or the request no longer exists | check the key; refresh the list |
291
+ | `intake.errors.file-unsupported-type` (415), `file-undecodable` (422), `file-too-large` (413), `file-too-many-pixels` (422), `too-many-files` (400), `files-too-large` (413) | an attached file the API refuses (PNG, JPEG, WebP or PDF; 5 MB each, 12 MB and 3 files per report, 25 megapixels) | the widget checks these first and shows the reason; attach a smaller or supported file |
292
+ | `intake.errors.ticket-invalid`, `ticket-expired`, `ticket-used`, `upload-mismatch`, `quarantine-full` | an upload ticket is damaged, older than 15 minutes, already used, or the organisation's quarantine is full | send the report again; if it persists, tell the project's owners |
293
+ | `intake.errors.request-declined` (409), `reopen-expired` (409) | a declined request is read-only; a request resolved over 30 days ago cannot be reopened | open a new request |
294
+ | `intake.errors.attachments-disabled` (403) | the key's "Screenshots and files" switch is off | switch it on, or set `data-attachments="false"` |
295
+ | `config` | no project key, or no `apiBase` on the npm route | give both |
296
+ | `intake.errors.unavailable` (503) | the service cannot check its limits | retry shortly |
297
+ | `signPulsarixIdentity: ... must be ...` | an option the API would refuse | fix the named option; the message says which |
298
+ | Blocked by CSP in the console | the pulsarix host is missing from `script-src` or `connect-src`, or a strict `style-src` has no nonce | section 4 |
299
+ | `identify()` seems ignored | the token is malformed (anything that is not `<payload>.<signature>` is dropped) | pass the string `signPulsarixIdentity` returned, unchanged |
300
+
301
+ ## 9. Inheriting the host app's theme
302
+
303
+ When the host app is built on `@softistx/material`, the widget wears the host's theme (its
304
+ colours, radius and light or dark mode) instead of its own `lavande` one, and follows the host
305
+ when the user changes theme. Nothing to configure: `inheritTheme` is `true` by default.
306
+
307
+ ```ts
308
+ mount({ projectKey: "pk_live_xxx", apiBase: "https://pulsarix.example.com" });
309
+ // the host's theme picker, dark mode and primary now apply to the dialog
310
+
311
+ mount({ projectKey: "pk_live_xxx", inheritTheme: false }); // the widget's own look, as before
312
+ ```
313
+
314
+ Script tag: `data-inherit-theme="false"`. Element attribute: `inherit-theme="false"`.
315
+
316
+ ### How it works
317
+
318
+ The widget lives in a shadow root and declares its own tokens there, so the page's custom
319
+ properties cannot reach it by plain CSS inheritance. Instead, the widget reads the host's tokens
320
+ from `getComputedStyle(document.documentElement)` and sets the valid ones on its own root as
321
+ inline custom properties:
322
+
323
+ - **Which tokens**: the literal colours of the built-in theme (`--primary`, `--background`,
324
+ `--foreground`, `--card`, `--border`, `--muted`, `--error`, ...), `--radius` and the few
325
+ percentage tokens. Tokens the theme derives from others (`--ground`, `--primary-text`, ...)
326
+ are recomputed by the widget from the inherited ones. Fonts are never inherited: the widget
327
+ keeps the system font stack.
328
+ - **Fallback**: a token that is missing, empty or not valid (a colour the browser rejects, a
329
+ length that is not `px` or `rem`) keeps the widget's own value. A host that is not on
330
+ `@softistx/material`, or whose tokens are bare HSL triplets (`222 47% 11%`), therefore looks
331
+ exactly as before. `rem` radii are converted to `px` with the host's root font size.
332
+ - **Light and dark**: the inherited values are the host's current mode's, so the widget's scheme
333
+ follows the host's: its `dark` / `light` class on `<html>`, else its `color-scheme`. When the
334
+ host says neither, the `theme` option decides as before.
335
+ - **`accentColor` wins**: with an explicit `accentColor`, the host's primary family
336
+ (`--primary`, `--primary-foreground`, `--inverse-primary*`) is not inherited; the other tokens
337
+ still are.
338
+ - **Follows the host**: a `MutationObserver` on `<html>` (`class`, `style`, `data-theme`,
339
+ `data-mode`, `data-nxgt-theme`, `data-color-scheme`) and the `prefers-color-scheme` media query
340
+ re-read the tokens (`data-theme` and `data-mode` only trigger a re-read; they never decide
341
+ dark or light). It stops when the widget is removed (`destroy()`).
342
+
343
+ ### Limits
344
+
345
+ - The tokens are read from `<html>`. A host that scopes its theme to a wrapper element (not
346
+ `<html>`) is not read: the widget keeps its own look.
347
+ - Custom properties set at run time through a host's stylesheet swap (a new `<link>`) without an
348
+ attribute change on `<html>` are picked up at the next attribute change or scheme change.
349
+ - Pairing: the inherited colours are the host's own, so the widget is as readable as the host.
350
+ Mixing a few inherited tokens with the widget's own for the rest (a partial host theme) can
351
+ lower contrast; set `inheritTheme: false` when the host only defines part of the palette.
352
+
353
+ ## 10. Changing theme, locale and metadata at run time
354
+
355
+ Part of the host integration: the host switches its organisation, language or light/dark mode while a
356
+ reporter may have a dialog open. Never remount the widget for that (a remount drops the report being typed);
357
+ use the setters on the mount handle or on the script-tag global.
358
+
359
+ ```ts
360
+ const widget = mount({ projectKey, apiBase, theme: "light", locale: "en" });
361
+
362
+ // the app's mode changed (resolve "Système" yourself, from the app's own state)
363
+ widget.setTheme(resolvedMode); // "light" | "dark" | "auto"
364
+
365
+ // the app's language changed
366
+ widget.setLocale("fr"); // "en" | "fr"
367
+
368
+ // the app's organisation changed: the next report carries these entries
369
+ widget.setMetadata({ org: orgId, plan });
370
+ widget.setMetadata(null); // none
371
+ ```
372
+
373
+ ```js
374
+ PulsarixWidget.setTheme("dark");
375
+ PulsarixWidget.setLocale("fr");
376
+ PulsarixWidget.setMetadata({ org: "acme" });
377
+ ```
378
+
379
+ | Call | Effect | Kept |
380
+ | ---------------------- | ----------------------------------------------------------- | ----------------------------- |
381
+ | `setTheme(theme)` | the widget's own light or dark mode, at once | the open dialog and its draft |
382
+ | `setLocale(locale)` | the strings re-render in that language | the open dialog and its draft |
383
+ | `setMetadata(entries)` | replaces the metadata of the next report (`null` clears it) | the open dialog and its draft |
384
+
385
+ Rules:
386
+
387
+ - `"light"` and `"dark"` are applied exactly. `"auto"` follows the operating system's
388
+ `prefers-color-scheme`, never the host page's class or attribute. A host with its own mode switch passes the
389
+ resolved `"light"` or `"dark"` to `setTheme` on each change.
390
+ - `setTheme` is independent of `inheritTheme` (section 9). With `inheritTheme`, the widget follows the host's
391
+ mode by default, and a `theme` given at mount or written later as the `theme` attribute wins over it; the
392
+ host mode counts only when the host provides tokens. `setTheme("light")` or `setTheme("dark")` wins over the
393
+ host's mode until the `theme` attribute is written again (that gives the mode back to the host);
394
+ `setTheme("auto")` gives it back at once. An inherited token still wins for its colour value.
395
+ - `setTheme` only sets the widget's own mode. The accent (`accentColor`) is a mount option and does not change.
396
+ - `setMetadata` replaces; it does not merge. The limits are those of `metadata` at mount (20 entries, keys of
397
+ 64 characters, values of 512, 2 KB in all). A report already sent is not changed.
398
+ - `setLocale` changes the widget's own strings at once. The built-in labels of `@softistx/material` (the close
399
+ button, the file list, ...) are read once by its i18n context, so they change when the form is next idle:
400
+ - On an idle form, the typed fields, the chosen type and impact and the selected tab are kept; files and a
401
+ screenshot already attached are dropped.
402
+ - While a report is being sent, on the confirmation screen, or on the "My requests" tab, nothing is rebuilt:
403
+ those built-in labels switch when the reporter returns to the form (or the dialog closes), and no
404
+ attachment is lost.
405
+ - `setTheme` and `setMetadata` drop nothing.
406
+ - An unsupported theme or locale is ignored.
407
+ - Calls before the script-tag bundle has loaded are queued, replayed in order; a repeated call to the same
408
+ setter replaces the earlier one, so only the last `setTheme`, `setLocale` and `setMetadata` run.
409
+
410
+ ## 11. The launcher: look, position and visibility
411
+
412
+ The floating button that opens the dialog. Three options shape it; each has a script-tag
413
+ attribute and a `mount()` option.
414
+
415
+ ### Look: `launcher`
416
+
417
+ | Value | Result |
418
+ | ------------------ | --------------------------------------------------------------------------------------------------------------- |
419
+ | `"auto"` (default) | The icon below 640 px of viewport width, the text pill from 640 px up. Live: it follows a resize or a rotation. |
420
+ | `"pill"` | Always the text pill (the 0.3 look). |
421
+ | `"icon"` | Always a 48 px round button with a speech-bubble icon. |
422
+ | `false` | No launcher; open the dialog with `open()`. |
423
+
424
+ The icon button keeps the localized label as its accessible name (and as its `title`, so a
425
+ pointer hover shows it), carries the unread count in that name, and shows a visible focus ring.
426
+
427
+ ```html
428
+ <script src="https://<pulsarix-host>/widget/v1/loader.js" async
429
+ data-project-key="pk_live_xxx" data-launcher="icon"></script>
430
+ ```
431
+
432
+ ```ts
433
+ mount({ projectKey: "pk_live_xxx", launcher: "auto" });
434
+ ```
435
+
436
+ ### Offset: `offset` and the CSS custom properties
437
+
438
+ The launcher sits 16 px from the bottom and from its side, plus the device's safe area
439
+ (`env(safe-area-inset-bottom)`) at the bottom. Move it to clear a sticky action bar:
440
+
441
+ ```ts
442
+ mount({ projectKey: "pk_live_xxx", offset: { bottom: 88, side: "1.5rem" } });
443
+ ```
444
+
445
+ ```html
446
+ <script ... data-offset-bottom="88" data-offset-side="1.5rem"></script>
447
+ ```
448
+
449
+ A number is pixels; a string is any CSS length (`"2rem"`, `"calc(var(--bar-height) + 8px)"`,
450
+ `"env(...)"`). Negative values and anything that is not a length are ignored. The option sets two custom
451
+ properties on the `<pulsarix-widget>` element, which a host can also set in its own stylesheet (for example
452
+ from a media query, or following the height of its bar); the widget only ever removes a property it set itself:
453
+
454
+ ```css
455
+ pulsarix-widget {
456
+ --pulsarix-launcher-bottom: 88px;
457
+ --pulsarix-launcher-side: 24px;
458
+ }
459
+ ```
460
+
461
+ `side` is the distance from the edge named by `position` (`bottom-right` by default).
462
+
463
+ ### Visibility: `setLauncherVisible(visible)`
464
+
465
+ Hides or shows the launcher only, for a screen where the button is in the way:
466
+
467
+ ```ts
468
+ const widget = mount({ projectKey: "pk_live_xxx" });
469
+ widget.setLauncherVisible(false); // on the checkout step
470
+ widget.setLauncherVisible(true);
471
+ ```
472
+
473
+ An open dialog is never hidden or closed by it, and `open()` still works while the launcher is hidden.
474
+ With the script tag: `window.PulsarixWidget.setLauncherVisible(false)`. `launcher: false` still
475
+ removes the launcher for good.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softistx/pulsarix-widget",
3
- "version": "0.3.2",
3
+ "version": "0.4.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,21 +10,25 @@
10
10
  },
11
11
  "publishConfig": {
12
12
  "registry": "https://registry.npmjs.org/",
13
- "access": "public"
13
+ "access": "restricted"
14
14
  },
15
15
  "devDependencies": {
16
- "@biomejs/biome": "2.5.15",
16
+ "@biomejs/biome": "2.6.8",
17
+ "@graphql-codegen/cli": "^8.0.0",
18
+ "@graphql-codegen/typescript": "^7.0.1",
19
+ "@graphql-codegen/typescript-operations": "^7.0.1",
17
20
  "@happy-dom/global-registrator": "^21.0.4",
18
- "@softistx/material": "^3.252.0",
19
- "@softistx/material-core": "^0.95.1",
21
+ "@softistx/material": "^3.264.0",
22
+ "@softistx/material-core": "^0.96.1",
20
23
  "@tailwindcss/cli": "^4.3.3",
21
24
  "@testing-library/dom": "^10.4.2",
22
25
  "@testing-library/react": "^16.3.3",
23
- "@testing-library/user-event": "^14.6.9",
24
- "@types/bun": "^1.4.4",
26
+ "@testing-library/user-event": "^14.6.13",
27
+ "@types/bun": "^1.4.5",
25
28
  "@types/react": "^19.3.0",
26
29
  "@types/react-dom": "^19.3.0",
27
- "playwright-core": "^1.64.1",
30
+ "graphql": "^17.1.0",
31
+ "playwright-core": "^1.65.1",
28
32
  "react": "^19.3.1",
29
33
  "react-dom": "^19.3.1",
30
34
  "react-hook-form": "^7.92.0",
@@ -38,11 +42,17 @@
38
42
  "typecheck": "bun check",
39
43
  "test": "bun test",
40
44
  "size": "bun scripts/check-size.ts",
45
+ "check:deps": "bun scripts/check-deps.ts",
46
+ "generate": "bun scripts/generate.ts",
47
+ "generate:check": "bun scripts/generate.ts --check",
48
+ "schema:sync": "bun scripts/schema-sync.ts",
49
+ "schema:check": "bun scripts/schema-sync.ts --check",
41
50
  "test:browser": "bun scripts/leak-test.ts && bun scripts/screenshot-test.ts && bun scripts/files-test.ts && bun scripts/thread-test.ts && bun scripts/privacy-test.ts",
42
51
  "fixture": "bun scripts/serve-fixture.ts",
43
- "verify": "bun run lint && bun run build && bun run typecheck && bun run test && bun run size",
52
+ "verify": "bun run lint && bun run schema:check && bun run generate:check && bun run build && bun run typecheck && bun run test && bun run check:deps && bun run size",
44
53
  "release": "bun scripts/publish.ts",
45
54
  "capture": "bun scripts/capture.ts",
55
+ "capture:theme": "bun scripts/capture-theme.ts",
46
56
  "capture:requests": "bun scripts/capture-requests.ts",
47
57
  "capture:thread": "bun scripts/capture-thread.ts",
48
58
  "capture:privacy": "bun scripts/capture-privacy.ts"
@@ -54,13 +64,22 @@
54
64
  "types": "./dist/types/index.d.ts",
55
65
  "import": "./dist/index.js",
56
66
  "default": "./dist/index.js"
67
+ },
68
+ "./server": {
69
+ "types": "./dist/types/server.d.ts",
70
+ "import": "./dist/server.js",
71
+ "default": "./dist/server.js"
57
72
  }
58
73
  },
59
74
  "files": [
60
75
  "dist/index.js",
61
76
  "dist/types/index.d.ts",
62
77
  "dist/types/config.d.ts",
63
- "dist/types/element.d.ts"
78
+ "dist/types/element.d.ts",
79
+ "dist/types/mount.d.ts",
80
+ "dist/server.js",
81
+ "dist/types/server.d.ts",
82
+ "docs/integration.md"
64
83
  ],
65
84
  "types": "./dist/types/index.d.ts",
66
85
  "sideEffects": true