@mdx-js/mdx
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -14,1 +14,2 @@ export { createProcessor } from "./lib/core.js"; | ||
export { run, runSync } from "./lib/run.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -50,1 +50,2 @@ /** | ||
export type CompileOptions = CoreProcessorOptions & ExtraOptions; | ||
//# sourceMappingURL=compile.d.ts.map |
@@ -173,6 +173,7 @@ /** | ||
/** | ||
* Turn obsolete `align` props on `td` and `th` into CSS `style` props | ||
* (default: `true`). | ||
* Turn obsolete `align` properties on `td` and `th` into CSS `style` | ||
* properties (default: `true`). | ||
*/ | ||
tableCellAlignToStyle?: boolean | null | undefined; | ||
}; | ||
//# sourceMappingURL=core.d.ts.map |
@@ -124,4 +124,4 @@ /** | ||
* @property {boolean | null | undefined} [tableCellAlignToStyle=true] | ||
* Turn obsolete `align` props on `td` and `th` into CSS `style` props | ||
* (default: `true`). | ||
* Turn obsolete `align` properties on `td` and `th` into CSS `style` | ||
* properties (default: `true`). | ||
*/ | ||
@@ -128,0 +128,0 @@ |
@@ -56,1 +56,2 @@ /** | ||
export type EvaluateOptions = import('./util/resolve-evaluate-options.js').EvaluateOptions; | ||
//# sourceMappingURL=evaluate.d.ts.map |
@@ -6,1 +6,2 @@ /** | ||
export const nodeTypes: readonly ["mdxFlowExpression", "mdxJsxFlowElement", "mdxJsxTextElement", "mdxTextExpression", "mdxjsEsm"]; | ||
//# sourceMappingURL=node-types.d.ts.map |
@@ -36,1 +36,2 @@ /** | ||
export type ProcessorOptions = import('../core.js').ProcessorOptions; | ||
//# sourceMappingURL=recma-document.d.ts.map |
@@ -76,4 +76,2 @@ /** | ||
const replacement = [] | ||
/** @type {Array<string>} */ | ||
const pragmas = [] | ||
let exportAllCount = 0 | ||
@@ -87,27 +85,16 @@ /** @type {ExportDefaultDeclaration | ExportSpecifier | undefined} */ | ||
if (jsxRuntime) { | ||
pragmas.push('@jsxRuntime ' + jsxRuntime) | ||
if (jsxRuntime === 'classic' && pragmaFrag) { | ||
injectPragma(tree, '@jsxFrag', pragmaFrag) | ||
} | ||
if (jsxRuntime === 'automatic' && jsxImportSource) { | ||
pragmas.push('@jsxImportSource ' + jsxImportSource) | ||
} | ||
if (jsxRuntime === 'classic' && pragma) { | ||
pragmas.push('@jsx ' + pragma) | ||
injectPragma(tree, '@jsx', pragma) | ||
} | ||
if (jsxRuntime === 'classic' && pragmaFrag) { | ||
pragmas.push('@jsxFrag ' + pragmaFrag) | ||
if (jsxRuntime === 'automatic' && jsxImportSource) { | ||
injectPragma(tree, '@jsxImportSource', jsxImportSource) | ||
} | ||
/* c8 ignore next -- comments can be missing in the types, we always have it. */ | ||
if (!tree.comments) tree.comments = [] | ||
if (pragmas.length > 0) { | ||
tree.comments.unshift({ | ||
type: 'Block', | ||
value: pragmas.join(' '), | ||
data: {_mdxIsPragmaComment: true} | ||
}) | ||
if (jsxRuntime) { | ||
injectPragma(tree, '@jsxRuntime', jsxRuntime) | ||
} | ||
@@ -138,3 +125,3 @@ | ||
// ```tsx | ||
// export default props => <>{props.children}</> | ||
// export default properties => <>{properties.children}</> | ||
// ``` | ||
@@ -309,3 +296,3 @@ // | ||
/** @type {Property} */ | ||
const prop = { | ||
const property = { | ||
type: 'Property', | ||
@@ -326,3 +313,3 @@ kind: 'init', | ||
return prop | ||
return property | ||
}) | ||
@@ -715,2 +702,16 @@ ] | ||
/** | ||
* @param {Program} tree | ||
* @param {string} name | ||
* @param {string} value | ||
* @returns {undefined} | ||
*/ | ||
function injectPragma(tree, name, value) { | ||
tree.comments?.unshift({ | ||
type: 'Block', | ||
value: name + ' ' + value, | ||
data: {_mdxIsPragmaComment: true} | ||
}) | ||
} | ||
/** | ||
* @param {Expression} importMetaUrl | ||
@@ -717,0 +718,0 @@ * @returns {FunctionDeclaration} |
@@ -28,1 +28,2 @@ /** | ||
export type Options = BuildJsxOptions & ExtraOptions; | ||
//# sourceMappingURL=recma-jsx-build.d.ts.map |
@@ -48,9 +48,6 @@ /** | ||
// needed. | ||
if ( | ||
tree.comments && | ||
tree.comments[0].type === 'Block' && | ||
tree.comments[0].data && | ||
tree.comments[0].data._mdxIsPragmaComment | ||
) { | ||
tree.comments.shift() | ||
if (tree.comments) { | ||
tree.comments = tree.comments.filter(function (d) { | ||
return !d.data?._mdxIsPragmaComment | ||
}) | ||
} | ||
@@ -57,0 +54,0 @@ |
@@ -68,1 +68,2 @@ /** | ||
}; | ||
//# sourceMappingURL=recma-jsx-rewrite.d.ts.map |
@@ -82,3 +82,3 @@ /** | ||
/** @type {Array<StackEntry>} */ | ||
const fnStack = [] | ||
const functionStack = [] | ||
let importProvider = false | ||
@@ -101,3 +101,3 @@ let createErrorHelper = false | ||
) { | ||
fnStack.push({ | ||
functionStack.push({ | ||
components: [], | ||
@@ -117,10 +117,10 @@ idToInvalidComponentName: new Map(), | ||
) { | ||
fnStack[0].components.push('MDXLayout') | ||
functionStack[0].components.push('MDXLayout') | ||
} | ||
} | ||
const fnScope = fnStack[0] | ||
const functionScope = functionStack[0] | ||
if ( | ||
!fnScope || | ||
(!isNamedFunction(fnScope.node, '_createMdxContent') && | ||
!functionScope || | ||
(!isNamedFunction(functionScope.node, '_createMdxContent') && | ||
!providerImportSource) | ||
@@ -156,3 +156,3 @@ ) { | ||
if (!Object.hasOwn(fnScope.references, fullId)) { | ||
if (!Object.hasOwn(functionScope.references, fullId)) { | ||
// Cast because we match `node`. | ||
@@ -170,8 +170,8 @@ const parentScope = /** @type {Scope | undefined} */ ( | ||
) { | ||
fnScope.references[fullId] = {component: true, node} | ||
functionScope.references[fullId] = {component: true, node} | ||
} | ||
} | ||
if (!fnScope.objects.includes(id) && !isInScope) { | ||
fnScope.objects.push(id) | ||
if (!functionScope.objects.includes(id) && !isInScope) { | ||
functionScope.objects.push(id) | ||
} | ||
@@ -195,9 +195,9 @@ } | ||
id !== 'MDXLayout' && | ||
!Object.hasOwn(fnScope.references, id) | ||
!Object.hasOwn(functionScope.references, id) | ||
) { | ||
fnScope.references[id] = {component: true, node} | ||
functionScope.references[id] = {component: true, node} | ||
} | ||
if (!fnScope.components.includes(id)) { | ||
fnScope.components.push(id) | ||
if (!functionScope.components.includes(id)) { | ||
functionScope.components.push(id) | ||
} | ||
@@ -212,4 +212,4 @@ } | ||
if (!fnScope.tags.includes(id)) { | ||
fnScope.tags.push(id) | ||
if (!functionScope.tags.includes(id)) { | ||
functionScope.tags.push(id) | ||
} | ||
@@ -221,6 +221,9 @@ | ||
let invalidComponentName = | ||
fnScope.idToInvalidComponentName.get(id) | ||
functionScope.idToInvalidComponentName.get(id) | ||
if (invalidComponentName === undefined) { | ||
invalidComponentName = `_component${fnScope.idToInvalidComponentName.size}` | ||
fnScope.idToInvalidComponentName.set(id, invalidComponentName) | ||
invalidComponentName = `_component${functionScope.idToInvalidComponentName.size}` | ||
functionScope.idToInvalidComponentName.set( | ||
id, | ||
invalidComponentName | ||
) | ||
} | ||
@@ -261,4 +264,4 @@ | ||
) { | ||
const fn = node | ||
const scope = fnStack[fnStack.length - 1] | ||
const scopeNode = node | ||
const scope = functionStack[functionStack.length - 1] | ||
/** @type {string} */ | ||
@@ -485,13 +488,13 @@ let name | ||
// Arrow functions with an implied return: | ||
if (fn.body.type !== 'BlockStatement') { | ||
fn.body = { | ||
if (scopeNode.body.type !== 'BlockStatement') { | ||
scopeNode.body = { | ||
type: 'BlockStatement', | ||
body: [{type: 'ReturnStatement', argument: fn.body}] | ||
body: [{type: 'ReturnStatement', argument: scopeNode.body}] | ||
} | ||
} | ||
fn.body.body.unshift(...statements) | ||
scopeNode.body.body.unshift(...statements) | ||
} | ||
fnStack.pop() | ||
functionStack.pop() | ||
} | ||
@@ -498,0 +501,0 @@ } |
@@ -6,1 +6,2 @@ export function recmaStringify(this: import("unified").Processor<undefined, undefined, undefined, undefined, undefined>, parameters_0: Readonly<import("../core.js").ProcessorOptions>): void | undefined; | ||
export type ProcessorOptions = import('../core.js').ProcessorOptions; | ||
//# sourceMappingURL=recma-stringify.d.ts.map |
@@ -14,1 +14,2 @@ /** | ||
export type ProcessorOptions = import('../core.js').ProcessorOptions; | ||
//# sourceMappingURL=rehype-recma.d.ts.map |
@@ -12,1 +12,2 @@ /** | ||
export type Root = import('hast').Root; | ||
//# sourceMappingURL=rehype-remove-raw.d.ts.map |
@@ -14,1 +14,2 @@ /** | ||
export type RootContent = import('mdast').RootContent; | ||
//# sourceMappingURL=remark-mark-and-unravel.d.ts.map |
@@ -37,1 +37,2 @@ /** | ||
export type RunOptions = import('./util/resolve-evaluate-options.js').RunOptions; | ||
//# sourceMappingURL=run.d.ts.map |
@@ -33,1 +33,2 @@ /** | ||
export type Process = (vfileCompatible: Compatible) => Promise<VFile>; | ||
//# sourceMappingURL=create-format-aware-processors.d.ts.map |
@@ -52,4 +52,4 @@ /** | ||
: compileOptions_.format === 'mdx' | ||
? mdxExtensions | ||
: [...mdExtensions, ...mdxExtensions], | ||
? mdxExtensions | ||
: [...mdExtensions, ...mdxExtensions], | ||
process | ||
@@ -56,0 +56,0 @@ } |
@@ -11,1 +11,2 @@ /** | ||
export type Node = import('estree-jsx').Node; | ||
//# sourceMappingURL=estree-util-create.d.ts.map |
@@ -8,3 +8,3 @@ /** | ||
* | ||
* @param {Readonly<Declaration>} declaration | ||
* @param {Readonly<Declaration | MaybeNamedClassDeclaration | MaybeNamedFunctionDeclaration>} declaration | ||
* Declaration. | ||
@@ -14,4 +14,7 @@ * @returns {Expression} | ||
*/ | ||
export function declarationToExpression(declaration: Readonly<Declaration>): Expression; | ||
export function declarationToExpression(declaration: Readonly<Declaration | MaybeNamedClassDeclaration | MaybeNamedFunctionDeclaration>): Expression; | ||
export type Declaration = import('estree-jsx').Declaration; | ||
export type Expression = import('estree-jsx').Expression; | ||
export type MaybeNamedClassDeclaration = import('estree-jsx').MaybeNamedClassDeclaration; | ||
export type MaybeNamedFunctionDeclaration = import('estree-jsx').MaybeNamedFunctionDeclaration; | ||
//# sourceMappingURL=estree-util-declaration-to-expression.d.ts.map |
/** | ||
* @typedef {import('estree-jsx').Declaration} Declaration | ||
* @typedef {import('estree-jsx').Expression} Expression | ||
* @typedef {import('estree-jsx').MaybeNamedClassDeclaration} MaybeNamedClassDeclaration | ||
* @typedef {import('estree-jsx').MaybeNamedFunctionDeclaration} MaybeNamedFunctionDeclaration | ||
*/ | ||
@@ -15,3 +17,3 @@ | ||
* | ||
* @param {Readonly<Declaration>} declaration | ||
* @param {Readonly<Declaration | MaybeNamedClassDeclaration | MaybeNamedFunctionDeclaration>} declaration | ||
* Declaration. | ||
@@ -18,0 +20,0 @@ * @returns {Expression} |
/** | ||
* Check if `node` is a declaration. | ||
* | ||
* @param {Readonly<Node>} node | ||
* @param {Readonly<MaybeNamedClassDeclaration | MaybeNamedFunctionDeclaration | Node>} node | ||
* Node to check. | ||
* @returns {node is Declaration} | ||
* @returns {node is Declaration | MaybeNamedClassDeclaration | MaybeNamedFunctionDeclaration} | ||
* Whether `node` is a declaration. | ||
*/ | ||
export function isDeclaration(node: Readonly<Node>): node is import("estree").Declaration; | ||
export function isDeclaration(node: Readonly<MaybeNamedClassDeclaration | MaybeNamedFunctionDeclaration | Node>): node is import("estree").MaybeNamedClassDeclaration | import("estree").MaybeNamedFunctionDeclaration | import("estree").Declaration; | ||
export type Declaration = import('estree-jsx').Declaration; | ||
export type MaybeNamedClassDeclaration = import('estree-jsx').MaybeNamedClassDeclaration; | ||
export type MaybeNamedFunctionDeclaration = import('estree-jsx').MaybeNamedFunctionDeclaration; | ||
export type Node = import('estree-jsx').Node; | ||
//# sourceMappingURL=estree-util-is-declaration.d.ts.map |
/** | ||
* @typedef {import('estree-jsx').Declaration} Declaration | ||
* @typedef {import('estree-jsx').MaybeNamedClassDeclaration} MaybeNamedClassDeclaration | ||
* @typedef {import('estree-jsx').MaybeNamedFunctionDeclaration} MaybeNamedFunctionDeclaration | ||
* @typedef {import('estree-jsx').Node} Node | ||
@@ -12,5 +14,5 @@ */ | ||
* | ||
* @param {Readonly<Node>} node | ||
* @param {Readonly<MaybeNamedClassDeclaration | MaybeNamedFunctionDeclaration | Node>} node | ||
* Node to check. | ||
* @returns {node is Declaration} | ||
* @returns {node is Declaration | MaybeNamedClassDeclaration | MaybeNamedFunctionDeclaration} | ||
* Whether `node` is a declaration. | ||
@@ -17,0 +19,0 @@ */ |
@@ -18,1 +18,2 @@ /** | ||
export type VariableDeclarator = import('estree-jsx').VariableDeclarator; | ||
//# sourceMappingURL=estree-util-specifiers-to-declarations.d.ts.map |
@@ -63,4 +63,4 @@ /** | ||
: specifier.type === 'ExportSpecifier' | ||
? specifier.exported | ||
: {type: 'Identifier', name: 'default'} | ||
? specifier.exported | ||
: {type: 'Identifier', name: 'default'} | ||
let value = specifier.local | ||
@@ -67,0 +67,0 @@ |
@@ -9,1 +9,2 @@ /** | ||
export type Expression = import('estree-jsx').Expression; | ||
//# sourceMappingURL=estree-util-to-binary-addition.d.ts.map |
@@ -20,1 +20,2 @@ /** | ||
export type MemberExpression = import('estree-jsx').MemberExpression; | ||
//# sourceMappingURL=estree-util-to-id-or-member-expression.d.ts.map |
@@ -10,1 +10,2 @@ /** | ||
export function extnamesToRegex(extnames: ReadonlyArray<string>): RegExp; | ||
//# sourceMappingURL=extnames-to-regex.d.ts.map |
export const md: string[]; | ||
export const mdx: string[]; | ||
//# sourceMappingURL=extnames.d.ts.map |
@@ -71,1 +71,2 @@ /** | ||
export type UseMdxComponents = () => Components; | ||
//# sourceMappingURL=resolve-evaluate-options.d.ts.map |
@@ -20,1 +20,2 @@ /** | ||
import { VFile } from 'vfile'; | ||
//# sourceMappingURL=resolve-file-and-options.d.ts.map |
@@ -33,4 +33,4 @@ /** | ||
: file.extname && (rest.mdExtensions || md).includes(file.extname) | ||
? 'md' | ||
: 'mdx', | ||
? 'md' | ||
: 'mdx', | ||
...rest | ||
@@ -37,0 +37,0 @@ } |
{ | ||
"name": "@mdx-js/mdx", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "MDX compiler", | ||
@@ -37,7 +37,7 @@ "license": "MIT", | ||
"./internal-create-format-aware-processors": "./lib/util/create-format-aware-processors.js", | ||
"./internal-extnames-to-regex": "./lib/util/extnames-to-regex.js", | ||
"./internal-resolve-evaluate-options": "./lib/util/resolve-evaluate-options.js" | ||
"./internal-extnames-to-regex": "./lib/util/extnames-to-regex.js" | ||
}, | ||
"files": [ | ||
"lib/", | ||
"index.d.ts.map", | ||
"index.d.ts", | ||
@@ -80,2 +80,10 @@ "index.js" | ||
"files": [ | ||
"test/**/*.js" | ||
], | ||
"rules": { | ||
"no-restricted-globals": "off" | ||
} | ||
}, | ||
{ | ||
"files": [ | ||
"**/*.ts" | ||
@@ -93,2 +101,3 @@ ], | ||
"complexity": "off", | ||
"logical-assignment-operators": "off", | ||
"max-depth": "off", | ||
@@ -95,0 +104,0 @@ "n/file-extension-in-import": "off", |
@@ -70,3 +70,3 @@ # `@mdx-js/mdx` | ||
```tsx | ||
import {compile} from 'https://esm.sh/@mdx-js/mdx@2' | ||
import {compile} from 'https://esm.sh/@mdx-js/mdx@3' | ||
``` | ||
@@ -78,3 +78,3 @@ | ||
<script type="module"> | ||
import {compile} from 'https://esm.sh/@mdx-js/mdx@2?bundle' | ||
import {compile} from 'https://esm.sh/@mdx-js/mdx@3?bundle' | ||
</script> | ||
@@ -449,4 +449,4 @@ ``` | ||
— element type: `Fragment` symbol, tag name (`string`), component | ||
* `props` (`Props`) | ||
— element props and `children` | ||
* `properties` (`Properties`) | ||
— element properties and `children` | ||
* `key` (`string` or `undefined`) | ||
@@ -467,4 +467,4 @@ — key to use | ||
— element type: `Fragment` symbol, tag name (`string`), component | ||
* `props` (`Props`) | ||
— element props and `children` | ||
* `properties` (`Properties`) | ||
— element properties and `children` | ||
* `key` (`string` or `undefined`) | ||
@@ -660,3 +660,4 @@ — key to use | ||
-import {Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs} from 'react/jsx-runtime' | ||
+/* @jsxRuntime automatic @jsxImportSource react */ | ||
+/*@jsxRuntime automatic*/ | ||
+/*@jsxImportSource react*/ | ||
@@ -990,3 +991,4 @@ export function Thing() { | ||
* `tableCellAlignToStyle` (`boolean`, default: `true`) | ||
— turn obsolete `align` props on `td` and `th` into CSS `style` props | ||
— turn obsolete `align` properties on `td` and `th` into CSS `style` | ||
properties | ||
@@ -993,0 +995,0 @@ ### `RunOptions` |
No License Found
License(Experimental) License information could not be found
Found 1 instance in 1 package
175140
76
0
3338
1311