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.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,11 @@ var getSubdomain = (hostname) => {
50
86
  return parts[0] ?? "";
51
87
  };
52
88
  var getEnvironmentFromHostname = (hostname) => {
89
+ const debugMode = getCookie("dsp-debug-mode") === "on";
90
+ const debugModeEnv = getCookie("dsp-debug-mode-env")?.toLowerCase();
91
+ if (debugMode && debugModeEnv) {
92
+ return debugModeEnv;
93
+ }
53
94
  const subDomain = getSubdomain(hostname);
54
95
  if (hostname === "localhost" || hostname === "127.0.0.1" || hostname.startsWith("localhost")) {
55
96
  return "local";
@@ -571,42 +612,6 @@ function drawImageResizeCentered(base64, size) {
571
612
  });
572
613
  }
573
614
 
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
615
  // src/utils/file-utils.ts
611
616
  function base64ToBlob(base64String, contentType = "") {
612
617
  const regex = /^data:([a-zA-Z0-9/+.-]+);base64,/;