@blotoutio/providers-shop-gpt-sdk 1.4.0 → 1.5.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/index.cjs.js CHANGED
@@ -302,6 +302,7 @@ const isoCountries = new Map([
302
302
  new Set(isoCountries.keys());
303
303
 
304
304
  const packageName = 'shopGPT';
305
+ const DEFAULT_MAX_THREAD_AGE = 14;
305
306
  const previewKeyName = 'previewShopGPT';
306
307
 
307
308
  const canLog = () => {
@@ -491,7 +492,7 @@ const init = (params) => {
491
492
  // exit if not in top window
492
493
  return;
493
494
  }
494
- const { enabled, devMode, merchantUrl, profiles, productHandles, targetPath, uiMode, brandName, quickPrompts, merchantImage, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
495
+ const { enabled, devMode, merchantUrl, profiles, productHandles, targetPath, uiMode, brandName, quickPrompts, merchantImage, latestThreadLoad, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
495
496
  let shouldShowUI = enabled;
496
497
  if (!enabled && hasPreviewKey()) {
497
498
  logger.log('Enabling UI in preview mode');
@@ -520,6 +521,7 @@ const init = (params) => {
520
521
  brandName,
521
522
  quickPrompts,
522
523
  merchantImage,
524
+ latestThreadLoad: latestThreadLoad !== null && latestThreadLoad !== void 0 ? latestThreadLoad : DEFAULT_MAX_THREAD_AGE,
523
525
  });
524
526
  }
525
527
  };
@@ -1581,14 +1583,18 @@ class ProductsList extends r$2 {
1581
1583
  super(...arguments);
1582
1584
  this.showButtons = true;
1583
1585
  this.updateButtonsState = () => {
1584
- if (!this.leftBtnEle || !this.productsEle || !this.rightBtnEle) {
1586
+ if (!this.productsEle) {
1585
1587
  return;
1586
1588
  }
1587
1589
  const { scrollWidth, clientWidth } = this.productsEle;
1588
1590
  this.showButtons = scrollWidth > clientWidth;
1589
- this.leftBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft === 0);
1591
+ if (this.leftBtnEle) {
1592
+ this.leftBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft === 0);
1593
+ }
1590
1594
  const maxScroll = this.productsEle.scrollWidth - this.productsEle.clientWidth;
1591
- this.rightBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft >= maxScroll - 1);
1595
+ if (this.rightBtnEle) {
1596
+ this.rightBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft >= maxScroll - 1);
1597
+ }
1592
1598
  };
1593
1599
  }
