@depict-ai/utilishared 0.0.2 → 0.0.3

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.ts CHANGED
@@ -680,58 +680,6 @@ export const send_ga: (action: string) => any;
680
680
  export const setup_ga: (GAID: string) => void;
681
681
  export const ga_rec_click: () => any;
682
682
  export const ga_purchase_click: () => any;
683
- type ImpressionTrackOptions = {
684
- t?: Tenant;
685
- impression_tracking?: false;
686
- } | {
687
- impression_tracking: true;
688
- t: Tenant;
689
- };
690
- type TenantSpecificationOptions = {
691
- t?: Tenant;
692
- tenant: string;
693
- market: string;
694
- get_product_id: (url?: string) => string | Promise<string>;
695
- } | {
696
- t: Tenant;
697
- tenant?: string;
698
- market?: string;
699
- get_product_id?: (url?: string) => string | Promise<string>;
700
- };
701
- type ElementDiscoveryOptions = {
702
- product_selector: string;
703
- product_elements?: null | void | undefined;
704
- } | {
705
- product_selector?: null | void | undefined;
706
- product_elements: HTMLElement[];
707
- };
708
- type A2CButtonDiscoveryOptions = {
709
- a2c_selector: string;
710
- a2c_elements?: null | void | undefined;
711
- } | {
712
- a2c_selector?: null | void | undefined;
713
- a2c_elements: HTMLElement[];
714
- };
715
- export const AIO: (options: {
716
- attempt_gtag_view_tracking?: boolean | undefined;
717
- no_gtag?: boolean | undefined;
718
- shade?: boolean | undefined;
719
- always_track_a2c?: boolean | undefined;
720
- get_rec_id?: ((elem: HTMLElement) => string | undefined) | undefined;
721
- get_prod_id?: ((elem: HTMLElement) => (string | undefined) | Promise<string | undefined>) | undefined;
722
- get_ga_prod_id?: ((elem: HTMLElement) => string | undefined | Promise<string | undefined>) | undefined;
723
- click_location_prefix?: ((elem: HTMLElement) => string | undefined) | undefined;
724
- rec_a2c_selector?: string | undefined;
725
- rec_a2c_unbubbled?: boolean | undefined;
726
- get_display?: ((elem: HTMLElement) => Partial<Display> | undefined) | undefined;
727
- } & ImpressionTrackOptions & TenantSpecificationOptions & ElementDiscoveryOptions & A2CButtonDiscoveryOptions, gtag_options?: {
728
- [key: string]: any;
729
- list_name?: string | undefined;
730
- } | undefined) => Promise<{
731
- add_a2c_element: (element: HTMLElement) => void;
732
- add_product_element: (element: HTMLElement) => Promise<void>;
733
- }>;
734
- export const paint_red: (element: HTMLElement) => void;
735
683
  export const insert_styling: (css: string) => Promise<void>;
736
684
  /**
737
685
  * A function meant to use to track the main add to cart button on the product page of an integration.
@@ -838,6 +786,58 @@ export class Tenant<ProductId extends IdType = IdType> {
838
786
  * This is a list of alpha-2 country codes plus some two letter combinations commonly used to describe markets
839
787
  */
