@metamask-previews/platform-api-docs 0.1.0-preview-abca9bcea → 0.2.0-preview-0a30e47

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/{cli.mjs → cli.js} +10 -40
  5. package/dist/cli.js.map +1 -0
  6. package/dist/{extraction.d.cts → extraction.d.ts} +3 -3
  7. package/dist/extraction.d.ts.map +1 -0
  8. package/dist/{extraction.mjs → extraction.js} +3 -3
  9. package/dist/extraction.js.map +1 -0
  10. package/dist/{generate.d.cts → generate.d.ts} +2 -2
  11. package/dist/generate.d.ts.map +1 -0
  12. package/dist/{generate.mjs → generate.js} +10 -10
  13. package/dist/generate.js.map +1 -0
  14. package/dist/{markdown.d.cts → markdown.d.ts} +2 -2
  15. package/dist/markdown.d.ts.map +1 -0
  16. package/dist/{markdown.mjs → markdown.js} +1 -1
  17. package/dist/markdown.js.map +1 -0
  18. package/dist/{root-messenger-discovery.d.cts → root-messenger-discovery.d.ts} +2 -2
  19. package/dist/root-messenger-discovery.d.ts.map +1 -0
  20. package/dist/{root-messenger-discovery.mjs → root-messenger-discovery.js} +5 -5
  21. package/dist/root-messenger-discovery.js.map +1 -0
  22. package/dist/{ts-project.d.cts → ts-project.d.ts} +2 -2
  23. package/dist/ts-project.d.ts.map +1 -0
  24. package/dist/{ts-project.mjs → ts-project.js} +2 -2
  25. package/dist/ts-project.js.map +1 -0
  26. package/dist/{types.d.cts → types.d.ts} +1 -1
  27. package/dist/types.d.ts.map +1 -0
  28. package/dist/types.js +2 -0
  29. package/dist/types.js.map +1 -0
  30. package/package.json +12 -8
  31. package/dist/cli.cjs +0 -328
  32. package/dist/cli.cjs.map +0 -1
  33. package/dist/cli.d.cts +0 -3
  34. package/dist/cli.d.cts.map +0 -1
  35. package/dist/cli.d.mts +0 -3
  36. package/dist/cli.d.mts.map +0 -1
  37. package/dist/cli.mjs.map +0 -1
  38. package/dist/extraction.cjs +0 -754
  39. package/dist/extraction.cjs.map +0 -1
  40. package/dist/extraction.d.cts.map +0 -1
  41. package/dist/extraction.d.mts +0 -73
  42. package/dist/extraction.d.mts.map +0 -1
  43. package/dist/extraction.mjs.map +0 -1
  44. package/dist/generate.cjs +0 -505
  45. package/dist/generate.cjs.map +0 -1
  46. package/dist/generate.d.cts.map +0 -1
  47. package/dist/generate.d.mts +0 -70
  48. package/dist/generate.d.mts.map +0 -1
  49. package/dist/generate.mjs.map +0 -1
  50. package/dist/markdown.cjs +0 -239
  51. package/dist/markdown.cjs.map +0 -1
  52. package/dist/markdown.d.cts.map +0 -1
  53. package/dist/markdown.d.mts +0 -52
  54. package/dist/markdown.d.mts.map +0 -1
  55. package/dist/markdown.mjs.map +0 -1
  56. package/dist/root-messenger-discovery.cjs +0 -359
  57. package/dist/root-messenger-discovery.cjs.map +0 -1
  58. package/dist/root-messenger-discovery.d.cts.map +0 -1
  59. package/dist/root-messenger-discovery.d.mts +0 -61
  60. package/dist/root-messenger-discovery.d.mts.map +0 -1
  61. package/dist/root-messenger-discovery.mjs.map +0 -1
  62. package/dist/ts-project.cjs +0 -33
  63. package/dist/ts-project.cjs.map +0 -1
  64. package/dist/ts-project.d.cts.map +0 -1
  65. package/dist/ts-project.d.mts +0 -12
  66. package/dist/ts-project.d.mts.map +0 -1
  67. package/dist/ts-project.mjs.map +0 -1
  68. package/dist/types.cjs +0 -3
  69. package/dist/types.cjs.map +0 -1
  70. package/dist/types.d.cts.map +0 -1
  71. package/dist/types.d.mts +0 -47
  72. package/dist/types.d.mts.map +0 -1
  73. package/dist/types.mjs +0 -2
  74. package/dist/types.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,8 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.0]
11
+
10
12
  ### Changed
11
13
 
