← Files Flows by plugin.spaceARCHIVED FILE
lib/capture-settings.mjs
1.96 KB · Nov 30, 2026 · 00:17 UTC
export const DEFAULT_CAPTURE_SETTINGS = {
profiles: [
{ id: 'mobile', name: 'Mobile', width: 390, height: 844, enabled: true, isMobile: true, hasTouch: true },
{ id: 'tablet', name: 'Tablet', width: 768, height: 1024, enabled: true, isMobile: true, hasTouch: true },
{ id: 'desktop', name: 'Desktop', width: 1440, height: 900, enabled: true, isMobile: false, hasTouch: false },
],
fullPage: false,
colorScheme: 'light',
};
export function validateCaptureSettings(value) {
const errors = [];
if (!value || typeof value !== 'object' || Array.isArray(value)) return ['Capture settings must be an object.'];
if (typeof value.fullPage !== 'boolean') errors.push('Choose viewport or full-page capture.');
if (!['light', 'dark'].includes(value.colorScheme)) errors.push('Choose a light or dark capture theme.');
if (!Array.isArray(value.profiles) || value.profiles.length < 1 || value.profiles.length > 16) return [...errors, 'Use 1–16 capture profiles.'];
const ids = new Set();
for (const profile of value.profiles) {
if (!profile || typeof profile !== 'object') { errors.push('Invalid capture profile.'); continue; }
if (typeof profile.id !== 'string' || !/^[a-zA-Z0-9_-]{1,100}$/.test(profile.id) || ids.has(profile.id)) errors.push('Each profile needs a unique ID.');
ids.add(profile.id);
if (typeof profile.name !== 'string' || !profile.name.trim() || profile.name.length > 60) errors.push('Each profile needs a name of up to 60 characters.');
if (!['width', 'height'].every(key => Number.isInteger(profile[key]) && profile[key] >= 240 && profile[key] <= 3840)) errors.push('Viewport dimensions must be whole numbers between 240 and 3840 px.');
if (!['enabled', 'isMobile', 'hasTouch'].every(key => typeof profile[key] === 'boolean')) errors.push('Profile capture and device options must be on or off.');
}
if (!value.profiles.some(profile => profile?.enabled === true)) errors.push('Enable at least one capture profile.');
return errors;
}
SHA-256: 2a7696854b5e44db4e8b6c2d599d06de3f17dbc1f0b71164cd6e36717244454e