@algorisys/yappydraw 0.8.253
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/LICENSE +661 -0
- package/README.md +45 -0
- package/chunks/AllPackages-DNX4gUvL.js +6879 -0
- package/chunks/BaseConfiguration-iE_YypNt.js +4401 -0
- package/chunks/Entities-XwxJEcR3.js +467 -0
- package/chunks/Factory--zguTNZ7.js +2768 -0
- package/chunks/InputJax-BYq2tqUz.js +42 -0
- package/chunks/MathItem-DD5NNBjZ.js +76 -0
- package/chunks/Options-BStFr0zv.js +199 -0
- package/chunks/PrioritizedList-TjDg4i-s.js +39 -0
- package/chunks/Styles-DdTYCumM.js +397 -0
- package/chunks/TeXAtom-Bp5xoo7F.js +2175 -0
- package/chunks/ai-providers-CycU8sO1.js +229 -0
- package/chunks/canva-ai-BREIRXSl.js +285 -0
- package/chunks/design-generator-C89SKTqv.js +149 -0
- package/chunks/drawing-engine-DLFI-cNg.js +903 -0
- package/chunks/drawings-store-C-PoHakg.js +109 -0
- package/chunks/ds-operations-D5B9Z5vO.js +253 -0
- package/chunks/export-game-DOlM1w0F.js +104 -0
- package/chunks/game-runtime-Hn9umSvi.js +346 -0
- package/chunks/gifenc.esm-48qFK9lH.js +278 -0
- package/chunks/html-DxnOvKy4.js +1694 -0
- package/chunks/image-utils-CJQBaGoQ.js +37 -0
- package/chunks/index-Bm3Inzn8.js +62744 -0
- package/chunks/lengths-DNFHULBn.js +70 -0
- package/chunks/liteAdaptor-BZby1Qz2.js +919 -0
- package/chunks/lucide-solid-D_6t_rbY.js +35452 -0
- package/chunks/markdown-to-slides-_1GIcD8M.js +96 -0
- package/chunks/mathjax-CnUrFnFS.js +117 -0
- package/chunks/mathjax-D6cR72fZ.js +26 -0
- package/chunks/morph-animator-7qX2s9j_.js +25 -0
- package/chunks/onboarding-tour-CthiVc3W.js +192 -0
- package/chunks/rocket-settings-CU8w9S9I.js +100 -0
- package/chunks/search-CnWoMV6A.js +384 -0
- package/chunks/slide-generator-BG0Oacui.js +553 -0
- package/chunks/svg-BvVc02XL.js +12498 -0
- package/chunks/tex-Cfi4Kfun.js +442 -0
- package/chunks/tinyfly-engine-Wfa50sVI.js +1804 -0
- package/chunks/turntable-ai-Bfq-oSsD.js +120 -0
- package/chunks/yappy-NspTXSPk.css +1 -0
- package/package.json +21 -0
- package/yappy.d.ts +34 -0
- package/yappy.js +9 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
async function w(n, a = 2048) {
|
|
2
|
+
const t = await u(n), e = await h(t);
|
|
3
|
+
let r = s(e, a);
|
|
4
|
+
return r.base64.length > 4194304 && a > 1024 && (r = s(e, 1024)), r;
|
|
5
|
+
}
|
|
6
|
+
function l(n) {
|
|
7
|
+
const a = n.match(/^data:([^;]+);base64,(.+)$/);
|
|
8
|
+
if (!a) throw new Error("Invalid data URL");
|
|
9
|
+
return { mediaType: a[1], base64: a[2] };
|
|
10
|
+
}
|
|
11
|
+
function u(n) {
|
|
12
|
+
return new Promise((a, t) => {
|
|
13
|
+
const e = new FileReader();
|
|
14
|
+
e.onload = () => a(e.result), e.onerror = () => t(new Error("Failed to read image file")), e.readAsDataURL(n);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function h(n) {
|
|
18
|
+
return new Promise((a, t) => {
|
|
19
|
+
const e = new Image();
|
|
20
|
+
e.onload = () => a(e), e.onerror = () => t(new Error("Failed to load image")), e.src = n;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function s(n, a) {
|
|
24
|
+
let { naturalWidth: t, naturalHeight: e } = n;
|
|
25
|
+
if (t > a || e > a) {
|
|
26
|
+
const o = a / Math.max(t, e);
|
|
27
|
+
t = Math.round(t * o), e = Math.round(e * o);
|
|
28
|
+
}
|
|
29
|
+
const r = document.createElement("canvas");
|
|
30
|
+
r.width = t, r.height = e, r.getContext("2d").drawImage(n, 0, 0, t, e);
|
|
31
|
+
const i = r.toDataURL("image/jpeg", 0.85), { base64: c, mediaType: d } = l(i);
|
|
32
|
+
return { base64: c, mediaType: d, width: t, height: e };
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
w as a,
|
|
36
|
+
l as p
|
|
37
|
+
};
|