HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
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/vhost/disk-apps/pwa.sports-crowd.com/node_modules/guess-parser/README.md
# guess-parser

This module is used for route extraction by the `GuessPlugin`. The module exports several functions:

## Usage

```bash
npm i guess-parser --save-dev
```

## API

* `detect(path: string)` - Detects the project type and returns metadata. For the currently supported projects see the `ProjectMetadata` interface.
* `parseRoutes(path: string)` - Extracts the routes of the application in `path`. Internally uses the `detect` function.
* `parseAngularRoutes(tsconfig: string)` - Extracts the routes of an Angular application. As arguments the function accepts path to the `tsconfig.json` file of the project.
* `parseReactJSXRoutes(path: string)` - Extracts the routes from React JSX project. See the supported syntax below.
* `parseReactTSXRoutes(tsconfig: string)` - Extracts the routes from React TypeScript projects which uses JSX by `tsconfig.json` file. See the supported syntax below.

```ts
export interface ProjectMetadata {
  type: ProjectType;
  version: string;
  details?: ProjectLayout;
}

export enum ProjectType {
  AngularCLI = 'angular-cli',
  CreateReactApp = 'create-react-app',
  Gatsby = 'gatsby',
  CreateReactAppTypeScript = 'create-react-app-typescript'
}

export interface ProjectLayout {
  typescript?: string;
  tsconfigPath?: string;
  sourceDir?: string;
}
```

## Supported Syntax

### Angular

Because of the produced summaries by the Angular compiler the Angular parser supports most Angular CLI applications as well as most starters.

### React

Because of the dynamic nature of React and lack of standard route definition syntax, only applications using the following convention can be successfully parsed:

```jsx
<Router history={history}>
  <div className="App">
    <Link to="/intro">Intro</Link>
    <Link to="/main">Main</Link>
    <div>
      <Switch>
        <Redirect exact={true} from="/" to="/intro" />
        <Route path="/intro" component={AsyncComponent(() => import('./intro/Intro'))} />
        <Route path="/main" component={Main} />
      </Switch>
    </div>
  </div>
</Router>
```

Currently, there are several important conventions:

* Support only for JSX syntax
* Support only for `react-router`-like syntax
* The path attribute of the `<Route/>` element must have value of type string literal.
* The lazy-loaded components should have dynamic import with the following structure of the AST:
  * `CallExpression` (e.g. `AsyncComponent`) with a single argument
  * The type of the argument should be an `ArrowFunction`
  * The arrow function should have an expression as body (e.g. `CallExpression`)
  * To the `CallExpression` should be passed a `StringLiteral` which points to the lazy-loaded module

**Contributions aiming to extend the supported syntax are very welcome!**

## License

MIT