@jetprint/editor-sdk 1.2.0 → 1.2.1

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.
@@ -0,0 +1,82 @@
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) {
13
+ const {
14
+ baseBitmap: t,
15
+ viewportTransform: e,
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,
27
+ resizeQuality: "medium"
28
+ });
29
+ } else {
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,
47
+ resizeQuality: "medium"
48
+ });
49
+ }
50
+ return { id: s.id, type: "TRANSFORM_BITMAP_RESULT", bitmap: d };
51
+ }
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;
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
+ }
82
+ };
@@ -3,7 +3,7 @@
3
3
  * 此文件由 vite-plugins/serverEncrypt.ts 在构建时自动生成
4
4
  * 请勿手动编辑
5
5
  *
6
- * 生成时间: 2026-06-18T09:51:11.051Z
6
+ * 生成时间: 2026-06-18T13:07:20.222Z
7
7
  * 构建模式: production
8
8
  * 加密模块数量: 13
9
9
  * 构建种子: Kx9mP2qR5s... (已隐藏)
@@ -18,6 +18,17 @@ export declare class UrlUtil {
18
18
  * 检查是否有指定参数
19
19
  */
20
20
  static hasParam(url: string, key: string): boolean;
21
+ /**
22
+ * 已知支持 https 的资源 CDN 域名。http://img.r480.cn 等会绕过 CDN 边缘缓存、打到抽风源站
23
+ * (频繁 503),且在 https 编辑器页里被浏览器当混合内容拦截 → 「图经常获取不到」。
24
+ * 故对这些域名一律强制升级到 https(走稳定的 CDN)。
25
+ */
26
+ private static readonly HTTPS_ASSET_HOST_RE;
27
+ /**
28
+ * 资源 URL 强制 https(仅对 HTTPS_ASSET_HOST_RE 命中的域名)。纯字符串替换协议,
29
+ * 不解析/重编码 query,避免 base64 fileToken 里的 +// = 被破坏。
30
+ */
31
+ static forceHttpsAsset(url: string): string;
21
32
  /**
22
33
  * 格式化 URL(保持原始格式)
23
34
  */
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetprint/editor-sdk",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "scripts": {