@jieyin/editor-sdk-test 1.1.209 → 1.1.210
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/editor-sdk.es.js +15692 -15635
- package/dist/renderWorker.js +2105 -2106
- package/dist/style.css +1 -1
- package/dist/zoneScreenshotWorker.js +71 -43
- package/package.json +1 -1
|
@@ -1,54 +1,82 @@
|
|
|
1
|
-
async function
|
|
1
|
+
async function _(s) {
|
|
2
|
+
const { bitmap: t, quality: e } = s, i = new OffscreenCanvas(t.width, t.height), o = i.getContext("2d");
|
|
3
|
+
if (!o) throw new Error("Failed to create OffscreenCanvas 2d context");
|
|
4
|
+
o.drawImage(t, 0, 0);
|
|
5
|
+
try {
|
|
6
|
+
t.close?.();
|
|
7
|
+
} catch {
|
|
8
|
+
}
|
|
9
|
+
const r = await i.convertToBlob({ type: "image/webp", quality: e });
|
|
10
|
+
return { id: s.id, type: "ENCODE_WEBP_RESULT", blob: r };
|
|
11
|
+
}
|
|
12
|
+
async function A(s) {
|
|
2
13
|
const {
|
|
3
|
-
baseBitmap:
|
|
14
|
+
baseBitmap: t,
|
|
4
15
|
viewportTransform: e,
|
|
5
|
-
canvasWidth:
|
|
6
|
-
canvasHeight:
|
|
7
|
-
exportExt:
|
|
8
|
-
multiplier:
|
|
9
|
-
} =
|
|
10
|
-
let
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
resizeWidth:
|
|
15
|
-
resizeHeight:
|
|
16
|
+
canvasWidth: i,
|
|
17
|
+
canvasHeight: o,
|
|
18
|
+
exportExt: r,
|
|
19
|
+
multiplier: c
|
|
20
|
+
} = s, a = e, E = a[0], x = a[4], y = a[5], R = Math.abs(E - 1) < 0.01 && Math.abs(x) < 0.5 && Math.abs(y) < 0.5;
|
|
21
|
+
let d;
|
|
22
|
+
if (R) {
|
|
23
|
+
const h = Math.max(1, Math.round(i * c)), f = Math.max(1, Math.round(o * c));
|
|
24
|
+
d = await createImageBitmap(t, {
|
|
25
|
+
resizeWidth: h,
|
|
26
|
+
resizeHeight: f,
|
|
16
27
|
resizeQuality: "medium"
|
|
17
28
|
});
|
|
18
29
|
} else {
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
const
|
|
22
|
-
if (Math.abs(
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
),
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
resizeWidth:
|
|
35
|
-
resizeHeight:
|
|
30
|
+
const h = Math.max(1, r.width), f = Math.max(1, r.height), u = new OffscreenCanvas(h, f), p = u.getContext("2d");
|
|
31
|
+
if (!p) throw new Error("Failed to create OffscreenCanvas context");
|
|
32
|
+
const w = a[0], g = a[1], v = a[2], M = a[3], l = a[4], b = a[5], n = w * M - g * v;
|
|
33
|
+
if (Math.abs(n) < 1e-9) throw new Error("Singular viewport matrix");
|
|
34
|
+
const B = M / n, T = -g / n, O = -v / n, C = w / n, I = (v * b - M * l) / n, S = (g * l - w * b) / n, m = t.width / i || 1;
|
|
35
|
+
p.setTransform(
|
|
36
|
+
B / m,
|
|
37
|
+
T / m,
|
|
38
|
+
O / m,
|
|
39
|
+
C / m,
|
|
40
|
+
I - r.minL,
|
|
41
|
+
S - r.minT
|
|
42
|
+
), p.drawImage(t, 0, 0);
|
|
43
|
+
const W = Math.max(1, Math.round(h * c)), z = Math.max(1, Math.round(f * c));
|
|
44
|
+
d = await createImageBitmap(u, {
|
|
45
|
+
resizeWidth: W,
|
|
46
|
+
resizeHeight: z,
|
|
36
47
|
resizeQuality: "medium"
|
|
37
48
|
});
|
|
38
49
|
}
|
|
39
|
-
return { id:
|
|
50
|
+
return { id: s.id, type: "TRANSFORM_BITMAP_RESULT", bitmap: d };
|
|
40
51
|
}
|
|
41
|
-
self.onmessage = async (
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
self.onmessage = async (s) => {
|
|
53
|
+
const t = s.data;
|
|
54
|
+
if (t) {
|
|
55
|
+
if (t.type === "TRANSFORM_BITMAP") {
|
|
56
|
+
try {
|
|
57
|
+
const e = await A(t);
|
|
58
|
+
self.postMessage(e, [e.bitmap]);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
self.postMessage({
|
|
61
|
+
id: t.id,
|
|
62
|
+
type: "ERROR",
|
|
63
|
+
error: e instanceof Error ? e.message : String(e)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
53
67
|
}
|
|
68
|
+
if (t.type === "ENCODE_WEBP") {
|
|
69
|
+
try {
|
|
70
|
+
const e = await _(t);
|
|
71
|
+
self.postMessage(e);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
self.postMessage({
|
|
74
|
+
id: t.id,
|
|
75
|
+
type: "ERROR",
|
|
76
|
+
error: e instanceof Error ? e.message : String(e)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
54
82
|
};
|