This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

2
node_modules/@mdx-js/react/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { MDXProvider, useMDXComponents } from "./lib/index.js";
//# sourceMappingURL=index.d.ts.map

1
node_modules/@mdx-js/react/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":""}

1
node_modules/@mdx-js/react/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {MDXProvider, useMDXComponents} from './lib/index.js'

44
node_modules/@mdx-js/react/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,44 @@
/**
* Get current components from the MDX Context.
*
* @param {Readonly<MDXComponents> | MergeComponents | null | undefined} [components]
* Additional components to use or a function that creates them (optional).
* @returns {MDXComponents}
* Current components.
*/
export function useMDXComponents(components?: Readonly<MDXComponents> | MergeComponents | null | undefined): MDXComponents;
/**
* Provider for MDX context.
*
* @param {Readonly<Props>} properties
* Properties.
* @returns {JSX.Element}
* Element.
* @satisfies {Component}
*/
export function MDXProvider(properties: Readonly<Props>): JSX.Element;
export type MDXComponents = import('mdx/types.js').MDXComponents;
export type Component = import('react').Component<{}, {}, unknown>;
export type ReactNode = import('react').ReactNode;
/**
* Custom merge function.
*/
export type MergeComponents = (currentComponents: Readonly<MDXComponents>) => MDXComponents;
/**
* Configuration for `MDXProvider`.
*/
export type Props = {
/**
* Children (optional).
*/
children?: ReactNode | null | undefined;
/**
* Additional components to use or a function that creates them (optional).
*/
components?: Readonly<MDXComponents> | MergeComponents | null | undefined;
/**
* Turn off outer component context (default: `false`).
*/
disableParentContext?: boolean | null | undefined;
};
//# sourceMappingURL=index.d.ts.map

1
node_modules/@mdx-js/react/lib/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AA+BA;;;;;;;GAOG;AACH,8CALW,SAAS,aAAa,CAAC,GAAG,eAAe,GAAG,IAAI,GAAG,SAAS,GAE1D,aAAa,CAkBzB;AAED;;;;;;;;GAQG;AACH,wCANW,SAAS,KAAK,CAAC,GAEb,WAAW,CAsBvB;4BAlFY,OAAO,cAAc,EAAE,aAAa;wBACpC,OAAO,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC;wBAC1C,OAAO,OAAO,EAAE,SAAS;;;;kDAM3B,SAAS,aAAa,CAAC,KAErB,aAAa;;;;;;;;eAKZ,SAAS,GAAG,IAAI,GAAG,SAAS;;;;iBAE5B,SAAS,aAAa,CAAC,GAAG,eAAe,GAAG,IAAI,GAAG,SAAS;;;;2BAE5D,OAAO,GAAG,IAAI,GAAG,SAAS"}

84
node_modules/@mdx-js/react/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,84 @@
/**
* @typedef {import('mdx/types.js').MDXComponents} MDXComponents
* @typedef {import('react').Component<{}, {}, unknown>} Component
* @typedef {import('react').ReactNode} ReactNode
*/
/**
* @callback MergeComponents
* Custom merge function.
* @param {Readonly<MDXComponents>} currentComponents
* Current components from the context.
* @returns {MDXComponents}
* Additional components.
*
* @typedef Props
* Configuration for `MDXProvider`.
* @property {ReactNode | null | undefined} [children]
* Children (optional).
* @property {Readonly<MDXComponents> | MergeComponents | null | undefined} [components]
* Additional components to use or a function that creates them (optional).
* @property {boolean | null | undefined} [disableParentContext=false]
* Turn off outer component context (default: `false`).
*/
import React from 'react'
/** @type {Readonly<MDXComponents>} */
const emptyComponents = {}
const MDXContext = React.createContext(emptyComponents)
/**
* Get current components from the MDX Context.
*
* @param {Readonly<MDXComponents> | MergeComponents | null | undefined} [components]
* Additional components to use or a function that creates them (optional).
* @returns {MDXComponents}
* Current components.
*/
export function useMDXComponents(components) {
const contextComponents = React.useContext(MDXContext)
// Memoize to avoid unnecessary top-level context changes
return React.useMemo(
function () {
// Custom merge via a function prop
if (typeof components === 'function') {
return components(contextComponents)
}
return {...contextComponents, ...components}
},
[contextComponents, components]
)
}
/**
* Provider for MDX context.
*
* @param {Readonly<Props>} properties
* Properties.
* @returns {JSX.Element}
* Element.
* @satisfies {Component}
*/
export function MDXProvider(properties) {
/** @type {Readonly<MDXComponents>} */
let allComponents
if (properties.disableParentContext) {
allComponents =
typeof properties.components === 'function'
? properties.components(emptyComponents)
: properties.components || emptyComponents
} else {
allComponents = useMDXComponents(properties.components)
}
return React.createElement(
MDXContext.Provider,
{value: allComponents},
properties.children
)
}

