sales-frontend-utils 0.0.19 → 0.0.20
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 +32 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -233,6 +233,10 @@ interface ConvertTextToImgParams {
|
|
|
233
233
|
* @returns Base64로 인코딩된 이미지 데이터 URL
|
|
234
234
|
*/
|
|
235
235
|
declare const convertTextToImg: ({ targetStr, canvasWidth, canvasHeight, backgroundColor, fontColor, fontSize, fontWeight }: ConvertTextToImgParams) => string;
|
|
236
|
+
declare function drawImageResizeCentered(base64: string, size: {
|
|
237
|
+
canvasWidth: number;
|
|
238
|
+
canvasHeight: number;
|
|
239
|
+
}): Promise<unknown>;
|
|
236
240
|
|
|
237
241
|
declare const getCookie: (name: string) => string;
|
|
238
242
|
declare const setCookie: (name: string, value: string, options?: {
|
|
@@ -283,4 +287,4 @@ declare const initASTX2: ({ initSuccess, initFailure, checkServerSuccess, checkS
|
|
|
283
287
|
*/
|
|
284
288
|
declare function getE2EDataIDs(ids: string[], onSuccess: (astx_data: any) => void, onFailure?: () => void): void;
|
|
285
289
|
|
|
286
|
-
export { type BrowserName, type ExecutionEnvironment, MessageEventManager, type OSName, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspExecutionEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getOSName, getOSVersion, getOrCreateDeviceId, getSubdomain, hasAstx2, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isSalesPortal, isStorybookEnv, isTablet, isWebView, loadScript, setCookie, throttle };
|
|
290
|
+
export { type BrowserName, type ExecutionEnvironment, MessageEventManager, type OSName, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspExecutionEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getOSName, getOSVersion, getOrCreateDeviceId, getSubdomain, hasAstx2, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isSalesPortal, isStorybookEnv, isTablet, isWebView, loadScript, setCookie, throttle };
|
package/dist/index.d.ts
CHANGED
|
@@ -233,6 +233,10 @@ interface ConvertTextToImgParams {
|
|
|
233
233
|
* @returns Base64로 인코딩된 이미지 데이터 URL
|
|
234
234
|
*/
|
|
235
235
|
declare const convertTextToImg: ({ targetStr, canvasWidth, canvasHeight, backgroundColor, fontColor, fontSize, fontWeight }: ConvertTextToImgParams) => string;
|
|
236
|
+
declare function drawImageResizeCentered(base64: string, size: {
|
|
237
|
+
canvasWidth: number;
|
|
238
|
+
canvasHeight: number;
|
|
239
|
+
}): Promise<unknown>;
|
|
236
240
|
|
|
237
241
|
declare const getCookie: (name: string) => string;
|
|
238
242
|
declare const setCookie: (name: string, value: string, options?: {
|
|
@@ -283,4 +287,4 @@ declare const initASTX2: ({ initSuccess, initFailure, checkServerSuccess, checkS
|
|
|
283
287
|
*/
|
|
284
288
|
declare function getE2EDataIDs(ids: string[], onSuccess: (astx_data: any) => void, onFailure?: () => void): void;
|
|
285
289
|
|
|
286
|
-
export { type BrowserName, type ExecutionEnvironment, MessageEventManager, type OSName, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspExecutionEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getOSName, getOSVersion, getOrCreateDeviceId, getSubdomain, hasAstx2, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isSalesPortal, isStorybookEnv, isTablet, isWebView, loadScript, setCookie, throttle };
|
|
290
|
+
export { type BrowserName, type ExecutionEnvironment, MessageEventManager, type OSName, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspExecutionEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getOSName, getOSVersion, getOrCreateDeviceId, getSubdomain, hasAstx2, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isSalesPortal, isStorybookEnv, isTablet, isWebView, loadScript, setCookie, throttle };
|
package/dist/index.js
CHANGED
|
@@ -471,6 +471,37 @@ var convertTextToImg = ({
|
|
|
471
471
|
ctx.fillText(targetStr, canvas.width / 2, canvas.height / 2);
|
|
472
472
|
return canvas.toDataURL();
|
|
473
473
|
};
|
|
474
|
+
function drawImageResizeCentered(base64, size) {
|
|
475
|
+
return new Promise((resolve) => {
|
|
476
|
+
const { canvasHeight, canvasWidth } = size;
|
|
477
|
+
const canvas = document.createElement("canvas");
|
|
478
|
+
canvas.width = canvasWidth;
|
|
479
|
+
canvas.height = canvasHeight;
|
|
480
|
+
const ctx = canvas.getContext("2d");
|
|
481
|
+
const img = new Image();
|
|
482
|
+
img.src = base64;
|
|
483
|
+
img.onload = () => {
|
|
484
|
+
const imageWidth = img.width;
|
|
485
|
+
const imageHeight = img.height;
|
|
486
|
+
const canvasRatio = canvasWidth / canvasHeight;
|
|
487
|
+
const imageRatio = imageWidth / imageHeight;
|
|
488
|
+
let newWidth;
|
|
489
|
+
let newHeight;
|
|
490
|
+
if (imageRatio > canvasRatio) {
|
|
491
|
+
newWidth = canvasWidth;
|
|
492
|
+
newHeight = newWidth / imageRatio;
|
|
493
|
+
} else {
|
|
494
|
+
newHeight = canvasHeight;
|
|
495
|
+
newWidth = newHeight * imageRatio;
|
|
496
|
+
}
|
|
497
|
+
const x = (canvasWidth - newWidth) / 2;
|
|
498
|
+
const y = (canvasHeight - newHeight) / 2;
|
|
499
|
+
ctx?.clearRect(0, 0, canvasWidth, canvasHeight);
|
|
500
|
+
ctx?.drawImage(img, x, y, newWidth, newHeight);
|
|
501
|
+
resolve(canvas.toDataURL());
|
|
502
|
+
};
|
|
503
|
+
});
|
|
504
|
+
}
|
|
474
505
|
|
|
475
506
|
// src/utils/cookie-utils.ts
|
|
476
507
|
var getCookie = (name) => {
|
|
@@ -664,6 +695,6 @@ function getE2EDataIDs(ids, onSuccess, onFailure = () => {
|
|
|
664
695
|
}
|
|
665
696
|
}
|
|
666
697
|
|
|
667
|
-
export { MessageEventManager, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspExecutionEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getOSName, getOSVersion, getOrCreateDeviceId, getSubdomain, hasAstx2, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isSalesPortal, isStorybookEnv, isTablet, isWebView, loadScript, setCookie, throttle };
|
|
698
|
+
export { MessageEventManager, addE2EObject, base64ToBlob, base64ToFile, blobToFile, checkUserAgentDspApp, convertTextToImg, debounce, deleteCookie, drawImageResizeCentered, fileToBase64, getApiHostNameFromEnvironment, getBrowserName, getBrowserVersion, getCdnHostNameFromEnvironment, getCookie, getCurrentBrowserName, getCurrentBrowserVersion, getCurrentOSName, getCurrentOSVersion, getDeviceModel, getDspExecutionEnvironment, getE2EDataIDs, getEnvironmentFromHostname, getExt, getFormFactorFromUserAgent, getOSName, getOSVersion, getOrCreateDeviceId, getSubdomain, hasAstx2, initASTX2, isClient, isDspApp, isFpPlannerApp, isPc, isPhone, isSalesPortal, isStorybookEnv, isTablet, isWebView, loadScript, setCookie, throttle };
|
|
668
699
|
//# sourceMappingURL=index.js.map
|
|
669
700
|
//# sourceMappingURL=index.js.map
|