sales-frontend-utils 0.0.32 → 0.0.34

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 CHANGED
@@ -38,6 +38,42 @@ function debounce(func, delay) {
38
38
  };
39
39
  }
40
40
 
41
+ // src/utils/cookie-utils.ts
42
+ var getCookie = (name) => {
43
+ if (typeof document === "undefined") {
44
+ return "";
45
+ }
46
+ const match = document.cookie.match(new RegExp(`(^|; *)${name}=([^;]*)`));
47
+ return match ? decodeURIComponent(match[2] || "") : "";
48
+ };
49
+ var setCookie = (name, value, options = {}) => {
50
+ if (typeof document === "undefined") {
51
+ return;
52
+ }
53
+ let cookieString = `${name}=${encodeURIComponent(value)}`;
54
+ if (options.expires) {
55
+ let expiresDate;
56
+ if (typeof options.expires === "number") {
57
+ expiresDate = /* @__PURE__ */ new Date();
58
+ expiresDate.setDate(expiresDate.getDate() + options.expires);
59
+ } else {
60
+ expiresDate = options.expires;
61
+ }
62
+ cookieString += `; expires=${expiresDate.toUTCString()}`;
63
+ }
64
+ cookieString += `; path=${options.path || "/"}`;
65
+ if (options.domain) {
66
+ cookieString += `; domain=${options.domain}`;
67
+ }
68
+ if (options.secure) {
69
+ cookieString += "; secure";
70
+ }
71
+ document.cookie = cookieString;
72
+ };
73
+ var deleteCookie = (name, options = {}) => {
74
+ setCookie(name, "", { ...options, expires: -1 });
75
+ };
76
+
41
77
  // src/utils/environment-utils.ts
42
78
  var getSubdomain = (hostname) => {
43
79
  if (!hostname || hostname === "localhost" || hostname === "127.0.0.1") {
@@ -50,6 +86,10 @@ var getSubdomain = (hostname) => {
50
86
  return parts[0] ?? "";
51
87
  };
52
88
  var getEnvironmentFromHostname = (hostname) => {
89
+ const debugModeEnv = getCookie("dsp-debug-mode-env")?.toLowerCase();
90
+ if (debugModeEnv) {
91
+ return debugModeEnv;
92
+ }
53
93
  const subDomain = getSubdomain(hostname);
54
94
  if (hostname === "localhost" || hostname === "127.0.0.1" || hostname.startsWith("localhost")) {
55
95
  return "local";
@@ -571,42 +611,6 @@ function drawImageResizeCentered(base64, size) {
571
611
  });
572
612
  }
573
613
 
574
- // src/utils/cookie-utils.ts
575
- var getCookie = (name) => {
576
- if (typeof document === "undefined") {
577
- return "";
578
- }
579
- const match = document.cookie.match(new RegExp(`(^|; *)${name}=([^;]*)`));
580
- return match ? decodeURIComponent(match[2] || "") : "";
581
- };
582
- var setCookie = (name, value, options = {}) => {
583
- if (typeof document === "undefined") {
584
- return;
585
- }
586
- let cookieString = `${name}=${encodeURIComponent(value)}`;
587
- if (options.expires) {
588
- let expiresDate;
589
- if (typeof options.expires === "number") {
590
- expiresDate = /* @__PURE__ */ new Date();
591
- expiresDate.setDate(expiresDate.getDate() + options.expires);
592
- } else {
593
- expiresDate = options.expires;
594
- }
595
- cookieString += `; expires=${expiresDate.toUTCString()}`;
596
- }
597
- cookieString += `; path=${options.path || "/"}`;
598
- if (options.domain) {
599
- cookieString += `; domain=${options.domain}`;
600
- }
601
- if (options.secure) {
602
- cookieString += "; secure";
603
- }
604
- document.cookie = cookieString;
605
- };
606
- var deleteCookie = (name, options = {}) => {
607
- setCookie(name, "", { ...options, expires: -1 });
608
- };
609
-
610
614
  // src/utils/file-utils.ts
611
615
  function base64ToBlob(base64String, contentType = "") {
612
616
  const regex = /^data:([a-zA-Z0-9/+.-]+);base64,/;