feat: complete MDX migration, stabilize routing and lead capture
Former-commit-id: ab5cc38c97e5f73d6e821465b90d199fb6e6edc9
This commit is contained in:
1
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/@types/estree-jsx
generated
vendored
Symbolic link
1
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/@types/estree-jsx
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../@types+estree-jsx@1.0.5/node_modules/@types/estree-jsx
|
||||
1
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/devlop
generated
vendored
Symbolic link
1
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/devlop
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../devlop@1.1.0/node_modules/devlop
|
||||
2
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/index.d.ts
generated
vendored
Normal file
2
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export { fromEstree } from "./lib/index.js";
|
||||
export type Options = import('./lib/index.js').Options;
|
||||
5
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/index.js
generated
vendored
Normal file
5
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @typedef {import('./lib/index.js').Options} Options
|
||||
*/
|
||||
|
||||
export {fromEstree} from './lib/index.js'
|
||||
26
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/lib/index.d.ts
generated
vendored
Normal file
26
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Turn an estree into an esast.
|
||||
*
|
||||
* @template {Nodes} Kind
|
||||
* Node kind.
|
||||
* @param {Kind} estree
|
||||
* estree.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns {Kind}
|
||||
* Clean clone of `estree`.
|
||||
*/
|
||||
export function fromEstree<Kind extends import("estree").Node>(estree: Kind, options?: Options | null | undefined): Kind;
|
||||
export type Nodes = import('estree-jsx').Node;
|
||||
/**
|
||||
* Configuration.
|
||||
*/
|
||||
export type Options = {
|
||||
/**
|
||||
* Leave discouraged fields in the tree (default: `false`).
|
||||
*/
|
||||
dirty?: boolean | null | undefined;
|
||||
};
|
||||
export type KeysOfType<T, U> = { [K in keyof T]: T[K] extends U ? K : never; }[keyof T];
|
||||
export type RequiredKeys<T> = Exclude<KeysOfType<T, Exclude<T[keyof T], undefined>>, undefined>;
|
||||
export type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
|
||||
121
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/lib/index.js
generated
vendored
Normal file
121
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* @typedef {import('estree-jsx').Node} Nodes
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Options
|
||||
* Configuration.
|
||||
* @property {boolean | null | undefined} [dirty=false]
|
||||
* Leave discouraged fields in the tree (default: `false`).
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @template U
|
||||
* @typedef {{[K in keyof T]: T[K] extends U ? K : never}[keyof T]} KeysOfType
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {Exclude<KeysOfType<T, Exclude<T[keyof T], undefined>>, undefined>} RequiredKeys
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {Exclude<keyof T, RequiredKeys<T>>} OptionalKeys
|
||||
*/
|
||||
|
||||
import {visit} from 'estree-util-visit'
|
||||
import {positionFromEstree} from 'unist-util-position-from-estree'
|
||||
|
||||
/** @type {Options} */
|
||||
const emptyOptions = {}
|
||||
|
||||
/**
|
||||
* Turn an estree into an esast.
|
||||
*
|
||||
* @template {Nodes} Kind
|
||||
* Node kind.
|
||||
* @param {Kind} estree
|
||||
* estree.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns {Kind}
|
||||
* Clean clone of `estree`.
|
||||
*/
|
||||
export function fromEstree(estree, options) {
|
||||
const settings = options || emptyOptions
|
||||
/** @type {Kind} */
|
||||
// Drop the `Node` and such constructors on Acorn nodes.
|
||||
const esast = JSON.parse(JSON.stringify(estree, ignoreBigint))
|
||||
|
||||
visit(esast, {
|
||||
leave(node) {
|
||||
const position = positionFromEstree(node)
|
||||
|
||||
if (!settings.dirty) {
|
||||
// Acorn specific.
|
||||
// @ts-expect-error: acorn adds this.
|
||||
if ('end' in node) remove(node, 'end')
|
||||
// @ts-expect-error: acorn adds this.
|
||||
if ('start' in node) remove(node, 'start')
|
||||
if (node.type === 'JSXOpeningFragment') {
|
||||
// @ts-expect-error: acorn adds this, but it should not exist.
|
||||
if ('attributes' in node) remove(node, 'attributes')
|
||||
// @ts-expect-error: acorn adds this, but it should not exist.
|
||||
if ('selfClosing' in node) remove(node, 'selfClosing')
|
||||
}
|
||||
|
||||
// Estree.
|
||||
if ('loc' in node) remove(node, 'loc')
|
||||
// @ts-expect-error: `JSXText` types are wrong: `raw` is optional.
|
||||
if ('raw' in node) remove(node, 'raw')
|
||||
|
||||
if (node.type === 'Literal') {
|
||||
// These `value`s on bigint/regex literals represent a raw value,
|
||||
// which is an antipattern.
|
||||
if ('bigint' in node) remove(node, 'value')
|
||||
if ('regex' in node) remove(node, 'value')
|
||||
}
|
||||
}
|
||||
|
||||
if (node.type === 'Literal' && 'bigint' in node) {
|
||||
const bigint = node.bigint
|
||||
const match = /0[box]/.exec(bigint.slice(0, 2).toLowerCase())
|
||||
|
||||
if (match) {
|
||||
const code = match[0].charCodeAt(1)
|
||||
const base =
|
||||
code === 98 /* `x` */ ? 2 : code === 111 /* `o` */ ? 8 : 16
|
||||
node.bigint = Number.parseInt(bigint.slice(2), base).toString()
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-expect-error: `position` is not in `Node`, but we add it anyway
|
||||
// because it’s useful.
|
||||
node.position = position
|
||||
}
|
||||
})
|
||||
|
||||
return esast
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {Nodes} Kind
|
||||
* @param {Kind} value
|
||||
* @param {OptionalKeys<Kind>} key
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function remove(value, key) {
|
||||
delete value[key]
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} _
|
||||
* @param {unknown} value
|
||||
* @returns {unknown}
|
||||
*/
|
||||
function ignoreBigint(_, value) {
|
||||
return typeof value === 'bigint' ? undefined : value
|
||||
}
|
||||
22
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/license
generated
vendored
Normal file
22
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2021 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
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.
|
||||
90
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/package.json
generated
vendored
Normal file
90
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/package.json
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"name": "esast-util-from-estree",
|
||||
"version": "2.0.0",
|
||||
"description": "esast utility to transform from estree",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"esast",
|
||||
"esast-util",
|
||||
"util",
|
||||
"utility",
|
||||
"recma",
|
||||
"esast",
|
||||
"estree",
|
||||
"javascript",
|
||||
"ecmascript",
|
||||
"tree",
|
||||
"ast",
|
||||
"transform"
|
||||
],
|
||||
"repository": "syntax-tree/esast-util-from-estree",
|
||||
"bugs": "https://github.com/syntax-tree/esast-util-from-estree/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"files": [
|
||||
"lib/",
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/estree-jsx": "^1.0.0",
|
||||
"devlop": "^1.0.0",
|
||||
"estree-util-visit": "^2.0.0",
|
||||
"unist-util-position-from-estree": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.0.0",
|
||||
"acorn": "^8.0.0",
|
||||
"acorn-jsx": "^5.0.0",
|
||||
"c8": "^8.0.0",
|
||||
"prettier": "^3.0.0",
|
||||
"remark-cli": "^11.0.0",
|
||||
"remark-preset-wooorm": "^9.0.0",
|
||||
"type-coverage": "^2.0.0",
|
||||
"typescript": "^5.0.0",
|
||||
"xo": "^0.55.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prepack": "npm run build && npm run format",
|
||||
"build": "tsc --build --clean && tsc --build && type-coverage",
|
||||
"format": "remark . -qfo && prettier . -w --log-level warn && xo --fix",
|
||||
"test-api": "node --conditions development test.js",
|
||||
"test-coverage": "c8 --100 --reporter lcov npm run test-api",
|
||||
"test": "npm run build && npm run format && npm run test-coverage"
|
||||
},
|
||||
"prettier": {
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"useTabs": false
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"remark-preset-wooorm"
|
||||
]
|
||||
},
|
||||
"typeCoverage": {
|
||||
"atLeast": 100,
|
||||
"detail": true,
|
||||
"ignoreCatch": true,
|
||||
"strict": true
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"rules": {
|
||||
"unicorn/prefer-at": "off",
|
||||
"unicorn/prefer-code-point": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
237
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/readme.md
generated
vendored
Normal file
237
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/esast-util-from-estree/readme.md
generated
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
# esast-util-from-estree
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
|
||||
[esast][] utility to transform from [estree][].
|
||||
|
||||
## Contents
|
||||
|
||||
* [What is this?](#what-is-this)
|
||||
* [When should I use this?](#when-should-i-use-this)
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`fromEstree(estree[, options])`](#fromestreeestree-options)
|
||||
* [`Options`](#options)
|
||||
* [Types](#types)
|
||||
* [Compatibility](#compatibility)
|
||||
* [Contribute](#contribute)
|
||||
* [License](#license)
|
||||
|
||||
## What is this?
|
||||
|
||||
This package applies some transforms to a cloned, given estree to make it
|
||||
compatible with unist.
|
||||
It:
|
||||
|
||||
* makes sure nodes are plain JSON
|
||||
* adds unist positions
|
||||
* normalizes `.bigint`
|
||||
* remove `attributes`, `selfClosing` from `JSXOpeningFragment`
|
||||
* removes certain discouraged fields
|
||||
|
||||
## When should I use this?
|
||||
|
||||
The transform applied by this utility is often optional: estrees can be used in
|
||||
most places where esast can be used, and vice versa.
|
||||
But, if you come from a unist background and want to deal with JavaScript,
|
||||
or want to use unist utilities with JavaScript, this helps a lot.
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 16+), install with [npm][]:
|
||||
|
||||
```sh
|
||||
npm install esast-util-from-estree
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
|
||||
```js
|
||||
import {fromEstree} from 'https://esm.sh/esast-util-from-estree@2'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import {fromEstree} from 'https://esm.sh/esast-util-from-estree@2?bundle'
|
||||
</script>
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
```js
|
||||
import {parse} from 'acorn'
|
||||
import {fromEstree} from './index.js'
|
||||
|
||||
// Make acorn support comments and positional info.
|
||||
/** @type {Array<import('acorn').Comment>} */
|
||||
const comments = []
|
||||
/** @type {import('estree').Program} */
|
||||
// @ts-expect-error: acorn looks like estree.
|
||||
const estree = parse(
|
||||
'export function x() { /* Something senseless */ console.log(/(?:)/ + 1n) }',
|
||||
{
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 'latest',
|
||||
locations: true,
|
||||
onComment: comments
|
||||
}
|
||||
)
|
||||
estree.comments = comments
|
||||
|
||||
const esast = fromEstree(estree)
|
||||
|
||||
console.log(esast)
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```js
|
||||
{
|
||||
type: 'Program',
|
||||
body: [
|
||||
{
|
||||
type: 'ExportNamedDeclaration',
|
||||
declaration: [Object],
|
||||
specifiers: [],
|
||||
source: null,
|
||||
position: [Object]
|
||||
}
|
||||
],
|
||||
sourceType: 'module',
|
||||
comments: [
|
||||
{
|
||||
type: 'Block',
|
||||
value: ' Something senseless ',
|
||||
position: [Object]
|
||||
}
|
||||
],
|
||||
position: {
|
||||
start: {line: 1, column: 1, offset: 0},
|
||||
end: {line: 1, column: 75, offset: 74}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
This package exports the identifier [`fromEstree`][api-from-estree].
|
||||
There is no default export.
|
||||
|
||||
### `fromEstree(estree[, options])`
|
||||
|
||||
Turn an estree into an esast.
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `estree` ([`EstreeNode`][estree])
|
||||
— estree
|
||||
* `options` ([`Options`][api-options], optional)
|
||||
— configuration
|
||||
|
||||
###### Returns
|
||||
|
||||
Clean clone of `estree` ([`UnistNode`][esast]).
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript Type).
|
||||
|
||||
###### Fields
|
||||
|
||||
* `dirty` (`boolean`, default: `false`)
|
||||
— leave discouraged fields in the tree
|
||||
|
||||
## 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,
|
||||
`esast-util-from-estree@^2`, compatible with Node.js 16.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
|
||||
ways to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definition -->
|
||||
|
||||
[build-badge]: https://github.com/syntax-tree/esast-util-from-estree/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/syntax-tree/esast-util-from-estree/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/esast-util-from-estree.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/esast-util-from-estree
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/esast-util-from-estree.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/esast-util-from-estree
|
||||
|
||||
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=esast-util-from-estree
|
||||
|
||||
[size]: https://bundlejs.com/?q=esast-util-from-estree
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/syntax-tree/unist/discussions
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[health]: https://github.com/syntax-tree/.github
|
||||
|
||||
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[esast]: https://github.com/syntax-tree/esast
|
||||
|
||||
[estree]: https://github.com/estree/estree
|
||||
|
||||
[api-from-estree]: #fromestreeestree-options
|
||||
|
||||
[api-options]: #options
|
||||
1
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/estree-util-visit
generated
vendored
Symbolic link
1
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/estree-util-visit
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../estree-util-visit@2.0.0/node_modules/estree-util-visit
|
||||
1
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/unist-util-position-from-estree
generated
vendored
Symbolic link
1
node_modules/.pnpm/esast-util-from-estree@2.0.0/node_modules/unist-util-position-from-estree
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../../unist-util-position-from-estree@2.0.0/node_modules/unist-util-position-from-estree
|
||||
Reference in New Issue
Block a user