1594
1600
  connectedCallback() {
@@ -3299,7 +3305,7 @@ class ChatSection extends r$2 {
3299
3305
  ? this.messages[0].welcomePrompts
3300
3306
  : this.prompts
3301
3307
  ? this.prompts.split(',').map((prompt) => prompt.trim())
3302
- : ['Best Selling Items', 'Hot Sales'];
3308
+ : ['Best Sellers'];
3303
3309
  if (!prompts) {
3304
3310
  return E;
3305
3311
  }
@@ -3704,11 +3710,11 @@ if (!customElements.get('chat-section')) {
3704
3710
  }
3705
3711
 
3706
3712
  const DIALOG_DELAY = 1000;
3707
- const LATEST_THREAD_LOAD_DAYS = 14;
3708
3713
  const normalizePath = (path) => path.replace(/\/$/, '');
3709
3714
  class ShopGPT extends r$2 {
3710
3715
  constructor() {
3711
3716
  super(...arguments);
3717
+ this.latestThreadLoad = DEFAULT_MAX_THREAD_AGE;
3712
3718
  this.modalState = 'close';
3713
3719
  this.isLoadingHistory = false;
3714
3720
  this.isLoadingThreads = false;
@@ -3846,7 +3852,7 @@ class ShopGPT extends r$2 {
3846
3852
  }
3847
3853
  }
3848
3854
  selectLatestThread() {
3849
- const cutoffTime = Date.now() - LATEST_THREAD_LOAD_DAYS * 24 * 60 * 60 * 1000;
3855
+ const cutoffTime = Date.now() - this.latestThreadLoad * 24 * 60 * 60 * 1000;
3850
3856
  // If the latest thread is not older than cutoff we should load the thread
3851
3857
  let latestThread;
3852
3858
  for (const thread of this.chatThreads.values()) {
@@ -4092,6 +4098,10 @@ class ShopGPT extends r$2 {
4092
4098
  }
4093
4099
  }
4094
4100
  ShopGPT.styles = [shopGPTStyles];
4101
+ __decorate([
4102
+ n({ type: Number }),
4103
+ __metadata("design:type", Number)
4104
+ ], ShopGPT.prototype, "latestThreadLoad", void 0);
4095
4105
  __decorate([
4096
4106
  e$3('#shop-gpt-dialog-overlay'),
4097
4107
  __metadata("design:type", Object)
@@ -4158,6 +4168,7 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
4158
4168
  shopGPT.brandName = params.brandName;
4159
4169
  shopGPT.quickPrompts = params.quickPrompts;
4160
4170
  shopGPT.merchantImage = params.merchantImage;
4171
+ shopGPT.latestThreadLoad = params.latestThreadLoad;
4161
4172
  document.body.append(shopGPT);
4162
4173
  },
4163
4174
  destroy() {
package/index.js CHANGED
@@ -303,6 +303,7 @@ var ProvidersShopGptSdk = (function () {
303
303
  new Set(isoCountries.keys());
304
304
 
305
305
  const packageName = 'shopGPT';
306
+ const DEFAULT_MAX_THREAD_AGE = 14;
306
307
  const previewKeyName = 'previewShopGPT';
307
308
 
308
309
  const canLog = () => {
@@ -492,7 +493,7 @@ var ProvidersShopGptSdk = (function () {
492
493
  // exit if not in top window
493
494
  return;
494
495
  }
495
- const { enabled, devMode, merchantUrl, profiles, productHandles, targetPath, uiMode, brandName, quickPrompts, merchantImage, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
496
+ const { enabled, devMode, merchantUrl, profiles, productHandles, targetPath, uiMode, brandName, quickPrompts, merchantImage, latestThreadLoad, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
496
497
  let shouldShowUI = enabled;
497
498
  if (!enabled && hasPreviewKey()) {
498
499
  logger.log('Enabling UI in preview mode');
@@ -521,6 +522,7 @@ var ProvidersShopGptSdk = (function () {
521
522
  brandName,
522
523
  quickPrompts,
523
524
  merchantImage,
525
+ latestThreadLoad: latestThreadLoad !== null && latestThreadLoad !== void 0 ? latestThreadLoad : DEFAULT_MAX_THREAD_AGE,
524
526
  });
525
527
  }
526
528
  };
@@ -1582,14 +1584,18 @@ var ProvidersShopGptSdk = (function () {
1582
1584
  super(...arguments);
1583
1585
  this.showButtons = true;
1584
1586
  this.updateButtonsState = () => {
1585
- if (!this.leftBtnEle || !this.productsEle || !this.rightBtnEle) {
1587
+ if (!this.productsEle) {
1586
1588
  return;
1587
1589
  }
1588
1590
  const { scrollWidth, clientWidth } = this.productsEle;
1589
1591
  this.showButtons = scrollWidth > clientWidth;
1590
- this.leftBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft === 0);
1592
+ if (this.leftBtnEle) {
1593
+ this.leftBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft === 0);
1594
+ }
1591
1595
  const maxScroll = this.productsEle.scrollWidth - this.productsEle.clientWidth;
1592
- this.rightBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft >= maxScroll - 1);
1596
+ if (this.rightBtnEle) {
1597
+ this.rightBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft >= maxScroll - 1);
1598
+ }
1593
1599
  };
1594
1600
  }
1595
1601
  connectedCallback() {
@@ -3300,7 +3306,7 @@ var ProvidersShopGptSdk = (function () {
3300
3306
  ? this.messages[0].welcomePrompts
3301
3307
  : this.prompts
3302
3308
  ? this.prompts.split(',').map((prompt) => prompt.trim())
3303
- : ['Best Selling Items', 'Hot Sales'];
3309
+ : ['Best Sellers'];
3304
3310
  if (!prompts) {
3305
3311
  return E;
3306
3312
  }
@@ -3705,11 +3711,11 @@ var ProvidersShopGptSdk = (function () {
3705
3711
  }
3706
3712
 
3707
3713
  const DIALOG_DELAY = 1000;
3708
- const LATEST_THREAD_LOAD_DAYS = 14;
3709
3714
  const normalizePath = (path) => path.replace(/\/$/, '');
3710
3715
  class ShopGPT extends r$2 {
3711
3716
  constructor() {
3712
3717
  super(...arguments);
3718
+ this.latestThreadLoad = DEFAULT_MAX_THREAD_AGE;
3713
3719
  this.modalState = 'close';
3714
3720
  this.isLoadingHistory = false;
3715
3721
  this.isLoadingThreads = false;
@@ -3847,7 +3853,7 @@ var ProvidersShopGptSdk = (function () {
3847
3853
  }
3848
3854
  }
3849
3855
  selectLatestThread() {
3850
- const cutoffTime = Date.now() - LATEST_THREAD_LOAD_DAYS * 24 * 60 * 60 * 1000;
3856
+ const cutoffTime = Date.now() - this.latestThreadLoad * 24 * 60 * 60 * 1000;
3851
3857
  // If the latest thread is not older than cutoff we should load the thread
3852
3858
  let latestThread;
3853
3859
  for (const thread of this.chatThreads.values()) {
@@ -4093,6 +4099,10 @@ var ProvidersShopGptSdk = (function () {
4093
4099
  }
4094
4100
  }
4095
4101
  ShopGPT.styles = [shopGPTStyles];
4102
+ __decorate([
4103
+ n({ type: Number }),
4104
+ __metadata("design:type", Number)
4105
+ ], ShopGPT.prototype, "latestThreadLoad", void 0);
4096
4106
  __decorate([
4097
4107
  e$3('#shop-gpt-dialog-overlay'),
4098
4108
  __metadata("design:type", Object)
@@ -4159,6 +4169,7 @@ var ProvidersShopGptSdk = (function () {
4159
4169
  shopGPT.brandName = params.brandName;
4160
4170
  shopGPT.quickPrompts = params.quickPrompts;
4161
4171
  shopGPT.merchantImage = params.merchantImage;
4172
+ shopGPT.latestThreadLoad = params.latestThreadLoad;
4162
4173
  document.body.append(shopGPT);
4163
4174
  },
4164
4175
  destroy() {
package/index.mjs CHANGED
@@ -300,6 +300,7 @@ const isoCountries = new Map([
300
300
  new Set(isoCountries.keys());
301
301
 
302
302
  const packageName = 'shopGPT';
303
+ const DEFAULT_MAX_THREAD_AGE = 14;
303
304
  const previewKeyName = 'previewShopGPT';
304
305
 
305
306
  const canLog = () => {
@@ -489,7 +490,7 @@ const init = (params) => {
489
490
  // exit if not in top window
490
491
  return;
491
492
  }
492
- const { enabled, devMode, merchantUrl, profiles, productHandles, targetPath, uiMode, brandName, quickPrompts, merchantImage, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
493
+ const { enabled, devMode, merchantUrl, profiles, productHandles, targetPath, uiMode, brandName, quickPrompts, merchantImage, latestThreadLoad, } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
493
494
  let shouldShowUI = enabled;
494
495
  if (!enabled && hasPreviewKey()) {
495
496
  logger.log('Enabling UI in preview mode');
@@ -518,6 +519,7 @@ const init = (params) => {
518
519
  brandName,
519
520
  quickPrompts,
520
521
  merchantImage,
522
+ latestThreadLoad: latestThreadLoad !== null && latestThreadLoad !== void 0 ? latestThreadLoad : DEFAULT_MAX_THREAD_AGE,
521
523
  });
522
524
  }
523
525
  };
@@ -1579,14 +1581,18 @@ class ProductsList extends r$2 {
1579
1581
  super(...arguments);
1580
1582
  this.showButtons = true;
1581
1583
  this.updateButtonsState = () => {
1582
- if (!this.leftBtnEle || !this.productsEle || !this.rightBtnEle) {
1584
+ if (!this.productsEle) {
1583
1585
  return;
1584
1586
  }
1585
1587
  const { scrollWidth, clientWidth } = this.productsEle;
1586
1588
  this.showButtons = scrollWidth > clientWidth;
1587
- this.leftBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft === 0);
1589
+ if (this.leftBtnEle) {
1590
+ this.leftBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft === 0);
1591
+ }
1588
1592
  const maxScroll = this.productsEle.scrollWidth - this.productsEle.clientWidth;
1589
- this.rightBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft >= maxScroll - 1);
1593
+ if (this.rightBtnEle) {
1594
+ this.rightBtnEle.classList.toggle('disabled', this.productsEle.scrollLeft >= maxScroll - 1);
1595
+ }
1590
1596
  };
1591
1597
  }
1592
1598
  connectedCallback() {
@@ -3297,7 +3303,7 @@ class ChatSection extends r$2 {
3297
3303
  ? this.messages[0].welcomePrompts
3298
3304
  : this.prompts
3299
3305
  ? this.prompts.split(',').map((prompt) => prompt.trim())
3300
- : ['Best Selling Items', 'Hot Sales'];
3306
+ : ['Best Sellers'];
3301
3307
  if (!prompts) {
3302
3308
  return E;
3303
3309
  }
@@ -3702,11 +3708,11 @@ if (!customElements.get('chat-section')) {
3702
3708
  }
3703
3709
 
3704
3710
  const DIALOG_DELAY = 1000;
3705
- const LATEST_THREAD_LOAD_DAYS = 14;
3706
3711
  const normalizePath = (path) => path.replace(/\/$/, '');
3707
3712
  class ShopGPT extends r$2 {
3708
3713
  constructor() {
3709
3714
  super(...arguments);
3715
+ this.latestThreadLoad = DEFAULT_MAX_THREAD_AGE;
3710
3716
  this.modalState = 'close';
3711
3717
  this.isLoadingHistory = false;
3712
3718
  this.isLoadingThreads = false;
@@ -3844,7 +3850,7 @@ class ShopGPT extends r$2 {
3844
3850
  }
3845
3851
  }
3846
3852
  selectLatestThread() {
3847
- const cutoffTime = Date.now() - LATEST_THREAD_LOAD_DAYS * 24 * 60 * 60 * 1000;
3853
+ const cutoffTime = Date.now() - this.latestThreadLoad * 24 * 60 * 60 * 1000;
3848
3854
  // If the latest thread is not older than cutoff we should load the thread
3849
3855
  let latestThread;
3850
3856
  for (const thread of this.chatThreads.values()) {
@@ -4090,6 +4096,10 @@ class ShopGPT extends r$2 {
4090
4096
  }
4091
4097
  }
4092
4098
  ShopGPT.styles = [shopGPTStyles];
4099
+ __decorate([
4100
+ n({ type: Number }),
4101
+ __metadata("design:type", Number)
4102
+ ], ShopGPT.prototype, "latestThreadLoad", void 0);
4093
4103
  __decorate([
4094
4104
  e$3('#shop-gpt-dialog-overlay'),
4095
4105
  __metadata("design:type", Object)
@@ -4156,6 +4166,7 @@ if (typeof window != 'undefined' && typeof document != 'undefined') {
4156
4166
  shopGPT.brandName = params.brandName;
4157
4167
  shopGPT.quickPrompts = params.quickPrompts;
4158
4168
  shopGPT.merchantImage = params.merchantImage;
4169
+ shopGPT.latestThreadLoad = params.latestThreadLoad;
4159
4170
  document.body.append(shopGPT);
4160
4171
  },
4161
4172
  destroy() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-shop-gpt-sdk",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Shop GPT SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",