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.d.cts
CHANGED
|
@@ -28,7 +28,12 @@ type BrowserName = 'chrome' | 'firefox' | 'safari' | 'edge' | 'opera' | 'samsung
|
|
|
28
28
|
* @returns
|
|
29
29
|
*/
|
|
30
30
|
declare const getDspExecutionEnvironment: () => ExecutionEnvironment;
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* 한화생명 영업 앱 환경 여부 판단(DSP 앱 또는 FP 플래너 앱)
|
|
33
|
+
* 운영 중인 프로덕션 앱에서 실행 중인지 확인
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
declare const isProductionApp: () => boolean;
|
|
32
37
|
/**
|
|
33
38
|
* UserAgent에 SspApp 이 있는지 검사
|
|
34
39
|
* 있으면, DSP 앱
|
|
@@ -327,4 +332,4 @@ declare const initASTX2: ({ initSuccess, initFailure, checkServerSuccess, checkS
|
|
|
327
332
|
*/
|
|
328
333
|
declare function getE2EDataIDs(ids: string[], onSuccess: (astx_data: any) => void, onFailure?: () => void): void;
|
|
329
334
|
|
|
330
|
-
export { type BrowserName, type ExecutionEnvironment, MessageEventManager, type OSName, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspApiHostNameFromEnvironment, getDspExecutionEnvironment, getDudApiHostNameFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getOSName, getOSVersion, getOrCreateDeviceId, getServiceCode, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isSalesPortal, isStorybookEnv, isTablet,
|
|
335
|
+
export { type BrowserName, type ExecutionEnvironment, MessageEventManager, type OSName, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspApiHostNameFromEnvironment, getDspExecutionEnvironment, getDudApiHostNameFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getOSName, getOSVersion, getOrCreateDeviceId, getServiceCode, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isProductionApp, isSalesPortal, isStorybookEnv, isTablet, loadScript, objectUrlToBase64, objectUrlToBlob, setCookie, throttle };
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,12 @@ type BrowserName = 'chrome' | 'firefox' | 'safari' | 'edge' | 'opera' | 'samsung
|
|
|
28
28
|
* @returns
|
|
29
29
|
*/
|
|
30
30
|
declare const getDspExecutionEnvironment: () => ExecutionEnvironment;
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* 한화생명 영업 앱 환경 여부 판단(DSP 앱 또는 FP 플래너 앱)
|
|
33
|
+
* 운영 중인 프로덕션 앱에서 실행 중인지 확인
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
declare const isProductionApp: () => boolean;
|
|
32
37
|
/**
|
|
33
38
|
* UserAgent에 SspApp 이 있는지 검사
|
|
34
39
|
* 있으면, DSP 앱
|
|
@@ -327,4 +332,4 @@ declare const initASTX2: ({ initSuccess, initFailure, checkServerSuccess, checkS
|
|
|
327
332
|
*/
|
|
328
333
|
declare function getE2EDataIDs(ids: string[], onSuccess: (astx_data: any) => void, onFailure?: () => void): void;
|
|
329
334
|
|
|
330
|
-
export { type BrowserName, type ExecutionEnvironment, MessageEventManager, type OSName, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspApiHostNameFromEnvironment, getDspExecutionEnvironment, getDudApiHostNameFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getOSName, getOSVersion, getOrCreateDeviceId, getServiceCode, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isSalesPortal, isStorybookEnv, isTablet,
|
|
335
|
+
export { type BrowserName, type ExecutionEnvironment, MessageEventManager, type OSName, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspApiHostNameFromEnvironment, getDspExecutionEnvironment, getDudApiHostNameFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getOSName, getOSVersion, getOrCreateDeviceId, getServiceCode, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isProductionApp, isSalesPortal, isStorybookEnv, isTablet, loadScript, objectUrlToBase64, objectUrlToBlob, setCookie, throttle };
|
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";
|
|
@@ -182,9 +223,11 @@ var getDspExecutionEnvironment = () => {
|
|
|
182
223
|
}
|
|
183
224
|
return "web";
|
|
184
225
|
};
|
|
185
|
-
var
|
|
186
|
-
|
|
187
|
-
|
|
226
|
+
var isProductionApp = () => {
|
|
227
|
+
if (!isClient()) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
return isDspApp() || isFpPlannerApp();
|
|
188
231
|
};
|
|
189
232
|
var checkUserAgentDspApp = (userAgent) => {
|
|
190
233
|
return userAgent.toLowerCase().includes("sspapp");
|
|
@@ -567,42 +610,6 @@ function drawImageResizeCentered(base64, size) {
|
|
|
567
610
|
});
|
|
568
611
|
}
|
|
569
612
|
|
|
570
|
-
// src/utils/cookie-utils.ts
|
|
571
|
-
var getCookie = (name) => {
|
|
572
|
-
if (typeof document === "undefined") {
|
|
573
|
-
return "";
|
|
574
|
-
}
|
|
575
|
-
const match = document.cookie.match(new RegExp(`(^|; *)${name}=([^;]*)`));
|
|
576
|
-
return match ? decodeURIComponent(match[2] || "") : "";
|
|
577
|
-
};
|
|
578
|
-
var setCookie = (name, value, options = {}) => {
|
|
579
|
-
if (typeof document === "undefined") {
|
|
580
|
-
return;
|
|
581
|
-
}
|
|
582
|
-
let cookieString = `${name}=${encodeURIComponent(value)}`;
|
|
583
|
-
if (options.expires) {
|
|
584
|
-
let expiresDate;
|
|
585
|
-
if (typeof options.expires === "number") {
|
|
586
|
-
expiresDate = /* @__PURE__ */ new Date();
|
|
587
|
-
expiresDate.setDate(expiresDate.getDate() + options.expires);
|
|
588
|
-
} else {
|
|
589
|
-
expiresDate = options.expires;
|
|
590
|
-
}
|
|
591
|
-
cookieString += `; expires=${expiresDate.toUTCString()}`;
|
|
592
|
-
}
|
|
593
|
-
cookieString += `; path=${options.path || "/"}`;
|
|
594
|
-
if (options.domain) {
|
|
595
|
-
cookieString += `; domain=${options.domain}`;
|
|
596
|
-
}
|
|
597
|
-
if (options.secure) {
|
|
598
|
-
cookieString += "; secure";
|
|
599
|
-
}
|
|
600
|
-
document.cookie = cookieString;
|
|
601
|
-
};
|
|
602
|
-
var deleteCookie = (name, options = {}) => {
|
|
603
|
-
setCookie(name, "", { ...options, expires: -1 });
|
|
604
|
-
};
|
|
605
|
-
|
|
606
613
|
// src/utils/file-utils.ts
|
|
607
614
|
function base64ToBlob(base64String, contentType = "") {
|
|
608
615
|
const regex = /^data:([a-zA-Z0-9/+.-]+);base64,/;
|
|
@@ -805,6 +812,6 @@ function getE2EDataIDs(ids, onSuccess, onFailure = () => {
|
|
|
805
812
|
}
|
|
806
813
|
}
|
|
807
814
|
|
|
808
|
-
export { MessageEventManager, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspApiHostNameFromEnvironment, getDspExecutionEnvironment, getDudApiHostNameFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getOSName, getOSVersion, getOrCreateDeviceId, getServiceCode, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isSalesPortal, isStorybookEnv, isTablet,
|
|
815
|
+
export { MessageEventManager, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, downloadBlob, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getBusinessWorkDivisionCode, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspApiHostNameFromEnvironment, getDspExecutionEnvironment, getDudApiHostNameFromEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getOSName, getOSVersion, getOrCreateDeviceId, getServiceCode, getSubdomain, hasAstx2, imageUrlToFile, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isProductionApp, isSalesPortal, isStorybookEnv, isTablet, loadScript, objectUrlToBase64, objectUrlToBlob, setCookie, throttle };
|
|
809
816
|
//# sourceMappingURL=index.js.map
|
|
810
817
|
//# sourceMappingURL=index.js.map
|