uidex 0.1.1 → 0.2.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.
@@ -35,6 +35,27 @@ interface KeyboardShortcut {
35
35
  altKey?: boolean;
36
36
  metaKey?: boolean;
37
37
  }
38
+ interface IngestConfig {
39
+ endpoint: string;
40
+ apiKey: string;
41
+ environment?: string;
42
+ appVersion?: string;
43
+ reporter?: {
44
+ email?: string;
45
+ name?: string;
46
+ };
47
+ metadata?: Record<string, string>;
48
+ captureConsole?: boolean;
49
+ captureNetwork?: boolean;
50
+ }
51
+ type FeedbackResult = {
52
+ ok: true;
53
+ id: string;
54
+ sequenceNumber: number;
55
+ } | {
56
+ ok: false;
57
+ error: string;
58
+ };
38
59
  interface UidexUIOptions {
39
60
  components?: UidexMap;
40
61
  pages?: UidexPage[];
@@ -44,6 +65,60 @@ interface UidexUIOptions {
44
65
  onSelect?: (id: string) => void;
45
66
  /** Keyboard shortcut to toggle inspect mode. Set to false to disable. */
46
67
  inspectShortcut?: KeyboardShortcut | false;
68
+ /** Ingest configuration for submitting feedback to a server. */
69
+ ingest?: IngestConfig;
70
+ /** Called after feedback submission with the report and result. */
71
+ onSubmit?: (report: FeedbackReport, result: FeedbackResult) => void;
72
+ }
73
+ type FeedbackType = 'bug' | 'feature' | 'improvement' | 'question';
74
+ type FeedbackSeverity = 'low' | 'medium' | 'high' | 'critical';
75
+ interface ConsoleLogEntry {
76
+ level: 'warn' | 'error';
77
+ message: string;
78
+ timestamp: string;
79
+ }
80
+ interface NetworkErrorEntry {
81
+ url: string;
82
+ method: string;
83
+ status: number | null;
84
+ statusText: string;
85
+ timestamp: string;
86
+ }
87
+ interface FeedbackReport {
88
+ type: FeedbackType;
89
+ severity: FeedbackSeverity;
90
+ title?: string;
91
+ description: string;
92
+ componentId: string;
93
+ element: string | null;
94
+ sources: {
95
+ filePath: string;
96
+ line: number;
97
+ }[];
98
+ url: string;
99
+ path: string;
100
+ route: string | null;
101
+ timestamp: string;
102
+ pageTitle: string;
103
+ locale: string;
104
+ sessionId: string;
105
+ viewport: {
106
+ width: number;
107
+ height: number;
108
+ };
109
+ screen: {
110
+ width: number;
111
+ height: number;
112
+ };
113
+ userAgent: string;
114
+ screenshot?: string;
115
+ reporterEmail?: string;
116
+ reporterName?: string;
117
+ environment?: string;
118
+ appVersion?: string;
119
+ metadata?: Record<string, string>;
120
+ consoleLogs?: ConsoleLogEntry[];
121
+ networkErrors?: NetworkErrorEntry[];
47
122
  }
48
123
  interface OverlayOptions {
49
124
  color?: string;
@@ -88,6 +163,11 @@ interface ModalData {
88
163
  interface ModalOptions {
89
164
  onComponentNavigate?: (id: string) => void;
90
165
  elementGetter?: (id: string) => Element | null;
166
+ ingest?: IngestConfig;
167
+ onSubmit?: (report: FeedbackReport, result: FeedbackResult) => void;
168
+ sessionId?: string;
169
+ getConsoleLogs?: () => ConsoleLogEntry[];
170
+ getNetworkErrors?: () => NetworkErrorEntry[];
91
171
  }
92
172
  declare class Modal {
93
173
  private backdrop;
@@ -187,6 +267,8 @@ declare class UidexUI {
187
267
  private copyTimer;
188
268
  private currentPresentIds;
189
269
  private activeMode;
270
+ private sessionId;
271
+ private capture;
190
272
  constructor(options?: UidexUIOptions);
191
273
  mount(container?: HTMLElement): void;
192
274
  destroy(): void;
@@ -277,6 +359,8 @@ declare class Overlay {
277
359
  private updateLabel;
278
360
  private applyLabelPosition;
279
361
  private updatePosition;
362
+ /** Move the label inside the overlay when there is no room outside. */
363
+ private clampLabel;
280
364
  private addListeners;
281
365
  private removeListeners;
282
366
  }
@@ -328,4 +412,30 @@ declare function getContrastColor(hexColor: string): string;
328
412
  declare function hexToRgba(hex: string, alpha: number): string;
329
413
  declare function resolveColor(color: string | undefined, colorMap?: Record<string, string>): string | undefined;
330
414
 
331
- export { type BorderStyle, type ButtonPosition, Inspector, type KeyboardShortcut, type LabelPosition, Menu, Modal, type ModalView, Overlay, type OverlayOptions, type UidexConfig, type UidexDefaults, type UidexFeature, type UidexLocation, type UidexMap, type UidexPage, UidexUI, type UidexUIOptions, classNames, createUidexUI, getComponents, getContrastColor, getFeatures, getPages, hexToRgba, injectStyles, registerComponents, registerFeatures, registerPages, resolveColor };
415
+ declare class IngestCapture {
416
+ private captureConsole;
417
+ private captureNetwork;
418
+ private consoleLogs;
419
+ private networkErrors;
420
+ private originalConsoleWarn;
421
+ private originalConsoleError;
422
+ private originalFetch;
423
+ constructor(captureConsole: boolean, captureNetwork: boolean);
424
+ start(): void;
425
+ stop(): void;
426
+ getConsoleLogs(): ConsoleLogEntry[];
427
+ getNetworkErrors(): NetworkErrorEntry[];
428
+ private interceptConsole;
429
+ private addConsoleLog;
430
+ private restoreConsole;
431
+ private interceptNetwork;
432
+ private addNetworkError;
433
+ private restoreNetwork;
434
+ }
435
+ declare function generateSessionId(): string;
436
+ declare function submitFeedback(endpoint: string, apiKey: string, report: FeedbackReport): Promise<{
437
+ id: string;
438
+ sequenceNumber: number;
439
+ }>;
440
+
441
+ export { type BorderStyle, type ButtonPosition, type ConsoleLogEntry, type FeedbackReport, type FeedbackResult, type FeedbackSeverity, type FeedbackType, IngestCapture, type IngestConfig, Inspector, type KeyboardShortcut, type LabelPosition, Menu, Modal, type ModalView, type NetworkErrorEntry, Overlay, type OverlayOptions, type UidexConfig, type UidexDefaults, type UidexFeature, type UidexLocation, type UidexMap, type UidexPage, UidexUI, type UidexUIOptions, classNames, createUidexUI, generateSessionId, getComponents, getContrastColor, getFeatures, getPages, hexToRgba, injectStyles, registerComponents, registerFeatures, registerPages, resolveColor, submitFeedback };
@@ -35,6 +35,27 @@ interface KeyboardShortcut {
35
35
  altKey?: boolean;
36
36
  metaKey?: boolean;
37
37
  }
38
+ interface IngestConfig {
39
+ endpoint: string;
40
+ apiKey: string;
41
+ environment?: string;
42
+ appVersion?: string;
43
+ reporter?: {
44
+ email?: string;
45
+ name?: string;
46
+ };
47
+ metadata?: Record<string, string>;
48
+ captureConsole?: boolean;
49
+ captureNetwork?: boolean;
50
+ }
51
+ type FeedbackResult = {
52
+ ok: true;
53
+ id: string;
54
+ sequenceNumber: number;
55
+ } | {
56
+ ok: false;
57
+ error: string;
58
+ };
38
59
  interface UidexUIOptions {
39
60
  components?: UidexMap;
40
61
  pages?: UidexPage[];
@@ -44,6 +65,60 @@ interface UidexUIOptions {
44
65
  onSelect?: (id: string) => void;
45
66
  /** Keyboard shortcut to toggle inspect mode. Set to false to disable. */
46
67
  inspectShortcut?: KeyboardShortcut | false;
68
+ /** Ingest configuration for submitting feedback to a server. */
69
+ ingest?: IngestConfig;
70
+ /** Called after feedback submission with the report and result. */
71
+ onSubmit?: (report: FeedbackReport, result: FeedbackResult) => void;
72
+ }
73
+ type FeedbackType = 'bug' | 'feature' | 'improvement' | 'question';
74
+ type FeedbackSeverity = 'low' | 'medium' | 'high' | 'critical';
75
+ interface ConsoleLogEntry {
76
+ level: 'warn' | 'error';
77
+ message: string;
78
+ timestamp: string;
79
+ }
80
+ interface NetworkErrorEntry {
81
+ url: string;
82
+ method: string;
83
+ status: number | null;
84
+ statusText: string;
85
+ timestamp: string;
86
+ }
87
+ interface FeedbackReport {
88
+ type: FeedbackType;
89
+ severity: FeedbackSeverity;
90
+ title?: string;
91
+ description: string;
92
+ componentId: string;
93
+ element: string | null;
94
+ sources: {
95
+ filePath: string;
96
+ line: number;
97
+ }[];
98
+ url: string;
99
+ path: string;
100
+ route: string | null;
101
+ timestamp: string;
102
+ pageTitle: string;
103
+ locale: string;
104
+ sessionId: string;
105
+ viewport: {
106
+ width: number;
107
+ height: number;
108
+ };
109
+ screen: {
110
+ width: number;
111
+ height: number;
112
+ };
113
+ userAgent: string;
114
+ screenshot?: string;
115
+ reporterEmail?: string;
116
+ reporterName?: string;
117
+ environment?: string;
118
+ appVersion?: string;
119
+ metadata?: Record<string, string>;
120
+ consoleLogs?: ConsoleLogEntry[];
121
+ networkErrors?: NetworkErrorEntry[];
47
122
  }
48
123
  interface OverlayOptions {
49
124
  color?: string;
@@ -88,6 +163,11 @@ interface ModalData {
88
163
  interface ModalOptions {
89
164
  onComponentNavigate?: (id: string) => void;
90
165
  elementGetter?: (id: string) => Element | null;
166
+ ingest?: IngestConfig;
167
+ onSubmit?: (report: FeedbackReport, result: FeedbackResult) => void;
168
+ sessionId?: string;
169
+ getConsoleLogs?: () => ConsoleLogEntry[];
170
+ getNetworkErrors?: () => NetworkErrorEntry[];
91
171
  }
92
172
  declare class Modal {
93
173
  private backdrop;
@@ -187,6 +267,8 @@ declare class UidexUI {
187
267
  private copyTimer;
188
268
  private currentPresentIds;
189
269
  private activeMode;
270
+ private sessionId;
271
+ private capture;
190
272
  constructor(options?: UidexUIOptions);
191
273
  mount(container?: HTMLElement): void;
192
274
  destroy(): void;
@@ -277,6 +359,8 @@ declare class Overlay {
277
359
  private updateLabel;
278
360
  private applyLabelPosition;
279
361
  private updatePosition;
362
+ /** Move the label inside the overlay when there is no room outside. */
363
+ private clampLabel;
280
364
  private addListeners;
281
365
  private removeListeners;
282
366
  }
@@ -328,4 +412,30 @@ declare function getContrastColor(hexColor: string): string;
328
412
  declare function hexToRgba(hex: string, alpha: number): string;
329
413
  declare function resolveColor(color: string | undefined, colorMap?: Record<string, string>): string | undefined;
330
414
 
331
- export { type BorderStyle, type ButtonPosition, Inspector, type KeyboardShortcut, type LabelPosition, Menu, Modal, type ModalView, Overlay, type OverlayOptions, type UidexConfig, type UidexDefaults, type UidexFeature, type UidexLocation, type UidexMap, type UidexPage, UidexUI, type UidexUIOptions, classNames, createUidexUI, getComponents, getContrastColor, getFeatures, getPages, hexToRgba, injectStyles, registerComponents, registerFeatures, registerPages, resolveColor };
415
+ declare class IngestCapture {
416
+ private captureConsole;
417
+ private captureNetwork;
418
+ private consoleLogs;
419
+ private networkErrors;
420
+ private originalConsoleWarn;
421
+ private originalConsoleError;
422
+ private originalFetch;
423
+ constructor(captureConsole: boolean, captureNetwork: boolean);
424
+ start(): void;
425
+ stop(): void;
426
+ getConsoleLogs(): ConsoleLogEntry[];
427
+ getNetworkErrors(): NetworkErrorEntry[];
428
+ private interceptConsole;
429
+ private addConsoleLog;
430
+ private restoreConsole;
431
+ private interceptNetwork;
432
+ private addNetworkError;
433
+ private restoreNetwork;
434
+ }
435
+ declare function generateSessionId(): string;
436
+ declare function submitFeedback(endpoint: string, apiKey: string, report: FeedbackReport): Promise<{
437
+ id: string;
438
+ sequenceNumber: number;
439
+ }>;
440
+
441
+ export { type BorderStyle, type ButtonPosition, type ConsoleLogEntry, type FeedbackReport, type FeedbackResult, type FeedbackSeverity, type FeedbackType, IngestCapture, type IngestConfig, Inspector, type KeyboardShortcut, type LabelPosition, Menu, Modal, type ModalView, type NetworkErrorEntry, Overlay, type OverlayOptions, type UidexConfig, type UidexDefaults, type UidexFeature, type UidexLocation, type UidexMap, type UidexPage, UidexUI, type UidexUIOptions, classNames, createUidexUI, generateSessionId, getComponents, getContrastColor, getFeatures, getPages, hexToRgba, injectStyles, registerComponents, registerFeatures, registerPages, resolveColor, submitFeedback };