@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/dist/types/config.d.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
/** The widget's configuration (plan section 10): read from attributes, validated, defaulted. */
|
|
2
2
|
export type Locale = "en" | "fr";
|
|
3
3
|
export type ThemeMode = "light" | "dark" | "auto";
|
|
4
|
-
|
|
5
|
-
/** `auto` shows the icon below 640 px of viewport width and the text pill above it. */
|
|
4
|
+
/** Every value gives the edge tab; the values are read so existing embeds keep working. */
|
|
6
5
|
export type LauncherMode = "auto" | "pill" | "icon";
|
|
7
|
-
/**
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
/** The edge the launcher is docked to. */
|
|
7
|
+
export type LauncherSide = "right" | "left";
|
|
8
|
+
/**
|
|
9
|
+
* Where the launcher starts: its edge and a vertical fraction of the free height (0 top, 1 bottom).
|
|
10
|
+
* The reporter can move it along the edge; what they chose wins over this starting point.
|
|
11
|
+
*/
|
|
12
|
+
export interface LauncherPlacement {
|
|
13
|
+
side: LauncherSide;
|
|
14
|
+
offset: number;
|
|
11
15
|
}
|
|
16
|
+
export declare const DEFAULT_PLACEMENT: LauncherPlacement;
|
|
12
17
|
export interface WidgetConfig {
|
|
13
18
|
projectKey: string | null;
|
|
14
19
|
locale: Locale;
|
|
15
20
|
theme: ThemeMode;
|
|
16
|
-
|
|
17
|
-
/** The launcher's look (`launcher="icon"`); `launcher="false"` is read by the element. */
|
|
21
|
+
/** Read for compatibility (`launcher="pill"`, `"icon"`): the launcher is always the edge tab; `launcher="false"` is read by the element. */
|
|
18
22
|
launcherMode: LauncherMode;
|
|
19
|
-
/** The launcher's
|
|
20
|
-
|
|
21
|
-
bottom: string | null;
|
|
22
|
-
side: string | null;
|
|
23
|
-
};
|
|
23
|
+
/** The launcher's starting edge and height (`launcher-side`, `launcher-offset`). */
|
|
24
|
+
launcher: LauncherPlacement;
|
|
24
25
|
/** A valid hex seed from the host, or null: the built-in lavande theme then applies. */
|
|
25
26
|
accentColor: string | null;
|
|
26
27
|
/**
|
|
@@ -59,14 +60,9 @@ export declare const METADATA_KEY_MAX = 64;
|
|
|
59
60
|
export declare const METADATA_VALUE_MAX = 512;
|
|
60
61
|
export declare const METADATA_MAX_BYTES = 2048;
|
|
61
62
|
/** The attributes the element observes, in their HTML spelling. */
|
|
62
|
-
export declare const OBSERVED_ATTRIBUTES: readonly ["project-key", "locale", "theme", "
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
* `calc()`, `min()`, `max()`, `clamp()`, `var()`, `env()` call), or null. A negative value, or
|
|
66
|
-
* anything else (`;`, `}`, quotes, a bare word), is dropped. The browser's `CSS.supports` has
|
|
67
|
-
* the last word where it exists.
|
|
68
|
-
*/
|
|
69
|
-
export declare function lengthOf(value: string | number | null | undefined): string | null;
|
|
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. */
|
|
65
|
+
export declare function offsetOf(value: string | number | null | undefined): number;
|
|
70
66
|
/** A hex colour (#rgb or #rrggbb): the only form accepted as a seed. */
|
|
71
67
|
export declare function isHexColor(value: string | null): value is string;
|
|
72
68
|
/** An http(s) URL's origin (plus path prefix), or null: anything else is not a base. */
|
package/dist/types/element.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type WidgetEvent = "pulsarix:ready" | "pulsarix:open" | "pulsarix:close"
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class PulsarixWidgetElement extends HTMLElement {
|
|
12
12
|
#private;
|
|
13
|
-
static observedAttributes: ("accent-color" | "api-base" | "attachments" | "identity" | "inherit-theme" | "launcher" | "
|
|
13
|
+
static observedAttributes: ("accent-color" | "api-base" | "attachments" | "identity" | "inherit-theme" | "launcher" | "launcher-offset" | "launcher-side" | "locale" | "mask-text" | "metadata" | "prefill-email" | "prefill-title" | "privacy-url" | "project-key" | "theme")[];
|
|
14
14
|
get config(): WidgetConfig;
|
|
15
15
|
get isOpen(): boolean;
|
|
16
16
|
connectedCallback(): void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { LauncherMode,
|
|
1
|
+
export type { LauncherMode, LauncherPlacement, LauncherSide, Locale, ThemeMode, WidgetConfig, } from "./config";
|
|
2
2
|
export { defineWidget, type MountMetadata, PulsarixWidgetElement, TAG_NAME, type WidgetEvent, } from "./element";
|
|
3
3
|
export { type MountOptions, mount, type WidgetHandle } from "./mount";
|
package/dist/types/mount.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { LauncherMode, LauncherPlacement, Locale, ThemeMode } from "./config";
|
|
2
2
|
import { type MountMetadata, type PulsarixWidgetElement, type WidgetEvent } from "./element";
|
|
3
3
|
export interface MountOptions {
|
|
4
4
|
projectKey: string;
|
|
5
5
|
locale?: "en" | "fr";
|
|
6
6
|
theme?: "light" | "dark" | "auto";
|
|
7
|
-
position?: "bottom-left" | "bottom-right";
|
|
8
7
|
accentColor?: string;
|
|
9
8
|
/**
|
|
10
9
|
* Wear the host app's `@softistx/material` theme (colours, radius, light or dark) and follow
|
|
@@ -14,10 +13,13 @@ export interface MountOptions {
|
|
|
14
13
|
inheritTheme?: boolean;
|
|
15
14
|
/** Origin of the pulsarix host (`https://pulsarix.example.com`); the loader fills it in. */
|
|
16
15
|
apiBase?: string;
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The edge tab: `false` for none, `"auto"`, `"pill"` and `"icon"` (kept for compatibility) for the
|
|
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
|
|
20
|
+
* edge, and what they chose wins.
|
|
21
|
+
*/
|
|
22
|
+
launcher?: boolean | LauncherMode | Partial<LauncherPlacement>;
|
|
21
23
|
/** The screenshot's "Mask the text on the page" option starts on. */
|
|
22
24
|
maskText?: boolean;
|
|
23
25
|
/** `false` hides the screenshot and file controls (`data-attachments="false"`). */
|
|
@@ -57,8 +59,8 @@ export interface WidgetHandle {
|
|
|
57
59
|
setTheme(theme: ThemeMode): void;
|
|
58
60
|
/**
|
|
59
61
|
* Switches the language. The widget's strings change at once; `@softistx/material`'s built-in labels
|
|
60
|
-
* follow when the form is idle (typed fields, type
|
|
61
|
-
* during a send, on the confirmation or on the requests
|
|
62
|
+
* follow when the form is idle (typed fields, type and impact kept, attachments dropped), never
|
|
63
|
+
* during a send, on the confirmation or on the requests view.
|
|
62
64
|
*/
|
|
63
65
|
setLocale(locale: Locale): void;
|
|
64
66
|
/** Replaces the metadata sent with the next report (`null` clears it). */
|
package/docs/integration.md
CHANGED
|
@@ -77,7 +77,7 @@ One widget per page: use the script tag or `mount()`, not both.
|
|
|
77
77
|
## 3. Identify your signed-in users
|
|
78
78
|
|
|
79
79
|
Without an identity the widget is the anonymous report form. With one, reports are filed under the
|
|
80
|
-
reporter, who also gets a "My requests"
|
|
80
|
+
reporter, who also gets a "My requests" view (threads, replies, unread counts, "Delete my data").
|
|
81
81
|
|
|
82
82
|
Your server signs a short-lived token for the signed-in user with the key's identity secret; the browser
|
|
83
83
|
only carries the token. The helper does the signing:
|
|
@@ -234,6 +234,17 @@ Content-Security-Policy:
|
|
|
234
234
|
- Nothing else is needed for images or capture: thumbnails and the screenshot editor draw on canvases,
|
|
235
235
|
so there is no `img-src blob:`. Screen capture needs `display-capture` in your `Permissions-Policy`
|
|
236
236
|
(uploading an image works without it).
|
|
237
|
+
- Lazy chunks come from the same pulsarix host, so no extra `script-src` entry: the screenshot editor
|
|
238
|
+
(fetched on the first capture) and the markdown renderer of the team's replies (`chat-markdown-*.js`,
|
|
239
|
+
about 740 KB, 221 KB gzipped, fetched when a thread opens; plain text shows until it arrives). Serve
|
|
240
|
+
every file of the widget's folder beside the entry, with the bundle's cache headers.
|
|
241
|
+
- The icons (the type and impact cards, the camera button) come from a small sheet at
|
|
242
|
+
`<apiBase>/widget/v1/icons/duotone.svg`, where `apiBase` is the loader's origin unless you set
|
|
243
|
+
`data-api-base`. Only the few icons the widget draws are in it. It is fetched once with CORS (no
|
|
244
|
+
credentials) and inlined into the widget's shadow root, so `connect-src` needs the `apiBase` origin
|
|
245
|
+
(already there for the API). An unavailable sheet, or an `apiBase` that is not `https` (or
|
|
246
|
+
`http://localhost`), leaves those icons blank; the form still works. Serve `icons/` with the rest of
|
|
247
|
+
the widget's folder.
|
|
237
248
|
- The widget's styles are adopted into its shadow root: no `style-src 'unsafe-inline'`. The requests
|
|
238
249
|
thread injects one `<style>` element; under a strict `style-src` give your page a nonce, which the
|
|
239
250
|
widget reads from a `nonce` attribute on a `style` or `script` element or from this tag:
|
|
@@ -246,25 +257,27 @@ Content-Security-Policy:
|
|
|
246
257
|
|
|
247
258
|
Script-tag attributes and `init` / `mount` options (all optional except the key):
|
|
248
259
|
|
|
249
|
-
| Attribute / option
|
|
250
|
-
|
|
|
251
|
-
| `data-project-key` / `projectKey`
|
|
252
|
-
| `data-api-base` / `apiBase`
|
|
253
|
-
| `data-locale` / `locale`
|
|
254
|
-
| `data-theme` / `theme`
|
|
255
|
-
| `data-
|
|
256
|
-
| `data-
|
|
257
|
-
| `data-
|
|
258
|
-
| `data-
|
|
259
|
-
| `data-attachments="false"`
|
|
260
|
-
| `data-mask-text="true"`
|
|
261
|
-
| `data-privacy-url` / `privacyUrl`
|
|
262
|
-
| `data-prefill-email`, `data-prefill-title`
|
|
263
|
-
| `data-identity` / `identity`
|
|
264
|
-
| `data-metadata` / `metadata`
|
|
260
|
+
| Attribute / option | Effect |
|
|
261
|
+
| ------------------------------------------ | ----------------------------------------------------------------- |
|
|
262
|
+
| `data-project-key` / `projectKey` | the public key (required) |
|
|
263
|
+
| `data-api-base` / `apiBase` | the pulsarix origin; required on the npm route |
|
|
264
|
+
| `data-locale` / `locale` | `en` (default) or `fr` |
|
|
265
|
+
| `data-theme` / `theme` | `light`, `dark` or `auto` (default) |
|
|
266
|
+
| `data-launcher-side` / `launcher.side` | `right` (default) or `left` (section 11) |
|
|
267
|
+
| `data-launcher-offset` / `launcher.offset` | a fraction from 0 (top) to 1 (bottom), `0.5` default (section 11) |
|
|
268
|
+
| `data-accent-color` / `accentColor` | a hex seed for the theme |
|
|
269
|
+
| `data-launcher` / `launcher` | `false` for none; any other value gives the edge tab (section 11) |
|
|
270
|
+
| `data-attachments="false"` | no screenshot and no file controls |
|
|
271
|
+
| `data-mask-text="true"` | "Mask the text on the page" starts on |
|
|
272
|
+
| `data-privacy-url` / `privacyUrl` | an http(s) link to your privacy page |
|
|
273
|
+
| `data-prefill-email`, `data-prefill-title` | starting values of the form |
|
|
274
|
+
| `data-identity` / `identity` | the signed token (section 3) |
|
|
275
|
+
| `data-metadata` / `metadata` | a JSON object of strings stored with each report |
|
|
265
276
|
|
|
266
277
|
`metadata` carries facts about the session that help triage: at most 20 entries, keys of 64 characters,
|
|
267
|
-
values of 512, 2 KB in all; the rest is dropped.
|
|
278
|
+
values of 512, 2 KB in all; the rest is dropped. The keys `capture-N-page` are reserved: the widget
|
|
279
|
+
writes one per screenshot (the page it was taken on, origin and path), drops a host entry of that shape,
|
|
280
|
+
and drops the host's last entries first when the whole would pass these limits.
|
|
268
281
|
|
|
269
282
|
```html
|
|
270
283
|
<script src="https://<pulsarix-host>/widget/v1/loader.js" async
|
|
@@ -448,9 +461,9 @@ Rules:
|
|
|
448
461
|
64 characters, values of 512, 2 KB in all). A report already sent is not changed.
|
|
449
462
|
- `setLocale` changes the widget's own strings at once. The built-in labels of `@softistx/material` (the close
|
|
450
463
|
button, the file list, ...) are read once by its i18n context, so they change when the form is next idle:
|
|
451
|
-
- On an idle form, the typed fields, the chosen type and impact
|
|
464
|
+
- On an idle form, the typed fields, the chosen type and impact are kept; files and a
|
|
452
465
|
screenshot already attached are dropped.
|
|
453
|
-
- While a report is being sent, on the confirmation screen, or
|
|
466
|
+
- While a report is being sent, on the confirmation screen, or in the "My requests" view, nothing is rebuilt:
|
|
454
467
|
those built-in labels switch when the reporter returns to the form (or the dialog closes), and no
|
|
455
468
|
attachment is lost.
|
|
456
469
|
- `setTheme` and `setMetadata` drop nothing.
|
|
@@ -460,56 +473,55 @@ Rules:
|
|
|
460
473
|
|
|
461
474
|
## 11. The launcher: look, position and visibility
|
|
462
475
|
|
|
463
|
-
The
|
|
464
|
-
attribute and a `mount()` option.
|
|
476
|
+
The edge tab that opens the dialog. Two options shape it; each has script-tag attributes and a `mount()` option.
|
|
465
477
|
|
|
466
478
|
### Look: `launcher`
|
|
467
479
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
480
|
+
The launcher is an icon button, 44 x 44 px at every width, docked flush to the viewport edge and
|
|
481
|
+
rounded on the content side only. It wears the pulsarix mark and the unread badge. At rest it peeks 6 px
|
|
482
|
+
less; it slides fully in on hover, focus and while dragged. Its label is a tooltip only
|
|
483
|
+
("Report a problem", with "Drag to move" on a second line): shown on hover or keyboard focus after a short
|
|
484
|
+
delay, hidden while dragging and on screens with no hover. The `launcher` option no longer changes its
|
|
485
|
+
look: `"auto"`, `"pill"` and `"icon"` are still read so existing embeds keep working, and `false` removes it
|
|
486
|
+
(open the dialog with `open()`).
|
|
474
487
|
|
|
475
|
-
|
|
476
|
-
|
|
488
|
+
Without a token the tab opens the report form directly. With a token it opens a small menu beside it
|
|
489
|
+
with two items, "Report a problem" and "My requests" (with its unread badge); each opens one
|
|
490
|
+
view, never tabs. The tab keeps the localized label as its accessible name and carries the unread
|
|
491
|
+
count in it ("Report a problem, 3 unread requests"). It has `aria-expanded`, `aria-controls` and
|
|
492
|
+
`aria-keyshortcuts="Alt+ArrowUp Alt+ArrowDown"`, a visible focus ring, and respects `prefers-reduced-motion`.
|
|
477
493
|
|
|
478
|
-
|
|
479
|
-
<script src="https://<pulsarix-host>/widget/v1/loader.js" async
|
|
480
|
-
data-project-key="pk_live_xxx" data-launcher="icon"></script>
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
```ts
|
|
484
|
-
mount({ projectKey: "pk_live_xxx", launcher: "auto" });
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
### Offset: `offset` and the CSS custom properties
|
|
494
|
+
### Position: `launcher.side` and `launcher.offset`
|
|
488
495
|
|
|
489
|
-
|
|
490
|
-
(`
|
|
496
|
+
You choose where the tab starts: the edge (`"right"` default, or `"left"`) and a vertical fraction
|
|
497
|
+
`offset` from `0` (top) to `1` (bottom), `0.5` by default. A value outside 0..1 is clamped, junk is the
|
|
498
|
+
default.
|
|
491
499
|
|
|
492
500
|
```ts
|
|
493
|
-
mount({ projectKey: "pk_live_xxx",
|
|
501
|
+
mount({ projectKey: "pk_live_xxx", launcher: { side: "left", offset: 0.3 } });
|
|
494
502
|
```
|
|
495
503
|
|
|
496
504
|
```html
|
|
497
|
-
<script ... data-
|
|
505
|
+
<script ... data-launcher-side="left" data-launcher-offset="0.3"></script>
|
|
498
506
|
```
|
|
499
507
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
508
|
+
The reporter can then move it along the edge, by dragging it (pointer or touch) or with
|
|
509
|
+
Alt+ArrowUp / Alt+ArrowDown (each move is announced in a live region). A drag never opens the dialog; only a
|
|
510
|
+
click, Enter or Space does. The tab keeps a 16 px gap from the top and the bottom of the viewport, also
|
|
511
|
+
when the window is resized. The position is saved in `localStorage` under a key of your page's origin
|
|
512
|
+
(inside a try/catch: with storage blocked, it lasts until the page closes) and wins over your starting
|
|
513
|
+
point from then on.
|
|
504
514
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
--pulsarix-launcher-side: 24px;
|
|
509
|
-
}
|
|
510
|
-
```
|
|
515
|
+
Alt+ArrowUp and Alt+ArrowDown may clash with an assistive technology or a window manager shortcut; dragging the tab always remains available.
|
|
516
|
+
|
|
517
|
+
### Migrating from 0.6 (breaking)
|
|
511
518
|
|
|
512
|
-
`
|
|
519
|
+
`position`, `data-position`, `offset`, `data-offset-bottom`, `data-offset-side` and the custom properties
|
|
520
|
+
`--pulsarix-launcher-bottom` / `--pulsarix-launcher-side` are removed. Use `launcher.side` and
|
|
521
|
+
`launcher.offset` (a fraction of the height, no longer pixels or CSS lengths). The tab is flush to the
|
|
522
|
+
edge, so there is no side distance. A host that reserved room for the round button can drop that
|
|
523
|
+
reserve. To clear a sticky bar, use `holdLauncher()` (below). The `Position` and `LauncherOffset`
|
|
524
|
+
types are replaced by `LauncherSide` and `LauncherPlacement`.
|
|
513
525
|
|
|
514
526
|
### Visibility: `setLauncherVisible(visible)`
|
|
515
527
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softistx/pulsarix-widget",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Embeddable client-issue intake widget for pulsarix, rendered in a Shadow DOM",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@graphql-codegen/typescript": "^7.0.1",
|
|
19
19
|
"@graphql-codegen/typescript-operations": "^7.0.1",
|
|
20
20
|
"@happy-dom/global-registrator": "^21.0.4",
|
|
21
|
-
"@softistx/material": "^3.
|
|
21
|
+
"@softistx/material": "^3.281.0",
|
|
22
22
|
"@softistx/material-core": "^0.96.1",
|
|
23
23
|
"@tailwindcss/cli": "^4.3.3",
|
|
24
24
|
"@testing-library/dom": "^10.4.2",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"generate:check": "bun scripts/generate.ts --check",
|
|
48
48
|
"schema:sync": "bun scripts/schema-sync.ts",
|
|
49
49
|
"schema:check": "bun scripts/schema-sync.ts --check",
|
|
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",
|
|
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 && bun scripts/contrast-test.ts",
|
|
51
51
|
"fixture": "bun scripts/serve-fixture.ts",
|
|
52
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",
|
|
53
53
|
"release": "bun scripts/publish.ts",
|