@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.js
CHANGED
|
@@ -2593,10 +2593,10 @@ async function loadGoogleFont(fontFamily, weights) {
|
|
|
2593
2593
|
if (LOCAL_FONTS.has(fontFamily)) return true;
|
|
2594
2594
|
if (loadedGoogleFonts.has(fontFamily)) return true;
|
|
2595
2595
|
if (failedGoogleFonts.has(fontFamily)) return false;
|
|
2596
|
-
const existing = loadingPromises$1.get(fontFamily);
|
|
2596
|
+
const existing = loadingPromises$1.get(`google:${fontFamily}`);
|
|
2597
2597
|
if (existing) return existing;
|
|
2598
|
-
const promise = _doLoadGoogleFont(fontFamily
|
|
2599
|
-
loadingPromises$1.set(fontFamily
|
|
2598
|
+
const promise = _doLoadGoogleFont(fontFamily);
|
|
2599
|
+
loadingPromises$1.set(`google:${fontFamily}`, promise);
|
|
2600
2600
|
try {
|
|
2601
2601
|
const result = await promise;
|
|
2602
2602
|
if (result) {
|
|
@@ -2606,38 +2606,46 @@ async function loadGoogleFont(fontFamily, weights) {
|
|
|
2606
2606
|
}
|
|
2607
2607
|
return result;
|
|
2608
2608
|
} finally {
|
|
2609
|
-
loadingPromises$1.delete(fontFamily);
|
|
2609
|
+
loadingPromises$1.delete(`google:${fontFamily}`);
|
|
2610
2610
|
}
|
|
2611
2611
|
}
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
const encodedFamily = encodeURIComponent(fontFamily);
|
|
2616
|
-
const url = `https://fonts.googleapis.com/css2?family=${encodedFamily}:ital,wght@0,${weightStr};1,${weightStr}&display=swap`;
|
|
2617
|
-
const existingLink = document.querySelector(`link[href="${url}"]`);
|
|
2618
|
-
if (existingLink) return true;
|
|
2612
|
+
function tryInjectGoogleFontsLink(url, fontFamily) {
|
|
2613
|
+
if (document.querySelector(`link[href="${url}"]`)) return Promise.resolve(true);
|
|
2614
|
+
return new Promise((resolve) => {
|
|
2619
2615
|
const link = document.createElement("link");
|
|
2620
2616
|
link.rel = "stylesheet";
|
|
2621
2617
|
link.href = url;
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2618
|
+
link.onload = async () => {
|
|
2619
|
+
try {
|
|
2620
|
+
await document.fonts.load(`16px "${fontFamily}"`);
|
|
2621
|
+
} catch {
|
|
2622
|
+
}
|
|
2623
|
+
resolve(true);
|
|
2624
|
+
};
|
|
2625
|
+
link.onerror = () => resolve(false);
|
|
2626
|
+
document.head.appendChild(link);
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2629
|
+
async function _doLoadGoogleFont(fontFamily, weights) {
|
|
2630
|
+
const encodedFamily = encodeURIComponent(fontFamily);
|
|
2631
|
+
const weightSet = [300, 400, 500, 600, 700];
|
|
2632
|
+
const fullWeightStr = weightSet.join(";");
|
|
2633
|
+
const coreWeightStr = "400;700";
|
|
2634
|
+
const candidates = [
|
|
2635
|
+
`https://fonts.googleapis.com/css2?family=${encodedFamily}:ital,wght@0,${fullWeightStr};1,${fullWeightStr}&display=swap`,
|
|
2636
|
+
`https://fonts.googleapis.com/css2?family=${encodedFamily}:wght@${fullWeightStr}&display=swap`,
|
|
2637
|
+
`https://fonts.googleapis.com/css2?family=${encodedFamily}:ital,wght@0,${coreWeightStr};1,${coreWeightStr}&display=swap`,
|
|
2638
|
+
`https://fonts.googleapis.com/css2?family=${encodedFamily}:wght@${coreWeightStr}&display=swap`,
|
|
2639
|
+
// Plainest possible URL — works for any published Google Font, even
|
|
2640
|
+
// single-weight display/script families like "Frijole" or "Creepster".
|
|
2641
|
+
`https://fonts.googleapis.com/css2?family=${encodedFamily}&display=swap`
|
|
2642
|
+
];
|
|
2643
|
+
for (const url of candidates) {
|
|
2644
|
+
const ok = await tryInjectGoogleFontsLink(url, fontFamily);
|
|
2645
|
+
if (ok) return true;
|
|
2640
2646
|
}
|
|
2647
|
+
console.warn(`[GoogleFonts] Failed to load: ${fontFamily}`);
|
|
2648
|
+
return false;
|
|
2641
2649
|
}
|
|
2642
2650
|
const getObjectId = (obj) => obj.__docuforgeId;
|
|
2643
2651
|
const setObjectData = (obj, id) => {
|
|
@@ -5544,7 +5552,7 @@ function createText(element) {
|
|
|
5544
5552
|
}
|
|
5545
5553
|
text = result;
|
|
5546
5554
|
}
|
|
5547
|
-
const targetWidth =
|
|
5555
|
+
const targetWidth = fixedWidth;
|
|
5548
5556
|
const targetScaleX = element.scaleX ?? 1;
|
|
5549
5557
|
const targetScaleY = element.scaleY ?? 1;
|
|
5550
5558
|
const textbox = new fabric.Textbox(text, {
|
|
@@ -11980,6 +11988,38 @@ function applyContentBoundsPagination(config) {
|
|
|
11980
11988
|
if (!mutated) return config;
|
|
11981
11989
|
return { ...config, pages: resultPages };
|
|
11982
11990
|
}
|
|
11991
|
+
const FONTSHARE_SLUGS = {
|
|
11992
|
+
"Satoshi": "satoshi",
|
|
11993
|
+
"Cabinet Grotesk": "cabinet-grotesk",
|
|
11994
|
+
"Clash Display": "clash-display",
|
|
11995
|
+
"Clash Grotesk": "clash-grotesk",
|
|
11996
|
+
"General Sans": "general-sans",
|
|
11997
|
+
"Switzer": "switzer",
|
|
11998
|
+
"Supreme": "supreme",
|
|
11999
|
+
"Author": "author",
|
|
12000
|
+
"Boska": "boska",
|
|
12001
|
+
"Excon": "excon",
|
|
12002
|
+
"Khand": "khand",
|
|
12003
|
+
"Sentient": "sentient",
|
|
12004
|
+
"Synonym": "synonym",
|
|
12005
|
+
"Erode": "erode",
|
|
12006
|
+
"Ranade": "ranade",
|
|
12007
|
+
"Tanker": "tanker",
|
|
12008
|
+
"Zodiak": "zodiak",
|
|
12009
|
+
"Gambarino": "gambarino",
|
|
12010
|
+
"Melodrama": "melodrama",
|
|
12011
|
+
"Bespoke Serif": "bespoke-serif",
|
|
12012
|
+
"Bespoke Stencil": "bespoke-stencil",
|
|
12013
|
+
"Panchang": "panchang",
|
|
12014
|
+
"Quincy CF": "quincy-cf",
|
|
12015
|
+
"Pally": "pally",
|
|
12016
|
+
"Tabular": "tabular",
|
|
12017
|
+
"Sharpie": "sharpie",
|
|
12018
|
+
"Stardom": "stardom",
|
|
12019
|
+
"Rebond Grotesque": "rebond-grotesque",
|
|
12020
|
+
"Telma": "telma",
|
|
12021
|
+
"Nippo": "nippo"
|
|
12022
|
+
};
|
|
11983
12023
|
function normalizeFontFamily(fontStack) {
|
|
11984
12024
|
const first = fontStack.split(",")[0].trim();
|
|
11985
12025
|
return first.replace(/^['"]|['"]$/g, "");
|
|
@@ -12006,6 +12046,20 @@ async function loadGoogleFontCSS(rawFontFamily) {
|
|
|
12006
12046
|
if (existing) return existing;
|
|
12007
12047
|
const promise = (async () => {
|
|
12008
12048
|
try {
|
|
12049
|
+
const fontshareSlug = FONTSHARE_SLUGS[fontFamily];
|
|
12050
|
+
if (fontshareSlug) {
|
|
12051
|
+
const url2 = `https://api.fontshare.com/v2/css?f[]=${fontshareSlug}@300,400,500,700&display=swap`;
|
|
12052
|
+
const link2 = document.createElement("link");
|
|
12053
|
+
link2.rel = "stylesheet";
|
|
12054
|
+
link2.href = url2;
|
|
12055
|
+
await new Promise((resolve, reject) => {
|
|
12056
|
+
link2.onload = () => resolve();
|
|
12057
|
+
link2.onerror = () => reject(new Error(`Failed to load Fontshare font: ${fontFamily}`));
|
|
12058
|
+
document.head.appendChild(link2);
|
|
12059
|
+
});
|
|
12060
|
+
loadedFonts.add(fontFamily);
|
|
12061
|
+
return;
|
|
12062
|
+
}
|
|
12009
12063
|
const encoded = encodeURIComponent(fontFamily);
|
|
12010
12064
|
const url = `https://fonts.googleapis.com/css?family=${encoded}:300,400,500,600,700&display=swap`;
|
|
12011
12065
|
const link = document.createElement("link");
|
|
@@ -12160,6 +12214,7 @@ async function awaitFontsForConfig(config, maxWaitMs) {
|
|
|
12160
12214
|
await ensureFontsForResolvedConfig(config);
|
|
12161
12215
|
const descriptors = collectFontDescriptorsFromConfig(config);
|
|
12162
12216
|
if (descriptors.length === 0) return;
|
|
12217
|
+
const overallBudget = Math.max(maxWaitMs, 5e3);
|
|
12163
12218
|
const loads = Promise.all(
|
|
12164
12219
|
descriptors.map((d) => {
|
|
12165
12220
|
const stylePrefix = d.style === "italic" ? "italic " : "";
|
|
@@ -12169,11 +12224,11 @@ async function awaitFontsForConfig(config, maxWaitMs) {
|
|
|
12169
12224
|
).then(() => void 0);
|
|
12170
12225
|
await Promise.race([
|
|
12171
12226
|
loads,
|
|
12172
|
-
new Promise((resolve) => setTimeout(resolve,
|
|
12227
|
+
new Promise((resolve) => setTimeout(resolve, overallBudget))
|
|
12173
12228
|
]);
|
|
12174
12229
|
await Promise.race([
|
|
12175
12230
|
document.fonts.ready.catch(() => void 0).then(() => void 0),
|
|
12176
|
-
new Promise((r) => setTimeout(r,
|
|
12231
|
+
new Promise((r) => setTimeout(r, 1500))
|
|
12177
12232
|
]);
|
|
12178
12233
|
const checkSpecs = [];
|
|
12179
12234
|
for (const d of descriptors) {
|
|
@@ -12181,7 +12236,7 @@ async function awaitFontsForConfig(config, maxWaitMs) {
|
|
|
12181
12236
|
checkSpecs.push(`${stylePrefix}${d.weight} 16px "${d.family}"`);
|
|
12182
12237
|
}
|
|
12183
12238
|
const startedAt = Date.now();
|
|
12184
|
-
const pollBudget =
|
|
12239
|
+
const pollBudget = 2500;
|
|
12185
12240
|
const allReady = () => {
|
|
12186
12241
|
for (const spec of checkSpecs) {
|
|
12187
12242
|
try {
|
|
@@ -12245,44 +12300,19 @@ function extractSectionStateCandidate(values, sections) {
|
|
|
12245
12300
|
const looksLikeSectionState = Object.keys(raw).some((key) => sectionIds.has(key) || key.startsWith("section_"));
|
|
12246
12301
|
return looksLikeSectionState ? raw : null;
|
|
12247
12302
|
}
|
|
12248
|
-
function entryIdentityTokens(entry, section) {
|
|
12249
|
-
const entryNameKey = section == null ? void 0 : section.entryNameFieldKey;
|
|
12250
|
-
const candidates = [
|
|
12251
|
-
entry[ENTRY_NAME_KEY],
|
|
12252
|
-
entryNameKey ? entry[entryNameKey] : void 0,
|
|
12253
|
-
entry.section_title,
|
|
12254
|
-
entry.label,
|
|
12255
|
-
entry.name
|
|
12256
|
-
];
|
|
12257
|
-
return Array.from(new Set(
|
|
12258
|
-
candidates.filter((value) => typeof value === "string" && !!value.trim()).map((value) => value.trim().toLowerCase())
|
|
12259
|
-
));
|
|
12260
|
-
}
|
|
12261
12303
|
function mergeRepeatableEntryMeta(target, metaSource, sections) {
|
|
12262
12304
|
if (!metaSource) return target;
|
|
12263
12305
|
let changed = false;
|
|
12264
12306
|
const next = { ...target };
|
|
12265
12307
|
const repeatableIds = new Set(sections.filter((section) => section.type === "repeatable").map((section) => section.id));
|
|
12266
12308
|
const isRepeatableStateKey = (key) => repeatableIds.has(key) || Array.from(repeatableIds).some((id) => key.endsWith(`_${id}`));
|
|
12267
|
-
const sectionForStateKey = (key) => sections.find((section) => section.type === "repeatable" && (section.id === key || key.endsWith(`_${section.id}`)));
|
|
12268
12309
|
for (const [key, targetEntries] of Object.entries(target)) {
|
|
12269
12310
|
if (!isRepeatableStateKey(key) || !Array.isArray(targetEntries)) continue;
|
|
12270
12311
|
const sourceEntries = metaSource[key];
|
|
12271
12312
|
if (!Array.isArray(sourceEntries)) continue;
|
|
12272
|
-
const section = sectionForStateKey(key);
|
|
12273
|
-
const sourceByToken = /* @__PURE__ */ new Map();
|
|
12274
|
-
const duplicateTokens = /* @__PURE__ */ new Set();
|
|
12275
|
-
for (const sourceEntry of sourceEntries) {
|
|
12276
|
-
if (!isRecord(sourceEntry)) continue;
|
|
12277
|
-
for (const token of entryIdentityTokens(sourceEntry, section)) {
|
|
12278
|
-
if (sourceByToken.has(token)) duplicateTokens.add(token);
|
|
12279
|
-
else sourceByToken.set(token, sourceEntry);
|
|
12280
|
-
}
|
|
12281
|
-
}
|
|
12282
|
-
for (const token of duplicateTokens) sourceByToken.delete(token);
|
|
12283
12313
|
const mergedEntries = targetEntries.map((entry, index) => {
|
|
12284
12314
|
if (!isRecord(entry)) return entry;
|
|
12285
|
-
const sourceEntry =
|
|
12315
|
+
const sourceEntry = sourceEntries[index];
|
|
12286
12316
|
if (!isRecord(sourceEntry)) return entry;
|
|
12287
12317
|
const id = sourceEntry[ENTRY_ID_KEY];
|
|
12288
12318
|
const name = sourceEntry[ENTRY_NAME_KEY];
|
|
@@ -16311,7 +16341,7 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
16311
16341
|
}
|
|
16312
16342
|
if (shouldOutlineText) {
|
|
16313
16343
|
try {
|
|
16314
|
-
const { convertAllTextToPath } = await import("./svgTextToPath-
|
|
16344
|
+
const { convertAllTextToPath } = await import("./svgTextToPath-CpWdqc8K.js");
|
|
16315
16345
|
pageSvg = await convertAllTextToPath(pageSvg, fontBaseUrl, { mode: outlineSubMode });
|
|
16316
16346
|
try {
|
|
16317
16347
|
dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-text-to-path-raw");
|