@pocketping/widget 1.1.0 → 1.2.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/dist/index.cjs +1157 -90
- package/dist/index.d.cts +75 -3
- package/dist/index.d.ts +75 -3
- package/dist/index.js +1154 -89
- package/dist/pocketping.min.global.js +493 -7
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -65,6 +65,16 @@ interface PocketPingConfig {
|
|
|
65
65
|
onVersionWarning?: (warning: VersionWarning) => void;
|
|
66
66
|
}
|
|
67
67
|
type MessageStatus = 'sending' | 'sent' | 'delivered' | 'read';
|
|
68
|
+
type AttachmentStatus = 'pending' | 'uploading' | 'ready' | 'failed';
|
|
69
|
+
interface Attachment {
|
|
70
|
+
id: string;
|
|
71
|
+
filename: string;
|
|
72
|
+
mimeType: string;
|
|
73
|
+
size: number;
|
|
74
|
+
url: string;
|
|
75
|
+
thumbnailUrl?: string;
|
|
76
|
+
status: AttachmentStatus;
|
|
77
|
+
}
|
|
68
78
|
interface Message {
|
|
69
79
|
id: string;
|
|
70
80
|
sessionId: string;
|
|
@@ -73,9 +83,12 @@ interface Message {
|
|
|
73
83
|
timestamp: string;
|
|
74
84
|
replyTo?: string;
|
|
75
85
|
metadata?: Record<string, unknown>;
|
|
86
|
+
attachments?: Attachment[];
|
|
76
87
|
status?: MessageStatus;
|
|
77
88
|
deliveredAt?: string;
|
|
78
89
|
readAt?: string;
|
|
90
|
+
editedAt?: string;
|
|
91
|
+
deletedAt?: string;
|
|
79
92
|
}
|
|
80
93
|
interface Session {
|
|
81
94
|
sessionId: string;
|
|
@@ -191,10 +204,44 @@ declare class PocketPingClient {
|
|
|
191
204
|
constructor(config: ResolvedPocketPingConfig);
|
|
192
205
|
connect(): Promise<Session>;
|
|
193
206
|
disconnect(): void;
|
|
194
|
-
sendMessage(content: string): Promise<Message>;
|
|
207
|
+
sendMessage(content: string, attachmentIds?: string[], replyTo?: string): Promise<Message>;
|
|
208
|
+
/**
|
|
209
|
+
* Upload a file attachment
|
|
210
|
+
* Returns the attachment data after successful upload
|
|
211
|
+
* @param file - File object to upload
|
|
212
|
+
* @param onProgress - Optional callback for upload progress (0-100)
|
|
213
|
+
* @example
|
|
214
|
+
* const attachment = await PocketPing.uploadFile(file, (progress) => {
|
|
215
|
+
* console.log(`Upload ${progress}% complete`)
|
|
216
|
+
* })
|
|
217
|
+
* await PocketPing.sendMessage('Check this file', [attachment.id])
|
|
218
|
+
*/
|
|
219
|
+
uploadFile(file: File, onProgress?: (progress: number) => void): Promise<Attachment>;
|
|
220
|
+
/**
|
|
221
|
+
* Upload multiple files at once
|
|
222
|
+
* @param files - Array of File objects to upload
|
|
223
|
+
* @param onProgress - Optional callback for overall progress (0-100)
|
|
224
|
+
* @returns Array of uploaded attachments
|
|
225
|
+
*/
|
|
226
|
+
uploadFiles(files: File[], onProgress?: (progress: number) => void): Promise<Attachment[]>;
|
|
227
|
+
/**
|
|
228
|
+
* Upload file to presigned URL with progress tracking
|
|
229
|
+
*/
|
|
230
|
+
private uploadToPresignedUrl;
|
|
195
231
|
fetchMessages(after?: string): Promise<Message[]>;
|
|
196
232
|
sendTyping(isTyping?: boolean): Promise<void>;
|
|
197
233
|
sendReadStatus(messageIds: string[], status: MessageStatus): Promise<void>;
|
|
234
|
+
/**
|
|
235
|
+
* Edit a message (visitor can only edit their own messages)
|
|
236
|
+
* @param messageId - ID of the message to edit
|
|
237
|
+
* @param content - New content for the message
|
|
238
|
+
*/
|
|
239
|
+
editMessage(messageId: string, content: string): Promise<Message>;
|
|
240
|
+
/**
|
|
241
|
+
* Delete a message (soft delete - visitor can only delete their own messages)
|
|
242
|
+
* @param messageId - ID of the message to delete
|
|
243
|
+
*/
|
|
244
|
+
deleteMessage(messageId: string): Promise<boolean>;
|
|
198
245
|
getPresence(): Promise<PresenceResponse>;
|
|
199
246
|
/**
|
|
200
247
|
* Identify the current user with metadata
|
|
@@ -315,7 +362,30 @@ declare function destroy(): void;
|
|
|
315
362
|
declare function open(): void;
|
|
316
363
|
declare function close(): void;
|
|
317
364
|
declare function toggle(): void;
|
|
318
|
-
declare function sendMessage(content: string): Promise<Message>;
|
|
365
|
+
declare function sendMessage(content: string, attachmentIds?: string[]): Promise<Message>;
|
|
366
|
+
/**
|
|
367
|
+
* Upload a file attachment
|
|
368
|
+
* Returns the attachment data after successful upload
|
|
369
|
+
* @param file - File object to upload
|
|
370
|
+
* @param onProgress - Optional callback for upload progress (0-100)
|
|
371
|
+
* @example
|
|
372
|
+
* const attachment = await PocketPing.uploadFile(file, (progress) => {
|
|
373
|
+
* console.log(`Upload ${progress}% complete`)
|
|
374
|
+
* })
|
|
375
|
+
* await PocketPing.sendMessage('Check this file', [attachment.id])
|
|
376
|
+
*/
|
|
377
|
+
declare function uploadFile(file: File, onProgress?: (progress: number) => void): Promise<Attachment>;
|
|
378
|
+
/**
|
|
379
|
+
* Upload multiple files at once
|
|
380
|
+
* @param files - Array of File objects to upload
|
|
381
|
+
* @param onProgress - Optional callback for overall progress (0-100)
|
|
382
|
+
* @returns Array of uploaded attachments
|
|
383
|
+
* @example
|
|
384
|
+
* const attachments = await PocketPing.uploadFiles(files)
|
|
385
|
+
* const ids = attachments.map(a => a.id)
|
|
386
|
+
* await PocketPing.sendMessage('Here are the files', ids)
|
|
387
|
+
*/
|
|
388
|
+
declare function uploadFiles(files: File[], onProgress?: (progress: number) => void): Promise<Attachment[]>;
|
|
319
389
|
/**
|
|
320
390
|
* Trigger a custom event to the backend
|
|
321
391
|
* @param eventName - The name of the event (e.g., 'clicked_pricing', 'viewed_demo')
|
|
@@ -413,6 +483,8 @@ declare const _default: {
|
|
|
413
483
|
close: typeof close;
|
|
414
484
|
toggle: typeof toggle;
|
|
415
485
|
sendMessage: typeof sendMessage;
|
|
486
|
+
uploadFile: typeof uploadFile;
|
|
487
|
+
uploadFiles: typeof uploadFiles;
|
|
416
488
|
trigger: typeof trigger;
|
|
417
489
|
onEvent: typeof onEvent;
|
|
418
490
|
offEvent: typeof offEvent;
|
|
@@ -424,4 +496,4 @@ declare const _default: {
|
|
|
424
496
|
getTrackedElements: typeof getTrackedElements;
|
|
425
497
|
};
|
|
426
498
|
|
|
427
|
-
export { type CustomEvent, type CustomEventHandler, type Message, type PocketPingConfig, type TrackedElement, type TriggerOptions, type UserIdentity, type VersionWarning, close, _default as default, destroy, getIdentity, getTrackedElements, identify, init, offEvent, on, onEvent, open, reset, sendMessage, setupTrackedElements, toggle, trigger };
|
|
499
|
+
export { type Attachment, type CustomEvent, type CustomEventHandler, type Message, type PocketPingConfig, type TrackedElement, type TriggerOptions, type UserIdentity, type VersionWarning, close, _default as default, destroy, getIdentity, getTrackedElements, identify, init, offEvent, on, onEvent, open, reset, sendMessage, setupTrackedElements, toggle, trigger, uploadFile, uploadFiles };
|
package/dist/index.d.ts
CHANGED
|
@@ -65,6 +65,16 @@ interface PocketPingConfig {
|
|
|
65
65
|
onVersionWarning?: (warning: VersionWarning) => void;
|
|
66
66
|
}
|
|
67
67
|
type MessageStatus = 'sending' | 'sent' | 'delivered' | 'read';
|
|
68
|
+
type AttachmentStatus = 'pending' | 'uploading' | 'ready' | 'failed';
|
|
69
|
+
interface Attachment {
|
|
70
|
+
id: string;
|
|
71
|
+
filename: string;
|
|
72
|
+
mimeType: string;
|
|
73
|
+
size: number;
|
|
74
|
+
url: string;
|
|
75
|
+
thumbnailUrl?: string;
|
|
76
|
+
status: AttachmentStatus;
|
|
77
|
+
}
|
|
68
78
|
interface Message {
|
|
69
79
|
id: string;
|
|
70
80
|
sessionId: string;
|
|
@@ -73,9 +83,12 @@ interface Message {
|
|
|
73
83
|
timestamp: string;
|
|
74
84
|
replyTo?: string;
|
|
75
85
|
metadata?: Record<string, unknown>;
|
|
86
|
+
attachments?: Attachment[];
|
|
76
87
|
status?: MessageStatus;
|
|
77
88
|
deliveredAt?: string;
|
|
78
89
|
readAt?: string;
|
|
90
|
+
editedAt?: string;
|
|
91
|
+
deletedAt?: string;
|
|
79
92
|
}
|
|
80
93
|
interface Session {
|
|
81
94
|
sessionId: string;
|
|
@@ -191,10 +204,44 @@ declare class PocketPingClient {
|
|
|
191
204
|
constructor(config: ResolvedPocketPingConfig);
|
|
192
205
|
connect(): Promise<Session>;
|
|
193
206
|
disconnect(): void;
|
|
194
|
-
sendMessage(content: string): Promise<Message>;
|
|
207
|
+
sendMessage(content: string, attachmentIds?: string[], replyTo?: string): Promise<Message>;
|
|
208
|
+
/**
|
|
209
|
+
* Upload a file attachment
|
|
210
|
+
* Returns the attachment data after successful upload
|
|
211
|
+
* @param file - File object to upload
|
|
212
|
+
* @param onProgress - Optional callback for upload progress (0-100)
|
|
213
|
+
* @example
|
|
214
|
+
* const attachment = await PocketPing.uploadFile(file, (progress) => {
|
|
215
|
+
* console.log(`Upload ${progress}% complete`)
|
|
216
|
+
* })
|
|
217
|
+
* await PocketPing.sendMessage('Check this file', [attachment.id])
|
|
218
|
+
*/
|
|
219
|
+
uploadFile(file: File, onProgress?: (progress: number) => void): Promise<Attachment>;
|
|
220
|
+
/**
|
|
221
|
+
* Upload multiple files at once
|
|
222
|
+
* @param files - Array of File objects to upload
|
|
223
|
+
* @param onProgress - Optional callback for overall progress (0-100)
|
|
224
|
+
* @returns Array of uploaded attachments
|
|
225
|
+
*/
|
|
226
|
+
uploadFiles(files: File[], onProgress?: (progress: number) => void): Promise<Attachment[]>;
|
|
227
|
+
/**
|
|
228
|
+
* Upload file to presigned URL with progress tracking
|
|
229
|
+
*/
|
|
230
|
+
private uploadToPresignedUrl;
|
|
195
231
|
fetchMessages(after?: string): Promise<Message[]>;
|
|
196
232
|
sendTyping(isTyping?: boolean): Promise<void>;
|
|
197
233
|
sendReadStatus(messageIds: string[], status: MessageStatus): Promise<void>;
|
|
234
|
+
/**
|
|
235
|
+
* Edit a message (visitor can only edit their own messages)
|
|
236
|
+
* @param messageId - ID of the message to edit
|
|
237
|
+
* @param content - New content for the message
|
|
238
|
+
*/
|
|
239
|
+
editMessage(messageId: string, content: string): Promise<Message>;
|
|
240
|
+
/**
|
|
241
|
+
* Delete a message (soft delete - visitor can only delete their own messages)
|
|
242
|
+
* @param messageId - ID of the message to delete
|
|
243
|
+
*/
|
|
244
|
+
deleteMessage(messageId: string): Promise<boolean>;
|
|
198
245
|
getPresence(): Promise<PresenceResponse>;
|
|
199
246
|
/**
|
|
200
247
|
* Identify the current user with metadata
|
|
@@ -315,7 +362,30 @@ declare function destroy(): void;
|
|
|
315
362
|
declare function open(): void;
|
|
316
363
|
declare function close(): void;
|
|
317
364
|
declare function toggle(): void;
|
|
318
|
-
declare function sendMessage(content: string): Promise<Message>;
|
|
365
|
+
declare function sendMessage(content: string, attachmentIds?: string[]): Promise<Message>;
|
|
366
|
+
/**
|
|
367
|
+
* Upload a file attachment
|
|
368
|
+
* Returns the attachment data after successful upload
|
|
369
|
+
* @param file - File object to upload
|
|
370
|
+
* @param onProgress - Optional callback for upload progress (0-100)
|
|
371
|
+
* @example
|
|
372
|
+
* const attachment = await PocketPing.uploadFile(file, (progress) => {
|
|
373
|
+
* console.log(`Upload ${progress}% complete`)
|
|
374
|
+
* })
|
|
375
|
+
* await PocketPing.sendMessage('Check this file', [attachment.id])
|
|
376
|
+
*/
|
|
377
|
+
declare function uploadFile(file: File, onProgress?: (progress: number) => void): Promise<Attachment>;
|
|
378
|
+
/**
|
|
379
|
+
* Upload multiple files at once
|
|
380
|
+
* @param files - Array of File objects to upload
|
|
381
|
+
* @param onProgress - Optional callback for overall progress (0-100)
|
|
382
|
+
* @returns Array of uploaded attachments
|
|
383
|
+
* @example
|
|
384
|
+
* const attachments = await PocketPing.uploadFiles(files)
|
|
385
|
+
* const ids = attachments.map(a => a.id)
|
|
386
|
+
* await PocketPing.sendMessage('Here are the files', ids)
|
|
387
|
+
*/
|
|
388
|
+
declare function uploadFiles(files: File[], onProgress?: (progress: number) => void): Promise<Attachment[]>;
|
|
319
389
|
/**
|
|
320
390
|
* Trigger a custom event to the backend
|
|
321
391
|
* @param eventName - The name of the event (e.g., 'clicked_pricing', 'viewed_demo')
|
|
@@ -413,6 +483,8 @@ declare const _default: {
|
|
|
413
483
|
close: typeof close;
|
|
414
484
|
toggle: typeof toggle;
|
|
415
485
|
sendMessage: typeof sendMessage;
|
|
486
|
+
uploadFile: typeof uploadFile;
|
|
487
|
+
uploadFiles: typeof uploadFiles;
|
|
416
488
|
trigger: typeof trigger;
|
|
417
489
|
onEvent: typeof onEvent;
|
|
418
490
|
offEvent: typeof offEvent;
|
|
@@ -424,4 +496,4 @@ declare const _default: {
|
|
|
424
496
|
getTrackedElements: typeof getTrackedElements;
|
|
425
497
|
};
|
|
426
498
|
|
|
427
|
-
export { type CustomEvent, type CustomEventHandler, type Message, type PocketPingConfig, type TrackedElement, type TriggerOptions, type UserIdentity, type VersionWarning, close, _default as default, destroy, getIdentity, getTrackedElements, identify, init, offEvent, on, onEvent, open, reset, sendMessage, setupTrackedElements, toggle, trigger };
|
|
499
|
+
export { type Attachment, type CustomEvent, type CustomEventHandler, type Message, type PocketPingConfig, type TrackedElement, type TriggerOptions, type UserIdentity, type VersionWarning, close, _default as default, destroy, getIdentity, getTrackedElements, identify, init, offEvent, on, onEvent, open, reset, sendMessage, setupTrackedElements, toggle, trigger, uploadFile, uploadFiles };
|