iframe-pubsub 1.0.4 → 1.0.6

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.d.mts CHANGED
@@ -83,11 +83,10 @@ declare enum AIChatNameEnum {
83
83
  SHOW_SUGGESTIONS = "showSuggestions",
84
84
  SHOW_CHAT_MESSAGE = "showChatMessage",
85
85
  SHOW_ERROR_MESSAGE = "showErrorMessage",
86
- SHOW_UNKNOWN_MESSAGE = "showUnknownMessage",
86
+ SHOW_COMING_SOON = "showComingSoon",
87
87
  CONFIRM_ACTION = "confirmAction",
88
88
  SHOW_OPTIONS = "showOptions",
89
89
  SEND_CHAT_PROMPT = "sendChatPrompt",
90
- GENERIC_ACTION = "genericAction",
91
90
  OPEN_INTERCOM = "openIntercom",
92
91
  DEFAULT = "default"
93
92
  }
@@ -98,7 +97,7 @@ declare class AIChatClient extends Client {
98
97
  * @param pageId The ID of the page or component to register to.
99
98
  */
100
99
  constructor(pageId: string);
101
- private sendAIChatMethod;
100
+ private sendAIChatPubsubMethod;
102
101
  /**
103
102
  * Set the parent name then the AI Chat can know who should it communicate with.
104
103
  *
@@ -141,6 +140,12 @@ declare class AIChatClient extends Client {
141
140
  * @param message The message to show.
142
141
  */
143
142
  showChatMessage(message: string): void;
143
+ /**
144
+ * Show an error message in the AI Chat component.
145
+ *
146
+ * @param message The error message to show.
147
+ */
148
+ showErrorMessage(message: string): void;
144
149
  /**
145
150
  * Confirm an action in the AI Chat component.
146
151
  *
@@ -159,16 +164,10 @@ declare class AIChatClient extends Client {
159
164
  * @param prompt The prompt to send.
160
165
  */
161
166
  sendChatPrompt(prompt: string): void;
162
- /**
163
- * Show an error message in the AI Chat component.
164
- *
165
- * @param message The error message to show.
166
- */
167
- showErrorMessage(message: string): void;
168
167
  /**
169
168
  * Show an unknown error message in the AI Chat component.
170
169
  */
171
- showUnknownMessage(): void;
170
+ showComingSoon(): void;
172
171
  }
173
172
 
