@softistx/pulsarix-widget 0.5.0 → 0.7.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 +68 -35
- package/dist/index.js +4856 -52
- package/dist/types/config.d.ts +17 -21
- package/dist/types/element.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/mount.d.ts +10 -8
- package/docs/integration.md +67 -55
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -46,11 +46,11 @@ and isolated in the widget's shadow root, so it never clashes with the page's ow
|
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
Attributes (all optional but the key): `data-locale` (`en` default, `fr`), `data-theme`
|
|
49
|
-
(`light`, `dark`, `auto` default), `data-
|
|
49
|
+
(`light`, `dark`, `auto` default), `data-launcher-side` (`right` default, `left`) and `data-launcher-offset` (a fraction from 0, top, to 1, bottom; `0.5` default),
|
|
50
50
|
`data-accent-color` (a hex seed for the theme; without it the widget wears the host's `@softistx/material` theme, else material's built-in `lavande`), `data-inherit-theme="false"` (never inherit the host's theme; see "Theme"), `data-api-base` (the
|
|
51
51
|
pulsarix origin; defaults to the host that served the loader), `data-launcher="false"` (no
|
|
52
52
|
floating button; open it with `window.PulsarixWidget.open()`) or `data-launcher="auto|pill|icon"`
|
|
53
|
-
(
|
|
53
|
+
(any value other than `false` gives the edge tab; see "The launcher"), `data-mask-text="true"` (the
|
|
54
54
|
"Mask the text on the page" screenshot option starts on; see "Screenshots"), `data-attachments="false"`
|
|
55
55
|
(no screenshot and no file controls; see "Attached files"), `data-privacy-url` (an http(s) link to your
|
|
56
56
|
own privacy page, shown after the privacy line), `data-prefill-email` and `data-prefill-title` (starting
|
|
@@ -121,22 +121,20 @@ Server helper: `@softistx/pulsarix-widget/server` exports `signPulsarixIdentity`
|
|
|
121
121
|
|
|
122
122
|
`mount`, `defineWidget` (registers the element; `mount` calls it), `PulsarixWidgetElement`,
|
|
123
123
|
`TAG_NAME` (`"pulsarix-widget"`), and the types `MountOptions`,
|
|
124
|
-
`WidgetHandle`, `WidgetEvent`, `WidgetConfig`, `Locale`, `
|
|
125
|
-
`
|
|
126
|
-
|
|
127
|
-
| `MountOptions` | Type
|
|
128
|
-
| -------------- |
|
|
129
|
-
| `projectKey` | `string`
|
|
130
|
-
| `apiBase` | `string`
|
|
131
|
-
| `locale` | `"en" \| "fr"`
|
|
132
|
-
| `theme` | `"light" \| "dark" \| "auto"`
|
|
133
|
-
| `
|
|
134
|
-
| `
|
|
135
|
-
| `
|
|
136
|
-
| `
|
|
137
|
-
| `
|
|
138
|
-
| `identity` | `string \| null` | none: today's form only (see "Identified reporters") |
|
|
139
|
-
| `target` | `Element` | `document.body` |
|
|
124
|
+
`WidgetHandle`, `WidgetEvent`, `WidgetConfig`, `Locale`, `ThemeMode`, `LauncherMode`,
|
|
125
|
+
`LauncherPlacement`, `LauncherSide`.
|
|
126
|
+
|
|
127
|
+
| `MountOptions` | Type | Default |
|
|
128
|
+
| -------------- | ------------------------------------------------------------- | ---------------------------------------------------------- |
|
|
129
|
+
| `projectKey` | `string` | required; missing reports `pulsarix:error` `config` |
|
|
130
|
+
| `apiBase` | `string` | none; required on the npm route |
|
|
131
|
+
| `locale` | `"en" \| "fr"` | `"en"` |
|
|
132
|
+
| `theme` | `"light" \| "dark" \| "auto"` | `"auto"` |
|
|
133
|
+
| `accentColor` | hex string | none: the built-in `lavande` theme |
|
|
134
|
+
| `inheritTheme` | `boolean` | `true`: wear the host's `@softistx/material` theme |
|
|
135
|
+
| `launcher` | `boolean \| "auto" \| "pill" \| "icon" \| { side?, offset? }` | `{ side: "right", offset: 0.5 }` (`false` removes the tab) |
|
|
136
|
+
| `identity` | `string \| null` | none: today's form only (see "Identified reporters") |
|
|
137
|
+
| `target` | `Element` | `document.body` |
|
|
140
138
|
|
|
141
139
|
`WidgetHandle`: `open()`, `close()`, `setLauncherVisible(visible)`, `holdLauncher()` (returns a release function), `destroy()`, `identify(token \| null)`, `setTheme(theme)`, `setLocale(locale)`,
|
|
142
140
|
`setMetadata(metadata \| null)` (see "Changing theme, locale and metadata at run time"), `on(name, callback)` (returns the function that
|
|
@@ -164,9 +162,9 @@ bundle has loaded is queued. An unsupported theme or locale is ignored.
|
|
|
164
162
|
- `setMetadata` replaces the whole object (same limits as `metadata` at mount); a report already sent keeps
|
|
165
163
|
the metadata it was sent with.
|
|
166
164
|
- `setLocale` changes the widget's own strings at once. The built-in labels of `@softistx/material` follow
|
|
167
|
-
when the form is next idle: on an idle form the typed fields, the type
|
|
165
|
+
when the form is next idle: on an idle form the typed fields, the type and the impact are kept
|
|
168
166
|
and files or a screenshot already attached are dropped; while a report is being sent, on the confirmation
|
|
169
|
-
or
|
|
167
|
+
or in the "My requests" view nothing is rebuilt (and nothing is lost), and those labels switch once the
|
|
170
168
|
reporter is back on the form or the dialog closes.
|
|
171
169
|
- A repeated call before the bundle loads replaces the earlier one: only the last of each setter runs.
|
|
172
170
|
- With `inheritTheme`, an explicit `setTheme` wins over the host's mode until the `theme` attribute is
|
|
@@ -181,13 +179,41 @@ works, and its limits: [docs/integration.md](docs/integration.md#9-inheriting-th
|
|
|
181
179
|
|
|
182
180
|
## The launcher
|
|
183
181
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
The launcher is an **edge tab**: a 44 x 44 px icon button docked flush to the viewport edge, rounded on the
|
|
183
|
+
content side only, with the pulsarix mark and the unread badge. At rest it peeks 6 px less; it slides fully
|
|
184
|
+
in on hover, focus and while it is dragged. Its label is a tooltip only (hover or keyboard focus, hidden
|
|
185
|
+
while dragging and on touch screens), and its accessible name carries the unread count ("Report a
|
|
186
|
+
problem, 2 unread requests"). Without an identity token a click opens the report form; with one it opens a
|
|
187
|
+
menu with "Report a problem" and "My requests" (unread badge).
|
|
188
|
+
|
|
189
|
+
You choose where it starts, `launcher: { side: "right" | "left", offset: 0..1 }` (`offset` is a fraction of
|
|
190
|
+
the free height, `0.5` by default; script tag: `data-launcher-side`, `data-launcher-offset`). The reporter can move it
|
|
191
|
+
along the edge: by dragging it, or with Alt+ArrowUp / Alt+ArrowDown (each move is announced). Their
|
|
192
|
+
position is saved in `localStorage` for your origin and wins over your starting point; it stays inside the
|
|
193
|
+
viewport, also when the window is resized. A drag never opens the dialog.
|
|
194
|
+
|
|
195
|
+
`false` removes the tab (`"auto"`, `"pill"` and `"icon"` are still read and give the default tab). With the
|
|
196
|
+
launcher removed or held hidden, an identified reporter has no way to the requests list: keep it visible for them.
|
|
187
197
|
`setLauncherVisible(false)` hides only the launcher, never an open dialog, and `holdLauncher()` hides it the same way while a host's own sticky bar is up (ref-counted, call the returned function to release); with the script tag it is
|
|
188
|
-
`window.PulsarixWidget.setLauncherVisible(false)`.
|
|
198
|
+
`window.PulsarixWidget.setLauncherVisible(false)`. Details and examples:
|
|
189
199
|
[docs/integration.md](docs/integration.md).
|
|
190
200
|
|
|
201
|
+
### Migrating from 0.6 (breaking)
|
|
202
|
+
|
|
203
|
+
The floating round button, its `position` and its offsets are gone:
|
|
204
|
+
|
|
205
|
+
| 0.6 | Now |
|
|
206
|
+
| -------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
207
|
+
| `position: "bottom-left"` / `data-position` | `launcher: { side: "left" }` / `data-launcher-side="left"` |
|
|
208
|
+
| `offset: { bottom: 88 }` / `data-offset-bottom` | `launcher: { offset: 0.4 }` / `data-launcher-offset="0.4"` (a fraction of the height, not pixels) |
|
|
209
|
+
| `offset.side` / `data-offset-side` | removed: the tab is flush to the edge |
|
|
210
|
+
| `--pulsarix-launcher-bottom`, `--pulsarix-launcher-side` | removed: no longer read |
|
|
211
|
+
| `LauncherOffset`, `Position` types | `LauncherPlacement`, `LauncherSide` |
|
|
212
|
+
|
|
213
|
+
A host that reserved space for the round button (a right padding, say) no longer needs it: the tab is 44 px
|
|
214
|
+
wide, sits on the edge and the reporter can move it out of the way. To clear a sticky bar, use
|
|
215
|
+
`holdLauncher()`.
|
|
216
|
+
|
|
191
217
|
## The report form
|
|
192
218
|
|
|
193
219
|
The launcher opens a dialog with a title, a description and an optional e-mail. With an e-mail,
|
|
@@ -220,11 +246,11 @@ never in a URL. A malformed token is ignored. A token given with `identify()` or
|
|
|
220
246
|
is kept in the widget's memory and is not written to the page; a token in `data-identity` is an
|
|
221
247
|
attribute of the element, so it is visible in the DOM (prefer `identify()` when that matters).
|
|
222
248
|
|
|
223
|
-
- Without a token the dialog is
|
|
224
|
-
- With one, the
|
|
249
|
+
- Without a token the dialog is the one report form, and the e-mail field is asked.
|
|
250
|
+
- With one, the tab opens a menu with "Report a problem" and "My requests" (no e-mail field). My requests is its own view, with its own title, and one list with
|
|
225
251
|
filter chips and their counts (Open by default, Resolved, Declined, All); requests with
|
|
226
252
|
unread replies come first, and the list is read again each time the dialog opens.
|
|
227
|
-
- The
|
|
253
|
+
- The tab (in its name) and the My requests menu item show the unread count.
|
|
228
254
|
- Opening a request shows its thread: the original message, then the replies of the team (plain
|
|
229
255
|
text, with their file names). The reporter can reply, with up to three files sent the same way as
|
|
230
256
|
a report's (the ticket upload below), resolve the request, and reopen a resolved one for 30 days.
|
|
@@ -338,24 +364,31 @@ With the npm route, call `widget.identify(token)` on the handle `mount()` return
|
|
|
338
364
|
## Screenshots
|
|
339
365
|
|
|
340
366
|
A report can carry one optional screenshot, never taken without a click (and a per-report
|
|
341
|
-
choice). The
|
|
367
|
+
choice). The form has a "Screenshot" section and a separate "Attachments" section:
|
|
342
368
|
|
|
343
|
-
- **
|
|
369
|
+
- **Capture this page** (Screenshot section): the browser's screen capture (`getDisplayMedia`). The widget hides itself
|
|
344
370
|
(`visibility`, not unmount, so the form keeps its text) while the frame is grabbed, then shows
|
|
345
371
|
itself again. Not offered on a phone, without the API, or under a Permissions-Policy that blocks
|
|
346
372
|
`display-capture`.
|
|
347
|
-
- **Upload
|
|
348
|
-
refused. PNG, JPEG or
|
|
373
|
+
- **Upload a file** (Attachments section, a drop zone with a Browse button): always offered, and the only choice where capture is unavailable or was
|
|
374
|
+
refused. PNG, JPEG, WebP or PDF. An uploaded image opens in the same editor as a capture (a PDF is
|
|
375
|
+
a plain attachment).
|
|
349
376
|
- **Mask the text on the page** (off by default; `data-mask-text="true"`, or `maskText: true` in `init` / `mount`, turns it on when the dialog opens): covers the
|
|
350
377
|
page's text with opaque boxes before the picture is taken. It needs the current tab to be shared;
|
|
351
378
|
otherwise the widget says it cannot and nothing is captured. Mark anything that must stay visible
|
|
352
379
|
with `data-capture-unmask`.
|
|
353
380
|
|
|
354
|
-
|
|
381
|
+
A capture or an uploaded image opens straight in the editor (a separate chunk, fetched when first needed) with a pen, a highlighter,
|
|
355
382
|
an arrow, a box, text, a solid "Redact" box (redacted pixels are one opaque colour) and Crop, which trims the
|
|
356
383
|
picture before it is kept. Only the flattened
|
|
357
|
-
export (2560 px on its longest side at most) is kept
|
|
358
|
-
|
|
384
|
+
export (2560 px on its longest side at most) is kept when you save; Cancel in the editor keeps the
|
|
385
|
+
capture as it was taken. No media track stays live. The screenshot and the files share one list of removable thumbnails. Every image has an "Edit" button that reopens it (the
|
|
386
|
+
kept image, not the raw capture). Each capture records the page it was taken on (origin and path, never
|
|
387
|
+
the query or the fragment), shown under it ("Captured on ...") and in the editor. The report's
|
|
388
|
+
`pageUrl` is the first capture's page, and each capture's page is also sent as a `metadata` entry
|
|
389
|
+
(`capture-1-page`, `capture-2-page`, ... by position among the captures; those keys are reserved: a
|
|
390
|
+
host entry of that shape is dropped, and when the whole passes the metadata limits the host's entries
|
|
391
|
+
are dropped from the end first). A report is complete without
|
|
359
392
|
any of this. No `blob:` image source is needed in your CSP (the editor draws on canvases), and a
|
|
360
393
|
`Permissions-Policy` without `display-capture` turns the capture button off.
|
|
361
394
|
|
|
@@ -377,7 +410,7 @@ widget.on("pulsarix:error", (event) => console.warn(event.detail.code));
|
|
|
377
410
|
## Attached files
|
|
378
411
|
|
|
379
412
|
Besides the screenshot, a reporter can attach up to 3 files (PNG, JPEG, WebP or PDF, 5 MB each,
|
|
380
|
-
12 MB for the report, screenshot included) by dropping them on the zone or with
|
|
413
|
+
12 MB for the report, screenshot included) by dropping them on the Attachments zone or with "Upload a file". The
|
|
381
414
|
checks mirror the API's, so a refused file is shown with its reason and never sent; the list shows
|
|
382
415
|
each file's type icon, name, size, a thumbnail for images, a Remove button, and its progress while
|
|
383
416
|
the report goes out.
|