@pixldocs/canvas-renderer 0.5.92 → 0.5.94
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 +90 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +90 -60
- package/dist/index.js.map +1 -1
- package/dist/{svgTextToPath-B4SihUQv.cjs → svgTextToPath-CWlhIf-q.cjs} +88 -3
- package/dist/svgTextToPath-CWlhIf-q.cjs.map +1 -0
- package/dist/{svgTextToPath-BmOzWJsV.js → svgTextToPath-CpWdqc8K.js} +88 -3
- package/dist/svgTextToPath-CpWdqc8K.js.map +1 -0
- package/package.json +1 -1
- package/dist/svgTextToPath-B4SihUQv.cjs.map +0 -1
- package/dist/svgTextToPath-BmOzWJsV.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -2612,10 +2612,10 @@ async function loadGoogleFont(fontFamily, weights) {
|
|
|
2612
2612
|
if (LOCAL_FONTS.has(fontFamily)) return true;
|
|
2613
2613
|
if (loadedGoogleFonts.has(fontFamily)) return true;
|
|
2614
2614
|
if (failedGoogleFonts.has(fontFamily)) return false;
|
|
2615
|
-
const existing = loadingPromises$1.get(fontFamily);
|
|
2615
|
+
const existing = loadingPromises$1.get(`google:${fontFamily}`);
|
|
2616
2616
|
if (existing) return existing;
|
|
2617
|
-
const promise = _doLoadGoogleFont(fontFamily
|
|
2618
|
-
loadingPromises$1.set(fontFamily
|
|
2617
|
+
const promise = _doLoadGoogleFont(fontFamily);
|
|
2618
|
+
loadingPromises$1.set(`google:${fontFamily}`, promise);
|
|
2619
2619
|
try {
|
|
2620
2620
|
const result = await promise;
|
|
2621
2621
|
if (result) {
|
|
@@ -2625,38 +2625,46 @@ async function loadGoogleFont(fontFamily, weights) {
|
|
|
2625
2625
|
}
|
|
2626
2626
|
return result;
|
|
2627
2627
|
} finally {
|
|
2628
|
-
loadingPromises$1.delete(fontFamily);
|
|
2628
|
+
loadingPromises$1.delete(`google:${fontFamily}`);
|
|
2629
2629
|
}
|
|
2630
2630
|
}
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
const encodedFamily = encodeURIComponent(fontFamily);
|
|
2635
|
-
const url = `https://fonts.googleapis.com/css2?family=${encodedFamily}:ital,wght@0,${weightStr};1,${weightStr}&display=swap`;
|
|
2636
|
-
const existingLink = document.querySelector(`link[href="${url}"]`);
|
|
2637
|
-
if (existingLink) return true;
|
|
2631
|
+
function tryInjectGoogleFontsLink(url, fontFamily) {
|
|
2632
|
+
if (document.querySelector(`link[href="${url}"]`)) return Promise.resolve(true);
|
|
2633
|
+
return new Promise((resolve) => {
|
|
2638
2634
|
const link = document.createElement("link");
|
|
2639
2635
|
link.rel = "stylesheet";
|
|
2640
2636
|
link.href = url;
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2637
|
+
link.onload = async () => {
|
|
2638
|
+
try {
|
|
2639
|
+
await document.fonts.load(`16px "${fontFamily}"`);
|
|
2640
|
+
} catch {
|
|
2641
|
+
}
|
|
2642
|
+
resolve(true);
|
|
2643
|
+
};
|
|
2644
|
+
link.onerror = () => resolve(false);
|
|
2645
|
+
document.head.appendChild(link);
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
async function _doLoadGoogleFont(fontFamily, weights) {
|
|
2649
|
+
const encodedFamily = encodeURIComponent(fontFamily);
|
|
2650
|
+
const weightSet = [300, 400, 500, 600, 700];
|
|
2651
|
+
const fullWeightStr = weightSet.join(";");
|
|
2652
|
+
const coreWeightStr = "400;700";
|
|
2653
|
+
const candidates = [
|
|
2654
|
+
`https://fonts.googleapis.com/css2?family=${encodedFamily}:ital,wght@0,${fullWeightStr};1,${fullWeightStr}&display=swap`,
|
|
2655
|
+
`https://fonts.googleapis.com/css2?family=${encodedFamily}:wght@${fullWeightStr}&display=swap`,
|
|
2656
|
+
`https://fonts.googleapis.com/css2?family=${encodedFamily}:ital,wght@0,${coreWeightStr};1,${coreWeightStr}&display=swap`,
|
|
2657
|
+
`https://fonts.googleapis.com/css2?family=${encodedFamily}:wght@${coreWeightStr}&display=swap`,
|
|
2658
|
+
// Plainest possible URL — works for any published Google Font, even
|
|
2659
|
+
// single-weight display/script families like "Frijole" or "Creepster".
|
|
2660
|
+
`https://fonts.googleapis.com/css2?family=${encodedFamily}&display=swap`
|
|
2661
|
+
];
|
|
2662
|
+
for (const url of candidates) {
|
|
2663
|
+
const ok = await tryInjectGoogleFontsLink(url, fontFamily);
|
|
2664
|
+
if (ok) return true;
|
|
2659
2665
|
}
|
|
2666
|
+
console.warn(`[GoogleFonts] Failed to load: ${fontFamily}`);
|
|
2667
|
+
return false;
|
|
2660
2668
|
}
|
|
2661
2669
|
const getObjectId = (obj) => obj.__docuforgeId;
|
|
2662
2670
|
const setObjectData = (obj, id) => {
|
|
@@ -5563,7 +5571,7 @@ function createText(element) {
|
|
|
5563
5571
|
}
|
|
5564
5572
|
text = result;
|
|
5565
5573
|
}
|
|
5566
|
-
const targetWidth =
|
|
5574
|
+
const targetWidth = fixedWidth;
|
|
5567
5575
|
const targetScaleX = element.scaleX ?? 1;
|
|
5568
5576
|
const targetScaleY = element.scaleY ?? 1;
|
|
5569
5577
|
const textbox = new fabric__namespace.Textbox(text, {
|
|
@@ -11999,6 +12007,38 @@ function applyContentBoundsPagination(config) {
|
|
|
11999
12007
|
if (!mutated) return config;
|
|
12000
12008
|
return { ...config, pages: resultPages };
|
|
12001
12009
|
}
|
|
12010
|
+
const FONTSHARE_SLUGS = {
|
|
12011
|
+
"Satoshi": "satoshi",
|
|
12012
|
+
"Cabinet Grotesk": "cabinet-grotesk",
|
|
12013
|
+
"Clash Display": "clash-display",
|
|
12014
|
+
"Clash Grotesk": "clash-grotesk",
|
|
12015
|
+
"General Sans": "general-sans",
|
|
12016
|
+
"Switzer": "switzer",
|
|
12017
|
+
"Supreme": "supreme",
|
|
12018
|
+
"Author": "author",
|
|
12019
|
+
"Boska": "boska",
|
|
12020
|
+
"Excon": "excon",
|
|
12021
|
+
"Khand": "khand",
|
|
12022
|
+
"Sentient": "sentient",
|
|
12023
|
+
"Synonym": "synonym",
|
|
12024
|
+
"Erode": "erode",
|
|
12025
|
+
"Ranade": "ranade",
|
|
12026
|
+
"Tanker": "tanker",
|
|
12027
|
+
"Zodiak": "zodiak",
|
|
12028
|
+
"Gambarino": "gambarino",
|
|
12029
|
+
"Melodrama": "melodrama",
|
|
12030
|
+
"Bespoke Serif": "bespoke-serif",
|
|
12031
|
+
"Bespoke Stencil": "bespoke-stencil",
|
|
12032
|
+
"Panchang": "panchang",
|
|
12033
|
+
"Quincy CF": "quincy-cf",
|
|
12034
|
+
"Pally": "pally",
|
|
12035
|
+
"Tabular": "tabular",
|
|
12036
|
+
"Sharpie": "sharpie",
|
|
12037
|
+
"Stardom": "stardom",
|
|
12038
|
+
"Rebond Grotesque": "rebond-grotesque",
|
|
12039
|
+
"Telma": "telma",
|
|
12040
|
+
"Nippo": "nippo"
|
|
12041
|
+
};
|
|
12002
12042
|
function normalizeFontFamily(fontStack) {
|
|
12003
12043
|
const first = fontStack.split(",")[0].trim();
|
|
12004
12044
|
return first.replace(/^['"]|['"]$/g, "");
|
|
@@ -12025,6 +12065,20 @@ async function loadGoogleFontCSS(rawFontFamily) {
|
|
|
12025
12065
|
if (existing) return existing;
|
|
12026
12066
|
const promise = (async () => {
|
|
12027
12067
|
try {
|
|
12068
|
+
const fontshareSlug = FONTSHARE_SLUGS[fontFamily];
|
|
12069
|
+
if (fontshareSlug) {
|
|
12070
|
+
const url2 = `https://api.fontshare.com/v2/css?f[]=${fontshareSlug}@300,400,500,700&display=swap`;
|
|
12071
|
+
const link2 = document.createElement("link");
|
|
12072
|
+
link2.rel = "stylesheet";
|
|
12073
|
+
link2.href = url2;
|
|
12074
|
+
await new Promise((resolve, reject) => {
|
|
12075
|
+
link2.onload = () => resolve();
|
|
12076
|
+
link2.onerror = () => reject(new Error(`Failed to load Fontshare font: ${fontFamily}`));
|
|
12077
|
+
document.head.appendChild(link2);
|
|
12078
|
+
});
|
|
12079
|
+
loadedFonts.add(fontFamily);
|
|
12080
|
+
return;
|
|
12081
|
+
}
|
|
12028
12082
|
const encoded = encodeURIComponent(fontFamily);
|
|
12029
12083
|
const url = `https://fonts.googleapis.com/css?family=${encoded}:300,400,500,600,700&display=swap`;
|
|
12030
12084
|
const link = document.createElement("link");
|
|
@@ -12179,6 +12233,7 @@ async function awaitFontsForConfig(config, maxWaitMs) {
|
|
|
12179
12233
|
await ensureFontsForResolvedConfig(config);
|
|
12180
12234
|
const descriptors = collectFontDescriptorsFromConfig(config);
|
|
12181
12235
|
if (descriptors.length === 0) return;
|
|
12236
|
+
const overallBudget = Math.max(maxWaitMs, 5e3);
|
|
12182
12237
|
const loads = Promise.all(
|
|
12183
12238
|
descriptors.map((d) => {
|
|
12184
12239
|
const stylePrefix = d.style === "italic" ? "italic " : "";
|
|
@@ -12188,11 +12243,11 @@ async function awaitFontsForConfig(config, maxWaitMs) {
|
|
|
12188
12243
|
).then(() => void 0);
|
|
12189
12244
|
await Promise.race([
|
|
12190
12245
|
loads,
|
|
12191
|
-
new Promise((resolve) => setTimeout(resolve,
|
|
12246
|
+
new Promise((resolve) => setTimeout(resolve, overallBudget))
|
|
12192
12247
|
]);
|
|
12193
12248
|
await Promise.race([
|
|
12194
12249
|
document.fonts.ready.catch(() => void 0).then(() => void 0),
|
|
12195
|
-
new Promise((r) => setTimeout(r,
|
|
12250
|
+
new Promise((r) => setTimeout(r, 1500))
|
|
12196
12251
|
]);
|
|
12197
12252
|
const checkSpecs = [];
|
|
12198
12253
|
for (const d of descriptors) {
|
|
@@ -12200,7 +12255,7 @@ async function awaitFontsForConfig(config, maxWaitMs) {
|
|
|
12200
12255
|
checkSpecs.push(`${stylePrefix}${d.weight} 16px "${d.family}"`);
|
|
12201
12256
|
}
|
|
12202
12257
|
const startedAt = Date.now();
|
|
12203
|
-
const pollBudget =
|
|
12258
|
+
const pollBudget = 2500;
|
|
12204
12259
|
const allReady = () => {
|
|
12205
12260
|
for (const spec of checkSpecs) {
|
|
12206
12261
|
try {
|
|
@@ -12264,44 +12319,19 @@ function extractSectionStateCandidate(values, sections) {
|
|
|
12264
12319
|
const looksLikeSectionState = Object.keys(raw).some((key) => sectionIds.has(key) || key.startsWith("section_"));
|
|
12265
12320
|
return looksLikeSectionState ? raw : null;
|
|
12266
12321
|
}
|
|
12267
|
-
function entryIdentityTokens(entry, section) {
|
|
12268
|
-
const entryNameKey = section == null ? void 0 : section.entryNameFieldKey;
|
|
12269
|
-
const candidates = [
|
|
12270
|
-
entry[ENTRY_NAME_KEY],
|
|
12271
|
-
entryNameKey ? entry[entryNameKey] : void 0,
|
|
12272
|
-
entry.section_title,
|
|
12273
|
-
entry.label,
|
|
12274
|
-
entry.name
|
|
12275
|
-
];
|
|
12276
|
-
return Array.from(new Set(
|
|
12277
|
-
candidates.filter((value) => typeof value === "string" && !!value.trim()).map((value) => value.trim().toLowerCase())
|
|
12278
|
-
));
|
|
12279
|
-
}
|
|
12280
12322
|
function mergeRepeatableEntryMeta(target, metaSource, sections) {
|
|
12281
12323
|
if (!metaSource) return target;
|
|
12282
12324
|
let changed = false;
|
|
12283
12325
|
const next = { ...target };
|
|
12284
12326
|
const repeatableIds = new Set(sections.filter((section) => section.type === "repeatable").map((section) => section.id));
|
|
12285
12327
|
const isRepeatableStateKey = (key) => repeatableIds.has(key) || Array.from(repeatableIds).some((id) => key.endsWith(`_${id}`));
|
|
12286
|
-
const sectionForStateKey = (key) => sections.find((section) => section.type === "repeatable" && (section.id === key || key.endsWith(`_${section.id}`)));
|
|
12287
12328
|
for (const [key, targetEntries] of Object.entries(target)) {
|
|
12288
12329
|
if (!isRepeatableStateKey(key) || !Array.isArray(targetEntries)) continue;
|
|
12289
12330
|
const sourceEntries = metaSource[key];
|
|
12290
12331
|
if (!Array.isArray(sourceEntries)) continue;
|
|
12291
|
-
const section = sectionForStateKey(key);
|
|
12292
|
-
const sourceByToken = /* @__PURE__ */ new Map();
|
|
12293
|
-
const duplicateTokens = /* @__PURE__ */ new Set();
|
|
12294
|
-
for (const sourceEntry of sourceEntries) {
|
|
12295
|
-
if (!isRecord(sourceEntry)) continue;
|
|
12296
|
-
for (const token of entryIdentityTokens(sourceEntry, section)) {
|
|
12297
|
-
if (sourceByToken.has(token)) duplicateTokens.add(token);
|
|
12298
|
-
else sourceByToken.set(token, sourceEntry);
|
|
12299
|
-
}
|
|
12300
|
-
}
|
|
12301
|
-
for (const token of duplicateTokens) sourceByToken.delete(token);
|
|
12302
12332
|
const mergedEntries = targetEntries.map((entry, index) => {
|
|
12303
12333
|
if (!isRecord(entry)) return entry;
|
|
12304
|
-
const sourceEntry =
|
|
12334
|
+
const sourceEntry = sourceEntries[index];
|
|
12305
12335
|
if (!isRecord(sourceEntry)) return entry;
|
|
12306
12336
|
const id = sourceEntry[ENTRY_ID_KEY];
|
|
12307
12337
|
const name = sourceEntry[ENTRY_NAME_KEY];
|
|
@@ -16330,7 +16360,7 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
16330
16360
|
}
|
|
16331
16361
|
if (shouldOutlineText) {
|
|
16332
16362
|
try {
|
|
16333
|
-
const { convertAllTextToPath } = await Promise.resolve().then(() => require("./svgTextToPath-
|
|
16363
|
+
const { convertAllTextToPath } = await Promise.resolve().then(() => require("./svgTextToPath-CWlhIf-q.cjs"));
|
|
16334
16364
|
pageSvg = await convertAllTextToPath(pageSvg, fontBaseUrl, { mode: outlineSubMode });
|
|
16335
16365
|
try {
|
|
16336
16366
|
dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-text-to-path-raw");
|