fumadocs-typescript 1.0.1 → 2.0.0

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.
@@ -5,6 +5,10 @@ interface TypescriptConfig {
5
5
  tsconfigPath?: string;
6
6
  /** A root directory to resolve relative path entries in the config file to. e.g. outDir */
7
7
  basePath?: string;
8
+ /**
9
+ * Default lib directory, use `./node_modules/typescript/lib` if not specified
10
+ */
11
+ getDefaultLibLocation?: (() => string) | 'default';
8
12
  }
9
13
 
10
14
  interface GeneratedDoc {
@@ -1,6 +1,4 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
2
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
3
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
4
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -16,7 +14,6 @@ var __spreadValues = (a, b) => {
16
14
  }
17
15
  return a;
18
16
  };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
17
  var __objRest = (source, exclude) => {
21
18
  var target = {};
22
19
  for (var prop in source)
@@ -30,7 +27,7 @@ var __objRest = (source, exclude) => {
30
27
  return target;
31
28
  };
32
29
  var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
30
+ return new Promise((resolve2, reject) => {
34
31
  var fulfilled = (value) => {
35
32
  try {
36
33
  step(generator.next(value));
@@ -45,7 +42,7 @@ var __async = (__this, __arguments, generator) => {
45
42
  reject(e);
46
43
  }
47
44
  };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
+ var step = (x) => x.done ? resolve2(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
46
  step((generator = generator.apply(__this, __arguments)).next());
50
47
  });
51
48
  };
@@ -54,6 +51,7 @@ var __async = (__this, __arguments, generator) => {
54
51
  import ts2 from "typescript";
55
52
 
56
53
  // src/program.ts
54
+ import * as path from "path";
57
55
  import ts from "typescript";
58
56
  var cache = /* @__PURE__ */ new Map();
59
57
  function getFileSymbol(file, program) {
@@ -64,25 +62,31 @@ function getFileSymbol(file, program) {
64
62
  return checker.getSymbolAtLocation(sourceFile);
65
63
  }
66
64
  function getProgram(options = {}) {
67
- var _a, _b, _c;
65
+ var _a, _b, _c, _d;
68
66
  const key = JSON.stringify(options);
69
67
  const cached = cache.get(key);
70
68
  if (cached)
71
69
  return cached;
72
70
  const configFile = ts.readJsonConfigFile(
73
71
  (_a = options.tsconfigPath) != null ? _a : "./tsconfig.json",
74
- (path) => ts.sys.readFile(path)
72
+ (p) => ts.sys.readFile(p)
75
73
  );
76
74
  const parsed = ts.parseJsonSourceFileConfigFileContent(
77
75
  configFile,
78
76
  ts.sys,
79
77
  (_b = options.basePath) != null ? _b : "./"
80
78
  );
79
+ parsed.options.incremental = false;
80
+ const host = ts.createCompilerHost(parsed.options);
81
+ if (options.getDefaultLibLocation !== "default") {
82
+ host.getDefaultLibLocation = (_c = options.getDefaultLibLocation) != null ? _c : () => path.resolve("./node_modules/typescript/lib");
83
+ }
81
84
  const program = ts.createProgram({
82
- rootNames: (_c = options.files) != null ? _c : parsed.fileNames,
83
- options: __spreadProps(__spreadValues({}, parsed.options), {
84
- incremental: false
85
- })
85
+ rootNames: (_d = options.files) != null ? _d : parsed.fileNames,
86
+ host,
87
+ options: parsed.options,
88
+ configFileParsingDiagnostics: parsed.errors,
89
+ projectReferences: parsed.projectReferences
86
90
  });
87
91
  cache.set(key, program);
88
92
  return program;
@@ -145,6 +149,19 @@ function getDocEntry(prop, context) {
145
149
  return entry;
146
150
  }
147
151
 
152
+ // src/markdown.ts
153
+ import { fromMarkdown } from "mdast-util-from-markdown";
154
+ import { gfmFromMarkdown } from "mdast-util-gfm";
155
+ import { toHast } from "mdast-util-to-hast";
156
+ function renderMarkdownToHast(md) {
157
+ const mdast = fromMarkdown(
158
+ md.replace(new RegExp("{@link (?<link>[^}]*)}", "g"), "$1"),
159
+ // replace jsdoc links
160
+ { mdastExtensions: [gfmFromMarkdown()] }
161
+ );
162
+ return toHast(mdast);
163
+ }
164
+
148
165
  export {
149
166
  __spreadValues,
150
167
  __objRest,
@@ -152,5 +169,6 @@ export {
152
169
  getFileSymbol,
153
170
  getProgram,
154
171
  generateDocumentation,
155
- generate
172
+ generate,
173
+ renderMarkdownToHast
156
174
  };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { G as GenerateOptions, T as TypescriptConfig, a as GeneratedDoc, D as DocEntry } from './base-EFDclhRL.js';
2
- export { b as GenerateDocumentationOptions, c as generate, g as generateDocumentation } from './base-EFDclhRL.js';
1
+ import { G as GenerateOptions, T as TypescriptConfig, a as GeneratedDoc, D as DocEntry } from './base-3iGxlbJG.js';
2
+ export { b as GenerateDocumentationOptions, c as generate, g as generateDocumentation } from './base-3iGxlbJG.js';
3
3
  import fg from 'fast-glob';
4
+ import { Nodes } from 'hast';
4
5
  import 'typescript';
5
6
 
6
7
  interface Templates {
@@ -32,4 +33,6 @@ interface GenerateFilesOptions {
32
33
  }
33
34
  declare function generateFiles(options: GenerateFilesOptions): Promise<void>;
34
35
 
35
- export { DocEntry, type GenerateFilesOptions, type GenerateMDXOptions, GenerateOptions, GeneratedDoc, generateFiles, generateMDX };
36
+ declare function renderMarkdownToHast(md: string): Nodes;
37
+
38
+ export { DocEntry, type GenerateFilesOptions, type GenerateMDXOptions, GenerateOptions, GeneratedDoc, generateFiles, generateMDX, renderMarkdownToHast };
package/dist/index.js CHANGED
@@ -5,8 +5,9 @@ import {
5
5
  generate,
6
6
  generateDocumentation,
7
7
  getFileSymbol,
8
- getProgram
9
- } from "./chunk-J5BKKGOH.js";
8
+ getProgram,
9
+ renderMarkdownToHast
10
+ } from "./chunk-ESYFMJFA.js";
10
11
 
11
12
  // src/generate/mdx.ts
12
13
  import * as path from "path";
@@ -103,5 +104,6 @@ export {
103
104
  generate,
104
105
  generateDocumentation,
105
106
  generateFiles,
106
- generateMDX
107
+ generateMDX,
108
+ renderMarkdownToHast
107
109
  };
@@ -1,4 +1,4 @@
1
- import { G as GenerateOptions } from '../base-EFDclhRL.js';
1
+ import { G as GenerateOptions } from '../base-3iGxlbJG.js';
2
2
  import 'typescript';
3
3
 
4
4
  /**
@@ -10,6 +10,6 @@ declare function AutoTypeTable({ path, name, options, }: {
10
10
  path: string;
11
11
  name: string;
12
12
  options?: GenerateOptions;
13
- }): JSX.Element;
13
+ }): React.ReactElement;
14
14
 
15
15
  export { AutoTypeTable };
package/dist/ui/index.js CHANGED
@@ -1,32 +1,12 @@
1
1
  import {
2
- generateDocumentation
3
- } from "../chunk-J5BKKGOH.js";
2
+ generateDocumentation,
3
+ renderMarkdownToHast
4
+ } from "../chunk-ESYFMJFA.js";
4
5
 
5
6
  // src/ui/auto-type-table.tsx
6
7
  import { TypeTable } from "fumadocs-ui/components/type-table";
7
-
8
- // src/markdown.ts
9
- import { fromMarkdown } from "mdast-util-from-markdown";
10
- import { gfmFromMarkdown } from "mdast-util-gfm";
11
- import { toHast } from "mdast-util-to-hast";
12
- import {
13
- toJsxRuntime
14
- } from "hast-util-to-jsx-runtime";
8
+ import { toJsxRuntime } from "hast-util-to-jsx-runtime";
15
9
  import * as runtime from "react/jsx-runtime";
16
- function renderMarkdown(md) {
17
- const mdast = fromMarkdown(
18
- md.replace(new RegExp("{@link (?<link>[^}]*)}", "g"), "$1"),
19
- // replace jsdoc links
20
- { mdastExtensions: [gfmFromMarkdown()] }
21
- );
22
- return toJsxRuntime(toHast(mdast), {
23
- Fragment: runtime.Fragment,
24
- jsx: runtime.jsx,
25
- jsxs: runtime.jsxs
26
- });
27
- }
28
-
29
- // src/ui/auto-type-table.tsx
30
10
  import "server-only";
31
11
  import { jsx as jsx2 } from "react/jsx-runtime";
32
12
  function AutoTypeTable({
@@ -53,6 +33,13 @@ function AutoTypeTable({
53
33
  }
54
34
  );
55
35
  }
36
+ function renderMarkdown(md) {
37
+ return toJsxRuntime(renderMarkdownToHast(md), {
38
+ Fragment: runtime.Fragment,
39
+ jsx: runtime.jsx,
40
+ jsxs: runtime.jsxs
41
+ });
42
+ }
56
43
  export {
57
44
  AutoTypeTable
58
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-typescript",
3
- "version": "1.0.1",
3
+ "version": "2.0.0",
4
4
  "description": "Typescript Integration for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -42,12 +42,13 @@
42
42
  "mdast-util-to-hast": "^13.1.0"
43
43
  },
44
44
  "devDependencies": {
45
+ "@types/estree": "^1.0.5",
45
46
  "@types/hast": "^3.0.4",
46
47
  "@types/mdast": "^4.0.3",
47
- "@types/react": "18.2.0",
48
- "@types/react-dom": "18.2.1",
48
+ "@types/react": "18.2.67",
49
+ "@types/react-dom": "18.2.22",
49
50
  "eslint-config-custom": "0.0.0",
50
- "fumadocs-ui": "10.0.2",
51
+ "fumadocs-ui": "11.0.0",
51
52
  "tsconfig": "0.0.0"
52
53
  },
53
54
  "peerDependencies": {