-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
101 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
coverage/ | ||
node_modules/ | ||
index.d.ts | ||
test.d.ts | ||
*.d.ts | ||
*.log | ||
.DS_Store | ||
yarn.lock | ||
!/complex-types.d.ts | ||
!/index.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import type { | ||
Node as MdastNode, | ||
Parent as MdastParent, | ||
Literal as MdastLiteral, | ||
BlockContent, | ||
PhrasingContent | ||
} from 'mdast' | ||
import type {Program} from 'estree-jsx' | ||
|
||
// Expose JavaScript API. | ||
export {mdxJsxFromMarkdown, mdxJsxToMarkdown} from './lib/index.js' | ||
|
||
// Expose options. | ||
export type {ToMarkdownOptions} from './lib/index.js' | ||
|
||
// Expose node types. | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export interface MdxJsxAttributeValueExpression extends MdastLiteral { | ||
type: 'mdxJsxAttributeValueExpression' | ||
data?: {estree?: Program} & MdastLiteral['data'] | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export interface MdxJsxExpressionAttribute extends MdastLiteral { | ||
type: 'mdxJsxExpressionAttribute' | ||
data?: {estree?: Program} & MdastLiteral['data'] | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export interface MdxJsxAttribute extends MdastNode { | ||
type: 'mdxJsxAttribute' | ||
name: string | ||
value?: MdxJsxAttributeValueExpression | string | null | undefined | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface MdxJsxElementFields { | ||
name: string | null | ||
attributes: Array<MdxJsxAttribute | MdxJsxExpressionAttribute> | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export interface MdxJsxFlowElement extends MdxJsxElementFields, MdastParent { | ||
type: 'mdxJsxFlowElement' | ||
children: BlockContent[] | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export interface MdxJsxTextElement extends MdxJsxElementFields, MdastParent { | ||
type: 'mdxJsxTextElement' | ||
children: PhrasingContent[] | ||
} | ||
|
||
// Add nodes to mdast content. | ||
declare module 'mdast' { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface StaticPhrasingContentMap { | ||
mdxJsxTextElement: MdxJsxTextElement | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface BlockContentMap { | ||
mdxJsxFlowElement: MdxJsxFlowElement | ||
} | ||
} | ||
|
||
// Add nodes to hast content. | ||
declare module 'hast' { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface RootContentMap { | ||
mdxJsxTextElement: MdxJsxTextElement | ||
mdxJsxFlowElement: MdxJsxFlowElement | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface ElementContentMap { | ||
mdxJsxTextElement: MdxJsxTextElement | ||
mdxJsxFlowElement: MdxJsxFlowElement | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
/** | ||
* @typedef {import('./lib/index.js').MdxJsxAttributeValueExpression} MdxJsxAttributeValueExpression | ||
* @typedef {import('./lib/index.js').MdxJsxAttribute} MdxJsxAttribute | ||
* @typedef {import('./lib/index.js').MdxJsxExpressionAttribute} MdxJsxExpressionAttribute | ||
* @typedef {import('./lib/index.js').MdxJsxFlowElement} MdxJsxFlowElement | ||
* @typedef {import('./lib/index.js').MdxJsxTextElement} MdxJsxTextElement | ||
* @typedef {import('./lib/index.js').ToMarkdownOptions} ToMarkdownOptions | ||
*/ | ||
|
||
// Note: types exposed from `index.d.ts`. | ||
export {mdxJsxFromMarkdown, mdxJsxToMarkdown} from './lib/index.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,11 @@ | ||
import type {Node} from 'unist' | ||
import type {Parent, Literal, BlockContent, PhrasingContent} from 'mdast' | ||
import type {Program} from 'estree-jsx' | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export interface MdxJsxAttributeValueExpression extends Literal { | ||
type: 'mdxJsxAttributeValueExpression' | ||
data?: {estree?: Program} & Literal['data'] | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export interface MdxJsxAttribute extends Node { | ||
type: 'mdxJsxAttribute' | ||
name: string | ||
value?: MdxJsxAttributeValueExpression | string | null | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export interface MdxJsxExpressionAttribute extends Literal { | ||
type: 'mdxJsxExpressionAttribute' | ||
data?: {estree?: Program} & Literal['data'] | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface MdxJsxElementFields { | ||
name: string | null | ||
attributes: Array<MdxJsxAttribute | MdxJsxExpressionAttribute> | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export interface MdxJsxFlowElement extends MdxJsxElementFields, Parent { | ||
type: 'mdxJsxFlowElement' | ||
children: BlockContent[] | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export interface MdxJsxTextElement extends MdxJsxElementFields, Parent { | ||
type: 'mdxJsxTextElement' | ||
children: PhrasingContent[] | ||
} | ||
|
||
declare module 'mdast' { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface StaticPhrasingContentMap { | ||
mdxJsxTextElement: MdxJsxTextElement | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface BlockContentMap { | ||
mdxJsxFlowElement: MdxJsxFlowElement | ||
} | ||
} | ||
|
||
declare module 'hast' { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface RootContentMap { | ||
mdxJsxTextElement: MdxJsxTextElement | ||
mdxJsxFlowElement: MdxJsxFlowElement | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface ElementContentMap { | ||
mdxJsxTextElement: MdxJsxTextElement | ||
mdxJsxFlowElement: MdxJsxFlowElement | ||
} | ||
} | ||
// To do: next major: remove this file. | ||
export type { | ||
MdxJsxAttributeValueExpression, | ||
MdxJsxAttribute, | ||
MdxJsxExpressionAttribute, | ||
MdxJsxFlowElement, | ||
MdxJsxTextElement, | ||
ToMarkdownOptions | ||
} from '../index.js' | ||
|
||
/// <reference types="../index.js" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters