feat: complete MDX migration, stabilize routing and lead capture

Former-commit-id: ab5cc38c97e5f73d6e821465b90d199fb6e6edc9
This commit is contained in:
2026-05-03 21:06:47 +02:00
parent b13f628b55
commit f2fdea96ec
7175 changed files with 371649 additions and 1078689 deletions

View File

@@ -0,0 +1 @@
../../../@types+estree@1.0.8/node_modules/@types/estree

View File

@@ -0,0 +1 @@
../../esast-util-from-js@2.0.1/node_modules/esast-util-from-js

View File

@@ -0,0 +1,31 @@
import type {Options} from 'esast-util-from-js'
import type {Program} from 'estree'
import type {Plugin} from 'unified'
export type {Options} from 'esast-util-from-js'
// Note: we have to use manual types here,
// instead of getting them from `lib/index.js`,
// because TS generates wrong types for functions that use `this`.
// TS makes them into classes which is incorrect.
/**
* Plugin to add support for parsing from JavaScript.
*
* @this
* Unified processor.
* @param
* Configuration (optional).
* @returns
* Nothing.
*/
declare const recmaParse: Plugin<
[(Readonly<Options> | null | undefined)?],
string,
Program
>
export default recmaParse
// Add custom settings supported when `recma-parse` is added.
declare module 'unified' {
interface Settings extends Options {}
}

View File

@@ -0,0 +1,2 @@
// Note: types exposed from `index.d.ts`.
export {default} from './lib/index.js'

View File

@@ -0,0 +1,29 @@
/**
* Plugin to add support for parsing from JavaScript.
*
* @this {Processor<Program>}
* Processor instance.
* @param {Readonly<Options> | null | undefined} [options]
* Configuration (optional).
* @returns {undefined}
* Nothing.
*/
export default function rehypeParse(this: Processor<Program, undefined, undefined, undefined, undefined>, options?: Readonly<Options> | null | undefined): undefined;
export default class rehypeParse {
/**
* Plugin to add support for parsing from JavaScript.
*
* @this {Processor<Program>}
* Processor instance.
* @param {Readonly<Options> | null | undefined} [options]
* Configuration (optional).
* @returns {undefined}
* Nothing.
*/
constructor(this: Processor<Program, undefined, undefined, undefined, undefined>, options?: Readonly<Options> | null | undefined);
parser: (value: string) => Program;
}
import type { Options } from 'esast-util-from-js';
import type { Program } from 'estree';
import type { Processor } from 'unified';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH,oHALW,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GAElC,SAAS,CAiBrB;;IAxBD;;;;;;;;;OASG;IACH,4FALW,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAmB9C;IAXC,gBAGW,MAAM,KAEJ,OAAO,CALA;;6BApBI,oBAAoB;6BACpB,QAAQ;+BACN,SAAS"}

View File

@@ -0,0 +1,33 @@
/**
* @import {Options} from 'esast-util-from-js'
* @import {Program} from 'estree'
* @import {Processor} from 'unified'
*/
import {fromJs} from 'esast-util-from-js'
/**
* Plugin to add support for parsing from JavaScript.
*
* @this {Processor<Program>}
* Processor instance.
* @param {Readonly<Options> | null | undefined} [options]
* Configuration (optional).
* @returns {undefined}
* Nothing.
*/
export default function rehypeParse(options) {
const self = this
self.parser = parser
/**
* @param {string} value
* JavaScript.
* @returns {Program}
* Tree.
*/
function parser(value) {
return fromJs(value, {...self.data('settings'), ...options})
}
}

View File

@@ -0,0 +1,21 @@
(The MIT License)
Copyright (c) Titus Wormer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,50 @@
{
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"bugs": "https://github.com/mdx-js/recma/issues",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"dependencies": {
"@types/estree": "^1.0.0",
"esast-util-from-js": "^2.0.0",
"unified": "^11.0.0",
"vfile": "^6.0.0"
},
"description": "recma plugin to parse JavaScript",
"exports": "./index.js",
"files": [
"lib/",
"index.d.ts",
"index.js"
],
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"homepage": "https://github.com/mdx-js/recma",
"keywords": [
"abstract",
"ast",
"javascript",
"parse",
"plugin",
"recma-plugin",
"recma",
"syntax",
"tree",
"unified"
],
"license": "MIT",
"name": "recma-parse",
"repository": "https://github.com/mdx-js/recma/tree/main/packages/recma-parse",
"scripts": {},
"sideEffects": false,
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true,
"ignoreCatch": true
},
"type": "module",
"version": "1.0.0"
}

View File