840
788
  export type TwoLetterMarket = "af" | "al" | "dz" | "as" | "ad" | "ao" | "ai" | "aq" | "ag" | "ar" | "am" | "aw" | "au" | "at" | "az" | "bs" | "bh" | "bd" | "bb" | "by" | "be" | "bz" | "bj" | "bm" | "bt" | "bo" | "bq" | "ba" | "bw" | "bv" | "br" | "io" | "bn" | "bg" | "bf" | "bi" | "cv" | "kh" | "cm" | "ca" | "ky" | "cf" | "td" | "cl" | "cn" | "cx" | "cc" | "co" | "km" | "cd" | "cg" | "ck" | "cr" | "hr" | "cu" | "cw" | "cy" | "cz" | "ci" | "dk" | "dj" | "dm" | "do" | "ec" | "eg" | "sv" | "gq" | "er" | "ee" | "sz" | "et" | "fk" | "fo" | "fj" | "fi" | "fr" | "gf" | "pf" | "tf" | "ga" | "gm" | "ge" | "de" | "gh" | "gi" | "gr" | "gl" | "gd" | "gp" | "gu" | "gt" | "gg" | "gn" | "gw" | "gy" | "ht" | "hm" | "va" | "hn" | "hk" | "hu" | "is" | "in" | "id" | "ir" | "iq" | "ie" | "im" | "il" | "it" | "jm" | "jp" | "je" | "jo" | "kz" | "ke" | "ki" | "kp" | "kr" | "kw" | "kg" | "la" | "lv" | "lb" | "ls" | "lr" | "ly" | "li" | "lt" | "lu" | "mo" | "mg" | "mw" | "my" | "mv" | "ml" | "mt" | "mh" | "mq" | "mr" | "mu" | "yt" | "mx" | "fm" | "md" | "mc" | "mn" | "me" | "ms" | "ma" | "mz" | "mm" | "na" | "nr" | "np" | "nl" | "nc" | "nz" | "ni" | "ne" | "ng" | "nu" | "nf" | "mp" | "no" | "om" | "pk" | "pw" | "ps" | "pa" | "pg" | "py" | "pe" | "ph" | "pn" | "pl" | "pt" | "pr" | "qa" | "mk" | "ro" | "ru" | "rw" | "re" | "bl" | "sh" | "kn" | "lc" | "mf" | "pm" | "vc" | "ws" | "sm" | "st" | "sa" | "sn" | "rs" | "sc" | "sl" | "sg" | "sx" | "sk" | "si" | "sb" | "so" | "za" | "gs" | "ss" | "es" | "lk" | "sd" | "sr" | "sj" | "se" | "ch" | "sy" | "tw" | "tj" | "tz" | "th" | "tl" | "tg" | "tk" | "to" | "tt" | "tn" | "tr" | "tm" | "tc" | "tv" | "ug" | "ua" | "ae" | "gb" | "um" | "us" | "uy" | "uz" | "vu" | "ve" | "vn" | "vg" | "vi" | "wf" | "eh" | "ye" | "zm" | "zw" | "ax" | "uk" | "en" | "da" | "eu" | "sv" | "oc" | "nb" | "sq";
789
+ type ImpressionTrackOptions = {
790
+ t?: Tenant;
791
+ impression_tracking?: false;
792
+ } | {
793
+ impression_tracking: true;
794
+ t: Tenant;
795
+ };
796
+ type TenantSpecificationOptions = {
797
+ t?: Tenant;
798
+ tenant: string;
799
+ market: string;
800
+ get_product_id: (url?: string) => string | Promise<string>;
801
+ } | {
802
+ t: Tenant;
803
+ tenant?: string;
804
+ market?: string;
805
+ get_product_id?: (url?: string) => string | Promise<string>;
806
+ };
807
+ type ElementDiscoveryOptions = {
808
+ product_selector: string;
809
+ product_elements?: null | void | undefined;
810
+ } | {
811
+ product_selector?: null | void | undefined;
812
+ product_elements: HTMLElement[];
813
+ };
814
+ type A2CButtonDiscoveryOptions = {
815
+ a2c_selector: string;
816
+ a2c_elements?: null | void | undefined;
817
+ } | {
818
+ a2c_selector?: null | void | undefined;
819
+ a2c_elements: HTMLElement[];
820
+ };
821
+ export const AIO: (options: {
822
+ attempt_gtag_view_tracking?: boolean | undefined;
823
+ no_gtag?: boolean | undefined;
824
+ shade?: boolean | undefined;
825
+ always_track_a2c?: boolean | undefined;
826
+ get_rec_id?: ((elem: HTMLElement) => string | undefined) | undefined;
827
+ get_prod_id?: ((elem: HTMLElement) => (string | undefined) | Promise<string | undefined>) | undefined;
828
+ get_ga_prod_id?: ((elem: HTMLElement) => string | undefined | Promise<string | undefined>) | undefined;
829
+ click_location_prefix?: ((elem: HTMLElement) => string | undefined) | undefined;
830
+ rec_a2c_selector?: string | undefined;
831
+ rec_a2c_unbubbled?: boolean | undefined;
832
+ get_display?: ((elem: HTMLElement) => Partial<Display> | undefined) | undefined;
833
+ } & ImpressionTrackOptions & TenantSpecificationOptions & ElementDiscoveryOptions & A2CButtonDiscoveryOptions, gtag_options?: {
834
+ [key: string]: any;
835
+ list_name?: string | undefined;
836
+ } | undefined) => Promise<{
837
+ add_a2c_element: (element: HTMLElement) => void;
838
+ add_product_element: (element: HTMLElement) => Promise<void>;
839
+ }>;
840
+ export const paint_red: (element: HTMLElement) => void;
841
841
  /**
842
842
  * A function that attempts to "serialize" an object to a text representation that helps with debugging when using sentry
843
843
  * @param anything Something to try to serialize - this function is crappy and your mileage may vary
package/dist/main.js CHANGED
@@ -1495,6 +1495,10 @@ var $94edfb6d9c42a288$exports = {};
1495
1495
 
1496
1496
  $parcel$export($94edfb6d9c42a288$exports, "fetch_recs", () => $94edfb6d9c42a288$export$1bc0df10745d5412);
1497
1497
  $parcel$export($94edfb6d9c42a288$exports, "fetch_recs_whole_response", () => $94edfb6d9c42a288$export$d40679eb4cf32f09);
1498
+ const $4c6861fbcd3a0611$export$362abebb4b313340 = "https://api.depict.ai";
1499
+
1500
+
1501
+
1498
1502
  var $e0a87646d12cb987$exports = {};
1499
1503
 
1500
1504
  $parcel$export($e0a87646d12cb987$exports, "get_depict_id", () => $e0a87646d12cb987$export$6399bdb2291895e0);
@@ -1798,6 +1802,7 @@ function $650b64c1b384c895$export$a6db784f019668ba() {
1798
1802
 
1799
1803
 
1800
1804
 
1805
+
1801
1806
  const $0c84f8e99aac5765$var$c = (0, $268cbd9e4ade92db$export$b3bbfd758f11cfa9);
1802
1807
  const $0c84f8e99aac5765$var$ws_instance = /*@__PURE__*/ $0c84f8e99aac5765$var$c(()=>new (0, $d10801050840d92b$export$1d9c6fddbff3441f)("wss://ws.depict.ai/ws/create-events"))();
