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/resolver/FindAllDefinitionsResolver.js
import isReactComponentClass from '../utils/isReactComponentClass.js';
import isReactCreateClassCall from '../utils/isReactCreateClassCall.js';
import isReactForwardRefCall from '../utils/isReactForwardRefCall.js';
import isStatelessComponent from '../utils/isStatelessComponent.js';
import normalizeClassDefinition from '../utils/normalizeClassDefinition.js';
import resolveToValue from '../utils/resolveToValue.js';
import { visitors } from '@babel/traverse';
function classVisitor(path, state) {
    if (isReactComponentClass(path)) {
        normalizeClassDefinition(path);
        state.foundDefinitions.add(path);
    }
    path.skip();
}
function statelessVisitor(path, state) {
    if (isStatelessComponent(path)) {
        state.foundDefinitions.add(path);
    }
    path.skip();
}
const explodedVisitors = visitors.explode({
    FunctionDeclaration: { enter: statelessVisitor },
    FunctionExpression: { enter: statelessVisitor },
    ObjectMethod: { enter: statelessVisitor },
    ArrowFunctionExpression: { enter: statelessVisitor },
    ClassExpression: { enter: classVisitor },
    ClassDeclaration: { enter: classVisitor },
    CallExpression: {
        enter: function (path, state) {
            const argument = path.get('arguments')[0];
            if (!argument) {
                return;
            }
            if (isReactForwardRefCall(path)) {
                // If the the inner function was previously identified as a component
                // replace it with the parent node
                const inner = resolveToValue(argument);
                state.foundDefinitions.delete(inner);
                state.foundDefinitions.add(path);
                // Do not traverse into arguments
                return path.skip();
            }
            else if (isReactCreateClassCall(path)) {
                const resolvedPath = resolveToValue(argument);
                if (resolvedPath.isObjectExpression()) {
                    state.foundDefinitions.add(resolvedPath);
                }
                // Do not traverse into arguments
                return path.skip();
            }
        },
    },
});
/**
 * Given an AST, this function tries to find all object expressions that are
 * passed to `React.createClass` calls, by resolving all references properly.
 */
export default class FindAllDefinitionsResolver {
    resolve(file) {
        const state = {
            foundDefinitions: new Set(),
        };
        file.traverse(explodedVisitors, state);
        return Array.from(state.foundDefinitions);
    }
}