iframe-pubsub 1.0.5 → 1.0.7

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