@metamask-previews/messenger-cli 0.0.0-preview-e024252b6 → 0.1.0-preview-8f51c7a3a
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/CHANGELOG.md +8 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/docs/cli.cjs +199 -0
- package/dist/docs/cli.cjs.map +1 -0
- package/dist/docs/cli.d.cts +3 -0
- package/dist/docs/cli.d.cts.map +1 -0
- package/dist/docs/cli.d.mts +3 -0
- package/dist/docs/cli.d.mts.map +1 -0
- package/dist/docs/cli.mjs +198 -0
- package/dist/docs/cli.mjs.map +1 -0
- package/dist/docs/discovery.cjs +46 -0
- package/dist/docs/discovery.cjs.map +1 -0
- package/dist/docs/discovery.d.cts +17 -0
- package/dist/docs/discovery.d.cts.map +1 -0
- package/dist/docs/discovery.d.mts +17 -0
- package/dist/docs/discovery.d.mts.map +1 -0
- package/dist/docs/discovery.mjs +41 -0
- package/dist/docs/discovery.mjs.map +1 -0
- package/dist/docs/extraction.cjs +577 -0
- package/dist/docs/extraction.cjs.map +1 -0
- package/dist/docs/extraction.d.cts +10 -0
- package/dist/docs/extraction.d.cts.map +1 -0
- package/dist/docs/extraction.d.mts +10 -0
- package/dist/docs/extraction.d.mts.map +1 -0
- package/dist/docs/extraction.mjs +551 -0
- package/dist/docs/extraction.mjs.map +1 -0
- package/dist/docs/generate.cjs +254 -0
- package/dist/docs/generate.cjs.map +1 -0
- package/dist/docs/generate.d.cts +27 -0
- package/dist/docs/generate.d.cts.map +1 -0
- package/dist/docs/generate.d.mts +27 -0
- package/dist/docs/generate.d.mts.map +1 -0
- package/dist/docs/generate.mjs +227 -0
- package/dist/docs/generate.mjs.map +1 -0
- package/dist/docs/markdown.cjs +210 -0
- package/dist/docs/markdown.cjs.map +1 -0
- package/dist/docs/markdown.d.cts +35 -0
- package/dist/docs/markdown.d.cts.map +1 -0
- package/dist/docs/markdown.d.mts +35 -0
- package/dist/docs/markdown.d.mts.map +1 -0
- package/dist/docs/markdown.mjs +203 -0
- package/dist/docs/markdown.mjs.map +1 -0
- package/dist/docs/types.cjs +3 -0
- package/dist/docs/types.cjs.map +1 -0
- package/dist/docs/types.d.cts +23 -0
- package/dist/docs/types.d.cts.map +1 -0
- package/dist/docs/types.d.mts +23 -0
- package/dist/docs/types.d.mts.map +1 -0
- package/dist/docs/types.mjs +2 -0
- package/dist/docs/types.mjs.map +1 -0
- package/package.json +24 -4
- package/template/docusaurus.config.ts +123 -0
- package/template/src/css/custom.css +314 -0
- package/template/static/fonts/MM-Sans/MM_Sans_Mono-Regular.woff2 +0 -0
- package/template/static/img/favicons/favicon-96x96.png +0 -0
- package/template/static/img/metamask-fox.svg +12 -0
- package/template/static/img/metamask-logo-dark.svg +3 -0
- package/template/static/img/metamask-logo.svg +3 -0
- package/template/tsconfig.json +13 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert backtick-quoted action/event names in text into links when they
|
|
3
|
+
* match a known item in the same namespace. For example, `` `setActiveNetwork` ``
|
|
4
|
+
* becomes a link to `#networkcontrollersetactivenetwork` on the actions page.
|
|
5
|
+
*
|
|
6
|
+
* @param text - The markdown text to process.
|
|
7
|
+
* @param namespace - The current namespace (e.g. "NetworkController").
|
|
8
|
+
* @param knownNames - Map from short name (e.g. "setActiveNetwork") to the page-relative path and anchor.
|
|
9
|
+
* @returns The text with backtick references replaced by links.
|
|
10
|
+
*/
|
|
11
|
+
function linkifyReferences(text, namespace, knownNames) {
|
|
12
|
+
return text.replace(/`([a-zA-Z]\w*)`/gu, (match, name) => {
|
|
13
|
+
const link = knownNames.get(name);
|
|
14
|
+
if (link) {
|
|
15
|
+
return `[\`${name}\`](${link})`;
|
|
16
|
+
}
|
|
17
|
+
// Also try with namespace prefix (e.g. "NetworkController:setActiveNetwork")
|
|
18
|
+
const fullName = `${namespace}:${name}`;
|
|
19
|
+
const anchor = fullName.toLowerCase().replace(/[^a-z0-9]/gu, '');
|
|
20
|
+
const linkFull = knownNames.get(fullName);
|
|
21
|
+
if (linkFull) {
|
|
22
|
+
return `[\`${name}\`](${linkFull})`;
|
|
23
|
+
}
|
|
24
|
+
// Check if the anchor exists anywhere in known names values
|
|
25
|
+
for (const [, href] of knownNames) {
|
|
26
|
+
if (href.includes(anchor)) {
|
|
27
|
+
return `[\`${name}\`](${href})`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return match;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Generate markdown documentation for a single messenger item.
|
|
35
|
+
*
|
|
36
|
+
* @param item - The messenger item to document.
|
|
37
|
+
* @param namespace - The current namespace.
|
|
38
|
+
* @param knownNames - Map from short/full names to their link paths.
|
|
39
|
+
* @param repoBaseUrl - Optional GitHub blob base URL (e.g. "https://github.com/Owner/Repo/blob/sha/").
|
|
40
|
+
* @returns The generated markdown string.
|
|
41
|
+
*/
|
|
42
|
+
export function generateItemMarkdown(item, namespace, knownNames, repoBaseUrl) {
|
|
43
|
+
const parts = [];
|
|
44
|
+
parts.push(`### \`${item.typeString}\``);
|
|
45
|
+
parts.push('');
|
|
46
|
+
if (item.deprecated) {
|
|
47
|
+
parts.push('> **Deprecated**');
|
|
48
|
+
parts.push('');
|
|
49
|
+
}
|
|
50
|
+
if (item.sourceFile.includes('node_modules/')) {
|
|
51
|
+
const pkgMatch = item.sourceFile.match(/node_modules\/(@metamask\/[^/]+)/u);
|
|
52
|
+
const pkgName = pkgMatch ? pkgMatch[1] : item.sourceFile;
|
|
53
|
+
const npmUrl = `https://www.npmjs.com/package/${pkgName}`;
|
|
54
|
+
parts.push(`**Package**: [\`${pkgName}\`](${npmUrl})`);
|
|
55
|
+
}
|
|
56
|
+
else if (repoBaseUrl) {
|
|
57
|
+
const ghUrl = `${repoBaseUrl}${item.sourceFile}#L${item.line}`;
|
|
58
|
+
parts.push(`**Source**: [${item.sourceFile}:${item.line}](${ghUrl})`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
parts.push(`**Source**: \`${item.sourceFile}:${item.line}\``);
|
|
62
|
+
}
|
|
63
|
+
parts.push('');
|
|
64
|
+
if (item.jsDoc) {
|
|
65
|
+
parts.push(linkifyReferences(item.jsDoc, namespace, knownNames));
|
|
66
|
+
parts.push('');
|
|
67
|
+
}
|
|
68
|
+
const label = item.kind === 'action' ? 'Handler' : 'Payload';
|
|
69
|
+
parts.push(`**${label}**:`);
|
|
70
|
+
parts.push('');
|
|
71
|
+
parts.push('```typescript');
|
|
72
|
+
parts.push(item.handlerOrPayload);
|
|
73
|
+
parts.push('```');
|
|
74
|
+
parts.push('');
|
|
75
|
+
return parts.join('\n');
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Generate a full markdown page for a namespace's actions or events.
|
|
79
|
+
*
|
|
80
|
+
* @param ns - The namespace group to generate a page for.
|
|
81
|
+
* @param kind - Whether to generate the actions or events page.
|
|
82
|
+
* @param repoBaseUrl - Optional GitHub blob base URL for source links.
|
|
83
|
+
* @returns The generated markdown string.
|
|
84
|
+
*/
|
|
85
|
+
export function generateNamespacePage(ns, kind, repoBaseUrl = null) {
|
|
86
|
+
const items = kind === 'action' ? ns.actions : ns.events;
|
|
87
|
+
const title = kind === 'action' ? 'Actions' : 'Events';
|
|
88
|
+
const parts = [];
|
|
89
|
+
parts.push('---');
|
|
90
|
+
parts.push(`title: "${ns.namespace} ${title}"`);
|
|
91
|
+
parts.push(`sidebar_label: "${title}"`);
|
|
92
|
+
parts.push('---');
|
|
93
|
+
parts.push('');
|
|
94
|
+
parts.push(`# ${ns.namespace} ${title}`);
|
|
95
|
+
parts.push('');
|
|
96
|
+
if (items.length === 0) {
|
|
97
|
+
parts.push(`_No ${kind}s found for this namespace._`);
|
|
98
|
+
parts.push('');
|
|
99
|
+
return parts.join('\n');
|
|
100
|
+
}
|
|
101
|
+
parts.push(`${items.length} ${kind}${items.length === 1 ? '' : 's'} registered.`);
|
|
102
|
+
parts.push('');
|
|
103
|
+
// Build a map of known names → link paths for cross-referencing.
|
|
104
|
+
// Actions on same page get #anchor, actions/events on sibling page get relative path.
|
|
105
|
+
const knownNames = new Map();
|
|
106
|
+
for (const action of ns.actions) {
|
|
107
|
+
const shortName = action.typeString.split(':')[1];
|
|
108
|
+
const anchor = action.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');
|
|
109
|
+
const href = kind === 'action' ? `#${anchor}` : `./actions#${anchor}`;
|
|
110
|
+
knownNames.set(shortName, href);
|
|
111
|
+
knownNames.set(action.typeString, href);
|
|
112
|
+
}
|
|
113
|
+
for (const event of ns.events) {
|
|
114
|
+
const shortName = event.typeString.split(':')[1];
|
|
115
|
+
const anchor = event.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');
|
|
116
|
+
const href = kind === 'event' ? `#${anchor}` : `./events#${anchor}`;
|
|
117
|
+
knownNames.set(shortName, href);
|
|
118
|
+
knownNames.set(event.typeString, href);
|
|
119
|
+
}
|
|
120
|
+
// Table of contents
|
|
121
|
+
parts.push('| Name | Deprecated |');
|
|
122
|
+
parts.push('|------|-----------|');
|
|
123
|
+
for (const item of items) {
|
|
124
|
+
const name = item.typeString.split(':')[1];
|
|
125
|
+
// Docusaurus uses github-slugger: strips non-alphanumeric, lowercases, no dashes for special chars in code spans
|
|
126
|
+
const anchor = item.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');
|
|
127
|
+
const dep = item.deprecated ? 'Yes' : '';
|
|
128
|
+
parts.push(`| [\`${name}\`](#${anchor}) | ${dep} |`);
|
|
129
|
+
}
|
|
130
|
+
parts.push('');
|
|
131
|
+
parts.push('---');
|
|
132
|
+
parts.push('');
|
|
133
|
+
for (const item of items) {
|
|
134
|
+
parts.push(generateItemMarkdown(item, ns.namespace, knownNames, repoBaseUrl));
|
|
135
|
+
parts.push('---');
|
|
136
|
+
parts.push('');
|
|
137
|
+
}
|
|
138
|
+
return parts.join('\n');
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Generate the index/overview page listing all namespaces.
|
|
142
|
+
*
|
|
143
|
+
* @param namespaces - All namespace groups sorted alphabetically.
|
|
144
|
+
* @returns The generated markdown string.
|
|
145
|
+
*/
|
|
146
|
+
export function generateIndexPage(namespaces) {
|
|
147
|
+
const totalActions = namespaces.reduce((sum, ns) => sum + ns.actions.length, 0);
|
|
148
|
+
const totalEvents = namespaces.reduce((sum, ns) => sum + ns.events.length, 0);
|
|
149
|
+
const parts = [];
|
|
150
|
+
parts.push('---');
|
|
151
|
+
parts.push('title: "Messenger API Reference"');
|
|
152
|
+
parts.push('slug: "/"');
|
|
153
|
+
parts.push('---');
|
|
154
|
+
parts.push('');
|
|
155
|
+
parts.push('# Messenger API');
|
|
156
|
+
parts.push('');
|
|
157
|
+
parts.push('This site documents every action and event registered on the Messenger — the type-safe message bus used across all controllers.');
|
|
158
|
+
parts.push('');
|
|
159
|
+
parts.push(`- **${namespaces.length}** namespaces`);
|
|
160
|
+
parts.push(`- **${totalActions}** actions`);
|
|
161
|
+
parts.push(`- **${totalEvents}** events`);
|
|
162
|
+
parts.push('');
|
|
163
|
+
parts.push('## Namespaces');
|
|
164
|
+
parts.push('');
|
|
165
|
+
parts.push('| Namespace | Actions | Events |');
|
|
166
|
+
parts.push('|-----------|---------|--------|');
|
|
167
|
+
for (const ns of namespaces) {
|
|
168
|
+
const firstLink = ns.actions.length > 0
|
|
169
|
+
? `${ns.namespace}/actions`
|
|
170
|
+
: `${ns.namespace}/events`;
|
|
171
|
+
parts.push(`| [${ns.namespace}](${firstLink}) | ${ns.actions.length} | ${ns.events.length} |`);
|
|
172
|
+
}
|
|
173
|
+
parts.push('');
|
|
174
|
+
return parts.join('\n');
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Generate the sidebars.ts file content for Docusaurus.
|
|
178
|
+
*
|
|
179
|
+
* @param namespaces - All namespace groups sorted alphabetically.
|
|
180
|
+
* @returns The generated TypeScript source string.
|
|
181
|
+
*/
|
|
182
|
+
export function generateSidebars(namespaces) {
|
|
183
|
+
const items = namespaces.map((ns) => ({
|
|
184
|
+
type: 'category',
|
|
185
|
+
label: ns.namespace,
|
|
186
|
+
items: [
|
|
187
|
+
...(ns.actions.length > 0 ? [`${ns.namespace}/actions`] : []),
|
|
188
|
+
...(ns.events.length > 0 ? [`${ns.namespace}/events`] : []),
|
|
189
|
+
],
|
|
190
|
+
}));
|
|
191
|
+
const sidebar = {
|
|
192
|
+
messengerSidebar: [
|
|
193
|
+
{
|
|
194
|
+
type: 'doc',
|
|
195
|
+
id: 'index',
|
|
196
|
+
label: 'Overview',
|
|
197
|
+
},
|
|
198
|
+
...items,
|
|
199
|
+
],
|
|
200
|
+
};
|
|
201
|
+
return `// This file is auto-generated by @metamask/messenger-docs\n// Do not edit manually.\nconst sidebars = ${JSON.stringify(sidebar, null, 2)};\nexport default sidebars;\n`;
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=markdown.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.mjs","sourceRoot":"","sources":["../../src/docs/markdown.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,SAAS,iBAAiB,CACxB,IAAY,EACZ,SAAiB,EACjB,UAA+B;IAE/B,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;QAC/D,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,MAAM,IAAI,OAAO,IAAI,GAAG,CAAC;QAClC,CAAC;QACD,6EAA6E;QAC7E,MAAM,QAAQ,GAAG,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QACjE,MAAM,QAA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AAM,CAAC,MAAM,IAAI,CACnF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAA4B;IAC3D,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,EAAE,CAAC,SAAS;QACnB,KAAK,EAAE;YACL,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7D,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D;KACF,CAAC,CAAC,CAAC;IAEJ,MAAM,OAAO,GAAG;QACd,gBAAgB,EAAE;YAChB;gBACE,IAAI,EAAE,KAAK;gBACX,EAAE,EAAE,OAAO;gBACX,KAAK,EAAE,UAAU;aAClB;YACD,GAAG,KAAK;SACT;KACF,CAAC;IAEF,OAAO,0GAA0G,IAAI,CAAC,SAAS,CAC7H,OAAO,EACP,IAAI,EACJ,CAAC,CACF,+BAA+B,CAAC;AACnC,CAAC","sourcesContent":["import type { MessengerItemDoc, NamespaceGroup } from './types';\n\n/**\n * Convert backtick-quoted action/event names in text into links when they\n * match a known item in the same namespace. For example, `` `setActiveNetwork` ``\n * becomes a link to `#networkcontrollersetactivenetwork` on the actions page.\n *\n * @param text - The markdown text to process.\n * @param namespace - The current namespace (e.g. \"NetworkController\").\n * @param knownNames - Map from short name (e.g. \"setActiveNetwork\") to the page-relative path and anchor.\n * @returns The text with backtick references replaced by links.\n */\nfunction linkifyReferences(\n text: string,\n namespace: string,\n knownNames: Map<string, string>,\n): string {\n return text.replace(/`([a-zA-Z]\\w*)`/gu, (match, name: string) => {\n const link = knownNames.get(name);\n if (link) {\n return `[\\`${name}\\`](${link})`;\n }\n // Also try with namespace prefix (e.g. \"NetworkController:setActiveNetwork\")\n const fullName = `${namespace}:${name}`;\n const anchor = fullName.toLowerCase().replace(/[^a-z0-9]/gu, '');\n const linkFull = knownNames.get(fullName);\n if (linkFull) {\n return `[\\`${name}\\`](${linkFull})`;\n }\n // Check if the anchor exists anywhere in known names values\n for (const [, href] of knownNames) {\n if (href.includes(anchor)) {\n return `[\\`${name}\\`](${href})`;\n }\n }\n return match;\n });\n}\n\n/**\n * Generate markdown documentation for a single messenger item.\n *\n * @param item - The messenger item to document.\n * @param namespace - The current namespace.\n * @param knownNames - Map from short/full names to their link paths.\n * @param repoBaseUrl - Optional GitHub blob base URL (e.g. \"https://github.com/Owner/Repo/blob/sha/\").\n * @returns The generated markdown string.\n */\nexport function generateItemMarkdown(\n item: MessengerItemDoc,\n namespace: string,\n knownNames: Map<string, string>,\n repoBaseUrl: string | null,\n): string {\n const parts: string[] = [];\n\n parts.push(`### \\`${item.typeString}\\``);\n parts.push('');\n\n if (item.deprecated) {\n parts.push('> **Deprecated**');\n parts.push('');\n }\n\n if (item.sourceFile.includes('node_modules/')) {\n const pkgMatch = item.sourceFile.match(/node_modules\\/(@metamask\\/[^/]+)/u);\n const pkgName = pkgMatch ? pkgMatch[1] : item.sourceFile;\n const npmUrl = `https://www.npmjs.com/package/${pkgName}`;\n parts.push(`**Package**: [\\`${pkgName}\\`](${npmUrl})`);\n } else if (repoBaseUrl) {\n const ghUrl = `${repoBaseUrl}${item.sourceFile}#L${item.line}`;\n parts.push(`**Source**: [${item.sourceFile}:${item.line}](${ghUrl})`);\n } else {\n parts.push(`**Source**: \\`${item.sourceFile}:${item.line}\\``);\n }\n parts.push('');\n\n if (item.jsDoc) {\n parts.push(linkifyReferences(item.jsDoc, namespace, knownNames));\n parts.push('');\n }\n\n const label = item.kind === 'action' ? 'Handler' : 'Payload';\n parts.push(`**${label}**:`);\n parts.push('');\n parts.push('```typescript');\n parts.push(item.handlerOrPayload);\n parts.push('```');\n parts.push('');\n\n return parts.join('\\n');\n}\n\n/**\n * Generate a full markdown page for a namespace's actions or events.\n *\n * @param ns - The namespace group to generate a page for.\n * @param kind - Whether to generate the actions or events page.\n * @param repoBaseUrl - Optional GitHub blob base URL for source links.\n * @returns The generated markdown string.\n */\nexport function generateNamespacePage(\n ns: NamespaceGroup,\n kind: 'action' | 'event',\n repoBaseUrl: string | null = null,\n): string {\n const items = kind === 'action' ? ns.actions : ns.events;\n const title = kind === 'action' ? 'Actions' : 'Events';\n const parts: string[] = [];\n\n parts.push('---');\n parts.push(`title: \"${ns.namespace} ${title}\"`);\n parts.push(`sidebar_label: \"${title}\"`);\n parts.push('---');\n parts.push('');\n parts.push(`# ${ns.namespace} ${title}`);\n parts.push('');\n\n if (items.length === 0) {\n parts.push(`_No ${kind}s found for this namespace._`);\n parts.push('');\n return parts.join('\\n');\n }\n\n parts.push(\n `${items.length} ${kind}${items.length === 1 ? '' : 's'} registered.`,\n );\n parts.push('');\n\n // Build a map of known names → link paths for cross-referencing.\n // Actions on same page get #anchor, actions/events on sibling page get relative path.\n const knownNames = new Map<string, string>();\n for (const action of ns.actions) {\n const shortName = action.typeString.split(':')[1];\n const anchor = action.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');\n const href = kind === 'action' ? `#${anchor}` : `./actions#${anchor}`;\n knownNames.set(shortName, href);\n knownNames.set(action.typeString, href);\n }\n for (const event of ns.events) {\n const shortName = event.typeString.split(':')[1];\n const anchor = event.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');\n const href = kind === 'event' ? `#${anchor}` : `./events#${anchor}`;\n knownNames.set(shortName, href);\n knownNames.set(event.typeString, href);\n }\n\n // Table of contents\n parts.push('| Name | Deprecated |');\n parts.push('|------|-----------|');\n for (const item of items) {\n const name = item.typeString.split(':')[1];\n // Docusaurus uses github-slugger: strips non-alphanumeric, lowercases, no dashes for special chars in code spans\n const anchor = item.typeString.toLowerCase().replace(/[^a-z0-9]/gu, '');\n const dep = item.deprecated ? 'Yes' : '';\n parts.push(`| [\\`${name}\\`](#${anchor}) | ${dep} |`);\n }\n parts.push('');\n parts.push('---');\n parts.push('');\n\n for (const item of items) {\n parts.push(\n generateItemMarkdown(item, ns.namespace, knownNames, repoBaseUrl),\n );\n parts.push('---');\n parts.push('');\n }\n\n return parts.join('\\n');\n}\n\n/**\n * Generate the index/overview page listing all namespaces.\n *\n * @param namespaces - All namespace groups sorted alphabetically.\n * @returns The generated markdown string.\n */\nexport function generateIndexPage(namespaces: NamespaceGroup[]): string {\n const totalActions = namespaces.reduce(\n (sum, ns) => sum + ns.actions.length,\n 0,\n );\n const totalEvents = namespaces.reduce((sum, ns) => sum + ns.events.length, 0);\n\n const parts: string[] = [];\n parts.push('---');\n parts.push('title: \"Messenger API Reference\"');\n parts.push('slug: \"/\"');\n parts.push('---');\n parts.push('');\n parts.push('# Messenger API');\n parts.push('');\n parts.push(\n 'This site documents every action and event registered on the Messenger — the type-safe message bus used across all controllers.',\n );\n parts.push('');\n parts.push(`- **${namespaces.length}** namespaces`);\n parts.push(`- **${totalActions}** actions`);\n parts.push(`- **${totalEvents}** events`);\n parts.push('');\n parts.push('## Namespaces');\n parts.push('');\n parts.push('| Namespace | Actions | Events |');\n parts.push('|-----------|---------|--------|');\n\n for (const ns of namespaces) {\n const firstLink =\n ns.actions.length > 0\n ? `${ns.namespace}/actions`\n : `${ns.namespace}/events`;\n parts.push(\n `| [${ns.namespace}](${firstLink}) | ${ns.actions.length} | ${ns.events.length} |`,\n );\n }\n\n parts.push('');\n return parts.join('\\n');\n}\n\n/**\n * Generate the sidebars.ts file content for Docusaurus.\n *\n * @param namespaces - All namespace groups sorted alphabetically.\n * @returns The generated TypeScript source string.\n */\nexport function generateSidebars(namespaces: NamespaceGroup[]): string {\n const items = namespaces.map((ns) => ({\n type: 'category',\n label: ns.namespace,\n items: [\n ...(ns.actions.length > 0 ? [`${ns.namespace}/actions`] : []),\n ...(ns.events.length > 0 ? [`${ns.namespace}/events`] : []),\n ],\n }));\n\n const sidebar = {\n messengerSidebar: [\n {\n type: 'doc',\n id: 'index',\n label: 'Overview',\n },\n ...items,\n ],\n };\n\n return `// This file is auto-generated by @metamask/messenger-docs\\n// Do not edit manually.\\nconst sidebars = ${JSON.stringify(\n sidebar,\n null,\n 2,\n )};\\nexport default sidebars;\\n`;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/docs/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MessengerItemDoc = {\n typeName: string; // e.g. \"NetworkControllerGetStateAction\"\n typeString: string; // e.g. \"NetworkController:getState\"\n kind: 'action' | 'event';\n jsDoc: string; // Cleaned JSDoc body text (empty if none)\n handlerOrPayload: string; // Raw type text of handler / payload\n sourceFile: string; // Relative path from repo root\n line: number;\n deprecated: boolean;\n};\n\nexport type NamespaceGroup = {\n namespace: string;\n actions: MessengerItemDoc[];\n events: MessengerItemDoc[];\n};\n\n/**\n * Info about a class method, used to resolve `ClassName['methodName']` handlers.\n */\nexport type MethodInfo = {\n jsDoc: string;\n signature: string; // e.g. \"(fields: AddNetworkFields) => NetworkConfiguration\"\n};\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type MessengerItemDoc = {
|
|
2
|
+
typeName: string;
|
|
3
|
+
typeString: string;
|
|
4
|
+
kind: 'action' | 'event';
|
|
5
|
+
jsDoc: string;
|
|
6
|
+
handlerOrPayload: string;
|
|
7
|
+
sourceFile: string;
|
|
8
|
+
line: number;
|
|
9
|
+
deprecated: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type NamespaceGroup = {
|
|
12
|
+
namespace: string;
|
|
13
|
+
actions: MessengerItemDoc[];
|
|
14
|
+
events: MessengerItemDoc[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Info about a class method, used to resolve `ClassName['methodName']` handlers.
|
|
18
|
+
*/
|
|
19
|
+
export type MethodInfo = {
|
|
20
|
+
jsDoc: string;
|
|
21
|
+
signature: string;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/docs/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type MessengerItemDoc = {
|
|
2
|
+
typeName: string;
|
|
3
|
+
typeString: string;
|
|
4
|
+
kind: 'action' | 'event';
|
|
5
|
+
jsDoc: string;
|
|
6
|
+
handlerOrPayload: string;
|
|
7
|
+
sourceFile: string;
|
|
8
|
+
line: number;
|
|
9
|
+
deprecated: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type NamespaceGroup = {
|
|
12
|
+
namespace: string;
|
|
13
|
+
actions: MessengerItemDoc[];
|
|
14
|
+
events: MessengerItemDoc[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Info about a class method, used to resolve `ClassName['methodName']` handlers.
|
|
18
|
+
*/
|
|
19
|
+
export type MethodInfo = {
|
|
20
|
+
jsDoc: string;
|
|
21
|
+
signature: string;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/docs/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/docs/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MessengerItemDoc = {\n typeName: string; // e.g. \"NetworkControllerGetStateAction\"\n typeString: string; // e.g. \"NetworkController:getState\"\n kind: 'action' | 'event';\n jsDoc: string; // Cleaned JSDoc body text (empty if none)\n handlerOrPayload: string; // Raw type text of handler / payload\n sourceFile: string; // Relative path from repo root\n line: number;\n deprecated: boolean;\n};\n\nexport type NamespaceGroup = {\n namespace: string;\n actions: MessengerItemDoc[];\n events: MessengerItemDoc[];\n};\n\n/**\n * Info about a class method, used to resolve `ClassName['methodName']` handlers.\n */\nexport type MethodInfo = {\n jsDoc: string;\n signature: string; // e.g. \"(fields: AddNetworkFields) => NetworkConfiguration\"\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/messenger-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0-preview-8f51c7a3a",
|
|
4
4
|
"description": "CLI tools for the MetaMask messenger system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -17,16 +17,19 @@
|
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"bin": {
|
|
20
|
-
"messenger-action-types": "./dist/cli.mjs"
|
|
20
|
+
"messenger-action-types": "./dist/cli.mjs",
|
|
21
|
+
"messenger-docs": "./dist/docs/cli.mjs"
|
|
21
22
|
},
|
|
22
23
|
"files": [
|
|
23
|
-
"dist/"
|
|
24
|
+
"dist/",
|
|
25
|
+
"template/"
|
|
24
26
|
],
|
|
25
27
|
"scripts": {
|
|
26
28
|
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
|
|
27
29
|
"build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
|
|
28
30
|
"changelog:update": "../../scripts/update-changelog.sh @metamask/messenger-cli",
|
|
29
31
|
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/messenger-cli",
|
|
32
|
+
"docs": "tsx src/docs/cli.ts",
|
|
30
33
|
"since-latest-release": "../../scripts/since-latest-release.sh",
|
|
31
34
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
|
|
32
35
|
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
|
|
@@ -34,17 +37,29 @@
|
|
|
34
37
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
35
38
|
},
|
|
36
39
|
"dependencies": {
|
|
40
|
+
"@docusaurus/core": "^3.9.0",
|
|
41
|
+
"@docusaurus/preset-classic": "^3.9.0",
|
|
42
|
+
"@docusaurus/theme-common": "^3.9.0",
|
|
43
|
+
"@easyops-cn/docusaurus-search-local": "^0.55.0",
|
|
44
|
+
"@mdx-js/react": "^3.0.0",
|
|
37
45
|
"@metamask/utils": "^11.9.0",
|
|
46
|
+
"execa": "^5.0.0",
|
|
47
|
+
"glob": "^10.0.0",
|
|
48
|
+
"prism-react-renderer": "^2.4.1",
|
|
49
|
+
"react": "^18.3.1",
|
|
50
|
+
"react-dom": "^18.3.1",
|
|
38
51
|
"yargs": "^17.7.2"
|
|
39
52
|
},
|
|
40
53
|
"devDependencies": {
|
|
54
|
+
"@docusaurus/types": "^3.9.0",
|
|
41
55
|
"@metamask/auto-changelog": "^3.4.4",
|
|
42
56
|
"@ts-bridge/cli": "^0.6.4",
|
|
43
57
|
"@types/jest": "^29.5.14",
|
|
58
|
+
"@types/node": "^16.18.54",
|
|
59
|
+
"@types/react": "^18.3.0",
|
|
44
60
|
"@types/yargs": "^17.0.32",
|
|
45
61
|
"deepmerge": "^4.2.2",
|
|
46
62
|
"eslint": "^9.39.1",
|
|
47
|
-
"execa": "^5.0.0",
|
|
48
63
|
"jest": "^29.7.0",
|
|
49
64
|
"ts-jest": "^29.2.5",
|
|
50
65
|
"typescript": "~5.3.3"
|
|
@@ -53,6 +68,11 @@
|
|
|
53
68
|
"eslint": ">=8",
|
|
54
69
|
"typescript": ">=5.0.0"
|
|
55
70
|
},
|
|
71
|
+
"peerDependenciesMeta": {
|
|
72
|
+
"eslint": {
|
|
73
|
+
"optional": true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
56
76
|
"engines": {
|
|
57
77
|
"node": "^18.18 || >=20"
|
|
58
78
|
},
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import type * as Preset from '@docusaurus/preset-classic';
|
|
5
|
+
import type { Config } from '@docusaurus/types';
|
|
6
|
+
import { themes } from 'prism-react-renderer';
|
|
7
|
+
|
|
8
|
+
const codeTheme = themes.dracula;
|
|
9
|
+
|
|
10
|
+
// When running inside a host project (e.g. metamask-extension) whose React
|
|
11
|
+
// version differs from Docusaurus's, we alias react/react-dom to the copies
|
|
12
|
+
// installed alongside this package. Only create aliases for packages that
|
|
13
|
+
// actually exist at the NODE_PATH location (they may be hoisted when the host
|
|
14
|
+
// already has a compatible version).
|
|
15
|
+
const extraNodeModules = process.env.NODE_PATH; // eslint-disable-line no-process-env
|
|
16
|
+
const reactAlias: Record<string, string> = {};
|
|
17
|
+
if (extraNodeModules) {
|
|
18
|
+
for (const pkg of ['react', 'react-dom', '@mdx-js/react']) {
|
|
19
|
+
const pkgPath = path.join(extraNodeModules, pkg);
|
|
20
|
+
if (fs.existsSync(pkgPath)) {
|
|
21
|
+
reactAlias[pkg] = pkgPath;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const config: Config = {
|
|
27
|
+
title: 'Messenger API',
|
|
28
|
+
tagline: 'Action and event reference for MetaMask controller messengers',
|
|
29
|
+
url: process.env.DOCS_URL || 'https://metamask.github.io', // eslint-disable-line no-process-env
|
|
30
|
+
baseUrl: process.env.DOCS_BASE_URL || '/', // eslint-disable-line no-process-env
|
|
31
|
+
favicon: 'img/favicons/favicon-96x96.png',
|
|
32
|
+
|
|
33
|
+
onBrokenLinks: 'warn',
|
|
34
|
+
|
|
35
|
+
markdown: {
|
|
36
|
+
hooks: {
|
|
37
|
+
onBrokenMarkdownLinks: 'warn',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
i18n: {
|
|
42
|
+
defaultLocale: 'en',
|
|
43
|
+
locales: ['en'],
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
plugins: [
|
|
47
|
+
function resolvePlugin() {
|
|
48
|
+
return {
|
|
49
|
+
name: 'resolve-deps',
|
|
50
|
+
configureWebpack() {
|
|
51
|
+
if (Object.keys(reactAlias).length === 0) {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
resolve: { alias: reactAlias },
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
|
|
62
|
+
themes: [
|
|
63
|
+
[
|
|
64
|
+
'@easyops-cn/docusaurus-search-local',
|
|
65
|
+
{
|
|
66
|
+
docsRouteBasePath: '/',
|
|
67
|
+
hashed: true,
|
|
68
|
+
indexBlog: false,
|
|
69
|
+
highlightSearchTermsOnTargetPage: true,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
],
|
|
73
|
+
|
|
74
|
+
presets: [
|
|
75
|
+
[
|
|
76
|
+
'classic',
|
|
77
|
+
{
|
|
78
|
+
docs: {
|
|
79
|
+
routeBasePath: '/',
|
|
80
|
+
sidebarPath: './sidebars.ts',
|
|
81
|
+
breadcrumbs: false,
|
|
82
|
+
},
|
|
83
|
+
blog: false,
|
|
84
|
+
theme: {
|
|
85
|
+
customCss: './src/css/custom.css',
|
|
86
|
+
},
|
|
87
|
+
} satisfies Preset.Options,
|
|
88
|
+
],
|
|
89
|
+
],
|
|
90
|
+
|
|
91
|
+
themeConfig: {
|
|
92
|
+
colorMode: {
|
|
93
|
+
respectPrefersColorScheme: true,
|
|
94
|
+
},
|
|
95
|
+
navbar: {
|
|
96
|
+
logo: {
|
|
97
|
+
alt: 'MetaMask logo',
|
|
98
|
+
src: 'img/metamask-logo.svg',
|
|
99
|
+
srcDark: 'img/metamask-logo-dark.svg',
|
|
100
|
+
},
|
|
101
|
+
hideOnScroll: false,
|
|
102
|
+
items: [
|
|
103
|
+
{
|
|
104
|
+
href: 'https://github.com/MetaMask/core',
|
|
105
|
+
label: 'GitHub',
|
|
106
|
+
position: 'right',
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
docs: {
|
|
111
|
+
sidebar: {
|
|
112
|
+
autoCollapseCategories: false,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
prism: {
|
|
116
|
+
theme: codeTheme,
|
|
117
|
+
defaultLanguage: 'typescript',
|
|
118
|
+
additionalLanguages: ['bash', 'json'],
|
|
119
|
+
},
|
|
120
|
+
} satisfies Preset.ThemeConfig,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export default config;
|