import { useState } from 'react' import { WebLink } from 'shared/components/web-link.mjs' const knownVars = [ 'sa', 'Path', 'Point', 'Snippet', 'paths', 'points', 'snippets', 'absoluteOptions', 'complete', 'measurements', 'options', 'paperless', 'sa', 'scale', 'context', 'getId', 'hide', 'log', 'macro', 'setHidden', 'store', 'unhide', 'units', 'utils', 'Bezier', 'part', ] export const analyzeDraftLogLine = ({ type, line, t }) => { if (type === 'error' && line.stack) return return null } const Code = ({ children }) => {children} const ShowStackButton = ({ setDetails, details, t, txt = 'click here to show the stack trace', }) => ( ) const NotDestructured = ({ missing, err, setDetails, details, t }) => (
This most likely means that {missing} was not desctructured as a draft method parameter.
See{' '} {' '} or .
) const DesignsVarUndefined = ({ missing, err, t }) => (
We were unable to draft this pattern because {missing} is undefined in{' '} {err.stack.split('\n')[0].split('/designs/').pop()}
) const OtherVarUndefined = ({ missing, err, t }) => (
The {missing} variable is undefined.
Check {stack[0]} for details or .
) const DraftError = ({ err, t }) => { const [details, setDetails] = useState(false) const data = [] const stack = err.stack.split('\n') // Leave this here, it's intentional. We log the error to you can inpect it. console.log(err) if (err.name === 'ReferenceError') { if (err.message.includes('is not defined')) { const missing = err.message.split(' ').shift() if (stack[0].includes('/designs/')) { data.push() if (knownVars.includes(missing)) data.push() } else data.push() } } return ( <> {data} {t('alsoLogged')} {details ? ( <>
{t('stackTrace')}
    {stack.map((line, i) => (
  1. {line}
  2. ))}
) : null} ) }