14
+ - **BREAKING:** Drop CommonJS support ([#9536](https://github.com/MetaMask/core/pull/9536))
15
+ - This package is now ESM-only, but can still be used in CommonJS projects via `require(esm)` in modern Node.js versions (22+), or dynamic imports in older Node.js versions.
16
+ - **BREAKING:** Bump minimum Node.js version to 22 ([#9976](https://github.com/MetaMask/core/pull/9976))
17
+ - **BREAKING:** Bump TypeScript target to ES2022 ([#10019](https://github.com/MetaMask/core/pull/10019))
18
+ - This package now ships ES2022 code, requiring a compatible modern environment or bundler configuration to consume.
12
19
  - Speed up documentation generation by loading source files in bulk instead of one at a time ([#9990](https://github.com/MetaMask/core/pull/9990))
13
20
  - Bump `@metamask/utils` from `^11.11.0` to `^11.12.0` ([#10076](https://github.com/MetaMask/core/pull/10076))
14
21
 
@@ -18,5 +25,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
25
 
19
26
  - Initial release of the platform-api-docs package ([#8012](https://github.com/MetaMask/core/pull/8012), [#9913](https://github.com/MetaMask/core/pull/9913))
20
27
 
21
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/platform-api-docs@0.1.0...HEAD
28
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/platform-api-docs@0.2.0...HEAD
29
+ [0.2.0]: https://github.com/MetaMask/core/compare/@metamask/platform-api-docs@0.1.0...@metamask/platform-api-docs@0.2.0
22
30
  [0.1.0]: https://github.com/MetaMask/core/releases/tag/@metamask/platform-api-docs@0.1.0
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
@@ -1,37 +1,11 @@
1
1
  #!/usr/bin/env node
2
- function $__filename(fileUrl) {
3
- const url = new URL(fileUrl);
4
- return url.pathname.replace(/^\/([a-zA-Z]:)/u, "$1");
5
- }
6
- function $getDirname(path) {
7
- const sanitisedPath = path.toString().replace(/\\/gu, "/").replace(/\/$/u, "");
8
- const index = sanitisedPath.lastIndexOf("/");
9
- if (index === -1) {
10
- return path;
11
- }
12
- if (index === 0) {
13
- return "/";
14
- }
15
- return sanitisedPath.slice(0, index);
16
- }
17
- function $__dirname(url) {
18
- return $getDirname($__filename(url));
19
- }
20
- function $importDefault(module) {
21
- if (module?.__esModule) {
22
- return module.default;
23
- }
24
- return module;
25
- }
26
- import $execa from "execa/index.js";
27
- const execa = $importDefault($execa);
28
- import * as fs from "node:fs/promises";
29
- import * as path from "node:path";
30
- import $npmWhich from "npm-which";
31
- const npmWhich = $importDefault($npmWhich);
32
- import yargs from "yargs";
33
- import { generate, resolveRepoUrl } from "./generate.mjs";
34
- import { parseRootCapabilitiesTypeReference } from "./root-messenger-discovery.mjs";
2
+ import execa from 'execa';
3
+ import * as fs from 'node:fs/promises';
4
+ import * as path from 'node:path';
5
+ import npmWhich from 'npm-which';
6
+ import yargs from 'yargs';
7
+ import { generate, resolveRepoUrl } from './generate.js';
8
+ import { parseRootCapabilitiesTypeReference } from './root-messenger-discovery.js';
35
9
  /**
36
10
  * Locate the Docusaurus binary in this package's `node_modules/.bin`. Using
37
11
  * `npm-which` lets the lookup track wherever the installed Docusaurus puts
@@ -40,7 +14,7 @@ import { parseRootCapabilitiesTypeReference } from "./root-messenger-discovery.m
40
14
  * @returns Absolute path to the `docusaurus` executable.
41
15
  */
42
16
  function resolveDocusaurus() {
43
- return npmWhich($__dirname(import.meta.url)).sync('docusaurus');
17
+ return npmWhich(import.meta.dirname).sync('docusaurus');
44
18
  }
45
19
  /**
46
20
  * Run a Docusaurus command.
@@ -69,15 +43,11 @@ async function runDocusaurus(command, cwd, extraEnv = {}) {
69
43
  * @param outDir - The output directory to set up.
70
44
  */
71
45
  async function setupSite(outDir) {
72
- const packageDir = path.resolve($__dirname(import.meta.url), '..');
46
+ const packageDir = path.resolve(import.meta.dirname, '..');
73
47
  const siteDir = path.join(packageDir, 'site');
74
48
  const packageNodeModules = path.join(packageDir, 'node_modules');
75
49
  const skip = new Set(['node_modules', 'docs', 'tsconfig.json']);
76
50
  console.log(`\nSetting up Docusaurus site in ${outDir}...`);
77
- // `fs.cp` has been available since Node 16.7 and only got the "stable"
78
- // marker in 22.3 — it's functional throughout our supported Node range
79
- // (`^18.18 || >=20`), even though the linter flags the older versions.
80
- // eslint-disable-next-line n/no-unsupported-features/node-builtins
81
51
  await fs.cp(siteDir, outDir, {
82
52
  recursive: true,
83
53
  filter: (source) => !skip.has(path.basename(source)),
@@ -323,4 +293,4 @@ main().catch((error) => {
323
293
  console.error(error);
324
294
  process.exitCode = 1;
325
295
  });
326
- //# sourceMappingURL=cli.mjs.map
296
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,kCAAkC,EAAE,MAAM,+BAA+B,CAAC;AAoDnF;;;;;;GAMG;AACH,SAAS,iBAAiB;IACxB,OAAO,QAAQ,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;;;GAQG;AACH,KAAK,UAAU,aAAa,CAC1B,OAAe,EACf,GAAW,EACX,QAAQ,GAA2B,EAAE;IAErC,MAAM,KAAK,CAAC,iBAAiB,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE;QAC1C,GAAG;QACH,KAAK,EAAE,SAAS;QAChB,GAAG,EAA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C;aAAM,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YACzC,MAAM,aAAa,CAAC,OAAO,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;YAE/D,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;gBACxC,MAAM,aAAa,CAAC,OAAO,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport execa from 'execa';\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport npmWhich from 'npm-which';\nimport yargs from 'yargs';\n\nimport { generate, resolveRepoUrl } from './generate.js';\nimport type { RootCapabilitiesTypeReference } from './root-messenger-discovery.js';\nimport { parseRootCapabilitiesTypeReference } from './root-messenger-discovery.js';\n\n/**\n * Arguments shared by both discovery strategies.\n */\ntype CommonArguments = {\n /** Whether to build the generated site. */\n build: boolean;\n /** Whether to serve the production build. */\n serve: boolean;\n /** Whether to serve the development site. */\n dev: boolean;\n /** Path to the project being documented. */\n 'project-path': string;\n /** Directory where generated documentation is written. */\n output?: string;\n /** Label displayed in the generated documentation. */\n 'project-label'?: string;\n /** URL where the generated site is served. */\n 'site-url'?: string;\n /** Base path where the generated site is served. */\n 'site-base-url'?: string;\n};\n\n/**\n * Arguments for the strategy that scans configured source directories.\n */\ntype ScanStrategyArguments = {\n /** The selected strategy. */\n strategy: 'scan';\n /** Directories, relative to the project root, to scan. */\n scanDir: string[];\n};\n\n/**\n * Arguments for the strategy that resolves a root messenger's type unions.\n */\ntype RootMessengerStrategyArguments = {\n /** The selected strategy. */\n strategy: 'root-messenger';\n /** The root messenger actions type reference. */\n rootActions: RootCapabilitiesTypeReference;\n /** The root messenger events type reference. */\n rootEvents: RootCapabilitiesTypeReference;\n};\n\n/**\n * Parsed CLI arguments, discriminated by the selected discovery strategy.\n */\ntype ParsedArguments = CommonArguments &\n (ScanStrategyArguments | RootMessengerStrategyArguments);\n\n/**\n * Locate the Docusaurus binary in this package's `node_modules/.bin`. Using\n * `npm-which` lets the lookup track wherever the installed Docusaurus puts\n * its binary, so a future Docusaurus upgrade can't break this path.\n *\n * @returns Absolute path to the `docusaurus` executable.\n */\nfunction resolveDocusaurus(): string {\n return npmWhich(import.meta.dirname).sync('docusaurus');\n}\n\n/**\n * Run a Docusaurus command.\n *\n * @param command - The docusaurus command (start, build, serve).\n * @param cwd - The site directory.\n * @param extraEnv - Extra environment variables passed through to the\n * Docusaurus process (e.g. `DOCS_PROJECT_LABEL`, `DOCS_COMMIT_SHA`,\n * `DOCS_REPO_URL`).\n */\nasync function runDocusaurus(\n command: string,\n cwd: string,\n extraEnv: Record<string, string> = {},\n): Promise<void> {\n await execa(resolveDocusaurus(), [command], {\n cwd,\n stdio: 'inherit',\n env: { ...process.env, ...extraEnv },\n });\n}\n\n/**\n * Copy site files into the output directory, skipping `node_modules`, `docs`,\n * and `tsconfig.json`. `docs` is owned by the doc generator and shouldn't be\n * carried over from the source `site/` directory. `tsconfig.json` extends the\n * monorepo's `tsconfig.base.json` via a relative path that only resolves from\n * the source location — it's there for IDE / lint inheritance, not for\n * Docusaurus, which uses `jiti` and doesn't consult the tsconfig at runtime.\n *\n * @param outDir - The output directory to set up.\n */\nasync function setupSite(outDir: string): Promise<void> {\n const packageDir = path.resolve(import.meta.dirname, '..');\n const siteDir = path.join(packageDir, 'site');\n const packageNodeModules = path.join(packageDir, 'node_modules');\n const skip = new Set(['node_modules', 'docs', 'tsconfig.json']);\n\n console.log(`\\nSetting up Docusaurus site in ${outDir}...`);\n\n await fs.cp(siteDir, outDir, {\n recursive: true,\n filter: (source) => !skip.has(path.basename(source)),\n });\n\n // Symlink this package's `node_modules` into the output so the copied\n // `docusaurus.config.ts` and the rest of Docusaurus's bundling pipeline can\n // resolve their deps the same way they do in the source tree. Without it,\n // Node's resolver walks up from the output and can't reach our nested deps\n // when the package is installed as a regular dependency by an external\n // consumer (e.g. `metamask-extension`, `metamask-mobile`).\n const linkPath = path.join(outDir, 'node_modules');\n try {\n // `'junction'` works cross-platform (POSIX ignores it; Windows uses it\n // without admin) — `'dir'` would require admin on Windows.\n await fs.symlink(packageNodeModules, linkPath, 'junction');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'EEXIST') {\n throw error;\n }\n }\n\n // Write a minimal package.json so Docusaurus doesn't warn about a missing one\n const pkgJsonPath = path.join(outDir, 'package.json');\n try {\n await fs.access(pkgJsonPath);\n } catch {\n await fs.writeFile(\n pkgJsonPath,\n JSON.stringify(\n { name: 'platform-api-docs-site', private: true },\n null,\n 2,\n ),\n );\n }\n}\n\n/**\n * Resolve the short Git commit SHA the docs are being generated from.\n * Returns null when the project isn't a git repo or git isn't available.\n *\n * @param projectPath - The project root path.\n * @returns The short SHA, or null on failure.\n */\nasync function resolveCommitSha(projectPath: string): Promise<string | null> {\n try {\n const { stdout } = await execa('git', ['rev-parse', '--short', 'HEAD'], {\n cwd: projectPath,\n });\n const trimmed = stdout.trim();\n return trimmed.length > 0 ? trimmed : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Reject flag combinations that don't make sense, so a mistaken invocation\n * fails instead of silently producing docs built the wrong way.\n *\n * Flags belonging to the strategy that wasn't selected are errors rather than\n * ignored. Used as a yargs `.check`, so failures print alongside usage.\n *\n * @param argv - The parsed arguments.\n * @param argv.strategy - The selected discovery strategy.\n * @param argv.rootActions - The parsed root actions type reference.\n * @param argv.rootEvents - The parsed root events type reference.\n * @param argv.scanDir - The additional directories to scan.\n * @returns True when the combination is valid.\n */\nfunction checkStrategyArgs({\n strategy,\n rootActions,\n rootEvents,\n scanDir = [],\n}: {\n strategy?: 'root-messenger' | 'scan';\n rootActions?: RootCapabilitiesTypeReference;\n rootEvents?: RootCapabilitiesTypeReference;\n scanDir?: string[];\n}): ScanStrategyArguments | RootMessengerStrategyArguments {\n if (strategy !== 'root-messenger') {\n if (rootActions !== undefined || rootEvents !== undefined) {\n throw new Error(\n '--root-actions and --root-events only apply to --strategy root-messenger.',\n );\n }\n return { strategy: 'scan', scanDir };\n }\n\n if (rootActions === undefined || rootEvents === undefined) {\n throw new Error(\n '--strategy root-messenger requires both --root-actions and --root-events, ' +\n 'each written as \"<file>#<TypeName>\".',\n );\n }\n if (scanDir.length > 0) {\n throw new Error(\n '--scan-dir only applies to --strategy scan; --strategy root-messenger reads ' +\n 'only the files named by --root-actions and --root-events.',\n );\n }\n\n return { strategy, rootActions, rootEvents };\n}\n\n/**\n * Parse and validate CLI arguments.\n *\n * @param argumentsForParsing - Arguments to parse, excluding the Node and\n * script paths.\n * @returns Parsed arguments, discriminated by discovery strategy.\n */\nasync function parseArguments(\n argumentsForParsing: string[] = process.argv.slice(2),\n): Promise<ParsedArguments> {\n const argv = await yargs(argumentsForParsing)\n .command(\n '$0 [project-path]',\n 'Produces documentation for the platform API, the set of actions and events available in clients through the message bus.',\n (yargsInstance) => {\n yargsInstance.positional('project-path', {\n type: 'string',\n description: 'Path to the project to scan',\n default: '.',\n });\n },\n )\n .option('build', {\n type: 'boolean',\n description:\n 'Generate platform API docs and build a production-ready site',\n default: false,\n })\n .option('serve', {\n type: 'boolean',\n description:\n 'Generate platform API docs and serve a production-ready site',\n default: false,\n })\n .option('dev', {\n type: 'boolean',\n description:\n 'Generate platform API docs and serve a development-only site',\n default: false,\n })\n .option('strategy', {\n type: 'string',\n description:\n 'How to find messenger actions and events. \"scan\" parses every source and declaration file looking for messenger types. \"root-messenger\" instead resolves the two types the project declares for its root messenger',\n default: 'scan',\n })\n .choices('strategy', ['scan', 'root-messenger'] as const)\n .option('root-actions', {\n type: 'string',\n coerce: parseRootCapabilitiesTypeReference,\n description:\n 'Type aliasing the union of every action on the root messenger, written as \"<file>#<TypeName>\" (required with --strategy root-messenger)',\n })\n .option('root-events', {\n type: 'string',\n coerce: parseRootCapabilitiesTypeReference,\n description:\n 'Type aliasing the union of every event on the root messenger, written as \"<file>#<TypeName>\" (required with --strategy root-messenger)',\n })\n .option('scan-dir', {\n type: 'array',\n string: true,\n description:\n 'Additional directories within the project to scan for messenger actions and events (note: may be specified multiple times)',\n default: [],\n })\n .option('output', {\n type: 'string',\n description: 'Output directory',\n })\n .option('project-label', {\n type: 'string',\n description:\n 'Short label identifying the project (e.g. \"Core\", \"Extension\") — stamped on the site title and headings',\n })\n .option('site-url', {\n type: 'string',\n description:\n 'Absolute URL the built site will be served from, e.g. https://metamask.github.io',\n })\n .option('site-base-url', {\n type: 'string',\n description:\n 'Path prefix the built site will be served under, e.g. /core/platform-api/',\n })\n .help()\n .parse();\n\n const strategyArguments = checkStrategyArgs(argv);\n\n const projectPath = argv['project-path'];\n if (typeof projectPath !== 'string') {\n throw new Error('Expected --project-path to be a string.');\n }\n\n return {\n build: argv.build,\n serve: argv.serve,\n dev: argv.dev,\n 'project-path': projectPath,\n output: argv.output,\n 'project-label': argv['project-label'],\n 'site-url': argv['site-url'],\n 'site-base-url': argv['site-base-url'],\n ...strategyArguments,\n };\n}\n\n/**\n * Main CLI entry point.\n */\nasync function main(): Promise<void> {\n const argv = await parseArguments();\n\n const resolvedProjectPath = path.resolve(argv['project-path']);\n const resolvedOutputDir = path.resolve(\n argv.output ?? path.join(resolvedProjectPath, '.platform-api-docs'),\n );\n const projectLabel =\n argv['project-label'] && argv['project-label'].length > 0\n ? argv['project-label']\n : null;\n const commitSha = await resolveCommitSha(resolvedProjectPath);\n const repoUrl = await resolveRepoUrl(resolvedProjectPath);\n\n // Step 1: Generate docs\n if (argv.strategy === 'root-messenger') {\n await generate({\n projectPath: resolvedProjectPath,\n outputDir: resolvedOutputDir,\n projectLabel,\n commitSha,\n strategy: 'root-messenger',\n rootActions: argv.rootActions,\n rootEvents: argv.rootEvents,\n });\n } else {\n const scanDirs = ['src', ...argv.scanDir].filter(\n (dir, index, dirs) => dirs.indexOf(dir) === index,\n );\n\n await generate({\n projectPath: resolvedProjectPath,\n outputDir: resolvedOutputDir,\n projectLabel,\n commitSha,\n strategy: 'scan',\n scanDirs,\n });\n }\n\n // Step 2: If --build, --serve, or --dev, set up and run Docusaurus\n if (argv.build || argv.serve || argv.dev) {\n await setupSite(resolvedOutputDir);\n\n // Translate CLI flags into the environment variables Docusaurus's\n // config reads. Keeping the CLI surface flag-only means consumers\n // (workflow files, package.json scripts) don't have to know how the\n // values are plumbed through to Docusaurus.\n const docusaurusEnv: Record<string, string> = {};\n if (projectLabel) {\n docusaurusEnv.DOCS_PROJECT_LABEL = projectLabel;\n }\n if (commitSha) {\n docusaurusEnv.DOCS_COMMIT_SHA = commitSha;\n }\n if (repoUrl) {\n docusaurusEnv.DOCS_REPO_URL = repoUrl;\n }\n if (typeof argv['site-url'] === 'string' && argv['site-url'].length > 0) {\n docusaurusEnv.DOCS_URL = argv['site-url'];\n }\n if (\n typeof argv['site-base-url'] === 'string' &&\n argv['site-base-url'].length > 0\n ) {\n docusaurusEnv.DOCS_BASE_URL = argv['site-base-url'];\n }\n\n if (argv.dev) {\n console.log('\\nStarting dev server...');\n await runDocusaurus('start', resolvedOutputDir, docusaurusEnv);\n } else if (argv.build || argv.serve) {\n console.log('\\nBuilding static site...');\n await runDocusaurus('build', resolvedOutputDir, docusaurusEnv);\n\n if (argv.serve) {\n console.log('\\nServing static site...');\n await runDocusaurus('serve', resolvedOutputDir, docusaurusEnv);\n }\n }\n }\n}\n\nmain().catch((error) => {\n console.error(error);\n process.exitCode = 1;\n});\n"]}
@@ -1,5 +1,5 @@
1
- import type { Identifier, InterfaceDeclaration, SourceFile, TypeAliasDeclaration, TypeReferenceNode } from "ts-morph";
2
- import type { MessengerCapabilityPacket } from "./types.cjs";
1
+ import type { Identifier, InterfaceDeclaration, SourceFile, TypeAliasDeclaration, TypeReferenceNode } from 'ts-morph';
2
+ import type { MessengerCapabilityPacket } from './types.js';
3
3
  /**
4
4
  * A messenger capability type whose body invokes a capability-type-constructor
5
5
  * utility such as `ControllerGetStateAction<...>` or
@@ -70,4 +70,4 @@ export declare function extractFromMessengerCapabilityTypeDeclaration(capability
70
70
  */
71
71
  export declare function extractFromSourceFile(sourceFile: SourceFile, projectPath: string): MessengerCapabilityPacket[];
72
72
  export {};
73
- //# sourceMappingURL=extraction.d.cts.map
73
+ //# sourceMappingURL=extraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../src/extraction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,oBAAoB,EAMpB,UAAU,EACV,oBAAoB,EAGpB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAGlB,OAAO,KAAK,EACV,yBAAyB,EAE1B,MAAM,YAAY,CAAC;AAiQpB;;;;;;GAMG;AACH,KAAK,6CAA6C,GAAG;IACnD,SAAS,EAAE,aAAa,CAAC;IACzB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IACzB,WAAW,EAAE,oBAAoB,CAAC;IAClC,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,EAAE,UAAU,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,KAAK,wCAAwC,GAAG;IAC9C,SAAS,EAAE,QAAQ,CAAC;IACpB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IACzB,WAAW,EAAE,oBAAoB,GAAG,oBAAoB,CAAC;CAC1D,CAAC;AAEF;;;;GAIG;AACH,KAAK,kCAAkC,GACnC,6CAA6C,GAC7C,wCAAwC,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,wBAAgB,0CAA0C,CACxD,WAAW,EAAE,oBAAoB,GAAG,oBAAoB,EACxD,IAAI,EAAE,QAAQ,GAAG,OAAO,GACvB,kCAAkC,GAAG,IAAI,CA4C3C;AA2QD;;;;;;;;;;GAUG;AACH,wBAAgB,6CAA6C,CAC3D,yBAAyB,EAAE,kCAAkC,EAC7D,WAAW,EAAE,MAAM,GAClB,yBAAyB,GAAG,IAAI,CAWlC;AA4QD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,GAClB,yBAAyB,EAAE,CAkB7B"}
@@ -1,5 +1,5 @@
1
- import * as path from "node:path";
2
- import { Node as NodeGuards } from "ts-morph";
1
+ import * as path from 'node:path';
2
+ import { Node as NodeGuards } from 'ts-morph';
3
3
  // ---------------------------------------------------------------------------
4
4
  // NOTE: `ts-morph` is used heavily in this file to parse and extract
5
5
  // information from TypeScript files. Although this library is not well
@@ -722,4 +722,4 @@ export function extractFromSourceFile(sourceFile, projectPath) {
722
722
  }
723
723
  return messengerCapabilityPackets;
724
724
  }
725
- //# sourceMappingURL=extraction.mjs.map
725
+ //# sourceMappingURL=extraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extraction.js","sourceRoot":"","sources":["../src/extraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAelC,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AAO9C,8EAA8E;AAC9E,qEAAqE;AACrE,uEAAuE;AACvE,8EAA8E;AAC9E,sEAAsE;AACtE,8EAA8E;AAE9E,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;;;;GAOG;AACH,SAAS,qBAAqB,CAAC,IAAY;IACzC,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;IACxE,0EAA0E;IAC1E,4EAA4E;IAC5E,4EAA4E;IAC5E,sBAAsB;IACtB,OAAO,iBAAiB,CAAC,OAAO,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IAC7E,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IACnE,MAAM,UAAU,GAAG,WAAW,CAAC,aAAa,EAAE,CAAC;IAE/C,OAAO;QACL,QAAQ,EAAE,WAAW,CAAC,OAAO,EAAE;QAC/B,UAAU;QACV,IAAI;QACJ,KAAK,EAAE,WAAW;QAClB,MAAM;QACN,OAAO;QACP,gBAAgB;QAChB,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC;QAChE,IAAI,EAAE,WAAW,CAAC,kBAAkB,EAAE;QACtC,UAAU,EAAE,qBAAqB,CAAC,WAAW,CAAC;KAC/C,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CACnC,UAAsB,EACtB,WAAmB;IAEnB,MAAM,oBAAoB,GAAG,wBAAwB,CAAC,UAAU,CAAC,CAAC;IAElE,MAAM,0BAA0B,GAC9B,0CAA0C,CAAC,oBAAoB,CAAC,CAAC;IAEnE,MAAM,0BAA0B,GAAgC,EAAE,CAAC;IACnE,KAAK,MAAM,yBAAyB,IAAI,0BAA0B,EAAE,CAAC;QACnE,MAAM,yBAAyB,GAC7B,6CAA6C,CAC3C,yBAAyB,EACzB,WAAW,CACZ,CAAC;QACJ,IAAI,yBAAyB,EAAE,CAAC;YAC9B,0BAA0B,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IACD,OAAO,0BAA0B,CAAC;AACpC,CAAC","sourcesContent":["import * as path from 'node:path';\nimport type {\n Identifier,\n InterfaceDeclaration,\n JSDocableNode,\n JSDocTag,\n MethodDeclaration,\n Node as TsMorphNode,\n PropertySignature,\n SourceFile,\n TypeAliasDeclaration,\n TypeElementTypes,\n TypeNode,\n TypeReferenceNode,\n} from 'ts-morph';\nimport { Node as NodeGuards } from 'ts-morph';\n\nimport type {\n MessengerCapabilityPacket,\n DocumentedParameter,\n} from './types.js';\n\n// ---------------------------------------------------------------------------\n// NOTE: `ts-morph` is used heavily in this file to parse and extract\n// information from TypeScript files. Although this library is not well\n// documented, it wraps the TypeScript AST fairly well, and you can get a good\n// sense of the AST by using this website: <https://ts-ast-viewer.com>\n// ---------------------------------------------------------------------------\n\n// ---------------------------------------------------------------------------\n// JSDoc utilities\n// ---------------------------------------------------------------------------\n\n/**\n * Convert `{@link X}` references inside a JSDoc comment string to plain\n * backtick code spans and escape any remaining (out-of-backtick) curly braces.\n * This way the output is safe to render in a MDX document.\n *\n * @param text - The raw text to normalize.\n * @returns The text with `@link` resolved and stray braces escaped.\n */\nfunction escapeJsDocTextForMdx(text: string): string {\n const withLinksResolved = text.replace(/\\{@link\\s+([^}]+)\\}/gu, '`$1`');\n // Escape the characters MDX reads as syntax rather than text: `{` and `}`\n // open an expression, and `<` opens a JSX tag — so an unescaped return type\n // like `Promise<Foo[]>` fails the site build. Content already inside a code\n // span is left alone.\n return withLinksResolved.replace(\n /`[^`]*`|([{}<])/gu,\n (match, special: string | undefined) =>\n special === undefined ? match : `\\\\${special}`,\n );\n}\n\n/**\n * Extract the comment text of a JSDoc tag — the part that comes after the tag\n * and any identifier, e.g. \"Some param\" in \"@param foo Some param\" —\n * normalizing whitespace to a single space so we can better control how it's\n * rendered within the site.\n *\n * @param tag - The JSDoc tag.\n * @returns The flattened comment text.\n */\nfunction extractJsDocTagComment(tag: JSDocTag): string {\n return (tag.getCommentText() ?? '').replace(/\\s+/gu, ' ').trim();\n}\n\n/**\n * Strip the conventional `- ` separator from the start of a `@param` tag's\n * comment.\n *\n * @param comment - The flattened comment text from a `@param` tag.\n * @returns The comment with any leading `- ` (or `– `, `— `) removed.\n */\nfunction stripJsDocParamSeparator(comment: string): string {\n return comment.replace(/^[-–—]\\s*/u, '');\n}\n\n/**\n * Extract JSDoc from a TypeScript AST node and decompose it into the parts we\n * need to render docs:\n *\n * - `description` — the body above the first tag, with `@deprecated` comments\n * appended as `**Deprecated:** <comment>` lines and normalized for MDX\n * (curly braces escaped, `{@link}` resolved),\n * - `params` — every `@param` tag in source order, with name and description,\n * - `returns` — the `@returns` tag's comment, or empty string if absent.\n *\n * Other tags (`@see`, `@throws`, `@template`, `@example`) are dropped.\n *\n * @param node - The AST node to extract JSDoc from (e.g. a type or a method).\n * @returns The decomposed JSDoc; empty strings/arrays when the node has no JSDoc.\n */\nfunction extractJsDoc(node: JSDocableNode): {\n description: string;\n params: DocumentedParameter[];\n returns: string;\n} {\n const jsDocs = node.getJsDocs();\n if (jsDocs.length === 0) {\n return { description: '', params: [], returns: '' };\n }\n\n const jsDoc = jsDocs[0];\n const descriptionBody = jsDoc.getDescription().trim();\n\n const deprecatedLines: string[] = [];\n const params: DocumentedParameter[] = [];\n let returns = '';\n\n for (const tag of jsDoc.getTags()) {\n const tagName = tag.getTagName();\n if (tagName === 'deprecated') {\n const comment = extractJsDocTagComment(tag);\n deprecatedLines.push(\n comment ? `**Deprecated:** ${comment}` : '**Deprecated:**',\n );\n } else if (tagName === 'param' && NodeGuards.isJSDocParameterTag(tag)) {\n const nameNode = tag.getNameNode();\n const paramName = nameNode.getText();\n if (!paramName) {\n continue;\n }\n const comment = extractJsDocTagComment(tag);\n params.push({\n name: paramName,\n description: escapeJsDocTextForMdx(stripJsDocParamSeparator(comment)),\n });\n } else if (tagName === 'returns' || tagName === 'return') {\n const comment = extractJsDocTagComment(tag);\n returns = escapeJsDocTextForMdx(comment);\n }\n }\n\n const description = escapeJsDocTextForMdx(\n [descriptionBody, ...deprecatedLines]\n .filter((line) => line.length > 0)\n .join('\\n'),\n );\n\n return { description, params, returns };\n}\n\n/**\n * Check whether a node has an `@deprecated` JSDoc tag.\n *\n * @param node - The AST node to check.\n * @returns True if the node has an `@deprecated` tag.\n */\nfunction hasDeprecatedJsDocTag(node: JSDocableNode): boolean {\n return node\n .getJsDocs()\n .flatMap((jsDoc) => jsDoc.getTags())\n .some((tag) => tag.getTagName() === 'deprecated');\n}\n\n// ---------------------------------------------------------------------------\n// Type-resolution helpers (powered by ts-morph's type checker)\n// ---------------------------------------------------------------------------\n\n/**\n * Locates the type that represents a method on a class (e.g.\n * `Class['method']`), which itself comes from a messenger action handler.\n *\n * @param typeNode - The node that represents the indexed access.\n * @returns The found method declaration, or null.\n */\nfunction findClassMethodDeclaration(\n typeNode: TypeNode | undefined,\n): MethodDeclaration | null {\n // Fundamental check: if we don't have `Class['method']`, we can't do anything.\n if (!NodeGuards.isIndexedAccessTypeNode(typeNode)) {\n return null;\n }\n\n // The type that represents the class being accessed.\n // EXAMPLE:\n // FooController['someMethod']\n // ^^^^^^^^^^^^^\n const objectType = typeNode.getObjectTypeNode();\n // The type that represents the property being accessed.\n // EXAMPLE:\n // FooController['someMethod']\n // ^^^^^^^^^^^^\n const indexType = typeNode.getIndexTypeNode();\n\n // To access a property on a type, it must be a type we can access properties of.\n if (\n !NodeGuards.isTypeReference(objectType) ||\n !NodeGuards.isLiteralTypeNode(indexType)\n ) {\n return null;\n }\n const indexLiteral = indexType.getLiteral();\n // Names of methods must be static strings; they cannot be template strings.\n if (\n !NodeGuards.isStringLiteral(indexLiteral) &&\n !NodeGuards.isNoSubstitutionTemplateLiteral(indexLiteral)\n ) {\n return null;\n }\n const methodName = indexLiteral.getLiteralValue();\n\n // Reject qualified-name type names, as we need a plain identifier to\n // resolve the symbol.\n // EXAMPLE:\n // import * as somePackage from '....js';\n // somePackage.FooController['someMethod']\n // ^^^^^^^^^^^^^^^^^^^^^^^^^\n const classNameNode = objectType.getTypeName();\n if (!NodeGuards.isIdentifier(classNameNode)) {\n return null;\n }\n\n // Since we know we have a type reference, we can assume that we have a symbol.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const localSymbol = classNameNode.getSymbol()!;\n // If we have a type imported from another file, ensure that when we access\n // the declaration, it's the type declaration in the other file, not the\n // import declaration in this file.\n // EXAMPLE:\n // import { FooController } from '@metamask/foo-controller';\n // FooController['someMethod']\n // ^^^^^^^^^^^^^\n const symbol = localSymbol.getAliasedSymbol() ?? localSymbol;\n\n for (const declaration of symbol.getDeclarations()) {\n // We must have a class to treat the property on the object type as a\n // method.\n if (NodeGuards.isClassDeclaration(declaration)) {\n const method = declaration.getMethod(methodName);\n if (method) {\n return method;\n }\n }\n }\n\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Method info\n// ---------------------------------------------------------------------------\n\n/**\n * Build the textual signature of a class method — its parameter list and\n * return type expressed as a TypeScript function type — so a handler that\n * references `Class['method']` can be rendered as `(arg: T) => R` instead of\n * the bare indexed-access syntax.\n *\n * @param method - The method declaration.\n * @returns The signature, e.g. `(id: number) => Promise<string>`.\n */\nfunction buildMethodSignature(method: MethodDeclaration): string {\n const signatureParams = method\n .getParameters()\n .map((param) => {\n const rest = param.isRestParameter() ? '...' : '';\n const paramName = param.getNameNode().getText();\n const optional = param.hasQuestionToken() ? '?' : '';\n const typeNode = param.getTypeNode();\n const paramType = typeNode ? typeNode.getText() : 'unknown';\n return `${rest}${paramName}${optional}: ${paramType}`;\n })\n .join(', ');\n\n const returnTypeNode = method.getReturnTypeNode();\n const returnType = returnTypeNode ? returnTypeNode.getText() : 'void';\n // For async methods, the declared return type already includes `Promise<>`,\n // so we don't need to wrap again.\n return `(${signatureParams}) => ${returnType}`;\n}\n\n// ---------------------------------------------------------------------------\n// Messenger discovery\n// ---------------------------------------------------------------------------\n\n/**\n * A messenger capability type whose body invokes a capability-type-constructor\n * utility such as `ControllerGetStateAction<...>` or\n * `ControllerStateChangeEvent<...>`. The walker classifies the body once when\n * it captures the declaration so the extractor can read the body's type name\n * and type arguments without re-running the AST guards.\n */\ntype ConstructorMessengerCapabilityTypeDeclaration = {\n bodyShape: 'constructor';\n kind: 'action' | 'event';\n declaration: TypeAliasDeclaration;\n body: TypeReferenceNode;\n typeName: Identifier;\n};\n\n/**\n * A messenger capability type whose declaration carries the action/event\n * shape directly — either an interface or a type alias for a type literal.\n * The extractor reads `type`, `handler`, and `payload` from the members.\n */\ntype ObjectMessengerCapabilityTypeDeclaration = {\n bodyShape: 'object';\n kind: 'action' | 'event';\n declaration: TypeAliasDeclaration | InterfaceDeclaration;\n};\n\n/**\n * Represents a type declaration (type alias or interface) for an individual\n * messenger action or event, tagged with the body shape the walker\n * identified.\n */\ntype MessengerCapabilityTypeDeclaration =\n | ConstructorMessengerCapabilityTypeDeclaration\n | ObjectMessengerCapabilityTypeDeclaration;\n\n/**\n * Tag a capability type declaration with the body shape it has, so the right\n * extractor can read it: 'constructor' for a capability-type-constructor\n * invocation such as `ControllerGetStateAction<...>`, 'object' otherwise.\n *\n * Callers must resolve unions and bare type references first, so that the\n * declaration reaching here is a leaf.\n *\n * @param declaration - The type alias or interface to classify.\n * @param kind - Whether to tag the declaration as 'action' or 'event'.\n * @returns The tagged declaration, or null for a qualified-name reference.\n */\nexport function classifyMessengerCapabilityTypeDeclaration(\n declaration: TypeAliasDeclaration | InterfaceDeclaration,\n kind: 'action' | 'event',\n): MessengerCapabilityTypeDeclaration | null {\n // Interfaces always carry their members directly.\n // EXAMPLE:\n // interface FooControllerSomeAction { ... }\n if (NodeGuards.isInterfaceDeclaration(declaration)) {\n return { bodyShape: 'object', kind, declaration };\n }\n\n const body = declaration.getTypeNode();\n\n // A TypeReference body is a capability-type-constructor invocation (e.g.\n // `ControllerGetStateAction<typeof name, State>`). Tag it so the constructor\n // extractor can read `body` directly without re-checking its shape.\n // EXAMPLE:\n // type FooControllerSomeAction = ControllerGetStateAction<...>\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n if (body && NodeGuards.isTypeReference(body)) {\n // Reject qualified-name constructor type names, as we need a plain\n // identifier to match the constructor by name.\n // EXAMPLE:\n // import * as somePackage from '....js';\n // type FooControllerSomeAction = somePackage.ControllerGetStateAction<...>\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n const constructorTypeName = body.getTypeName();\n if (!NodeGuards.isIdentifier(constructorTypeName)) {\n return null;\n }\n\n return {\n bodyShape: 'constructor',\n kind,\n declaration,\n body,\n typeName: constructorTypeName,\n };\n }\n\n // Anything else (a type literal, intersection, conditional, …) goes to the\n // literal extractor, which knows how to read members off a type literal and\n // rejects exotic shapes.\n // EXAMPLE:\n // type FooControllerSomeAction = { ... }\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n return { bodyShape: 'object', kind, declaration };\n}\n\n/**\n * Represents a type alias for a messenger. Only includes nodes representing the\n * `Actions` and `Events` type parameters.\n */\ntype ParsedMessengerTypeAlias = {\n actionsTypeParameter: TypeNode;\n eventsTypeParameter: TypeNode;\n};\n\n/**\n * Looks for Messenger types in the source file (that is, those that are type\n * aliases whose names end with \"Messenger\"), then extracts the `Actions` and\n * `Events` parameters from these types.\n *\n * @param sourceFile - The TypeScript source file to scan.\n * @returns A list of objects that represent messenger types.\n */\nfunction findMessengerTypeAliases(\n sourceFile: SourceFile,\n): ParsedMessengerTypeAlias[] {\n const parsedMessengerTypeAliases: ParsedMessengerTypeAlias[] = [];\n\n for (const typeAlias of sourceFile.getTypeAliases()) {\n if (!typeAlias.getName().endsWith('Messenger')) {\n continue;\n }\n\n const body = typeAlias.getTypeNode();\n // Basic check\n if (!body || !NodeGuards.isTypeReference(body)) {\n continue;\n }\n\n const typeArgs = body.getTypeArguments();\n // Messenger types always have 3 type parameters\n // (e.g. `Messenger<'FooController', Actions, Events>`)\n if (typeArgs.length < 3) {\n continue;\n }\n\n parsedMessengerTypeAliases.push({\n actionsTypeParameter: typeArgs[1],\n eventsTypeParameter: typeArgs[2],\n });\n }\n\n return parsedMessengerTypeAliases;\n}\n\n/**\n * Walks the `Actions` and `Events` type parameters of the given messenger\n * types, extracted in a previous step, to find all type declarations (i.e.,\n * statements) that represent individual messenger actions or events.\n *\n * @param parsedMessengerTypeAliases - The list of objects representing\n * messenger types, parsed in a previous step.\n * @returns The list of type aliases that represent messenger capabilities among\n * the given messenger types.\n */\nfunction findAllMessengerCapabilityTypeDeclarations(\n parsedMessengerTypeAliases: ParsedMessengerTypeAlias[],\n): MessengerCapabilityTypeDeclaration[] {\n const allCapabilityTypeDeclarations: MessengerCapabilityTypeDeclaration[] =\n [];\n let allVisitedTypeDeclarations: Set<TsMorphNode> = new Set();\n\n for (const {\n actionsTypeParameter,\n eventsTypeParameter,\n } of parsedMessengerTypeAliases) {\n for (const [typeParameter, kind] of [\n [actionsTypeParameter, 'action'],\n [eventsTypeParameter, 'event'],\n ] as const) {\n const result = recursivelyFindMessengerCapabilityTypeDeclarations(\n typeParameter,\n kind,\n allVisitedTypeDeclarations,\n );\n allCapabilityTypeDeclarations.push(...result.capabilityTypeDeclarations);\n allVisitedTypeDeclarations = result.visitedTypeDeclarations;\n }\n }\n\n return allCapabilityTypeDeclarations;\n}\n\n/**\n * Recursively walks a `ts-morph` AST node — at first the `Actions` or `Events`\n * type parameter of a messenger type, and then a node within that parameter —\n * to find all type aliases that represent individual messenger actions or\n * events, no matter how deeply the type aliases exist in the tree or in which\n * file they are located.\n *\n * @param node - The `ts-morph` AST node to walk.\n * @param kind - Whether to tag found type aliases as 'action' or 'event'.\n * @param visitedTypeDeclarations - A variable that tracks visited type aliases\n * and prevents duplicates.\n * @returns The list of extracted messenger capability type aliases as well as\n * an updated version of `visitedTypeDeclarations`.\n */\nfunction recursivelyFindMessengerCapabilityTypeDeclarations(\n node: TsMorphNode,\n kind: 'action' | 'event',\n visitedTypeDeclarations: Set<TsMorphNode>,\n): {\n capabilityTypeDeclarations: MessengerCapabilityTypeDeclaration[];\n visitedTypeDeclarations: Set<TsMorphNode>;\n} {\n const result: {\n capabilityTypeDeclarations: MessengerCapabilityTypeDeclaration[];\n visitedTypeDeclarations: Set<TsMorphNode>;\n } = {\n capabilityTypeDeclarations: [],\n visitedTypeDeclarations: new Set([...visitedTypeDeclarations]),\n };\n\n // If `node` is a union type, walk each type within it.\n // EXAMPLES:\n // type Actions = FooControllerSomeAction | FooControllerSomeOtherAction\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n // type FooControllerActions = FooControllerSomeAction | FooControllerSomeOtherAction\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n if (NodeGuards.isUnionTypeNode(node)) {\n for (const typeNode of node.getTypeNodes()) {\n const innerResult = recursivelyFindMessengerCapabilityTypeDeclarations(\n typeNode,\n kind,\n result.visitedTypeDeclarations,\n );\n result.capabilityTypeDeclarations.push(\n ...innerResult.capabilityTypeDeclarations,\n );\n for (const typeDeclaration of innerResult.visitedTypeDeclarations) {\n result.visitedTypeDeclarations.add(typeDeclaration);\n }\n }\n return result;\n }\n\n // If `node` is not a type reference, don't walk it.\n // EXAMPLE:\n // // Bad\n // type Actions = { ... }\n // ^^^^^^^\n // // Good\n // type Actions = FooControllerSomeAction;\n // ^^^^^^^^^^^^^^^^^^^^^^^\n // // Good\n // type Actions = ControllerGetStateAction<...>;\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n if (!NodeGuards.isTypeReference(node)) {\n return result;\n }\n\n const nameNode = node.getTypeName();\n\n // Reject qualified-name type names, as we need a plain identifier to\n // resolve the symbol.\n // EXAMPLE:\n // import * as somePackage from '....js';\n // type Actions = somePackage.FooControllerSomeAction;\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n if (!NodeGuards.isIdentifier(nameNode)) {\n return result;\n }\n\n // Since we know we have a type reference, we can assume that we have a symbol.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const localSymbol = nameNode.getSymbol()!;\n // If we have a type imported from another file, ensure that when we access\n // the declaration, it's the type declaration in the other file, not the\n // import declaration in this file.\n // EXAMPLE:\n // import { FooControllerSomeAction } from '@metamask/foo-controller';\n // type Actions = FooControllerSomeAction;\n // ^^^^^^^^^^^^^^^^^^^^^^^\n const symbol = localSymbol.getAliasedSymbol() ?? localSymbol;\n\n // At this point, we have a type *reference*, but we need to find the type\n // *declaration*.\n // For instance, if we have `FooControllerSomeAction`, we need to find\n // the full `type FooControllerSomeAction = ...` statement.\n for (const declaration of symbol.getDeclarations()) {\n // Prevent duplicates\n if (result.visitedTypeDeclarations.has(declaration)) {\n continue;\n }\n result.visitedTypeDeclarations.add(declaration);\n\n // If we have a type alias, then we have to handle a few scenarios.\n // EXAMPLES:\n // type FooControllerMethodActions = ...\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n // type FooControllerSomeAction = ...\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n if (NodeGuards.isTypeAliasDeclaration(declaration)) {\n const body = declaration.getTypeNode();\n\n // If the body is a union type or a plain type reference (not a utility\n // type), walk it.\n // EXAMPLES:\n // type FooControllerMethodActions = FooControllerSomeAction | FooControllerSomeOtherAction\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n // type DelegationControllerMethodActions = DelegationControllerSignDelegationAction\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n if (\n body &&\n (NodeGuards.isUnionTypeNode(body) ||\n (NodeGuards.isTypeReference(body) &&\n body.getTypeArguments().length === 0))\n ) {\n const innerResult = recursivelyFindMessengerCapabilityTypeDeclarations(\n body,\n kind,\n result.visitedTypeDeclarations,\n );\n result.capabilityTypeDeclarations.push(\n ...innerResult.capabilityTypeDeclarations,\n );\n for (const typeDeclaration of innerResult.visitedTypeDeclarations) {\n result.visitedTypeDeclarations.add(typeDeclaration);\n }\n continue;\n }\n\n // Everything else is a leaf capability type — a capability-type-\n // constructor invocation (e.g. `ControllerGetStateAction<typeof name,\n // State>`) or a literal object type. Tag it so the matching extractor\n // can read it without re-checking its shape.\n // EXAMPLES:\n // type FooControllerSomeAction = ControllerGetStateAction<...>\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n // type FooControllerSomeAction = { ... }\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n const classified = classifyMessengerCapabilityTypeDeclaration(\n declaration,\n kind,\n );\n if (classified) {\n result.capabilityTypeDeclarations.push(classified);\n }\n }\n\n // Interfaces always carry their members directly — tag for the literal\n // extractor.\n // EXAMPLE:\n // interface FooControllerSomeAction { ... }\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n else if (NodeGuards.isInterfaceDeclaration(declaration)) {\n result.capabilityTypeDeclarations.push({\n bodyShape: 'object',\n kind,\n declaration,\n });\n }\n }\n\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Per-statement extraction\n// ---------------------------------------------------------------------------\n\n/**\n * Given the declaration of a messenger capability type, extract information\n * about it (action/event type string, handler/payload arguments and return\n * type, etc.)\n *\n * @param capabilityTypeDeclaration - The statement that declared the type for a\n * messenger action or event, extracted in a previous step.\n * @param projectPath - Project root, used for computing relative source paths.\n * @returns Information that may be extracted from the messenger capability type\n * (may be `null` if the type is ineligible for extraction).\n */\nexport function extractFromMessengerCapabilityTypeDeclaration(\n capabilityTypeDeclaration: MessengerCapabilityTypeDeclaration,\n projectPath: string,\n): MessengerCapabilityPacket | null {\n if (capabilityTypeDeclaration.bodyShape === 'constructor') {\n return tryToExtractFromCapabilityTypeConstructor(\n capabilityTypeDeclaration,\n projectPath,\n );\n }\n return tryToExtractFromMessengerCapabilityTypeLiteral(\n capabilityTypeDeclaration,\n projectPath,\n );\n}\n\n/**\n * If a messenger capability type is a type alias or interface and its body is\n * a literal object type — i.e. one of:\n *\n * - `{ type: '...'; handler: ... }` (action)\n * - `{ type: '...'; payload: ... }` (event)\n *\n * then this function extracts information about the type (action/event type\n * string, handler/payload arguments and return type, etc.)\n *\n * @param capabilityTypeDeclaration - The statement that declared the type for a\n * messenger action or event, extracted in a previous step.\n * @param projectPath - Project root, used for computing relative source paths.\n * @returns The extracted capability packet, or null if the shape of the type\n * doesn't match.\n */\nfunction tryToExtractFromMessengerCapabilityTypeLiteral(\n capabilityTypeDeclaration: ObjectMessengerCapabilityTypeDeclaration,\n projectPath: string,\n): MessengerCapabilityPacket | null {\n const { declaration, kind } = capabilityTypeDeclaration;\n\n // We must have a object type alias or an interface, and the body must not be empty.\n // EXAMPLES:\n // // Good\n // type FooControllerSomeAction = {\n // type: 'FooController:getState';\n // handler: FooController['getState'];\n // }\n // // Good\n // interface FooControllerSomeAction {\n // type: 'FooController:getState';\n // handler: FooController['getState'];\n // }\n // // Bad\n // type FooControllerSomeAction = {};\n // // Bad\n // interface FooControllerSomeAction {};\n let members: TypeElementTypes[] | undefined;\n if (NodeGuards.isTypeAliasDeclaration(declaration)) {\n const body = declaration.getTypeNode();\n if (body && NodeGuards.isTypeLiteral(body)) {\n members = body.getMembers();\n }\n } else {\n members = declaration.getMembers();\n }\n if (!members) {\n return null;\n }\n\n const propertySignatures = members.filter(\n NodeGuards.isPropertySignature.bind(NodeGuards),\n );\n\n // Actions and events must have a `type`, and it must be a string.\n const typeString = getMessengerCapabilityTypeString(propertySignatures);\n if (!typeString) {\n return null;\n }\n\n // Actions must have a `handler`, and events must have a `payload`.\n const handlerOrPayloadProperty = findProperty(\n propertySignatures,\n kind === 'action' ? 'handler' : 'payload',\n );\n if (!handlerOrPayloadProperty) {\n return null;\n }\n\n const handlerOrPayloadPropertyTypeNode =\n // We can assume the property has a type; otherwise it wouldn't compile.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n handlerOrPayloadProperty.getTypeNode()!;\n let handlerOrPayloadSignature = handlerOrPayloadPropertyTypeNode\n .getText()\n .trim();\n\n const { description: jsDoc, params, returns } = extractJsDoc(declaration);\n\n // For actions that represent methods (e.g. `Class['method']`), walk the\n // handler type to find the underlying handler signature\n // (e.g. `(id: number) => Promise<string>`).\n if (kind === 'action') {\n const methodDeclaration = findClassMethodDeclaration(\n handlerOrPayloadPropertyTypeNode,\n );\n if (methodDeclaration) {\n handlerOrPayloadSignature = buildMethodSignature(methodDeclaration);\n }\n }\n\n const sourceFile = declaration.getSourceFile();\n return {\n typeName: declaration.getName(),\n typeString,\n kind,\n jsDoc,\n params,\n returns,\n handlerOrPayload: handlerOrPayloadSignature,\n sourceFile: path.relative(projectPath, sourceFile.getFilePath()),\n line: declaration.getStartLineNumber(),\n deprecated: hasDeprecatedJsDocTag(declaration),\n };\n}\n\n/**\n * Searches the property signatures of a messenger capability type alias or\n * interface to find the value of the `type` property, and then resolves it to a\n * string (assuming it is already a string or a resolvable template literal).\n *\n * @param capabilityTypeProperties - The property signatures of the messenger\n * capability type.\n * @returns The extracted capability type string, or null if `type` cannot be\n * found in the members or it is an unexpected node.\n */\nfunction getMessengerCapabilityTypeString(\n capabilityTypeProperties: PropertySignature[],\n): string | null {\n const typeProperty = findProperty(capabilityTypeProperties, 'type');\n if (!typeProperty) {\n return null;\n }\n\n // A `type` property without an explicit type wouldn't compile.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const typeNode = typeProperty.getTypeNode()!;\n\n // Ask the type checker to resolve the value of `type`. We're looking for\n // `type` to be either a string literal or template literal.\n //\n // EXAMPLES:\n // type FooControllerSomeAction = {\n // type: 'FooController:someAction';\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^\n // }\n // type FooControllerSomeAction = {\n // type: `FooController:someAction`;\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^\n // }\n // type FooControllerSomeAction = {\n // type: `${typeof CONTROLLER_NAME}:someAction`;\n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n // }\n const resolvedType = typeNode.getType();\n if (resolvedType.isStringLiteral()) {\n // Type assertion: There aren't any type guards we can use to narrow this\n // type further.\n const literalValue = resolvedType.getLiteralValueOrThrow() as string;\n\n // Messenger action/event types need to be namespaced.\n if (literalValue.includes(':')) {\n return literalValue;\n }\n }\n\n return null;\n}\n\n/**\n * Finds a specific property in a list of property signatures for an object\n * type.\n *\n * @param propertySignatures - The property signatures of the messenger\n * capability type.\n * @param name - The property name to find.\n * @returns The property signature, or null.\n */\nfunction findProperty(\n propertySignatures: PropertySignature[],\n name: string,\n): PropertySignature | null {\n for (const property of propertySignatures) {\n const propertyNameNode = property.getNameNode();\n if (\n !NodeGuards.isIdentifier(propertyNameNode) ||\n propertyNameNode.getText() !== name\n ) {\n continue;\n }\n\n return property;\n }\n\n return null;\n}\n\n/**\n * If a messenger capability type is a type alias for either the\n * `ControllerGetStateAction` or `ControllerStateChangeEvent` type constructors,\n * then this function extracts information about the type (action/event type\n * string, handler/payload arguments and return type, etc.)\n *\n * @param capabilityTypeDeclaration - The statement that declared the type for a\n * messenger action or event, extracted in a previous step.\n * @param projectPath - Project root, used for computing relative source paths.\n * @returns The extracted capability packet, or null if the shape of the type\n * doesn't match.\n */\nfunction tryToExtractFromCapabilityTypeConstructor(\n capabilityTypeDeclaration: ConstructorMessengerCapabilityTypeDeclaration,\n projectPath: string,\n): MessengerCapabilityPacket | null {\n const { declaration, kind, body, typeName } = capabilityTypeDeclaration;\n\n // The name of the utility type should be either `ControllerGetStateAction`\n // (for actions) or `ControllerStateChangeEvent` (for events).\n // EXAMPLES:\n // type FooControllerSomeAction = ControllerGetStateAction<...>\n // type FooControllerSomeEvent = ControllerStateChangeEvent<...>\n const expectedConstructor =\n kind === 'action'\n ? 'ControllerGetStateAction'\n : 'ControllerStateChangeEvent';\n if (typeName.getText() !== expectedConstructor) {\n return null;\n }\n\n // The utility type should take two parameters.\n // EXAMPLES:\n // type FooControllerSomeAction = ControllerGetStateAction<..., ...>\n // type FooControllerSomeEvent = ControllerStateChangeEvent<..., ...>\n const typeArgs = body.getTypeArguments();\n if (typeArgs.length < 2) {\n return null;\n }\n\n const namespaceArgType = typeArgs[0].getType();\n // The first parameter should be a string literal.\n // EXAMPLES:\n // type FooControllerSomeAction = ControllerGetStateAction<'FooController', ...>\n // type FooControllerSomeAction = ControllerGetStateAction<typeof CONTROLLER_NAME, ...>\n if (!namespaceArgType.isStringLiteral()) {\n return null;\n }\n // Type assertion: There aren't any type guards we can use to narrow this type\n // further.\n const namespace = namespaceArgType.getLiteralValueOrThrow() as string;\n\n const typeString =\n kind === 'action' ? `${namespace}:getState` : `${namespace}:stateChange`;\n const stateArgText = typeArgs[1].getText();\n const handlerOrPayload =\n kind === 'action' ? `() => ${stateArgText}` : `[${stateArgText}, Patch[]]`;\n const { description, params, returns } = extractJsDoc(declaration);\n const sourceFile = declaration.getSourceFile();\n\n return {\n typeName: declaration.getName(),\n typeString,\n kind,\n jsDoc: description,\n params,\n returns,\n handlerOrPayload,\n sourceFile: path.relative(projectPath, sourceFile.getFilePath()),\n line: declaration.getStartLineNumber(),\n deprecated: hasDeprecatedJsDocTag(declaration),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Public entry points\n// ---------------------------------------------------------------------------\n\n/**\n * Extract information (action/event type string, handler/payload arguments and\n * return type, etc.) about every messenger action or event type which is\n * reachable through all of a source file's `*Messenger` type declarations.\n *\n * The caller is responsible for ensuring `sourceFile` (plus any files it\n * imports from) belongs to a `ts-morph` Project so cross-file symbol resolution\n * works.\n *\n * @param sourceFile - The TypeScript source file to extract from.\n * @param projectPath - Project root, used for computing relative source paths.\n * @returns The extracted information about actions and events.\n */\nexport function extractFromSourceFile(\n sourceFile: SourceFile,\n projectPath: string,\n): MessengerCapabilityPacket[] {\n const messengerTypeAliases = findMessengerTypeAliases(sourceFile);\n\n const capabilityTypeDeclarations =\n findAllMessengerCapabilityTypeDeclarations(messengerTypeAliases);\n\n const messengerCapabilityPackets: MessengerCapabilityPacket[] = [];\n for (const capabilityTypeDeclaration of capabilityTypeDeclarations) {\n const messengerCapabilityPacket =\n extractFromMessengerCapabilityTypeDeclaration(\n capabilityTypeDeclaration,\n projectPath,\n );\n if (messengerCapabilityPacket) {\n messengerCapabilityPackets.push(messengerCapabilityPacket);\n }\n }\n return messengerCapabilityPackets;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { RootCapabilitiesTypeReference } from "./root-messenger-discovery.cjs";
1
+ import type { RootCapabilitiesTypeReference } from './root-messenger-discovery.js';
2
2
  /**
3
3
  * Options for the `scan` strategy, which reads every `*Messenger` type alias
4
4
  * in every file it can find. Used when no single messenger aggregates every
@@ -67,4 +67,4 @@ export declare function resolveRepoUrl(projectPath: string): Promise<string | nu
67
67
  */
68
68
  export declare function generate(options: GenerateOptions): Promise<GenerateResult>;
69
69
  export {};
70
- //# sourceMappingURL=generate.d.cts.map
70
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAQnF;;;;GAIG;AACH,KAAK,mBAAmB,GAAG;IACzB,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,KAAK,4BAA4B,GAAG;IAClC,6BAA6B;IAC7B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,iDAAiD;IACjD,WAAW,EAAE,6BAA6B,CAAC;IAC3C,gDAAgD;IAChD,UAAU,EAAE,6BAA6B,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,GAAG,CAAC,mBAAmB,GAAG,4BAA4B,CAAC,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAmEF;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAuBxB;AA+dD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC,CAsCzB"}
@@ -1,12 +1,12 @@
1
- import { directoryExists } from "@metamask/utils/node";
2
- import { execFile } from "node:child_process";
3
- import * as fs from "node:fs/promises";
4
- import * as path from "node:path";
5
- import { promisify } from "node:util";
6
- import { extractFromSourceFile } from "./extraction.mjs";
7
- import { generateIndexPage, generateNamespacePage, generateSidebars } from "./markdown.mjs";
8
- import { discoverFromRootMessengerCapabilitiesTypes } from "./root-messenger-discovery.mjs";
9
- import { createProject } from "./ts-project.mjs";
1
+ import { directoryExists } from '@metamask/utils/node';
2
+ import { execFile } from 'node:child_process';
3
+ import * as fs from 'node:fs/promises';
4
+ import * as path from 'node:path';
5
+ import { promisify } from 'node:util';
6
+ import { extractFromSourceFile } from './extraction.js';
7
+ import { generateIndexPage, generateNamespacePage, generateSidebars, } from './markdown.js';
8
+ import { discoverFromRootMessengerCapabilitiesTypes } from './root-messenger-discovery.js';
9
+ import { createProject } from './ts-project.js';
10
10
  /** How many skipped capability types to name before summarizing the rest. */
11
11
  const MAX_SKIPPED_SHOWN = 10;
12
12
  /**
@@ -474,4 +474,4 @@ export async function generate(options) {
474
474
  events: totalEvents,
475
475
  };
476
476
  }
477
- //# sourceMappingURL=generate.mjs.map
477
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAA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IAEH,MAAM,YAAY,GAAG,UAAU,CAAC,MAAM,CACpC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EACpC,CAAC,CACF,CAAC;IACF,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAE9E,OAAO,CAAC,GAAG,CACT,sBAAsB,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,GAAG,CACnG,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,cAAc,YAAY,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,aAAa,WAAW,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAExD,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,MAAM;QAC7B,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,WAAW;KACpB,CAAC;AACJ,CAAC","sourcesContent":["import { directoryExists } from '@metamask/utils/node';\nimport { execFile } from 'node:child_process';\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { promisify } from 'node:util';\nimport type { Project } from 'ts-morph';\n\nimport { extractFromSourceFile } from './extraction.js';\nimport {\n generateIndexPage,\n generateNamespacePage,\n generateSidebars,\n} from './markdown.js';\nimport type { RootCapabilitiesTypeReference } from './root-messenger-discovery.js';\nimport { discoverFromRootMessengerCapabilitiesTypes } from './root-messenger-discovery.js';\nimport { createProject } from './ts-project.js';\nimport type { MessengerCapabilityPacket, NamespaceGroup } from './types.js';\n\n/** How many skipped capability types to name before summarizing the rest. */\nconst MAX_SKIPPED_SHOWN = 10;\n\n/**\n * Options for the `scan` strategy, which reads every `*Messenger` type alias\n * in every file it can find. Used when no single messenger aggregates every\n * capability.\n */\ntype ScanStrategyOptions = {\n /** The selected strategy. */\n strategy: 'scan';\n /** Directories, relative to the project root, to scan. */\n scanDirs: string[];\n};\n\n/**\n * Options for the `root-messenger` strategy, which walks the types a\n * project declares for its root messenger capabilities instead of scanning the\n * entire repo. Used when one messenger carries every action and event.\n */\ntype RootMessengerStrategyOptions = {\n /** The selected strategy. */\n strategy: 'root-messenger';\n /** The root messenger actions type reference. */\n rootActions: RootCapabilitiesTypeReference;\n /** The root messenger events type reference. */\n rootEvents: RootCapabilitiesTypeReference;\n};\n\n/**\n * Options for the generate function.\n */\nexport type GenerateOptions = {\n /** Absolute path to the project to scan. */\n projectPath: string;\n /** Absolute path to the output directory for generated docs. */\n outputDir: string;\n /**\n * Short label identifying the project the docs were generated from (e.g.\n * \"Core\", \"Extension\"). Stamped in the index page title.\n */\n projectLabel?: string | null;\n /**\n * Git commit SHA the docs were generated from. Stamped in the index page\n * intro so engineers know how current the site is.\n */\n commitSha?: string | null;\n} & (ScanStrategyOptions | RootMessengerStrategyOptions);\n\n/**\n * Result returned by the generate function.\n */\nexport type GenerateResult = {\n namespaces: number;\n actions: number;\n events: number;\n};\n\n/**\n * The set of directories available to scan for messenger types, resolved from\n * the project's filesystem layout.\n */\ntype ScanSources = {\n /** User-configured scan dirs that exist on disk (relative to projectPath). */\n scanDirs: string[];\n /** Absolute path to `packages/` if it exists, otherwise null. */\n packagesDir: string | null;\n /** Absolute path to `node_modules/@metamask/` if it exists, otherwise null. */\n nodeModulesDir: string | null;\n};\n\n/**\n * Compute a deduplication score for a messenger item, preferring items with\n * JSDoc and from the \"home\" package whose name matches the namespace.\n *\n * @param item - The messenger item to score.\n * @returns A numeric score (higher is better).\n */\nfunction deduplicationScore(item: MessengerCapabilityPacket): number {\n const jsDocScore = item.jsDoc ? 2 : 0;\n const namespacePrefix = item.typeString\n .split(':')[0]\n .replace(/(?:Controller|Service)$/u, '')\n .toLowerCase();\n const homeScore =\n namespacePrefix.length > 0 &&\n item.sourceFile.toLowerCase().includes(namespacePrefix)\n ? 1\n : 0;\n return jsDocScore + homeScore;\n}\n\nconst execFileAsync = promisify(execFile);\n\n/**\n * Resolve the default branch of a project's `origin` remote by reading the\n * symbolic ref `refs/remotes/origin/HEAD`. Falls back to `main` if the\n * symbolic ref isn't set (e.g. in shallow CI clones).\n *\n * @param projectPath - Absolute path to the project root.\n * @returns The default branch name (e.g. \"main\", \"master\", \"develop\").\n */\nasync function resolveDefaultBranch(projectPath: string): Promise<string> {\n try {\n const { stdout } = await execFileAsync(\n 'git',\n ['symbolic-ref', '--short', 'refs/remotes/origin/HEAD'],\n { cwd: projectPath },\n );\n // stdout looks like \"origin/main\"; strip the leading \"origin/\".\n const trimmed = stdout.trim();\n const slash = trimmed.indexOf('/');\n return slash === -1\n ? // istanbul ignore next: defensive — `symbolic-ref --short` always\n // returns `origin/<branch>` when the symbolic ref is set; this\n // fallback only matters if git's output format ever changes.\n trimmed || 'main'\n : trimmed.slice(slash + 1);\n } catch {\n return 'main';\n }\n}\n\n/**\n * Resolve the bare GitHub repository URL for a project by reading its\n * `origin` remote.\n *\n * @param projectPath - Absolute path to the project root.\n * @returns A URL like \"https://github.com/Owner/Repo\" or null when the remote\n * isn't a GitHub URL or can't be read.\n */\nexport async function resolveRepoUrl(\n projectPath: string,\n): Promise<string | null> {\n try {\n const { stdout: remoteRaw } = await execFileAsync(\n 'git',\n ['remote', 'get-url', 'origin'],\n { cwd: projectPath },\n );\n\n const remote = remoteRaw.trim();\n\n // Parse owner/repo from SSH or HTTPS remote URLs\n // Handles aliases like github.com-Org used in SSH configs\n const match = remote.match(\n /github\\.com[^:/]*[:/]([^/]+\\/[^/]+?)(?:\\.git)?$/u,\n );\n if (!match) {\n return null;\n }\n\n return `https://github.com/${match[1]}`;\n } catch {\n return null;\n }\n}\n\n/**\n * Resolve the GitHub blob base URL used for per-line source links.\n *\n * Prefers the documented commit SHA when one is available so the links point\n * at the exact revision the docs were generated from; falls back to the\n * default branch otherwise.\n *\n * @param projectPath - Absolute path to the project root.\n * @param commitSha - Optional commit SHA to use as the ref. When null, the\n * default branch is used instead.\n * @returns A base URL like \"https://github.com/Owner/Repo/blob/<ref>/\" or null.\n */\nasync function resolveRepoBaseUrl(\n projectPath: string,\n commitSha: string | null,\n): Promise<string | null> {\n const repoUrl = await resolveRepoUrl(projectPath);\n if (!repoUrl) {\n return null;\n }\n const ref = commitSha ?? (await resolveDefaultBranch(projectPath));\n return `${repoUrl}/blob/${ref}/`;\n}\n\n/**\n * Discover which configured source locations actually exist on disk.\n *\n * @param projectPath - The project root path.\n * @param scanDirs - User-configured scan directories relative to projectPath.\n * @returns A ScanSources object describing the locations to scan.\n */\nasync function discoverScanSources(\n projectPath: string,\n scanDirs: string[],\n): Promise<ScanSources> {\n const existingScanDirs: string[] = [];\n for (const dir of scanDirs) {\n if (await directoryExists(path.join(projectPath, dir))) {\n existingScanDirs.push(dir);\n }\n }\n\n const packagesDir = path.join(projectPath, 'packages');\n const nodeModulesDir = path.join(projectPath, 'node_modules', '@metamask');\n\n return {\n scanDirs: existingScanDirs,\n packagesDir: (await directoryExists(packagesDir)) ? packagesDir : null,\n nodeModulesDir: (await directoryExists(nodeModulesDir))\n ? nodeModulesDir\n : null,\n };\n}\n\n/**\n * Log a human-readable description of which source locations will be scanned.\n *\n * @param sources - The resolved scan sources.\n */\nfunction logScanPlan(sources: ScanSources): void {\n const summary: string[] = [];\n for (const dir of sources.scanDirs) {\n summary.push(`${dir}/ (.ts)`);\n }\n if (sources.packagesDir) {\n summary.push('packages/*/src (.ts)');\n }\n if (sources.nodeModulesDir) {\n summary.push('node_modules/@metamask/*/dist (.d.cts)');\n }\n console.log(\n `Scanning ${summary.join(', ')} for Messenger action/event types...`,\n );\n}\n\n/**\n * Patterns excluded when scanning TypeScript sources: build output, tests, and\n * declaration files (which are only read under `node_modules/@metamask`, via\n * the separate set below).\n *\n * Every pattern is anchored to `root` rather than written as a bare\n * `!**‍/*.test.ts`. A matcher resolves an unanchored negation against the\n * process's working directory, not against the pattern it accompanies, so an\n * unanchored exclusion silently stops excluding anything the moment the scanned\n * path falls outside the working directory — which is the normal case, since\n * this runs from wherever the consumer invoked it.\n *\n * `contentRoot` must be the directory the matched *files* live under, not an\n * ancestor of it. Anchoring at `packages/` rather than `packages/*‍/src` would\n * make the first path segment a package name, so a workspace package called\n * `test` or `dist` would match `test/**` and be dropped whole.\n *\n * @param contentRoot - Resolved directory, or directory glob, that the matched\n * files live directly under.\n * @returns The exclusion patterns.\n */\nfunction buildTsSourceExclusions(contentRoot: string): string[] {\n return [\n 'node_modules/**',\n 'dist/**',\n '__tests__/**',\n 'tests/**',\n 'test/**',\n '__mocks__/**',\n '*.test.ts',\n '*.test-d.ts',\n '*.spec.ts',\n '*.d.ts',\n ].map((pattern) => `!${contentRoot}/**/${pattern}`);\n}\n\n/**\n * Add every file matching a set of glob patterns to the project, in a stable\n * order.\n *\n * ts-morph promises nothing about the order it returns matches in, and\n * deduplication downstream keeps the first of two equally-scored items, so an\n * unsorted list would let the filesystem decide which source link a capability\n * gets.\n *\n * Ordering is by code unit rather than `localeCompare`, which collates\n * differently depending on the locale the process happens to run under.\n *\n * @param project - The shared ts-morph project.\n * @param patterns - Glob patterns to match, including `!` exclusions.\n * @returns The added source files, sorted by path.\n */\nfunction addSourceFiles(\n project: Project,\n patterns: string[],\n): ReturnType<Project['addSourceFilesAtPaths']> {\n return project.addSourceFilesAtPaths(patterns).sort(\n (fileA, fileB) =>\n // Subtracting the two comparisons keeps this branchless, so it reads\n // the same whichever order the matcher happened to return.\n Number(fileA.getFilePath() > fileB.getFilePath()) -\n Number(fileA.getFilePath() < fileB.getFilePath()),\n );\n}\n\n/**\n * Build a glob pattern from a directory path.\n *\n * Two things have to be true of the result. Glob syntax is always\n * forward-slashed, including on Windows, where `path.join` would produce\n * backslashes that a matcher reads as escapes. And the path must be fully\n * resolved: the matcher does not follow a symlinked *ancestor* of the pattern,\n * so a project under `/tmp` or `/var` on macOS (both symlinks) would match\n * nothing at all.\n *\n * @param segments - Path segments to join.\n * @returns The joined, resolved path with forward slashes.\n */\nasync function toGlobPath(...segments: string[]): Promise<string> {\n // Safe to resolve without a fallback: `discoverScanSources` has already\n // confirmed every directory reaching this point exists.\n const resolved = await fs.realpath(path.join(...segments));\n return resolved.replace(/\\\\/gu, '/');\n}\n\n/**\n * Scan every source location described by `sources` (scan directories first,\n * then workspace packages, then published declaration files) and return all\n * extracted messenger items.\n *\n * A single ts-morph Project is shared across every file so the type checker can\n * resolve cross-file references (e.g. a `*Messenger` declaration in one file\n * walking through an imported umbrella union into an auto-generated\n * `*-method-action-types.ts` sibling).\n *\n * @param projectPath - The project root path.\n * @param sources - The set of source locations to scan.\n * @returns A flat list of all extracted messenger items.\n */\nasync function scanSources(\n projectPath: string,\n sources: ScanSources,\n): Promise<MessengerCapabilityPacket[]> {\n const project = createProject();\n const sourceFiles = [];\n\n for (const dir of sources.scanDirs) {\n const root = await toGlobPath(projectPath, dir);\n sourceFiles.push(\n ...addSourceFiles(project, [\n `${root}/**/*.ts`,\n ...buildTsSourceExclusions(root),\n ]),\n );\n }\n\n if (sources.packagesDir) {\n const root = await toGlobPath(sources.packagesDir);\n // Anchored at each package's `src`, not at `packages` itself, so a package\n // whose name collides with an exclusion (`test`, `dist`) isn't dropped.\n const contentRoot = `${root}/*/src`;\n sourceFiles.push(\n ...addSourceFiles(project, [\n `${contentRoot}/**/*.ts`,\n ...buildTsSourceExclusions(contentRoot),\n ]),\n );\n }\n\n if (sources.nodeModulesDir) {\n const root = await toGlobPath(sources.nodeModulesDir);\n sourceFiles.push(...addSourceFiles(project, [`${root}/*/dist/**/*.d.cts`]));\n }\n\n // Matched paths are fully resolved, so the root they are made relative to\n // has to be resolved the same way or every source link becomes a `../..`\n // walk out of the project.\n const resolvedProjectPath = await fs.realpath(projectPath);\n\n const allItems: MessengerCapabilityPacket[] = [];\n for (const sourceFile of sourceFiles) {\n allItems.push(...extractFromSourceFile(sourceFile, resolvedProjectPath));\n }\n return allItems;\n}\n\n/**\n * Replace a previously-seen item in its existing namespace group with a\n * higher-scoring duplicate. Handles the case where the duplicate is a\n * different kind (action vs event) by moving it between lists.\n *\n * @param byNamespace - Map of namespace to its group.\n * @param previous - The previously stored item.\n * @param replacement - The new item to replace it with.\n */\nfunction replaceDuplicateInGroup(\n byNamespace: Map<string, NamespaceGroup>,\n previous: MessengerCapabilityPacket,\n replacement: MessengerCapabilityPacket,\n): void {\n const namespace = replacement.typeString.split(':')[0];\n const group = byNamespace.get(namespace);\n // istanbul ignore next: `previous` and `replacement` have the same\n // typeString, so they share a namespace, and we always insert the\n // namespace into `byNamespace` before recording the original entry.\n if (!group) {\n return;\n }\n const previousList =\n previous.kind === 'action' ? group.actions : group.events;\n const index = previousList.indexOf(previous);\n // istanbul ignore next: `previous` was added to its kind's list by\n // `groupByNamespace` before being recorded in `seen`, so it is always\n // present when we look it up here.\n if (index === -1) {\n return;\n }\n if (previous.kind === replacement.kind) {\n previousList[index] = replacement;\n } else {\n previousList.splice(index, 1);\n const newList =\n replacement.kind === 'action' ? group.actions : group.events;\n newList.push(replacement);\n }\n}\n\n/**\n * Group items by namespace, deduplicating duplicate typeStrings using\n * `deduplicationScore`. Returns groups sorted alphabetically by namespace,\n * with each group's items sorted alphabetically by typeString.\n *\n * @param items - The full list of extracted items.\n * @returns The deduplicated and sorted namespace groups.\n */\nfunction groupByNamespace(\n items: MessengerCapabilityPacket[],\n): NamespaceGroup[] {\n const byNamespace = new Map<string, NamespaceGroup>();\n const seen = new Map<string, MessengerCapabilityPacket>();\n\n for (const item of items) {\n const existing = seen.get(item.typeString);\n if (existing) {\n if (deduplicationScore(item) <= deduplicationScore(existing)) {\n continue;\n }\n replaceDuplicateInGroup(byNamespace, existing, item);\n seen.set(item.typeString, item);\n continue;\n }\n\n seen.set(item.typeString, item);\n const namespace = item.typeString.split(':')[0];\n let group = byNamespace.get(namespace);\n if (!group) {\n group = { namespace, actions: [], events: [] };\n byNamespace.set(namespace, group);\n }\n if (item.kind === 'action') {\n group.actions.push(item);\n } else {\n group.events.push(item);\n }\n }\n\n const namespaces = Array.from(byNamespace.values()).sort((a, b) =>\n a.namespace.localeCompare(b.namespace),\n );\n\n for (const ns of namespaces) {\n ns.actions.sort((a, b) => a.typeString.localeCompare(b.typeString));\n ns.events.sort((a, b) => a.typeString.localeCompare(b.typeString));\n }\n\n return namespaces;\n}\n\n/**\n * Write generated docs (namespace pages, index page, sidebars) to disk,\n * replacing any existing `docs/` directory.\n *\n * @param namespaces - The grouped namespaces to render.\n * @param outputDir - The root output directory.\n * @param repoBaseUrl - GitHub blob base URL for source links, or null.\n * @param indexOptions - Options stamped on the index page header.\n * @param indexOptions.projectLabel - Short label identifying the project.\n * @param indexOptions.commitSha - Git commit SHA the docs were generated from.\n * @returns Promise that resolves once all files are written.\n */\nasync function writeOutput(\n namespaces: NamespaceGroup[],\n outputDir: string,\n repoBaseUrl: string | null,\n indexOptions: {\n projectLabel?: string | null;\n commitSha?: string | null;\n },\n): Promise<void> {\n const docsDir = path.join(outputDir, 'docs');\n\n if (await directoryExists(docsDir)) {\n await fs.rm(docsDir, { recursive: true });\n }\n await fs.mkdir(docsDir, { recursive: true });\n\n for (const ns of namespaces) {\n const nsDir = path.join(docsDir, ns.namespace);\n await fs.mkdir(nsDir, { recursive: true });\n\n if (ns.actions.length > 0) {\n await fs.writeFile(\n path.join(nsDir, 'actions.md'),\n generateNamespacePage(ns, 'action', repoBaseUrl),\n );\n }\n\n if (ns.events.length > 0) {\n await fs.writeFile(\n path.join(nsDir, 'events.md'),\n generateNamespacePage(ns, 'event', repoBaseUrl),\n );\n }\n }\n\n await fs.writeFile(\n path.join(docsDir, 'index.md'),\n generateIndexPage(namespaces, indexOptions),\n );\n\n await fs.writeFile(\n path.join(outputDir, 'sidebars.ts'),\n generateSidebars(namespaces),\n );\n}\n\n/**\n * Collect capabilities by scanning the project's files.\n *\n * @param projectPath - The project root path.\n * @param scanDirs - Directories (relative to projectPath) to scan.\n * @returns The extracted capabilities.\n * @throws If the project has no scannable directories at all.\n */\nasync function collectByScanning(\n projectPath: string,\n scanDirs: string[],\n): Promise<MessengerCapabilityPacket[]> {\n const sources = await discoverScanSources(projectPath, scanDirs);\n\n if (\n sources.scanDirs.length === 0 &&\n !sources.packagesDir &&\n !sources.nodeModulesDir\n ) {\n throw new Error(\n `No scannable directories found in ${projectPath}. ` +\n `Looked for: ${scanDirs.join(', ')}, packages/, node_modules/@metamask/`,\n );\n }\n\n logScanPlan(sources);\n\n return await scanSources(projectPath, sources);\n}\n\n/**\n * Using the project's root messenger capability collection types as\n * entrypoints, collect the constituent individual capability types and package\n * them so that they can be displayed within the documentation site.\n *\n * @param projectPath - The project root path.\n * @param options - The root-messenger strategy options.\n * @returns The extracted capabilities.\n */\nfunction collectFromRootMessengerCapabilities(\n projectPath: string,\n options: RootMessengerStrategyOptions,\n): MessengerCapabilityPacket[] {\n const { rootActions, rootEvents } = options;\n\n console.log(\n `Resolving actions from ${rootActions.filePath}#${rootActions.typeName} ` +\n `and events from ${rootEvents.filePath}#${rootEvents.typeName}...`,\n );\n\n const { capabilityPackets, skippedCapabilities } =\n discoverFromRootMessengerCapabilitiesTypes({\n projectPath,\n rootActionsTypeReference: rootActions,\n rootEventsTypeReference: rootEvents,\n });\n\n // Report rather than drop silently: a jump in any of these usually means the\n // project changed how it declares its capabilities.\n warnSkipped(\n 'declared inline, with no name to document',\n skippedCapabilities.unnamedCapabilities,\n );\n warnSkipped(\n 'whose shape could not be read',\n skippedCapabilities.unextractableCapabilities,\n );\n\n // If both capability collection types resolve to nothing, it's always a\n // misconfiguration (a wrong type name, or imports that didn't resolve).\n // Failing here matters because generation would otherwise replace an existing\n // docs directory with an empty one and exit successfully.\n if (capabilityPackets.length === 0) {\n throw new Error(\n `No messenger actions or events found in ` +\n `${rootActions.filePath}#${rootActions.typeName} or ` +\n `${rootEvents.filePath}#${rootEvents.typeName}. ` +\n `Check that these types name the collections carrying every ` +\n `capability, and that their imports resolve.`,\n );\n }\n\n return capabilityPackets;\n}\n\n/**\n * Warn about capability types that couldn't be documented, naming them so the\n * warning is actionable.\n *\n * @param description - Why they were skipped, as a noun phrase.\n * @param labels - Labels identifying each skipped type.\n */\nfunction warnSkipped(description: string, labels: string[]): void {\n if (labels.length === 0) {\n return;\n }\n\n const shown = labels.slice(0, MAX_SKIPPED_SHOWN);\n const remaining = labels.length - shown.length;\n console.warn(\n `Warning: skipped ${labels.length} capability ` +\n `${labels.length === 1 ? 'type' : 'types'} ${description}: ` +\n `${shown.join(', ')}${remaining > 0 ? `, and ${remaining} more` : ''}`,\n );\n}\n\n/**\n * Scan a project for messenger action/event types and generate documentation.\n *\n * @param options - Generation options.\n * @returns A promise resolving to counts of generated namespaces, actions, and events.\n */\nexport async function generate(\n options: GenerateOptions,\n): Promise<GenerateResult> {\n const { projectPath, outputDir, projectLabel, commitSha } = options;\n\n const allItems =\n options.strategy === 'root-messenger'\n ? collectFromRootMessengerCapabilities(projectPath, options)\n : await collectByScanning(projectPath, options.scanDirs);\n\n console.log(\n `Found ${allItems.length} messenger ${allItems.length === 1 ? 'item' : 'items'} total.`,\n );\n\n const namespaces = groupByNamespace(allItems);\n const repoBaseUrl = await resolveRepoBaseUrl(projectPath, commitSha ?? null);\n\n await writeOutput(namespaces, outputDir, repoBaseUrl, {\n projectLabel,\n commitSha,\n });\n\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 console.log(\n `Generated docs for ${namespaces.length} ${namespaces.length === 1 ? 'namespace' : 'namespaces'}.`,\n );\n console.log(` Actions: ${totalActions}`);\n console.log(` Events: ${totalEvents}`);\n console.log(`Output: ${path.join(outputDir, 'docs')}/`);\n\n return {\n namespaces: namespaces.length,\n actions: totalActions,\n events: totalEvents,\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { MessengerCapabilityPacket, NamespaceGroup } from "./types.cjs";
1
+ import type { MessengerCapabilityPacket, NamespaceGroup } from './types.js';
2
2
  /**
3
3
  * Generate markdown documentation for a single messenger item.
4
4
  *
@@ -49,4 +49,4 @@ export declare function generateIndexPage(namespaces: NamespaceGroup[], options?
49
49
  * @returns The generated TypeScript source string.
50
50
  */
51
51
  export declare function generateSidebars(namespaces: NamespaceGroup[]): string;
52
- //# sourceMappingURL=markdown.d.cts.map
52
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAuC5E;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,yBAAyB,EAC/B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,GACzB,MAAM,CAqER;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,cAAc,EAClB,IAAI,EAAE,QAAQ,GAAG,OAAO,EACxB,WAAW,GAAE,MAAM,GAAG,IAAW,GAChC,MAAM,CAiER;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,cAAc,EAAE,EAC5B,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CA+CR;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,MAAM,CA0BrE"}
@@ -229,4 +229,4 @@ export function generateSidebars(namespaces) {
229
229
  };
230
230
  return `// This file is auto-generated by @metamask/platform-api-docs\n// Do not edit manually.\nconst sidebars = ${JSON.stringify(sidebar, null, 2)};\nexport default sidebars;\n`;
231
231
  }
232
- //# sourceMappingURL=markdown.mjs.map
232
+ //# sourceMappingURL=markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/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,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,MAAM,IAAI,OAAO,QAAQ,GAAG,CAAC;QACtC,CAAC;QACD,4DAA4D;QAC5D,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC;YAClC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,MAAM,EAAE,CAAC,EAAE,CAAC;gBAChC,OAAO,MAAM,IAAI,OAAO,IAAI,GAAG,CAAC;YAClC,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC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,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,6GAA6G,IAAI,CAAC,SAAS,CAChI,OAAO,EACP,IAAI,EACJ,CAAC,CACF,+BAA+B,CAAC;AACnC,CAAC","sourcesContent":["import type { MessengerCapabilityPacket, NamespaceGroup } from './types.js';\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 matches exactly in known names values\n for (const [, href] of knownNames) {\n if (href.endsWith(`#${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: MessengerCapabilityPacket,\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 // For sources scanned out of an @metamask/*/dist directory we render an\n // npm link, since the original .ts paths are not part of the repo we're\n // documenting. Other `node_modules/` paths fall through to the normal\n // source-link branches.\n const metamaskPkgMatch = item.sourceFile.match(\n /node_modules\\/(@metamask\\/[^/]+)/u,\n );\n if (metamaskPkgMatch) {\n const pkgName = metamaskPkgMatch[1];\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 // Only actions get a parameters table — events carry a positional tuple\n // payload, not named arguments, so a `@param` table doesn't fit.\n if (item.kind === 'action' && item.params.length > 0) {\n parts.push('**Parameters**:');\n parts.push('');\n parts.push('| Name | Description |');\n parts.push('|------|-------------|');\n for (const param of item.params) {\n const description = linkifyReferences(\n param.description,\n namespace,\n knownNames,\n );\n parts.push(`| \\`${param.name}\\` | ${description} |`);\n }\n parts.push('');\n }\n\n if (item.kind === 'action' && item.returns) {\n parts.push(\n `**Returns**: ${linkifyReferences(item.returns, namespace, knownNames)}`,\n );\n parts.push('');\n }\n\n const signatureLabel = item.kind === 'action' ? 'Handler' : 'Payload';\n parts.push(`**${signatureLabel} signature**:`);\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 * Options controlling how {@link generateIndexPage} renders the index header.\n */\nexport type IndexPageOptions = {\n /**\n * Short label identifying the project the docs were generated from (e.g.\n * \"Core\", \"Extension\"). When provided, the title is rendered as\n * `Platform API (Core)`.\n */\n projectLabel?: string | null;\n /**\n * Git commit SHA the docs were generated from. When provided, it's shown\n * in the intro so engineers know how current the site is.\n */\n commitSha?: string | null;\n};\n\n/**\n * Generate the index/overview page listing all namespaces.\n *\n * @param namespaces - All namespace groups sorted alphabetically.\n * @param options - Optional project label and commit SHA to stamp in the header.\n * @returns The generated markdown string.\n */\nexport function generateIndexPage(\n namespaces: NamespaceGroup[],\n options: IndexPageOptions = {},\n): 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 const projectSuffix = options.projectLabel\n ? ` (${options.projectLabel})`\n : '';\n\n const parts: string[] = [];\n parts.push('---');\n parts.push(`title: \"Platform API${projectSuffix} Reference\"`);\n parts.push('slug: \"/\"');\n parts.push('---');\n parts.push('');\n parts.push(`# Platform API${projectSuffix}`);\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 if (options.commitSha) {\n parts.push(`Generated from commit \\`${options.commitSha}\\`.`);\n parts.push('');\n }\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/platform-api-docs\\n// Do not edit manually.\\nconst sidebars = ${JSON.stringify(\n sidebar,\n null,\n 2,\n )};\\nexport default sidebars;\\n`;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { MessengerCapabilityPacket } from "./types.cjs";
1
+ import type { MessengerCapabilityPacket } from './types.js';
2
2
  /**
3
3
  * A reference to a type declared in a file, written as `<file>#<TypeName>`.
4
4
  *
@@ -58,4 +58,4 @@ export declare function discoverFromRootMessengerCapabilitiesTypes({ projectPath
58
58
  skippedCapabilities: SkippedCapabilities;
59
59
  };
60
60
  export {};
61
- //# sourceMappingURL=root-messenger-discovery.d.cts.map
61
+ //# sourceMappingURL=root-messenger-discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-messenger-discovery.d.ts","sourceRoot":"","sources":["../src/root-messenger-discovery.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAS5D;;;;;;;GAOG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,KAAK,mBAAmB,GAAG;IACzB;;;OAGG;IACH,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAI9B,yBAAyB,EAAE,MAAM,EAAE,CAAC;CACrC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAChD,SAAS,EAAE,MAAM,GAChB,6BAA6B,CAiB/B;AA6VD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0CAA0C,CAAC,EACzD,WAAW,EACX,wBAAwB,EACxB,uBAAuB,GACxB,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,wBAAwB,EAAE,6BAA6B,CAAC;IACxD,uBAAuB,EAAE,6BAA6B,CAAC;CACxD,GAAG;IACF,iBAAiB,EAAE,yBAAyB,EAAE,CAAC;IAC/C,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CA8CA"}
@@ -1,7 +1,7 @@
1
- import * as path from "node:path";
2
- import { Node as NodeGuards } from "ts-morph";
3
- import { classifyMessengerCapabilityTypeDeclaration, extractFromMessengerCapabilityTypeDeclaration } from "./extraction.mjs";
4
- import { createProject } from "./ts-project.mjs";
1
+ import * as path from 'node:path';
2
+ import { Node as NodeGuards } from 'ts-morph';
3
+ import { classifyMessengerCapabilityTypeDeclaration, extractFromMessengerCapabilityTypeDeclaration, } from './extraction.js';
4
+ import { createProject } from './ts-project.js';
5
5
  /**
6
6
  * Split a `<file>#<TypeName>` reference into its parts, on the last `#` so
7
7
  * that paths containing a `#` still work.
@@ -328,4 +328,4 @@ export function discoverFromRootMessengerCapabilitiesTypes({ projectPath, rootAc
328
328
  skippedCapabilities: allSkippedCapabilities,
329
329
  };
330
330
  }
331
- //# sourceMappingURL=root-messenger-discovery.mjs.map
331
+ //# sourceMappingURL=root-messenger-discovery.js.map