Files
vibemake/js/cad/config.js
T
2026-11-06 15:54:55 +08:00

22 lines
1.5 KiB
JavaScript

export const CAD = Object.freeze({ product: 'VibeMake CAD', list: '/cad/', editor: '/cad/editor/', bridgeVersion: 1, maxSourceBytes: 256 * 1024 * 1024, maxStepSourceBytes: 500 * 1024 * 1024,
links: Object.freeze({ home: '/', help: null, feedback: null, releases: null }), engineManifest: '/cad/engine.json' });
export const projectUrl = (id) => `${CAD.editor}?project=${encodeURIComponent(id)}`;
export function desktopAllowed() {
return !matchMedia('(max-width: 820px)').matches && !navigator.userAgentData?.mobile
&& !/Android|iPhone|iPad|iPod|Mobile|Tablet/i.test(navigator.userAgent)
&& !(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
}
export function validName(value) { const s = value.trim(); return [...s].length >= 1 && [...s].length <= 100 && !/[\u0000-\u001f\u007f]/.test(s); }
export function filename(name) { return (name.replace(/[\\/:*?"<>|\u0000-\u001f\u007f]/g, '_').slice(0, 100).replace(/^\.+/, '') || 'design') + '.sc'; }
export function validNativeFilename(value) {
return typeof value === 'string' && value.length > 3 && [...value].length <= 255 && /\.sc$/i.test(value)
&& !/[\\/:\u0000-\u001f\u007f-\u009f]/.test(value);
}
export function validStepFilename(value) {
return typeof value === 'string' && [...value].length <= 1024 && /\.(step|stp)$/i.test(value)
&& !/[\\/\u0000-\u001f\u007f-\u009f]/.test(value);
}
export const workspaceCadEditable = (project, sha = null) => project?.repoStatus === 'READY'
&& typeof project.stepMainUrl === 'string' && !!project.stepMainUrl.trim() && !sha;