typedoc 0.28.8 → 0.28.10

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.
@@ -59,7 +59,6 @@ import { Outputs } from "./output/output.js";
59
59
  import { validateMergeModuleWith } from "./validation/unusedMergeModuleWith.js";
60
60
  import { diagnostic, diagnostics } from "./utils/loggers.js";
61
61
  import { ValidatingFileRegistry } from "./utils/ValidatingFileRegistry.js";
62
- import { addInferredDeclarationMapPaths } from "./converter/factories/symbol-id.js";
63
62
  import { Internationalization } from "./internationalization/internationalization.js";
64
63
  const packageInfo = JSON.parse(readFileSync(Path.join(fileURLToPath(import.meta.url), "../../../package.json"), "utf8"));
65
64
  const supportedVersionMajorMinor = packageInfo.peerDependencies.typescript
@@ -626,7 +625,6 @@ let Application = (() => {
626
625
  this.logger.error(i18n.nested_packages_unsupported_0(nicePath(dir)));
627
626
  continue;
628
627
  }
629
- addInferredDeclarationMapPaths(opts.getCompilerOptions(), opts.getFileNames());
630
628
  projectsToConvert.push({ dir, options: opts });
631
629
  }
632
630
  for (const { dir, options } of projectsToConvert) {
@@ -195,7 +195,13 @@ function checkReference(data) {
195
195
  while (/[ \t]/.test(token.text[lookahead])) {
196
196
  ++lookahead;
197
197
  }
198
- if (token.text[lookahead] === "[") {
198
+ // #2991, we check that this reference also doesn't look like a footnote reference
199
+ // as it is unlikely that someone uses that syntax without intending for footnote behavior.
200
+ // This introduces a problem if someone has an [^ref] and doesn't intend for that to
201
+ // be interpreted as a footnote, but as a reference, but we can't have it both ways,
202
+ // and having people rename their reference to not be confused with a footnote isn't a
203
+ // horrible workaround.
204
+ if (token.text[lookahead] === "[" && token.text[lookahead + 1] !== "^") {
199
205
  while (lookahead < token.text.length &&
200
206
  /[^\n\]]/.test(token.text[lookahead])) {
201
207
  ++lookahead;
@@ -5,7 +5,7 @@ import { Context } from "./context.js";
5
5
  import { AbstractComponent } from "../utils/component.js";
6
6
  import { type GlobString, MinimalSourceFile } from "#utils";
7
7
  import type { DocumentationEntryPoint } from "../utils/entry-point.js";
8
- import type { CommentParserConfig } from "./comments/index.js";
8
+ import { type CommentParserConfig } from "./comments/index.js";
9
9
  import type { CommentStyle, ValidationOptions } from "../utils/options/declaration.js";
10
10
  import { type ExternalResolveResult, type ExternalSymbolResolver } from "./comments/linkResolver.js";
11
11
  import { type DeclarationReference } from "#utils";
@@ -43,6 +43,7 @@ import { ConverterEvents } from "./converter-events.js";
43
43
  import { convertSymbol } from "./symbols.js";
44
44
  import { MinimatchSet, nicePath, normalizePath } from "../utils/paths.js";
45
45
  import { hasAllFlags, hasAnyFlag, i18n, MinimalSourceFile, NormalizedPathUtils, partition, unique, } from "#utils";
46
+ import { clearCommentCache } from "./comments/index.js";
46
47
  import { parseCommentString } from "./comments/parser.js";
47
48
  import { lexCommentString } from "./comments/rawLexer.js";
48
49
  import { resolveLinks, resolvePartLinks, } from "./comments/linkResolver.js";
@@ -320,6 +321,9 @@ let Converter = (() => {
320
321
  delete this._config;
321
322
  delete this.excludeCache;
322
323
  delete this.externalPatternCache;
324
+ // Also clear the comment cache so if we convert this ts.Program again
325
+ // later we will re-parse comments.
326
+ clearCommentCache();
323
327
  return project;
324
328
  }
325
329
  /** @internal */
@@ -1,4 +1,3 @@
1
1
  import { ReflectionSymbolId } from "#models";
2
2
  import ts from "typescript";
3
3
  export declare function createSymbolIdImpl(symbol: ts.Symbol, declaration?: ts.Declaration): ReflectionSymbolId;
4
- export declare function addInferredDeclarationMapPaths(opts: ts.CompilerOptions, files: readonly string[]): void;
@@ -1,10 +1,8 @@
1
1
  import { ReflectionSymbolId } from "#models";
2
- import { findPackageForPath, getCommonDirectory, getQualifiedName, normalizePath, readFile } from "#node-utils";
3
- import { Validation } from "#utils";
4
- import { existsSync } from "fs";
5
- import { join, relative, resolve } from "node:path";
2
+ import { findPackageForPath, getQualifiedName, normalizePath, resolveDeclarationMaps } from "#node-utils";
3
+ import {} from "#utils";
4
+ import { relative } from "node:path";
6
5
  import ts from "typescript";
7
- const declarationMapCache = new Map();
8
6
  let transientCount = 0;
9
7
  const transientIds = new WeakMap();
10
8
  // Don't use this directly, use Context.createSymbolId instead.
@@ -47,48 +45,3 @@ export function createSymbolIdImpl(symbol, declaration) {
47
45
  id.fileName = normalizePath(sourceFileName);
48
46
  return id;
49
47
  }
50
- function resolveDeclarationMaps(file) {
51
- if (!/\.d\.[cm]?ts$/.test(file))
52
- return file;
53
- if (declarationMapCache.has(file))
54
- return declarationMapCache.get(file);
55
- const mapFile = file + ".map";
56
- if (!existsSync(mapFile))
57
- return file;
58
- let sourceMap;
59
- try {
60
- sourceMap = JSON.parse(readFile(mapFile));
61
- }
62
- catch {
63
- return file;
64
- }
65
- if (Validation.validate({
66
- file: String,
67
- sourceRoot: Validation.optional(String),
68
- sources: [Array, String],
69
- }, sourceMap)) {
70
- // There's a pretty large assumption in here that we only have
71
- // 1 source file per js file. This is a pretty standard typescript approach,
72
- // but people might do interesting things with transpilation that could break this.
73
- let source = sourceMap.sources[0];
74
- // If we have a sourceRoot, trim any leading slash from the source, and join them
75
- // Similar to how it's done at https://github.com/mozilla/source-map/blob/58819f09018d56ef84dc41ba9c93f554e0645169/lib/util.js#L412
76
- if (sourceMap.sourceRoot !== undefined) {
77
- source = source.replace(/^\//, "");
78
- source = join(sourceMap.sourceRoot, source);
79
- }
80
- const result = resolve(mapFile, "..", source);
81
- declarationMapCache.set(file, result);
82
- return result;
83
- }
84
- return file;
85
- }
86
- // See also: inferEntryPoints in entry-point.ts
87
- export function addInferredDeclarationMapPaths(opts, files) {
88
- const rootDir = opts.rootDir || getCommonDirectory(files);
89
- const declDir = opts.declarationDir || opts.outDir || rootDir;
90
- for (const file of files) {
91
- const mapFile = normalizePath(resolve(declDir, relative(rootDir, file)).replace(/\.([cm]?[tj]s)x?$/, ".d.$1"));
92
- declarationMapCache.set(mapFile, file);
93
- }
94
- }
@@ -95,18 +95,21 @@ export class ImplementsPlugin extends ConverterComponent {
95
95
  // serialization/deserialization, might point to an unexpected location. (See the mixin
96
96
  // converter tests, I suspect this might actually be an indication of something else slightly
97
97
  // broken there, but don't want to spend more time with this right now.)
98
+ // #2982, even more unfortunately, we only want to keep the link if it is pointing to a reflection
99
+ // which will receive a link during rendering.
100
+ const isValidRef = (ref) => ref.reflection && !ref.reflection.parent?.kindOf(ReflectionKind.TypeLiteral);
98
101
  for (const child of reflection.children || []) {
99
- if (child.inheritedFrom && !child.inheritedFrom.reflection) {
102
+ if (child.inheritedFrom && !isValidRef(child.inheritedFrom)) {
100
103
  child.inheritedFrom = ReferenceType.createBrokenReference(child.inheritedFrom.name, project);
101
104
  }
102
- if (child.overwrites && !child.overwrites.reflection) {
105
+ if (child.overwrites && !isValidRef(child.overwrites)) {
103
106
  child.overwrites = ReferenceType.createBrokenReference(child.overwrites.name, project);
104
107
  }
105
108
  for (const childSig of child.getAllSignatures()) {
106
- if (childSig.inheritedFrom && !childSig.inheritedFrom.reflection) {
109
+ if (childSig.inheritedFrom && !isValidRef(childSig.inheritedFrom)) {
107
110
  childSig.inheritedFrom = ReferenceType.createBrokenReference(childSig.inheritedFrom.name, project);
108
111
  }
109
- if (childSig.overwrites && !childSig.overwrites.reflection) {
112
+ if (childSig.overwrites && !isValidRef(childSig.overwrites)) {
110
113
  childSig.overwrites = ReferenceType.createBrokenReference(childSig.overwrites.name, project);
111
114
  }
112
115
  }
@@ -37,7 +37,7 @@ import { ConverterComponent } from "../components.js";
37
37
  import { ApplicationEvents } from "../../application-events.js";
38
38
  import { ConverterEvents } from "../converter-events.js";
39
39
  import { i18n, MinimalSourceFile, NormalizedPathUtils } from "#utils";
40
- import { discoverPackageJson, getCommonDirectory, nicePath, normalizePath, Option, readFile, } from "#node-utils";
40
+ import { deriveRootDir, discoverPackageJson, nicePath, normalizePath, Option, readFile, } from "#node-utils";
41
41
  import { existsSync } from "fs";
42
42
  /**
43
43
  * A handler that tries to find the package.json and readme.md files of the
@@ -117,7 +117,7 @@ let PackagePlugin = (() => {
117
117
  this.readmeContents = undefined;
118
118
  this.packageJson = undefined;
119
119
  const dirName = this.application.options.packageDir ??
120
- Path.resolve(getCommonDirectory(this.entryPoints.map(g => `${g}/`)));
120
+ Path.resolve(deriveRootDir(this.entryPoints));
121
121
  this.application.logger.verbose(`Begin package.json search at ${nicePath(dirName)}`);
122
122
  const packageJson = discoverPackageJson(dirName);
123
123
  this.packageJson = packageJson?.content;
@@ -56,6 +56,7 @@ module.exports = localeUtils.buildIncompleteTranslation({
56
56
  open_brace_within_inline_tag: "在内联标签中遇到左括号,这可能是一个错误",
57
57
  inline_tag_not_closed: "内联标签未关闭",
58
58
  // validation
59
+ comment_for_0_links_to_1_not_included_in_docs_use_external_link_2: `{0} 注释中指向 “{1}” 的已解析的链接不会被包含在文档中。请将 {2} 导出或添加至 externalSymbolLinkMappings 选项以修复该警告`,
59
60
  failed_to_resolve_link_to_0_in_comment_for_1: "无法解析 {1} 注释中指向 “{0}” 的链接",
60
61
  failed_to_resolve_link_to_0_in_comment_for_1_may_have_meant_2: "无法解析 {1} 的注释中指向 “{0}” 的链接。您可能想要 “{2}”",
61
62
  failed_to_resolve_link_to_0_in_readme_for_1: "无法解析 {1} 的自述文件中指向 “{0}” 的链接",
@@ -71,8 +72,9 @@ module.exports = localeUtils.buildIncompleteTranslation({
71
72
  // conversion plugins
72
73
  not_all_search_category_boosts_used_0: "文档中并未使用 searchCategoryBoosts 中指定的所有类别。未使用的类别包括:\n{0}",
73
74
  not_all_search_group_boosts_used_0: "文档中并未使用 searchGroupBoosts 中指定的所有组。未使用的组为:\n{0}",
74
- comment_for_0_includes_categoryDescription_for_1_but_no_child_in_group: "{0} 的评论包含“{1}”的 @categoryDescription,但该类别中没有子项",
75
- comment_for_0_includes_groupDescription_for_1_but_no_child_in_group: "{0} 的注释包含“{1}”的 @groupDescription,但该组中没有子项",
75
+ comment_for_0_includes_categoryDescription_for_1_but_no_child_in_group: "{0} 的注释中包含了 “{1} @categoryDescription,但该类别中没有子项",
76
+ comment_for_0_includes_groupDescription_for_1_but_no_child_in_group: "{0} 的注释中包含了 “{1} @groupDescription,但该分组中没有子项",
77
+ comment_for_0_specifies_1_as_sort_strategy_but_only_2_is_valid: `{0} 的注释中指定的 “{1}” 的 @sortStrategy 无效,以下是有效的选项:\n\t{2}`,
76
78
  label_0_for_1_cannot_be_referenced: "无法使用声明引用来引用 {1} 的标签“{0}”。标签只能包含 A-Z、0-9 和 _,并且不能以数字开头",
77
79
  modifier_tag_0_is_mutually_exclusive_with_1_in_comment_for_2: "修饰符标签 {0} 与 {2} 注释中的 {1} 互斥",
78
80
  signature_0_has_unused_param_with_name_1: "签名 {0} 有一个名为“{1}”的 @param,但未被使用",
@@ -130,6 +132,7 @@ module.exports = localeUtils.buildIncompleteTranslation({
130
132
  // options
131
133
  circular_reference_extends_0: "{0} 的“extends”字段出现循环引用",
132
134
  failed_resolve_0_to_file_in_1: "无法将 {0} 解析为 {1} 中的文件",
135
+ glob_0_should_use_posix_slash: `该 glob “{0}” 中转义了不是特殊字符的字符。输入 TypeDoc 的 glob 可能不会使用 Windows 路径分隔符(\\),请尝试将其替换为 POSIX 路径分隔符(/)`,
133
136
  option_0_can_only_be_specified_by_config_file: "“{0}”选项只能通过配置文件指定",
134
137
  option_0_expected_a_value_but_none_provided: "--{0} 需要一个值,但没有给出任何参数",
135
138
  unknown_option_0_may_have_meant_1: "未知选项:{0},你可能指的是:\n\t{1}",
@@ -274,6 +277,8 @@ module.exports = localeUtils.buildIncompleteTranslation({
274
277
  useHostedBaseUrlForAbsoluteLinks_requires_hostedBaseUrl: "useHostedBaseUrlForAbsoluteLinks 选项要求设置 hostingBaseUrl",
275
278
  favicon_must_have_one_of_the_following_extensions_0: "favicon 的后缀名必须是下列之一:{0}",
276
279
  option_0_must_be_an_object: "“{0}”选项必须是非数组对象",
280
+ option_0_must_be_an_array_of_string: "“{0}”选项必须是字符串数组",
281
+ option_0_must_be_an_array_of_string_or_functions: "“{0}”选项必须是由字符串或函数构成的数组",
277
282
  option_0_must_be_a_function: "‘{0}’ 选项必须是一个函数",
278
283
  option_0_must_be_object_with_urls: "{0} 必须是具有字符串标签作为键和 URL 值的对象",
279
284
  visibility_filters_only_include_0: "visibilityFilters 只能包含以下非@键:{0}",
@@ -431,6 +436,7 @@ module.exports = localeUtils.buildIncompleteTranslation({
431
436
  tag_return: "返回",
432
437
  tag_satisfies: "满足",
433
438
  tag_since: "添加于",
439
+ tag_sortStrategy: "排序策略",
434
440
  tag_template: "类型参数",
435
441
  tag_type: "类型",
436
442
  tag_typedef: "类型定义",
@@ -460,6 +466,7 @@ module.exports = localeUtils.buildIncompleteTranslation({
460
466
  tag_virtual: "虚函数",
461
467
  tag_abstract: "抽象类",
462
468
  tag_class: "类",
469
+ tag_disableGroups: "禁用分组",
463
470
  tag_enum: "枚举",
464
471
  tag_event: "事件",
465
472
  tag_expand: "展开",
@@ -49,6 +49,7 @@ declare const _default: {
49
49
  unknown_inline_tag_0: "遇到未知的内联标签 {0}";
50
50
  open_brace_within_inline_tag: string;
51
51
  inline_tag_not_closed: string;
52
+ comment_for_0_links_to_1_not_included_in_docs_use_external_link_2: "{0} 注释中指向 “{1}” 的已解析的链接不会被包含在文档中。请将 {2} 导出或添加至 externalSymbolLinkMappings 选项以修复该警告";
52
53
  failed_to_resolve_link_to_0_in_comment_for_1: "无法解析 {1} 注释中指向 “{0}” 的链接";
53
54
  failed_to_resolve_link_to_0_in_comment_for_1_may_have_meant_2: "无法解析 {1} 的注释中指向 “{0}” 的链接。您可能想要 “{2}”";
54
55
  failed_to_resolve_link_to_0_in_readme_for_1: "无法解析 {1} 的自述文件中指向 “{0}” 的链接";
@@ -63,8 +64,9 @@ declare const _default: {
63
64
  reflection_0_links_to_1_with_text_2_but_resolved_to_3: "“{0}”中的链接“{2}”指向“{1}”,目标虽然存在但并没有直接的链接,因此将改为链接至“{3}”。";
64
65
  not_all_search_category_boosts_used_0: "文档中并未使用 searchCategoryBoosts 中指定的所有类别。未使用的类别包括:\n{0}";
65
66
  not_all_search_group_boosts_used_0: "文档中并未使用 searchGroupBoosts 中指定的所有组。未使用的组为:\n{0}";
66
- comment_for_0_includes_categoryDescription_for_1_but_no_child_in_group: "{0} 的评论包含“{1}”的 @categoryDescription,但该类别中没有子项";
67
- comment_for_0_includes_groupDescription_for_1_but_no_child_in_group: "{0} 的注释包含“{1}”的 @groupDescription,但该组中没有子项";
67
+ comment_for_0_includes_categoryDescription_for_1_but_no_child_in_group: "{0} 的注释中包含了 “{1} @categoryDescription,但该类别中没有子项";
68
+ comment_for_0_includes_groupDescription_for_1_but_no_child_in_group: "{0} 的注释中包含了 “{1} @groupDescription,但该分组中没有子项";
69
+ comment_for_0_specifies_1_as_sort_strategy_but_only_2_is_valid: "{0} 的注释中指定的 “{1}” 的 @sortStrategy 无效,以下是有效的选项:\n\t{2}";
68
70
  label_0_for_1_cannot_be_referenced: "无法使用声明引用来引用 {1} 的标签“{0}”。标签只能包含 A-Z、0-9 和 _,并且不能以数字开头";
69
71
  modifier_tag_0_is_mutually_exclusive_with_1_in_comment_for_2: "修饰符标签 {0} 与 {2} 注释中的 {1} 互斥";
70
72
  signature_0_has_unused_param_with_name_1: "签名 {0} 有一个名为“{1}”的 @param,但未被使用";
@@ -117,6 +119,7 @@ declare const _default: {
117
119
  saved_relative_path_0_resolved_from_1_does_not_exist: "序列化项目引用的 {0} 不存在或无法在 {1} 下找到";
118
120
  circular_reference_extends_0: "{0} 的“extends”字段出现循环引用";
119
121
  failed_resolve_0_to_file_in_1: "无法将 {0} 解析为 {1} 中的文件";
122
+ glob_0_should_use_posix_slash: "该 glob “{0}” 中转义了不是特殊字符的字符。输入 TypeDoc 的 glob 可能不会使用 Windows 路径分隔符(\\),请尝试将其替换为 POSIX 路径分隔符(/)";
120
123
  option_0_can_only_be_specified_by_config_file: "“{0}”选项只能通过配置文件指定";
121
124
  option_0_expected_a_value_but_none_provided: "--{0} 需要一个值,但没有给出任何参数";
122
125
  unknown_option_0_may_have_meant_1: "未知选项:{0},你可能指的是:\n\t{1}";
@@ -256,6 +259,8 @@ declare const _default: {
256
259
  useHostedBaseUrlForAbsoluteLinks_requires_hostedBaseUrl: string;
257
260
  favicon_must_have_one_of_the_following_extensions_0: "favicon 的后缀名必须是下列之一:{0}";
258
261
  option_0_must_be_an_object: "“{0}”选项必须是非数组对象";
262
+ option_0_must_be_an_array_of_string: "“{0}”选项必须是字符串数组";
263
+ option_0_must_be_an_array_of_string_or_functions: "“{0}”选项必须是由字符串或函数构成的数组";
259
264
  option_0_must_be_a_function: "‘{0}’ 选项必须是一个函数";
260
265
  option_0_must_be_object_with_urls: "{0} 必须是具有字符串标签作为键和 URL 值的对象";
261
266
  visibility_filters_only_include_0: "visibilityFilters 只能包含以下非@键:{0}";
@@ -396,6 +401,7 @@ declare const _default: {
396
401
  tag_return: string;
397
402
  tag_satisfies: string;
398
403
  tag_since: string;
404
+ tag_sortStrategy: string;
399
405
  tag_template: string;
400
406
  tag_type: string;
401
407
  tag_typedef: string;
@@ -423,6 +429,7 @@ declare const _default: {
423
429
  tag_virtual: string;
424
430
  tag_abstract: string;
425
431
  tag_class: string;
432
+ tag_disableGroups: string;
426
433
  tag_enum: string;
427
434
  tag_event: string;
428
435
  tag_expand: string;
@@ -1,3 +1,37 @@
1
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
2
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
3
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
4
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
5
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6
+ var _, done = false;
7
+ for (var i = decorators.length - 1; i >= 0; i--) {
8
+ var context = {};
9
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
10
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
11
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
12
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13
+ if (kind === "accessor") {
14
+ if (result === void 0) continue;
15
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
16
+ if (_ = accept(result.get)) descriptor.get = _;
17
+ if (_ = accept(result.set)) descriptor.set = _;
18
+ if (_ = accept(result.init)) initializers.unshift(_);
19
+ }
20
+ else if (_ = accept(result)) {
21
+ if (kind === "field") initializers.unshift(_);
22
+ else descriptor[key] = _;
23
+ }
24
+ }
25
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
26
+ done = true;
27
+ };
28
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
29
+ var useValue = arguments.length > 2;
30
+ for (var i = 0; i < initializers.length; i++) {
31
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
32
+ }
33
+ return useValue ? value : void 0;
34
+ };
1
35
  import { TraverseProperty } from "./Reflection.js";
2
36
  import { ContainerReflection } from "./ContainerReflection.js";
3
37
  import { ReferenceReflection } from "./ReferenceReflection.js";
@@ -5,7 +39,7 @@ import { IntrinsicType, makeRecursiveVisitor } from "./types.js";
5
39
  import { ReflectionKind } from "./kind.js";
6
40
  import { Comment } from "./Comment.js";
7
41
  import { ReflectionSymbolId } from "./ReflectionSymbolId.js";
8
- import { assertNever, DefaultMap, i18n, removeIfPresent, StableKeyMap } from "#utils";
42
+ import { assertNever, DefaultMap, i18n, NonEnumerable, removeIfPresent, StableKeyMap, } from "#utils";
9
43
  // Keep this in sync with JSONOutput.SCHEMA_VERSION
10
44
  export const JSON_SCHEMA_VERSION = "2.0";
11
45
  /**
@@ -15,331 +49,369 @@ export const JSON_SCHEMA_VERSION = "2.0";
15
49
  * and source files of the processed project through this reflection.
16
50
  * @category Reflections
17
51
  */
18
- export class ProjectReflection extends ContainerReflection {
19
- variant = "project";
20
- // Used to resolve references.
21
- symbolToReflectionIdMap = new StableKeyMap();
22
- reflectionIdToSymbolIdMap = new Map();
23
- removedSymbolIds = new StableKeyMap();
24
- // Maps a reflection ID to all references eventually referring to it.
25
- referenceGraph;
26
- // Maps a reflection ID to all reflections with it as their parent.
27
- reflectionChildren = new DefaultMap(() => []);
28
- /**
29
- * A list of all reflections within the project. DO NOT MUTATE THIS OBJECT.
30
- * All mutation should be done via {@link registerReflection} and {@link removeReflection}
31
- * to ensure that links to reflections remain valid.
32
- *
33
- * This may be replaced with a `Map<number, Reflection>` someday.
34
- */
35
- reflections = {};
36
- /**
37
- * The name of the package that this reflection documents according to package.json.
38
- */
39
- packageName;
40
- /**
41
- * The version of the package that this reflection documents according to package.json.
42
- */
43
- packageVersion;
44
- /**
45
- * The contents of the readme.md file of the project when found.
46
- */
47
- readme;
48
- /**
49
- * Object which describes where to find content for relative links.
50
- */
51
- files;
52
- constructor(name, registry) {
53
- super(name, ReflectionKind.Project);
54
- this.reflections[this.id] = this;
55
- this.files = registry;
56
- }
57
- /**
58
- * Return whether this reflection is the root / project reflection.
59
- */
60
- isProject() {
61
- return true;
62
- }
63
- /**
64
- * Return a list of all reflections in this project of a certain kind.
65
- *
66
- * @param kind The desired kind of reflection.
67
- * @returns An array containing all reflections with the desired kind.
68
- */
69
- getReflectionsByKind(kind) {
70
- return Object.values(this.reflections).filter((reflection) => reflection.kindOf(kind));
71
- }
72
- /**
73
- * Registers the given reflection so that it can be quickly looked up by helper methods.
74
- * Should be called for *every* reflection added to the project.
75
- *
76
- * Note: During conversion, `Context.registerReflection` should be used instead so
77
- * that symbols can be saved for later use.
78
- */
79
- registerReflection(reflection, id, filePath) {
80
- this.referenceGraph = undefined;
81
- if (reflection.parent) {
82
- this.reflectionChildren
83
- .get(reflection.parent.id)
84
- .push(reflection.id);
52
+ let ProjectReflection = (() => {
53
+ let _classSuper = ContainerReflection;
54
+ let _symbolToReflectionIdMap_decorators;
55
+ let _symbolToReflectionIdMap_initializers = [];
56
+ let _symbolToReflectionIdMap_extraInitializers = [];
57
+ let _reflectionIdToSymbolIdMap_decorators;
58
+ let _reflectionIdToSymbolIdMap_initializers = [];
59
+ let _reflectionIdToSymbolIdMap_extraInitializers = [];
60
+ let _removedSymbolIds_decorators;
61
+ let _removedSymbolIds_initializers = [];
62
+ let _removedSymbolIds_extraInitializers = [];
63
+ let _referenceGraph_decorators;
64
+ let _referenceGraph_initializers = [];
65
+ let _referenceGraph_extraInitializers = [];
66
+ let _reflectionChildren_decorators;
67
+ let _reflectionChildren_initializers = [];
68
+ let _reflectionChildren_extraInitializers = [];
69
+ let _reflections_decorators;
70
+ let _reflections_initializers = [];
71
+ let _reflections_extraInitializers = [];
72
+ return class ProjectReflection extends _classSuper {
73
+ static {
74
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
75
+ _symbolToReflectionIdMap_decorators = [NonEnumerable];
76
+ _reflectionIdToSymbolIdMap_decorators = [NonEnumerable];
77
+ _removedSymbolIds_decorators = [NonEnumerable];
78
+ _referenceGraph_decorators = [NonEnumerable];
79
+ _reflectionChildren_decorators = [NonEnumerable];
80
+ _reflections_decorators = [NonEnumerable];
81
+ __esDecorate(null, null, _symbolToReflectionIdMap_decorators, { kind: "field", name: "symbolToReflectionIdMap", static: false, private: false, access: { has: obj => "symbolToReflectionIdMap" in obj, get: obj => obj.symbolToReflectionIdMap, set: (obj, value) => { obj.symbolToReflectionIdMap = value; } }, metadata: _metadata }, _symbolToReflectionIdMap_initializers, _symbolToReflectionIdMap_extraInitializers);
82
+ __esDecorate(null, null, _reflectionIdToSymbolIdMap_decorators, { kind: "field", name: "reflectionIdToSymbolIdMap", static: false, private: false, access: { has: obj => "reflectionIdToSymbolIdMap" in obj, get: obj => obj.reflectionIdToSymbolIdMap, set: (obj, value) => { obj.reflectionIdToSymbolIdMap = value; } }, metadata: _metadata }, _reflectionIdToSymbolIdMap_initializers, _reflectionIdToSymbolIdMap_extraInitializers);
83
+ __esDecorate(null, null, _removedSymbolIds_decorators, { kind: "field", name: "removedSymbolIds", static: false, private: false, access: { has: obj => "removedSymbolIds" in obj, get: obj => obj.removedSymbolIds, set: (obj, value) => { obj.removedSymbolIds = value; } }, metadata: _metadata }, _removedSymbolIds_initializers, _removedSymbolIds_extraInitializers);
84
+ __esDecorate(null, null, _referenceGraph_decorators, { kind: "field", name: "referenceGraph", static: false, private: false, access: { has: obj => "referenceGraph" in obj, get: obj => obj.referenceGraph, set: (obj, value) => { obj.referenceGraph = value; } }, metadata: _metadata }, _referenceGraph_initializers, _referenceGraph_extraInitializers);
85
+ __esDecorate(null, null, _reflectionChildren_decorators, { kind: "field", name: "reflectionChildren", static: false, private: false, access: { has: obj => "reflectionChildren" in obj, get: obj => obj.reflectionChildren, set: (obj, value) => { obj.reflectionChildren = value; } }, metadata: _metadata }, _reflectionChildren_initializers, _reflectionChildren_extraInitializers);
86
+ __esDecorate(null, null, _reflections_decorators, { kind: "field", name: "reflections", static: false, private: false, access: { has: obj => "reflections" in obj, get: obj => obj.reflections, set: (obj, value) => { obj.reflections = value; } }, metadata: _metadata }, _reflections_initializers, _reflections_extraInitializers);
87
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
85
88
  }
86
- this.reflections[reflection.id] = reflection;
87
- if (id) {
88
- this.registerSymbolId(reflection, id);
89
+ variant = "project";
90
+ // Used to resolve references.
91
+ symbolToReflectionIdMap = __runInitializers(this, _symbolToReflectionIdMap_initializers, new StableKeyMap());
92
+ reflectionIdToSymbolIdMap = (__runInitializers(this, _symbolToReflectionIdMap_extraInitializers), __runInitializers(this, _reflectionIdToSymbolIdMap_initializers, new Map()));
93
+ removedSymbolIds = (__runInitializers(this, _reflectionIdToSymbolIdMap_extraInitializers), __runInitializers(this, _removedSymbolIds_initializers, new StableKeyMap()));
94
+ // Maps a reflection ID to all references eventually referring to it.
95
+ referenceGraph = (__runInitializers(this, _removedSymbolIds_extraInitializers), __runInitializers(this, _referenceGraph_initializers, void 0));
96
+ // Maps a reflection ID to all reflections with it as their parent.
97
+ reflectionChildren = (__runInitializers(this, _referenceGraph_extraInitializers), __runInitializers(this, _reflectionChildren_initializers, new DefaultMap(() => [])));
98
+ /**
99
+ * A list of all reflections within the project. DO NOT MUTATE THIS OBJECT.
100
+ * All mutation should be done via {@link registerReflection} and {@link removeReflection}
101
+ * to ensure that links to reflections remain valid.
102
+ *
103
+ * This may be replaced with a `Map<number, Reflection>` someday.
104
+ */
105
+ reflections = (__runInitializers(this, _reflectionChildren_extraInitializers), __runInitializers(this, _reflections_initializers, {}));
106
+ /**
107
+ * The name of the package that this reflection documents according to package.json.
108
+ */
109
+ packageName = __runInitializers(this, _reflections_extraInitializers);
110
+ /**
111
+ * The version of the package that this reflection documents according to package.json.
112
+ */
113
+ packageVersion;
114
+ /**
115
+ * The contents of the readme.md file of the project when found.
116
+ */
117
+ readme;
118
+ /**
119
+ * Object which describes where to find content for relative links.
120
+ */
121
+ files;
122
+ constructor(name, registry) {
123
+ super(name, ReflectionKind.Project);
124
+ this.reflections[this.id] = this;
125
+ this.files = registry;
89
126
  }
90
- if (filePath) {
91
- this.files.registerReflection(filePath, reflection);
127
+ /**
128
+ * Return whether this reflection is the root / project reflection.
129
+ */
130
+ isProject() {
131
+ return true;
92
132
  }
93
- }
94
- /**
95
- * Removes references to reflections contained within the provided type.
96
- * Plugins which overwrite types on reflections should pass the type to this
97
- * method before overwriting the property.
98
- * @since 0.26.6
99
- */
100
- removeTypeReflections(type) {
101
- type?.visit(makeRecursiveVisitor({
102
- reflection: (type) => {
103
- this.removeReflection(type.declaration);
104
- },
105
- }));
106
- }
107
- /**
108
- * Removes a reflection from the documentation. Can be used by plugins to filter reflections
109
- * out of the generated documentation. Has no effect if the reflection is not present in the
110
- * project.
111
- */
112
- removeReflection(reflection) {
113
- // Remove the reflection...
114
- this._removeReflection(reflection);
115
- // And now try to remove references to it in the parent reflection.
116
- // This might not find anything if someone called removeReflection on a member of a union
117
- // but I think that could only be caused by a plugin doing something weird, not by a regular
118
- // user... so this is probably good enough for now. Reflections that live on types are
119
- // kind of half-real anyways.
120
- const parent = reflection.parent;
121
- parent?.traverse((child, property) => {
122
- if (child !== reflection) {
123
- return true; // Continue iteration
133
+ /**
134
+ * Return a list of all reflections in this project of a certain kind.
135
+ *
136
+ * @param kind The desired kind of reflection.
137
+ * @returns An array containing all reflections with the desired kind.
138
+ */
139
+ getReflectionsByKind(kind) {
140
+ return Object.values(this.reflections).filter((reflection) => reflection.kindOf(kind));
141
+ }
142
+ /**
143
+ * Registers the given reflection so that it can be quickly looked up by helper methods.
144
+ * Should be called for *every* reflection added to the project.
145
+ *
146
+ * Note: During conversion, `Context.registerReflection` should be used instead so
147
+ * that symbols can be saved for later use.
148
+ */
149
+ registerReflection(reflection, id, filePath) {
150
+ this.referenceGraph = undefined;
151
+ if (reflection.parent) {
152
+ this.reflectionChildren
153
+ .get(reflection.parent.id)
154
+ .push(reflection.id);
124
155
  }
125
- switch (property) {
126
- case TraverseProperty.Children:
127
- case TraverseProperty.Documents:
128
- parent.removeChild(reflection);
129
- break;
130
- case TraverseProperty.GetSignature:
131
- delete parent.getSignature;
132
- break;
133
- case TraverseProperty.IndexSignature:
134
- removeIfPresent(parent.indexSignatures, reflection);
135
- if (!parent.indexSignatures?.length) {
136
- delete parent.indexSignatures;
137
- }
138
- break;
139
- case TraverseProperty.Parameters:
140
- removeIfPresent(reflection.parent.parameters, reflection);
141
- if (!reflection.parent.parameters
142
- ?.length) {
143
- delete reflection.parent
144
- .parameters;
145
- }
146
- break;
147
- case TraverseProperty.SetSignature:
148
- delete parent.setSignature;
149
- break;
150
- case TraverseProperty.Signatures:
151
- removeIfPresent(parent.signatures, reflection);
152
- if (!parent.signatures?.length) {
153
- delete parent.signatures;
154
- }
155
- break;
156
- case TraverseProperty.TypeLiteral:
157
- parent.type = new IntrinsicType("Object");
158
- break;
159
- case TraverseProperty.TypeParameter:
160
- removeIfPresent(parent.typeParameters, reflection);
161
- if (!parent.typeParameters?.length) {
162
- delete parent.typeParameters;
163
- }
164
- break;
165
- default:
166
- assertNever(property);
156
+ this.reflections[reflection.id] = reflection;
157
+ if (id) {
158
+ this.registerSymbolId(reflection, id);
167
159
  }
168
- return false; // Stop iteration
169
- });
170
- }
171
- /** @internal */
172
- mergeReflections(source, target) {
173
- // First, tell the children about their new parent
174
- delete this.referenceGraph;
175
- const oldChildrenIds = this.reflectionChildren.getNoInsert(source.id) || [];
176
- const newChildren = this.reflectionChildren.get(target.id);
177
- for (const childId of oldChildrenIds) {
178
- const childRefl = this.getReflectionById(childId);
179
- // To avoid conflicting with some plugins which do this surgery somewhat incorrectly
180
- // (typedoc-plugin-merge-modules and likely others I'm not aware of) only move children
181
- // which are still children
182
- if (childRefl?.parent === source) {
183
- childRefl.parent = target;
184
- newChildren.push(childId);
185
- target.addChild(childRefl);
160
+ if (filePath) {
161
+ this.files.registerReflection(filePath, reflection);
186
162
  }
187
163
  }
188
- // Then remove the now-empty parent
189
- this.reflectionChildren.delete(source.id);
190
- this.removeReflection(source);
191
- // And remove any outdated collections of children on the new parent.
192
- // So long as this is used before REVIVE(-100) or EVENT_BEGIN_RESOLVE(-100)
193
- // this will make the appropriate plugin rebuild the lists.
194
- delete target.groups;
195
- delete target.categories;
196
- }
197
- /**
198
- * Remove a reflection without updating the parent reflection to remove references to the removed reflection.
199
- */
200
- _removeReflection(reflection) {
201
- this.files.removeReflection(reflection);
202
- // Remove references pointing to this reflection
203
- const graph = this.getReferenceGraph();
204
- for (const id of graph.get(reflection.id) ?? []) {
205
- const ref = this.getReflectionById(id);
206
- if (ref) {
207
- this.removeReflection(ref);
208
- }
164
+ /**
165
+ * Removes references to reflections contained within the provided type.
166
+ * Plugins which overwrite types on reflections should pass the type to this
167
+ * method before overwriting the property.
168
+ * @since 0.26.6
169
+ */
170
+ removeTypeReflections(type) {
171
+ type?.visit(makeRecursiveVisitor({
172
+ reflection: (type) => {
173
+ this.removeReflection(type.declaration);
174
+ },
175
+ }));
176
+ }
177
+ /**
178
+ * Removes a reflection from the documentation. Can be used by plugins to filter reflections
179
+ * out of the generated documentation. Has no effect if the reflection is not present in the
180
+ * project.
181
+ */
182
+ removeReflection(reflection) {
183
+ // Remove the reflection...
184
+ this._removeReflection(reflection);
185
+ // And now try to remove references to it in the parent reflection.
186
+ // This might not find anything if someone called removeReflection on a member of a union
187
+ // but I think that could only be caused by a plugin doing something weird, not by a regular
188
+ // user... so this is probably good enough for now. Reflections that live on types are
189
+ // kind of half-real anyways.
190
+ const parent = reflection.parent;
191
+ parent?.traverse((child, property) => {
192
+ if (child !== reflection) {
193
+ return true; // Continue iteration
194
+ }
195
+ switch (property) {
196
+ case TraverseProperty.Children:
197
+ case TraverseProperty.Documents:
198
+ parent.removeChild(reflection);
199
+ break;
200
+ case TraverseProperty.GetSignature:
201
+ delete parent.getSignature;
202
+ break;
203
+ case TraverseProperty.IndexSignature:
204
+ removeIfPresent(parent.indexSignatures, reflection);
205
+ if (!parent.indexSignatures?.length) {
206
+ delete parent.indexSignatures;
207
+ }
208
+ break;
209
+ case TraverseProperty.Parameters:
210
+ removeIfPresent(reflection.parent.parameters, reflection);
211
+ if (!reflection.parent.parameters
212
+ ?.length) {
213
+ delete reflection.parent
214
+ .parameters;
215
+ }
216
+ break;
217
+ case TraverseProperty.SetSignature:
218
+ delete parent.setSignature;
219
+ break;
220
+ case TraverseProperty.Signatures:
221
+ removeIfPresent(parent.signatures, reflection);
222
+ if (!parent.signatures?.length) {
223
+ delete parent.signatures;
224
+ }
225
+ break;
226
+ case TraverseProperty.TypeLiteral:
227
+ parent.type = new IntrinsicType("Object");
228
+ break;
229
+ case TraverseProperty.TypeParameter:
230
+ removeIfPresent(parent.typeParameters, reflection);
231
+ if (!parent.typeParameters?.length) {
232
+ delete parent.typeParameters;
233
+ }
234
+ break;
235
+ default:
236
+ assertNever(property);
237
+ }
238
+ return false; // Stop iteration
239
+ });
209
240
  }
210
- graph.delete(reflection.id);
211
- // Remove children of this reflection
212
- for (const childId of this.reflectionChildren.getNoInsert(reflection.id) || []) {
213
- const child = this.getReflectionById(childId);
214
- // Only remove if the child's parent is still actually this reflection.
215
- // This might not be the case if a plugin has moved this reflection to another parent.
216
- // (typedoc-plugin-merge-modules)
217
- if (child?.parent === reflection) {
218
- this._removeReflection(child);
241
+ /** @internal */
242
+ mergeReflections(source, target) {
243
+ // First, tell the children about their new parent
244
+ delete this.referenceGraph;
245
+ const oldChildrenIds = this.reflectionChildren.getNoInsert(source.id) || [];
246
+ const newChildren = this.reflectionChildren.get(target.id);
247
+ for (const childId of oldChildrenIds) {
248
+ const childRefl = this.getReflectionById(childId);
249
+ // To avoid conflicting with some plugins which do this surgery somewhat incorrectly
250
+ // (typedoc-plugin-merge-modules and likely others I'm not aware of) only move children
251
+ // which are still children
252
+ if (childRefl?.parent === source) {
253
+ childRefl.parent = target;
254
+ newChildren.push(childId);
255
+ target.addChild(childRefl);
256
+ }
219
257
  }
258
+ // Then remove the now-empty parent
259
+ this.reflectionChildren.delete(source.id);
260
+ this.removeReflection(source);
261
+ // And remove any outdated collections of children on the new parent.
262
+ // So long as this is used before REVIVE(-100) or EVENT_BEGIN_RESOLVE(-100)
263
+ // this will make the appropriate plugin rebuild the lists.
264
+ delete target.groups;
265
+ delete target.categories;
220
266
  }
221
- this.reflectionChildren.delete(reflection.id);
222
- // Remove references from the TS symbol to this reflection.
223
- const symbolId = this.reflectionIdToSymbolIdMap.get(reflection.id);
224
- if (symbolId) {
225
- const saved = this.symbolToReflectionIdMap.get(symbolId);
226
- if (saved === reflection.id) {
227
- this.symbolToReflectionIdMap.delete(symbolId);
228
- this.removedSymbolIds.set(symbolId, true);
267
+ /**
268
+ * Remove a reflection without updating the parent reflection to remove references to the removed reflection.
269
+ */
270
+ _removeReflection(reflection) {
271
+ this.files.removeReflection(reflection);
272
+ // Remove references pointing to this reflection
273
+ const graph = this.getReferenceGraph();
274
+ for (const id of graph.get(reflection.id) ?? []) {
275
+ const ref = this.getReflectionById(id);
276
+ if (ref) {
277
+ this.removeReflection(ref);
278
+ }
229
279
  }
230
- else if (typeof saved === "object") {
231
- removeIfPresent(saved, reflection.id);
232
- if (saved.length === 0) {
280
+ graph.delete(reflection.id);
281
+ // Remove children of this reflection
282
+ for (const childId of this.reflectionChildren.getNoInsert(reflection.id) || []) {
283
+ const child = this.getReflectionById(childId);
284
+ // Only remove if the child's parent is still actually this reflection.
285
+ // This might not be the case if a plugin has moved this reflection to another parent.
286
+ // (typedoc-plugin-merge-modules)
287
+ if (child?.parent === reflection) {
288
+ this._removeReflection(child);
289
+ }
290
+ }
291
+ this.reflectionChildren.delete(reflection.id);
292
+ // Remove references from the TS symbol to this reflection.
293
+ const symbolId = this.reflectionIdToSymbolIdMap.get(reflection.id);
294
+ if (symbolId) {
295
+ const saved = this.symbolToReflectionIdMap.get(symbolId);
296
+ if (saved === reflection.id) {
297
+ this.symbolToReflectionIdMap.delete(symbolId);
233
298
  this.removedSymbolIds.set(symbolId, true);
234
299
  }
300
+ else if (typeof saved === "object") {
301
+ removeIfPresent(saved, reflection.id);
302
+ if (saved.length === 0) {
303
+ this.removedSymbolIds.set(symbolId, true);
304
+ }
305
+ }
235
306
  }
307
+ this.reflectionIdToSymbolIdMap.delete(reflection.id);
308
+ delete this.reflections[reflection.id];
236
309
  }
237
- this.reflectionIdToSymbolIdMap.delete(reflection.id);
238
- delete this.reflections[reflection.id];
239
- }
240
- /**
241
- * Gets the reflection registered for the given reflection ID, or undefined if it is not present
242
- * in the project.
243
- */
244
- getReflectionById(id) {
245
- return this.reflections[id];
246
- }
247
- /**
248
- * Gets the reflection associated with the given symbol id, if it exists.
249
- * If there are multiple reflections associated with this symbol, gets the first one.
250
- * @internal
251
- */
252
- getReflectionFromSymbolId(symbolId) {
253
- return this.getReflectionsFromSymbolId(symbolId)[0];
254
- }
255
- /** @internal */
256
- getReflectionsFromSymbolId(symbolId) {
257
- const id = this.symbolToReflectionIdMap.get(symbolId);
258
- if (typeof id === "number") {
259
- return [this.getReflectionById(id)];
310
+ /**
311
+ * Gets the reflection registered for the given reflection ID, or undefined if it is not present
312
+ * in the project.
313
+ */
314
+ getReflectionById(id) {
315
+ return this.reflections[id];
260
316
  }
261
- else if (typeof id === "object") {
262
- return id.map((id) => this.getReflectionById(id));
317
+ /**
318
+ * Gets the reflection associated with the given symbol id, if it exists.
319
+ * If there are multiple reflections associated with this symbol, gets the first one.
320
+ * @internal
321
+ */
322
+ getReflectionFromSymbolId(symbolId) {
323
+ return this.getReflectionsFromSymbolId(symbolId)[0];
263
324
  }
264
- return [];
265
- }
266
- /** @internal */
267
- getSymbolIdFromReflection(reflection) {
268
- return this.reflectionIdToSymbolIdMap.get(reflection.id);
269
- }
270
- /** @internal */
271
- registerSymbolId(reflection, id) {
272
- this.removedSymbolIds.delete(id);
273
- this.reflectionIdToSymbolIdMap.set(reflection.id, id);
274
- const previous = this.symbolToReflectionIdMap.get(id);
275
- if (previous) {
276
- if (typeof previous === "number") {
277
- this.symbolToReflectionIdMap.set(id, [previous, reflection.id]);
325
+ /** @internal */
326
+ getReflectionsFromSymbolId(symbolId) {
327
+ const id = this.symbolToReflectionIdMap.get(symbolId);
328
+ if (typeof id === "number") {
329
+ return [this.getReflectionById(id)];
330
+ }
331
+ else if (typeof id === "object") {
332
+ return id.map((id) => this.getReflectionById(id));
333
+ }
334
+ return [];
335
+ }
336
+ /** @internal */
337
+ getSymbolIdFromReflection(reflection) {
338
+ return this.reflectionIdToSymbolIdMap.get(reflection.id);
339
+ }
340
+ /** @internal */
341
+ registerSymbolId(reflection, id) {
342
+ this.removedSymbolIds.delete(id);
343
+ this.reflectionIdToSymbolIdMap.set(reflection.id, id);
344
+ const previous = this.symbolToReflectionIdMap.get(id);
345
+ if (previous) {
346
+ if (typeof previous === "number") {
347
+ this.symbolToReflectionIdMap.set(id, [previous, reflection.id]);
348
+ }
349
+ else {
350
+ previous.push(reflection.id);
351
+ }
278
352
  }
279
353
  else {
280
- previous.push(reflection.id);
354
+ this.symbolToReflectionIdMap.set(id, reflection.id);
281
355
  }
282
356
  }
283
- else {
284
- this.symbolToReflectionIdMap.set(id, reflection.id);
357
+ symbolIdHasBeenRemoved(id) {
358
+ return this.removedSymbolIds.has(id);
285
359
  }
286
- }
287
- symbolIdHasBeenRemoved(id) {
288
- return this.removedSymbolIds.has(id);
289
- }
290
- getReferenceGraph() {
291
- if (!this.referenceGraph) {
292
- this.referenceGraph = new Map();
293
- for (const id in this.reflections) {
294
- const ref = this.reflections[id];
295
- if (ref instanceof ReferenceReflection) {
296
- const target = ref.tryGetTargetReflection();
297
- if (target) {
298
- const refs = this.referenceGraph.get(target.id) ?? [];
299
- refs.push(ref.id);
300
- this.referenceGraph.set(target.id, refs);
360
+ getReferenceGraph() {
361
+ if (!this.referenceGraph) {
362
+ this.referenceGraph = new Map();
363
+ for (const id in this.reflections) {
364
+ const ref = this.reflections[id];
365
+ if (ref instanceof ReferenceReflection) {
366
+ const target = ref.tryGetTargetReflection();
367
+ if (target) {
368
+ const refs = this.referenceGraph.get(target.id) ?? [];
369
+ refs.push(ref.id);
370
+ this.referenceGraph.set(target.id, refs);
371
+ }
301
372
  }
302
373
  }
303
374
  }
375
+ return this.referenceGraph;
304
376
  }
305
- return this.referenceGraph;
306
- }
307
- toObject(serializer) {
308
- const symbolIdMap = {};
309
- this.reflectionIdToSymbolIdMap.forEach((sid, id) => {
310
- symbolIdMap[id] = sid.toObject();
311
- });
312
- return {
313
- schemaVersion: JSON_SCHEMA_VERSION,
314
- ...super.toObject(serializer),
315
- variant: this.variant,
316
- packageName: this.packageName,
317
- packageVersion: this.packageVersion,
318
- readme: Comment.serializeDisplayParts(this.readme),
319
- symbolIdMap,
320
- files: serializer.toObject(this.files),
321
- };
322
- }
323
- fromObject(de, obj) {
324
- super.fromObject(de, obj);
325
- // If updating this, also check the block in DeclarationReflection.fromObject.
326
- this.packageName = obj.packageName;
327
- this.packageVersion = obj.packageVersion;
328
- if (obj.readme) {
329
- this.readme = Comment.deserializeDisplayParts(de, obj.readme);
377
+ toObject(serializer) {
378
+ const symbolIdMap = {};
379
+ this.reflectionIdToSymbolIdMap.forEach((sid, id) => {
380
+ symbolIdMap[id] = sid.toObject();
381
+ });
382
+ return {
383
+ schemaVersion: JSON_SCHEMA_VERSION,
384
+ ...super.toObject(serializer),
385
+ variant: this.variant,
386
+ packageName: this.packageName,
387
+ packageVersion: this.packageVersion,
388
+ readme: Comment.serializeDisplayParts(this.readme),
389
+ symbolIdMap,
390
+ files: serializer.toObject(this.files),
391
+ };
330
392
  }
331
- this.files.fromObject(de, obj.files || {});
332
- de.defer(() => {
333
- // Unnecessary conditional in release
334
- for (const [id, sid] of Object.entries(obj.symbolIdMap || {})) {
335
- const refl = this.getReflectionById(de.oldIdToNewId[+id] ?? -1);
336
- if (refl) {
337
- this.registerSymbolId(refl, new ReflectionSymbolId(sid));
338
- }
339
- else {
340
- de.logger.warn(i18n.serialized_project_referenced_0_not_part_of_project(id.toString()));
341
- }
393
+ fromObject(de, obj) {
394
+ super.fromObject(de, obj);
395
+ // If updating this, also check the block in DeclarationReflection.fromObject.
396
+ this.packageName = obj.packageName;
397
+ this.packageVersion = obj.packageVersion;
398
+ if (obj.readme) {
399
+ this.readme = Comment.deserializeDisplayParts(de, obj.readme);
342
400
  }
343
- });
344
- }
345
- }
401
+ this.files.fromObject(de, obj.files || {});
402
+ de.defer(() => {
403
+ // Unnecessary conditional in release
404
+ for (const [id, sid] of Object.entries(obj.symbolIdMap || {})) {
405
+ const refl = this.getReflectionById(de.oldIdToNewId[+id] ?? -1);
406
+ if (refl) {
407
+ this.registerSymbolId(refl, new ReflectionSymbolId(sid));
408
+ }
409
+ else {
410
+ de.logger.warn(i18n.serialized_project_referenced_0_not_part_of_project(id.toString()));
411
+ }
412
+ }
413
+ });
414
+ }
415
+ };
416
+ })();
417
+ export { ProjectReflection };
@@ -29,7 +29,7 @@ export function moduleReflection(context, mod) {
29
29
  })));
30
30
  }
31
31
  export function moduleMemberSummary(context, member) {
32
- const id = context.slugger.slug(member.name);
32
+ const id = member.isReference() ? context.getAnchor(member) : context.slugger.slug(member.name);
33
33
  context.page.pageHeadings.push({
34
34
  link: `#${id}`,
35
35
  text: getDisplayName(member),
@@ -0,0 +1,3 @@
1
+ import type ts from "typescript";
2
+ export declare function resolveDeclarationMaps(file: string): string;
3
+ export declare function addInferredDeclarationMapPaths(opts: ts.CompilerOptions, files: readonly string[]): void;
@@ -0,0 +1,51 @@
1
+ import { existsSync } from "fs";
2
+ import { readFile } from "./fs.js";
3
+ import { Validation } from "#utils";
4
+ import { join, relative, resolve } from "path";
5
+ import { getCommonDirectory, normalizePath } from "./paths.js";
6
+ const declarationMapCache = new Map();
7
+ export function resolveDeclarationMaps(file) {
8
+ if (!/\.d\.[cm]?ts$/.test(file))
9
+ return file;
10
+ if (declarationMapCache.has(file))
11
+ return declarationMapCache.get(file);
12
+ const mapFile = file + ".map";
13
+ if (!existsSync(mapFile))
14
+ return file;
15
+ let sourceMap;
16
+ try {
17
+ sourceMap = JSON.parse(readFile(mapFile));
18
+ }
19
+ catch {
20
+ return file;
21
+ }
22
+ if (Validation.validate({
23
+ file: String,
24
+ sourceRoot: Validation.optional(String),
25
+ sources: [Array, String],
26
+ }, sourceMap)) {
27
+ // There's a pretty large assumption in here that we only have
28
+ // 1 source file per js file. This is a pretty standard typescript approach,
29
+ // but people might do interesting things with transpilation that could break this.
30
+ let source = sourceMap.sources[0];
31
+ // If we have a sourceRoot, trim any leading slash from the source, and join them
32
+ // Similar to how it's done at https://github.com/mozilla/source-map/blob/58819f09018d56ef84dc41ba9c93f554e0645169/lib/util.js#L412
33
+ if (sourceMap.sourceRoot !== undefined) {
34
+ source = source.replace(/^\//, "");
35
+ source = join(sourceMap.sourceRoot, source);
36
+ }
37
+ const result = resolve(mapFile, "..", source);
38
+ declarationMapCache.set(file, result);
39
+ return result;
40
+ }
41
+ return file;
42
+ }
43
+ // See also: inferEntryPoints in entry-point.ts
44
+ export function addInferredDeclarationMapPaths(opts, files) {
45
+ const rootDir = opts.rootDir || getCommonDirectory(files);
46
+ const declDir = opts.declarationDir || opts.outDir || rootDir;
47
+ for (const file of files) {
48
+ const mapFile = normalizePath(resolve(declDir, relative(rootDir, file)).replace(/\.([cm]?[tj]s)x?$/, ".d.$1"));
49
+ declarationMapCache.set(mapFile, file);
50
+ }
51
+ }
@@ -5,6 +5,7 @@ import { expandPackages } from "./package-manifest.js";
5
5
  import { deriveRootDir, getCommonDirectory, MinimatchSet, nicePath, normalizePath } from "./paths.js";
6
6
  import { discoverPackageJson, glob, inferPackageEntryPointPaths, isDir } from "./fs.js";
7
7
  import { assertNever, i18n } from "#utils";
8
+ import { addInferredDeclarationMapPaths, resolveDeclarationMaps } from "./declaration-maps.js";
8
9
  /**
9
10
  * Defines how entry points are interpreted.
10
11
  * @enum
@@ -39,7 +40,7 @@ export function inferEntryPoints(logger, options, programs) {
39
40
  const pathEntries = inferPackageEntryPointPaths(packageJson.file);
40
41
  const entryPoints = [];
41
42
  programs ||= getEntryPrograms(pathEntries.map((p) => p[1]), logger, options);
42
- // See also: addInferredDeclarationMapPaths in ReflectionSymbolId
43
+ // See also: addInferredDeclarationMapPaths in symbol-id factory
43
44
  const jsToTsSource = new Map();
44
45
  for (const program of programs) {
45
46
  const opts = program.getCompilerOptions();
@@ -53,7 +54,7 @@ export function inferEntryPoints(logger, options, programs) {
53
54
  for (const [name, path] of pathEntries) {
54
55
  // Strip leading ./ from the display name
55
56
  const displayName = name.replace(/^\.\/?/, "");
56
- const targetPath = jsToTsSource.get(path) || path;
57
+ const targetPath = jsToTsSource.get(path) || resolveDeclarationMaps(path) || path;
57
58
  const program = programs.find((p) => p.getSourceFile(targetPath));
58
59
  if (program) {
59
60
  entryPoints.push({
@@ -70,6 +71,7 @@ export function inferEntryPoints(logger, options, programs) {
70
71
  logger.warn(i18n.no_entry_points_provided());
71
72
  return [];
72
73
  }
74
+ logger.verbose(`Inferred entry points to be:\n\t${entryPoints.map(e => nicePath(e.sourceFile.fileName)).join("\n\t")}`);
73
75
  return entryPoints;
74
76
  }
75
77
  export function getEntryPoints(logger, options) {
@@ -257,6 +259,7 @@ function getEntryPrograms(inputFiles, logger, options) {
257
259
  options: options.getCompilerOptions(),
258
260
  projectReferences: options.getProjectReferences(),
259
261
  });
262
+ addInferredDeclarationMapPaths(options.getCompilerOptions(), options.getFileNames());
260
263
  const programs = [rootProgram];
261
264
  // This might be a solution style tsconfig, in which case we need to add a program for each
262
265
  // reference so that the converter can look through each of these.
@@ -271,6 +274,7 @@ function getEntryPrograms(inputFiles, logger, options) {
271
274
  rootNames: ref.commandLine.fileNames,
272
275
  projectReferences: ref.commandLine.projectReferences,
273
276
  }));
277
+ addInferredDeclarationMapPaths(ref.commandLine.options, ref.commandLine.fileNames);
274
278
  }
275
279
  }
276
280
  return programs;
@@ -9,6 +9,7 @@ export { loadPlugins } from "./plugins.js";
9
9
  export { getSortFunction } from "./sort.js";
10
10
  export type { SortStrategy } from "./sort.js";
11
11
  export * from "./entry-point.js";
12
+ export * from "./declaration-maps.js";
12
13
  export * from "./highlighter.js";
13
14
  export * from "./html.js";
14
15
  export * from "./tsconfig.js";
@@ -7,6 +7,7 @@ export * from "./paths.js";
7
7
  export { loadPlugins } from "./plugins.js";
8
8
  export { getSortFunction } from "./sort.js";
9
9
  export * from "./entry-point.js";
10
+ export * from "./declaration-maps.js";
10
11
  export * from "./highlighter.js";
11
12
  export * from "./html.js";
12
13
  export * from "./tsconfig.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typedoc",
3
3
  "description": "Create api documentation for TypeScript projects.",
4
- "version": "0.28.8",
4
+ "version": "0.28.10",
5
5
  "homepage": "https://typedoc.org",
6
6
  "type": "module",
7
7
  "exports": {
@@ -31,32 +31,32 @@
31
31
  "pnpm": ">= 10"
32
32
  },
33
33
  "dependencies": {
34
- "@gerrit0/mini-shiki": "^3.7.0",
34
+ "@gerrit0/mini-shiki": "^3.9.0",
35
35
  "lunr": "^2.3.9",
36
36
  "markdown-it": "^14.1.0",
37
37
  "minimatch": "^9.0.5",
38
38
  "yaml": "^2.8.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "typescript": "5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x"
41
+ "typescript": "5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x || 5.9.x"
42
42
  },
43
43
  "devDependencies": {
44
- "@eslint/js": "^9.30.0",
44
+ "@eslint/js": "^9.32.0",
45
45
  "@types/lunr": "^2.3.7",
46
46
  "@types/markdown-it": "^14.1.2",
47
47
  "@types/mocha": "^10.0.10",
48
48
  "@types/node": "18",
49
49
  "@typestrong/fs-fixture-builder": "github:TypeStrong/fs-fixture-builder#34113409e3a171e68ce5e2b55461ef5c35591cfe",
50
50
  "c8": "^10.1.3",
51
- "dprint": "^0.50.0",
52
- "esbuild": "^0.25.5",
53
- "eslint": "^9.30.0",
51
+ "dprint": "^0.50.1",
52
+ "esbuild": "^0.25.8",
53
+ "eslint": "^9.32.0",
54
54
  "mocha": "^11.7.1",
55
55
  "puppeteer": "^24.11.1",
56
56
  "semver": "^7.7.2",
57
57
  "tsx": "^4.20.3",
58
- "typescript": "5.8.3",
59
- "typescript-eslint": "^8.35.0"
58
+ "typescript": "5.9.2",
59
+ "typescript-eslint": "^8.38.0"
60
60
  },
61
61
  "files": [
62
62
  "/bin",