lecodes-web-host 2.0.2 → 2.0.3
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.js +16 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1351,11 +1351,24 @@ class Canvas2DPainter {
|
|
|
1351
1351
|
}
|
|
1352
1352
|
drawImage(image, srcRect, dst, opts) {
|
|
1353
1353
|
if (!image.handle) return;
|
|
1354
|
-
const
|
|
1354
|
+
const fit = srcRect ? { src: srcRect, dst } : computeObjectFit(image.naturalWidth, image.naturalHeight, dst, opts.fit);
|
|
1355
|
+
const d = fit.dst;
|
|
1356
|
+
let src = fit.src;
|
|
1355
1357
|
const dw = Math.max(1, Math.ceil(d.width * this.dpr));
|
|
1356
1358
|
const dh = Math.max(1, Math.ceil(d.height * this.dpr));
|
|
1357
|
-
const handle = image.rasterize ? image.rasterize(dw, dh) : image.handle;
|
|
1358
1359
|
const whole = !srcRect && opts.fit !== "cover";
|
|
1360
|
+
let handle = image.handle;
|
|
1361
|
+
if (image.rasterize) {
|
|
1362
|
+
if (whole) handle = image.rasterize(dw, dh);
|
|
1363
|
+
else {
|
|
1364
|
+
const k = Math.max(dw / src.width, dh / src.height);
|
|
1365
|
+
const rw = Math.max(1, Math.ceil(image.naturalWidth * k));
|
|
1366
|
+
const rh = Math.max(1, Math.ceil(image.naturalHeight * k));
|
|
1367
|
+
handle = image.rasterize(rw, rh);
|
|
1368
|
+
const kx = rw / image.naturalWidth, ky = rh / image.naturalHeight;
|
|
1369
|
+
src = { x: src.x * kx, y: src.y * ky, width: src.width * kx, height: src.height * ky };
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1359
1372
|
if (opts.tint === void 0) {
|
|
1360
1373
|
if (whole) this.ctx.drawImage(handle, d.x, d.y, d.width, d.height);
|
|
1361
1374
|
else this.ctx.drawImage(handle, src.x, src.y, src.width, src.height, d.x, d.y, d.width, d.height);
|
|
@@ -3942,7 +3955,7 @@ const loadBootFonts = async (fonts, doc, budgetMs = 2e3) => {
|
|
|
3942
3955
|
}
|
|
3943
3956
|
await Promise.race([Promise.all(loads), new Promise((res) => setTimeout(res, budgetMs))]);
|
|
3944
3957
|
};
|
|
3945
|
-
const SDK_VERSION = "2.0.
|
|
3958
|
+
const SDK_VERSION = "2.0.3";
|
|
3946
3959
|
const sdkMajor = (version) => {
|
|
3947
3960
|
const m = version?.match(/^(\d+)\.\d+\.\d+/);
|
|
3948
3961
|
return m ? Number(m[1]) : null;
|