@getpinax/widget 0.0.0-stage → 1.0.0-beta.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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +267 -2
  3. package/dist/api.d.ts +62 -0
  4. package/dist/capture/breadcrumbs.d.ts +49 -0
  5. package/dist/capture/console.d.ts +17 -0
  6. package/dist/capture/env.d.ts +25 -0
  7. package/dist/capture/network.d.ts +23 -0
  8. package/dist/capture/ring.d.ts +14 -0
  9. package/dist/capture/signature.d.ts +2 -0
  10. package/dist/capture/text.d.ts +7 -0
  11. package/dist/capture/ua.d.ts +13 -0
  12. package/dist/chunks/editor-DbHLGwOA.mjs +1368 -0
  13. package/dist/chunks/privacy-DmU6v5Fr.mjs +39 -0
  14. package/dist/chunks/recorder-BUtEB_em.mjs +2859 -0
  15. package/dist/chunks/text-8QYEyRYs.mjs +18 -0
  16. package/dist/chunks/widget-CkR1Ptzb.mjs +961 -0
  17. package/dist/editor/annotator.d.ts +20 -0
  18. package/dist/editor/capture.d.ts +28 -0
  19. package/dist/editor/encode.d.ts +7 -0
  20. package/dist/editor/index.d.ts +5 -0
  21. package/dist/editor/mask.d.ts +29 -0
  22. package/dist/editor/pii.d.ts +22 -0
  23. package/dist/editor/shapes.d.ts +31 -0
  24. package/dist/editor-loader.d.ts +6 -0
  25. package/dist/editor-loader.embed.d.ts +5 -0
  26. package/dist/fixcheck.d.ts +31 -0
  27. package/dist/index.d.ts +46 -0
  28. package/dist/mount.d.ts +8 -0
  29. package/dist/navigation.d.ts +1 -0
  30. package/dist/paths.d.ts +4 -0
  31. package/dist/pinax-editor.js +1417 -0
  32. package/dist/pinax-recorder.js +2902 -0
  33. package/dist/pinax.js +113 -0
  34. package/dist/pinax.mjs +1041 -0
  35. package/dist/preview.d.ts +35 -0
  36. package/dist/preview.mjs +54 -0
  37. package/dist/privacy.d.ts +22 -0
  38. package/dist/queue.d.ts +9 -0
  39. package/dist/replay/buffer.d.ts +40 -0
  40. package/dist/replay/recorder.d.ts +15 -0
  41. package/dist/replay/sanitize.d.ts +13 -0
  42. package/dist/report.d.ts +109 -0
  43. package/dist/segment.d.ts +31 -0
  44. package/dist/settings.d.ts +31 -0
  45. package/dist/types.d.ts +137 -0
  46. package/dist/ui/color.d.ts +7 -0
  47. package/dist/ui/dom.d.ts +14 -0
  48. package/dist/ui/styles.d.ts +3 -0
  49. package/dist/ui/widget.d.ts +161 -0
  50. package/package.json +73 -4
