@pirireis/webglobeplugins 1.5.3 → 1.5.4
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/package.json
CHANGED
|
@@ -70,7 +70,6 @@ export class IconFactory {
|
|
|
70
70
|
if (!(combinationsMap instanceof Map)) {
|
|
71
71
|
throw new Error('combinationsMap must be a Map instance.');
|
|
72
72
|
}
|
|
73
|
-
console.log("combinationMap", combinationsMap);
|
|
74
73
|
if (combinationsMap !== this.combinationMap) {
|
|
75
74
|
this.combinationMap = combinationsMap;
|
|
76
75
|
const baseSize = this.printer.baseSize;
|
|
@@ -56,8 +56,7 @@ export class PngBlobMapPart {
|
|
|
56
56
|
img.onload = () => resolve(img);
|
|
57
57
|
img.onerror = () => {
|
|
58
58
|
this.imageCache.delete(src);
|
|
59
|
-
|
|
60
|
-
reject(new Error(`Failed to load base64 image for src: ${src.slice(0, 64)}...`));
|
|
59
|
+
reject(new Error(`Failed to load base64 image`));
|
|
61
60
|
};
|
|
62
61
|
img.src = src;
|
|
63
62
|
});
|
|
@@ -70,11 +69,26 @@ export class PngBlobMapPart {
|
|
|
70
69
|
}
|
|
71
70
|
async printPart(partInput, targetCanvas, partDestination) {
|
|
72
71
|
const source = this.getBase64Source(partInput);
|
|
73
|
-
const img = await this.loadImage(source);
|
|
74
72
|
const ctx = targetCanvas.getContext("2d");
|
|
75
73
|
if (!ctx) {
|
|
76
74
|
throw new Error("Failed to get 2D context from target canvas.");
|
|
77
75
|
}
|
|
76
|
+
let img;
|
|
77
|
+
try {
|
|
78
|
+
img = await this.loadImage(source);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// draw Red Pixels to indicate broken image
|
|
82
|
+
ctx.fillStyle = "red";
|
|
83
|
+
ctx.fillRect(partDestination.x, partDestination.y, partDestination.width, partDestination.height);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (img.naturalWidth === 0 || img.naturalHeight === 0) {
|
|
87
|
+
// draw Red Pixels to indicate broken image
|
|
88
|
+
ctx.fillStyle = "red";
|
|
89
|
+
ctx.fillRect(partDestination.x, partDestination.y, partDestination.width, partDestination.height);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
78
92
|
const { x, y, width, height } = partDestination;
|
|
79
93
|
ctx.drawImage(img, 0, 0, img.width, img.height, x, y, width, height);
|
|
80
94
|
}
|
|
@@ -35,11 +35,26 @@ export class UrlImagePart {
|
|
|
35
35
|
}
|
|
36
36
|
async printPart(partInput, targetCanvas, partDestination) {
|
|
37
37
|
const url = this.getUrl(partInput);
|
|
38
|
-
const img = await this.loadImage(url);
|
|
39
38
|
const ctx = targetCanvas.getContext('2d');
|
|
40
39
|
if (!ctx) {
|
|
41
40
|
throw new Error('Failed to get 2D context from target canvas.');
|
|
42
41
|
}
|
|
42
|
+
let img;
|
|
43
|
+
try {
|
|
44
|
+
img = await this.loadImage(url);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// draw Red Pixels to indicate broken image
|
|
48
|
+
ctx.fillStyle = "red";
|
|
49
|
+
ctx.fillRect(partDestination.x, partDestination.y, partDestination.width, partDestination.height);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (img.naturalWidth === 0 || img.naturalHeight === 0) {
|
|
53
|
+
// draw Red Pixels to indicate broken image
|
|
54
|
+
ctx.fillStyle = "red";
|
|
55
|
+
ctx.fillRect(partDestination.x, partDestination.y, partDestination.width, partDestination.height);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
43
58
|
const { x, y, width, height } = partDestination;
|
|
44
59
|
ctx.drawImage(img, 0, 0, img.width, img.height, // Source rectangle (entire image)
|
|
45
60
|
x, y, // Destination start point on the target canvas
|