HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/design.system/node_modules/react-docgen/dist/utils/resolveObjectValuesToArray.js
import resolveToValue from './resolveToValue.js';
function isObjectValuesCall(path) {
    if (!path.isCallExpression() || path.node.arguments.length !== 1) {
        return false;
    }
    const callee = path.get('callee');
    if (!callee.isMemberExpression()) {
        return false;
    }
    const object = callee.get('object');
    const property = callee.get('property');
    return (object.isIdentifier({ name: 'Object' }) &&
        property.isIdentifier({ name: 'values' }));
}
// Resolves an ObjectExpression or an ObjectTypeAnnotation
function resolveObjectToPropMap(object) {
    if (object.isObjectExpression()) {
        const values = new Map();
        let error = false;
        object.get('properties').forEach((propPath) => {
            if (error || propPath.isObjectMethod())
                return;
            if (propPath.isObjectProperty()) {
                const key = propPath.get('key');
                let name;
                // Key is either Identifier or Literal
                if (key.isIdentifier()) {
                    name = key.node.name;
                }
                else if (key.isNumericLiteral() || key.isStringLiteral()) {
                    name = `${key.node.value}`;
                }
                else {
                    error = true;
                    return;
                }
                const valuePath = resolveToValue(propPath.get('value'));
                const value = valuePath.isStringLiteral()
                    ? `"${valuePath.node.value}"`
                    : valuePath.isNumericLiteral()
                        ? `${valuePath.node.value}`
                        : // we return null here because there are a lot of cases and we don't know yet what we need to handle
                            'null';
                values.set(name, value);
            }
            else if (propPath.isSpreadElement()) {
                const spreadObject = resolveToValue(propPath.get('argument'));
                const spreadValues = resolveObjectToPropMap(spreadObject);
                if (!spreadValues) {
                    error = true;
                    return;
                }
                for (const entry of spreadValues.entries()) {
                    const [key, value] = entry;
                    values.set(key, value);
                }
            }
        });
        if (!error) {
            return values;
        }
    }
    return null;
}
/**
 * Returns an ArrayExpression which contains all the values resolved from an object
 *
 * Ignores setters in objects
 *
 * Returns null in case of
 *  unresolvable spreads
 *  computed identifier values
 */
export default function resolveObjectValuesToArray(path) {
    if (isObjectValuesCall(path)) {
        const argument = path.get('arguments')[0];
        const objectExpression = resolveToValue(
        // isObjectValuesCall already asserts that there is at least one argument, hence the non-null-assertion
        argument);
        const values = resolveObjectToPropMap(objectExpression);
        if (values) {
            return Array.from(values.values());
        }
    }
    return null;
}