@xyd-js/sources 0.0.0-build
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/CHANGELOG.md +9 -0
- package/ISSUES.md +10 -0
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/TODO.md +9 -0
- package/__fixtures__/-1.typescript/package.json +5 -0
- package/__fixtures__/-1.typescript/src/index.ts +0 -0
- package/__fixtures__/-1.typescript/src/settings.ts +592 -0
- package/__fixtures__/-1.typescript/tsconfig.json +8 -0
- package/__fixtures__/-2.react.basic/1.flat-interface.output.json +114 -0
- package/__fixtures__/-2.react.basic/2.file-connect-interface.output.json +60 -0
- package/__fixtures__/-2.react.basic/2a.file-connect-interface-advanced.output.json +92 -0
- package/__fixtures__/-2.react.basic/3.props-as-variants.output.json +166 -0
- package/__fixtures__/-2.react.basic/4.outside-interface.output.json +60 -0
- package/__fixtures__/-2.react.basic/5.inline-props.output.json +60 -0
- package/__fixtures__/-2.react.basic/5.outside-inline-props.output.json +60 -0
- package/__fixtures__/-2.react.basic/5a.inline-props+outside.output.json +60 -0
- package/__fixtures__/-2.react.basic/5b.inline-props+interfaces.output.json +92 -0
- package/__fixtures__/-2.react.basic/package.json +4 -0
- package/__fixtures__/-2.react.basic/src/1.flat-interface.tsx +41 -0
- package/__fixtures__/-2.react.basic/src/2.file-connect-interface.tsx +28 -0
- package/__fixtures__/-2.react.basic/src/2a.file-connect-interace+advanced.tsx +54 -0
- package/__fixtures__/-2.react.basic/src/3.props-as-variants.tsx +67 -0
- package/__fixtures__/-2.react.basic/src/4.outside-interface.tsx +13 -0
- package/__fixtures__/-2.react.basic/src/4.outside-interface2.ts +15 -0
- package/__fixtures__/-2.react.basic/src/5.inline-props.tsx +19 -0
- package/__fixtures__/-2.react.basic/src/5a.inline-props+outside.tsx +19 -0
- package/__fixtures__/-2.react.basic/src/5b.inline-props+interfaces.tsx +62 -0
- package/__fixtures__/-2.react.basic/src/index.ts +0 -0
- package/__fixtures__/-2.react.basic/tsconfig.json +8 -0
- package/__tests__/sourcesToUniform.test.ts +167 -0
- package/__tests__/testResolvePropertySymbol.ts +838 -0
- package/__tests__/types.ts +12 -0
- package/__tests__/utils.ts +108 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +237 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +6 -0
- package/dist/react.d.ts +6 -0
- package/dist/react.js +212 -0
- package/dist/react.js.map +1 -0
- package/dist/ts.cjs +1794 -0
- package/dist/ts.cjs.map +1 -0
- package/dist/ts.d.cts +14 -0
- package/dist/ts.d.ts +14 -0
- package/dist/ts.js +1760 -0
- package/dist/ts.js.map +1 -0
- package/package.json +41 -0
- package/packages/react/index.ts +1 -0
- package/packages/react/uniformToReactUniform.ts +275 -0
- package/packages/ts/SignatureText.ts +233 -0
- package/packages/ts/TypeDocTransformer.ts +1519 -0
- package/packages/ts/__fixtures__/packages/package-a/package.json +4 -0
- package/packages/ts/__fixtures__/packages/package-a/src/index.ts +56 -0
- package/packages/ts/__fixtures__/packages/package-a/tsconfig.json +23 -0
- package/packages/ts/__fixtures__/packages/package-b/package.json +7 -0
- package/packages/ts/__fixtures__/packages/package-b/src/billing.ts +193 -0
- package/packages/ts/__fixtures__/packages/package-b/src/index.ts +8 -0
- package/packages/ts/__fixtures__/packages/package-b/tsconfig.json +20 -0
- package/packages/ts/__fixtures__/packages2/package-a/package.json +4 -0
- package/packages/ts/__fixtures__/packages2/package-a/src/index.ts +496 -0
- package/packages/ts/__fixtures__/packages2/package-a/tsconfig.json +6 -0
- package/packages/ts/__fixtures__/packages3/package-a/package.json +4 -0
- package/packages/ts/__fixtures__/packages3/package-a/src/index.ts +488 -0
- package/packages/ts/__fixtures__/packages3/package-a/tsconfig.json +6 -0
- package/packages/ts/__fixtures__/packages3/project.json +171 -0
- package/packages/ts/__fixtures__/react/react-a/package.json +5 -0
- package/packages/ts/__fixtures__/react/react-a/src/TestAbc.tsx +90 -0
- package/packages/ts/__fixtures__/react/react-a/src/TestBasic.tsx +27 -0
- package/packages/ts/__fixtures__/react/react-a/src/TestNamedParameters.tsx +27 -0
- package/packages/ts/__fixtures__/react/react-a/src/TestNamedParameters2.tsx +26 -0
- package/packages/ts/__fixtures__/react/react-a/src/TestUnion.tsx +32 -0
- package/packages/ts/__fixtures__/react/react-a/src/index.ts +1 -0
- package/packages/ts/__fixtures__/react/react-a/tsconfig.json +8 -0
- package/packages/ts/__fixtures__/references-output-project.json +344 -0
- package/packages/ts/__fixtures__/references-output-react.json +68 -0
- package/packages/ts/__fixtures__/references-output.json +129 -0
- package/packages/ts/__tests__/sourcesToUniform.test.ts +106 -0
- package/packages/ts/context.ts +0 -0
- package/packages/ts/converterts/ts-class.ts +0 -0
- package/packages/ts/converterts/ts-enum.ts +0 -0
- package/packages/ts/converterts/ts-function.ts +0 -0
- package/packages/ts/converterts/ts-interface.ts +0 -0
- package/packages/ts/converterts/ts-type.ts +0 -0
- package/packages/ts/index.ts +129 -0
- package/packages/ts/ts-core.ts +0 -0
- package/packages/ts/uniformToMiniUniform.ts +486 -0
- package/src/index.ts +0 -0
- package/test-cmd/index.ts +62 -0
- package/tsconfig.json +38 -0
- package/tsup.config.ts +39 -0
- package/vitest.config.ts +34 -0
package/dist/ts.cjs
ADDED
|
@@ -0,0 +1,1794 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/ts/index.ts
|
|
31
|
+
var ts_exports = {};
|
|
32
|
+
__export(ts_exports, {
|
|
33
|
+
sourcesToUniformV2: () => sourcesToUniformV2,
|
|
34
|
+
uniformToMiniUniform: () => uniformToMiniUniform
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(ts_exports);
|
|
37
|
+
var path2 = __toESM(require("path"), 1);
|
|
38
|
+
var import_path = require("path");
|
|
39
|
+
var import_typescript = __toESM(require("typescript"), 1);
|
|
40
|
+
var TypeDoc = __toESM(require("typedoc"), 1);
|
|
41
|
+
|
|
42
|
+
// packages/ts/TypeDocTransformer.ts
|
|
43
|
+
var fs2 = __toESM(require("fs"), 1);
|
|
44
|
+
var path = __toESM(require("path"), 1);
|
|
45
|
+
var import_typedoc = require("typedoc");
|
|
46
|
+
var import_uniform = require("@xyd-js/uniform");
|
|
47
|
+
|
|
48
|
+
// packages/ts/SignatureText.ts
|
|
49
|
+
var ts = __toESM(require("typescript"), 1);
|
|
50
|
+
var fs = __toESM(require("fs"), 1);
|
|
51
|
+
var printer = ts.createPrinter({ removeComments: true });
|
|
52
|
+
var SignatureTextLoader = class {
|
|
53
|
+
constructor(sourcePath) {
|
|
54
|
+
const source = fs.readFileSync(sourcePath, "utf-8");
|
|
55
|
+
this.sourceFile = ts.createSourceFile(
|
|
56
|
+
sourcePath,
|
|
57
|
+
source,
|
|
58
|
+
ts.ScriptTarget.Latest,
|
|
59
|
+
true
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var MultiSignatureLoader = class {
|
|
64
|
+
constructor() {
|
|
65
|
+
this.loaders = /* @__PURE__ */ new Map();
|
|
66
|
+
}
|
|
67
|
+
load(path3) {
|
|
68
|
+
if (this.loaders.has(path3)) {
|
|
69
|
+
return this.loaders.get(path3);
|
|
70
|
+
}
|
|
71
|
+
const loader = new SignatureTextLoader(path3);
|
|
72
|
+
this.loaders.set(path3, loader);
|
|
73
|
+
return loader;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
function signatureTextByLine(sign, targetLine, options) {
|
|
77
|
+
return signatureText.call(sign, targetLine, options);
|
|
78
|
+
}
|
|
79
|
+
function signatureSourceCodeByLine(sign, targetLine) {
|
|
80
|
+
return signatureSourceCode.call(sign, targetLine);
|
|
81
|
+
}
|
|
82
|
+
function signatureText(targetLine, options) {
|
|
83
|
+
const sourceFile = this.sourceFile;
|
|
84
|
+
const signatureNode = findSignatureNode.call(
|
|
85
|
+
this,
|
|
86
|
+
sourceFile,
|
|
87
|
+
[targetLine]
|
|
88
|
+
);
|
|
89
|
+
if (!signatureNode) {
|
|
90
|
+
console.error("(signatureText): `signatureNode` is empty, something went wrong");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const printableSignatureNode = nodeToPrintableSignatureNode(signatureNode, options == null ? void 0 : options.typeOnly);
|
|
94
|
+
if (!printableSignatureNode) {
|
|
95
|
+
console.error("(signatureText): cannot convert `signatureNode` to `printableSignatureNode`");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
return printer.printNode(ts.EmitHint.Unspecified, printableSignatureNode, sourceFile).trim();
|
|
99
|
+
}
|
|
100
|
+
function findSignatureNode(node, targetLines) {
|
|
101
|
+
let isSourceFile = false;
|
|
102
|
+
if (node === node.getSourceFile()) {
|
|
103
|
+
isSourceFile = true;
|
|
104
|
+
}
|
|
105
|
+
if (!isSourceFile && isNodeAtLine(node, targetLines, this.sourceFile)) {
|
|
106
|
+
return node;
|
|
107
|
+
}
|
|
108
|
+
let signatureNode;
|
|
109
|
+
ts.forEachChild(node, (n) => {
|
|
110
|
+
if (signatureNode) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
signatureNode = findSignatureNode.call(this, n, targetLines);
|
|
114
|
+
});
|
|
115
|
+
return signatureNode;
|
|
116
|
+
}
|
|
117
|
+
function signatureSourceCode(targetLine) {
|
|
118
|
+
const sourceFile = this.sourceFile;
|
|
119
|
+
const signatureNode = findSignatureNode.call(
|
|
120
|
+
this,
|
|
121
|
+
sourceFile,
|
|
122
|
+
[targetLine]
|
|
123
|
+
);
|
|
124
|
+
if (!signatureNode) {
|
|
125
|
+
console.error("(signatureSourceCode): `signatureNode` is empty, something went wrong");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const start = signatureNode.getStart(sourceFile);
|
|
129
|
+
const end = signatureNode.getEnd();
|
|
130
|
+
return sourceFile.text.substring(start, end).trim();
|
|
131
|
+
}
|
|
132
|
+
function nodeToPrintableSignatureNode(node, typeOnly = false) {
|
|
133
|
+
if (typeOnly) {
|
|
134
|
+
if ("type" in node) {
|
|
135
|
+
return node.type;
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
let resp;
|
|
140
|
+
if (ts.isFunctionDeclaration(node)) {
|
|
141
|
+
resp = ts.factory.updateFunctionDeclaration(
|
|
142
|
+
node,
|
|
143
|
+
node.modifiers,
|
|
144
|
+
node.asteriskToken,
|
|
145
|
+
node.name,
|
|
146
|
+
node.typeParameters,
|
|
147
|
+
node.parameters,
|
|
148
|
+
node.type,
|
|
149
|
+
void 0
|
|
150
|
+
);
|
|
151
|
+
} else if (ts.isClassDeclaration(node)) {
|
|
152
|
+
resp = ts.factory.updateClassDeclaration(
|
|
153
|
+
node,
|
|
154
|
+
node.modifiers,
|
|
155
|
+
node.name,
|
|
156
|
+
node.typeParameters,
|
|
157
|
+
node.heritageClauses,
|
|
158
|
+
[]
|
|
159
|
+
);
|
|
160
|
+
} else if (ts.isInterfaceDeclaration(node)) {
|
|
161
|
+
resp = ts.factory.updateInterfaceDeclaration(
|
|
162
|
+
node,
|
|
163
|
+
node.modifiers,
|
|
164
|
+
node.name,
|
|
165
|
+
node.typeParameters,
|
|
166
|
+
node.heritageClauses,
|
|
167
|
+
[]
|
|
168
|
+
);
|
|
169
|
+
} else if (ts.isEnumDeclaration(node)) {
|
|
170
|
+
resp = ts.factory.updateEnumDeclaration(
|
|
171
|
+
node,
|
|
172
|
+
node.modifiers,
|
|
173
|
+
node.name,
|
|
174
|
+
[]
|
|
175
|
+
);
|
|
176
|
+
} else if (ts.isTypeAliasDeclaration(node)) {
|
|
177
|
+
resp = ts.factory.updateTypeAliasDeclaration(
|
|
178
|
+
node,
|
|
179
|
+
node.modifiers,
|
|
180
|
+
node.name,
|
|
181
|
+
node.typeParameters,
|
|
182
|
+
node.type
|
|
183
|
+
);
|
|
184
|
+
} else if (ts.isPropertySignature(node)) {
|
|
185
|
+
resp = ts.factory.updatePropertySignature(
|
|
186
|
+
node,
|
|
187
|
+
node.modifiers,
|
|
188
|
+
node.name,
|
|
189
|
+
node.questionToken,
|
|
190
|
+
node.type
|
|
191
|
+
);
|
|
192
|
+
} else {
|
|
193
|
+
resp = node;
|
|
194
|
+
}
|
|
195
|
+
if (!resp) {
|
|
196
|
+
console.error("(nodeToPrintableSignatureNode): resp is empty, something went wrong");
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
return resp;
|
|
200
|
+
}
|
|
201
|
+
function isNodeAtLine(node, lines, sf) {
|
|
202
|
+
const { line: startLine } = sf.getLineAndCharacterOfPosition(node.getStart());
|
|
203
|
+
return lines.includes(startLine + 1);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// packages/ts/TypeDocTransformer.ts
|
|
207
|
+
var TypeDocSignatureTextLoader = class extends MultiSignatureLoader {
|
|
208
|
+
constructor(project, packagePathMap) {
|
|
209
|
+
super();
|
|
210
|
+
this.project = project;
|
|
211
|
+
this.packagePathMap = packagePathMap;
|
|
212
|
+
}
|
|
213
|
+
signatureText(id, line, options) {
|
|
214
|
+
const loader = this.getSignatuerLoader(id);
|
|
215
|
+
if (!loader) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const signTxt = signatureTextByLine(loader, line, options);
|
|
219
|
+
if (!signTxt) {
|
|
220
|
+
console.warn("(TypeDocSignatureTextLoader.signatureText): Signature text is empty", id);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
return signTxt;
|
|
224
|
+
}
|
|
225
|
+
signatureSourceCode(id, line) {
|
|
226
|
+
const loader = this.getSignatuerLoader(id);
|
|
227
|
+
if (!loader) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const sourceCode = signatureSourceCodeByLine(loader, line);
|
|
231
|
+
if (!sourceCode) {
|
|
232
|
+
console.warn("(TypeDocSignatureTextLoader.signatureSourceCode): Source code is empty", id);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
return sourceCode;
|
|
236
|
+
}
|
|
237
|
+
getSignatuerLoader(id) {
|
|
238
|
+
const symbolMap = this.project.symbolIdMap[id];
|
|
239
|
+
if (!symbolMap) {
|
|
240
|
+
console.warn("(TypeDocSignatureTextLoader.getSignatuerLoader): Symbol not found", id);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const fullPath = this.packagePathMap[id];
|
|
244
|
+
if (!fullPath) {
|
|
245
|
+
console.warn("(TypeDocSignatureTextLoader.getSignatuerLoader): Package path not found for symbol", symbolMap.packageName);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const loader = this.load(fullPath);
|
|
249
|
+
if (!loader) {
|
|
250
|
+
console.warn("(TypeDocSignatureTextLoader.getSignatuerLoader): Loader not found", fullPath);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
return loader;
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
var Transformer = class {
|
|
257
|
+
constructor(rootPath, project, references = []) {
|
|
258
|
+
this.rootPath = rootPath;
|
|
259
|
+
this.project = project;
|
|
260
|
+
this.references = references;
|
|
261
|
+
this.packagePathMap = {};
|
|
262
|
+
const packagePathMap = this.createPackagePathMap();
|
|
263
|
+
if (packagePathMap) {
|
|
264
|
+
this.packagePathMap = packagePathMap;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
createPackagePathMap() {
|
|
268
|
+
const packagePathMap = {};
|
|
269
|
+
const packageJsonPaths = this.findPackageJsonPaths(this.rootPath);
|
|
270
|
+
if (!packageJsonPaths.length) {
|
|
271
|
+
console.warn("(Transformer.createPackagePathMap): No package.json found in rootPath", this.rootPath);
|
|
272
|
+
return { packageMap: null, moduleRootMap: null };
|
|
273
|
+
}
|
|
274
|
+
for (const packageJsonPath of packageJsonPaths) {
|
|
275
|
+
const packageJson = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
|
|
276
|
+
const packageName = packageJson.name;
|
|
277
|
+
const moduleRoot = path.dirname(packageJsonPath);
|
|
278
|
+
if (!packageName) {
|
|
279
|
+
console.warn("(Transformer.createPackagePathMap): Package name not found in package.json", packageJsonPath);
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
for (const id in this.project.symbolIdMap) {
|
|
283
|
+
const symbolMap = this.project.symbolIdMap[id];
|
|
284
|
+
if (symbolMap.packageName === packageName) {
|
|
285
|
+
const fullPath = path.join(moduleRoot, symbolMap.packagePath);
|
|
286
|
+
packagePathMap[Number.parseInt(id)] = fullPath;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return packagePathMap;
|
|
291
|
+
}
|
|
292
|
+
findPackageJsonPaths(dir) {
|
|
293
|
+
let results = [];
|
|
294
|
+
const list = fs2.readdirSync(dir);
|
|
295
|
+
for (const file of list) {
|
|
296
|
+
const filePath = path.join(dir, file);
|
|
297
|
+
const stat = fs2.statSync(filePath);
|
|
298
|
+
if (stat && stat.isDirectory()) {
|
|
299
|
+
if (file === "node_modules") {
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
results = results.concat(this.findPackageJsonPaths(filePath));
|
|
303
|
+
} else if (file === "package.json") {
|
|
304
|
+
results.push(filePath);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return results;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
function typedocToUniform(rootPath, project) {
|
|
311
|
+
const references = [];
|
|
312
|
+
const transformer = new Transformer(
|
|
313
|
+
rootPath,
|
|
314
|
+
project,
|
|
315
|
+
references
|
|
316
|
+
);
|
|
317
|
+
const signatureTextLoader = new TypeDocSignatureTextLoader(
|
|
318
|
+
project,
|
|
319
|
+
transformer.packagePathMap
|
|
320
|
+
);
|
|
321
|
+
transformer.signatureTextLoader = signatureTextLoader;
|
|
322
|
+
if (project.kind !== import_typedoc.ReflectionKind.Project) {
|
|
323
|
+
throw new Error("Project reflection expected");
|
|
324
|
+
}
|
|
325
|
+
for (const child of project.children || []) {
|
|
326
|
+
if (!("kind" in child)) {
|
|
327
|
+
throw new Error("(typedocToUniform): Child reflection expected in project childrens");
|
|
328
|
+
}
|
|
329
|
+
if (typeof child.kind != "number") {
|
|
330
|
+
throw new Error("(typedocToUniform): Child reflection kind expected to be a number");
|
|
331
|
+
}
|
|
332
|
+
if (!child.kind) {
|
|
333
|
+
throw new Error("(typedocToUniform): Child reflection kind expected to be a valid ReflectionKind");
|
|
334
|
+
}
|
|
335
|
+
const kind = child.kind;
|
|
336
|
+
switch (kind) {
|
|
337
|
+
case import_typedoc.ReflectionKind.Module: {
|
|
338
|
+
const container = child;
|
|
339
|
+
for (const group of container.children || []) {
|
|
340
|
+
const ref = typedocGroupToUniform.call(
|
|
341
|
+
transformer,
|
|
342
|
+
group
|
|
343
|
+
);
|
|
344
|
+
if (!ref) {
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
ref.context = {
|
|
348
|
+
...ref.context,
|
|
349
|
+
packageName: container.name
|
|
350
|
+
};
|
|
351
|
+
references.push(ref);
|
|
352
|
+
}
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
case import_typedoc.ReflectionKind.Function:
|
|
356
|
+
case import_typedoc.ReflectionKind.Class:
|
|
357
|
+
case import_typedoc.ReflectionKind.Interface: {
|
|
358
|
+
if (!("kind" in child) || child.kind !== import_typedoc.ReflectionKind.Function && child.kind !== import_typedoc.ReflectionKind.Class && child.kind !== import_typedoc.ReflectionKind.Interface) {
|
|
359
|
+
throw new Error("(typedocToUniform): Function/Class/Interface reflection expected to be a DeclarationReflection");
|
|
360
|
+
}
|
|
361
|
+
const ref = typedocGroupToUniform.call(
|
|
362
|
+
transformer,
|
|
363
|
+
child
|
|
364
|
+
);
|
|
365
|
+
if (!ref) {
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
ref.context = {
|
|
369
|
+
...ref.context,
|
|
370
|
+
packageName: project.name
|
|
371
|
+
};
|
|
372
|
+
references.push(ref);
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
case import_typedoc.ReflectionKind.TypeAlias: {
|
|
376
|
+
if (!("kind" in child) || child.kind !== import_typedoc.ReflectionKind.TypeAlias) {
|
|
377
|
+
throw new Error("(typedocToUniform): Type alias reflection expected to be a DeclarationReflection");
|
|
378
|
+
}
|
|
379
|
+
const ref = jsTypeAliasToUniformRef.call(
|
|
380
|
+
transformer,
|
|
381
|
+
child
|
|
382
|
+
);
|
|
383
|
+
if (!ref) {
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
ref.context = {
|
|
387
|
+
...ref.context,
|
|
388
|
+
packageName: project.name
|
|
389
|
+
};
|
|
390
|
+
references.push(ref);
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
case import_typedoc.ReflectionKind.Enum: {
|
|
394
|
+
if (!("kind" in child) || child.kind !== import_typedoc.ReflectionKind.Enum) {
|
|
395
|
+
throw new Error("(typedocToUniform): Enum reflection expected to be a DeclarationReflection");
|
|
396
|
+
}
|
|
397
|
+
const ref = jsEnumToUniformRef.call(
|
|
398
|
+
transformer,
|
|
399
|
+
child
|
|
400
|
+
);
|
|
401
|
+
if (!ref) {
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
ref.context = {
|
|
405
|
+
...ref.context,
|
|
406
|
+
packageName: project.name
|
|
407
|
+
};
|
|
408
|
+
references.push(ref);
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
default: {
|
|
412
|
+
console.warn("(typedocToUniform): Another children project kind not supported", child.kind);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
references.sort((a, b) => {
|
|
417
|
+
const contextA = a.context;
|
|
418
|
+
const contextB = b.context;
|
|
419
|
+
const filePathA = (contextA == null ? void 0 : contextA.fileFullPath) || "";
|
|
420
|
+
const filePathB = (contextB == null ? void 0 : contextB.fileFullPath) || "";
|
|
421
|
+
if (filePathA !== filePathB) {
|
|
422
|
+
return filePathA.localeCompare(filePathB);
|
|
423
|
+
}
|
|
424
|
+
const lineA = (contextA == null ? void 0 : contextA.line) || 0;
|
|
425
|
+
const lineB = (contextB == null ? void 0 : contextB.line) || 0;
|
|
426
|
+
return lineA - lineB;
|
|
427
|
+
});
|
|
428
|
+
return references;
|
|
429
|
+
}
|
|
430
|
+
function typedocGroupToUniform(group) {
|
|
431
|
+
let ref;
|
|
432
|
+
switch (group.kind) {
|
|
433
|
+
case import_typedoc.ReflectionKind.Class: {
|
|
434
|
+
ref = jsClassToUniformRef.call(this, group);
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
case import_typedoc.ReflectionKind.Function: {
|
|
438
|
+
ref = jsFunctionToUniformRef.call(this, group);
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
case import_typedoc.ReflectionKind.Interface: {
|
|
442
|
+
ref = jsInterfaceToUniformRef.call(this, group);
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
case import_typedoc.ReflectionKind.Enum: {
|
|
446
|
+
ref = jsEnumToUniformRef.call(this, group);
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
case import_typedoc.ReflectionKind.TypeAlias: {
|
|
450
|
+
ref = jsTypeAliasToUniformRef.call(this, group);
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
default: {
|
|
454
|
+
console.warn("(typedocGroupToUniform): Unhandled reflection kind", group.kind);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return ref;
|
|
458
|
+
}
|
|
459
|
+
function jsClassToUniformRef(dec) {
|
|
460
|
+
var _a, _b, _c, _d;
|
|
461
|
+
const definitions = [];
|
|
462
|
+
const ref = {
|
|
463
|
+
title: `Class ${dec.name}`,
|
|
464
|
+
canonical: "",
|
|
465
|
+
description: "",
|
|
466
|
+
context: void 0,
|
|
467
|
+
examples: {
|
|
468
|
+
groups: []
|
|
469
|
+
},
|
|
470
|
+
definitions
|
|
471
|
+
};
|
|
472
|
+
const declarationCtx = declarationUniformContext.call(this, dec);
|
|
473
|
+
if (declarationCtx) {
|
|
474
|
+
ref.context = {
|
|
475
|
+
...ref.context,
|
|
476
|
+
...declarationCtx
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
ref.canonical = uniformCanonical(dec, declarationCtx);
|
|
480
|
+
if (dec.comment) {
|
|
481
|
+
const description = commentToUniformDescription(dec.comment);
|
|
482
|
+
const group = uniformGroup(declarationCtx);
|
|
483
|
+
if (ref.context) {
|
|
484
|
+
ref.context.group = [
|
|
485
|
+
...group,
|
|
486
|
+
"Classes"
|
|
487
|
+
];
|
|
488
|
+
}
|
|
489
|
+
ref.description = description;
|
|
490
|
+
}
|
|
491
|
+
{
|
|
492
|
+
const constructor = (_a = dec.children) == null ? void 0 : _a.find((child) => child.name === "constructor");
|
|
493
|
+
if ((_b = constructor == null ? void 0 : constructor.signatures) == null ? void 0 : _b[0]) {
|
|
494
|
+
const constructorDef = {
|
|
495
|
+
title: "Constructor",
|
|
496
|
+
properties: []
|
|
497
|
+
};
|
|
498
|
+
const constructorSign = constructor.signatures[0];
|
|
499
|
+
for (const param of constructorSign.parameters || []) {
|
|
500
|
+
if (!param.type) {
|
|
501
|
+
console.warn("(jsClassToUniformRef): Constructor parameter type not found", param.name);
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
let description = "";
|
|
505
|
+
if (param.comment) {
|
|
506
|
+
description = commentToUniformDescription(param.comment);
|
|
507
|
+
}
|
|
508
|
+
let uniformType = someTypeToUniform.call(this, param.type);
|
|
509
|
+
let someTypeProps = {};
|
|
510
|
+
if (typeof uniformType === "object") {
|
|
511
|
+
delete uniformType.ofType;
|
|
512
|
+
someTypeProps = uniformType;
|
|
513
|
+
}
|
|
514
|
+
constructorDef.properties.push({
|
|
515
|
+
name: param.name,
|
|
516
|
+
type: typeof uniformType === "string" ? uniformType : "",
|
|
517
|
+
description,
|
|
518
|
+
...someTypeProps
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
definitions.push(constructorDef);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
{
|
|
525
|
+
const methods = ((_c = dec.children) == null ? void 0 : _c.filter(
|
|
526
|
+
(child) => child.kind === import_typedoc.ReflectionKind.Method && child.name !== "constructor"
|
|
527
|
+
)) || [];
|
|
528
|
+
if (methods.length > 0) {
|
|
529
|
+
const methodsDef = {
|
|
530
|
+
title: "Methods",
|
|
531
|
+
properties: []
|
|
532
|
+
};
|
|
533
|
+
for (const method of methods) {
|
|
534
|
+
if (!((_d = method.signatures) == null ? void 0 : _d[0])) continue;
|
|
535
|
+
const methodSign = method.signatures[0];
|
|
536
|
+
let methodDesc = "";
|
|
537
|
+
if (methodSign.comment) {
|
|
538
|
+
methodDesc = commentToUniformDescription(methodSign.comment);
|
|
539
|
+
}
|
|
540
|
+
let type = "";
|
|
541
|
+
let someTypeProps = {};
|
|
542
|
+
if (methodSign.type) {
|
|
543
|
+
if (typeof methodSign.type === "object") {
|
|
544
|
+
someTypeProps = methodSign.type;
|
|
545
|
+
}
|
|
546
|
+
type = typeof methodSign.type === "string" ? methodSign.type : "";
|
|
547
|
+
} else {
|
|
548
|
+
type = "void";
|
|
549
|
+
}
|
|
550
|
+
const property = {
|
|
551
|
+
name: method.name,
|
|
552
|
+
type,
|
|
553
|
+
description: methodDesc,
|
|
554
|
+
...someTypeProps
|
|
555
|
+
};
|
|
556
|
+
if (method.comment) {
|
|
557
|
+
const examples = commentToUniformExamples(method.comment);
|
|
558
|
+
if (examples.length > 0) {
|
|
559
|
+
property.examples = examples;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
methodsDef.properties.push(property);
|
|
563
|
+
}
|
|
564
|
+
definitions.push(methodsDef);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return ref;
|
|
568
|
+
}
|
|
569
|
+
function jsFunctionToUniformRef(dec) {
|
|
570
|
+
const definitions = [];
|
|
571
|
+
const ref = {
|
|
572
|
+
title: `Function ${dec.name}`,
|
|
573
|
+
canonical: "",
|
|
574
|
+
description: "",
|
|
575
|
+
context: void 0,
|
|
576
|
+
examples: {
|
|
577
|
+
groups: []
|
|
578
|
+
},
|
|
579
|
+
definitions
|
|
580
|
+
};
|
|
581
|
+
const declarationCtx = declarationUniformContext.call(this, dec);
|
|
582
|
+
if (declarationCtx) {
|
|
583
|
+
ref.context = {
|
|
584
|
+
...ref.context,
|
|
585
|
+
...declarationCtx
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
ref.canonical = uniformCanonical(dec, declarationCtx);
|
|
589
|
+
const signatures = dec.signatures || [];
|
|
590
|
+
if (signatures.length > 1) {
|
|
591
|
+
console.error("(jsFunctionToUniformRef): Multiple signatures not supported for function declaration", dec.name);
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
for (const sign of dec.signatures || []) {
|
|
595
|
+
{
|
|
596
|
+
if (sign.comment) {
|
|
597
|
+
const description = commentToUniformDescription(sign.comment);
|
|
598
|
+
const group = uniformGroup(declarationCtx);
|
|
599
|
+
if (ref.context) {
|
|
600
|
+
ref.context.group = [
|
|
601
|
+
...group,
|
|
602
|
+
"Functions"
|
|
603
|
+
];
|
|
604
|
+
}
|
|
605
|
+
ref.description = description;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
{
|
|
609
|
+
const meta = [
|
|
610
|
+
{
|
|
611
|
+
name: "type",
|
|
612
|
+
value: "returns"
|
|
613
|
+
}
|
|
614
|
+
];
|
|
615
|
+
const returnsUniformDef = {
|
|
616
|
+
title: "Returns",
|
|
617
|
+
properties: [],
|
|
618
|
+
meta
|
|
619
|
+
};
|
|
620
|
+
if (sign.type) {
|
|
621
|
+
let desc = "";
|
|
622
|
+
if (sign.comment) {
|
|
623
|
+
desc = returnCommentToUniform(sign.comment) || "";
|
|
624
|
+
}
|
|
625
|
+
const uniformType = someTypeToUniform.call(this, sign.type);
|
|
626
|
+
let someTypeProps = {};
|
|
627
|
+
if (typeof uniformType === "object") {
|
|
628
|
+
delete uniformType.ofType;
|
|
629
|
+
someTypeProps = uniformType;
|
|
630
|
+
}
|
|
631
|
+
returnsUniformDef.properties.push({
|
|
632
|
+
name: "",
|
|
633
|
+
type: typeof uniformType === "string" ? uniformType : "",
|
|
634
|
+
description: desc,
|
|
635
|
+
...someTypeProps
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
ref.definitions.push(returnsUniformDef);
|
|
639
|
+
}
|
|
640
|
+
{
|
|
641
|
+
const meta = [
|
|
642
|
+
{
|
|
643
|
+
name: "type",
|
|
644
|
+
value: "parameters"
|
|
645
|
+
}
|
|
646
|
+
];
|
|
647
|
+
const parametersUniformDef = {
|
|
648
|
+
title: "Parameters",
|
|
649
|
+
properties: [],
|
|
650
|
+
meta
|
|
651
|
+
};
|
|
652
|
+
for (const param of sign.parameters || []) {
|
|
653
|
+
if (!param.type) {
|
|
654
|
+
console.warn("(jsFunctionToUniformRef): Parameter type not found", param.name);
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
let description = "";
|
|
658
|
+
if (param.comment) {
|
|
659
|
+
description = commentToUniformDescription(param.comment);
|
|
660
|
+
}
|
|
661
|
+
const uniformType = someTypeToUniform.call(this, param.type);
|
|
662
|
+
let someTypeProps = {};
|
|
663
|
+
if (typeof uniformType === "object") {
|
|
664
|
+
delete uniformType.ofType;
|
|
665
|
+
someTypeProps = uniformType;
|
|
666
|
+
}
|
|
667
|
+
const prop = {
|
|
668
|
+
name: param.name,
|
|
669
|
+
type: typeof uniformType === "string" ? uniformType : "",
|
|
670
|
+
description,
|
|
671
|
+
...someTypeProps
|
|
672
|
+
};
|
|
673
|
+
switch (prop.name) {
|
|
674
|
+
case "__namedParameters": {
|
|
675
|
+
prop.name = "";
|
|
676
|
+
prop.type = import_uniform.DEFINED_DEFINITION_PROPERTY_TYPE.UNION;
|
|
677
|
+
break;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
if (param.comment) {
|
|
681
|
+
const examples = commentToUniformExamples(param.comment);
|
|
682
|
+
if (examples.length > 0) {
|
|
683
|
+
prop.examples = examples;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
parametersUniformDef.properties.push(prop);
|
|
687
|
+
}
|
|
688
|
+
ref.definitions.push(parametersUniformDef);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
return ref;
|
|
692
|
+
}
|
|
693
|
+
function jsInterfaceToUniformRef(dec) {
|
|
694
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
695
|
+
const definitions = [];
|
|
696
|
+
const ref = {
|
|
697
|
+
title: `Interface ${dec.name}`,
|
|
698
|
+
canonical: "",
|
|
699
|
+
description: "",
|
|
700
|
+
context: void 0,
|
|
701
|
+
examples: {
|
|
702
|
+
groups: []
|
|
703
|
+
},
|
|
704
|
+
definitions
|
|
705
|
+
};
|
|
706
|
+
const declarationCtx = declarationUniformContext.call(this, dec);
|
|
707
|
+
if (declarationCtx) {
|
|
708
|
+
ref.context = {
|
|
709
|
+
...ref.context,
|
|
710
|
+
...declarationCtx
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
ref.canonical = uniformCanonical(dec, declarationCtx);
|
|
714
|
+
if (dec.comment) {
|
|
715
|
+
const description = commentToUniformDescription(dec.comment);
|
|
716
|
+
const group = uniformGroup(declarationCtx);
|
|
717
|
+
if (ref.context) {
|
|
718
|
+
ref.context.group = [
|
|
719
|
+
...group,
|
|
720
|
+
"Interfaces"
|
|
721
|
+
];
|
|
722
|
+
}
|
|
723
|
+
ref.description = description;
|
|
724
|
+
}
|
|
725
|
+
{
|
|
726
|
+
const properties = ((_a = dec.children) == null ? void 0 : _a.filter(
|
|
727
|
+
(child) => child.kind === import_typedoc.ReflectionKind.Property
|
|
728
|
+
)) || [];
|
|
729
|
+
if (properties.length > 0) {
|
|
730
|
+
const propertiesDef = {
|
|
731
|
+
title: "Properties",
|
|
732
|
+
properties: []
|
|
733
|
+
};
|
|
734
|
+
for (const prop of properties) {
|
|
735
|
+
if (!prop.type) {
|
|
736
|
+
console.warn("(jsInterfaceToUniformRef): Property type not found", prop.name);
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
let description = "";
|
|
740
|
+
if (prop.comment) {
|
|
741
|
+
description = commentToUniformDescription(prop.comment);
|
|
742
|
+
}
|
|
743
|
+
const uniformType = someTypeToUniform.call(this, prop.type);
|
|
744
|
+
let someTypeProps = {};
|
|
745
|
+
let meta = [];
|
|
746
|
+
if (typeof uniformType === "object") {
|
|
747
|
+
delete uniformType.ofType;
|
|
748
|
+
someTypeProps = uniformType;
|
|
749
|
+
meta = uniformType.meta || [];
|
|
750
|
+
}
|
|
751
|
+
if (!((_b = prop.flags) == null ? void 0 : _b.isOptional)) {
|
|
752
|
+
meta.push({
|
|
753
|
+
name: "required",
|
|
754
|
+
value: "true"
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
if (Array.isArray((_c = prop.comment) == null ? void 0 : _c.modifierTags) && ((_e = (_d = prop.comment) == null ? void 0 : _d.modifierTags) == null ? void 0 : _e.includes("@internal"))) {
|
|
758
|
+
meta.push({
|
|
759
|
+
name: "internal",
|
|
760
|
+
value: "true"
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
const property = {
|
|
764
|
+
name: prop.name,
|
|
765
|
+
type: typeof uniformType === "string" ? uniformType : "",
|
|
766
|
+
description,
|
|
767
|
+
...someTypeProps,
|
|
768
|
+
meta
|
|
769
|
+
};
|
|
770
|
+
if (prop.comment) {
|
|
771
|
+
const examples = commentToUniformExamples(prop.comment);
|
|
772
|
+
if (examples.length > 0) {
|
|
773
|
+
property.examples = examples;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
propertiesDef.properties.push(property);
|
|
777
|
+
}
|
|
778
|
+
definitions.push(propertiesDef);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
{
|
|
782
|
+
const methods = ((_f = dec.children) == null ? void 0 : _f.filter(
|
|
783
|
+
(child) => child.kind === import_typedoc.ReflectionKind.Method
|
|
784
|
+
)) || [];
|
|
785
|
+
if (methods.length > 0) {
|
|
786
|
+
const methodsDef = {
|
|
787
|
+
title: "Methods",
|
|
788
|
+
properties: []
|
|
789
|
+
};
|
|
790
|
+
for (const method of methods) {
|
|
791
|
+
if (!((_g = method.signatures) == null ? void 0 : _g[0])) continue;
|
|
792
|
+
const methodSign = method.signatures[0];
|
|
793
|
+
let methodDesc = "";
|
|
794
|
+
if (methodSign.comment) {
|
|
795
|
+
methodDesc = commentToUniformDescription(methodSign.comment);
|
|
796
|
+
}
|
|
797
|
+
let type = "";
|
|
798
|
+
let someTypeProps = {};
|
|
799
|
+
if (methodSign.type) {
|
|
800
|
+
if (typeof methodSign.type === "object") {
|
|
801
|
+
someTypeProps = methodSign.type;
|
|
802
|
+
}
|
|
803
|
+
type = typeof methodSign.type === "string" ? methodSign.type : "";
|
|
804
|
+
} else {
|
|
805
|
+
type = "void";
|
|
806
|
+
}
|
|
807
|
+
const property = {
|
|
808
|
+
name: method.name,
|
|
809
|
+
type,
|
|
810
|
+
description: methodDesc,
|
|
811
|
+
...someTypeProps
|
|
812
|
+
};
|
|
813
|
+
if (method.comment) {
|
|
814
|
+
const examples = commentToUniformExamples(method.comment);
|
|
815
|
+
if (examples.length > 0) {
|
|
816
|
+
property.examples = examples;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
methodsDef.properties.push(property);
|
|
820
|
+
}
|
|
821
|
+
definitions.push(methodsDef);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return ref;
|
|
825
|
+
}
|
|
826
|
+
function jsTypeAliasToUniformRef(dec) {
|
|
827
|
+
var _a, _b;
|
|
828
|
+
const definitions = [];
|
|
829
|
+
const ref = {
|
|
830
|
+
title: `Type ${dec.name}`,
|
|
831
|
+
canonical: "",
|
|
832
|
+
description: "",
|
|
833
|
+
context: void 0,
|
|
834
|
+
examples: {
|
|
835
|
+
groups: []
|
|
836
|
+
},
|
|
837
|
+
definitions
|
|
838
|
+
};
|
|
839
|
+
const declarationCtx = declarationUniformContext.call(this, dec);
|
|
840
|
+
if (declarationCtx) {
|
|
841
|
+
ref.context = {
|
|
842
|
+
...ref.context,
|
|
843
|
+
...declarationCtx
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
ref.canonical = uniformCanonical(dec, declarationCtx);
|
|
847
|
+
if (dec.comment) {
|
|
848
|
+
const description = commentToUniformDescription(dec.comment);
|
|
849
|
+
const group = uniformGroup(declarationCtx);
|
|
850
|
+
if (ref.context) {
|
|
851
|
+
ref.context.group = [
|
|
852
|
+
...group,
|
|
853
|
+
"Types"
|
|
854
|
+
];
|
|
855
|
+
}
|
|
856
|
+
ref.description = description;
|
|
857
|
+
}
|
|
858
|
+
if (dec.type && ((_a = dec.children) == null ? void 0 : _a.length)) {
|
|
859
|
+
console.warn("(jsTypeAliasToUniformRef): Type alias with children is not fully supported, only type definition will be handled", dec.name);
|
|
860
|
+
}
|
|
861
|
+
{
|
|
862
|
+
const typeDef = {
|
|
863
|
+
title: "Type Definition",
|
|
864
|
+
properties: []
|
|
865
|
+
};
|
|
866
|
+
let comment = "";
|
|
867
|
+
if (dec.comment) {
|
|
868
|
+
comment = commentToUniformDescription(dec.comment);
|
|
869
|
+
}
|
|
870
|
+
if (dec.type) {
|
|
871
|
+
const uniformType = someTypeToUniform.call(this, dec.type);
|
|
872
|
+
let someTypeProps = {};
|
|
873
|
+
if (typeof uniformType === "object") {
|
|
874
|
+
delete uniformType.ofType;
|
|
875
|
+
someTypeProps = uniformType;
|
|
876
|
+
}
|
|
877
|
+
const propDefinition = {
|
|
878
|
+
name: "",
|
|
879
|
+
type: typeof uniformType === "string" ? uniformType : "",
|
|
880
|
+
description: comment,
|
|
881
|
+
...someTypeProps
|
|
882
|
+
};
|
|
883
|
+
typeDef.rootProperty = propDefinition;
|
|
884
|
+
} else if ((_b = dec == null ? void 0 : dec.children) == null ? void 0 : _b.length) {
|
|
885
|
+
const properties = uniformProperties.call(this, dec);
|
|
886
|
+
typeDef.properties = properties;
|
|
887
|
+
}
|
|
888
|
+
definitions.push(typeDef);
|
|
889
|
+
}
|
|
890
|
+
return ref;
|
|
891
|
+
}
|
|
892
|
+
function jsEnumToUniformRef(dec) {
|
|
893
|
+
var _a;
|
|
894
|
+
const definitions = [];
|
|
895
|
+
const ref = {
|
|
896
|
+
title: `Enum ${dec.name}`,
|
|
897
|
+
canonical: "",
|
|
898
|
+
description: "",
|
|
899
|
+
context: void 0,
|
|
900
|
+
examples: {
|
|
901
|
+
groups: []
|
|
902
|
+
},
|
|
903
|
+
definitions
|
|
904
|
+
};
|
|
905
|
+
const declarationCtx = declarationUniformContext.call(this, dec);
|
|
906
|
+
if (declarationCtx) {
|
|
907
|
+
ref.context = {
|
|
908
|
+
...ref.context,
|
|
909
|
+
...declarationCtx
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
ref.canonical = uniformCanonical(dec, declarationCtx);
|
|
913
|
+
if (dec.comment) {
|
|
914
|
+
const description = commentToUniformDescription(dec.comment);
|
|
915
|
+
const group = uniformGroup(declarationCtx);
|
|
916
|
+
if (ref.context) {
|
|
917
|
+
ref.context.group = [
|
|
918
|
+
...group,
|
|
919
|
+
"Enums"
|
|
920
|
+
];
|
|
921
|
+
}
|
|
922
|
+
ref.description = description;
|
|
923
|
+
}
|
|
924
|
+
{
|
|
925
|
+
const members = ((_a = dec.children) == null ? void 0 : _a.filter(
|
|
926
|
+
(child) => child.kind === import_typedoc.ReflectionKind.EnumMember
|
|
927
|
+
)) || [];
|
|
928
|
+
if (members.length > 0) {
|
|
929
|
+
const membersDef = {
|
|
930
|
+
title: "Members",
|
|
931
|
+
properties: []
|
|
932
|
+
};
|
|
933
|
+
const sortedMembers = [...members].sort((a, b) => {
|
|
934
|
+
var _a2, _b, _c, _d;
|
|
935
|
+
if (!((_b = (_a2 = a.sources) == null ? void 0 : _a2[0]) == null ? void 0 : _b.line) || !((_d = (_c = b.sources) == null ? void 0 : _c[0]) == null ? void 0 : _d.line)) {
|
|
936
|
+
return 0;
|
|
937
|
+
}
|
|
938
|
+
return a.sources[0].line - b.sources[0].line;
|
|
939
|
+
});
|
|
940
|
+
for (const member of sortedMembers) {
|
|
941
|
+
let description = "";
|
|
942
|
+
if (member.comment) {
|
|
943
|
+
description = commentToUniformDescription(member.comment);
|
|
944
|
+
}
|
|
945
|
+
let value = "";
|
|
946
|
+
let type = "number";
|
|
947
|
+
if (member.type && typeof member.type === "object" && member.type.type === "literal" && member.type.value !== null) {
|
|
948
|
+
if (typeof member.type.value === "string") {
|
|
949
|
+
value = member.type.value;
|
|
950
|
+
type = "string";
|
|
951
|
+
} else {
|
|
952
|
+
value = member.type.value.toString();
|
|
953
|
+
type = "number";
|
|
954
|
+
}
|
|
955
|
+
} else if (member.defaultValue !== void 0) {
|
|
956
|
+
value = member.defaultValue.toString();
|
|
957
|
+
if (value.startsWith('"') && value.endsWith('"')) {
|
|
958
|
+
type = "string";
|
|
959
|
+
value = value.substring(1, value.length - 1);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
const formattedName = `${member.name} (${value})`;
|
|
963
|
+
membersDef.properties.push({
|
|
964
|
+
name: formattedName,
|
|
965
|
+
type,
|
|
966
|
+
description
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
definitions.push(membersDef);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
return ref;
|
|
973
|
+
}
|
|
974
|
+
function declarationUniformContext(dec) {
|
|
975
|
+
var _a, _b, _c, _d;
|
|
976
|
+
if (!dec.sources || !dec.sources.length) {
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
if (dec.sources.length > 1) {
|
|
980
|
+
console.warn("(declarationUniformContext): Multiple sources not supported for function declaration", dec.name);
|
|
981
|
+
}
|
|
982
|
+
const source = dec.sources[0];
|
|
983
|
+
const signTxt = this.signatureTextLoader.signatureText(
|
|
984
|
+
dec.id,
|
|
985
|
+
source == null ? void 0 : source.line
|
|
986
|
+
) || "";
|
|
987
|
+
const sourceCode = this.signatureTextLoader.signatureSourceCode(
|
|
988
|
+
dec.id,
|
|
989
|
+
source == null ? void 0 : source.line
|
|
990
|
+
) || "";
|
|
991
|
+
const symbolMap = this.project.symbolIdMap[dec.id];
|
|
992
|
+
const fileFullPath = symbolMap.packagePath;
|
|
993
|
+
const meta = [];
|
|
994
|
+
if (Array.isArray((_a = dec.comment) == null ? void 0 : _a.modifierTags) && ((_c = (_b = dec.comment) == null ? void 0 : _b.modifierTags) == null ? void 0 : _c.includes("@internal"))) {
|
|
995
|
+
meta.push({
|
|
996
|
+
name: "internal",
|
|
997
|
+
value: "true"
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
const ctx = {
|
|
1001
|
+
symbolId: (_d = dec.id) == null ? void 0 : _d.toString(),
|
|
1002
|
+
symbolName: dec.name,
|
|
1003
|
+
symbolKind: dec.kind,
|
|
1004
|
+
packageName: symbolMap == null ? void 0 : symbolMap.packageName,
|
|
1005
|
+
fileName: source.fileName,
|
|
1006
|
+
fileFullPath,
|
|
1007
|
+
line: source.line,
|
|
1008
|
+
col: source.character,
|
|
1009
|
+
signatureText: {
|
|
1010
|
+
code: signTxt,
|
|
1011
|
+
lang: "ts"
|
|
1012
|
+
},
|
|
1013
|
+
sourcecode: {
|
|
1014
|
+
code: sourceCode,
|
|
1015
|
+
lang: "ts"
|
|
1016
|
+
},
|
|
1017
|
+
meta
|
|
1018
|
+
};
|
|
1019
|
+
const category = uniformCategory(dec);
|
|
1020
|
+
if (category) {
|
|
1021
|
+
ctx.category = category;
|
|
1022
|
+
}
|
|
1023
|
+
return ctx;
|
|
1024
|
+
}
|
|
1025
|
+
function someTypeToUniform(someType) {
|
|
1026
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1027
|
+
const meta = [];
|
|
1028
|
+
if ("target" in someType) {
|
|
1029
|
+
for (const child of ((_a = this == null ? void 0 : this.project) == null ? void 0 : _a.children) || []) {
|
|
1030
|
+
if (String(child.id) === String(someType.target)) {
|
|
1031
|
+
if (Array.isArray((_b = child.comment) == null ? void 0 : _b.modifierTags) && ((_d = (_c = child.comment) == null ? void 0 : _c.modifierTags) == null ? void 0 : _d.includes("@internal"))) {
|
|
1032
|
+
meta.push({
|
|
1033
|
+
name: "internal",
|
|
1034
|
+
value: "true"
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
switch (someType.type) {
|
|
1041
|
+
case "reference": {
|
|
1042
|
+
let refType = `${someType.qualifiedName || someType.name}`;
|
|
1043
|
+
if ("target" in someType && typeof someType.target === "number") {
|
|
1044
|
+
return {
|
|
1045
|
+
type: refType,
|
|
1046
|
+
symbolDef: {
|
|
1047
|
+
id: (_e = someType.target) == null ? void 0 : _e.toString()
|
|
1048
|
+
},
|
|
1049
|
+
meta
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
if ("typeArguments" in someType && someType.typeArguments) {
|
|
1053
|
+
const typeArgs = someType.typeArguments.map((arg) => {
|
|
1054
|
+
const argType = someTypeToUniform.call(this, arg);
|
|
1055
|
+
return typeof argType === "string" ? argType : argType.type || "";
|
|
1056
|
+
});
|
|
1057
|
+
refType = `${refType}<${typeArgs.join(", ")}>`;
|
|
1058
|
+
}
|
|
1059
|
+
return refType;
|
|
1060
|
+
}
|
|
1061
|
+
case "union": {
|
|
1062
|
+
const resp = unionLikeSomeType.call(this, someType.types);
|
|
1063
|
+
if (typeof resp === "string") {
|
|
1064
|
+
return resp;
|
|
1065
|
+
}
|
|
1066
|
+
return {
|
|
1067
|
+
...resp,
|
|
1068
|
+
meta: [
|
|
1069
|
+
...resp.meta || [],
|
|
1070
|
+
...meta
|
|
1071
|
+
]
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
case "literal": {
|
|
1075
|
+
if (typeof someType.value === "string") {
|
|
1076
|
+
return `"${someType.value}"`;
|
|
1077
|
+
}
|
|
1078
|
+
return (someType.value || "").toString();
|
|
1079
|
+
}
|
|
1080
|
+
case "reflection": {
|
|
1081
|
+
const properties = uniformProperties.call(this, someType.declaration);
|
|
1082
|
+
let type = "";
|
|
1083
|
+
if (((_f = someType.declaration.indexSignatures) == null ? void 0 : _f.length) || ((_g = someType.declaration.children) == null ? void 0 : _g.length)) {
|
|
1084
|
+
type = this.signatureTextLoader.signatureText(
|
|
1085
|
+
someType.declaration.id,
|
|
1086
|
+
((_i = (_h = someType.declaration.sources) == null ? void 0 : _h[0]) == null ? void 0 : _i.line) || 0,
|
|
1087
|
+
{
|
|
1088
|
+
typeOnly: true
|
|
1089
|
+
}
|
|
1090
|
+
) || "";
|
|
1091
|
+
}
|
|
1092
|
+
if ((_j = someType.declaration.indexSignatures) == null ? void 0 : _j.length) {
|
|
1093
|
+
if (properties.length > 1) {
|
|
1094
|
+
console.warn("(someTypeToUniform): Reflection type with multiple properties, using first one as ofProperty", someType.declaration.name);
|
|
1095
|
+
}
|
|
1096
|
+
return {
|
|
1097
|
+
type: import_uniform.DEFINED_DEFINITION_PROPERTY_TYPE.UNION,
|
|
1098
|
+
properties: [],
|
|
1099
|
+
meta,
|
|
1100
|
+
ofProperty: {
|
|
1101
|
+
name: "",
|
|
1102
|
+
type,
|
|
1103
|
+
description: ""
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
return {
|
|
1108
|
+
type,
|
|
1109
|
+
properties,
|
|
1110
|
+
meta
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
case "array": {
|
|
1114
|
+
const arrayItemType = someTypeToUniform.call(this, someType.elementType);
|
|
1115
|
+
if (typeof arrayItemType === "string") {
|
|
1116
|
+
return {
|
|
1117
|
+
type: arrayItemType + "[]",
|
|
1118
|
+
meta
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
return {
|
|
1122
|
+
ofType: (arrayItemType.type || "") + "[]",
|
|
1123
|
+
type: import_uniform.DEFINED_DEFINITION_PROPERTY_TYPE.ARRAY,
|
|
1124
|
+
ofProperty: {
|
|
1125
|
+
name: "",
|
|
1126
|
+
description: "",
|
|
1127
|
+
type: arrayItemType.type || "",
|
|
1128
|
+
properties: [],
|
|
1129
|
+
symbolDef: arrayItemType.symbolDef
|
|
1130
|
+
},
|
|
1131
|
+
meta
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
case "tuple": {
|
|
1135
|
+
const elements = someType.elements || [];
|
|
1136
|
+
const elementTypes = elements.map((element) => someTypeToUniform.call(this, element));
|
|
1137
|
+
const tupleType = `[${elementTypes.map((t) => typeof t === "string" ? t : t.type || "").join(", ")}]`;
|
|
1138
|
+
const symbolIds = [];
|
|
1139
|
+
for (const t of elementTypes) {
|
|
1140
|
+
if (typeof t === "object" && ((_k = t.symbolDef) == null ? void 0 : _k.id)) {
|
|
1141
|
+
if (Array.isArray(t.symbolDef.id)) {
|
|
1142
|
+
symbolIds.push(...t.symbolDef.id);
|
|
1143
|
+
} else {
|
|
1144
|
+
symbolIds.push(t.symbolDef.id);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
return {
|
|
1149
|
+
type: tupleType,
|
|
1150
|
+
symbolDef: symbolIds.length > 0 ? { id: symbolIds } : void 0,
|
|
1151
|
+
meta
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
case "intersection": {
|
|
1155
|
+
const resp = unionLikeSomeType.call(this, someType.types);
|
|
1156
|
+
if (typeof resp === "string") {
|
|
1157
|
+
return resp;
|
|
1158
|
+
}
|
|
1159
|
+
return {
|
|
1160
|
+
...resp,
|
|
1161
|
+
meta: [
|
|
1162
|
+
...resp.meta || [],
|
|
1163
|
+
...meta
|
|
1164
|
+
]
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
case "rest": {
|
|
1168
|
+
const resp = someTypeToUniform.call(this, someType.elementType);
|
|
1169
|
+
if (typeof resp === "string") {
|
|
1170
|
+
return `${resp}[]`;
|
|
1171
|
+
}
|
|
1172
|
+
return {
|
|
1173
|
+
...resp,
|
|
1174
|
+
type: `${resp.type || ""}[]`
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
default: {
|
|
1178
|
+
if (!("name" in someType)) {
|
|
1179
|
+
console.warn("SomeType does not have name property", someType.type);
|
|
1180
|
+
return "";
|
|
1181
|
+
}
|
|
1182
|
+
return someType.name;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return "";
|
|
1186
|
+
}
|
|
1187
|
+
function unionLikeSomeType(someTypes) {
|
|
1188
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1189
|
+
let types = [];
|
|
1190
|
+
const symbolIds = [];
|
|
1191
|
+
for (const t of someTypes) {
|
|
1192
|
+
const tUniform = someTypeToUniform.call(this, t);
|
|
1193
|
+
if (typeof tUniform === "object") {
|
|
1194
|
+
if ((_a = tUniform.meta) == null ? void 0 : _a.some((m) => m.name === "internal" && m.value === "true")) {
|
|
1195
|
+
continue;
|
|
1196
|
+
}
|
|
1197
|
+
if (((_b = tUniform.type) == null ? void 0 : _b.startsWith("[")) && ((_c = tUniform.type) == null ? void 0 : _c.endsWith("]"))) {
|
|
1198
|
+
types.push(tUniform.type);
|
|
1199
|
+
} else {
|
|
1200
|
+
types.push(tUniform.ofType || tUniform.type || "");
|
|
1201
|
+
}
|
|
1202
|
+
if ((_d = tUniform == null ? void 0 : tUniform.symbolDef) == null ? void 0 : _d.id) {
|
|
1203
|
+
if (Array.isArray((_e = tUniform == null ? void 0 : tUniform.symbolDef) == null ? void 0 : _e.id)) {
|
|
1204
|
+
symbolIds.push(...(_f = tUniform.symbolDef) == null ? void 0 : _f.id);
|
|
1205
|
+
} else {
|
|
1206
|
+
symbolIds.push(tUniform.symbolDef.id);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
delete tUniform.ofType;
|
|
1210
|
+
} else {
|
|
1211
|
+
types.push(tUniform);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
return {
|
|
1215
|
+
type: types.filter(Boolean).join(" | "),
|
|
1216
|
+
symbolDef: {
|
|
1217
|
+
id: symbolIds
|
|
1218
|
+
}
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
function commentToUniformDescription(comment) {
|
|
1222
|
+
let desc = "";
|
|
1223
|
+
for (const summary of (comment == null ? void 0 : comment.summary) || []) {
|
|
1224
|
+
desc += `${summary.text}
|
|
1225
|
+
`;
|
|
1226
|
+
}
|
|
1227
|
+
return desc;
|
|
1228
|
+
}
|
|
1229
|
+
function commentToUniformExamples(comment) {
|
|
1230
|
+
if (!comment.blockTags || !comment.blockTags.length) {
|
|
1231
|
+
return [];
|
|
1232
|
+
}
|
|
1233
|
+
const examples = [];
|
|
1234
|
+
for (const tag of comment.blockTags) {
|
|
1235
|
+
if (tag.tag === "@example") {
|
|
1236
|
+
for (const content of tag.content || []) {
|
|
1237
|
+
if (content.kind === "code") {
|
|
1238
|
+
const code = content.text.replace(/```ts\n|\n```/g, "");
|
|
1239
|
+
examples.push(code);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
return examples;
|
|
1245
|
+
}
|
|
1246
|
+
function uniformCategory(dec) {
|
|
1247
|
+
if (!dec) {
|
|
1248
|
+
return "";
|
|
1249
|
+
}
|
|
1250
|
+
let category = "";
|
|
1251
|
+
for (const signature of dec.signatures || []) {
|
|
1252
|
+
if (signature.comment) {
|
|
1253
|
+
const comment = signature.comment;
|
|
1254
|
+
if (comment.blockTags) {
|
|
1255
|
+
for (const tag of comment.blockTags) {
|
|
1256
|
+
if (tag.tag === "@category") {
|
|
1257
|
+
for (const content of tag.content || []) {
|
|
1258
|
+
category += content.text;
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
return category;
|
|
1266
|
+
}
|
|
1267
|
+
function returnCommentToUniform(comment) {
|
|
1268
|
+
if (!comment.blockTags || !comment.blockTags.length) {
|
|
1269
|
+
return "";
|
|
1270
|
+
}
|
|
1271
|
+
let desc = "";
|
|
1272
|
+
for (const tag of comment.blockTags) {
|
|
1273
|
+
if (tag.tag === "@returns") {
|
|
1274
|
+
for (const content of tag.content || []) {
|
|
1275
|
+
desc += `${content.text}
|
|
1276
|
+
`;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
return desc;
|
|
1281
|
+
}
|
|
1282
|
+
function uniformProperties(dec) {
|
|
1283
|
+
var _a, _b, _c, _d;
|
|
1284
|
+
const properties = [];
|
|
1285
|
+
for (const prop of dec.children || []) {
|
|
1286
|
+
if (!prop.type) {
|
|
1287
|
+
console.warn("(uniformProperties): Property type not found", prop.name);
|
|
1288
|
+
continue;
|
|
1289
|
+
}
|
|
1290
|
+
let description = "";
|
|
1291
|
+
if (prop.comment) {
|
|
1292
|
+
description = commentToUniformDescription(prop.comment);
|
|
1293
|
+
}
|
|
1294
|
+
const uniformType = someTypeToUniform.call(this, prop.type);
|
|
1295
|
+
let meta = [];
|
|
1296
|
+
let someTypeProps = {};
|
|
1297
|
+
if (typeof uniformType === "object") {
|
|
1298
|
+
delete uniformType.ofType;
|
|
1299
|
+
someTypeProps = uniformType;
|
|
1300
|
+
meta = uniformType.meta || [];
|
|
1301
|
+
}
|
|
1302
|
+
if (!((_a = prop.flags) == null ? void 0 : _a.isOptional)) {
|
|
1303
|
+
meta.push({
|
|
1304
|
+
name: "required",
|
|
1305
|
+
value: "true"
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
if (Array.isArray((_b = prop.comment) == null ? void 0 : _b.modifierTags) && ((_d = (_c = prop.comment) == null ? void 0 : _c.modifierTags) == null ? void 0 : _d.includes("@internal"))) {
|
|
1309
|
+
meta.push({
|
|
1310
|
+
name: "internal",
|
|
1311
|
+
value: "true"
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
const property = {
|
|
1315
|
+
name: prop.name,
|
|
1316
|
+
type: typeof uniformType === "string" ? uniformType : "",
|
|
1317
|
+
description,
|
|
1318
|
+
...someTypeProps,
|
|
1319
|
+
meta
|
|
1320
|
+
};
|
|
1321
|
+
if (prop.comment) {
|
|
1322
|
+
const examples = commentToUniformExamples(prop.comment);
|
|
1323
|
+
if (examples.length > 0) {
|
|
1324
|
+
property.examples = examples;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
properties.push(property);
|
|
1328
|
+
}
|
|
1329
|
+
return properties;
|
|
1330
|
+
}
|
|
1331
|
+
function uniformGroup(ctx) {
|
|
1332
|
+
if (!ctx) {
|
|
1333
|
+
return [];
|
|
1334
|
+
}
|
|
1335
|
+
const group = ctx.packageName.split("/");
|
|
1336
|
+
return group;
|
|
1337
|
+
}
|
|
1338
|
+
function uniformCanonical(dec, ctx) {
|
|
1339
|
+
const parts = [];
|
|
1340
|
+
if (ctx == null ? void 0 : ctx.packageName) {
|
|
1341
|
+
parts.push(ctx.packageName);
|
|
1342
|
+
}
|
|
1343
|
+
switch (dec.kind) {
|
|
1344
|
+
case import_typedoc.ReflectionKind.Class: {
|
|
1345
|
+
parts.push("classes", dec.name);
|
|
1346
|
+
break;
|
|
1347
|
+
}
|
|
1348
|
+
case import_typedoc.ReflectionKind.Interface: {
|
|
1349
|
+
parts.push("interfaces", dec.name);
|
|
1350
|
+
break;
|
|
1351
|
+
}
|
|
1352
|
+
case import_typedoc.ReflectionKind.Function: {
|
|
1353
|
+
parts.push("functions", dec.name);
|
|
1354
|
+
break;
|
|
1355
|
+
}
|
|
1356
|
+
case import_typedoc.ReflectionKind.TypeAlias: {
|
|
1357
|
+
parts.push("types", dec.name);
|
|
1358
|
+
break;
|
|
1359
|
+
}
|
|
1360
|
+
case import_typedoc.ReflectionKind.Enum: {
|
|
1361
|
+
parts.push("enums", dec.name);
|
|
1362
|
+
break;
|
|
1363
|
+
}
|
|
1364
|
+
default: {
|
|
1365
|
+
return "";
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
return parts.join("/");
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
// packages/ts/uniformToMiniUniform.ts
|
|
1372
|
+
var import_uniform2 = require("@xyd-js/uniform");
|
|
1373
|
+
var TXT = {
|
|
1374
|
+
Properties: "Properties"
|
|
1375
|
+
};
|
|
1376
|
+
var PRIMITIVE_TYPES = /* @__PURE__ */ new Set(["string", "number", "boolean"]);
|
|
1377
|
+
function uniformToMiniUniform(rootSymbolName, references) {
|
|
1378
|
+
var _a, _b;
|
|
1379
|
+
const output = [];
|
|
1380
|
+
const refBySymbolId = {};
|
|
1381
|
+
for (const reference of references) {
|
|
1382
|
+
const ctx = reference.context;
|
|
1383
|
+
if (ctx == null ? void 0 : ctx.symbolId) {
|
|
1384
|
+
if ((_b = (_a = reference.context) == null ? void 0 : _a.meta) == null ? void 0 : _b.some((m) => m.name === "internal" && m.value === "true")) {
|
|
1385
|
+
continue;
|
|
1386
|
+
}
|
|
1387
|
+
refBySymbolId[ctx.symbolId] = JSON.parse(JSON.stringify(reference));
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
for (const reference of references) {
|
|
1391
|
+
const ctx = reference.context;
|
|
1392
|
+
if ((ctx == null ? void 0 : ctx.symbolName) !== rootSymbolName) {
|
|
1393
|
+
continue;
|
|
1394
|
+
}
|
|
1395
|
+
const miniRef = {
|
|
1396
|
+
...reference,
|
|
1397
|
+
title: (ctx == null ? void 0 : ctx.symbolName) || reference.title,
|
|
1398
|
+
canonical: "",
|
|
1399
|
+
context: ctx,
|
|
1400
|
+
definitions: []
|
|
1401
|
+
};
|
|
1402
|
+
for (const def of reference.definitions) {
|
|
1403
|
+
const miniDef = {
|
|
1404
|
+
...def,
|
|
1405
|
+
title: TXT.Properties,
|
|
1406
|
+
properties: [],
|
|
1407
|
+
symbolDef: {
|
|
1408
|
+
...def.symbolDef || {},
|
|
1409
|
+
canonical: ""
|
|
1410
|
+
// TODO: support canonical in the future
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
1413
|
+
const defProperties = (def == null ? void 0 : def.rootProperty) ? [def.rootProperty] : def.properties || [];
|
|
1414
|
+
definitionMiniPropsPassThrough(
|
|
1415
|
+
refBySymbolId,
|
|
1416
|
+
defProperties,
|
|
1417
|
+
miniDef
|
|
1418
|
+
);
|
|
1419
|
+
miniRef.definitions.push(miniDef);
|
|
1420
|
+
}
|
|
1421
|
+
output.push(miniRef);
|
|
1422
|
+
}
|
|
1423
|
+
return output;
|
|
1424
|
+
}
|
|
1425
|
+
function definitionMiniPropsPassThrough(refBySymbolId, defProperties, miniDef, options) {
|
|
1426
|
+
for (let property of defProperties) {
|
|
1427
|
+
property = {
|
|
1428
|
+
...property,
|
|
1429
|
+
symbolDef: {
|
|
1430
|
+
...property.symbolDef || {},
|
|
1431
|
+
canonical: ""
|
|
1432
|
+
// TODO: support canonical in the future
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
const resolvedProperty = resolveProperty(refBySymbolId, property, options);
|
|
1436
|
+
miniDef.properties.push({
|
|
1437
|
+
...resolvedProperty,
|
|
1438
|
+
symbolDef: {
|
|
1439
|
+
...resolvedProperty.symbolDef || {},
|
|
1440
|
+
canonical: ""
|
|
1441
|
+
// TODO: support canonical in the future
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
function resolveProperty(refBySymbolId, property, options) {
|
|
1447
|
+
var _a, _b, _c;
|
|
1448
|
+
property = {
|
|
1449
|
+
...property,
|
|
1450
|
+
symbolDef: {
|
|
1451
|
+
...property.symbolDef || {},
|
|
1452
|
+
canonical: ""
|
|
1453
|
+
// TODO: support canonical in the future
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
const depth = (options == null ? void 0 : options.depth) || 0;
|
|
1457
|
+
const visited = (options == null ? void 0 : options.visited) || /* @__PURE__ */ new Set();
|
|
1458
|
+
if (depth > 10) {
|
|
1459
|
+
console.warn("Maximum recursion depth reached for property:", property.name);
|
|
1460
|
+
return property;
|
|
1461
|
+
}
|
|
1462
|
+
if ((_a = property == null ? void 0 : property.properties) == null ? void 0 : _a.length) {
|
|
1463
|
+
return property;
|
|
1464
|
+
}
|
|
1465
|
+
const resolvedPropertyProps = [];
|
|
1466
|
+
const resolvedProperty = {
|
|
1467
|
+
...property,
|
|
1468
|
+
properties: resolvedPropertyProps
|
|
1469
|
+
};
|
|
1470
|
+
if (property.type === import_uniform2.DEFINED_DEFINITION_PROPERTY_TYPE.ARRAY) {
|
|
1471
|
+
if (property.ofProperty) {
|
|
1472
|
+
const resolvedRootProperty = resolveProperty(
|
|
1473
|
+
refBySymbolId,
|
|
1474
|
+
property.ofProperty,
|
|
1475
|
+
options
|
|
1476
|
+
);
|
|
1477
|
+
resolvedProperty.ofProperty = resolvedRootProperty;
|
|
1478
|
+
return resolvedProperty;
|
|
1479
|
+
} else {
|
|
1480
|
+
console.warn(`Property ${property.name} is an array but has no ofProperty defined, using type only`);
|
|
1481
|
+
}
|
|
1482
|
+
return property;
|
|
1483
|
+
}
|
|
1484
|
+
const symbolId = (_b = property == null ? void 0 : property.symbolDef) == null ? void 0 : _b.id;
|
|
1485
|
+
if (symbolId) {
|
|
1486
|
+
if (typeof symbolId === "string") {
|
|
1487
|
+
if (visited.has(symbolId)) {
|
|
1488
|
+
return resolvedProperty;
|
|
1489
|
+
}
|
|
1490
|
+
visited.add(symbolId);
|
|
1491
|
+
const refSymbol = refBySymbolId[symbolId];
|
|
1492
|
+
const refSymbolDefinition = (_c = refSymbol == null ? void 0 : refSymbol.definitions) == null ? void 0 : _c[0];
|
|
1493
|
+
const refSymbolDefinitionProps = (refSymbolDefinition == null ? void 0 : refSymbolDefinition.properties) || [];
|
|
1494
|
+
if (!refSymbol) {
|
|
1495
|
+
console.warn(`Reference for symbol ${symbolId} not found, using type only`);
|
|
1496
|
+
return resolvedProperty;
|
|
1497
|
+
}
|
|
1498
|
+
if (refSymbolDefinitionProps.length) {
|
|
1499
|
+
for (const prop of refSymbolDefinitionProps) {
|
|
1500
|
+
const resolvedProp = resolveProperty(refBySymbolId, prop, {
|
|
1501
|
+
...options,
|
|
1502
|
+
depth: depth + 1,
|
|
1503
|
+
visited: new Set(visited)
|
|
1504
|
+
});
|
|
1505
|
+
resolvedPropertyProps.push(resolvedProp);
|
|
1506
|
+
}
|
|
1507
|
+
} else if (refSymbolDefinition.rootProperty) {
|
|
1508
|
+
const resolvedProp = resolveProperty(refBySymbolId, refSymbolDefinition.rootProperty, {
|
|
1509
|
+
...options,
|
|
1510
|
+
depth: depth + 1,
|
|
1511
|
+
visited: new Set(visited)
|
|
1512
|
+
});
|
|
1513
|
+
resolvedProperty.ofProperty = resolvedProp;
|
|
1514
|
+
} else {
|
|
1515
|
+
console.warn(`Reference for symbol ${symbolId} has no properties, using type and description only`);
|
|
1516
|
+
}
|
|
1517
|
+
if (!resolvedProperty.description) {
|
|
1518
|
+
resolvedProperty.description = refSymbol.description || "";
|
|
1519
|
+
}
|
|
1520
|
+
return resolvedProperty;
|
|
1521
|
+
}
|
|
1522
|
+
const isResolveUnion = isResolveUnionRef(property);
|
|
1523
|
+
if (isResolveUnion) {
|
|
1524
|
+
resolvedProperty.type = import_uniform2.DEFINED_DEFINITION_PROPERTY_TYPE.UNION;
|
|
1525
|
+
const unionProps = handleUnionTypes(
|
|
1526
|
+
refBySymbolId,
|
|
1527
|
+
property,
|
|
1528
|
+
options
|
|
1529
|
+
);
|
|
1530
|
+
if (unionProps.length > 1) {
|
|
1531
|
+
resolvedProperty.properties = unionProps;
|
|
1532
|
+
} else {
|
|
1533
|
+
resolvedProperty.ofProperty = unionProps[0];
|
|
1534
|
+
}
|
|
1535
|
+
const shortType = shortMergedType(resolvedProperty);
|
|
1536
|
+
if (shortType) {
|
|
1537
|
+
return shortType;
|
|
1538
|
+
}
|
|
1539
|
+
return resolvedProperty;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
return property;
|
|
1543
|
+
}
|
|
1544
|
+
function shortMergedType(property) {
|
|
1545
|
+
property = {
|
|
1546
|
+
...property,
|
|
1547
|
+
symbolDef: {
|
|
1548
|
+
...property.symbolDef || {},
|
|
1549
|
+
canonical: ""
|
|
1550
|
+
// TODO: support canonical in the future
|
|
1551
|
+
}
|
|
1552
|
+
};
|
|
1553
|
+
if (property.type !== import_uniform2.DEFINED_DEFINITION_PROPERTY_TYPE.UNION) {
|
|
1554
|
+
return null;
|
|
1555
|
+
}
|
|
1556
|
+
const properties = property.ofProperty ? [property.ofProperty] : property.properties || [];
|
|
1557
|
+
const processedProperties = properties.map((prop) => {
|
|
1558
|
+
if (prop.type === import_uniform2.DEFINED_DEFINITION_PROPERTY_TYPE.UNION) {
|
|
1559
|
+
const shortType2 = shortMergedType(prop);
|
|
1560
|
+
if (shortType2) {
|
|
1561
|
+
return shortType2;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
const shortType = shortMergedType({
|
|
1565
|
+
name: "",
|
|
1566
|
+
description: "",
|
|
1567
|
+
type: import_uniform2.DEFINED_DEFINITION_PROPERTY_TYPE.UNION,
|
|
1568
|
+
properties: prop.properties,
|
|
1569
|
+
ofProperty: prop.ofProperty
|
|
1570
|
+
});
|
|
1571
|
+
if (shortType) {
|
|
1572
|
+
return shortType;
|
|
1573
|
+
}
|
|
1574
|
+
return prop;
|
|
1575
|
+
});
|
|
1576
|
+
if (!(processedProperties == null ? void 0 : processedProperties.length)) {
|
|
1577
|
+
return null;
|
|
1578
|
+
}
|
|
1579
|
+
const hasOnlySimpleTypes = processedProperties.every((prop) => {
|
|
1580
|
+
if (isLiteralValues(prop.type)) {
|
|
1581
|
+
return true;
|
|
1582
|
+
}
|
|
1583
|
+
return PRIMITIVE_TYPES.has(prop.type);
|
|
1584
|
+
});
|
|
1585
|
+
if (!hasOnlySimpleTypes) {
|
|
1586
|
+
return null;
|
|
1587
|
+
}
|
|
1588
|
+
const types = processedProperties.map((prop) => prop.type);
|
|
1589
|
+
const mergedType = types.join(" | ");
|
|
1590
|
+
return {
|
|
1591
|
+
...property,
|
|
1592
|
+
type: mergedType,
|
|
1593
|
+
properties: []
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
function handleUnionTypes(refBySymbolId, property, options) {
|
|
1597
|
+
var _a, _b, _c, _d;
|
|
1598
|
+
property = {
|
|
1599
|
+
...property,
|
|
1600
|
+
symbolDef: {
|
|
1601
|
+
...property.symbolDef || {},
|
|
1602
|
+
canonical: ""
|
|
1603
|
+
// TODO: support canonical in the future
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1606
|
+
const symbolIds = Array.isArray((_a = property.symbolDef) == null ? void 0 : _a.id) ? property.symbolDef.id : [];
|
|
1607
|
+
const typeString = property.type;
|
|
1608
|
+
const properties = [];
|
|
1609
|
+
const unionTypeStringsMap = (typeString || "").split("|").map((t) => t.trim()).reduce((acc, type) => ({
|
|
1610
|
+
...acc,
|
|
1611
|
+
[type]: true
|
|
1612
|
+
}), {});
|
|
1613
|
+
if (symbolIds.length > 0) {
|
|
1614
|
+
for (const symbolId of symbolIds) {
|
|
1615
|
+
const refSymbol = refBySymbolId[symbolId];
|
|
1616
|
+
const refSymbolDefinition = (_b = refSymbol == null ? void 0 : refSymbol.definitions) == null ? void 0 : _b[0];
|
|
1617
|
+
const ctx = refSymbol == null ? void 0 : refSymbol.context;
|
|
1618
|
+
if (refSymbolDefinition) {
|
|
1619
|
+
unionTypeStringsMap[ctx.symbolName] = false;
|
|
1620
|
+
const propProperties = [];
|
|
1621
|
+
const prop = {
|
|
1622
|
+
name: ctx.symbolName || "",
|
|
1623
|
+
type: ctx.symbolName || "",
|
|
1624
|
+
description: refSymbol.description || "",
|
|
1625
|
+
properties: propProperties,
|
|
1626
|
+
symbolDef: {
|
|
1627
|
+
id: symbolId,
|
|
1628
|
+
canonical: ""
|
|
1629
|
+
// TODO: support canonical in the future
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
if (refSymbolDefinition.properties.length) {
|
|
1633
|
+
for (const prop2 of refSymbolDefinition.properties) {
|
|
1634
|
+
const resolvedProp = resolveProperty(
|
|
1635
|
+
refBySymbolId,
|
|
1636
|
+
prop2,
|
|
1637
|
+
options
|
|
1638
|
+
);
|
|
1639
|
+
propProperties.push(resolvedProp);
|
|
1640
|
+
}
|
|
1641
|
+
} else if (refSymbolDefinition.rootProperty) {
|
|
1642
|
+
const resolvedProp = resolveProperty(
|
|
1643
|
+
refBySymbolId,
|
|
1644
|
+
refSymbolDefinition.rootProperty,
|
|
1645
|
+
options
|
|
1646
|
+
);
|
|
1647
|
+
const shouldMergeUnion = resolvedProp.type === import_uniform2.DEFINED_DEFINITION_PROPERTY_TYPE.UNION && ((_c = resolvedProp.ofProperty) == null ? void 0 : _c.type) && !((_d = resolvedProp.properties) == null ? void 0 : _d.length);
|
|
1648
|
+
if (shouldMergeUnion) {
|
|
1649
|
+
prop.ofProperty = resolvedProp.ofProperty;
|
|
1650
|
+
} else {
|
|
1651
|
+
prop.ofProperty = resolvedProp;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
properties.push(prop);
|
|
1655
|
+
if (!prop.description) {
|
|
1656
|
+
prop.description = refSymbol.description || "";
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
for (const type of Object.keys(unionTypeStringsMap)) {
|
|
1662
|
+
const ok = unionTypeStringsMap[type];
|
|
1663
|
+
if (!ok) {
|
|
1664
|
+
continue;
|
|
1665
|
+
}
|
|
1666
|
+
properties.push({
|
|
1667
|
+
name: type,
|
|
1668
|
+
type,
|
|
1669
|
+
description: "",
|
|
1670
|
+
properties: []
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
return properties;
|
|
1674
|
+
}
|
|
1675
|
+
function isResolveUnionRef(property) {
|
|
1676
|
+
var _a;
|
|
1677
|
+
const symbolId = (_a = property == null ? void 0 : property.symbolDef) == null ? void 0 : _a.id;
|
|
1678
|
+
const symbolIsArr = Array.isArray(symbolId) && symbolId.length;
|
|
1679
|
+
if (symbolIsArr) {
|
|
1680
|
+
return true;
|
|
1681
|
+
}
|
|
1682
|
+
const hasUnionString = property.type && property.type.includes("|");
|
|
1683
|
+
if (hasUnionString) {
|
|
1684
|
+
const literalValues = isLiteralValues(property.type);
|
|
1685
|
+
if (literalValues) {
|
|
1686
|
+
return false;
|
|
1687
|
+
}
|
|
1688
|
+
return true;
|
|
1689
|
+
}
|
|
1690
|
+
return false;
|
|
1691
|
+
}
|
|
1692
|
+
function isLiteralValues(type) {
|
|
1693
|
+
const types = type.split("|").map((t) => t.trim());
|
|
1694
|
+
return types.every(
|
|
1695
|
+
(t) => t.startsWith('"') && t.endsWith('"') || t.startsWith("'") && t.endsWith("'")
|
|
1696
|
+
);
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
// packages/ts/index.ts
|
|
1700
|
+
var importedFiles = /* @__PURE__ */ new Set();
|
|
1701
|
+
async function sourcesToUniformV2(root, entryPoints) {
|
|
1702
|
+
var _a;
|
|
1703
|
+
const commonOptions = {
|
|
1704
|
+
// entryPoints,
|
|
1705
|
+
// entryPointStrategy: TypeDoc.EntryPointStrategy.Packages,
|
|
1706
|
+
exclude: ["**/*.test.ts", "**/*.test.tsx"],
|
|
1707
|
+
// @ts-ignore // TODO: for some reason on build types mismatch
|
|
1708
|
+
excludePrivate: true,
|
|
1709
|
+
// @ts-ignore
|
|
1710
|
+
excludeProtected: true,
|
|
1711
|
+
// @ts-ignore
|
|
1712
|
+
excludeExternals: true,
|
|
1713
|
+
// @ts-ignore
|
|
1714
|
+
includeVersion: true,
|
|
1715
|
+
// @ts-ignore
|
|
1716
|
+
// hideGenerator: true,
|
|
1717
|
+
// @ts-ignore
|
|
1718
|
+
skipErrorChecking: true,
|
|
1719
|
+
// @ts-ignore
|
|
1720
|
+
sort: ["source-order"],
|
|
1721
|
+
// @ts-ignore
|
|
1722
|
+
sortEntryPoints: false
|
|
1723
|
+
};
|
|
1724
|
+
const options = {
|
|
1725
|
+
...commonOptions
|
|
1726
|
+
};
|
|
1727
|
+
const everySingleFile = entryPoints == null ? void 0 : entryPoints.every((ep) => !!path2.extname(ep));
|
|
1728
|
+
if (everySingleFile) {
|
|
1729
|
+
entryPoints.map((ep) => {
|
|
1730
|
+
findImports(root, path2.resolve(root, ep));
|
|
1731
|
+
});
|
|
1732
|
+
const fileImported = Array.from(importedFiles) || [];
|
|
1733
|
+
options.entryPoints = [
|
|
1734
|
+
...(_a = [
|
|
1735
|
+
...entryPoints,
|
|
1736
|
+
...fileImported
|
|
1737
|
+
]) == null ? void 0 : _a.map((ep) => path2.resolve(root, ep))
|
|
1738
|
+
];
|
|
1739
|
+
} else {
|
|
1740
|
+
options.entryPointStrategy = TypeDoc.EntryPointStrategy.Packages;
|
|
1741
|
+
options.entryPoints = entryPoints;
|
|
1742
|
+
options.packageOptions = {
|
|
1743
|
+
...commonOptions
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
const app = await TypeDoc.Application.bootstrapWithPlugins(options);
|
|
1747
|
+
const project = await app.convert();
|
|
1748
|
+
if (!project) {
|
|
1749
|
+
console.error("Failed to generate documentation.");
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
const jsonOutput = await app.serializer.projectToObject(project, root);
|
|
1753
|
+
const projectJson = jsonOutput;
|
|
1754
|
+
if (!projectJson.schemaVersion || !projectJson.children || !projectJson.children.length) {
|
|
1755
|
+
console.error("Failed to generate documentation.");
|
|
1756
|
+
return;
|
|
1757
|
+
}
|
|
1758
|
+
const references = typedocToUniform(root, projectJson);
|
|
1759
|
+
if (!references) {
|
|
1760
|
+
console.error("Failed to generate documentation.");
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
return {
|
|
1764
|
+
references,
|
|
1765
|
+
projectJson
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
function findImports(root, file, seen = /* @__PURE__ */ new Set()) {
|
|
1769
|
+
if (seen.has(file)) return;
|
|
1770
|
+
seen.add(file);
|
|
1771
|
+
const source = import_typescript.default.createSourceFile(
|
|
1772
|
+
file,
|
|
1773
|
+
import_typescript.default.sys.readFile(file) || "",
|
|
1774
|
+
import_typescript.default.ScriptTarget.Latest,
|
|
1775
|
+
true
|
|
1776
|
+
);
|
|
1777
|
+
for (const stmt of source.statements) {
|
|
1778
|
+
if (import_typescript.default.isImportDeclaration(stmt) && stmt.moduleSpecifier) {
|
|
1779
|
+
const importPath = stmt.moduleSpecifier.getText().replace(/['"]/g, "");
|
|
1780
|
+
if (importPath.startsWith(".")) {
|
|
1781
|
+
const resolved = (0, import_path.resolve)(file, "..", importPath + ".ts");
|
|
1782
|
+
const relativePath = path2.relative(root, resolved);
|
|
1783
|
+
importedFiles.add(relativePath);
|
|
1784
|
+
findImports(root, resolved, seen);
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1790
|
+
0 && (module.exports = {
|
|
1791
|
+
sourcesToUniformV2,
|
|
1792
|
+
uniformToMiniUniform
|
|
1793
|
+
});
|
|
1794
|
+
//# sourceMappingURL=ts.cjs.map
|