@pixldocs/canvas-renderer 0.5.97 → 0.5.98
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.cjs +34 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +34 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -256,7 +256,7 @@ export declare function normalizeFontFamily(fontStack: string): string;
|
|
|
256
256
|
* Package version banner. Bump alongside package.json so we can confirm
|
|
257
257
|
* (via browser:log) that the deployed bundle matches the expected build.
|
|
258
258
|
*/
|
|
259
|
-
export declare const PACKAGE_VERSION = "0.5.
|
|
259
|
+
export declare const PACKAGE_VERSION = "0.5.98";
|
|
260
260
|
|
|
261
261
|
export declare interface PageSettings {
|
|
262
262
|
backgroundColor?: string;
|
package/dist/index.js
CHANGED
|
@@ -13084,7 +13084,7 @@ function PixldocsPreview(props) {
|
|
|
13084
13084
|
!canvasSettled && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
|
|
13085
13085
|
] });
|
|
13086
13086
|
}
|
|
13087
|
-
const PACKAGE_VERSION = "0.5.
|
|
13087
|
+
const PACKAGE_VERSION = "0.5.98";
|
|
13088
13088
|
const roundParityValue = (value) => {
|
|
13089
13089
|
if (typeof value !== "number") return value;
|
|
13090
13090
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -14045,6 +14045,7 @@ class PixldocsRenderer {
|
|
|
14045
14045
|
this.logFabricTextParitySnapshot("after-stable-text-metrics", fabricInstance);
|
|
14046
14046
|
}
|
|
14047
14047
|
}
|
|
14048
|
+
const __vite_import_meta_env__ = {};
|
|
14048
14049
|
const FONT_WEIGHT_LABELS = {
|
|
14049
14050
|
300: "Light",
|
|
14050
14051
|
400: "Regular",
|
|
@@ -14671,10 +14672,36 @@ function bytesToBase64(bytes) {
|
|
|
14671
14672
|
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
14672
14673
|
return btoa(binary);
|
|
14673
14674
|
}
|
|
14675
|
+
function getFontProxyUrl() {
|
|
14676
|
+
var _a;
|
|
14677
|
+
const viteUrl = (__vite_import_meta_env__ == null ? void 0 : __vite_import_meta_env__.VITE_SUPABASE_URL) || "";
|
|
14678
|
+
const runtimeUrl = typeof globalThis !== "undefined" ? ((_a = globalThis.__CONFIG__) == null ? void 0 : _a.supabaseUrl) || globalThis.__PIXLDOCS_SUPABASE_URL || "" : "";
|
|
14679
|
+
const baseUrl = (viteUrl || runtimeUrl || "").replace(/\/$/, "");
|
|
14680
|
+
return baseUrl ? `${baseUrl}/functions/v1/font-proxy` : null;
|
|
14681
|
+
}
|
|
14682
|
+
async function fetchTtfViaProxy(family, weight, isItalic, source) {
|
|
14683
|
+
const proxyUrl = getFontProxyUrl();
|
|
14684
|
+
if (!proxyUrl) return null;
|
|
14685
|
+
try {
|
|
14686
|
+
const url = `${proxyUrl}?family=${encodeURIComponent(family)}&weight=${weight}&italic=${isItalic ? 1 : 0}&source=${source}`;
|
|
14687
|
+
const res = await fetch(url);
|
|
14688
|
+
if (!res.ok) return null;
|
|
14689
|
+
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
14690
|
+
return isJsPdfEmbeddableTrueType(bytes) ? bytes : null;
|
|
14691
|
+
} catch {
|
|
14692
|
+
return null;
|
|
14693
|
+
}
|
|
14694
|
+
}
|
|
14674
14695
|
async function fetchGoogleFontTTF(fontFamily, weight, isItalic = false) {
|
|
14675
14696
|
const cacheKey = `gf:${fontFamily}:${weight}:${isItalic ? "i" : "n"}`;
|
|
14676
14697
|
if (ttfCache.has(cacheKey)) return ttfCache.get(cacheKey);
|
|
14677
14698
|
if (googleFontNotFound.has(fontFamily)) return null;
|
|
14699
|
+
const proxyBytes = await fetchTtfViaProxy(fontFamily, weight, isItalic, "google");
|
|
14700
|
+
if (proxyBytes) {
|
|
14701
|
+
const b64 = bytesToBase64(proxyBytes);
|
|
14702
|
+
ttfCache.set(cacheKey, b64);
|
|
14703
|
+
return b64;
|
|
14704
|
+
}
|
|
14678
14705
|
try {
|
|
14679
14706
|
const ital = isItalic ? "1" : "0";
|
|
14680
14707
|
const cssUrl = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
@@ -14714,6 +14741,12 @@ async function fetchFontshareTTF(fontFamily, weight, isItalic = false) {
|
|
|
14714
14741
|
if (ttfCache.has(cacheKey)) return ttfCache.get(cacheKey);
|
|
14715
14742
|
if (fontshareNotFound.has(fontFamily)) return null;
|
|
14716
14743
|
const slug = fontFamily.trim().toLowerCase().replace(/\s+/g, "-");
|
|
14744
|
+
const proxyBytes = await fetchTtfViaProxy(fontFamily, weight, isItalic, "fontshare");
|
|
14745
|
+
if (proxyBytes) {
|
|
14746
|
+
const b64 = bytesToBase64(proxyBytes);
|
|
14747
|
+
ttfCache.set(cacheKey, b64);
|
|
14748
|
+
return b64;
|
|
14749
|
+
}
|
|
14717
14750
|
try {
|
|
14718
14751
|
const styleSuffix = isItalic ? "i" : "";
|
|
14719
14752
|
const cssUrl = `https://api.fontshare.com/v2/css?f[]=${slug}@${weight}${styleSuffix}&display=swap`;
|