1803
1808
  const $0c84f8e99aac5765$var$allowed_keys = [
@@ -1846,7 +1851,7 @@ const $0c84f8e99aac5765$export$608478473a3304a0 = /*@__PURE__*/ $0c84f8e99aac576
1846
1851
  (0, $e6c6e7929ea385ae$export$de56f1198d121036)("Sending to depict (ws)", payload);
1847
1852
  return $0c84f8e99aac5765$export$aa26019042811d4f(payload);
1848
1853
  }
1849
- const url = process.env.BASE_URL + "/create-events";
1854
+ const url = (0, $4c6861fbcd3a0611$export$362abebb4b313340) + "/create-events";
1850
1855
  return $0c84f8e99aac5765$export$cc3b6ddf805f6156(url, payload);
1851
1856
  });
1852
1857
  const $0c84f8e99aac5765$export$cc3b6ddf805f6156 = /*@__PURE__*/ $0c84f8e99aac5765$var$c((url, payload)=>{
@@ -2429,6 +2434,7 @@ var $c18ce8dadd041cdd$exports = {};
2429
2434
 
2430
2435
  $parcel$export($c18ce8dadd041cdd$exports, "make_tracker_send_to_depict", () => $c18ce8dadd041cdd$export$edfedd0557ca5a2d);
2431
2436
  $parcel$export($c18ce8dadd041cdd$exports, "create_ga_queue", () => $c18ce8dadd041cdd$export$674d8cd8b6868154);
2437
+
2432
2438
  function $c18ce8dadd041cdd$export$edfedd0557ca5a2d(ga_tracker, append_to_url) {
2433
2439
  if (!ga_tracker) return;
2434
2440
  // Docs for analytics.js Tasks:
@@ -2440,7 +2446,7 @@ function $c18ce8dadd041cdd$export$edfedd0557ca5a2d(ga_tracker, append_to_url) {
2440
2446
  // console.log('Sent original hit, now sending to depict');
2441
2447
  try {
2442
2448
  const payLoad = model.get("hitPayload");
2443
- const path = process.env.BASE_URL + "/collect-ga";
2449
+ const path = (0, $4c6861fbcd3a0611$export$362abebb4b313340) + "/collect-ga";
2444
2450
  let url = path + "?" + payLoad;
2445
2451
  if (append_to_url) url += append_to_url;
2446
2452
  const n = navigator;
@@ -3241,7 +3247,6 @@ async function $d2fc3fb450961938$var$send_sentry_422(response, body, stack) {
3241
3247
  }
3242
3248
 
3243
3249
 
3244
-
3245
3250
  async function $94edfb6d9c42a288$export$1bc0df10745d5412(t, options, headers, get_url = $94edfb6d9c42a288$var$default_get_fetch_url) {
3246
3251
  const res = await $94edfb6d9c42a288$export$d40679eb4cf32f09(t, options, headers, get_url);
3247
3252
  return res?.displays || [];
@@ -3269,7 +3274,7 @@ async function $94edfb6d9c42a288$export$d40679eb4cf32f09(t, options, headers, ge
3269
3274
  .then((r)=>r.json()).catch((e)=>(0, $e6c6e7929ea385ae$export$de56f1198d121036)("fetch_retry threw", e));
3270
3275
  }
3271
3276
  function $94edfb6d9c42a288$var$default_get_fetch_url(type) {
3272
- return `${process.env.BASE_URL}/v2/recommend/products/${type}`;
3277
+ return `${0, $4c6861fbcd3a0611$export$362abebb4b313340}/v2/recommend/products/${type}`;
3273
3278
  }
3274
3279
  function $94edfb6d9c42a288$var$get_fetch_endpoint_from_options(options) {
3275
3280
  if (options["category_id"] !== undefined) return "category";
@@ -4968,6 +4973,10 @@ $parcel$export($0b6a8303b64cced1$exports, "Depict", () => $0b6a8303b64cced1$expo
4968
4973
 
4969
4974
 
4970
4975
 
4976
+
4977
+
4978
+
4979
+
4971
4980
  var /**
4972
4981
  * @deprecated please use `fetch_retry()` instead
4973
4982
  *
@@ -5026,13 +5035,10 @@ async function $c413c7798924612a$var$send_sentry_422(response, body, stack) {
5026
5035
  }
5027
5036
 
5028
5037
 
5029
-
5030
-
5031
-
5032
5038
  const $0b6a8303b64cced1$var$discountMatcher = /{DISCOUNT{([\s\S]+?)}}/g;
5033
5039
  const $0b6a8303b64cced1$var$noDiscountMatcher = /{NODISCOUNT{([\s\S]+?)}}/g;
5034
- const $0b6a8303b64cced1$var$APICreateEvent = process.env.BASE_URL + "/create-events";
5035
- const $0b6a8303b64cced1$var$APIRecommend = process.env.BASE_URL + "/recommend";
5040
+ const $0b6a8303b64cced1$var$APICreateEvent = (0, $4c6861fbcd3a0611$export$362abebb4b313340) + "/create-events";
5041
+ const $0b6a8303b64cced1$var$APIRecommend = (0, $4c6861fbcd3a0611$export$362abebb4b313340) + "/recommend";
5036
5042
  let $0b6a8303b64cced1$var$pageview_sent = false, $0b6a8303b64cced1$var$windows_proof_fetch;
5037
5043
  class $0b6a8303b64cced1$export$1a8782481a9af507 {
5038
5044
  constructor(settings){
@@ -5072,7 +5078,7 @@ class $0b6a8303b64cced1$export$1a8782481a9af507 {
5072
5078
  if (this.settings.waitForSelectors !== undefined) {
5073
5079
  const SLEEP_TIME_MS = 50;
5074
5080
  let MAX_RETRY = Math.round(10000 / SLEEP_TIME_MS);
5075
- let tick = setInterval(()=>{
5081
+ const tick = setInterval(()=>{
5076
5082
  let allLoaded = true;
5077
5083
  for (const selector of this.settings.waitForSelectors)if (document.querySelector(selector) == null) {
5078
5084
  allLoaded = false;
@@ -5131,7 +5137,7 @@ class $0b6a8303b64cced1$export$1a8782481a9af507 {
5131
5137
  }
5132
5138
  createContainer(root, container, prepend = false) {
5133
5139
  function htmlToElements(html) {
5134
- var template = document.createElement("template");
5140
+ const template = document.createElement("template");
5135
5141
  template.innerHTML = html;
5136
5142
  return template.content.childNodes;
5137
5143
  }
@@ -5170,8 +5176,8 @@ class $0b6a8303b64cced1$export$1a8782481a9af507 {
5170
5176
  };
5171
5177
  const elementsFromHTML = (html)=>new DOMParser().parseFromString(html, "text/html").body.children;
5172
5178
  const getContent = ()=>{
5173
- let recsArray = [];
5174
- let resultingElements = [];
5179
+ const recsArray = [];
5180
+ const resultingElements = [];
5175
5181
  this.data.forEach((item, rec_index)=>{
5176
5182
  if (typeof itemPreprocessor === "function") {
5177
5183
  item = itemPreprocessor(item, rec_index);
@@ -5232,8 +5238,8 @@ class $0b6a8303b64cced1$export$1a8782481a9af507 {
5232
5238
  if (this.settings.loadHack === true) {
5233
5239
  const SLEEP_TIME_MS = 50;
5234
5240
  let MAX_RETRY = Math.round(10000 / SLEEP_TIME_MS);
5235
- let tick = setInterval(()=>{
5236
- let r = root();
5241
+ const tick = setInterval(()=>{
5242
+ const r = root();
5237
5243
  if (MAX_RETRY === 0) clearInterval(tick);
5238
5244
  MAX_RETRY--;
5239
5245
  if (r !== null) {
@@ -5242,13 +5248,13 @@ class $0b6a8303b64cced1$export$1a8782481a9af507 {
5242
5248
  }
5243
5249
  }, SLEEP_TIME_MS);
5244
5250
  } else if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", ()=>{
5245
- let r = root();
5251
+ const r = root();
5246
5252
  r.append(...renderedContent);
5247
5253
  }, {
5248
5254
  once: true
5249
5255
  });
5250
5256
  else {
5251
- let r = root();
5257
+ const r = root();
5252
5258
  r.append(...renderedContent);
5253
5259
  }
5254
5260
  return;
@@ -6931,6 +6937,7 @@ $parcel$export($0c9d834f187cc4ff$exports, "url_transaction_id_extractor", () =>
6931
6937
 
6932
6938
 
6933
6939
 
6940
+
6934
6941
  function $0c9d834f187cc4ff$export$3ebd86018b39d9d2(t, selector, filter) {
6935
6942
  (0, $2a1cbc63a04d4a2d$export$b6ae1bc530f4c149).onexists(selector, (0, $268cbd9e4ade92db$export$b3bbfd758f11cfa9)((eoe)=>{
6936
6943
  (0, $e6c6e7929ea385ae$export$de56f1198d121036)("Order confirmation element showed up!", eoe);
@@ -6992,7 +6999,7 @@ function $0c9d834f187cc4ff$export$1ac466d53a6636ac(t, input_id, dsid = (0, $e0a8
6992
6999
  }
6993
7000
  ]
6994
7001
  };
6995
- (0, $0c84f8e99aac5765$export$cc3b6ddf805f6156)(process.env.BASE_URL + "/v2/track", payload);
7002
+ (0, $0c84f8e99aac5765$export$cc3b6ddf805f6156)((0, $4c6861fbcd3a0611$export$362abebb4b313340) + "/v2/track", payload);
6996
7003
  }
6997
7004
 
6998
7005
 
@@ -7061,6 +7068,7 @@ $parcel$export($8594d423459ba80c$exports, "send_product_unavailable_to_depict",
7061
7068
 
7062
7069
 
7063
7070
 
7071
+
7064
7072
  async function $8594d423459ba80c$export$d63b08f4f29ddba5(t, unavailability_type) {
7065
7073
  const product_id = await t.get_product_id();
7066
7074
  (0, $e6c6e7929ea385ae$export$de56f1198d121036)(`Notifying Depict that product id: ${product_id} is ${unavailability_type}`);
@@ -7077,7 +7085,7 @@ async function $8594d423459ba80c$export$d63b08f4f29ddba5(t, unavailability_type)
7077
7085
  }
7078
7086
  ]
7079
7087
  };
7080
- (0, $0c84f8e99aac5765$export$cc3b6ddf805f6156)(process.env.BASE_URL + "/v2/track", payload);
7088
+ (0, $0c84f8e99aac5765$export$cc3b6ddf805f6156)((0, $4c6861fbcd3a0611$export$362abebb4b313340) + "/v2/track", payload);
7081
7089
  }
7082
7090
 
7083
7091
 
package/dist/module.js CHANGED
@@ -1476,6 +1476,10 @@ var $2d47b009af5bc0a4$exports = {};
1476
1476
 
1477
1477
  $parcel$export($2d47b009af5bc0a4$exports, "fetch_recs", () => $2d47b009af5bc0a4$export$1bc0df10745d5412);
1478
1478
  $parcel$export($2d47b009af5bc0a4$exports, "fetch_recs_whole_response", () => $2d47b009af5bc0a4$export$d40679eb4cf32f09);
1479
+ const $6c2b49f3f564b0d1$export$362abebb4b313340 = "https://api.depict.ai";
1480
+
1481
+
1482
+
1479
1483
  var $43683b1103edab15$exports = {};
1480
1484
 
1481
1485
  $parcel$export($43683b1103edab15$exports, "get_depict_id", () => $43683b1103edab15$export$6399bdb2291895e0);
@@ -1779,6 +1783,7 @@ function $460df8550f9d084d$export$a6db784f019668ba() {
1779
1783
 
1780
1784
 
1781
1785
 
1786
+
1782
1787
  const $cafa1ff1049985c2$var$c = (0, $b04e44fad5ea42c7$export$b3bbfd758f11cfa9);
1783
1788
  const $cafa1ff1049985c2$var$ws_instance = /*@__PURE__*/ $cafa1ff1049985c2$var$c(()=>new (0, $4ce764ddfee055ef$export$1d9c6fddbff3441f)("wss://ws.depict.ai/ws/create-events"))();
1784
1789
  const $cafa1ff1049985c2$var$allowed_keys = [
@@ -1827,7 +1832,7 @@ const $cafa1ff1049985c2$export$608478473a3304a0 = /*@__PURE__*/ $cafa1ff1049985c
1827
1832
  (0, $649f456f663da9fc$export$de56f1198d121036)("Sending to depict (ws)", payload);
1828
1833
  return $cafa1ff1049985c2$export$aa26019042811d4f(payload);
1829
1834
  }
1830
- const url = process.env.BASE_URL + "/create-events";
1835
+ const url = (0, $6c2b49f3f564b0d1$export$362abebb4b313340) + "/create-events";
1831
1836
  return $cafa1ff1049985c2$export$cc3b6ddf805f6156(url, payload);
1832
1837
  });
1833
1838
  const $cafa1ff1049985c2$export$cc3b6ddf805f6156 = /*@__PURE__*/ $cafa1ff1049985c2$var$c((url, payload)=>{
@@ -2410,6 +2415,7 @@ var $42bbbba8196bd057$exports = {};
2410
2415
 
2411
2416
  $parcel$export($42bbbba8196bd057$exports, "make_tracker_send_to_depict", () => $42bbbba8196bd057$export$edfedd0557ca5a2d);
2412
2417
  $parcel$export($42bbbba8196bd057$exports, "create_ga_queue", () => $42bbbba8196bd057$export$674d8cd8b6868154);
2418
+
2413
2419
  function $42bbbba8196bd057$export$edfedd0557ca5a2d(ga_tracker, append_to_url) {
2414
2420
  if (!ga_tracker) return;
2415
2421
  // Docs for analytics.js Tasks:
@@ -2421,7 +2427,7 @@ function $42bbbba8196bd057$export$edfedd0557ca5a2d(ga_tracker, append_to_url) {
2421
2427
  // console.log('Sent original hit, now sending to depict');
2422
2428
  try {
2423
2429
  const payLoad = model.get("hitPayload");
2424
- const path = process.env.BASE_URL + "/collect-ga";
2430
+ const path = (0, $6c2b49f3f564b0d1$export$362abebb4b313340) + "/collect-ga";
2425
2431
  let url = path + "?" + payLoad;
2426
2432
  if (append_to_url) url += append_to_url;
2427
2433
  const n = navigator;
@@ -3222,7 +3228,6 @@ async function $2d1ffbfaa1c2d9e3$var$send_sentry_422(response, body, stack) {
3222
3228
  }
3223
3229
 
3224
3230
 
3225
-
3226
3231
  async function $2d47b009af5bc0a4$export$1bc0df10745d5412(t, options, headers, get_url = $2d47b009af5bc0a4$var$default_get_fetch_url) {
3227
3232
  const res = await $2d47b009af5bc0a4$export$d40679eb4cf32f09(t, options, headers, get_url);
3228
3233
  return res?.displays || [];
@@ -3250,7 +3255,7 @@ async function $2d47b009af5bc0a4$export$d40679eb4cf32f09(t, options, headers, ge
3250
3255
  .then((r)=>r.json()).catch((e)=>(0, $649f456f663da9fc$export$de56f1198d121036)("fetch_retry threw", e));
3251
3256
  }
3252
3257
  function $2d47b009af5bc0a4$var$default_get_fetch_url(type) {
3253
- return `${process.env.BASE_URL}/v2/recommend/products/${type}`;
3258
+ return `${0, $6c2b49f3f564b0d1$export$362abebb4b313340}/v2/recommend/products/${type}`;
3254
3259
  }
3255
3260
  function $2d47b009af5bc0a4$var$get_fetch_endpoint_from_options(options) {
3256
3261
  if (options["category_id"] !== undefined) return "category";
@@ -4949,6 +4954,10 @@ $parcel$export($366fff12da348e66$exports, "Depict", () => $366fff12da348e66$expo
4949
4954
 
4950
4955
 
4951
4956
 
4957
+
4958
+
4959
+
4960
+
4952
4961
  var /**
4953
4962
  * @deprecated please use `fetch_retry()` instead
4954
4963
  *
@@ -5007,13 +5016,10 @@ async function $acf11540344875ed$var$send_sentry_422(response, body, stack) {
5007
5016
  }
5008
5017
 
5009
5018
 
5010
-
5011
-
5012
-
5013
5019
  const $366fff12da348e66$var$discountMatcher = /{DISCOUNT{([\s\S]+?)}}/g;
5014
5020
  const $366fff12da348e66$var$noDiscountMatcher = /{NODISCOUNT{([\s\S]+?)}}/g;
5015
- const $366fff12da348e66$var$APICreateEvent = process.env.BASE_URL + "/create-events";
5016
- const $366fff12da348e66$var$APIRecommend = process.env.BASE_URL + "/recommend";
5021
+ const $366fff12da348e66$var$APICreateEvent = (0, $6c2b49f3f564b0d1$export$362abebb4b313340) + "/create-events";
5022
+ const $366fff12da348e66$var$APIRecommend = (0, $6c2b49f3f564b0d1$export$362abebb4b313340) + "/recommend";
5017
5023
  let $366fff12da348e66$var$pageview_sent = false, $366fff12da348e66$var$windows_proof_fetch;
5018
5024
  class $366fff12da348e66$export$1a8782481a9af507 {
5019
5025
  constructor(settings){
@@ -5053,7 +5059,7 @@ class $366fff12da348e66$export$1a8782481a9af507 {
5053
5059
  if (this.settings.waitForSelectors !== undefined) {
5054
5060
  const SLEEP_TIME_MS = 50;
5055
5061
  let MAX_RETRY = Math.round(10000 / SLEEP_TIME_MS);
5056
- let tick = setInterval(()=>{
5062
+ const tick = setInterval(()=>{
5057
5063
  let allLoaded = true;
5058
5064
  for (const selector of this.settings.waitForSelectors)if (document.querySelector(selector) == null) {
5059
5065
  allLoaded = false;
@@ -5112,7 +5118,7 @@ class $366fff12da348e66$export$1a8782481a9af507 {
5112
5118
  }
5113
5119
  createContainer(root, container, prepend = false) {
5114
5120
  function htmlToElements(html) {
5115
- var template = document.createElement("template");
5121
+ const template = document.createElement("template");
5116
5122
  template.innerHTML = html;
5117
5123
  return template.content.childNodes;
5118
5124
  }
@@ -5151,8 +5157,8 @@ class $366fff12da348e66$export$1a8782481a9af507 {
5151
5157
  };
5152
5158
  const elementsFromHTML = (html)=>new DOMParser().parseFromString(html, "text/html").body.children;
5153
5159
  const getContent = ()=>{
5154
- let recsArray = [];
5155
- let resultingElements = [];
5160
+ const recsArray = [];
5161
+ const resultingElements = [];
5156
5162
  this.data.forEach((item, rec_index)=>{
5157
5163
  if (typeof itemPreprocessor === "function") {
5158
5164
  item = itemPreprocessor(item, rec_index);
@@ -5213,8 +5219,8 @@ class $366fff12da348e66$export$1a8782481a9af507 {
5213
5219
  if (this.settings.loadHack === true) {
5214
5220
  const SLEEP_TIME_MS = 50;
5215
5221
  let MAX_RETRY = Math.round(10000 / SLEEP_TIME_MS);
5216
- let tick = setInterval(()=>{
5217
- let r = root();
5222
+ const tick = setInterval(()=>{
5223
+ const r = root();
5218
5224
  if (MAX_RETRY === 0) clearInterval(tick);
5219
5225
  MAX_RETRY--;
5220
5226
  if (r !== null) {
@@ -5223,13 +5229,13 @@ class $366fff12da348e66$export$1a8782481a9af507 {
5223
5229
  }
5224
5230
  }, SLEEP_TIME_MS);
5225
5231
  } else if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", ()=>{
5226
- let r = root();
5232
+ const r = root();
5227
5233
  r.append(...renderedContent);
5228
5234
  }, {
5229
5235
  once: true
5230
5236
  });
5231
5237
  else {
5232
- let r = root();
5238
+ const r = root();
5233
5239
  r.append(...renderedContent);
5234
5240
  }
5235
5241
  return;
@@ -6912,6 +6918,7 @@ $parcel$export($847e4a06ea6767c0$exports, "url_transaction_id_extractor", () =>
6912
6918
 
6913
6919
 
6914
6920
 
6921
+
6915
6922
  function $847e4a06ea6767c0$export$3ebd86018b39d9d2(t, selector, filter) {
6916
6923
  (0, $0b48ba2f40ce6067$export$b6ae1bc530f4c149).onexists(selector, (0, $b04e44fad5ea42c7$export$b3bbfd758f11cfa9)((eoe)=>{
6917
6924
  (0, $649f456f663da9fc$export$de56f1198d121036)("Order confirmation element showed up!", eoe);
@@ -6973,7 +6980,7 @@ function $847e4a06ea6767c0$export$1ac466d53a6636ac(t, input_id, dsid = (0, $4368
6973
6980
  }
6974
6981
  ]
6975
6982
  };
6976
- (0, $cafa1ff1049985c2$export$cc3b6ddf805f6156)(process.env.BASE_URL + "/v2/track", payload);
6983
+ (0, $cafa1ff1049985c2$export$cc3b6ddf805f6156)((0, $6c2b49f3f564b0d1$export$362abebb4b313340) + "/v2/track", payload);
6977
6984
  }
6978
6985
 
6979
6986
 
@@ -7042,6 +7049,7 @@ $parcel$export($54793663e06a1437$exports, "send_product_unavailable_to_depict",
7042
7049
 
7043
7050
 
7044
7051
 
7052
+
7045
7053
  async function $54793663e06a1437$export$d63b08f4f29ddba5(t, unavailability_type) {
7046
7054
  const product_id = await t.get_product_id();
7047
7055
  (0, $649f456f663da9fc$export$de56f1198d121036)(`Notifying Depict that product id: ${product_id} is ${unavailability_type}`);
@@ -7058,7 +7066,7 @@ async function $54793663e06a1437$export$d63b08f4f29ddba5(t, unavailability_type)
7058
7066
  }
7059
7067
  ]
7060
7068
  };
7061
- (0, $cafa1ff1049985c2$export$cc3b6ddf805f6156)(process.env.BASE_URL + "/v2/track", payload);
7069
+ (0, $cafa1ff1049985c2$export$cc3b6ddf805f6156)((0, $6c2b49f3f564b0d1$export$362abebb4b313340) + "/v2/track", payload);
7062
7070
  }
7063
7071
 
7064
7072
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/utilishared",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "packageManager": "yarn@3.2.2",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",
package/types.d.ts CHANGED
@@ -13,7 +13,7 @@ declare namespace NodeJS {
13
13
  type ConsentLevel = "marketing" | "necessary" | "preferences" | "statistics";
14
14
 
15
15
  interface ProcessEnv {
16
- /** base URL of the API, usually `https://api.depict.ai`, an environment variable to allow the backend to test locally */
16
+ /** base URL of the API, defaults to `https://api.depict.ai`. Use if testing against a different api */
17
17
  readonly BASE_URL: string;
18
18
 
19
19
  readonly DEBUG: "true" | "false";