sales-frontend-utils 0.0.32 → 0.0.33

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