sales-frontend-utils 0.0.59 → 0.0.61

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/environment-utils.ts","../src/utils/cookie-utils.ts","../src/duplicate.ts"],"names":[],"mappings":";;;AA4DO,IAAM,WAAW,MAAM;AAC5B,EAAI,IAAA;AACF,IAAA,OAAO,CAAC,CAAC,MAAA;AAAA,GACH,CAAA,MAAA;AACN,IAAO,OAAA,KAAA;AAAA;AAEX,CAAA;;;AChEO,IAAM,SAAA,GAAY,CAAC,IAAyB,KAAA;AACjD,EAAI,IAAA,CAAC,UAAY,EAAA;AACf,IAAO,OAAA,EAAA;AAAA;AAET,EAAI,IAAA,OAAO,aAAa,WAAa,EAAA;AACnC,IAAO,OAAA,EAAA;AAAA;AAET,EAAM,MAAA,KAAA,GAAQ,SAAS,MAAO,CAAA,KAAA,CAAM,IAAI,MAAO,CAAA,CAAA,OAAA,EAAU,IAAI,CAAA,QAAA,CAAU,CAAC,CAAA;AAExE,EAAA,OAAO,QAAQ,kBAAmB,CAAA,KAAA,CAAM,CAAC,CAAA,IAAK,EAAE,CAAI,GAAA,EAAA;AACtD,CAAA;;;ACTO,IAAM,mBAAsB,GAAA;AAC5B,SAAS,oBAAoB,IAAuB,EAAA;AACvD,EAAA,MAAM,WAAc,GAAA,SAAA,CAAU,mBAAmB,CAAA,EAAG,MAAM,GAAG,CAAA;AAE7D,EAAO,OAAA,WAAA,EAAa,QAAS,CAAA,IAAI,CAAK,IAAA,KAAA;AAE1C;AAEa,IAAA,kBAAA,GAAqB,MAAM,mBAAA,CAAoB,YAAY","file":"duplicate.cjs","sourcesContent":["import { getCookie } from './cookie-utils';\n\n/**\n * 호스트명에서 서브도메인을 추출합니다.\n * @param hostname 호스트명\n * @returns 서브도메인 (예: nxl-dsp-dev)\n */\nexport const getSubdomain = (hostname: string): string => {\n if (!hostname || hostname === 'localhost' || hostname === '127.0.0.1') {\n return '';\n }\n\n const parts = hostname.split('.');\n\n // 최소 3개 부분이 있어야 서브도메인 존재 (subdomain.domain.com)\n if (parts.length < 3) {\n return '';\n }\n\n // 첫 번째 부분이 서브도메인\n return parts[0] ?? '';\n};\n\n/**\n * 호스트명을 기반으로 환경을 판단합니다.\n * @param hostname 호스트명\n * @returns 환경 구분 문자열 ('local' | 'dev' | 'stg' | 'prd')\n */\nexport const getEnvironmentFromHostname = (hostname: string): 'local' | 'dev' | 'stg' | 'prd' => {\n if (isClient()) {\n const debugModeEnv = getCookie('dsp-debug-mode-env')?.toLowerCase();\n if (debugModeEnv) {\n return debugModeEnv as 'local' | 'dev' | 'stg' | 'prd';\n }\n }\n const subDomain = getSubdomain(hostname);\n\n // localhost 판단\n if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname.startsWith('localhost')) {\n return 'local';\n }\n\n // dev 환경 판단\n if (subDomain.includes(`dev`)) {\n return 'dev';\n }\n\n // stg 환경 판단\n if (subDomain.includes('stg')) {\n return 'stg';\n }\n\n // 기본 운영\n return 'prd';\n};\n\n/**\n * @see https://github.com/storybookjs/storybook/issues/32028#issuecomment-3298982086\n * @note 스토리북에서 버그로인해 window객체를 정상적으로 탐지하지 못하는 이슈우회\n */\nexport const isClient = () => {\n try {\n return !!window;\n } catch {\n return false;\n }\n};\n\n// window.isStorybookEnv 접근을 위한 타입캐스팅\ndeclare const window: Window & { isStorybookEnv?: boolean };\n/**\n * 현재 실행 환경이 Storybook인지 확인하는 함수\n *\n * 사용 전, `viteFinal` 설정에서 `window.isStorybookEnv`를 `true`로 정의해야 정상 동작합니다.\n *\n * 예시:\n * ```ts\n * const config: StorybookConfig = {\n * viteFinal: (config) => {\n * // window.isStorybookEnv를 true로 설정 (boolean 값으로 처리됨)\n * config.define = {\n * ...config.define,\n * 'window.isStorybookEnv': 'true',\n * };\n *\n * return config;\n * },\n * };\n * ```\n */\nexport const isStorybookEnv = () => {\n try {\n return window.isStorybookEnv === true;\n } catch {\n // window가 존재하지 않는 등 예외 상황에서는 false 반환\n return false;\n }\n};\n\n/**\n * 현재 업무구분 코드 구하기\n * 원칙: pathname의 첫 번째가 업무구분코드를 사용할 경우 해당 값을 반환\n * @returns\n */\nexport const getBusinessWorkDivisionCode = (pathname?: string) => {\n if (pathname) {\n return pathname.split('/')[1] ?? '';\n }\n\n return location.pathname.split('/')[1] ?? '';\n};\n\n/**\n * @description storybook에서 동작을 고려하여 수정한 버전\n * @returns\n */\nexport const getServicePath = () => {\n if (typeof window.isStorybookEnv === 'boolean') {\n return '';\n } else {\n return `/${getBusinessWorkDivisionCode()}`;\n }\n};\n\n/**\n * 환경에 맞는 API 호스트명을 반환합니다.\n * 호스트명을 강제하고 싶으면 두 번째 파라미터로 넘기세요.\n * @param currentHostname\n * @param forceApiHostName\n * @returns\n */\n\nexport const getApiHostNameFromEnvironment = (currentHostname: string, forceApiHostName?: string) => {\n if (forceApiHostName) {\n return forceApiHostName;\n }\n\n const environment = getEnvironmentFromHostname(currentHostname);\n\n switch (environment) {\n case 'dev':\n return `https://nxl-dsp-dev.hanwhalife.com`;\n\n case 'local':\n case 'stg':\n return `https://nxl-dsp-stg.hanwhalife.com`;\n\n case 'prd':\n return `https://nxl-dsp.hanwhalife.com`;\n\n default:\n console.warn('DSP API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * 환경에 맞는 CDN 호스트명을 반환합니다.\n * 호스트명을 강제하고 싶으면 두 번째 파라미터로 넘기세요.\n * @param currentHostname\n * @param forceApiHostName\n * @returns\n */\nexport const getCdnHostNameFromEnvironment = (currentHostname: string, forceApiHostName?: string) => {\n if (!isClient()) {\n return '';\n }\n\n if (forceApiHostName) {\n return forceApiHostName;\n }\n\n const environment = getEnvironmentFromHostname(currentHostname);\n\n switch (environment) {\n case 'dev':\n return `https://dev-dsp-static.hanwhalife.com`;\n\n case 'local':\n case 'stg':\n return `https://stg-dsp-static.hanwhalife.com`;\n\n case 'prd':\n return `https://dsp-static.hanwhalife.com'`;\n\n default:\n console.warn('DSP environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 비정형PI 호스트명을 반환합니다.\n * @param serviceCode dea,dis,dcm\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getDudApiBasePathFromEnvironment = (hostname: string, servicePath: string) => {\n const environment = getEnvironmentFromHostname(hostname);\n\n switch (environment) {\n /**\n * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.\n * (cors이슈 해결을 위해 필수)\n */\n case 'local':\n return `${servicePath}/api/dud`;\n /**\n * local 이 아닌 환경에서는 전체주소를 호출합니다.\n */\n case 'dev':\n return `https://dsp-dud-dev.hanwhalife.com:10101/api`;\n\n case 'stg':\n return `https://dsp-dud-stg.hanwhalife.com:10102/api`;\n\n case 'prd':\n return `https://dsp-dud.hanwhalife.com/api`;\n\n default:\n console.warn('DUD API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 Dsp 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param serviceCodeTo dea,dis 같은 api서버명\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getDspApiBasePathFromEnvironment = (serviceCodeTo: string, hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n /**\n * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.\n * (cors이슈 해결을 위해 필수)\n */\n case 'local':\n return `${getServicePath()}/api/${serviceCodeTo}`;\n /**\n * local 이 아닌 환경에서는 전체주소를 호출합니다.\n */\n case 'dev':\n return `https://nxl-dsp-dev.hanwhalife.com/api/${serviceCodeTo}`;\n\n case 'stg':\n return `https://nxl-dsp-stg.hanwhalife.com/api/${serviceCodeTo}`;\n\n case 'prd':\n return `https://nxl-dsp.hanwhalife.com/api/${serviceCodeTo}`;\n\n default:\n console.warn('DSP API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 NLC 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getNlcHostFromEnvironment = (hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n case 'local':\n return `https://nxl-nlc-stg.hanwhalife.com`;\n\n case 'dev':\n return `https://nxl-nlc-dev.hanwhalife.com`;\n\n case 'stg':\n return `https://nxl-nlc-stg.hanwhalife.com`;\n\n case 'prd':\n return `https://nxl-nlc.hanwhalife.com`;\n\n default:\n console.warn('NLC environment is not defined');\n\n return '';\n }\n};\n","import { isClient } from \"./environment-utils\";\n\nexport const getCookie = (name: string): string => {\n if (!isClient()) {\n return '';\n }\n if (typeof document === 'undefined') {\n return '';\n }\n const match = document.cookie.match(new RegExp(`(^|; *)${name}=([^;]*)`));\n\n return match ? decodeURIComponent(match[2] || '') : '';\n};\n\nexport const setCookie = (\n name: string,\n value: string,\n options: {\n expires?: number | Date; // number of days\n path?: string;\n domain?: string;\n secure?: boolean;\n } = {}\n): void => {\n if (!isClient()) {\n return;\n }\n if (typeof document === 'undefined') {\n return;\n }\n\n let cookieString = `${name}=${encodeURIComponent(value)}`;\n\n if (options.expires) {\n let expiresDate: Date;\n if (typeof options.expires === 'number') {\n expiresDate = new Date();\n expiresDate.setDate(expiresDate.getDate() + options.expires);\n } else {\n expiresDate = options.expires;\n }\n cookieString += `; expires=${expiresDate.toUTCString()}`;\n }\n\n cookieString += `; path=${options.path || '/'}`;\n\n if (options.domain) {\n cookieString += `; domain=${options.domain}`;\n }\n\n if (options.secure) {\n cookieString += '; secure';\n }\n\n document.cookie = cookieString;\n};\n\nexport const deleteCookie = (name: string, options: { path?: string; domain?: string } = {}): void => {\n if (!isClient()) {\n return;\n }\n setCookie(name, '', { ...options, expires: -1 });\n};\n","import { getCookie } from \"./utils/cookie-utils\";\n\n//중복코드지만, 패키지 의존성을 피하기위해서 별도로 재작성한 코드들입니다. \nexport const filterNameCookieKey = 'dsp-debug-mode-filter-name';\nexport function isDebugByFilterName(name: string): boolean {\n const filterNames = getCookie(filterNameCookieKey)?.split(',');\n\n return filterNames?.includes(name) || false;\n\n}\n\nexport const isDownloaderFilter = () => isDebugByFilterName('downloader');"]}
1
+ {"version":3,"sources":["../src/utils/environment-utils.ts","../src/utils/cookie-utils.ts","../src/duplicate.ts"],"names":[],"mappings":";;;AA4DO,IAAM,WAAW,MAAM;AAC5B,EAAI,IAAA;AACF,IAAA,OAAO,CAAC,CAAC,MAAA;AAAA,GACH,CAAA,MAAA;AACN,IAAO,OAAA,KAAA;AAAA;AAEX,CAAA;;;AChEO,IAAM,SAAA,GAAY,CAAC,IAAyB,KAAA;AACjD,EAAI,IAAA,CAAC,UAAY,EAAA;AACf,IAAO,OAAA,EAAA;AAAA;AAET,EAAI,IAAA,OAAO,aAAa,WAAa,EAAA;AACnC,IAAO,OAAA,EAAA;AAAA;AAET,EAAM,MAAA,KAAA,GAAQ,SAAS,MAAO,CAAA,KAAA,CAAM,IAAI,MAAO,CAAA,CAAA,OAAA,EAAU,IAAI,CAAA,QAAA,CAAU,CAAC,CAAA;AAExE,EAAA,OAAO,QAAQ,kBAAmB,CAAA,KAAA,CAAM,CAAC,CAAA,IAAK,EAAE,CAAI,GAAA,EAAA;AACtD,CAAA;;;ACTO,IAAM,mBAAsB,GAAA;AAC5B,SAAS,oBAAoB,IAAuB,EAAA;AACvD,EAAA,MAAM,WAAc,GAAA,SAAA,CAAU,mBAAmB,CAAA,EAAG,MAAM,GAAG,CAAA;AAE7D,EAAO,OAAA,WAAA,EAAa,QAAS,CAAA,IAAI,CAAK,IAAA,KAAA;AAE1C;AAEa,IAAA,kBAAA,GAAqB,MAAM,mBAAA,CAAoB,YAAY","file":"duplicate.cjs","sourcesContent":["import { getCookie } from './cookie-utils';\n\n/**\n * 호스트명에서 서브도메인을 추출합니다.\n * @param hostname 호스트명\n * @returns 서브도메인 (예: nxl-dsp-dev)\n */\nexport const getSubdomain = (hostname: string): string => {\n if (!hostname || hostname === 'localhost' || hostname === '127.0.0.1') {\n return '';\n }\n\n const parts = hostname.split('.');\n\n // 최소 3개 부분이 있어야 서브도메인 존재 (subdomain.domain.com)\n if (parts.length < 3) {\n return '';\n }\n\n // 첫 번째 부분이 서브도메인\n return parts[0] ?? '';\n};\n\n/**\n * 호스트명을 기반으로 환경을 판단합니다.\n * @param hostname 호스트명\n * @returns 환경 구분 문자열 ('local' | 'dev' | 'stg' | 'prd')\n */\nexport const getEnvironmentFromHostname = (hostname: string): 'local' | 'dev' | 'stg' | 'prd' => {\n if (isClient()) {\n const debugModeEnv = getCookie('dsp-debug-mode-env')?.toLowerCase();\n if (debugModeEnv) {\n return debugModeEnv as 'local' | 'dev' | 'stg' | 'prd';\n }\n }\n const subDomain = getSubdomain(hostname);\n\n // localhost 판단\n if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname.startsWith('localhost')) {\n return 'local';\n }\n\n // dev 환경 판단\n if (subDomain.includes(`dev`)) {\n return 'dev';\n }\n\n // stg 환경 판단\n if (subDomain.includes('stg')) {\n return 'stg';\n }\n\n // 기본 운영\n return 'prd';\n};\n\n/**\n * @see https://github.com/storybookjs/storybook/issues/32028#issuecomment-3298982086\n * @note 스토리북에서 버그로인해 window객체를 정상적으로 탐지하지 못하는 이슈우회\n */\nexport const isClient = () => {\n try {\n return !!window;\n } catch {\n return false;\n }\n};\n\n// window.isStorybookEnv 접근을 위한 타입캐스팅\ndeclare const window: Window & { isStorybookEnv?: boolean };\n/**\n * 현재 실행 환경이 Storybook인지 확인하는 함수\n *\n * 사용 전, `viteFinal` 설정에서 `window.isStorybookEnv`를 `true`로 정의해야 정상 동작합니다.\n *\n * 예시:\n * ```ts\n * const config: StorybookConfig = {\n * viteFinal: (config) => {\n * // window.isStorybookEnv를 true로 설정 (boolean 값으로 처리됨)\n * config.define = {\n * ...config.define,\n * 'window.isStorybookEnv': 'true',\n * };\n *\n * return config;\n * },\n * };\n * ```\n */\nexport const isStorybookEnv = () => {\n try {\n return window.isStorybookEnv === true;\n } catch {\n // window가 존재하지 않는 등 예외 상황에서는 false 반환\n return false;\n }\n};\n\n/**\n * 현재 업무구분 코드 구하기\n * 원칙: pathname의 첫 번째가 업무구분코드를 사용할 경우 해당 값을 반환\n * @returns\n */\nexport const getBusinessWorkDivisionCode = (pathname?: string) => {\n if (pathname) {\n return pathname.split('/')[1] ?? '';\n }\n\n return location.pathname.split('/')[1] ?? '';\n};\n\n/**\n * @description storybook에서 동작을 고려하여 수정한 버전\n * @returns\n */\nexport const getServicePath = () => {\n if (typeof window.isStorybookEnv === 'boolean') {\n return '';\n } else {\n return `/${getBusinessWorkDivisionCode()}`;\n }\n};\n\n/**\n * 환경에 맞는 API 호스트명을 반환합니다.\n * 호스트명을 강제하고 싶으면 두 번째 파라미터로 넘기세요.\n * @param currentHostname\n * @param forceApiHostName\n * @returns\n */\n\nexport const getApiHostNameFromEnvironment = (currentHostname: string, forceApiHostName?: string) => {\n if (forceApiHostName) {\n return forceApiHostName;\n }\n\n const environment = getEnvironmentFromHostname(currentHostname);\n\n switch (environment) {\n case 'dev':\n return `https://nxl-dsp-dev.hanwhalife.com`;\n\n case 'local':\n case 'stg':\n return `https://nxl-dsp-stg.hanwhalife.com`;\n\n case 'prd':\n return `https://nxl-dsp.hanwhalife.com`;\n\n default:\n console.warn('DSP API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * 환경에 맞는 CDN 호스트명을 반환합니다.\n * 호스트명을 강제하고 싶으면 두 번째 파라미터로 넘기세요.\n * @param currentHostname\n * @param forceApiHostName\n * @returns\n */\nexport const getCdnHostNameFromEnvironment = (currentHostname: string, forceApiHostName?: string) => {\n if (!isClient()) {\n return '';\n }\n\n if (forceApiHostName) {\n return forceApiHostName;\n }\n\n const environment = getEnvironmentFromHostname(currentHostname);\n\n switch (environment) {\n case 'dev':\n return `https://dev-dsp-static.hanwhalife.com`;\n\n case 'local':\n case 'stg':\n return `https://stg-dsp-static.hanwhalife.com`;\n\n case 'prd':\n return `https://dsp-static.hanwhalife.com`;\n\n default:\n console.warn('DSP environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 비정형PI 호스트명을 반환합니다.\n * @param serviceCode dea,dis,dcm\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getDudApiBasePathFromEnvironment = (hostname: string, servicePath: string) => {\n const environment = getEnvironmentFromHostname(hostname);\n\n switch (environment) {\n /**\n * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.\n * (cors이슈 해결을 위해 필수)\n */\n case 'local':\n return `${servicePath}/api/dud`;\n /**\n * local 이 아닌 환경에서는 전체주소를 호출합니다.\n */\n case 'dev':\n return `https://dsp-dud-dev.hanwhalife.com:10101/api`;\n\n case 'stg':\n return `https://dsp-dud-stg.hanwhalife.com:10102/api`;\n\n case 'prd':\n return `https://dsp-dud.hanwhalife.com/api`;\n\n default:\n console.warn('DUD API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 Dsp 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param serviceCodeTo dea,dis 같은 api서버명\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getDspApiBasePathFromEnvironment = (serviceCodeTo: string, hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n /**\n * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.\n * (cors이슈 해결을 위해 필수)\n */\n case 'local':\n return `${getServicePath()}/api/${serviceCodeTo}`;\n /**\n * local 이 아닌 환경에서는 전체주소를 호출합니다.\n */\n case 'dev':\n return `https://nxl-dsp-dev.hanwhalife.com/api/${serviceCodeTo}`;\n\n case 'stg':\n return `https://nxl-dsp-stg.hanwhalife.com/api/${serviceCodeTo}`;\n\n case 'prd':\n return `https://nxl-dsp.hanwhalife.com/api/${serviceCodeTo}`;\n\n default:\n console.warn('DSP API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 NLC 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getNlcHostFromEnvironment = (hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n case 'local':\n return `https://nxl-nlc-stg.hanwhalife.com`;\n\n case 'dev':\n return `https://nxl-nlc-dev.hanwhalife.com`;\n\n case 'stg':\n return `https://nxl-nlc-stg.hanwhalife.com`;\n\n case 'prd':\n return `https://nxl-nlc.hanwhalife.com`;\n\n default:\n console.warn('NLC environment is not defined');\n\n return '';\n }\n};\n","import { isClient } from \"./environment-utils\";\n\nexport const getCookie = (name: string): string => {\n if (!isClient()) {\n return '';\n }\n if (typeof document === 'undefined') {\n return '';\n }\n const match = document.cookie.match(new RegExp(`(^|; *)${name}=([^;]*)`));\n\n return match ? decodeURIComponent(match[2] || '') : '';\n};\n\nexport const setCookie = (\n name: string,\n value: string,\n options: {\n expires?: number | Date; // number of days\n path?: string;\n domain?: string;\n secure?: boolean;\n } = {}\n): void => {\n if (!isClient()) {\n return;\n }\n if (typeof document === 'undefined') {\n return;\n }\n\n let cookieString = `${name}=${encodeURIComponent(value)}`;\n\n if (options.expires) {\n let expiresDate: Date;\n if (typeof options.expires === 'number') {\n expiresDate = new Date();\n expiresDate.setDate(expiresDate.getDate() + options.expires);\n } else {\n expiresDate = options.expires;\n }\n cookieString += `; expires=${expiresDate.toUTCString()}`;\n }\n\n cookieString += `; path=${options.path || '/'}`;\n\n if (options.domain) {\n cookieString += `; domain=${options.domain}`;\n }\n\n if (options.secure) {\n cookieString += '; secure';\n }\n\n document.cookie = cookieString;\n};\n\nexport const deleteCookie = (name: string, options: { path?: string; domain?: string } = {}): void => {\n if (!isClient()) {\n return;\n }\n setCookie(name, '', { ...options, expires: -1 });\n};\n","import { getCookie } from \"./utils/cookie-utils\";\n\n//중복코드지만, 패키지 의존성을 피하기위해서 별도로 재작성한 코드들입니다. \nexport const filterNameCookieKey = 'dsp-debug-mode-filter-name';\nexport function isDebugByFilterName(name: string): boolean {\n const filterNames = getCookie(filterNameCookieKey)?.split(',');\n\n return filterNames?.includes(name) || false;\n\n}\n\nexport const isDownloaderFilter = () => isDebugByFilterName('downloader');"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/environment-utils.ts","../src/utils/cookie-utils.ts","../src/duplicate.ts"],"names":[],"mappings":";AA4DO,IAAM,WAAW,MAAM;AAC5B,EAAI,IAAA;AACF,IAAA,OAAO,CAAC,CAAC,MAAA;AAAA,GACH,CAAA,MAAA;AACN,IAAO,OAAA,KAAA;AAAA;AAEX,CAAA;;;AChEO,IAAM,SAAA,GAAY,CAAC,IAAyB,KAAA;AACjD,EAAI,IAAA,CAAC,UAAY,EAAA;AACf,IAAO,OAAA,EAAA;AAAA;AAET,EAAI,IAAA,OAAO,aAAa,WAAa,EAAA;AACnC,IAAO,OAAA,EAAA;AAAA;AAET,EAAM,MAAA,KAAA,GAAQ,SAAS,MAAO,CAAA,KAAA,CAAM,IAAI,MAAO,CAAA,CAAA,OAAA,EAAU,IAAI,CAAA,QAAA,CAAU,CAAC,CAAA;AAExE,EAAA,OAAO,QAAQ,kBAAmB,CAAA,KAAA,CAAM,CAAC,CAAA,IAAK,EAAE,CAAI,GAAA,EAAA;AACtD,CAAA;;;ACTO,IAAM,mBAAsB,GAAA;AAC5B,SAAS,oBAAoB,IAAuB,EAAA;AACvD,EAAA,MAAM,WAAc,GAAA,SAAA,CAAU,mBAAmB,CAAA,EAAG,MAAM,GAAG,CAAA;AAE7D,EAAO,OAAA,WAAA,EAAa,QAAS,CAAA,IAAI,CAAK,IAAA,KAAA;AAE1C;AAEa,IAAA,kBAAA,GAAqB,MAAM,mBAAA,CAAoB,YAAY","file":"duplicate.js","sourcesContent":["import { getCookie } from './cookie-utils';\n\n/**\n * 호스트명에서 서브도메인을 추출합니다.\n * @param hostname 호스트명\n * @returns 서브도메인 (예: nxl-dsp-dev)\n */\nexport const getSubdomain = (hostname: string): string => {\n if (!hostname || hostname === 'localhost' || hostname === '127.0.0.1') {\n return '';\n }\n\n const parts = hostname.split('.');\n\n // 최소 3개 부분이 있어야 서브도메인 존재 (subdomain.domain.com)\n if (parts.length < 3) {\n return '';\n }\n\n // 첫 번째 부분이 서브도메인\n return parts[0] ?? '';\n};\n\n/**\n * 호스트명을 기반으로 환경을 판단합니다.\n * @param hostname 호스트명\n * @returns 환경 구분 문자열 ('local' | 'dev' | 'stg' | 'prd')\n */\nexport const getEnvironmentFromHostname = (hostname: string): 'local' | 'dev' | 'stg' | 'prd' => {\n if (isClient()) {\n const debugModeEnv = getCookie('dsp-debug-mode-env')?.toLowerCase();\n if (debugModeEnv) {\n return debugModeEnv as 'local' | 'dev' | 'stg' | 'prd';\n }\n }\n const subDomain = getSubdomain(hostname);\n\n // localhost 판단\n if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname.startsWith('localhost')) {\n return 'local';\n }\n\n // dev 환경 판단\n if (subDomain.includes(`dev`)) {\n return 'dev';\n }\n\n // stg 환경 판단\n if (subDomain.includes('stg')) {\n return 'stg';\n }\n\n // 기본 운영\n return 'prd';\n};\n\n/**\n * @see https://github.com/storybookjs/storybook/issues/32028#issuecomment-3298982086\n * @note 스토리북에서 버그로인해 window객체를 정상적으로 탐지하지 못하는 이슈우회\n */\nexport const isClient = () => {\n try {\n return !!window;\n } catch {\n return false;\n }\n};\n\n// window.isStorybookEnv 접근을 위한 타입캐스팅\ndeclare const window: Window & { isStorybookEnv?: boolean };\n/**\n * 현재 실행 환경이 Storybook인지 확인하는 함수\n *\n * 사용 전, `viteFinal` 설정에서 `window.isStorybookEnv`를 `true`로 정의해야 정상 동작합니다.\n *\n * 예시:\n * ```ts\n * const config: StorybookConfig = {\n * viteFinal: (config) => {\n * // window.isStorybookEnv를 true로 설정 (boolean 값으로 처리됨)\n * config.define = {\n * ...config.define,\n * 'window.isStorybookEnv': 'true',\n * };\n *\n * return config;\n * },\n * };\n * ```\n */\nexport const isStorybookEnv = () => {\n try {\n return window.isStorybookEnv === true;\n } catch {\n // window가 존재하지 않는 등 예외 상황에서는 false 반환\n return false;\n }\n};\n\n/**\n * 현재 업무구분 코드 구하기\n * 원칙: pathname의 첫 번째가 업무구분코드를 사용할 경우 해당 값을 반환\n * @returns\n */\nexport const getBusinessWorkDivisionCode = (pathname?: string) => {\n if (pathname) {\n return pathname.split('/')[1] ?? '';\n }\n\n return location.pathname.split('/')[1] ?? '';\n};\n\n/**\n * @description storybook에서 동작을 고려하여 수정한 버전\n * @returns\n */\nexport const getServicePath = () => {\n if (typeof window.isStorybookEnv === 'boolean') {\n return '';\n } else {\n return `/${getBusinessWorkDivisionCode()}`;\n }\n};\n\n/**\n * 환경에 맞는 API 호스트명을 반환합니다.\n * 호스트명을 강제하고 싶으면 두 번째 파라미터로 넘기세요.\n * @param currentHostname\n * @param forceApiHostName\n * @returns\n */\n\nexport const getApiHostNameFromEnvironment = (currentHostname: string, forceApiHostName?: string) => {\n if (forceApiHostName) {\n return forceApiHostName;\n }\n\n const environment = getEnvironmentFromHostname(currentHostname);\n\n switch (environment) {\n case 'dev':\n return `https://nxl-dsp-dev.hanwhalife.com`;\n\n case 'local':\n case 'stg':\n return `https://nxl-dsp-stg.hanwhalife.com`;\n\n case 'prd':\n return `https://nxl-dsp.hanwhalife.com`;\n\n default:\n console.warn('DSP API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * 환경에 맞는 CDN 호스트명을 반환합니다.\n * 호스트명을 강제하고 싶으면 두 번째 파라미터로 넘기세요.\n * @param currentHostname\n * @param forceApiHostName\n * @returns\n */\nexport const getCdnHostNameFromEnvironment = (currentHostname: string, forceApiHostName?: string) => {\n if (!isClient()) {\n return '';\n }\n\n if (forceApiHostName) {\n return forceApiHostName;\n }\n\n const environment = getEnvironmentFromHostname(currentHostname);\n\n switch (environment) {\n case 'dev':\n return `https://dev-dsp-static.hanwhalife.com`;\n\n case 'local':\n case 'stg':\n return `https://stg-dsp-static.hanwhalife.com`;\n\n case 'prd':\n return `https://dsp-static.hanwhalife.com'`;\n\n default:\n console.warn('DSP environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 비정형PI 호스트명을 반환합니다.\n * @param serviceCode dea,dis,dcm\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getDudApiBasePathFromEnvironment = (hostname: string, servicePath: string) => {\n const environment = getEnvironmentFromHostname(hostname);\n\n switch (environment) {\n /**\n * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.\n * (cors이슈 해결을 위해 필수)\n */\n case 'local':\n return `${servicePath}/api/dud`;\n /**\n * local 이 아닌 환경에서는 전체주소를 호출합니다.\n */\n case 'dev':\n return `https://dsp-dud-dev.hanwhalife.com:10101/api`;\n\n case 'stg':\n return `https://dsp-dud-stg.hanwhalife.com:10102/api`;\n\n case 'prd':\n return `https://dsp-dud.hanwhalife.com/api`;\n\n default:\n console.warn('DUD API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 Dsp 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param serviceCodeTo dea,dis 같은 api서버명\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getDspApiBasePathFromEnvironment = (serviceCodeTo: string, hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n /**\n * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.\n * (cors이슈 해결을 위해 필수)\n */\n case 'local':\n return `${getServicePath()}/api/${serviceCodeTo}`;\n /**\n * local 이 아닌 환경에서는 전체주소를 호출합니다.\n */\n case 'dev':\n return `https://nxl-dsp-dev.hanwhalife.com/api/${serviceCodeTo}`;\n\n case 'stg':\n return `https://nxl-dsp-stg.hanwhalife.com/api/${serviceCodeTo}`;\n\n case 'prd':\n return `https://nxl-dsp.hanwhalife.com/api/${serviceCodeTo}`;\n\n default:\n console.warn('DSP API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 NLC 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getNlcHostFromEnvironment = (hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n case 'local':\n return `https://nxl-nlc-stg.hanwhalife.com`;\n\n case 'dev':\n return `https://nxl-nlc-dev.hanwhalife.com`;\n\n case 'stg':\n return `https://nxl-nlc-stg.hanwhalife.com`;\n\n case 'prd':\n return `https://nxl-nlc.hanwhalife.com`;\n\n default:\n console.warn('NLC environment is not defined');\n\n return '';\n }\n};\n","import { isClient } from \"./environment-utils\";\n\nexport const getCookie = (name: string): string => {\n if (!isClient()) {\n return '';\n }\n if (typeof document === 'undefined') {\n return '';\n }\n const match = document.cookie.match(new RegExp(`(^|; *)${name}=([^;]*)`));\n\n return match ? decodeURIComponent(match[2] || '') : '';\n};\n\nexport const setCookie = (\n name: string,\n value: string,\n options: {\n expires?: number | Date; // number of days\n path?: string;\n domain?: string;\n secure?: boolean;\n } = {}\n): void => {\n if (!isClient()) {\n return;\n }\n if (typeof document === 'undefined') {\n return;\n }\n\n let cookieString = `${name}=${encodeURIComponent(value)}`;\n\n if (options.expires) {\n let expiresDate: Date;\n if (typeof options.expires === 'number') {\n expiresDate = new Date();\n expiresDate.setDate(expiresDate.getDate() + options.expires);\n } else {\n expiresDate = options.expires;\n }\n cookieString += `; expires=${expiresDate.toUTCString()}`;\n }\n\n cookieString += `; path=${options.path || '/'}`;\n\n if (options.domain) {\n cookieString += `; domain=${options.domain}`;\n }\n\n if (options.secure) {\n cookieString += '; secure';\n }\n\n document.cookie = cookieString;\n};\n\nexport const deleteCookie = (name: string, options: { path?: string; domain?: string } = {}): void => {\n if (!isClient()) {\n return;\n }\n setCookie(name, '', { ...options, expires: -1 });\n};\n","import { getCookie } from \"./utils/cookie-utils\";\n\n//중복코드지만, 패키지 의존성을 피하기위해서 별도로 재작성한 코드들입니다. \nexport const filterNameCookieKey = 'dsp-debug-mode-filter-name';\nexport function isDebugByFilterName(name: string): boolean {\n const filterNames = getCookie(filterNameCookieKey)?.split(',');\n\n return filterNames?.includes(name) || false;\n\n}\n\nexport const isDownloaderFilter = () => isDebugByFilterName('downloader');"]}
1
+ {"version":3,"sources":["../src/utils/environment-utils.ts","../src/utils/cookie-utils.ts","../src/duplicate.ts"],"names":[],"mappings":";AA4DO,IAAM,WAAW,MAAM;AAC5B,EAAI,IAAA;AACF,IAAA,OAAO,CAAC,CAAC,MAAA;AAAA,GACH,CAAA,MAAA;AACN,IAAO,OAAA,KAAA;AAAA;AAEX,CAAA;;;AChEO,IAAM,SAAA,GAAY,CAAC,IAAyB,KAAA;AACjD,EAAI,IAAA,CAAC,UAAY,EAAA;AACf,IAAO,OAAA,EAAA;AAAA;AAET,EAAI,IAAA,OAAO,aAAa,WAAa,EAAA;AACnC,IAAO,OAAA,EAAA;AAAA;AAET,EAAM,MAAA,KAAA,GAAQ,SAAS,MAAO,CAAA,KAAA,CAAM,IAAI,MAAO,CAAA,CAAA,OAAA,EAAU,IAAI,CAAA,QAAA,CAAU,CAAC,CAAA;AAExE,EAAA,OAAO,QAAQ,kBAAmB,CAAA,KAAA,CAAM,CAAC,CAAA,IAAK,EAAE,CAAI,GAAA,EAAA;AACtD,CAAA;;;ACTO,IAAM,mBAAsB,GAAA;AAC5B,SAAS,oBAAoB,IAAuB,EAAA;AACvD,EAAA,MAAM,WAAc,GAAA,SAAA,CAAU,mBAAmB,CAAA,EAAG,MAAM,GAAG,CAAA;AAE7D,EAAO,OAAA,WAAA,EAAa,QAAS,CAAA,IAAI,CAAK,IAAA,KAAA;AAE1C;AAEa,IAAA,kBAAA,GAAqB,MAAM,mBAAA,CAAoB,YAAY","file":"duplicate.js","sourcesContent":["import { getCookie } from './cookie-utils';\n\n/**\n * 호스트명에서 서브도메인을 추출합니다.\n * @param hostname 호스트명\n * @returns 서브도메인 (예: nxl-dsp-dev)\n */\nexport const getSubdomain = (hostname: string): string => {\n if (!hostname || hostname === 'localhost' || hostname === '127.0.0.1') {\n return '';\n }\n\n const parts = hostname.split('.');\n\n // 최소 3개 부분이 있어야 서브도메인 존재 (subdomain.domain.com)\n if (parts.length < 3) {\n return '';\n }\n\n // 첫 번째 부분이 서브도메인\n return parts[0] ?? '';\n};\n\n/**\n * 호스트명을 기반으로 환경을 판단합니다.\n * @param hostname 호스트명\n * @returns 환경 구분 문자열 ('local' | 'dev' | 'stg' | 'prd')\n */\nexport const getEnvironmentFromHostname = (hostname: string): 'local' | 'dev' | 'stg' | 'prd' => {\n if (isClient()) {\n const debugModeEnv = getCookie('dsp-debug-mode-env')?.toLowerCase();\n if (debugModeEnv) {\n return debugModeEnv as 'local' | 'dev' | 'stg' | 'prd';\n }\n }\n const subDomain = getSubdomain(hostname);\n\n // localhost 판단\n if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname.startsWith('localhost')) {\n return 'local';\n }\n\n // dev 환경 판단\n if (subDomain.includes(`dev`)) {\n return 'dev';\n }\n\n // stg 환경 판단\n if (subDomain.includes('stg')) {\n return 'stg';\n }\n\n // 기본 운영\n return 'prd';\n};\n\n/**\n * @see https://github.com/storybookjs/storybook/issues/32028#issuecomment-3298982086\n * @note 스토리북에서 버그로인해 window객체를 정상적으로 탐지하지 못하는 이슈우회\n */\nexport const isClient = () => {\n try {\n return !!window;\n } catch {\n return false;\n }\n};\n\n// window.isStorybookEnv 접근을 위한 타입캐스팅\ndeclare const window: Window & { isStorybookEnv?: boolean };\n/**\n * 현재 실행 환경이 Storybook인지 확인하는 함수\n *\n * 사용 전, `viteFinal` 설정에서 `window.isStorybookEnv`를 `true`로 정의해야 정상 동작합니다.\n *\n * 예시:\n * ```ts\n * const config: StorybookConfig = {\n * viteFinal: (config) => {\n * // window.isStorybookEnv를 true로 설정 (boolean 값으로 처리됨)\n * config.define = {\n * ...config.define,\n * 'window.isStorybookEnv': 'true',\n * };\n *\n * return config;\n * },\n * };\n * ```\n */\nexport const isStorybookEnv = () => {\n try {\n return window.isStorybookEnv === true;\n } catch {\n // window가 존재하지 않는 등 예외 상황에서는 false 반환\n return false;\n }\n};\n\n/**\n * 현재 업무구분 코드 구하기\n * 원칙: pathname의 첫 번째가 업무구분코드를 사용할 경우 해당 값을 반환\n * @returns\n */\nexport const getBusinessWorkDivisionCode = (pathname?: string) => {\n if (pathname) {\n return pathname.split('/')[1] ?? '';\n }\n\n return location.pathname.split('/')[1] ?? '';\n};\n\n/**\n * @description storybook에서 동작을 고려하여 수정한 버전\n * @returns\n */\nexport const getServicePath = () => {\n if (typeof window.isStorybookEnv === 'boolean') {\n return '';\n } else {\n return `/${getBusinessWorkDivisionCode()}`;\n }\n};\n\n/**\n * 환경에 맞는 API 호스트명을 반환합니다.\n * 호스트명을 강제하고 싶으면 두 번째 파라미터로 넘기세요.\n * @param currentHostname\n * @param forceApiHostName\n * @returns\n */\n\nexport const getApiHostNameFromEnvironment = (currentHostname: string, forceApiHostName?: string) => {\n if (forceApiHostName) {\n return forceApiHostName;\n }\n\n const environment = getEnvironmentFromHostname(currentHostname);\n\n switch (environment) {\n case 'dev':\n return `https://nxl-dsp-dev.hanwhalife.com`;\n\n case 'local':\n case 'stg':\n return `https://nxl-dsp-stg.hanwhalife.com`;\n\n case 'prd':\n return `https://nxl-dsp.hanwhalife.com`;\n\n default:\n console.warn('DSP API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * 환경에 맞는 CDN 호스트명을 반환합니다.\n * 호스트명을 강제하고 싶으면 두 번째 파라미터로 넘기세요.\n * @param currentHostname\n * @param forceApiHostName\n * @returns\n */\nexport const getCdnHostNameFromEnvironment = (currentHostname: string, forceApiHostName?: string) => {\n if (!isClient()) {\n return '';\n }\n\n if (forceApiHostName) {\n return forceApiHostName;\n }\n\n const environment = getEnvironmentFromHostname(currentHostname);\n\n switch (environment) {\n case 'dev':\n return `https://dev-dsp-static.hanwhalife.com`;\n\n case 'local':\n case 'stg':\n return `https://stg-dsp-static.hanwhalife.com`;\n\n case 'prd':\n return `https://dsp-static.hanwhalife.com`;\n\n default:\n console.warn('DSP environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 비정형PI 호스트명을 반환합니다.\n * @param serviceCode dea,dis,dcm\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getDudApiBasePathFromEnvironment = (hostname: string, servicePath: string) => {\n const environment = getEnvironmentFromHostname(hostname);\n\n switch (environment) {\n /**\n * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.\n * (cors이슈 해결을 위해 필수)\n */\n case 'local':\n return `${servicePath}/api/dud`;\n /**\n * local 이 아닌 환경에서는 전체주소를 호출합니다.\n */\n case 'dev':\n return `https://dsp-dud-dev.hanwhalife.com:10101/api`;\n\n case 'stg':\n return `https://dsp-dud-stg.hanwhalife.com:10102/api`;\n\n case 'prd':\n return `https://dsp-dud.hanwhalife.com/api`;\n\n default:\n console.warn('DUD API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 Dsp 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param serviceCodeTo dea,dis 같은 api서버명\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getDspApiBasePathFromEnvironment = (serviceCodeTo: string, hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n /**\n * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.\n * (cors이슈 해결을 위해 필수)\n */\n case 'local':\n return `${getServicePath()}/api/${serviceCodeTo}`;\n /**\n * local 이 아닌 환경에서는 전체주소를 호출합니다.\n */\n case 'dev':\n return `https://nxl-dsp-dev.hanwhalife.com/api/${serviceCodeTo}`;\n\n case 'stg':\n return `https://nxl-dsp-stg.hanwhalife.com/api/${serviceCodeTo}`;\n\n case 'prd':\n return `https://nxl-dsp.hanwhalife.com/api/${serviceCodeTo}`;\n\n default:\n console.warn('DSP API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 NLC 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getNlcHostFromEnvironment = (hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n case 'local':\n return `https://nxl-nlc-stg.hanwhalife.com`;\n\n case 'dev':\n return `https://nxl-nlc-dev.hanwhalife.com`;\n\n case 'stg':\n return `https://nxl-nlc-stg.hanwhalife.com`;\n\n case 'prd':\n return `https://nxl-nlc.hanwhalife.com`;\n\n default:\n console.warn('NLC environment is not defined');\n\n return '';\n }\n};\n","import { isClient } from \"./environment-utils\";\n\nexport const getCookie = (name: string): string => {\n if (!isClient()) {\n return '';\n }\n if (typeof document === 'undefined') {\n return '';\n }\n const match = document.cookie.match(new RegExp(`(^|; *)${name}=([^;]*)`));\n\n return match ? decodeURIComponent(match[2] || '') : '';\n};\n\nexport const setCookie = (\n name: string,\n value: string,\n options: {\n expires?: number | Date; // number of days\n path?: string;\n domain?: string;\n secure?: boolean;\n } = {}\n): void => {\n if (!isClient()) {\n return;\n }\n if (typeof document === 'undefined') {\n return;\n }\n\n let cookieString = `${name}=${encodeURIComponent(value)}`;\n\n if (options.expires) {\n let expiresDate: Date;\n if (typeof options.expires === 'number') {\n expiresDate = new Date();\n expiresDate.setDate(expiresDate.getDate() + options.expires);\n } else {\n expiresDate = options.expires;\n }\n cookieString += `; expires=${expiresDate.toUTCString()}`;\n }\n\n cookieString += `; path=${options.path || '/'}`;\n\n if (options.domain) {\n cookieString += `; domain=${options.domain}`;\n }\n\n if (options.secure) {\n cookieString += '; secure';\n }\n\n document.cookie = cookieString;\n};\n\nexport const deleteCookie = (name: string, options: { path?: string; domain?: string } = {}): void => {\n if (!isClient()) {\n return;\n }\n setCookie(name, '', { ...options, expires: -1 });\n};\n","import { getCookie } from \"./utils/cookie-utils\";\n\n//중복코드지만, 패키지 의존성을 피하기위해서 별도로 재작성한 코드들입니다. \nexport const filterNameCookieKey = 'dsp-debug-mode-filter-name';\nexport function isDebugByFilterName(name: string): boolean {\n const filterNames = getCookie(filterNameCookieKey)?.split(',');\n\n return filterNames?.includes(name) || false;\n\n}\n\nexport const isDownloaderFilter = () => isDebugByFilterName('downloader');"]}
package/dist/index.cjs CHANGED
@@ -181,7 +181,7 @@ var getCdnHostNameFromEnvironment = (currentHostname, forceApiHostName) => {
181
181
  case "stg":
182
182
  return `https://stg-dsp-static.hanwhalife.com`;
183
183
  case "prd":
184
- return `https://dsp-static.hanwhalife.com'`;
184
+ return `https://dsp-static.hanwhalife.com`;
185
185
  default:
186
186
  console.warn("DSP environment is not defined");
187
187
  return "";
@@ -881,73 +881,47 @@ function addE2EObject(el, e2e_type) {
881
881
  function hasAstx2() {
882
882
  return !!window.$ASTX2;
883
883
  }
884
- var loadScript = (callback) => {
885
- if (!window.$ASTX2) {
886
- console.log("dynamic load");
884
+ var loadScript = (params) => {
885
+ const { forceLoad, callback } = params || {};
886
+ if (!window.$ASTX2 || forceLoad) {
887
+ console.log("dynamic load : astx2 script");
887
888
  const script = document.createElement("script");
888
889
  script.innerHTML = `
889
890
  ${astx2_min_default}
890
891
  ${astx2_custom_default}
891
892
  `;
892
893
  document.head.appendChild(script);
893
- script.onload = () => {
894
- callback && callback();
895
- };
894
+ script.onload = () => callback?.();
896
895
  }
897
896
  };
898
- var init = ({
899
- initSuccess = () => {
900
- },
901
- initFailure = () => {
902
- },
903
- checkServerSuccess = () => {
904
- },
905
- checkServerFailure = () => {
906
- }
907
- } = {}) => {
908
- window.$ASTX2.init(
909
- () => {
910
- window.$ASTX2.initE2E();
911
- window.$ASTX2.checkServer(
912
- () => {
913
- checkServerSuccess();
914
- },
915
- () => {
916
- checkServerFailure();
917
- console.error(`ASTX.checkServer() onFailure: errno=${window.$ASTX2.getLastError()}`);
897
+ function initASTX2(astx2Init) {
898
+ const { initSuccess, initFailure, checkServerSuccess, checkServerFailure } = astx2Init || {};
899
+ if (window.$ASTX2) {
900
+ window.$ASTX2.init(
901
+ () => {
902
+ window.$ASTX2.initE2E();
903
+ window.$ASTX2.checkServer(
904
+ () => {
905
+ checkServerSuccess?.();
906
+ },
907
+ () => {
908
+ checkServerFailure?.();
909
+ console.error(`ASTX.checkServer() onFailure: errno=${window.$ASTX2.getLastError()}`);
910
+ }
911
+ );
912
+ initSuccess?.();
913
+ },
914
+ () => {
915
+ initFailure?.();
916
+ if (window.$ASTX2.getLastError() === 103) {
917
+ console.error("AhnLab Safe Transaction \uD074\uB77C\uC774\uC5B8\uD2B8\uAC00 \uC124\uCE58\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4.");
918
+ } else {
919
+ console.error(`$ASTX2.init() onFailure: errno=${window.$ASTX2.getLastError()}`);
918
920
  }
919
- );
920
- initSuccess();
921
- },
922
- () => {
923
- initFailure();
924
- if (window.$ASTX2.getLastError() === 103) {
925
- console.error("AhnLab Safe Transaction \uD074\uB77C\uC774\uC5B8\uD2B8\uAC00 \uC124\uCE58\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4.");
926
- } else {
927
- console.error(`$ASTX2.init() onFailure: errno=${window.$ASTX2.getLastError()}`);
928
921
  }
929
- }
930
- );
931
- };
932
- var initASTX2 = ({
933
- initSuccess = () => {
934
- },
935
- initFailure = () => {
936
- },
937
- checkServerSuccess = () => {
938
- },
939
- checkServerFailure = () => {
940
- }
941
- } = {}) => {
942
- if (window.$ASTX2) {
943
- init({
944
- initSuccess,
945
- initFailure,
946
- checkServerSuccess,
947
- checkServerFailure
948
- });
922
+ );
949
923
  }
950
- };
924
+ }
951
925
  function getE2EDataIDs(ids, onSuccess, onFailure = () => {
952
926
  }) {
953
927
  if (window.$ASTX2) {