@arcgis/api-extractor 5.0.0-next.136 → 5.0.0-next.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ApiExtractor-BwOcUvPV.js +2644 -0
- package/dist/apiJson.d.ts +706 -760
- package/dist/cli.js +26 -2
- package/dist/compilerHints.d.ts +62 -0
- package/dist/diff/diffApiJson.d.ts +6 -3
- package/dist/diff/diffApiJson.js +142 -0
- package/dist/diff/fetchApiJsonFromNpm.d.ts +5 -2
- package/dist/diff/fetchApiJsonFromNpm.js +9 -0
- package/dist/diff/types.d.ts +70 -56
- package/dist/diffTypes/index.d.ts +20 -23
- package/dist/diffTypes/index.js +4 -2
- package/dist/extractor/ApiExtractor.d.ts +72 -137
- package/dist/extractor/ApiExtractor.js +9 -0
- package/dist/extractor/config.d.ts +425 -39
- package/dist/extractor/config.js +17 -0
- package/dist/extractor/extractors/copyDoc.d.ts +25 -0
- package/dist/extractor/privateContext.d.ts +19 -0
- package/dist/extractor/privateContext.js +84 -0
- package/dist/extractor/processing/links.d.ts +12 -0
- package/dist/extractor/processing/links.js +177 -0
- package/dist/extractor/types.d.ts +40 -0
- package/dist/extractor/webComponent/findComponents.d.ts +19 -0
- package/dist/extractor/webComponent/findComponents.js +36 -0
- package/dist/extractor/webComponent/pathMapping.d.ts +11 -0
- package/dist/extractor/webComponent/pathMapping.js +44 -0
- package/dist/index.d.ts +164 -12
- package/dist/index.js +3 -841
- package/dist/typeScript-CzUTFiYO.js +64 -0
- package/dist/uiUtils/index.d.ts +10 -19
- package/dist/uiUtils/index.js +3 -55
- package/dist/utils/apiHelpers.d.ts +28 -61
- package/dist/utils/apiHelpers.js +80 -0
- package/dist/utils/astHelpers.d.ts +22 -21
- package/dist/utils/astHelpers.js +67 -0
- package/dist/utils/hydrateApiType.d.ts +26 -0
- package/dist/utils/hydrateApiType.js +62 -0
- package/dist/utils/inferEntrypoints.d.ts +17 -0
- package/dist/utils/inferEntrypoints.js +26 -0
- package/dist/utils/internalTypeScriptApis.d.ts +92 -0
- package/dist/utils/internalTypeScriptApis.js +58 -0
- package/dist/utils/partPrinter.d.ts +25 -19
- package/dist/utils/partPrinter.js +82 -0
- package/dist/vite/plugin.d.ts +53 -0
- package/dist/vite/plugin.js +107 -0
- package/dist/vite/typeScript.d.ts +16 -0
- package/dist/vite/typeScript.js +6 -0
- package/dist/worker-CULPfolw.js +3599 -0
- package/package.json +40 -9
- package/dist/cli.d.ts +0 -2
- package/dist/config/typeReferences/docLinkAdditions.d.ts +0 -51
- package/dist/config/typeReferences/globals.d.ts +0 -11
- package/dist/config/typeReferences/stringDocLinkAdditions.d.ts +0 -17
- package/dist/config/typeReferences/typeScriptGlobals.json.d.ts +0 -3
- package/dist/diff/index.d.ts +0 -3
- package/dist/diff/index.js +0 -149
- package/dist/ensureCemCompatibility.d.ts +0 -1
- package/dist/internalTypeScriptApis.d.ts +0 -31
- package/dist/types.d.ts +0 -22
- package/dist/utils/error.d.ts +0 -17
- package/dist/utils/jsDocHelpers.d.ts +0 -2
- package/dist/utils/jsDocParser.d.ts +0 -46
- package/dist/utils/jsDocPrinter.d.ts +0 -13
- package/dist/utils/print.d.ts +0 -6
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/** @experimental */
|
|
2
|
+
import type ts from "typescript";
|
|
3
|
+
|
|
4
|
+
/** Simplified type. Does not include all fields. */
|
|
5
|
+
export interface SourceMap {
|
|
6
|
+
mappings: "";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Using undocumented TypeScript APIs can break at any time. Moreover, with the
|
|
11
|
+
* transition to tsgo, the code using these APIs will definitely need to be
|
|
12
|
+
* refactored.
|
|
13
|
+
*
|
|
14
|
+
* However, we are still using them for now because:
|
|
15
|
+
* - until tsgo provides better API, this is the best way we have
|
|
16
|
+
* - the migration to tsgo may require significant refactoring anyway, as
|
|
17
|
+
* IPC overhead requires TypeScript to rethink the public API.
|
|
18
|
+
*
|
|
19
|
+
* Use cases for undocumented TypeScript APIs:
|
|
20
|
+
* - workaround for there being no public API for printing a file with source
|
|
21
|
+
* maps. See: https://github.com/microsoft/TypeScript/issues/51329#issuecomment-2197859814
|
|
22
|
+
* - TS has alternative API (program.emit), but it is very slow and does
|
|
23
|
+
* type-checking. If tsgo has an API we need, we could use it. Otherwise
|
|
24
|
+
* would have to use an alternative AST+transformer+printer in Lumina.
|
|
25
|
+
* - print TypeNode object literals across multiple lines rather than single
|
|
26
|
+
* line
|
|
27
|
+
* - alternative: use regex hacks
|
|
28
|
+
* - keep track of the location of each TypeReferenceNode as it is printed to
|
|
29
|
+
* populate the ApiTypeReference.start and .end fields. Alternatives:
|
|
30
|
+
* - alternative 1: write custom printer for type nodes, with fallback to
|
|
31
|
+
* TypeScript's printer for unknown nodes and `typeof <expression>` syntax.
|
|
32
|
+
* Much more control, much better performance, and less exposure to tsgo.
|
|
33
|
+
* But is much more complexity.
|
|
34
|
+
* - alternative 2: before printing or as part of printing, replace all
|
|
35
|
+
* TypeReferenceNodes with markers (`__ref_1__`), then post-process the
|
|
36
|
+
* print result.
|
|
37
|
+
* - alternative 3: collect list of type references before printing. after
|
|
38
|
+
* printing, do a regex search on print string and try matching each type
|
|
39
|
+
* reference to places where it is printed.
|
|
40
|
+
*/
|
|
41
|
+
export const unsafeUndocumentedTs: Required<UndocumentedTypeScript>;
|
|
42
|
+
|
|
43
|
+
export interface UndocumentedTypeScript {
|
|
44
|
+
/**
|
|
45
|
+
* @param host
|
|
46
|
+
* @param basename
|
|
47
|
+
* @param sourceRoot
|
|
48
|
+
* @param dirname
|
|
49
|
+
* @param compilerOptions
|
|
50
|
+
*/
|
|
51
|
+
createSourceMapGenerator?(host: Pick<ts.CompilerHost, "getCanonicalFileName" | "getCurrentDirectory">, basename: string, sourceRoot: string, dirname: string, compilerOptions: Record<never, never> | ts.CompilerOptions): SourceMapGenerator;
|
|
52
|
+
/** @param newLine */
|
|
53
|
+
createTextWriter?(newLine: string): EmitTextWriter;
|
|
54
|
+
/**
|
|
55
|
+
* @param options - Printer has undocumented options for printing source maps:
|
|
56
|
+
* https://github.com/microsoft/TypeScript/blob/7319968e90600102892a79142fb804bcbe384160/src/compiler/types.ts#L9689C18-L9707
|
|
57
|
+
* @param handlers
|
|
58
|
+
*/
|
|
59
|
+
createPrinter(options: ts.CompilerOptions & ts.PrinterOptions, handlers?: ts.PrintHandlers): ReturnType<typeof ts.createPrinter> & UndocumentedPrinter;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface SourceMapGenerator {
|
|
63
|
+
toJSON(): SourceMap;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface UndocumentedPrinter {
|
|
67
|
+
/**
|
|
68
|
+
* @param writeFile
|
|
69
|
+
* @param writer
|
|
70
|
+
* @param sourceMapGenerator
|
|
71
|
+
*/
|
|
72
|
+
writeFile?(writeFile: ts.SourceFile, writer: EmitTextWriter, sourceMapGenerator: SourceMapGenerator | undefined): void;
|
|
73
|
+
/**
|
|
74
|
+
* @param hint
|
|
75
|
+
* @param node
|
|
76
|
+
* @param sourceFile
|
|
77
|
+
* @param output
|
|
78
|
+
*/
|
|
79
|
+
writeNode?(hint: ts.EmitHint, node: ts.Node, sourceFile: ts.SourceFile | undefined, output: EmitTextWriter): void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface EmitTextWriter {
|
|
83
|
+
getText(): string;
|
|
84
|
+
getTextPos(): number;
|
|
85
|
+
clear(): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param compilerOptions
|
|
90
|
+
* @param handlers
|
|
91
|
+
*/
|
|
92
|
+
export function unsafeGetUndocumentedPrinter(compilerOptions: ts.CompilerOptions, handlers?: ts.PrintHandlers): ReturnType<typeof ts.createPrinter> & UndocumentedPrinter;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import p from "typescript";
|
|
2
|
+
const n = p, u = n, o = 5, i = 1, s = 3, a = 4;
|
|
3
|
+
d(n.createSourceMapGenerator);
|
|
4
|
+
c(n.createTextWriter);
|
|
5
|
+
function d(e) {
|
|
6
|
+
if (typeof e != "function")
|
|
7
|
+
throw Error(
|
|
8
|
+
"Failed to find ts.createSourceMapGenerator() function. Lumina needs to be updated to support the new TypeScript version"
|
|
9
|
+
);
|
|
10
|
+
if (e.length !== o)
|
|
11
|
+
throw Error(
|
|
12
|
+
`ts.createSourceMapGenerator() signature changed. Expected ${o} arguments. Lumina needs to be updated to support the new TypeScript version`
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
function c(e) {
|
|
16
|
+
if (typeof e != "function")
|
|
17
|
+
throw Error(
|
|
18
|
+
"Failed to find ts.createTextWriter() function. Lumina needs to be updated to support the new TypeScript version"
|
|
19
|
+
);
|
|
20
|
+
if (e.length !== i)
|
|
21
|
+
throw Error(
|
|
22
|
+
`ts.createTextWriter() signature changed. Expected ${i} arguments. Lumina needs to be updated to support the new TypeScript version`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
function f(e) {
|
|
26
|
+
if (typeof e != "function")
|
|
27
|
+
throw Error(
|
|
28
|
+
"Failed to find ts.Printer.writeFile() function. Lumina needs to be updated to support the new TypeScript version"
|
|
29
|
+
);
|
|
30
|
+
if (e.length !== s)
|
|
31
|
+
throw Error(
|
|
32
|
+
`ts.Printer.writeFile() signature changed. Expected ${s} arguments. Lumina needs to be updated to support the new TypeScript version`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
function h(e) {
|
|
36
|
+
if (typeof e != "function")
|
|
37
|
+
throw Error(
|
|
38
|
+
"Failed to find ts.Printer.writeNode() function. Lumina needs to be updated to support the new TypeScript version"
|
|
39
|
+
);
|
|
40
|
+
if (e.length !== a)
|
|
41
|
+
throw Error(
|
|
42
|
+
`ts.Printer.writeNode() signature changed. Expected ${a} arguments. Lumina needs to be updated to support the new TypeScript version`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function m(e, t) {
|
|
46
|
+
const r = u.createPrinter(e, t);
|
|
47
|
+
return f(r.writeFile), h(r.writeNode), r;
|
|
48
|
+
}
|
|
49
|
+
function w(e, t) {
|
|
50
|
+
return e.getWidenedLiteralType(
|
|
51
|
+
t
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
w as getWidenedLiteralType,
|
|
56
|
+
m as unsafeGetUndocumentedPrinter,
|
|
57
|
+
u as unsafeUndocumentedTs
|
|
58
|
+
};
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import { ApiFunctionLike
|
|
2
|
-
|
|
1
|
+
import type { ApiFunctionLike } from "../apiJson.js";
|
|
2
|
+
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Double quote property name if it is not a valid identifier and not a symbol.
|
|
5
|
+
*
|
|
6
|
+
* @param name
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare function printInterface(
|
|
8
|
+
export function maybeEscapePropertyName(name: string): string;
|
|
9
|
+
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* Determine if property name needs to be quoted and have quotes and backslashes
|
|
12
|
+
* escaped.
|
|
13
|
+
*
|
|
14
|
+
* Permits the name to start with [ for computed property names. At present, only
|
|
15
|
+
* [Symbol.iterator]
|
|
16
|
+
*
|
|
17
|
+
* @param name
|
|
15
18
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
export function isPropertyEscapeNeeded(name: string): boolean;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Print a function or method signature.
|
|
23
|
+
*
|
|
24
|
+
* Consider refactoring out usages of this function in favor of rendering a
|
|
25
|
+
* table of parameters (with their description), and a return type section.
|
|
26
|
+
*
|
|
27
|
+
* @param functionLike
|
|
28
|
+
*/
|
|
29
|
+
export function printSignature(functionLike: Pick<ApiFunctionLike, "parameters" | "return" | "typeParameters">): string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
function p(t, r, i, e, n, o) {
|
|
2
|
+
return `${`${r ? "export default " : "export "}${t ? "abstract " : ""}`}class ${i}${f(e)}${n === void 0 ? "" : ` extends ${n}`} {${o}}`;
|
|
3
|
+
}
|
|
4
|
+
function f(t) {
|
|
5
|
+
if (t === void 0)
|
|
6
|
+
return "";
|
|
7
|
+
let r = "<";
|
|
8
|
+
for (let i = 0; i < t.length; ++i) {
|
|
9
|
+
const e = t[i];
|
|
10
|
+
e.const === !0 ? r += "const " : e.in === !0 ? r += "in " : e.out === !0 && (r += "out "), r += e.name, e.constraint !== void 0 && (r += ` extends ${e.constraint.text}`), e.default !== void 0 && (r += ` = ${e.default.text}`), i < t.length - 1 && (r += ", ");
|
|
11
|
+
}
|
|
12
|
+
return r += ">", r;
|
|
13
|
+
}
|
|
14
|
+
function x(t, r, i, e, n) {
|
|
15
|
+
const o = t ? "export default " : "export ";
|
|
16
|
+
let $ = "";
|
|
17
|
+
if (e !== void 0) {
|
|
18
|
+
$ = " extends ";
|
|
19
|
+
for (let c = 0; c < e.length; ++c)
|
|
20
|
+
$ += e[c], c < e.length - 1 && ($ += ", ");
|
|
21
|
+
}
|
|
22
|
+
return `${o}interface ${r}${f(i)}${$} {${n}}`;
|
|
23
|
+
}
|
|
24
|
+
function v(t, r, i, e, n, o, $, c) {
|
|
25
|
+
const s = `${t ? "protected " : ""}${r ? "abstract " : ""}${i ? "static " : ""}`, l = c === void 0 ? "" : `: ${c}`;
|
|
26
|
+
return `${s}${n === "" ? "" : d(n)}${e ? "?" : ""}${f(o)}(${u($)})${l};`;
|
|
27
|
+
}
|
|
28
|
+
function d(t) {
|
|
29
|
+
return a.test(t) || t.startsWith("[") ? t : `"${t.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
30
|
+
}
|
|
31
|
+
const g = (t) => !a.test(t) && !t.startsWith("["), a = /^[A-Za-z_$][A-Za-z0-9_$]*$/u;
|
|
32
|
+
function h(t, r, i, e, n) {
|
|
33
|
+
return `${t ? "export default " : "export "}function ${r}${f(i)}(${u(e)}): ${n};`;
|
|
34
|
+
}
|
|
35
|
+
function m(t) {
|
|
36
|
+
return `${f(t.typeParameters)}(${u(t.parameters)}): ${t.return.type.text}`;
|
|
37
|
+
}
|
|
38
|
+
function u(t) {
|
|
39
|
+
if (t === void 0)
|
|
40
|
+
return "";
|
|
41
|
+
let r = "";
|
|
42
|
+
for (let i = 0; i < t.length; ++i) {
|
|
43
|
+
const e = t[i];
|
|
44
|
+
e.rest === !0 && (r += "..."), r += e.name, (e.optional === !0 || e.default !== void 0) && (r += "?"), r += `: ${e.type.text}`, i < t.length - 1 && (r += ", ");
|
|
45
|
+
}
|
|
46
|
+
return r;
|
|
47
|
+
}
|
|
48
|
+
function b(t, r, i, e, n, o, $, c) {
|
|
49
|
+
return `${`${t ? "protected " : ""}${r ? "abstract " : i ? "static " : ""}${e ? "readonly " : n ? "accessor " : ""}`}${d($)}${o ? "?" : ""}: ${c};`;
|
|
50
|
+
}
|
|
51
|
+
function A(t, r, i, e, n, o) {
|
|
52
|
+
const $ = `${t ? "protected " : ""}${r ? "abstract " : ""}${i ? "static " : ""}`, c = d(e), s = o === void 0 ? "" : `
|
|
53
|
+
${$}set ${c}(value: ${o});`;
|
|
54
|
+
return `${$}get ${c}(): ${n};${s}`;
|
|
55
|
+
}
|
|
56
|
+
function P(t, r, i) {
|
|
57
|
+
const n = `${t ? "declare " : "export "}const ${r}: ${i};`;
|
|
58
|
+
return t ? `${n}
|
|
59
|
+
export default ${r};` : n;
|
|
60
|
+
}
|
|
61
|
+
function N(t, r, i, e) {
|
|
62
|
+
let n = `export type ${t}${f(r)} = `;
|
|
63
|
+
if (i !== void 0)
|
|
64
|
+
for (let o = 0; o < i.length; ++o)
|
|
65
|
+
n += i[o], (o < i.length - 1 || e !== void 0) && (n += `
|
|
66
|
+
& `);
|
|
67
|
+
return e !== void 0 && (n += e), n += ";", n;
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
g as isPropertyEscapeNeeded,
|
|
71
|
+
d as maybeEscapePropertyName,
|
|
72
|
+
p as printClass,
|
|
73
|
+
h as printFunction,
|
|
74
|
+
A as printGetterSetter,
|
|
75
|
+
x as printInterface,
|
|
76
|
+
v as printMethod,
|
|
77
|
+
b as printProperty,
|
|
78
|
+
m as printSignature,
|
|
79
|
+
N as printTypeAlias,
|
|
80
|
+
f as printTypeParameters,
|
|
81
|
+
P as printVariable
|
|
82
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type { ApiExtractorConfig } from "../extractor/config.js";
|
|
3
|
+
import type { ApiExtractor } from "../extractor/ApiExtractor.js";
|
|
4
|
+
|
|
5
|
+
/** The non-readonly properties can be modified up till Vite's configResolved hook. */
|
|
6
|
+
export interface ApiExtractorPluginConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the API Extractor config file to use.
|
|
9
|
+
* Pass empty string to disable config loading.
|
|
10
|
+
*
|
|
11
|
+
* @default "api-extractor.config.ts"
|
|
12
|
+
*/
|
|
13
|
+
configFilePath?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Override the config file. This option is discouraged - specify the options
|
|
16
|
+
* in the config file as much as possible. The config file is read by ESLint
|
|
17
|
+
* rules, Astro docs generator, and other tools. For consistent results, use
|
|
18
|
+
* the same settings everywhere.
|
|
19
|
+
*
|
|
20
|
+
* It is safe to use this for setting .afterCreate() hook as long as you don't
|
|
21
|
+
* mutate the api.json in it.
|
|
22
|
+
*/
|
|
23
|
+
unsafeConfigOverride?: ApiExtractorConfig;
|
|
24
|
+
serve?: ApiExtractorPluginServeConfig;
|
|
25
|
+
/**
|
|
26
|
+
* A callback for after ApiExtractor instance is created, but before it is
|
|
27
|
+
* used for any extraction.
|
|
28
|
+
*
|
|
29
|
+
* @param extractor
|
|
30
|
+
*/
|
|
31
|
+
afterExtractorCreated?(extractor: ApiExtractor): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ApiExtractorPluginServeConfig {
|
|
35
|
+
/**
|
|
36
|
+
* Whether to run the extractor in the Vite dev server. By default, extractor
|
|
37
|
+
* only runs during build.
|
|
38
|
+
*
|
|
39
|
+
* If running during server, ensure your ApiExtractorConfig settings are
|
|
40
|
+
* serve-appropriate (like fullTypeCheck, whether dtsEmitPath is set, etc).
|
|
41
|
+
*
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
extract?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A vite plugin that runs both type checking and api-extractor.
|
|
49
|
+
* Supports dev server, build, and build watch modes.
|
|
50
|
+
*
|
|
51
|
+
* @param pluginConfig
|
|
52
|
+
*/
|
|
53
|
+
export function useApiExtractor(pluginConfig?: ApiExtractorPluginConfig): Plugin;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { l as T, m as J } from "../worker-CULPfolw.js";
|
|
2
|
+
import { A as b, w as S } from "../ApiExtractor-BwOcUvPV.js";
|
|
3
|
+
import { p as k, l as A } from "../typeScript-CzUTFiYO.js";
|
|
4
|
+
import { writeFile as C } from "node:fs/promises";
|
|
5
|
+
import { path as w } from "@arcgis/components-build-utils";
|
|
6
|
+
const M = k.name;
|
|
7
|
+
function V(s = {}) {
|
|
8
|
+
let t = !1, h = !1, e, i, c, l, E = !0, v = !1, f, m, u, y, p;
|
|
9
|
+
async function x(d, r) {
|
|
10
|
+
if (r.dtsFiles !== void 0 && u !== "") {
|
|
11
|
+
const g = w.join(w.resolve(p, u), "/");
|
|
12
|
+
await S(g, !1, d.changedDtsFiles ?? r.dtsFiles);
|
|
13
|
+
}
|
|
14
|
+
y !== "" && await C(
|
|
15
|
+
y,
|
|
16
|
+
d.config.context.environment === "production" ? JSON.stringify(r.apiJson) : JSON.stringify(r.apiJson, null, 2)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
name: M,
|
|
21
|
+
async configResolved(d) {
|
|
22
|
+
if (e = d, t = e.command === "build", !t && s.serve?.extract !== !0)
|
|
23
|
+
return;
|
|
24
|
+
h = (t ? e.build.watch : e.server.watch) !== null, p = e.configFile === void 0 ? e.root : w.dirname(e.configFile);
|
|
25
|
+
const r = {
|
|
26
|
+
context: {
|
|
27
|
+
// Handled by Vite
|
|
28
|
+
emptyDtsEmitPath: !1,
|
|
29
|
+
environment: e.mode === "production" ? "production" : "development",
|
|
30
|
+
cwd: p
|
|
31
|
+
},
|
|
32
|
+
types: {
|
|
33
|
+
// It is desirable to type-check as part of build. Thus, we can do
|
|
34
|
+
// typed extraction essentially for free.
|
|
35
|
+
typeCheckedExtraction: !0,
|
|
36
|
+
fullTypeCheck: t,
|
|
37
|
+
afterDiagnostic(o) {
|
|
38
|
+
if (o.length > 0 && !h) {
|
|
39
|
+
const W = new Error("TypeScript errors reported. See error messages above");
|
|
40
|
+
throw W.stack = "", W;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
watch: {
|
|
45
|
+
// Don't clear by default if running inside Vite. Reasons:
|
|
46
|
+
// Vanilla `vite build --watch` doesn't clear screen on rebuild.
|
|
47
|
+
// If we clear the screen, we may interfere with another plugin that
|
|
48
|
+
// does its own logging or clearing. Let user explicitly enable this
|
|
49
|
+
// if desired.
|
|
50
|
+
clearScreen: !1,
|
|
51
|
+
skipWritingUnchanged: d.build.emptyOutDir === !1,
|
|
52
|
+
onUpdate(o) {
|
|
53
|
+
f = o.then((n) => (c = n ?? c, f = void 0, clearTimeout(m), t && !v && n !== void 0 && (n.changedModules.length > 0 || n.removedModules.length > 0) && (m = setTimeout(() => {
|
|
54
|
+
x(i, n);
|
|
55
|
+
}, 250)), n));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, g = s.configFilePath === "" ? void 0 : await T(p, s.configFilePath), P = s.unsafeConfigOverride ?? {}, F = g === void 0 ? r : J(r, g), a = P === void 0 ? F : J(F, P);
|
|
59
|
+
u = t ? a.context?.dtsEmitPath ?? e.build.outDir : "", y = t ? a.context?.apiJsonEmitPath ?? "" : "";
|
|
60
|
+
const D = a.context?.logger ?? e.logger ?? console, B = {
|
|
61
|
+
...a,
|
|
62
|
+
context: {
|
|
63
|
+
...a.context,
|
|
64
|
+
dtsEmitPath: "",
|
|
65
|
+
apiJsonEmitPath: "",
|
|
66
|
+
logger: {
|
|
67
|
+
info(o) {
|
|
68
|
+
!t || o.startsWith(`${A}Wrote `) || D.info(o);
|
|
69
|
+
},
|
|
70
|
+
error(o) {
|
|
71
|
+
D.error(o);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
types: {
|
|
76
|
+
...a.types,
|
|
77
|
+
forceProduceDts: a.types?.forceProduceDts === !0 || u !== ""
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
i = new b(B), s.afterExtractorCreated?.(i);
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* TypeScript reads files directly from the file system - Vite's
|
|
84
|
+
* transform hooks have no impact. So we might as well start extraction
|
|
85
|
+
* early to give other plugins access to api.json sooner.
|
|
86
|
+
* This is TypeScript's default behavior, and it ensures our build errors
|
|
87
|
+
* match what "npx tsc" would report.
|
|
88
|
+
*/
|
|
89
|
+
async buildStart() {
|
|
90
|
+
v = !0, clearTimeout(m), !(i === void 0 || !E) && (E = !1, h ? l = await i.watch() : c = await i.run());
|
|
91
|
+
},
|
|
92
|
+
async writeBundle() {
|
|
93
|
+
clearTimeout(m), f !== void 0 && await f, i !== void 0 && c !== void 0 && await x(i, c), v = !1;
|
|
94
|
+
},
|
|
95
|
+
// Fires if dev server is closed programmatically. Ctrl+C is handled by Node
|
|
96
|
+
async closeBundle() {
|
|
97
|
+
!t && l !== void 0 && await l.close();
|
|
98
|
+
},
|
|
99
|
+
// Fires if build watch is closed programmatically. Ctrl+C is handled by Node
|
|
100
|
+
async closeWatcher() {
|
|
101
|
+
l !== void 0 && await l.close();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
V as useApiExtractor
|
|
107
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type ts from "typescript";
|
|
2
|
+
|
|
3
|
+
export interface TypeScriptConfigResult {
|
|
4
|
+
/** Absolute path to the resolved tsconfig.json file. */
|
|
5
|
+
configPath: string;
|
|
6
|
+
config: ts.ParsedCommandLine;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param cwd - Defaults to process.cwd()
|
|
11
|
+
* @param configPath - Optional absolute or relative path to a tsconfig.json file.
|
|
12
|
+
* @param resolveIncludedFiles - If true, will resolve tsconfig's include, exclude,
|
|
13
|
+
* and files globs. Resolved files can be accessed via
|
|
14
|
+
* TypeScriptConfigResult.config.fileNames.
|
|
15
|
+
*/
|
|
16
|
+
export function loadTypeScriptConfig(cwd: string | undefined, configPath: string | undefined, resolveIncludedFiles: boolean): TypeScriptConfigResult;
|