@softistx/pulsarix-widget 0.0.0-stage → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,62 @@
1
+ /** The widget's configuration (plan section 10): read from attributes, validated, defaulted. */
2
+ export type Locale = "en" | "fr";
3
+ export type ThemeMode = "light" | "dark" | "auto";
4
+ export type Position = "bottom-right" | "bottom-left";
5
+ export interface WidgetConfig {
6
+ projectKey: string | null;
7
+ locale: Locale;
8
+ theme: ThemeMode;
9
+ position: Position;
10
+ /** A valid hex seed from the host, or null: the built-in lavande theme then applies. */
11
+ accentColor: string | null;
12
+ /** Origin of the pulsarix host that serves `/public/graphql`; null until given. */
13
+ apiBase: string | null;
14
+ /** The "Mask the text on the page" option starts on (`data-mask-text="true"`). */
15
+ maskText: boolean;
16
+ /** The screenshot and file controls are shown (`data-attachments="false"` hides them). */
17
+ attachments: boolean;
18
+ /** An https or http link to the integrator's own privacy page, shown in the privacy line. */
19
+ privacyUrl: string | null;
20
+ /** Starting values of the form (`prefill-email`, `prefill-title`); empty when not given. */
21
+ prefill: {
22
+ email: string;
23
+ title: string;
24
+ };
25
+ /** Flat strings stored with the report (`metadata`, a JSON object), within the API's limits. */
26
+ metadata: MetadataEntry[];
27
+ /**
28
+ * The signed identity token the host's server made for its signed-in user, or null (no
29
+ * "My requests", today's form only). `identify()` sets and clears it at run time.
30
+ */
31
+ identity: string | null;
32
+ }
33
+ export interface MetadataEntry {
34
+ key: string;
35
+ value: string;
36
+ }
37
+ /** The API's limits on a report's metadata (`intake.submit.input`). */
38
+ export declare const METADATA_MAX_ENTRIES = 20;
39
+ export declare const METADATA_KEY_MAX = 64;
40
+ export declare const METADATA_VALUE_MAX = 512;
41
+ export declare const METADATA_MAX_BYTES = 2048;
42
+ /** The attributes the element observes, in their HTML spelling. */
43
+ export declare const OBSERVED_ATTRIBUTES: readonly ["project-key", "locale", "theme", "position", "accent-color", "api-base", "mask-text", "attachments", "privacy-url", "prefill-email", "prefill-title", "metadata", "identity"];
44
+ /** A hex colour (#rgb or #rrggbb): the only form accepted as a seed. */
45
+ export declare function isHexColor(value: string | null): value is string;
46
+ /** An http(s) URL's origin (plus path prefix), or null: anything else is not a base. */
47
+ export declare function apiBaseOf(value: string | null): string | null;
48
+ /** An http(s) link as written, or null: `javascript:` and the like are never linked. */
49
+ export declare function privacyUrlOf(value: string | null): string | null;
50
+ /**
51
+ * An identity token (`<payload>.<signature>`, both base64url) or null. Anything else is dropped,
52
+ * so a stray character can never break a request header.
53
+ */
54
+ export declare function identityOf(value: string | null): string | null;
55
+ /**
56
+ * A JSON object of strings (numbers and booleans are written as text) into the entries the API
57
+ * accepts: at most 20, keys of 64 characters, values of 512, 2 KB in all. What does not fit is
58
+ * left out, never thrown: a bad attribute must not break the widget.
59
+ */
60
+ export declare function metadataOf(value: string | null): MetadataEntry[];
61
+ /** An unknown or missing value falls back to its default; nothing throws on a bad attribute. */
62
+ export declare function readConfig(get: (name: string) => string | null): WidgetConfig;
@@ -0,0 +1,69 @@
1
+ import { type WidgetConfig } from "./config";
2
+ export declare const TAG_NAME = "pulsarix-widget";
3
+ export type WidgetEvent = "pulsarix:ready" | "pulsarix:open" | "pulsarix:close" | "pulsarix:submit" | "pulsarix:reply" | "pulsarix:unread" | "pulsarix:erase" | "pulsarix:error";
4
+ /**
5
+ * `<pulsarix-widget>`: an open shadow root holding material's stylesheet, the
6
+ * generated theme and the React tree. Nothing is added to the page's document:
7
+ * no style element, no global, no portal in `document.body`.
8
+ */
9
+ export declare class PulsarixWidgetElement extends HTMLElement {
10
+ #private;
11
+ static observedAttributes: string[];
12
+ get config(): WidgetConfig;
13
+ get isOpen(): boolean;
14
+ connectedCallback(): void;
15
+ disconnectedCallback(): void;
16
+ attributeChangedCallback(): void;
17
+ /**
18
+ * Signs the reporter in with the identity token the host's server signed, or out with `null`
19
+ * (on the host's sign-out): the dialog then shows or drops New request and My requests.
20
+ */
21
+ identify(token: string | null): void;
22
+ open(): void;
23
+ close(): void;
24
+ }
25
+ export declare function defineWidget(): void;
26
+ export interface MountOptions {
27
+ projectKey: string;
28
+ locale?: "en" | "fr";
29
+ theme?: "light" | "dark" | "auto";
30
+ position?: "bottom-left" | "bottom-right";
31
+ accentColor?: string;
32
+ /** Origin of the pulsarix host (`https://pulsarix.example.com`); the loader fills it in. */
33
+ apiBase?: string;
34
+ launcher?: boolean;
35
+ /** The screenshot's "Mask the text on the page" option starts on. */
36
+ maskText?: boolean;
37
+ /** `false` hides the screenshot and file controls (`data-attachments="false"`). */
38
+ attachments?: boolean;
39
+ /** Starting values of the form; the reporter can change them. */
40
+ prefill?: {
41
+ email?: string;
42
+ title?: string;
43
+ };
44
+ /** Flat strings stored with each report (20 entries, 2 KB at most; the rest is dropped). */
45
+ metadata?: Record<string, string | number | boolean>;
46
+ /** Link to your own privacy page, shown after the privacy line (http or https). */
47
+ privacyUrl?: string;
48
+ /**
49
+ * The identity token your server signed for the signed-in user (`<payload>.<signature>`).
50
+ * With it the widget shows New request and My requests; change it later with `identify()`.
51
+ */
52
+ identity?: string;
53
+ /** Where to append the element; `document.body` by default. */
54
+ target?: Element;
55
+ }
56
+ export interface WidgetHandle {
57
+ element: PulsarixWidgetElement;
58
+ open(): void;
59
+ close(): void;
60
+ /** Signs the reporter in with a signed identity token, or out with `null`. */
61
+ identify(token: string | null): void;
62
+ destroy(): void;
63
+ on(name: WidgetEvent, callback: (event: CustomEvent) => void): () => void;
64
+ }
65
+ /**
66
+ * Mounts the widget. One widget per page: while a mounted one is still attached, a second call
67
+ * returns its handle (and warns) instead of adding another element.
68
+ */
69
+ export declare function mount(options: MountOptions): WidgetHandle;
@@ -0,0 +1,2 @@
1
+ export type { Locale, Position, ThemeMode, WidgetConfig } from "./config";
2
+ export { defineWidget, type MountOptions, mount, PulsarixWidgetElement, TAG_NAME, type WidgetEvent, type WidgetHandle, } from "./element";
package/package.json CHANGED
@@ -1,6 +1,67 @@
1
1
  {
2
2
  "name": "@softistx/pulsarix-widget",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.1",
4
+ "type": "module",
5
+ "description": "Embeddable client-issue intake widget for pulsarix, rendered in a Shadow DOM",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/softistx/pulsarix-widget.git"
10
+ },
11
+ "publishConfig": {
12
+ "registry": "https://registry.npmjs.org/",
13
+ "access": "public"
14
+ },
15
+ "devDependencies": {
16
+ "@biomejs/biome": "2.5.15",
17
+ "@happy-dom/global-registrator": "^21.0.4",
18
+ "@softistx/material": "^3.250.1",
19
+ "@softistx/material-core": "^0.95.1",
20
+ "@tailwindcss/cli": "^4.3.3",
21
+ "@testing-library/dom": "^10.4.2",
22
+ "@testing-library/react": "^16.3.3",
23
+ "@testing-library/user-event": "^14.6.9",
24
+ "@types/bun": "^1.4.4",
25
+ "@types/react": "^19.3.0",
26
+ "@types/react-dom": "^19.3.0",
27
+ "playwright-core": "^1.64.1",
28
+ "react": "^19.3.1",
29
+ "react-dom": "^19.3.1",
30
+ "react-hook-form": "^7.92.0",
31
+ "tailwindcss": "^4.3.3",
32
+ "typescript": "^7.0.2"
33
+ },
34
+ "scripts": {
35
+ "build": "bun scripts/build.ts",
36
+ "lint": "biome ci",
37
+ "fix": "biome check --write",
38
+ "typecheck": "bun check",
39
+ "test": "bun test",
40
+ "size": "bun scripts/check-size.ts",
41
+ "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
+ "fixture": "bun scripts/serve-fixture.ts",
43
+ "verify": "bun run lint && bun run build && bun run typecheck && bun run test && bun run size",
44
+ "release": "bun scripts/publish.ts",
45
+ "capture": "bun scripts/capture.ts",
46
+ "capture:requests": "bun scripts/capture-requests.ts",
47
+ "capture:thread": "bun scripts/capture-thread.ts",
48
+ "capture:privacy": "bun scripts/capture-privacy.ts"
49
+ },
50
+ "main": "./dist/index.js",
51
+ "module": "./dist/index.js",
52
+ "exports": {
53
+ ".": {
54
+ "types": "./dist/types/index.d.ts",
55
+ "import": "./dist/index.js",
56
+ "default": "./dist/index.js"
57
+ }
58
+ },
59
+ "files": [
60
+ "dist/index.js",
61
+ "dist/types/index.d.ts",
62
+ "dist/types/config.d.ts",
63
+ "dist/types/element.d.ts"
64
+ ],
65
+ "types": "./dist/types/index.d.ts",
66
+ "sideEffects": true
67
+ }