@@ -0,0 +1,161 @@
1
+ import type { Annotation, FieldAnswer, PinaxUser, ReportType, WidgetConfig } from '../types';
2
+ export type Shot = {
3
+ /** The flattened image that will be sent. */
4
+ dataUrl: string;
5
+ annotations: Annotation[];
6
+ /** Opaque editor state so "Mark up" can continue where it left off. */
7
+ edit?: unknown;
8
+ /** AI-12: how many private details were blurred automatically. */
9
+ autoBlurred?: number;
10
+ };
11
+ export type SubmitInput = {
12
+ type: ReportType;
13
+ message: string;
14
+ rating?: number;
15
+ email?: string;
16
+ shot?: Shot;
17
+ /** AI-10: the follow-up question and the visitor's answer. */
18
+ followUp?: {
19
+ question: string;
20
+ answer: string;
21
+ };
22
+ /** W-10: answers to the site's custom fields. */
23
+ fields?: FieldAnswer[];
24
+ /** P-04: the hidden honeypot field (people leave it empty). */
25
+ hp?: string;
26
+ /** P-04: milliseconds from opening the panel to sending. */
27
+ elapsedMs?: number;
28
+ };
29
+ /** AI-10: only short notes on problems and ideas get a follow-up question. */
30
+ export declare const FOLLOW_UP_MAX_NOTE = 140;
31
+ export type SubmitResult = {
32
+ status: 'sent';
33
+ } | {
34
+ status: 'queued';
35
+ } | {
36
+ status: 'error';
37
+ message: string;
38
+ };
39
+ export type UIHandlers = {
40
+ takeScreenshot(): Promise<Shot>;
41
+ markUp(shot: Shot): Promise<Shot | null>;
42
+ submit(input: SubmitInput): Promise<SubmitResult>;
43
+ user(): PinaxUser | undefined;
44
+ /** Called each time the panel opens (Segment). Must not throw. */
45
+ opened?(): void;
46
+ /**
47
+ * AI-10: one follow-up question for a short note, or null to send as is.
48
+ * Must resolve (to null) on errors and within a few seconds.
49
+ */
50
+ followUp?(input: {
51
+ type: ReportType;
52
+ message: string;
53
+ }): Promise<string | null>;
54
+ };
55
+ /** A screen of the panel, or 'button' for the closed widget. */
56
+ export type WidgetView = 'button' | 'choose' | 'problem' | 'idea' | 'general' | 'done';
57
+ /**
58
+ * The floating button and the feedback panel (W-01, W-02, W-07 to W-11,
59
+ * W-15). Everything renders inside the shadow root.
60
+ */
61
+ export declare class WidgetUI {
62
+ private root;
63
+ private config;
64
+ private handlers;
65
+ private wrap;
66
+ private launcher;
67
+ private panel;
68
+ private live;
69
+ private kinds;
70
+ private kind;
71
+ private shot;
72
+ private message;
73
+ private email;
74
+ private rating;
75
+ /** W-10: answers by field id. */
76
+ private answers;
77
+ /** W-17: the client's colour on Send buttons (Agency). */
78
+ private sendColour;
79
+ private sending;
80
+ /** P-04: when the panel opened, and the honeypot field's value. */
81
+ private openedAt;
82
+ private hp;
83
+ private closeTimer;
84
+ private uid;
85
+ /** S-04 hidden path, set from outside as the visitor navigates. */
86
+ private pathHidden;
87
+ /** Where focus goes back to on close when there's no button to return to. */
88
+ private returnFocus;
89
+ constructor(root: ShadowRoot, config: WidgetConfig, handlers: UIHandlers,
90
+ /** Extra classes on the wrapper and extra CSS (the dashboard preview). */
91
+ extra?: {
92
+ className?: string;
93
+ css?: string;
94
+ });
95
+ isOpen(): boolean;
96
+ /** True while the floating button is on screen (S-04, S-05). */
97
+ hasButton(): boolean;
98
+ /**
99
+ * S-04: hide or show the floating button for the current page. An open
100
+ * panel stays open, and `open()` keeps working either way.
101
+ */
102
+ setPathHidden(hidden: boolean): void;
103
+ private updateButton;
104
+ /** `focus: false` opens without moving focus (the dashboard preview). */
105
+ open(focus?: boolean): void;
106
+ close(restoreFocus?: boolean): void;
107
+ /** The screen on show, for the dashboard preview. */
108
+ currentView(): WidgetView;
109
+ /**
110
+ * Dashboard preview: jump straight to a screen without moving focus. A
111
+ * type that's switched off shows the chooser instead.
112
+ */
113
+ showView(view: WidgetView): void;
114
+ /** S-06: the owner's wording, or ours when they left it empty. */
115
+ private word;
116
+ private kindTitle;
117
+ /** Hides the panel while the full-screen editor is up. */
118
+ private setSuspended;
119
+ destroy(): void;
120
+ private view;
121
+ private queued;
122
+ /** AI-10: the question asked about `message`, and the answer so far. */
123
+ private asked;
124
+ private answer;
125
+ private reset;
126
+ private holdOpen;
127
+ private focusFirst;
128
+ private announce;
129
+ private pick;
130
+ private capture;
131
+ private markUp;
132
+ private renderKeepingFocus;
133
+ private header;
134
+ private powered;
135
+ /** W-17: the client's logo at the top of the panel (Agency). */
136
+ private logo;
137
+ private render;
138
+ private renderChoose;
139
+ private renderShot;
140
+ private renderStars;
141
+ private renderForm;
142
+ /**
143
+ * P-04: a field people never see or reach (off-screen, out of the tab
144
+ * order and hidden from screen readers). Form-filling bots fill it in.
145
+ */
146
+ private honeypot;
147
+ private send;
148
+ /** The follow-up question for this note, or null (no question, error, timeout). */
149
+ private askFollowUp;
150
+ private submitNow;
151
+ /** AI-10: one question about the note, with "Send" and "Skip and send". */
152
+ private renderQuestion;
153
+ /** W-17: the client's colour on Send, else the colour of the kind. */
154
+ private colourSend;
155
+ /** W-10: the owner's fields for this kind of feedback. */
156
+ private fieldsFor;
157
+ private fieldAnswers;
158
+ /** W-10: dropdowns, short text and checkboxes, labelled and keyboard friendly. */
159
+ private renderFields;
160
+ private renderDone;
161
+ }
package/package.json CHANGED
@@ -1,6 +1,75 @@
1
1
  {
2
2
  "name": "@getpinax/widget",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0-beta.1",
4
+ "type": "module",
5
+ "description": "Pinax website feedback widget: a feedback button with screenshots, markup and page context",
6
+ "license": "MIT",
7
+ "author": "Pinax <hello@getpinax.com>",
8
+ "homepage": "https://getpinax.com",
9
+ "bugs": {
10
+ "email": "hello@getpinax.com"
11
+ },
12
+ "keywords": [
13
+ "feedback",
14
+ "bug-report",
15
+ "widget",
16
+ "screenshot",
17
+ "pinax"
18
+ ],
19
+ "sideEffects": false,
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "main": "./dist/pinax.mjs",
24
+ "module": "./dist/pinax.mjs",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/pinax.mjs"
30
+ },
31
+ "./preview": {
32
+ "types": "./dist/preview.d.ts",
33
+ "import": "./dist/preview.mjs"
34
+ },
35
+ "./package.json": "./package.json"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "!dist/**/*.map",
40
+ "README.md",
41
+ "LICENSE"
42
+ ],
43
+ "scripts": {
44
+ "dev": "vite",
45
+ "build": "tsc --noEmit && vite build && vite build --mode editor && vite build --mode recorder && vite build --mode embed && tsc -p tsconfig.build.json && node scripts/check-size.mjs",
46
+ "test": "vitest run",
47
+ "typecheck": "tsc --noEmit",
48
+ "check": "biome check ./src ./cdn",
49
+ "check:fix": "biome check --write ./src ./cdn",
50
+ "size": "node scripts/check-size.mjs",
51
+ "playground": "yarn build && node scripts/serve-playground.mjs",
52
+ "prepublishOnly": "VITE_PINAX_API=https://api.getpinax.com VITE_PINAX_CDN=https://cdn.getpinax.com yarn build && yarn test",
53
+ "cdn:deploy": "./cdn/deploy.sh"
54
+ },
55
+ "devDependencies": {
56
+ "@biomejs/biome": "^2.6.5",
57
+ "@types/node": "^22",
58
+ "axe-core": "^4.10.0",
59
+ "jsdom": "^30.1.3",
60
+ "typescript": "^7.0.2",
61
+ "vite": "^8.3.5",
62
+ "vitest": "^5.1.0"
63
+ },
64
+ "dependencies": {
65
+ "@rrweb/record": "2.1.7",
66
+ "modern-screenshot": "^4.7.0"
67
+ },
68
+ "resolutions": {
69
+ "rrweb": "2.1.7",
70
+ "rrweb-snapshot": "2.1.7",
71
+ "rrdom": "2.1.7",
72
+ "@rrweb/types": "2.1.7",
73
+ "@rrweb/utils": "2.1.7"
74
+ }
75
+ }