@metamask-previews/platform-api-docs 0.1.0-preview-a302de5c3 → 0.1.0-preview-e12b5ece6

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 (38) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/extraction.cjs +1 -27
  3. package/dist/extraction.cjs.map +1 -1
  4. package/dist/extraction.d.cts +0 -10
  5. package/dist/extraction.d.cts.map +1 -1
  6. package/dist/extraction.d.mts +0 -10
  7. package/dist/extraction.d.mts.map +1 -1
  8. package/dist/extraction.mjs +1 -26
  9. package/dist/extraction.mjs.map +1 -1
  10. package/dist/generate.cjs +102 -59
  11. package/dist/generate.cjs.map +1 -1
  12. package/dist/generate.d.cts.map +1 -1
  13. package/dist/generate.d.mts.map +1 -1
  14. package/dist/generate.mjs +103 -60
  15. package/dist/generate.mjs.map +1 -1
  16. package/dist/root-messenger-discovery.cjs +5 -26
  17. package/dist/root-messenger-discovery.cjs.map +1 -1
  18. package/dist/root-messenger-discovery.d.cts.map +1 -1
  19. package/dist/root-messenger-discovery.d.mts.map +1 -1
  20. package/dist/root-messenger-discovery.mjs +6 -27
  21. package/dist/root-messenger-discovery.mjs.map +1 -1
  22. package/dist/ts-project.cjs +33 -0
  23. package/dist/ts-project.cjs.map +1 -0
  24. package/dist/ts-project.d.cts +12 -0
  25. package/dist/ts-project.d.cts.map +1 -0
  26. package/dist/ts-project.d.mts +12 -0
  27. package/dist/ts-project.d.mts.map +1 -0
  28. package/dist/ts-project.mjs +29 -0
  29. package/dist/ts-project.mjs.map +1 -0
  30. package/package.json +2 -3
  31. package/dist/discovery.cjs +0 -53
  32. package/dist/discovery.cjs.map +0 -1
  33. package/dist/discovery.d.cts +0 -22
  34. package/dist/discovery.d.cts.map +0 -1
  35. package/dist/discovery.d.mts +0 -22
  36. package/dist/discovery.d.mts.map +0 -1
  37. package/dist/discovery.mjs +0 -48
  38. package/dist/discovery.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Changed