21
node_modules/@mdx-js/react/license generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 Compositor and Vercel, Inc.
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.

73
node_modules/@mdx-js/react/package.json generated vendored Normal file
View File

@@ -0,0 +1,73 @@
{
"name": "@mdx-js/react",
"version": "3.0.1",
"description": "React context for MDX",
"license": "MIT",
"keywords": [
"jsx",
"markdown",
"mdx",
"react",
"remark"
],
"homepage": "https://mdxjs.com",
"repository": {
"type": "git",
"url": "https://github.com/mdx-js/mdx",
"directory": "packages/react/"
},
"bugs": "https://github.com/mdx-js/mdx/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "John Otander <johnotander@gmail.com> (https://johno.com)",
"contributors": [
"John Otander <johnotander@gmail.com> (https://johno.com)",
"Tim Neutkens <tim@vercel.com>",
"Matija Marohnić <matija.marohnic@gmail.com>",
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"JounQin <admin@1stg.me> (https://www.1stg.me)",
"Christian Murphy <christian.murphy.42@gmail.com>"
],
"type": "module",
"sideEffects": false,
"exports": "./index.js",
"files": [
"lib/",
"index.d.ts.map",
"index.d.ts",
"index.js"
],
"dependencies": {
"@types/mdx": "^2.0.0"
},
"peerDependencies": {
"@types/react": ">=16",
"react": ">=16"
},
"devDependencies": {},
"scripts": {
"test": "npm run test-coverage",
"test-api": "node --conditions development --loader=../../script/jsx-loader.js test/index.jsx",
"test-coverage": "c8 --100 --reporter lcov npm run test-api"
},
"xo": {
"overrides": [
{
"extends": "xo-react",
"files": [
"**/*.jsx"
],
"rules": {
"react/jsx-no-bind": "off",
"react/react-in-jsx-scope": "off"
}
}
],
"prettier": true,
"rules": {
"n/file-extension-in-import": "off"
}
}
}

271
node_modules/@mdx-js/react/readme.md generated vendored Normal file
View File

@@ -0,0 +1,271 @@
# `@mdx-js/react`
[![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]
React context for MDX.
<!-- more -->
## Contents
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`MDXProvider(properties?)`](#mdxproviderproperties)
* [`useMDXComponents(components?)`](#usemdxcomponentscomponents)
* [`MergeComponents`](#mergecomponents)
* [`Props`](#props)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Contribute](#contribute)
* [License](#license)
## What is this?
This package is a *context* based components provider for combining React with
MDX.
## When should I use this?
This package is **not needed** for MDX to work with React.
See [¶ MDX provider in § Using MDX][use-provider] for when and how to use an MDX
provider.
If you use Next.js, **do not use this**.
Add an `mdx-components.tsx` (in `src/` or `/`) file instead.
See [Configuring MDX on `nextjs.org`][next-configuring-mdx] for more info.
## Install
This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:
```sh
npm install @mdx-js/react
```
In Deno with [`esm.sh`][esmsh]:
```tsx
import {MDXProvider} from 'https://esm.sh/@mdx-js/react@3'
```
In browsers with [`esm.sh`][esmsh]:
```html
<script type="module">
import {MDXProvider} from 'https://esm.sh/@mdx-js/react@3?bundle'
</script>
```
## Use
```tsx
import {MDXProvider} from '@mdx-js/react'
import Post from './post.mdx'
// ^-- Assumes an integration is used to compile MDX to JS, such as
// `@mdx-js/esbuild`, `@mdx-js/loader`, `@mdx-js/node-loader`, or
// `@mdx-js/rollup`, and that it is configured with
// `options.providerImportSource: '@mdx-js/react'`.
/** @type {import('mdx/types.js').MDXComponents} */
const components = {
em(properties) {
return <i {...properties} />
}
}
console.log(
<MDXProvider components={components}>
<Post />
</MDXProvider>
)
```
> 👉 **Note**: you dont have to use `MDXProvider` and can pass components
> directly:
>
> ```diff
> -<MDXProvider components={components}>
> - <Post />
> -</MDXProvider>
> +<Post components={components} />
> ```
See [¶ React in § Getting started][start-react] for how to get started with MDX
and React.
See [¶ MDX provider in § Using MDX][use-provider] for how to use an MDX
provider.
## API
This package exports the identifiers [`MDXProvider`][api-mdx-provider] and
[`useMDXComponents`][api-use-mdx-components].
There is no default export.
### `MDXProvider(properties?)`
Provider for MDX context.
###### Parameters
* `properties` ([`Props`][api-props])
— configuration
##### Returns
Element (`JSX.Element`).
### `useMDXComponents(components?)`
Get current components from the MDX Context.
###### Parameters
* `components` ([`MDXComponents` from `mdx/types.js`][mdx-types-components]
or [`MergeComponents`][api-merge-components], optional)
— additional components to use or a function that creates them
###### Returns
Current components ([`MDXComponents` from
`mdx/types.js`][mdx-types-components]).
### `MergeComponents`
Custom merge function (TypeScript type).
###### Parameters
* `components` ([`MDXComponents` from `mdx/types.js`][mdx-types-components])
— current components from the context
###### Returns
Additional components ([`MDXComponents` from
`mdx/types.js`][mdx-types-components]).
### `Props`
Configuration for `MDXProvider` (TypeScript type).
###### Fields
* `children` ([`ReactNode` from `react`][react-node],
optional)
— children
* `components` ([`MDXComponents` from `mdx/types.js`][mdx-types-components]
or [`MergeComponents`][api-merge-components], optional)
— additional components to use or a function that creates them
* `disableParentContext` (`boolean`, default: `false`)
— turn off outer component context
## Types
This package is fully typed with [TypeScript][].
It exports the additional types [`MergeComponents`][api-merge-components] and
[`Props`][api-props].
For types to work, make sure the TypeScript `JSX` namespace is typed.
This is done by installing and using the types of your framework, as in
[`@types/react`](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react).
## 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, `@mdx-js/react@^3`,
compatible with Node.js 16.
## Security
See [§ Security][security] on our website for information.
## Contribute
See [§ Contribute][contribute] on our website for ways to get started.
See [§ Support][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][] © Compositor and [Vercel][]
[build-badge]: https://github.com/mdx-js/mdx/workflows/main/badge.svg
[build]: https://github.com/mdx-js/mdx/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/mdx-js/mdx/main.svg
[coverage]: https://codecov.io/github/mdx-js/mdx
[downloads-badge]: https://img.shields.io/npm/dm/@mdx-js/react.svg
[downloads]: https://www.npmjs.com/package/@mdx-js/react
[size-badge]: https://img.shields.io/bundlejs/size/@mdx-js/react
[size]: https://bundlejs.com/?q=@mdx-js/react
[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/mdx-js/mdx/discussions
[npm]: https://docs.npmjs.com/cli/install
[contribute]: https://mdxjs.com/community/contribute/
[support]: https://mdxjs.com/community/support/
[coc]: https://github.com/mdx-js/.github/blob/main/code-of-conduct.md
[mit]: https://github.com/mdx-js/mdx/blob/main/packages/react/license
[vercel]: https://vercel.com
[start-react]: https://mdxjs.com/getting-started/#react
[use-provider]: https://mdxjs.com/docs/using-mdx/#mdx-provider
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esmsh]: https://esm.sh
[security]: https://mdxjs.com/getting-started/#security
[typescript]: https://www.typescriptlang.org
[mdx-types-components]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/HEAD/types/mdx/types.d.ts#L65
[react-node]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/HEAD/types/react/index.d.ts#L244
[next-configuring-mdx]: https://nextjs.org/docs/pages/building-your-application/configuring/mdx
[api-mdx-provider]: #mdxproviderproperties
[api-merge-components]: #mergecomponents
[api-props]: #props
[api-use-mdx-components]: #usemdxcomponentscomponents