@readme/markdown 7.14.0 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +59 -4
- package/dist/main.node.js +59 -4
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -78583,14 +78583,69 @@ const compile_compile = (text, _a = {}) => {
|
|
|
78583
78583
|
|
|
78584
78584
|
|
|
78585
78585
|
|
|
78586
|
-
|
|
78586
|
+
/* Example mdast structures to find first export name in a mdxjsEsm node:
|
|
78587
|
+
There are three types of export declarations that we need to consider:
|
|
78588
|
+
1. VARIABLE DECLARATION
|
|
78589
|
+
"type": "mdxjsEsm",
|
|
78590
|
+
"value": "export const Foo = () => <div>Hello world</div>\nexport const Bar = () => <div>hello darkness my old friend</div>",
|
|
78591
|
+
"data": {
|
|
78592
|
+
"estree": {
|
|
78593
|
+
"type": "Program",
|
|
78594
|
+
"body": [
|
|
78595
|
+
{
|
|
78596
|
+
"type": "ExportNamedDeclaration",
|
|
78597
|
+
"declaration": {
|
|
78598
|
+
"type": "VariableDeclaration",
|
|
78599
|
+
"declarations": [
|
|
78600
|
+
{
|
|
78601
|
+
"type": "VariableDeclarator",
|
|
78602
|
+
"id": {
|
|
78603
|
+
"type": "Identifier",
|
|
78604
|
+
"name": "Foo" // --------> This is the export name
|
|
78605
|
+
},
|
|
78606
|
+
...
|
|
78607
|
+
|
|
78608
|
+
2/3. FUNCTION DECLARATION & CLASS DECLARATION
|
|
78609
|
+
"estree": {
|
|
78610
|
+
"type": "Program",
|
|
78611
|
+
"body": [
|
|
78612
|
+
{
|
|
78613
|
+
"type": "ExportNamedDeclaration",
|
|
78614
|
+
"declaration": {
|
|
78615
|
+
"type": "ClassDeclaration" | "FunctionDeclaration",
|
|
78616
|
+
"id": {
|
|
78617
|
+
"type": "Identifier",
|
|
78618
|
+
"name": "Foo" // --------> This is the export name
|
|
78619
|
+
},
|
|
78620
|
+
*/
|
|
78587
78621
|
const exports_exports = (doc) => {
|
|
78588
78622
|
const set = new Set();
|
|
78589
78623
|
visit(lib_mdast(doc), isMDXEsm, (node) => {
|
|
78590
78624
|
var _a;
|
|
78591
|
-
|
|
78592
|
-
|
|
78593
|
-
|
|
78625
|
+
// Once inside an mdxjsEsm node, we need to check for one or more declared exports within data.estree.body
|
|
78626
|
+
// This is because single newlines \n are not considered as a new block, so there may be more than one export statement in a single mdxjsEsm node
|
|
78627
|
+
const body = (_a = node.data) === null || _a === void 0 ? void 0 : _a.estree.body;
|
|
78628
|
+
if (!body)
|
|
78629
|
+
return;
|
|
78630
|
+
for (const child of body) {
|
|
78631
|
+
if (child.type === 'ExportNamedDeclaration') {
|
|
78632
|
+
// There are three types of ExportNamedDeclaration that we need to consider: VariableDeclaration, FunctionDeclaration, ClassDeclaration
|
|
78633
|
+
const declaration = child.declaration;
|
|
78634
|
+
// FunctionDeclaration and ClassDeclaration have the same structure
|
|
78635
|
+
if (declaration.type !== 'VariableDeclaration') {
|
|
78636
|
+
// Note: declaration.id.type is always 'Identifier' for FunctionDeclarations and ClassDeclarations
|
|
78637
|
+
set.add(declaration.id.name);
|
|
78638
|
+
}
|
|
78639
|
+
else {
|
|
78640
|
+
const declarations = declaration.declarations;
|
|
78641
|
+
for (const declaration of declarations) {
|
|
78642
|
+
const id = declaration.id;
|
|
78643
|
+
if (id.type === 'Identifier') {
|
|
78644
|
+
set.add(id.name);
|
|
78645
|
+
}
|
|
78646
|
+
}
|
|
78647
|
+
}
|
|
78648
|
+
}
|
|
78594
78649
|
}
|
|
78595
78650
|
});
|
|
78596
78651
|
return Array.from(set);
|
package/dist/main.node.js
CHANGED
|
@@ -79662,14 +79662,69 @@ const compile_compile = (text, _a = {}) => {
|
|
|
79662
79662
|
|
|
79663
79663
|
|
|
79664
79664
|
|
|
79665
|
-
|
|
79665
|
+
/* Example mdast structures to find first export name in a mdxjsEsm node:
|
|
79666
|
+
There are three types of export declarations that we need to consider:
|
|
79667
|
+
1. VARIABLE DECLARATION
|
|
79668
|
+
"type": "mdxjsEsm",
|
|
79669
|
+
"value": "export const Foo = () => <div>Hello world</div>\nexport const Bar = () => <div>hello darkness my old friend</div>",
|
|
79670
|
+
"data": {
|
|
79671
|
+
"estree": {
|
|
79672
|
+
"type": "Program",
|
|
79673
|
+
"body": [
|
|
79674
|
+
{
|
|
79675
|
+
"type": "ExportNamedDeclaration",
|
|
79676
|
+
"declaration": {
|
|
79677
|
+
"type": "VariableDeclaration",
|
|
79678
|
+
"declarations": [
|
|
79679
|
+
{
|
|
79680
|
+
"type": "VariableDeclarator",
|
|
79681
|
+
"id": {
|
|
79682
|
+
"type": "Identifier",
|
|
79683
|
+
"name": "Foo" // --------> This is the export name
|
|
79684
|
+
},
|
|
79685
|
+
...
|
|
79686
|
+
|
|
79687
|
+
2/3. FUNCTION DECLARATION & CLASS DECLARATION
|
|
79688
|
+
"estree": {
|
|
79689
|
+
"type": "Program",
|
|
79690
|
+
"body": [
|
|
79691
|
+
{
|
|
79692
|
+
"type": "ExportNamedDeclaration",
|
|
79693
|
+
"declaration": {
|
|
79694
|
+
"type": "ClassDeclaration" | "FunctionDeclaration",
|
|
79695
|
+
"id": {
|
|
79696
|
+
"type": "Identifier",
|
|
79697
|
+
"name": "Foo" // --------> This is the export name
|
|
79698
|
+
},
|
|
79699
|
+
*/
|
|
79666
79700
|
const exports_exports = (doc) => {
|
|
79667
79701
|
const set = new Set();
|
|
79668
79702
|
visit(lib_mdast(doc), isMDXEsm, (node) => {
|
|
79669
79703
|
var _a;
|
|
79670
|
-
|
|
79671
|
-
|
|
79672
|
-
|
|
79704
|
+
// Once inside an mdxjsEsm node, we need to check for one or more declared exports within data.estree.body
|
|
79705
|
+
// This is because single newlines \n are not considered as a new block, so there may be more than one export statement in a single mdxjsEsm node
|
|
79706
|
+
const body = (_a = node.data) === null || _a === void 0 ? void 0 : _a.estree.body;
|
|
79707
|
+
if (!body)
|
|
79708
|
+
return;
|
|
79709
|
+
for (const child of body) {
|
|
79710
|
+
if (child.type === 'ExportNamedDeclaration') {
|
|
79711
|
+
// There are three types of ExportNamedDeclaration that we need to consider: VariableDeclaration, FunctionDeclaration, ClassDeclaration
|
|
79712
|
+
const declaration = child.declaration;
|
|
79713
|
+
// FunctionDeclaration and ClassDeclaration have the same structure
|
|
79714
|
+
if (declaration.type !== 'VariableDeclaration') {
|
|
79715
|
+
// Note: declaration.id.type is always 'Identifier' for FunctionDeclarations and ClassDeclarations
|
|
79716
|
+
set.add(declaration.id.name);
|
|
79717
|
+
}
|
|
79718
|
+
else {
|
|
79719
|
+
const declarations = declaration.declarations;
|
|
79720
|
+
for (const declaration of declarations) {
|
|
79721
|
+
const id = declaration.id;
|
|
79722
|
+
if (id.type === 'Identifier') {
|
|
79723
|
+
set.add(id.name);
|
|
79724
|
+
}
|
|
79725
|
+
}
|
|
79726
|
+
}
|
|
79727
|
+
}
|
|
79673
79728
|
}
|
|
79674
79729
|
});
|
|
79675
79730
|
return Array.from(set);
|
package/package.json
CHANGED