11
+
12
+ - 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
+ - Bump `@metamask/utils` from `^11.11.0` to `^11.12.0` ([#10076](https://github.com/MetaMask/core/pull/10076))
14
+
10
15
  ## [0.1.0]
11
16
 
12
17
  ### Added
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.extractFromSourceFile = exports.createExtractionProject = exports.extractFromMessengerCapabilityTypeDeclaration = exports.classifyMessengerCapabilityTypeDeclaration = void 0;
26
+ exports.extractFromSourceFile = exports.extractFromMessengerCapabilityTypeDeclaration = exports.classifyMessengerCapabilityTypeDeclaration = void 0;
27
27
  const path = __importStar(require("node:path"));
28
28
  const ts_morph_1 = require("ts-morph");
29
29
  // ---------------------------------------------------------------------------
@@ -725,32 +725,6 @@ function tryToExtractFromCapabilityTypeConstructor(capabilityTypeDeclaration, pr
725
725
  // ---------------------------------------------------------------------------
726
726
  // Public entry points
727
727
  // ---------------------------------------------------------------------------
728
- /**
729
- * Create a ts-morph Project configured for messenger-docs extraction. The
730
- * caller should add every source file that may be referenced (directly or
731
- * transitively) before calling {@link extractFromSourceFile}, so the type
732
- * checker can resolve cross-file references.
733
- *
734
- * @returns A new ts-morph Project.
735
- */
736
- function createExtractionProject() {
737
- return new ts_morph_1.Project({
738
- compilerOptions: {
739
- allowJs: false,
740
- noEmit: true,
741
- // Match the project's permissive defaults — we just need symbol
742
- // resolution, not full typechecking.
743
- strict: false,
744
- skipLibCheck: true,
745
- // Explicit module options so cross-file symbol resolution works
746
- // regardless of the host process's tsconfig.
747
- target: ts_morph_1.ts.ScriptTarget.ESNext,
748
- module: ts_morph_1.ts.ModuleKind.ESNext,
749
- moduleResolution: ts_morph_1.ts.ModuleResolutionKind.NodeJs,
750
- },
751
- });
752
- }
753
- exports.createExtractionProject = createExtractionProject;
754
728
  /**
755
729
  * Extract information (action/event type string, handler/payload arguments and
756
730
  * return type, etc.) about every messenger action or event type which is
@@ -1 +1 @@
1
- {"version":3,"file":"extraction.cjs","sourceRoot":"","sources":["../src/extraction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAelC,uCAA2D;AAO3D,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,CAC9B,mBAAmB,EACnB,CAAC,KAAK,EAAE,OAA2B,EAAE,EAAE,CACrC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CACjD,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,sBAAsB,CAAC,GAAa;IAC3C,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACnE,CAAC;AAED;;;;;;GAMG;AACH,SAAS,wBAAwB,CAAC,OAAe;IAC/C,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAS,YAAY,CAAC,IAAmB;IAKvC,MAAM,MAAM,G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AOG;AACH,SAAgB,uBAAuB;IACrC,OAAO,IAAI,kBAAO,CAAC;QACjB,eAAe,EAAE;YACf,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,IAAI;YACZ,gEAAgE;YAChE,qCAAqC;YACrC,MAAM,EAAE,KAAK;YACb,YAAY,EAAE,IAAI;YAClB,gEAAgE;YAChE,6CAA6C;YAC7C,MAAM,EAAE,aAAE,CAAC,YAAY,CAAC,MAAM;YAC9B,MAAM,EAAE,aAAE,CAAC,UAAU,CAAC,MAAM;YAC5B,gBAAgB,EAAE,aAAE,CAAC,oBAAoB,CAAC,MAAM;SACjD;KACF,CAAC,CAAC;AACL,CAAC;AAhBD,0DAgBC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,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;AArBD,sDAqBC","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, Project, ts } 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 * Create a ts-morph Project configured for messenger-docs extraction. The\n * caller should add every source file that may be referenced (directly or\n * transitively) before calling {@link extractFromSourceFile}, so the type\n * checker can resolve cross-file references.\n *\n * @returns A new ts-morph Project.\n */\nexport function createExtractionProject(): Project {\n return new Project({\n compilerOptions: {\n allowJs: false,\n noEmit: true,\n // Match the project's permissive defaults — we just need symbol\n // resolution, not full typechecking.\n strict: false,\n skipLibCheck: true,\n // Explicit module options so cross-file symbol resolution works\n // regardless of the host process's tsconfig.\n target: ts.ScriptTarget.ESNext,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.NodeJs,\n },\n });\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
+ {"version":3,"file":"extraction.cjs","sourceRoot":"","sources":["../src/extraction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAelC,uCAA8C;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,CAC9B,mBAAmB,EACnB,CAAC,KAAK,EAAE,OAA2B,EAAE,EAAE,CACrC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CACjD,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,sBAAsB,CAAC,GAAa;IAC3C,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACnE,CAAC;AAED;;;;;;GAMG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AAW,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,SAAgB,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;AArBD,sDAqBC","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,5 +1,4 @@
1
1
  import type { Identifier, InterfaceDeclaration, SourceFile, TypeAliasDeclaration, TypeReferenceNode } from "ts-morph";
2
- import { Project } from "ts-morph";
3
2
  import type { MessengerCapabilityPacket } from "./types.cjs";
4
3
  /**
5
4
  * A messenger capability type whose body invokes a capability-type-constructor
@@ -56,15 +55,6 @@ export declare function classifyMessengerCapabilityTypeDeclaration(declaration:
56
55
  * (may be `null` if the type is ineligible for extraction).
57
56
  */
58
57
  export declare function extractFromMessengerCapabilityTypeDeclaration(capabilityTypeDeclaration: MessengerCapabilityTypeDeclaration, projectPath: string): MessengerCapabilityPacket | null;
59
- /**
60
- * Create a ts-morph Project configured for messenger-docs extraction. The
61
- * caller should add every source file that may be referenced (directly or
62
- * transitively) before calling {@link extractFromSourceFile}, so the type
63
- * checker can resolve cross-file references.
64
- *
65
- * @returns A new ts-morph Project.
66
- */
67
- export declare function createExtractionProject(): Project;
68
58
  /**
69
59
  * Extract information (action/event type string, handler/payload arguments and
70
60
  * return type, etc.) about every messenger action or event type which is
@@ -1 +1 @@
1
- {"version":3,"file":"extraction.d.cts","sourceRoot":"","sources":["../src/extraction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,oBAAoB,EAMpB,UAAU,EACV,oBAAoB,EAGpB,iBAAiB,EAClB,iBAAiB;AAClB,OAAO,EAAsB,OAAO,EAAM,iBAAiB;AAE3D,OAAO,KAAK,EACV,yBAAyB,EAE1B,oBAAmB;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,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CAA6C,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,4 @@
1
1
  import type { Identifier, InterfaceDeclaration, SourceFile, TypeAliasDeclaration, TypeReferenceNode } from "ts-morph";
2
- import { Project } from "ts-morph";
3
2
  import type { MessengerCapabilityPacket } from "./types.mjs";
4
3
  /**
5
4
  * A messenger capability type whose body invokes a capability-type-constructor
@@ -56,15 +55,6 @@ export declare function classifyMessengerCapabilityTypeDeclaration(declaration:
56
55
  * (may be `null` if the type is ineligible for extraction).
57
56
  */
58
57
  export declare function extractFromMessengerCapabilityTypeDeclaration(capabilityTypeDeclaration: MessengerCapabilityTypeDeclaration, projectPath: string): MessengerCapabilityPacket | null;
59
- /**
60
- * Create a ts-morph Project configured for messenger-docs extraction. The
61
- * caller should add every source file that may be referenced (directly or
62
- * transitively) before calling {@link extractFromSourceFile}, so the type
63
- * checker can resolve cross-file references.
64
- *
65
- * @returns A new ts-morph Project.
66
- */
67
- export declare function createExtractionProject(): Project;
68
58
  /**
69
59
  * Extract information (action/event type string, handler/payload arguments and
70
60
  * return type, etc.) about every messenger action or event type which is
@@ -1 +1 @@
1
- {"version":3,"file":"extraction.d.mts","sourceRoot":"","sources":["../src/extraction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,oBAAoB,EAMpB,UAAU,EACV,oBAAoB,EAGpB,iBAAiB,EAClB,iBAAiB;AAClB,OAAO,EAAsB,OAAO,EAAM,iBAAiB;AAE3D,OAAO,KAAK,EACV,yBAAyB,EAE1B,oBAAmB;AAiQpB;;;;;;GAMG;AACH,KAAK,6CAA6C,GAAG;IACnD,SAAS,EAAE,aAAa,CAAC;IACzB,IAAI,EAAE,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AClC,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
1
  import * as path from "node:path";
2
- import { Node as NodeGuards, Project, ts } from "ts-morph";
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
@@ -697,31 +697,6 @@ function tryToExtractFromCapabilityTypeConstructor(capabilityTypeDeclaration, pr
697
697
  // ---------------------------------------------------------------------------
698
698
  // Public entry points
699
699
  // ---------------------------------------------------------------------------
700
- /**
701
- * Create a ts-morph Project configured for messenger-docs extraction. The
702
- * caller should add every source file that may be referenced (directly or
703
- * transitively) before calling {@link extractFromSourceFile}, so the type
704
- * checker can resolve cross-file references.
705
- *
706
- * @returns A new ts-morph Project.
707
- */
708
- export function createExtractionProject() {
709
- return new Project({
710
- compilerOptions: {
711
- allowJs: false,
712
- noEmit: true,
713
- // Match the project's permissive defaults — we just need symbol
714
- // resolution, not full typechecking.
715
- strict: false,
716
- skipLibCheck: true,
717
- // Explicit module options so cross-file symbol resolution works
718
- // regardless of the host process's tsconfig.
719
- target: ts.ScriptTarget.ESNext,
720
- module: ts.ModuleKind.ESNext,
721
- moduleResolution: ts.ModuleResolutionKind.NodeJs,
722
- },
723
- });
724
- }
725
700
  /**
726
701
  * Extract information (action/event type string, handler/payload arguments and
727
702
  * return type, etc.) about every messenger action or event type which is