SILENT KILLERPanel

Current Path: > home > codekrsu > > ameliagraphics.com > wp-content > plugins > extendify > src > > Launch > lib


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: /home/codekrsu//ameliagraphics.com/wp-content/plugins/extendify/src//Launch/lib

NameTypeSizeLast ModifiedActions
__tests__ Directory - -
blocks.js File 417 bytes September 12 2024 19:49:54.
fonts-helpers.js File 1876 bytes April 22 2025 21:31:24.
linkPages.js File 6552 bytes May 12 2025 16:42:28.
logo.js File 1331 bytes May 12 2025 16:42:28.
pages.js File 2281 bytes July 16 2025 19:39:24.
preview-helpers.js File 1636 bytes February 04 2025 00:18:34.
util.js File 1848 bytes May 12 2025 16:42:28.
wp.js File 10283 bytes July 16 2025 19:39:24.

Reading File: /home/codekrsu//ameliagraphics.com/wp-content/plugins/extendify/src//Launch/lib/fonts-helpers.js

import { sleep } from '@shared/lib/utils';

const MAX_RETRIES = 2;
const RETRY_DELAY = 1000; // 1 second in milliseconds

export const fetchFontFaceFile = async (url) => {
	for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
		try {
			// Add delay if this is not the first attempt
			if (attempt > 0) await sleep(RETRY_DELAY);

			const response = await fetch(url);

			if (!response.ok) {
				throw new Error('Failed to fetch font file.');
			}

			const blob = await response.blob();
			const filename = url.split('/').pop();

			return new File([blob], filename, {
				type: blob.type,
			});
		} catch (_) {
			if (attempt <= MAX_RETRIES) continue;

			console.error(
				`Failed to fetch font file after ${MAX_RETRIES + 1} attempts.`,
			);

			return;
		}
	}
};

export function makeFontFamilyFormData({ name, slug, fontFamily }) {
	const formData = new FormData();
	const fontFamilySettings = { name, slug, fontFamily };
	formData.append('font_family_settings', JSON.stringify(fontFamilySettings));

	return formData;
}

export function makeFontFaceFormData({
	fontFamilySlug,
	fontFamily,
	fontStyle,
	fontWeight,
	fontDisplay,
	unicodeRange,
	src = [],
	file = [],
}) {
	const formData = new FormData();
	const fontFaceSettings = {
		fontFamily,
		fontStyle,
		fontWeight,
		fontDisplay,
		unicodeRange,
		src: Array.isArray(src) ? src : [src],
	};
	const files = Array.isArray(file) ? file : [file];

	// Add each font file to the form data.
	files.forEach((file) => {
		const fileId = `${fontFamilySlug}-${fontWeight}-${fontStyle}`;
		formData.append(fileId, file, file.name);

		// Use the file ids as src for WP to match and upload the files.
		if (!src?.length) {
			fontFaceSettings.src.push(fileId);
		} else {
			fontFaceSettings.src = [fileId];
		}
	});

	formData.append('font_face_settings', JSON.stringify(fontFaceSettings));

	return formData;
}

SILENT KILLER Tool