sales-frontend-utils 0.0.31 → 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 +47 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +47 -40
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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";
|
|
@@ -184,9 +225,11 @@ var getDspExecutionEnvironment = () => {
|
|
|
184
225
|
}
|
|
185
226
|
return "web";
|
|
186
227
|
};
|
|
187
|
-
var
|
|
188
|
-
|
|
189
|
-
|
|
228
|
+
var isProductionApp = () => {
|
|
229
|
+
if (!isClient()) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
return isDspApp() || isFpPlannerApp();
|
|
190
233
|
};
|
|
191
234
|
var checkUserAgentDspApp = (userAgent) => {
|
|
192
235
|
return userAgent.toLowerCase().includes("sspapp");
|
|
@@ -569,42 +612,6 @@ function drawImageResizeCentered(base64, size) {
|
|
|
569
612
|
});
|
|
570
613
|
}
|
|
571
614
|
|
|
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
615
|
// src/utils/file-utils.ts
|
|
609
616
|
function base64ToBlob(base64String, contentType = "") {
|
|
610
617
|
const regex = /^data:([a-zA-Z0-9/+.-]+);base64,/;
|
|
@@ -850,10 +857,10 @@ exports.isDspApp = isDspApp;
|
|
|
850
857
|
exports.isFpPlannerApp = isFpPlannerApp;
|
|
851
858
|
exports.isPc = isPc;
|
|
852
859
|
exports.isPhone = isPhone;
|
|
860
|
+
exports.isProductionApp = isProductionApp;
|
|
853
861
|
exports.isSalesPortal = isSalesPortal;
|
|
854
862
|
exports.isStorybookEnv = isStorybookEnv;
|
|
855
863
|
exports.isTablet = isTablet;
|
|
856
|
-
exports.isWebView = isWebView;
|
|
857
864
|
exports.loadScript = loadScript;
|
|
858
865
|
exports.objectUrlToBase64 = objectUrlToBase64;
|
|
859
866
|
exports.objectUrlToBlob = objectUrlToBlob;
|