174
173
  declare class PubSub {
package/dist/index.d.ts CHANGED
@@ -83,11 +83,10 @@ declare enum AIChatNameEnum {
83
83
  SHOW_SUGGESTIONS = "showSuggestions",
84
84
  SHOW_CHAT_MESSAGE = "showChatMessage",
85
85
  SHOW_ERROR_MESSAGE = "showErrorMessage",
86
- SHOW_UNKNOWN_MESSAGE = "showUnknownMessage",
86
+ SHOW_COMING_SOON = "showComingSoon",
87
87
  CONFIRM_ACTION = "confirmAction",
88
88
  SHOW_OPTIONS = "showOptions",
89
89
  SEND_CHAT_PROMPT = "sendChatPrompt",
90
- GENERIC_ACTION = "genericAction",
91
90
  OPEN_INTERCOM = "openIntercom",
92
91
  DEFAULT = "default"
93
92
  }
@@ -98,7 +97,7 @@ declare class AIChatClient extends Client {
98
97
  * @param pageId The ID of the page or component to register to.
99
98
  */
100
99
  constructor(pageId: string);
101
- private sendAIChatMethod;
100
+ private sendAIChatPubsubMethod;
102
101
  /**
103
102
  * Set the parent name then the AI Chat can know who should it communicate with.
104
103
  *
@@ -141,6 +140,12 @@ declare class AIChatClient extends Client {
141
140
  * @param message The message to show.
142
141
  */
143
142
  showChatMessage(message: string): void;
143
+ /**
144
+ * Show an error message in the AI Chat component.
145
+ *
146
+ * @param message The error message to show.
147
+ */
148
+ showErrorMessage(message: string): void;
144
149
  /**
145
150
  * Confirm an action in the AI Chat component.
146
151
  *
@@ -159,16 +164,10 @@ declare class AIChatClient extends Client {
159
164
  * @param prompt The prompt to send.
160
165
  */
161
166
  sendChatPrompt(prompt: string): void;
162
- /**
163
- * Show an error message in the AI Chat component.
164
- *
165
- * @param message The error message to show.
166
- */
167
- showErrorMessage(message: string): void;
168
167
  /**
169
168
  * Show an unknown error message in the AI Chat component.
170
169
  */
171
- showUnknownMessage(): void;
170
+ showComingSoon(): void;
172
171
  }
173
172
 
174
173
  declare class PubSub {
package/dist/index.js CHANGED
@@ -308,11 +308,10 @@ var AIChatNameEnum = /* @__PURE__ */ ((AIChatNameEnum2) => {
308
308
  AIChatNameEnum2["SHOW_SUGGESTIONS"] = "showSuggestions";
309
309
  AIChatNameEnum2["SHOW_CHAT_MESSAGE"] = "showChatMessage";
310
310
  AIChatNameEnum2["SHOW_ERROR_MESSAGE"] = "showErrorMessage";
311
- AIChatNameEnum2["SHOW_UNKNOWN_MESSAGE"] = "showUnknownMessage";
311
+ AIChatNameEnum2["SHOW_COMING_SOON"] = "showComingSoon";
312
312
  AIChatNameEnum2["CONFIRM_ACTION"] = "confirmAction";
313
313
  AIChatNameEnum2["SHOW_OPTIONS"] = "showOptions";
314
314
  AIChatNameEnum2["SEND_CHAT_PROMPT"] = "sendChatPrompt";
315
- AIChatNameEnum2["GENERIC_ACTION"] = "genericAction";
316
315
  AIChatNameEnum2["OPEN_INTERCOM"] = "openIntercom";
317
316
  AIChatNameEnum2["DEFAULT"] = "default";
318
317
  return AIChatNameEnum2;
@@ -326,7 +325,7 @@ var AIChatClient = class extends Client {
326
325
  constructor(pageId) {
327
326
  super(pageId);
328
327
  }
329
- sendAIChatMethod(methodName, arg) {
328
+ sendAIChatPubsubMethod(methodName, arg) {
330
329
  this.sendMessage(
331
330
  "aichat" /* AI_CHAT_CLIENT_ID */,
332
331
  // This name is hardcode, do not change it
@@ -344,7 +343,7 @@ var AIChatClient = class extends Client {
344
343
  * @param parentName The name of the parent page.
345
344
  */
346
345
  setParentName(parentName) {
347
- this.sendAIChatMethod("setParentName" /* SET_PARENT_NAME */, parentName);
346
+ this.sendAIChatPubsubMethod("setParentName" /* SET_PARENT_NAME */, parentName);
348
347
  }
349
348
  /**
350
349
  * Set the user ID for the AI Chat component.
@@ -352,7 +351,7 @@ var AIChatClient = class extends Client {
352
351
  * @param userId The user ID.
353
352
  */
354
353
  setUserId(userId) {
355
- this.sendAIChatMethod("setUserId" /* SET_USER_ID */, userId);
354
+ this.sendAIChatPubsubMethod("setUserId" /* SET_USER_ID */, userId);
356
355
  }
357
356
  /**
358
357
  * Set custom headers for the AI Chat component.
@@ -360,7 +359,7 @@ var AIChatClient = class extends Client {
360
359
  * @param headers The custom headers.
361
360
  */
362
361
  setCustomHeaders(headers) {
363
- this.sendAIChatMethod("setCustomHeaders" /* SET_CUSTOM_HEADERS */, headers);
362
+ this.sendAIChatPubsubMethod("setCustomHeaders" /* SET_CUSTOM_HEADERS */, headers);
364
363
  }
365
364
  /**
366
365
  * Set custom payload for the AI Chat component.
@@ -368,7 +367,7 @@ var AIChatClient = class extends Client {
368
367
  * @param payload The custom payload.
369
368
  */
370
369
  setCustomPayload(payload) {
371
- this.sendAIChatMethod("setCustomPayload" /* SET_CUSTOM_PAYLOAD */, payload);
370
+ this.sendAIChatPubsubMethod("setCustomPayload" /* SET_CUSTOM_PAYLOAD */, payload);
372
371
  }
373
372
  /**
374
373
  * Set suggestions for the AI Chat component.
@@ -376,7 +375,7 @@ var AIChatClient = class extends Client {
376
375
  * @param suggestions The suggestions to set.
377
376
  */
378
377
  setSuggestions(suggestions) {
379
- this.sendAIChatMethod("setSuggestions" /* SET_SUGGESTIONS */, suggestions);
378
+ this.sendAIChatPubsubMethod("setSuggestions" /* SET_SUGGESTIONS */, suggestions);
380
379
  }
381
380
  /**
382
381
  * Show suggestions in the AI Chat component.
@@ -384,7 +383,7 @@ var AIChatClient = class extends Client {
384
383
  * @param show Whether to show suggestions.
385
384
  */
386
385
  showSuggestions(show) {
387
- this.sendAIChatMethod("showSuggestions" /* SHOW_SUGGESTIONS */, show);
386
+ this.sendAIChatPubsubMethod("showSuggestions" /* SHOW_SUGGESTIONS */, show);
388
387
  }
389
388
  /**
390
389
  * Show a chat message in the AI Chat component.
@@ -392,7 +391,27 @@ var AIChatClient = class extends Client {
392
391
  * @param message The message to show.
393
392
  */
394
393
  showChatMessage(message) {
395
- this.sendAIChatMethod("showChatMessage" /* SHOW_CHAT_MESSAGE */, message);
394
+ this.sendMessage("aichat" /* AI_CHAT_CLIENT_ID */, {
395
+ type: "aichat" /* AI_CHAT_CLIENT_ID */,
396
+ name: "showChatMessage" /* SHOW_CHAT_MESSAGE */,
397
+ parameters: {
398
+ message
399
+ }
400
+ });
401
+ }
402
+ /**
403
+ * Show an error message in the AI Chat component.
404
+ *
405
+ * @param message The error message to show.
406
+ */
407
+ showErrorMessage(message) {
408
+ this.sendMessage("aichat" /* AI_CHAT_CLIENT_ID */, {
409
+ type: "aichat" /* AI_CHAT_CLIENT_ID */,
410
+ name: "showErrorMessage" /* SHOW_ERROR_MESSAGE */,
411
+ parameters: {
412
+ message
413
+ }
414
+ });
396
415
  }
397
416
  /**
398
417
  * Confirm an action in the AI Chat component.
@@ -400,7 +419,13 @@ var AIChatClient = class extends Client {
400
419
  * @param action The action to confirm.
401
420
  */
402
421
  confirmAction(action) {
403
- this.sendAIChatMethod("confirmAction" /* CONFIRM_ACTION */, action);
422
+ this.sendMessage("aichat" /* AI_CHAT_CLIENT_ID */, {
423
+ type: "aichat" /* AI_CHAT_CLIENT_ID */,
424
+ name: "confirmAction" /* CONFIRM_ACTION */,
425
+ parameters: {
426
+ action
427
+ }
428
+ });
404
429
  }
405
430
  /**
406
431
  * Show options in the AI Chat component.
@@ -408,7 +433,13 @@ var AIChatClient = class extends Client {
408
433
  * @param options The options to show.
409
434
  */
410
435
  showOptions(options) {
411
- this.sendAIChatMethod("showOptions" /* SHOW_OPTIONS */, options);
436
+ this.sendMessage("aichat" /* AI_CHAT_CLIENT_ID */, {
437
+ type: "aichat" /* AI_CHAT_CLIENT_ID */,
438
+ name: "showOptions" /* SHOW_OPTIONS */,
439
+ parameters: {
440
+ options
441
+ }
442
+ });
412
443
  }
413
444
  /**
414
445
  * Send a chat prompt to the AI Chat component.
@@ -416,21 +447,26 @@ var AIChatClient = class extends Client {
416
447
  * @param prompt The prompt to send.
417
448
  */
418
449
  sendChatPrompt(prompt) {
419
- this.sendAIChatMethod("sendChatPrompt" /* SEND_CHAT_PROMPT */, prompt);
420
- }
421
- /**
422
- * Show an error message in the AI Chat component.
423
- *
424
- * @param message The error message to show.
425
- */
426
- showErrorMessage(message) {
427
- this.sendAIChatMethod("showErrorMessage" /* SHOW_ERROR_MESSAGE */, message);
450
+ this.sendMessage("aichat" /* AI_CHAT_CLIENT_ID */, {
451
+ type: "aichat" /* AI_CHAT_CLIENT_ID */,
452
+ name: "sendChatPrompt" /* SEND_CHAT_PROMPT */,
453
+ parameters: {
454
+ message: prompt
455
+ }
456
+ });
428
457
  }
429
458
  /**
430
459
  * Show an unknown error message in the AI Chat component.
431
460
  */
432
- showUnknownMessage() {
433
- this.sendAIChatMethod("showUnknownMessage" /* SHOW_UNKNOWN_MESSAGE */, "unknown_error");
461
+ showComingSoon() {
462
+ this.sendMessage("aichat" /* AI_CHAT_CLIENT_ID */, {
463
+ type: "aichat" /* AI_CHAT_CLIENT_ID */,
464
+ name: "showComingSoon" /* SHOW_COMING_SOON */,
465
+ parameters: {
466
+ message: "coming_soon"
467
+ // Not used
468
+ }
469
+ });
434
470
  }
435
471
  };
436
472
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -281,11 +281,10 @@ var AIChatNameEnum = /* @__PURE__ */ ((AIChatNameEnum2) => {
281
281
  AIChatNameEnum2["SHOW_SUGGESTIONS"] = "showSuggestions";
282
282
  AIChatNameEnum2["SHOW_CHAT_MESSAGE"] = "showChatMessage";
283
283
  AIChatNameEnum2["SHOW_ERROR_MESSAGE"] = "showErrorMessage";
284
- AIChatNameEnum2["SHOW_UNKNOWN_MESSAGE"] = "showUnknownMessage";
284
+ AIChatNameEnum2["SHOW_COMING_SOON"] = "showComingSoon";
285
285
  AIChatNameEnum2["CONFIRM_ACTION"] = "confirmAction";
286
286
  AIChatNameEnum2["SHOW_OPTIONS"] = "showOptions";
287
287
  AIChatNameEnum2["SEND_CHAT_PROMPT"] = "sendChatPrompt";
288
- AIChatNameEnum2["GENERIC_ACTION"] = "genericAction";
289
288
  AIChatNameEnum2["OPEN_INTERCOM"] = "openIntercom";
290
289
  AIChatNameEnum2["DEFAULT"] = "default";
291
290
  return AIChatNameEnum2;
@@ -299,7 +298,7 @@ var AIChatClient = class extends Client {
299
298
  constructor(pageId) {
300
299
  super(pageId);
301
300
  }
302
- sendAIChatMethod(methodName, arg) {
301
+ sendAIChatPubsubMethod(methodName, arg) {
303
302
  this.sendMessage(
304
303
  "aichat" /* AI_CHAT_CLIENT_ID */,
305
304
  // This name is hardcode, do not change it
@@ -317,7 +316,7 @@ var AIChatClient = class extends Client {
317
316
  * @param parentName The name of the parent page.
318
317
  */
319
318
  setParentName(parentName) {
320
- this.sendAIChatMethod("setParentName" /* SET_PARENT_NAME */, parentName);
319
+ this.sendAIChatPubsubMethod("setParentName" /* SET_PARENT_NAME */, parentName);
321
320
  }
322
321
  /**
323
322
  * Set the user ID for the AI Chat component.
@@ -325,7 +324,7 @@ var AIChatClient = class extends Client {
325
324
  * @param userId The user ID.
326
325
  */
327
326
  setUserId(userId) {
328
- this.sendAIChatMethod("setUserId" /* SET_USER_ID */, userId);
327
+ this.sendAIChatPubsubMethod("setUserId" /* SET_USER_ID */, userId);
329
328
  }
330
329
  /**
331
330
  * Set custom headers for the AI Chat component.
@@ -333,7 +332,7 @@ var AIChatClient = class extends Client {
333
332
  * @param headers The custom headers.
334
333
  */
335
334
  setCustomHeaders(headers) {
336
- this.sendAIChatMethod("setCustomHeaders" /* SET_CUSTOM_HEADERS */, headers);
335
+ this.sendAIChatPubsubMethod("setCustomHeaders" /* SET_CUSTOM_HEADERS */, headers);
337
336
  }
338
337
  /**
339
338
  * Set custom payload for the AI Chat component.
@@ -341,7 +340,7 @@ var AIChatClient = class extends Client {
341
340
  * @param payload The custom payload.
342
341
  */
343
342
  setCustomPayload(payload) {
344
- this.sendAIChatMethod("setCustomPayload" /* SET_CUSTOM_PAYLOAD */, payload);
343
+ this.sendAIChatPubsubMethod("setCustomPayload" /* SET_CUSTOM_PAYLOAD */, payload);
345
344
  }
346
345
  /**
347
346
  * Set suggestions for the AI Chat component.
@@ -349,7 +348,7 @@ var AIChatClient = class extends Client {
349
348
  * @param suggestions The suggestions to set.
350
349
  */
351
350
  setSuggestions(suggestions) {
352
- this.sendAIChatMethod("setSuggestions" /* SET_SUGGESTIONS */, suggestions);
351
+ this.sendAIChatPubsubMethod("setSuggestions" /* SET_SUGGESTIONS */, suggestions);
353
352
  }
354
353
  /**
355
354
  * Show suggestions in the AI Chat component.
@@ -357,7 +356,7 @@ var AIChatClient = class extends Client {
357
356
  * @param show Whether to show suggestions.
358
357
  */
359
358
  showSuggestions(show) {
360
- this.sendAIChatMethod("showSuggestions" /* SHOW_SUGGESTIONS */, show);
359
+ this.sendAIChatPubsubMethod("showSuggestions" /* SHOW_SUGGESTIONS */, show);
361
360
  }
362
361
  /**
363
362
  * Show a chat message in the AI Chat component.
@@ -365,7 +364,27 @@ var AIChatClient = class extends Client {
365
364
  * @param message The message to show.
366
365
  */
367
366
  showChatMessage(message) {
368
- this.sendAIChatMethod("showChatMessage" /* SHOW_CHAT_MESSAGE */, message);
367
+ this.sendMessage("aichat" /* AI_CHAT_CLIENT_ID */, {
368
+ type: "aichat" /* AI_CHAT_CLIENT_ID */,
369
+ name: "showChatMessage" /* SHOW_CHAT_MESSAGE */,
370
+ parameters: {
371
+ message
372
+ }
373
+ });
374
+ }
375
+ /**
376
+ * Show an error message in the AI Chat component.
377
+ *
378
+ * @param message The error message to show.
379
+ */
380
+ showErrorMessage(message) {
381
+ this.sendMessage("aichat" /* AI_CHAT_CLIENT_ID */, {
382
+ type: "aichat" /* AI_CHAT_CLIENT_ID */,
383
+ name: "showErrorMessage" /* SHOW_ERROR_MESSAGE */,
384
+ parameters: {
385
+ message
386
+ }
387
+ });
369
388
  }
370
389
  /**
371
390
  * Confirm an action in the AI Chat component.
@@ -373,7 +392,13 @@ var AIChatClient = class extends Client {
373
392
  * @param action The action to confirm.
374
393
  */
375
394
  confirmAction(action) {
376
- this.sendAIChatMethod("confirmAction" /* CONFIRM_ACTION */, action);
395
+ this.sendMessage("aichat" /* AI_CHAT_CLIENT_ID */, {
396
+ type: "aichat" /* AI_CHAT_CLIENT_ID */,
397
+ name: "confirmAction" /* CONFIRM_ACTION */,
398
+ parameters: {
399
+ action
400
+ }
401
+ });
377
402
  }
378
403
  /**
379
404
  * Show options in the AI Chat component.
@@ -381,7 +406,13 @@ var AIChatClient = class extends Client {
381
406
  * @param options The options to show.
382
407
  */
383
408
  showOptions(options) {
384
- this.sendAIChatMethod("showOptions" /* SHOW_OPTIONS */, options);
409
+ this.sendMessage("aichat" /* AI_CHAT_CLIENT_ID */, {
410
+ type: "aichat" /* AI_CHAT_CLIENT_ID */,
411
+ name: "showOptions" /* SHOW_OPTIONS */,
412
+ parameters: {
413
+ options
414
+ }
415
+ });
385
416
  }
386
417
  /**
387
418
  * Send a chat prompt to the AI Chat component.
@@ -389,21 +420,26 @@ var AIChatClient = class extends Client {
389
420
  * @param prompt The prompt to send.
390
421
  */
391
422
  sendChatPrompt(prompt) {
392
- this.sendAIChatMethod("sendChatPrompt" /* SEND_CHAT_PROMPT */, prompt);
393
- }
394
- /**
395
- * Show an error message in the AI Chat component.
396
- *
397
- * @param message The error message to show.
398
- */
399
- showErrorMessage(message) {
400
- this.sendAIChatMethod("showErrorMessage" /* SHOW_ERROR_MESSAGE */, message);
423
+ this.sendMessage("aichat" /* AI_CHAT_CLIENT_ID */, {
424
+ type: "aichat" /* AI_CHAT_CLIENT_ID */,
425
+ name: "sendChatPrompt" /* SEND_CHAT_PROMPT */,
426
+ parameters: {
427
+ message: prompt
428
+ }
429
+ });
401
430
  }
402
431
  /**
403
432
  * Show an unknown error message in the AI Chat component.
404
433
  */
405
- showUnknownMessage() {
406
- this.sendAIChatMethod("showUnknownMessage" /* SHOW_UNKNOWN_MESSAGE */, "unknown_error");
434
+ showComingSoon() {
435
+ this.sendMessage("aichat" /* AI_CHAT_CLIENT_ID */, {
436
+ type: "aichat" /* AI_CHAT_CLIENT_ID */,
437
+ name: "showComingSoon" /* SHOW_COMING_SOON */,
438
+ parameters: {
439
+ message: "coming_soon"
440
+ // Not used
441
+ }
442
+ });
407
443
  }
408
444
  };
409
445
  export {
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "iframe-pubsub",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
+ "description": "A PubSub library for iframe communication.",
5
+ "author": "lapth",
6
+ "license": "ISC",
4
7
  "main": "./dist/index.js",
5
8
  "module": "./dist/index.mjs",
6
9
  "types": "./dist/index.d.ts",
@@ -8,6 +11,10 @@
8
11
  "files": [
9
12
  "dist"
10
13
  ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/lapth/iframe-pubsub/tree/main/packages/iframe-pubsub"
17
+ },
11
18
  "scripts": {
12
19
  "build": "tsup src/index.ts --format cjs,esm --dts",
13
20
  "dev": "tsup src/index.ts --format cjs,esm --dts --watch",