labellife-design-tool 0.7.0 → 0.8.0

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/lib/index.js CHANGED
@@ -3045,6 +3045,31 @@ var exportToJSON = (design) => {
3045
3045
  document.body.removeChild(link);
3046
3046
  URL.revokeObjectURL(url);
3047
3047
  };
3048
+ var canvasToBlob = (stage, format = "png", options) => {
3049
+ if (!stage) {
3050
+ return Promise.reject(new Error("Stage is required"));
3051
+ }
3052
+ const oldScale = stage.scaleX();
3053
+ stage.scale({ x: 1, y: 1 });
3054
+ const pixelRatio = options?.pixelRatio ?? 2;
3055
+ const quality = options?.quality ?? 0.9;
3056
+ const dataUrl = stage.toDataURL({
3057
+ pixelRatio,
3058
+ mimeType: format === "jpg" ? "image/jpeg" : "image/png",
3059
+ quality: format === "jpg" ? quality : undefined
3060
+ });
3061
+ stage.scale({ x: oldScale, y: oldScale });
3062
+ return new Promise((resolve, reject) => {
3063
+ const byteString = atob(dataUrl.split(",")[1]);
3064
+ const mimeType = format === "jpg" ? "image/jpeg" : "image/png";
3065
+ const arrayBuffer = new ArrayBuffer(byteString.length);
3066
+ const uint8Array = new Uint8Array(arrayBuffer);
3067
+ for (let i = 0;i < byteString.length; i++) {
3068
+ uint8Array[i] = byteString.charCodeAt(i);
3069
+ }
3070
+ resolve(new Blob([arrayBuffer], { type: mimeType }));
3071
+ });
3072
+ };
3048
3073
  var importFromJSON = (event, onLoad, onError, onInputsRequired) => {
3049
3074
  const file = event.target.files?.[0];
3050
3075
  if (file) {
@@ -4380,6 +4405,7 @@ export {
4380
4405
  exportToJSON,
4381
4406
  exportToJPG,
4382
4407
  convertTemplateToCanvasDesign,
4408
+ canvasToBlob,
4383
4409
  UrlImageElement,
4384
4410
  ShapeElement,
4385
4411
  FONT_FAMILIES,
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export { default as CanvasEditor } from '../CanvasEditor';
6
6
  export * from '../types';
7
- export { exportToPNG, exportToJPG, exportToJSON, importFromJSON, findRequiredInputs, replaceUserInputs, convertTemplateToCanvasDesign, } from '../utils/exportImportUtils';
7
+ export { exportToPNG, exportToJPG, exportToJSON, importFromJSON, findRequiredInputs, replaceUserInputs, convertTemplateToCanvasDesign, canvasToBlob, } from '../utils/exportImportUtils';
8
8
  export * from '../elements';
9
9
  export { FONT_FAMILIES, DEFAULT_COLORS, CANVAS_PRESETS } from '../constants';
10
10
  export { setUnsplashAccessKey, getUnsplashAccessKey } from '../config';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG1D,cAAc,UAAU,CAAC;AAGzB,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,6BAA6B,GAC9B,MAAM,4BAA4B,CAAC;AAGpC,cAAc,aAAa,CAAC;AAG5B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG7E,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG1D,cAAc,UAAU,CAAC;AAGzB,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,6BAA6B,EAC7B,YAAY,GACb,MAAM,4BAA4B,CAAC;AAGpC,cAAc,aAAa,CAAC;AAG5B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG7E,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "labellife-design-tool",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Professional canvas editor built with React, TypeScript, and Konva",
5
5
  "main": "./dist/lib/index.js",
6
6
  "module": "./dist/lib/index.js",