@@ -0,0 +1,250 @@
# recma-parse
[![Build][badge-build-image]][badge-build-url]
[![Coverage][badge-coverage-image]][badge-coverage-url]
[![Downloads][badge-downloads-image]][badge-downloads-url]
[![Size][badge-size-image]][badge-size-url]
[![Sponsors][badge-sponsors-image]][badge-collective-url]
[![Backers][badge-backers-image]][badge-collective-url]
[![Chat][badge-chat-image]][badge-chat-url]
**[recma][github-recma]** plugin to add support for parsing JavaScript.
## Contents
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`unified().use(recmaParse[, options])`](#unifieduserecmaparse-options)
* [`Options`](#options)
* [Syntax](#syntax)
* [Syntax tree](#syntax-tree)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Contribute](#contribute)
* [License](#license)
## What is this?
This package is a [unified][github-unified] ([recma][github-recma]) plugin that
defines how to take JavaScript as input and turn it into a syntax tree.
When its used,
JavaScript can be parsed and other recma plugins can be used.
See [the monorepo readme][github-recma] for info on what the recma ecosystem is.
## When should I use this?
This plugin adds support to unified for parsing JavaScript.
If you also need to serialize JavaScript,
you can alternatively use [`recma`][github-recma-core],
which combines unified,
this plugin,
and [`recma-stringify`][github-recma-stringify].
If you dont use plugins and want to access the syntax tree,
you can directly use [`esast-util-from-js`][github-esast-util-from-js],
which is used inside this plugin.
recma focusses on making it easier to transform code by abstracting such
internals away.
## Install
This package is [ESM only][github-gist-esm].
In Node.js (version 16+),
install with [npm][npm-install]:
```sh
npm install recma-parse
```
In Deno with [`esm.sh`][esmsh]:
```js
import recmaParse from 'https://esm.sh/recma-parse@1'
```
In browsers with [`esm.sh`][esmsh]:
```html
<script type="module">
import recmaParse from 'https://esm.sh/recma-parse@1?bundle'
</script>
```
## Use
Say we have the following module `example.js`:
```js
import recmaBuildJsx from 'recma-build-jsx'
import recmaJsx from 'recma-jsx'
import recmaParse from 'recma-parse'
import recmaStringify from 'recma-stringify'
import {unified} from 'unified'
const file = await unified()
.use(recmaParse)
.use(recmaJsx)
.use(recmaBuildJsx)
.use(recmaStringify)
.process('console.log(<em>Hi!</em>)')
console.log(String(file))
```
…running that with `node example.js` yields:
```js
console.log(React.createElement("em", null, "Hi!"));
```
## API
This package exports no identifiers.
The default export is [`recmaParse`][api-recma-parse].
### `unified().use(recmaParse[, options])`
Plugin to add support for parsing from JavaScript.
###### Parameters
* `options` ([`Options`][api-options], optional)
— configuration
###### Returns
Nothing (`undefined`).
### `Options`
Configuration (TypeScript type).
Same as [`Options`][github-esast-util-from-js-options]
from [`esast-util-from-js`][github-esast-util-from-js].
## Syntax
JS is parsed according to [ECMA-262][tc39-ecma-262],
which is also followed by all browsers and engines such as Node.js.
## Syntax tree
The syntax tree format used in recma is [esast][github-esast] and
[estree][github-estree].
## Types
This package is fully typed with [TypeScript][].
It exports the additional type
[`Options`][api-options].
## Compatibility
Projects maintained by the unified collective are compatible with maintained
versions of Node.js.
When we cut a new major release,
we drop support for unmaintained versions of Node.
This means we try to keep the current release line,
`recma-parse@1`,
compatible with Node.js 16.
## Security
As **recma** works on JS and evaluating JS is unsafe,
use of recma can also be unsafe.
Do not evaluate unsafe code.
Use of recma plugins could also open you up to other attacks.
Carefully assess each plugin and the risks involved in using them.
For info on how to submit a report, see our [security policy][health-security].
## Contribute
See [§ Contribute][mdxjs-contribute] on our site for ways to get started.
See [§ Support][mdxjs-support] for ways to get help.
This project has a [code of conduct][health-coc].
By interacting with this repository,
organization,
or community you agree to abide by its terms.
## License
[MIT][file-license] © [Titus Wormer][wooorm]
<!-- Definitions -->
[api-options]: #options
[api-recma-parse]: #unifieduserecmaparse-options
[badge-backers-image]: https://opencollective.com/unified/backers/badge.svg
[badge-build-image]: https://github.com/mdx-js/recma/actions/workflows/main.yml/badge.svg
[badge-build-url]: https://github.com/mdx-js/recma/actions
[badge-collective-url]: https://opencollective.com/unified
[badge-coverage-image]: https://img.shields.io/codecov/c/github/mdx-js/recma.svg
[badge-coverage-url]: https://codecov.io/github/mdx-js/recma
[badge-downloads-image]: https://img.shields.io/npm/dm/recma-parse.svg
[badge-downloads-url]: https://www.npmjs.com/package/recma-parse
[badge-size-image]: https://img.shields.io/bundlejs/size/recma-parse
[badge-size-url]: https://bundlejs.com/?q=recma-parse
[badge-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
[badge-chat-url]: https://github.com/mdx-js/mdx/discussions
[esmsh]: https://esm.sh
[file-license]: license
[github-esast]: https://github.com/syntax-tree/esast
[github-esast-util-from-js]: https://github.com/syntax-tree/esast-util-from-js
[github-esast-util-from-js-options]: https://github.com/syntax-tree/esast-util-from-js#options
[github-estree]: https://github.com/estree/estree
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[github-recma-core]: https://github.com/mdx-js/recma/tree/main/packages/recma
[github-recma-stringify]: https://github.com/mdx-js/recma/tree/main/packages/recma-stringify
[github-recma]: https://github.com/mdx-js/recma
[github-unified]: https://github.com/unifiedjs/unified
[health-coc]: https://github.com/mdx-js/.github/blob/main/code-of-conduct.md
[health-security]: https://github.com/mdx-js/.github/blob/main/security.md
[mdxjs-contribute]: https://mdxjs.com/community/contribute/
[mdxjs-support]: https://mdxjs.com/community/support/
[npm-install]: https://docs.npmjs.com/cli/install
[tc39-ecma-262]: https://tc39.es/ecma262/multipage/
[typescript]: https://www.typescriptlang.org
[wooorm]: https://wooorm.com

View File

@@ -0,0 +1 @@
../../unified@11.0.5/node_modules/unified

1
node_modules/.pnpm/recma-parse@1.0.0/node_modules/vfile generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../../vfile@6.0.3/node_modules/vfile