@storybook/angular-vite 11.0.0-beta.1 → 11.0.0-beta.2
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/_browser-chunks/{chunk-IEOSIOYC.js → chunk-FDLKT4EQ.js} +39 -5
- package/dist/_browser-chunks/{chunk-GCT6OYDT.js → chunk-JSKZYOEY.js} +1 -1
- package/dist/_browser-chunks/{chunk-VFDWJHES.js → chunk-OAG3JRJQ.js} +3 -3
- package/dist/_browser-chunks/{chunk-RMTRNQGG.js → chunk-VA3FEKPB.js} +39 -3
- package/dist/_node-chunks/{chunk-MJSL2O6Q.js → chunk-2F3CYJX5.js} +6 -6
- package/dist/_node-chunks/{chunk-77GXSRPT.js → chunk-ETGWD5QX.js} +6 -6
- package/dist/_node-chunks/{story-docs-template-analysis-SKEZCPXI.js → chunk-VQ2WVY73.js} +52 -23
- package/dist/_node-chunks/{chunk-HKTBFY7T.js → chunk-WCYA5VMZ.js} +7 -7
- package/dist/_node-chunks/story-docs-template-analysis-65HGKMRZ.js +19 -0
- package/dist/builders/build-storybook/index.js +8 -8
- package/dist/builders/start-storybook/index.js +8 -8
- package/dist/client/config.js +2 -2
- package/dist/client/docs/config.js +2 -2
- package/dist/client/index.js +4 -4
- package/dist/docgen/docgen-worker.js +1651 -196
- package/dist/index.js +4 -4
- package/dist/node/index.js +6 -6
- package/dist/node/vitest.js +6 -6
- package/dist/preset.js +254 -137
- package/package.json +6 -5
|
@@ -1,46 +1,63 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_yl4v0bl5wmj from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_yl4v0bl5wmj from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_yl4v0bl5wmj from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_yl4v0bl5wmj.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_yl4v0bl5wmj.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_yl4v0bl5wmj.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
resolveStoryComponent
|
|
14
|
-
} from "../_node-chunks/chunk-
|
|
14
|
+
} from "../_node-chunks/chunk-2F3CYJX5.js";
|
|
15
15
|
|
|
16
16
|
// src/docgen/docgen-worker.ts
|
|
17
17
|
import {
|
|
18
18
|
getStoryImportPathFromEntry as getStoryImportPathFromEntry2,
|
|
19
|
-
loadTypeScriptCompilerApi,
|
|
20
19
|
STORY_FILE_TEST_REGEXP
|
|
21
20
|
} from "storybook/internal/common";
|
|
22
|
-
import { logger as
|
|
21
|
+
import { logger as logger6 } from "storybook/internal/node-logger";
|
|
23
22
|
|
|
24
23
|
// ../../lib/angular-cm/dist/index.js
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
24
|
+
import CJS_COMPAT_NODE_URL_i5q7k0g6kk from "node:url";
|
|
25
|
+
import CJS_COMPAT_NODE_PATH_i5q7k0g6kk from "node:path";
|
|
26
|
+
import CJS_COMPAT_NODE_MODULE_i5q7k0g6kk from "node:module";
|
|
28
27
|
import { isInNodeModules } from "storybook/internal/common";
|
|
29
28
|
import {
|
|
30
29
|
ComponentMetaManager,
|
|
31
30
|
parseTsconfigCommandLine
|
|
32
31
|
} from "storybook/internal/component-meta";
|
|
33
|
-
import
|
|
32
|
+
import CJS_COMPAT_NODE_URL_6lg7c74mo832 from "node:url";
|
|
33
|
+
import CJS_COMPAT_NODE_PATH_6lg7c74mo832 from "node:path";
|
|
34
|
+
import CJS_COMPAT_NODE_MODULE_6lg7c74mo832 from "node:module";
|
|
35
|
+
import CJS_COMPAT_NODE_URL_6lg7c74mo83 from "node:url";
|
|
36
|
+
import CJS_COMPAT_NODE_PATH_6lg7c74mo83 from "node:path";
|
|
37
|
+
import CJS_COMPAT_NODE_MODULE_6lg7c74mo83 from "node:module";
|
|
38
|
+
import "storybook/internal/common";
|
|
39
|
+
import "storybook/internal/server-errors";
|
|
40
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
41
|
+
import {
|
|
42
|
+
filterSourceFilePaths
|
|
43
|
+
} from "storybook/internal/component-meta";
|
|
44
|
+
import { statSync as statSync2 } from "node:fs";
|
|
45
|
+
import { logger } from "storybook/internal/node-logger";
|
|
46
|
+
import { slash } from "storybook/internal/common";
|
|
47
|
+
import { isInNodeModules as isInNodeModules2 } from "storybook/internal/common";
|
|
48
|
+
import {
|
|
49
|
+
extractComponentJsDocInfo
|
|
50
|
+
} from "storybook/internal/component-meta";
|
|
51
|
+
import { logger as logger4 } from "storybook/internal/node-logger";
|
|
52
|
+
import { logger as logger3 } from "storybook/internal/node-logger";
|
|
53
|
+
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
54
|
+
import { slash as slash2 } from "storybook/internal/common";
|
|
34
55
|
import {
|
|
35
|
-
extractComponentJsDocInfo,
|
|
36
56
|
ProgramBackedProject,
|
|
37
57
|
ProjectFileTracker
|
|
38
58
|
} from "storybook/internal/component-meta";
|
|
39
|
-
import { logger as logger3 } from "storybook/internal/node-logger";
|
|
40
59
|
import * as path from "node:path";
|
|
41
|
-
import
|
|
42
|
-
import { logger } from "storybook/internal/node-logger";
|
|
43
|
-
var __filename = CJS_COMPAT_NODE_URL_q6p8mh80nmb.fileURLToPath(import.meta.url), __dirname = CJS_COMPAT_NODE_PATH_q6p8mh80nmb.dirname(__filename), require2 = CJS_COMPAT_NODE_MODULE_q6p8mh80nmb.createRequire(import.meta.url), resolvedSymbol = (ctx, node) => {
|
|
60
|
+
var __filename = CJS_COMPAT_NODE_URL_i5q7k0g6kk.fileURLToPath(import.meta.url), __dirname = CJS_COMPAT_NODE_PATH_i5q7k0g6kk.dirname(__filename), require2 = CJS_COMPAT_NODE_MODULE_i5q7k0g6kk.createRequire(import.meta.url), resolvedSymbol = (ctx, node) => {
|
|
44
61
|
let symbol = ctx.checker.getSymbolAtLocation(node);
|
|
45
62
|
return symbol && symbol.flags & ctx.ts.SymbolFlags.Alias ? ctx.checker.getAliasedSymbol(symbol) : symbol;
|
|
46
63
|
}, resolvedNameSymbol = (ctx, name) => {
|
|
@@ -58,15 +75,15 @@ var __filename = CJS_COMPAT_NODE_URL_q6p8mh80nmb.fileURLToPath(import.meta.url),
|
|
|
58
75
|
cleaned.shift();
|
|
59
76
|
return cleaned.join(`
|
|
60
77
|
`);
|
|
61
|
-
}, rawJsDocComment = (sourceText, jsDoc) => {
|
|
78
|
+
}, rawJsDocComment = (ts, sourceText, jsDoc) => {
|
|
62
79
|
let end = jsDoc.tags?.length ? jsDoc.tags[0].pos : jsDoc.end;
|
|
63
|
-
return sourceText.slice(jsDoc
|
|
80
|
+
return sourceText.slice(ts.getJSDocStart(jsDoc), end).replace(/^\/\*\*/, "").replace(/\*\/$/, "");
|
|
64
81
|
}, rawTagComment = (ts, sourceText, tag) => {
|
|
65
|
-
let start;
|
|
66
|
-
return
|
|
82
|
+
let start, seeReference = ts.isJSDocSeeTag(tag) ? ts.getSeeTagReference(tag) : void 0;
|
|
83
|
+
return seeReference ? start = seeReference.pos : tag.comment !== void 0 && (start = ts.getJSDocTagCommentStart(tag)), start === void 0 ? void 0 : cleanCommentText(sourceText.slice(start, tag.end)).trimEnd();
|
|
67
84
|
};
|
|
68
85
|
function getJsDocDescription(ts, node) {
|
|
69
|
-
let sourceText = node.getSourceFile().text, jsDoc = ts.getJSDocCommentsAndTags(node).filter((doc) => ts.isJSDoc(doc)).at(-1), text = jsDoc?.comment === void 0 ? void 0 : cleanCommentText(rawJsDocComment(sourceText, jsDoc));
|
|
86
|
+
let sourceText = node.getSourceFile().text, jsDoc = ts.getJSDocCommentsAndTags(node).filter((doc) => ts.isJSDoc(doc)).at(-1), text = jsDoc?.comment === void 0 ? void 0 : cleanCommentText(rawJsDocComment(ts, sourceText, jsDoc));
|
|
70
87
|
text = text?.replace(/^(?:[ \t]*\*+[ \t]*\n)+/, "").replace(/^[ \t]*\*+[ \t]*$/, "");
|
|
71
88
|
let descriptionTag = ts.getJSDocTags(node).find((tag) => tag.tagName.text === "description" && tag.comment !== void 0);
|
|
72
89
|
descriptionTag && (text = cleanCommentText(sourceText.slice(descriptionTag.tagName.end, descriptionTag.end)));
|
|
@@ -131,7 +148,7 @@ var DETAIL_LINE_CAP = 20, isBareTypeName = (type) => /^[A-Za-z_$][\w$]*$/.test(t
|
|
|
131
148
|
for (let member of members) {
|
|
132
149
|
if (!ts.isPropertySignature(member) || member.type === void 0)
|
|
133
150
|
continue;
|
|
134
|
-
let optional = member
|
|
151
|
+
let optional = ts.hasQuestionToken(member) ? "?" : "";
|
|
135
152
|
lines.push(
|
|
136
153
|
describedLine(
|
|
137
154
|
context,
|
|
@@ -299,7 +316,7 @@ ${detailLines(lines).join(`
|
|
|
299
316
|
case "composite":
|
|
300
317
|
return initializer.text;
|
|
301
318
|
}
|
|
302
|
-
}, extractDefaultValue = (property,
|
|
319
|
+
}, extractDefaultValue = (property, logger52) => {
|
|
303
320
|
try {
|
|
304
321
|
let authored = authoredDefault(property);
|
|
305
322
|
if (authored !== void 0)
|
|
@@ -307,14 +324,14 @@ ${detailLines(lines).join(`
|
|
|
307
324
|
if (property.initializer === void 0)
|
|
308
325
|
return;
|
|
309
326
|
if (property.initializer.kind === "expression") {
|
|
310
|
-
|
|
327
|
+
logger52.debug(
|
|
311
328
|
`${property.name}: non-literal default '${property.initializer.text}' not shown`
|
|
312
329
|
);
|
|
313
330
|
return;
|
|
314
331
|
}
|
|
315
332
|
return analyzerDefault(property.initializer);
|
|
316
333
|
} catch {
|
|
317
|
-
|
|
334
|
+
logger52.debug(`Error extracting ${property.name}: ${property.initializer?.text}`);
|
|
318
335
|
return;
|
|
319
336
|
}
|
|
320
337
|
}, extractMemberJsDocTags = (member) => {
|
|
@@ -336,7 +353,7 @@ ${detailLines(lines).join(`
|
|
|
336
353
|
let input = inputsByName.get(item.name);
|
|
337
354
|
return input?.line !== void 0 && input.line === item.line;
|
|
338
355
|
});
|
|
339
|
-
}, extractArgTypesFromData = (componentData, { metadataJson, propsTable, logger:
|
|
356
|
+
}, extractArgTypesFromData = (componentData, { metadataJson, propsTable, logger: logger52 = NOOP_LOGGER, context }) => {
|
|
340
357
|
let sectionToItems = {}, componentClasses = propsTable === "inputs" ? ["inputsClass"] : ["propertiesClass", "methodsClass", "inputsClass", "outputsClass"], memberKeys = isDirectiveEntry(componentData) ? componentClasses : ["properties", "methods"], modelProperties = getModelProperties(componentData), modelPropertyNames = new Set(modelProperties.map((item) => item.name));
|
|
341
358
|
memberKeys.forEach((key) => {
|
|
342
359
|
readMembers(componentData, key).forEach((item) => {
|
|
@@ -344,12 +361,12 @@ ${detailLines(lines).join(`
|
|
|
344
361
|
if (key === "outputsClass" && !isMethod(item) && modelPropertyNames.has(item.name))
|
|
345
362
|
return;
|
|
346
363
|
if (!documentedInMode(item, section2, propsTable)) {
|
|
347
|
-
|
|
364
|
+
logger52.debug(
|
|
348
365
|
`${componentData.name}.${item.name} left out of the props table: propsTable '${propsTable}'`
|
|
349
366
|
);
|
|
350
367
|
return;
|
|
351
368
|
}
|
|
352
|
-
let defaultValue = isMethod(item) ? void 0 : extractDefaultValue(item,
|
|
369
|
+
let defaultValue = isMethod(item) ? void 0 : extractDefaultValue(item, logger52), { type: declaredType, detail } = isMethod(item) || section2 !== "inputs" && section2 !== "properties" ? { type: { name: "other", value: "void" } } : extractType(item, defaultValue, metadataJson, componentData.file, context), type = section2 === "inputs" && !isMethod(item) && isRequired(item) ? { ...declaredType, required: !0 } : declaredType, action = section2 === "outputs" ? { action: item.name } : {}, jsDocTags = extractMemberJsDocTags(item), argType = {
|
|
353
370
|
name: item.name,
|
|
354
371
|
description: item.rawdescription || item.description,
|
|
355
372
|
type,
|
|
@@ -388,7 +405,1041 @@ ${detailLines(lines).join(`
|
|
|
388
405
|
argTypes[argType.name] = argType;
|
|
389
406
|
});
|
|
390
407
|
}), argTypes;
|
|
391
|
-
},
|
|
408
|
+
}, __filename = CJS_COMPAT_NODE_URL_6lg7c74mo83.fileURLToPath(import.meta.url), __dirname = CJS_COMPAT_NODE_PATH_6lg7c74mo83.dirname(__filename), require22 = CJS_COMPAT_NODE_MODULE_6lg7c74mo83.createRequire(import.meta.url), _lazyMatch = () => {
|
|
409
|
+
var __lib__ = (() => {
|
|
410
|
+
var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
|
|
411
|
+
for (var n in e) m(r, n, { get: e[n], enumerable: !0 });
|
|
412
|
+
}, H = (r, e, n, a) => {
|
|
413
|
+
if (e && typeof e == "object" || typeof e == "function") for (let t of G(e)) !T.call(r, t) && t !== n && m(r, t, { get: () => e[t], enumerable: !(a = V(e, t)) || a.enumerable });
|
|
414
|
+
return r;
|
|
415
|
+
}, J = (r) => H(m({}, "__esModule", { value: !0 }), r), w = {};
|
|
416
|
+
q(w, { default: () => re });
|
|
417
|
+
var A = (r) => Array.isArray(r), d = (r) => typeof r == "function", Q = (r) => r.length === 0, W = (r) => typeof r == "number", K = (r) => typeof r == "object" && r !== null, X = (r) => r instanceof RegExp, b = (r) => typeof r == "string", h = (r) => r === void 0, Y = (r) => {
|
|
418
|
+
let e = /* @__PURE__ */ new Map();
|
|
419
|
+
return (n) => {
|
|
420
|
+
let a = e.get(n);
|
|
421
|
+
if (a) return a;
|
|
422
|
+
let t = r(n);
|
|
423
|
+
return e.set(n, t), t;
|
|
424
|
+
};
|
|
425
|
+
}, rr = (r, e, n = {}) => {
|
|
426
|
+
let a = { cache: {}, input: r, index: 0, indexMax: 0, options: n, output: [] };
|
|
427
|
+
if (v(e)(a) && a.index === r.length) return a.output;
|
|
428
|
+
throw new Error(`Failed to parse at index ${a.indexMax}`);
|
|
429
|
+
}, i = (r, e) => A(r) ? er(r, e) : b(r) ? ar(r, e) : nr(r, e), er = (r, e) => {
|
|
430
|
+
let n = {};
|
|
431
|
+
for (let a of r) {
|
|
432
|
+
if (a.length !== 1) throw new Error(`Invalid character: "${a}"`);
|
|
433
|
+
let t = a.charCodeAt(0);
|
|
434
|
+
n[t] = !0;
|
|
435
|
+
}
|
|
436
|
+
return (a) => {
|
|
437
|
+
let t = a.index, o = a.input;
|
|
438
|
+
for (; a.index < o.length && o.charCodeAt(a.index) in n; ) a.index += 1;
|
|
439
|
+
let u = a.index;
|
|
440
|
+
if (u > t) {
|
|
441
|
+
if (!h(e) && !a.options.silent) {
|
|
442
|
+
let s = a.input.slice(t, u), c = d(e) ? e(s, o, String(t)) : e;
|
|
443
|
+
h(c) || a.output.push(c);
|
|
444
|
+
}
|
|
445
|
+
a.indexMax = Math.max(a.indexMax, a.index);
|
|
446
|
+
}
|
|
447
|
+
return !0;
|
|
448
|
+
};
|
|
449
|
+
}, nr = (r, e) => {
|
|
450
|
+
let n = r.source, a = r.flags.replace(/y|$/, "y"), t = new RegExp(n, a);
|
|
451
|
+
return g((o) => {
|
|
452
|
+
t.lastIndex = o.index;
|
|
453
|
+
let u = t.exec(o.input);
|
|
454
|
+
if (u) {
|
|
455
|
+
if (!h(e) && !o.options.silent) {
|
|
456
|
+
let s = d(e) ? e(...u, o.input, String(o.index)) : e;
|
|
457
|
+
h(s) || o.output.push(s);
|
|
458
|
+
}
|
|
459
|
+
return o.index += u[0].length, o.indexMax = Math.max(o.indexMax, o.index), !0;
|
|
460
|
+
} else return !1;
|
|
461
|
+
});
|
|
462
|
+
}, ar = (r, e) => (n) => {
|
|
463
|
+
if (n.input.startsWith(r, n.index)) {
|
|
464
|
+
if (!h(e) && !n.options.silent) {
|
|
465
|
+
let t = d(e) ? e(r, n.input, String(n.index)) : e;
|
|
466
|
+
h(t) || n.output.push(t);
|
|
467
|
+
}
|
|
468
|
+
return n.index += r.length, n.indexMax = Math.max(n.indexMax, n.index), !0;
|
|
469
|
+
} else return !1;
|
|
470
|
+
}, C = (r, e, n, a) => {
|
|
471
|
+
let t = v(r);
|
|
472
|
+
return g(_(M((o) => {
|
|
473
|
+
let u = 0;
|
|
474
|
+
for (; u < n; ) {
|
|
475
|
+
let s = o.index;
|
|
476
|
+
if (!t(o) || (u += 1, o.index === s)) break;
|
|
477
|
+
}
|
|
478
|
+
return u >= e;
|
|
479
|
+
})));
|
|
480
|
+
}, tr = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, 1 / 0), x = (r, e) => {
|
|
481
|
+
let n = r.map(v);
|
|
482
|
+
return g(_(M((a) => {
|
|
483
|
+
for (let t = 0, o = n.length; t < o; t++) if (!n[t](a)) return !1;
|
|
484
|
+
return !0;
|
|
485
|
+
})));
|
|
486
|
+
}, l = (r, e) => {
|
|
487
|
+
let n = r.map(v);
|
|
488
|
+
return g(_((a) => {
|
|
489
|
+
for (let t = 0, o = n.length; t < o; t++) if (n[t](a)) return !0;
|
|
490
|
+
return !1;
|
|
491
|
+
}));
|
|
492
|
+
}, M = (r, e = !1) => {
|
|
493
|
+
let n = v(r);
|
|
494
|
+
return (a) => {
|
|
495
|
+
let t = a.index, o = a.output.length, u = n(a);
|
|
496
|
+
return (!u || e) && (a.index = t, a.output.length !== o && (a.output.length = o)), u;
|
|
497
|
+
};
|
|
498
|
+
}, _ = (r, e) => v(r), g = /* @__PURE__ */ (() => {
|
|
499
|
+
let r = 0;
|
|
500
|
+
return (e) => {
|
|
501
|
+
let n = v(e), a = r += 1;
|
|
502
|
+
return (t) => {
|
|
503
|
+
var o;
|
|
504
|
+
if (t.options.memoization === !1) return n(t);
|
|
505
|
+
let u = t.index, s = (o = t.cache)[a] || (o[a] = /* @__PURE__ */ new Map()), c = s.get(u);
|
|
506
|
+
if (c === !1) return !1;
|
|
507
|
+
if (W(c)) return t.index = c, !0;
|
|
508
|
+
if (c) return t.index = c.index, c.output?.length && t.output.push(...c.output), !0;
|
|
509
|
+
{
|
|
510
|
+
let Z = t.output.length;
|
|
511
|
+
if (n(t)) {
|
|
512
|
+
let D = t.index, U = t.output.length;
|
|
513
|
+
if (U > Z) {
|
|
514
|
+
let ee = t.output.slice(Z, U);
|
|
515
|
+
s.set(u, { index: D, output: ee });
|
|
516
|
+
} else s.set(u, D);
|
|
517
|
+
return !0;
|
|
518
|
+
} else return s.set(u, !1), !1;
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
};
|
|
522
|
+
})(), E = (r) => {
|
|
523
|
+
let e;
|
|
524
|
+
return (n) => (e || (e = v(r())), e(n));
|
|
525
|
+
}, v = Y((r) => {
|
|
526
|
+
if (d(r)) return Q(r) ? E(r) : r;
|
|
527
|
+
if (b(r) || X(r)) return i(r);
|
|
528
|
+
if (A(r)) return x(r);
|
|
529
|
+
if (K(r)) return l(Object.values(r));
|
|
530
|
+
throw new Error("Invalid rule");
|
|
531
|
+
}), P = "abcdefghijklmnopqrstuvwxyz", ir = (r) => {
|
|
532
|
+
let e = "";
|
|
533
|
+
for (; r > 0; ) {
|
|
534
|
+
let n = (r - 1) % 26;
|
|
535
|
+
e = P[n] + e, r = Math.floor((r - 1) / 26);
|
|
536
|
+
}
|
|
537
|
+
return e;
|
|
538
|
+
}, O = (r) => {
|
|
539
|
+
let e = 0;
|
|
540
|
+
for (let n = 0, a = r.length; n < a; n++) e = e * 26 + P.indexOf(r[n]) + 1;
|
|
541
|
+
return e;
|
|
542
|
+
}, S = (r, e) => {
|
|
543
|
+
if (e < r) return S(e, r);
|
|
544
|
+
let n = [];
|
|
545
|
+
for (; r <= e; ) n.push(r++);
|
|
546
|
+
return n;
|
|
547
|
+
}, or = (r, e, n) => S(r, e).map((a) => String(a).padStart(n, "0")), R = (r, e) => S(O(r), O(e)).map(ir), p = (r) => r, z = (r) => ur((e) => rr(e, r, { memoization: !1 }).join("")), ur = (r) => {
|
|
548
|
+
let e = {};
|
|
549
|
+
return (n) => e[n] ?? (e[n] = r(n));
|
|
550
|
+
}, sr = i(/^\*\*\/\*$/, ".*"), cr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (r, e, n) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}`), lr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (r, e, n, a) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}(?:${a.replaceAll(",", "|").replaceAll(".", "\\.")})`), y = i(/\\./, p), pr = i(/[$.*+?^(){}[\]\|]/, (r) => `\\${r}`), vr = i(/./, p), hr = i(/^(?:!!)*!(.*)$/, (r, e) => `(?!^${L(e)}$).*?`), dr = i(/^(!!)+/, ""), fr = l([hr, dr]), xr = i(/\/(\*\*\/)+/, "(?:/.+/|/)"), gr = i(/^(\*\*\/)+/, "(?:^|.*/)"), mr = i(/\/(\*\*)$/, "(?:/.*|$)"), _r = i(/\*\*/, ".*"), j = l([xr, gr, mr, _r]), Sr = i(/\*\/(?!\*\*\/)/, "[^/]*/"), yr = i(/\*/, "[^/]*"), N = l([Sr, yr]), k = i("?", "[^/]"), $r = i("[", p), wr = i("]", p), Ar = i(/[!^]/, "^/"), br = i(/[a-z]-[a-z]|[0-9]-[0-9]/i, p), Cr = i(/[$.*+?^(){}[\|]/, (r) => `\\${r}`), Mr = i(/[^\]]/, p), Er = l([y, Cr, br, Mr]), B = x([$r, tr(Ar), f(Er), wr]), Pr = i("{", "(?:"), Or = i("}", ")"), Rr = i(/(\d+)\.\.(\d+)/, (r, e, n) => or(+e, +n, Math.min(e.length, n.length)).join("|")), zr = i(/([a-z]+)\.\.([a-z]+)/, (r, e, n) => R(e, n).join("|")), jr = i(/([A-Z]+)\.\.([A-Z]+)/, (r, e, n) => R(e.toLowerCase(), n.toLowerCase()).join("|").toUpperCase()), Nr = l([Rr, zr, jr]), I = x([Pr, Nr, Or]), kr = i("{", "(?:"), Br = i("}", ")"), Ir = i(",", "|"), Fr = i(/[$.*+?^(){[\]\|]/, (r) => `\\${r}`), Lr = i(/[^}]/, p), Zr = E(() => F), Dr = l([j, N, k, B, I, Zr, y, Fr, Ir, Lr]), F = x([kr, f(Dr), Br]), Ur = f(l([sr, cr, lr, fr, j, N, k, B, I, F, y, pr, vr])), Vr = Ur, Gr = z(Vr), L = Gr, Tr = i(/\\./, p), qr = i(/./, p), Hr = i(/\*\*\*+/, "*"), Jr = i(/([^/{[(!])\*\*/, (r, e) => `${e}*`), Qr = i(/(^|.)\*\*(?=[^*/)\]}])/, (r, e) => `${e}*`), Wr = f(l([Tr, Hr, Jr, Qr, qr])), Kr = Wr, Xr = z(Kr), Yr = Xr, $ = (r, e) => {
|
|
551
|
+
let n = Array.isArray(r) ? r : [r];
|
|
552
|
+
if (!n.length) return !1;
|
|
553
|
+
let a = n.map($.compile), t = n.every((s) => /(\/(?:\*\*)?|\[\/\])$/.test(s)), o = e.replace(/[\\\/]+/g, "/").replace(/\/$/, t ? "/" : "");
|
|
554
|
+
return a.some((s) => s.test(o));
|
|
555
|
+
};
|
|
556
|
+
$.compile = (r) => new RegExp(`^${L(Yr(r))}$`, "s");
|
|
557
|
+
var re = $;
|
|
558
|
+
return J(w);
|
|
559
|
+
})();
|
|
560
|
+
return __lib__.default || __lib__;
|
|
561
|
+
}, _match, zeptomatch = (path2, pattern) => (_match || (_match = _lazyMatch(), _lazyMatch = null), _match(path2, pattern)), _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
562
|
+
function normalizeWindowsPath(input = "") {
|
|
563
|
+
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
564
|
+
}
|
|
565
|
+
var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/, _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/, _EXTNAME_RE = /.(\.[^./]+|\.)$/, _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/, sep = "/", normalize = function(path2) {
|
|
566
|
+
if (path2.length === 0)
|
|
567
|
+
return ".";
|
|
568
|
+
path2 = normalizeWindowsPath(path2);
|
|
569
|
+
let isUNCPath = path2.match(_UNC_REGEX), isPathAbsolute = isAbsolute(path2), trailingSeparator = path2[path2.length - 1] === "/";
|
|
570
|
+
return path2 = normalizeString(path2, !isPathAbsolute), path2.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path2 += "/"), _DRIVE_LETTER_RE.test(path2) && (path2 += "/"), isUNCPath ? isPathAbsolute ? `//${path2}` : `//./${path2}` : isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2);
|
|
571
|
+
}, join = function(...segments) {
|
|
572
|
+
let path2 = "";
|
|
573
|
+
for (let seg of segments)
|
|
574
|
+
if (seg)
|
|
575
|
+
if (path2.length > 0) {
|
|
576
|
+
let pathTrailing = path2[path2.length - 1] === "/", segLeading = seg[0] === "/";
|
|
577
|
+
pathTrailing && segLeading ? path2 += seg.slice(1) : path2 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
578
|
+
} else
|
|
579
|
+
path2 += seg;
|
|
580
|
+
return normalize(path2);
|
|
581
|
+
};
|
|
582
|
+
function cwd() {
|
|
583
|
+
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
584
|
+
}
|
|
585
|
+
var resolve = function(...arguments_) {
|
|
586
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
587
|
+
let resolvedPath = "", resolvedAbsolute = !1;
|
|
588
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
589
|
+
let path2 = index >= 0 ? arguments_[index] : cwd();
|
|
590
|
+
!path2 || path2.length === 0 || (resolvedPath = `${path2}/${resolvedPath}`, resolvedAbsolute = isAbsolute(path2));
|
|
591
|
+
}
|
|
592
|
+
return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
|
|
593
|
+
};
|
|
594
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
595
|
+
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
596
|
+
for (let index = 0; index <= path2.length; ++index) {
|
|
597
|
+
if (index < path2.length)
|
|
598
|
+
char = path2[index];
|
|
599
|
+
else {
|
|
600
|
+
if (char === "/")
|
|
601
|
+
break;
|
|
602
|
+
char = "/";
|
|
603
|
+
}
|
|
604
|
+
if (char === "/") {
|
|
605
|
+
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
|
606
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
607
|
+
if (res.length > 2) {
|
|
608
|
+
let lastSlashIndex = res.lastIndexOf("/");
|
|
609
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
|
610
|
+
continue;
|
|
611
|
+
} else if (res.length > 0) {
|
|
612
|
+
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
|
617
|
+
} else
|
|
618
|
+
res.length > 0 ? res += `/${path2.slice(lastSlash + 1, index)}` : res = path2.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
|
619
|
+
lastSlash = index, dots = 0;
|
|
620
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
|
621
|
+
}
|
|
622
|
+
return res;
|
|
623
|
+
}
|
|
624
|
+
var isAbsolute = function(p) {
|
|
625
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
626
|
+
}, toNamespacedPath = function(p) {
|
|
627
|
+
return normalizeWindowsPath(p);
|
|
628
|
+
}, extname = function(p) {
|
|
629
|
+
if (p === "..") return "";
|
|
630
|
+
let match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
631
|
+
return match && match[1] || "";
|
|
632
|
+
}, relative = function(from, to) {
|
|
633
|
+
let _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/"), _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
634
|
+
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0])
|
|
635
|
+
return _to.join("/");
|
|
636
|
+
let _fromCopy = [..._from];
|
|
637
|
+
for (let segment of _fromCopy) {
|
|
638
|
+
if (_to[0] !== segment)
|
|
639
|
+
break;
|
|
640
|
+
_from.shift(), _to.shift();
|
|
641
|
+
}
|
|
642
|
+
return [..._from.map(() => ".."), ..._to].join("/");
|
|
643
|
+
}, dirname2 = function(p) {
|
|
644
|
+
let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
645
|
+
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
646
|
+
}, format = function(p) {
|
|
647
|
+
let ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "", segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
|
|
648
|
+
Boolean
|
|
649
|
+
);
|
|
650
|
+
return normalizeWindowsPath(
|
|
651
|
+
p.root ? resolve(...segments) : segments.join("/")
|
|
652
|
+
);
|
|
653
|
+
}, basename = function(p, extension) {
|
|
654
|
+
let segments = normalizeWindowsPath(p).split("/"), lastSegment = "";
|
|
655
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
656
|
+
let val = segments[i];
|
|
657
|
+
if (val) {
|
|
658
|
+
lastSegment = val;
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
663
|
+
}, parse = function(p) {
|
|
664
|
+
let root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "", base = basename(p), extension = extname(base);
|
|
665
|
+
return {
|
|
666
|
+
root,
|
|
667
|
+
dir: dirname2(p),
|
|
668
|
+
base,
|
|
669
|
+
ext: extension,
|
|
670
|
+
name: base.slice(0, base.length - extension.length)
|
|
671
|
+
};
|
|
672
|
+
}, matchesGlob = (path2, pattern) => zeptomatch(pattern, normalize(path2)), _path = {
|
|
673
|
+
__proto__: null,
|
|
674
|
+
basename,
|
|
675
|
+
dirname: dirname2,
|
|
676
|
+
extname,
|
|
677
|
+
format,
|
|
678
|
+
isAbsolute,
|
|
679
|
+
join,
|
|
680
|
+
matchesGlob,
|
|
681
|
+
normalize,
|
|
682
|
+
normalizeString,
|
|
683
|
+
parse,
|
|
684
|
+
relative,
|
|
685
|
+
resolve,
|
|
686
|
+
sep,
|
|
687
|
+
toNamespacedPath
|
|
688
|
+
}, delimiter = globalThis.process?.platform === "win32" ? ";" : ":", _platforms = { posix: void 0, win32: void 0 }, mix = (del = delimiter) => new Proxy(_path, {
|
|
689
|
+
get(_, prop) {
|
|
690
|
+
return prop === "delimiter" ? del : prop === "posix" ? posix : prop === "win32" ? win32 : _platforms[prop] || _path[prop];
|
|
691
|
+
}
|
|
692
|
+
}), posix = mix(":"), win32 = mix(";"), __filename2 = CJS_COMPAT_NODE_URL_6lg7c74mo832.fileURLToPath(import.meta.url), __dirname2 = CJS_COMPAT_NODE_PATH_6lg7c74mo832.dirname(__filename2), require3 = CJS_COMPAT_NODE_MODULE_6lg7c74mo832.createRequire(import.meta.url), DOCGEN_NODE_GUARDS = [
|
|
693
|
+
"isArrayLiteralExpression",
|
|
694
|
+
"isArrayTypeNode",
|
|
695
|
+
"isArrowFunction",
|
|
696
|
+
"isAsExpression",
|
|
697
|
+
"isAwaitExpression",
|
|
698
|
+
"isBigIntLiteral",
|
|
699
|
+
"isBinaryExpression",
|
|
700
|
+
"isBindingElement",
|
|
701
|
+
"isBlock",
|
|
702
|
+
"isCallExpression",
|
|
703
|
+
"isClassDeclaration",
|
|
704
|
+
"isClassLike",
|
|
705
|
+
"isComputedPropertyName",
|
|
706
|
+
"isConditionalExpression",
|
|
707
|
+
"isConstructorDeclaration",
|
|
708
|
+
"isConstructorTypeNode",
|
|
709
|
+
"isEnumDeclaration",
|
|
710
|
+
"isEnumMember",
|
|
711
|
+
"isExportAssignment",
|
|
712
|
+
"isExportDeclaration",
|
|
713
|
+
"isExpressionStatement",
|
|
714
|
+
"isExpressionWithTypeArguments",
|
|
715
|
+
"isFunctionDeclaration",
|
|
716
|
+
"isFunctionExpression",
|
|
717
|
+
"isFunctionTypeNode",
|
|
718
|
+
"isGetAccessor",
|
|
719
|
+
"isGetAccessorDeclaration",
|
|
720
|
+
"isIdentifier",
|
|
721
|
+
"isImportDeclaration",
|
|
722
|
+
"isImportSpecifier",
|
|
723
|
+
"isIndexedAccessTypeNode",
|
|
724
|
+
"isInterfaceDeclaration",
|
|
725
|
+
"isIntersectionTypeNode",
|
|
726
|
+
"isJSDoc",
|
|
727
|
+
"isJSDocSeeTag",
|
|
728
|
+
"isJsxOpeningElement",
|
|
729
|
+
"isJsxSelfClosingElement",
|
|
730
|
+
"isLiteralTypeNode",
|
|
731
|
+
"isMethodDeclaration",
|
|
732
|
+
"isNamedExports",
|
|
733
|
+
"isNamedImports",
|
|
734
|
+
"isNamespaceImport",
|
|
735
|
+
"isNewExpression",
|
|
736
|
+
"isNoSubstitutionTemplateLiteral",
|
|
737
|
+
"isNonNullExpression",
|
|
738
|
+
"isNumericLiteral",
|
|
739
|
+
"isObjectBindingPattern",
|
|
740
|
+
"isObjectLiteralExpression",
|
|
741
|
+
"isOmittedExpression",
|
|
742
|
+
"isParameter",
|
|
743
|
+
"isParenthesizedExpression",
|
|
744
|
+
"isParenthesizedTypeNode",
|
|
745
|
+
"isPrefixUnaryExpression",
|
|
746
|
+
"isPropertyAccessExpression",
|
|
747
|
+
"isPropertyAssignment",
|
|
748
|
+
"isPropertyDeclaration",
|
|
749
|
+
"isPropertySignature",
|
|
750
|
+
"isQualifiedName",
|
|
751
|
+
"isSatisfiesExpression",
|
|
752
|
+
"isSetAccessor",
|
|
753
|
+
"isSetAccessorDeclaration",
|
|
754
|
+
"isShorthandPropertyAssignment",
|
|
755
|
+
"isSourceFile",
|
|
756
|
+
"isSpreadAssignment",
|
|
757
|
+
"isSpreadElement",
|
|
758
|
+
"isStringLiteral",
|
|
759
|
+
"isStringLiteralLike",
|
|
760
|
+
"isTupleTypeNode",
|
|
761
|
+
"isTypeAliasDeclaration",
|
|
762
|
+
"isTypeAssertionExpression",
|
|
763
|
+
"isTypeLiteralNode",
|
|
764
|
+
"isTypeOperatorNode",
|
|
765
|
+
"isTypeParameterDeclaration",
|
|
766
|
+
"isTypeReferenceNode",
|
|
767
|
+
"isUnionTypeNode",
|
|
768
|
+
"isVariableDeclaration",
|
|
769
|
+
"isVariableStatement"
|
|
770
|
+
], compilerNodeAccessors = {
|
|
771
|
+
getTypeParameterDefault: (node) => node.default,
|
|
772
|
+
hasQuestionToken: (member) => "questionToken" in member && member.questionToken !== void 0,
|
|
773
|
+
getSeeTagReference: (tag) => tag.name,
|
|
774
|
+
getJSDocStart: (jsDoc) => jsDoc.pos,
|
|
775
|
+
getJSDocTagCommentStart: (tag) => (typeof tag.comment == "string" ? tag.getChildren().at(-1)?.end : tag.comment?.pos) ?? tag.tagName.end
|
|
776
|
+
};
|
|
777
|
+
function createCompilerDocgenTypeScript(typescript) {
|
|
778
|
+
let members = {
|
|
779
|
+
...compilerNodeAccessors,
|
|
780
|
+
printNode: (node, visit) => {
|
|
781
|
+
let result = typescript.transform(node, [
|
|
782
|
+
(context) => (root) => {
|
|
783
|
+
let visitChildren = (child) => typescript.visitEachChild(
|
|
784
|
+
child,
|
|
785
|
+
(grandchild) => visit(grandchild, visitChildren),
|
|
786
|
+
context
|
|
787
|
+
);
|
|
788
|
+
return visit(root, visitChildren);
|
|
789
|
+
}
|
|
790
|
+
]);
|
|
791
|
+
try {
|
|
792
|
+
return typescript.createPrinter({ removeComments: !0 }).printNode(typescript.EmitHint.Unspecified, result.transformed[0], node.getSourceFile());
|
|
793
|
+
} finally {
|
|
794
|
+
result.dispose();
|
|
795
|
+
}
|
|
796
|
+
},
|
|
797
|
+
createSourceFile: (fileName, text) => typescript.createSourceFile(fileName, text, typescript.ScriptTarget.Latest, !0),
|
|
798
|
+
getEmptyObjectType: (checker) => checker.getTypeFromTypeNode(typescript.factory.createTypeLiteralNode([]))
|
|
799
|
+
};
|
|
800
|
+
return Object.create(
|
|
801
|
+
typescript,
|
|
802
|
+
Object.fromEntries(Object.entries(members).map(([name, value]) => [name, { value }]))
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
var getOrCompute = (map, key, compute) => {
|
|
806
|
+
let value = map.get(key);
|
|
807
|
+
return value === void 0 && !map.has(key) && (value = compute(), map.set(key, value)), value;
|
|
808
|
+
}, CallCache = class {
|
|
809
|
+
constructor() {
|
|
810
|
+
this.methods = /* @__PURE__ */ new Map();
|
|
811
|
+
}
|
|
812
|
+
answer(method, args, ask) {
|
|
813
|
+
let level = getOrCompute(this.methods, method, () => ({}));
|
|
814
|
+
for (let arg of args)
|
|
815
|
+
level = arg !== null && typeof arg == "object" ? getOrCompute(level.objects ??= /* @__PURE__ */ new WeakMap(), arg, () => ({})) : getOrCompute(level.values ??= /* @__PURE__ */ new Map(), arg, () => ({}));
|
|
816
|
+
return level.answered || (level.answer = ask(), level.answered = !0), level.answer;
|
|
817
|
+
}
|
|
818
|
+
}, textPart = (text) => ({
|
|
819
|
+
kind: "text",
|
|
820
|
+
text
|
|
821
|
+
}), SymbolFacade = class {
|
|
822
|
+
constructor(native, facades) {
|
|
823
|
+
this.native = native, this.facades = facades;
|
|
824
|
+
}
|
|
825
|
+
get name() {
|
|
826
|
+
return this.native.name;
|
|
827
|
+
}
|
|
828
|
+
get escapedName() {
|
|
829
|
+
return this.native.escapedName;
|
|
830
|
+
}
|
|
831
|
+
get flags() {
|
|
832
|
+
return this.native.flags;
|
|
833
|
+
}
|
|
834
|
+
getFlags() {
|
|
835
|
+
return this.flags;
|
|
836
|
+
}
|
|
837
|
+
getName() {
|
|
838
|
+
return this.native.name;
|
|
839
|
+
}
|
|
840
|
+
get valueDeclaration() {
|
|
841
|
+
return this.resolvedValueDeclaration === void 0 && (this.resolvedValueDeclaration = this.native.valueDeclaration?.resolve() ?? null), this.resolvedValueDeclaration ?? void 0;
|
|
842
|
+
}
|
|
843
|
+
get declarations() {
|
|
844
|
+
return this.getDeclarations();
|
|
845
|
+
}
|
|
846
|
+
getDeclarations() {
|
|
847
|
+
return this.resolvedDeclarations ??= this.native.declarations.flatMap((handle) => {
|
|
848
|
+
let node = handle.resolve();
|
|
849
|
+
return node ? [node] : [];
|
|
850
|
+
}), this.resolvedDeclarations;
|
|
851
|
+
}
|
|
852
|
+
getDocumentationComment() {
|
|
853
|
+
let text = this.facades.documentationComment(this.native);
|
|
854
|
+
return text ? [textPart(text)] : [];
|
|
855
|
+
}
|
|
856
|
+
getJsDocTags() {
|
|
857
|
+
return this.facades.jsDocTags(this.native).map(({ name, text }) => ({
|
|
858
|
+
name,
|
|
859
|
+
text: text === void 0 ? void 0 : [textPart(text)]
|
|
860
|
+
}));
|
|
861
|
+
}
|
|
862
|
+
}, TypeFacade = class {
|
|
863
|
+
constructor(native, facades) {
|
|
864
|
+
this.native = native, this.facades = facades;
|
|
865
|
+
}
|
|
866
|
+
get flags() {
|
|
867
|
+
return this.native.flags;
|
|
868
|
+
}
|
|
869
|
+
getFlags() {
|
|
870
|
+
return this.flags;
|
|
871
|
+
}
|
|
872
|
+
get symbol() {
|
|
873
|
+
return this.getSymbol();
|
|
874
|
+
}
|
|
875
|
+
get aliasSymbol() {
|
|
876
|
+
return this.facades.symbol(this.native.getAliasSymbol());
|
|
877
|
+
}
|
|
878
|
+
get objectFlags() {
|
|
879
|
+
return this.native.objectFlags;
|
|
880
|
+
}
|
|
881
|
+
getSymbol() {
|
|
882
|
+
return this.facades.symbol(this.native.getSymbol());
|
|
883
|
+
}
|
|
884
|
+
get value() {
|
|
885
|
+
return this.native.value;
|
|
886
|
+
}
|
|
887
|
+
get types() {
|
|
888
|
+
return this.facades.memberTypes(this.native).map((type) => this.facades.type(type));
|
|
889
|
+
}
|
|
890
|
+
isUnion() {
|
|
891
|
+
return this.native.isUnionType();
|
|
892
|
+
}
|
|
893
|
+
isClassOrInterface() {
|
|
894
|
+
return this.native.isClassOrInterface();
|
|
895
|
+
}
|
|
896
|
+
isIntersection() {
|
|
897
|
+
return this.native.isIntersectionType();
|
|
898
|
+
}
|
|
899
|
+
isStringLiteral() {
|
|
900
|
+
return this.native.isStringLiteralType();
|
|
901
|
+
}
|
|
902
|
+
isNumberLiteral() {
|
|
903
|
+
return this.native.isNumberLiteralType();
|
|
904
|
+
}
|
|
905
|
+
getProperty(name) {
|
|
906
|
+
return this.facades.symbol(this.native.getProperty(name));
|
|
907
|
+
}
|
|
908
|
+
getProperties() {
|
|
909
|
+
return this.properties ??= this.facades.symbols(this.native.getProperties()), this.properties;
|
|
910
|
+
}
|
|
911
|
+
getApparentProperties() {
|
|
912
|
+
return this.apparentProperties ??= this.facades.symbols(this.native.getApparentProperties()), this.apparentProperties;
|
|
913
|
+
}
|
|
914
|
+
getCallSignatures() {
|
|
915
|
+
return this.facades.callSignatures(this.native).map((signature) => this.facades.signature(signature));
|
|
916
|
+
}
|
|
917
|
+
getConstructSignatures() {
|
|
918
|
+
return this.constructSignatures ??= this.native.getConstructSignatures().map((signature) => this.facades.signature(signature)), this.constructSignatures;
|
|
919
|
+
}
|
|
920
|
+
getConstraint() {
|
|
921
|
+
return this.facades.type(this.facades.checker.getBaseConstraintOfType(this.native));
|
|
922
|
+
}
|
|
923
|
+
}, SignatureFacade = class {
|
|
924
|
+
constructor(native, facades) {
|
|
925
|
+
this.native = native, this.facades = facades;
|
|
926
|
+
}
|
|
927
|
+
get parameters() {
|
|
928
|
+
return this.getParameters();
|
|
929
|
+
}
|
|
930
|
+
get declaration() {
|
|
931
|
+
return this.native.declaration?.resolve();
|
|
932
|
+
}
|
|
933
|
+
getParameters() {
|
|
934
|
+
return this.resolvedParameters ??= this.native.getParameters().map((symbol) => this.facades.symbol(symbol)), this.resolvedParameters;
|
|
935
|
+
}
|
|
936
|
+
getReturnType() {
|
|
937
|
+
return this.facades.type(this.facades.returnType(this.native));
|
|
938
|
+
}
|
|
939
|
+
}, EmptyObjectTypeFacade = class {
|
|
940
|
+
constructor() {
|
|
941
|
+
this.native = void 0, this.flags = 0, this.getFlags = () => 0, this.getSymbol = () => {
|
|
942
|
+
}, this.types = [], this.isUnion = () => !1, this.isIntersection = () => !1, this.isStringLiteral = () => !1, this.isNumberLiteral = () => !1, this.getProperty = () => {
|
|
943
|
+
}, this.getProperties = () => [], this.getApparentProperties = () => [], this.getCallSignatures = () => [], this.getConstructSignatures = () => [], this.getConstraint = () => {
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
}, CACHED_QUERIES = [
|
|
947
|
+
"getAliasedSymbol",
|
|
948
|
+
"getBaseTypeOfLiteralType",
|
|
949
|
+
"getBaseTypes",
|
|
950
|
+
"getDeclaredTypeOfSymbol",
|
|
951
|
+
"getExportsOfModule",
|
|
952
|
+
"getMergedSymbol",
|
|
953
|
+
"getPropertyOfType",
|
|
954
|
+
"getResolvedSignature",
|
|
955
|
+
"getShorthandAssignmentValueSymbol",
|
|
956
|
+
"getSignatureFromDeclaration",
|
|
957
|
+
"getSymbolAtLocation",
|
|
958
|
+
"getTypeArguments",
|
|
959
|
+
"getTypeAtLocation",
|
|
960
|
+
"getTypeOfSymbol",
|
|
961
|
+
"resolveName"
|
|
962
|
+
];
|
|
963
|
+
function createDocgenChecker(facades) {
|
|
964
|
+
let { checker } = facades, calls = new CallCache(), unwrapSymbol = (symbol) => symbol.native, unwrapType = (type) => type.native, unwrapNativeType = (type) => {
|
|
965
|
+
let native = unwrapType(type);
|
|
966
|
+
if (!native)
|
|
967
|
+
throw new Error("The checker cannot take the empty object type here");
|
|
968
|
+
return native;
|
|
969
|
+
}, asNode = (node) => node, docgenChecker = {
|
|
970
|
+
getAliasedSymbol: (symbol) => facades.symbol(checker.getAliasedSymbol(unwrapSymbol(symbol))),
|
|
971
|
+
getBaseTypeOfLiteralType: (type) => facades.type(checker.getBaseTypeOfLiteralType(unwrapNativeType(type))),
|
|
972
|
+
getBaseTypes: (type) => checker.getBaseTypes(unwrapNativeType(type)).map((base) => facades.type(base)),
|
|
973
|
+
getDeclaredTypeOfSymbol: (symbol) => facades.type(checker.getDeclaredTypeOfSymbol(unwrapSymbol(symbol))),
|
|
974
|
+
getExportsOfModule: (symbol) => checker.getExportsOfModule(unwrapSymbol(symbol)).map((exported) => facades.symbol(exported)),
|
|
975
|
+
getMergedSymbol: (symbol) => facades.symbol(checker.getMergedSymbol(unwrapSymbol(symbol))),
|
|
976
|
+
getPropertyOfType: (type, name) => {
|
|
977
|
+
let native = unwrapType(type);
|
|
978
|
+
return native && facades.symbol(checker.getPropertyOfType(native, name));
|
|
979
|
+
},
|
|
980
|
+
getResolvedSignature: (node) => facades.signature(checker.getResolvedSignature(asNode(node))),
|
|
981
|
+
getShorthandAssignmentValueSymbol: (node) => node ? facades.symbol(checker.getShorthandAssignmentValueSymbol(asNode(node))) : void 0,
|
|
982
|
+
getSignatureFromDeclaration: (node) => {
|
|
983
|
+
let signature = checker.getSignatureFromDeclaration(asNode(node));
|
|
984
|
+
return signature && facades.signature(signature);
|
|
985
|
+
},
|
|
986
|
+
getSymbolAtLocation: (node) => facades.symbol(checker.getSymbolAtLocation(asNode(node))),
|
|
987
|
+
getTypeArguments: (type) => checker.getTypeArguments(unwrapNativeType(type)).map((argument) => facades.type(argument)),
|
|
988
|
+
getTypeAtLocation: (node) => facades.type(checker.getTypeAtLocation(asNode(node))),
|
|
989
|
+
getTypeOfSymbol: (symbol) => facades.type(checker.getTypeOfSymbol(unwrapSymbol(symbol))),
|
|
990
|
+
getTypeOfSymbolAtLocation: (symbol, node) => facades.type(facades.typeOfSymbolAtLocation(unwrapSymbol(symbol), asNode(node))),
|
|
991
|
+
getVoidType: () => facades.type(checker.getVoidType()),
|
|
992
|
+
// The native API takes `meaning` before `location`.
|
|
993
|
+
resolveName: (name, location, meaning, excludeGlobals) => facades.symbol(
|
|
994
|
+
checker.resolveName(name, meaning, location && asNode(location), excludeGlobals)
|
|
995
|
+
),
|
|
996
|
+
typeToString: (type, enclosingDeclaration, flags) => {
|
|
997
|
+
let native = unwrapType(type);
|
|
998
|
+
return native ? enclosingDeclaration === void 0 && flags === void 0 ? facades.typeToString(native) : calls.answer(
|
|
999
|
+
"typeToString",
|
|
1000
|
+
[native, enclosingDeclaration, flags],
|
|
1001
|
+
() => checker.typeToString(
|
|
1002
|
+
native,
|
|
1003
|
+
enclosingDeclaration && asNode(enclosingDeclaration),
|
|
1004
|
+
flags
|
|
1005
|
+
)
|
|
1006
|
+
) : "{}";
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
for (let method of CACHED_QUERIES) {
|
|
1010
|
+
let ask = docgenChecker[method];
|
|
1011
|
+
docgenChecker[method] = (...args) => calls.answer(method, args, () => ask(...args));
|
|
1012
|
+
}
|
|
1013
|
+
return docgenChecker;
|
|
1014
|
+
}
|
|
1015
|
+
var NATIVE_FACADES = /* @__PURE__ */ Symbol("nativeFacades"), NativeFacades = class {
|
|
1016
|
+
constructor(project, typescript) {
|
|
1017
|
+
this.project = project, this.typescript = typescript, this.symbolFacades = /* @__PURE__ */ new WeakMap(), this.typeFacades = /* @__PURE__ */ new WeakMap(), this.signatureFacades = /* @__PURE__ */ new WeakMap(), this.emptyObjectType = new EmptyObjectTypeFacade(), this.groupOf = /* @__PURE__ */ new WeakMap(), this.tags = /* @__PURE__ */ new WeakMap(), this.docs = /* @__PURE__ */ new WeakMap(), this.typeAtLocation = /* @__PURE__ */ new WeakMap(), this.typeText = /* @__PURE__ */ new WeakMap(), this.members = /* @__PURE__ */ new WeakMap(), this.typesAtDeclarationFetched = /* @__PURE__ */ new WeakSet(), this.callSignaturesOf = /* @__PURE__ */ new WeakMap(), this.returnTypeOf = /* @__PURE__ */ new WeakMap(), this.checker = project.checker;
|
|
1018
|
+
}
|
|
1019
|
+
static of(checker) {
|
|
1020
|
+
let facades = checker[NATIVE_FACADES];
|
|
1021
|
+
if (!facades)
|
|
1022
|
+
throw new Error("The checker was not created by NativeFacades.createChecker");
|
|
1023
|
+
return facades;
|
|
1024
|
+
}
|
|
1025
|
+
createChecker() {
|
|
1026
|
+
return this.docgenChecker || (this.docgenChecker = createDocgenChecker(this), Object.defineProperty(this.docgenChecker, NATIVE_FACADES, { value: this })), this.docgenChecker;
|
|
1027
|
+
}
|
|
1028
|
+
symbol(native) {
|
|
1029
|
+
return native ? getOrCompute(
|
|
1030
|
+
this.symbolFacades,
|
|
1031
|
+
native,
|
|
1032
|
+
() => new SymbolFacade(native, this)
|
|
1033
|
+
) : void 0;
|
|
1034
|
+
}
|
|
1035
|
+
symbols(natives) {
|
|
1036
|
+
return this.prefetchDocs(natives), natives.map((native) => this.symbol(native));
|
|
1037
|
+
}
|
|
1038
|
+
type(native) {
|
|
1039
|
+
return native ? getOrCompute(
|
|
1040
|
+
this.typeFacades,
|
|
1041
|
+
native,
|
|
1042
|
+
() => new TypeFacade(native, this)
|
|
1043
|
+
) : void 0;
|
|
1044
|
+
}
|
|
1045
|
+
signature(native) {
|
|
1046
|
+
return getOrCompute(
|
|
1047
|
+
this.signatureFacades,
|
|
1048
|
+
native,
|
|
1049
|
+
() => new SignatureFacade(native, this)
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
1052
|
+
getEmptyObjectType() {
|
|
1053
|
+
return this.emptyObjectType;
|
|
1054
|
+
}
|
|
1055
|
+
jsDocTags(symbol) {
|
|
1056
|
+
return getOrCompute(this.tags, symbol, () => this.checker.getJsDocTagsOfSymbol(symbol));
|
|
1057
|
+
}
|
|
1058
|
+
documentationComment(symbol) {
|
|
1059
|
+
return getOrCompute(
|
|
1060
|
+
this.docs,
|
|
1061
|
+
symbol,
|
|
1062
|
+
() => this.checker.getDocumentationCommentOfSymbol(symbol)
|
|
1063
|
+
);
|
|
1064
|
+
}
|
|
1065
|
+
memberTypes(type) {
|
|
1066
|
+
return getOrCompute(
|
|
1067
|
+
this.members,
|
|
1068
|
+
type,
|
|
1069
|
+
() => type.isUnionType() || type.isIntersectionType() ? type.getTypes() : []
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
typeToString(type) {
|
|
1073
|
+
return getOrCompute(this.typeText, type, () => this.checker.typeToString(type));
|
|
1074
|
+
}
|
|
1075
|
+
callSignatures(type) {
|
|
1076
|
+
return getOrCompute(this.callSignaturesOf, type, () => type.getCallSignatures());
|
|
1077
|
+
}
|
|
1078
|
+
returnType(signature) {
|
|
1079
|
+
return getOrCompute(this.returnTypeOf, signature, () => signature.getReturnType());
|
|
1080
|
+
}
|
|
1081
|
+
typeOfSymbolAtLocation(symbol, location) {
|
|
1082
|
+
let byLocation = this.typesAt(location), cached = byLocation.get(symbol);
|
|
1083
|
+
if (cached)
|
|
1084
|
+
return cached;
|
|
1085
|
+
let group = this.groupOf.get(symbol);
|
|
1086
|
+
return group && group.length > 1 && (this.isDeclarationOf(symbol, location) ? this.prefetchTypesAtDeclarations(group) : this.prefetchTypes(
|
|
1087
|
+
group.filter((member) => !byLocation.has(member)),
|
|
1088
|
+
location,
|
|
1089
|
+
byLocation
|
|
1090
|
+
)), getOrCompute(
|
|
1091
|
+
byLocation,
|
|
1092
|
+
symbol,
|
|
1093
|
+
() => this.checker.getTypeOfSymbolAtLocation(symbol, location)
|
|
1094
|
+
);
|
|
1095
|
+
}
|
|
1096
|
+
typesAt(location) {
|
|
1097
|
+
return getOrCompute(this.typeAtLocation, location, () => /* @__PURE__ */ new Map());
|
|
1098
|
+
}
|
|
1099
|
+
isDeclarationOf(symbol, location) {
|
|
1100
|
+
return !!this.symbol(symbol).getDeclarations()?.includes(location);
|
|
1101
|
+
}
|
|
1102
|
+
prefetchDocs(symbols) {
|
|
1103
|
+
let missing = symbols.filter((symbol) => !this.docs.has(symbol));
|
|
1104
|
+
for (let symbol of symbols)
|
|
1105
|
+
this.groupOf.set(symbol, symbols);
|
|
1106
|
+
if (missing.length < 2)
|
|
1107
|
+
return;
|
|
1108
|
+
let { checker } = this, [docs, tags] = this.typescript.batch(
|
|
1109
|
+
missing.map((symbol) => checker.getDocumentationCommentOfSymbol.gen(symbol)),
|
|
1110
|
+
missing.map((symbol) => checker.getJsDocTagsOfSymbol.gen(symbol))
|
|
1111
|
+
);
|
|
1112
|
+
missing.forEach((symbol, index) => {
|
|
1113
|
+
this.docs.set(symbol, docs[index]), this.tags.set(symbol, tags[index]);
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
prefetchTypes(symbols, location, byLocation) {
|
|
1117
|
+
if (symbols.length < 2)
|
|
1118
|
+
return;
|
|
1119
|
+
let { checker } = this, [types] = this.typescript.batch(
|
|
1120
|
+
symbols.map((symbol) => checker.getTypeOfSymbolAtLocation.gen(symbol, location))
|
|
1121
|
+
);
|
|
1122
|
+
symbols.forEach((symbol, index) => byLocation.set(symbol, types[index])), this.prefetchTexts(types);
|
|
1123
|
+
}
|
|
1124
|
+
prefetchTypesAtDeclarations(symbols) {
|
|
1125
|
+
let located = symbols.flatMap((symbol) => {
|
|
1126
|
+
if (this.typesAtDeclarationFetched.has(symbol))
|
|
1127
|
+
return [];
|
|
1128
|
+
this.typesAtDeclarationFetched.add(symbol);
|
|
1129
|
+
let declaration = this.symbol(symbol).getDeclarations()?.[0];
|
|
1130
|
+
return declaration ? [{ symbol, location: declaration }] : [];
|
|
1131
|
+
});
|
|
1132
|
+
if (located.length < 2)
|
|
1133
|
+
return;
|
|
1134
|
+
let { checker } = this, [types] = this.typescript.batch(
|
|
1135
|
+
located.map(({ symbol, location }) => checker.getTypeOfSymbolAtLocation.gen(symbol, location))
|
|
1136
|
+
);
|
|
1137
|
+
located.forEach(
|
|
1138
|
+
({ symbol, location }, index) => this.typesAt(location).set(symbol, types[index])
|
|
1139
|
+
), this.prefetchTexts(types), this.prefetchSignatures(types);
|
|
1140
|
+
}
|
|
1141
|
+
prefetchSignatures(types) {
|
|
1142
|
+
let objects = [...new Set(types)].filter(
|
|
1143
|
+
(type) => type.flags & this.typescript.TypeFlags.Object && !this.callSignaturesOf.has(type)
|
|
1144
|
+
);
|
|
1145
|
+
if (objects.length < 2)
|
|
1146
|
+
return;
|
|
1147
|
+
let [signatureLists] = this.typescript.batch(
|
|
1148
|
+
objects.map((type) => type.getCallSignatures.gen())
|
|
1149
|
+
);
|
|
1150
|
+
objects.forEach((type, index) => this.callSignaturesOf.set(type, signatureLists[index]));
|
|
1151
|
+
let signatures = signatureLists.flat().filter((signature) => !this.returnTypeOf.has(signature)), [returnTypes] = this.typescript.batch(
|
|
1152
|
+
signatures.map((signature) => signature.getReturnType.gen())
|
|
1153
|
+
);
|
|
1154
|
+
signatures.forEach((signature, index) => this.returnTypeOf.set(signature, returnTypes[index]));
|
|
1155
|
+
}
|
|
1156
|
+
prefetchTexts(types) {
|
|
1157
|
+
let { checker } = this, untexted = [...new Set(types)].filter((type) => !this.typeText.has(type)), unions = untexted.filter(
|
|
1158
|
+
(type) => (type.isUnionType() || type.isIntersectionType()) && !this.members.has(type)
|
|
1159
|
+
), [texts, members] = this.typescript.batch(
|
|
1160
|
+
untexted.map((type) => checker.typeToString.gen(type)),
|
|
1161
|
+
unions.map((type) => type.getTypes.gen())
|
|
1162
|
+
);
|
|
1163
|
+
untexted.forEach((type, index) => this.typeText.set(type, texts[index])), unions.forEach((type, index) => this.members.set(type, members[index] ?? []));
|
|
1164
|
+
}
|
|
1165
|
+
}, NATIVE_GUARD_NAMES = {
|
|
1166
|
+
isGetAccessor: "isGetAccessorDeclaration",
|
|
1167
|
+
isParameter: "isParameterDeclaration",
|
|
1168
|
+
isPropertySignature: "isPropertySignatureDeclaration",
|
|
1169
|
+
isSetAccessor: "isSetAccessorDeclaration",
|
|
1170
|
+
isTypeAssertionExpression: "isTypeAssertion"
|
|
1171
|
+
}, composedGuards = (ast) => ({
|
|
1172
|
+
isClassLike: (node) => ast.isClassDeclaration(node) || ast.isClassExpression(node),
|
|
1173
|
+
isStringLiteralLike: (node) => ast.isStringLiteral(node) || ast.isNoSubstitutionTemplateLiteral(node)
|
|
1174
|
+
}), nativeNodeAccessors = (ast) => ({
|
|
1175
|
+
getTypeParameterDefault: (node) => node.defaultType,
|
|
1176
|
+
hasQuestionToken: (member) => member.postfixToken?.kind === ast.SyntaxKind.QuestionToken,
|
|
1177
|
+
getSeeTagReference: (tag) => tag.nameExpression,
|
|
1178
|
+
// A JSDoc node starts at the trivia before it, comments included.
|
|
1179
|
+
getJSDocStart: (jsDoc) => {
|
|
1180
|
+
let sourceText = jsDoc.getSourceFile().text, at = jsDoc.pos;
|
|
1181
|
+
for (; at < sourceText.length && !sourceText.startsWith("/**", at); )
|
|
1182
|
+
if (sourceText.startsWith("//", at)) {
|
|
1183
|
+
let lineEnd = sourceText.indexOf(`
|
|
1184
|
+
`, at);
|
|
1185
|
+
at = lineEnd < 0 ? sourceText.length : lineEnd + 1;
|
|
1186
|
+
} else if (sourceText.startsWith("/*", at)) {
|
|
1187
|
+
let close = sourceText.indexOf("*/", at + 2);
|
|
1188
|
+
at = close < 0 ? sourceText.length : close + 2;
|
|
1189
|
+
} else
|
|
1190
|
+
at += 1;
|
|
1191
|
+
return at;
|
|
1192
|
+
},
|
|
1193
|
+
getJSDocTagCommentStart: (tag) => {
|
|
1194
|
+
let comment = tag.comment, commentStart = typeof comment == "string" ? tag.end : comment.pos, end = tag.tagName.end, afterPart = (part) => {
|
|
1195
|
+
part.end <= commentStart && (end = Math.max(end, part.end));
|
|
1196
|
+
};
|
|
1197
|
+
return tag.forEachChild(afterPart, (parts) => parts.forEach(afterPart)), end;
|
|
1198
|
+
}
|
|
1199
|
+
});
|
|
1200
|
+
function createNativeSystem() {
|
|
1201
|
+
return {
|
|
1202
|
+
fileExists: (path2) => {
|
|
1203
|
+
try {
|
|
1204
|
+
return statSync(path2).isFile();
|
|
1205
|
+
} catch {
|
|
1206
|
+
return !1;
|
|
1207
|
+
}
|
|
1208
|
+
},
|
|
1209
|
+
directoryExists: (path2) => {
|
|
1210
|
+
try {
|
|
1211
|
+
return statSync(path2).isDirectory();
|
|
1212
|
+
} catch {
|
|
1213
|
+
return !1;
|
|
1214
|
+
}
|
|
1215
|
+
},
|
|
1216
|
+
readFile: (path2) => {
|
|
1217
|
+
try {
|
|
1218
|
+
return readFileSync(path2, "utf-8");
|
|
1219
|
+
} catch {
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
},
|
|
1223
|
+
useCaseSensitiveFileNames: isCaseSensitiveFileSystem()
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
var isCaseSensitiveFileSystem = () => !existsSync(withSwappedCase(process.execPath)), withSwappedCase = (path2) => path2.replace(/\w/g, (character) => {
|
|
1227
|
+
let upper = character.toUpperCase();
|
|
1228
|
+
return character === upper ? character.toLowerCase() : upper;
|
|
1229
|
+
});
|
|
1230
|
+
function createNativeDocgenTypeScript({ sync, ast, factory }, api) {
|
|
1231
|
+
let leases = [], asNode = (node) => node, composed = composedGuards(ast);
|
|
1232
|
+
return {
|
|
1233
|
+
...Object.fromEntries(
|
|
1234
|
+
DOCGEN_NODE_GUARDS.map((name) => {
|
|
1235
|
+
let guard = composed[name] ?? ast[NATIVE_GUARD_NAMES[name] ?? name];
|
|
1236
|
+
if (typeof guard != "function")
|
|
1237
|
+
throw new Error(`typescript/ast has no node guard for ${name}`);
|
|
1238
|
+
return [name, (node) => guard(asNode(node))];
|
|
1239
|
+
})
|
|
1240
|
+
),
|
|
1241
|
+
...nativeNodeAccessors(ast),
|
|
1242
|
+
JsxEmit: sync.JsxEmit,
|
|
1243
|
+
ModuleKind: sync.ModuleKind,
|
|
1244
|
+
ModuleResolutionKind: sync.ModuleResolutionKind,
|
|
1245
|
+
ObjectFlags: sync.ObjectFlags,
|
|
1246
|
+
ScriptTarget: ast.ScriptTarget,
|
|
1247
|
+
SymbolFlags: sync.SymbolFlags,
|
|
1248
|
+
SyntaxKind: ast.SyntaxKind,
|
|
1249
|
+
TypeFlags: sync.TypeFlags,
|
|
1250
|
+
TypeFormatFlags: sync.TypeFormatFlags,
|
|
1251
|
+
factory: {
|
|
1252
|
+
createLiteralTypeNode: (literal) => factory.createLiteralTypeNode(asNode(literal)),
|
|
1253
|
+
createStringLiteral: (text) => factory.createStringLiteral(text, ast.TokenFlags.None)
|
|
1254
|
+
},
|
|
1255
|
+
sys: createNativeSystem(),
|
|
1256
|
+
canHaveDecorators: (node) => "modifiers" in node,
|
|
1257
|
+
canHaveModifiers: (node) => "modifiers" in node,
|
|
1258
|
+
getDecorators: (node) => node.modifiers?.filter(
|
|
1259
|
+
(modifier) => ast.isDecorator(asNode(modifier))
|
|
1260
|
+
),
|
|
1261
|
+
getJSDocCommentsAndTags: (node) => ast.getJSDocCommentsAndTags(asNode(node)),
|
|
1262
|
+
getJSDocTags: (node) => ast.getJSDocTags(asNode(node)),
|
|
1263
|
+
getLineAndCharacterOfPosition: (sourceFile, position) => sourceFile.getLineAndCharacterOfPosition(position),
|
|
1264
|
+
printNode: (node, visit) => {
|
|
1265
|
+
let visitChildren = (child) => ast.visitEachChild(
|
|
1266
|
+
asNode(child),
|
|
1267
|
+
(grandchild) => asNode(visit(grandchild, visitChildren))
|
|
1268
|
+
);
|
|
1269
|
+
return api.printer.printNode(asNode(visit(node, visitChildren)));
|
|
1270
|
+
},
|
|
1271
|
+
getModifiers: (node) => node.modifiers?.filter(
|
|
1272
|
+
(modifier) => ast.isModifier(asNode(modifier))
|
|
1273
|
+
),
|
|
1274
|
+
createSourceFile: (fileName, text) => {
|
|
1275
|
+
let lease = api.createSourceFile(fileName, text);
|
|
1276
|
+
return leases.push(lease), lease.sourceFile;
|
|
1277
|
+
},
|
|
1278
|
+
releaseSourceFiles: () => {
|
|
1279
|
+
for (let lease of leases)
|
|
1280
|
+
lease.dispose();
|
|
1281
|
+
leases = [];
|
|
1282
|
+
},
|
|
1283
|
+
batch: (first, second = []) => {
|
|
1284
|
+
if (first.length === 0 && second.length === 0)
|
|
1285
|
+
return [[], []];
|
|
1286
|
+
let [a, b] = api.batch(
|
|
1287
|
+
sync.all(...first),
|
|
1288
|
+
sync.all(...second)
|
|
1289
|
+
);
|
|
1290
|
+
return [a, b];
|
|
1291
|
+
},
|
|
1292
|
+
displayPartsToString: (parts) => (parts ?? []).map((part) => part.text).join(""),
|
|
1293
|
+
forEachChild: ((node, visitor, visitArray) => asNode(node).forEachChild(
|
|
1294
|
+
visitor,
|
|
1295
|
+
visitArray
|
|
1296
|
+
)),
|
|
1297
|
+
getEmptyObjectType: (checker) => NativeFacades.of(checker).getEmptyObjectType()
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
var NativeProject = class {
|
|
1301
|
+
constructor(api, typescript, commandLine, configFileName, getCommandLineFn) {
|
|
1302
|
+
this.api = api, this.typescript = typescript, this.commandLine = commandLine, this.configFileName = configFileName, this.getCommandLineFn = getCommandLineFn, this.fileMtimes = /* @__PURE__ */ new Map(), this.createdAt = Date.now(), this.disposed = !1, this.rootFiles = new Set(commandLine.fileNames), this.snapshot = api.createSnapshot({
|
|
1303
|
+
createPrograms: [this.programParams(this.rootFiles, commandLine)]
|
|
1304
|
+
});
|
|
1305
|
+
let program = this.snapshot.operation.createdPrograms?.[0];
|
|
1306
|
+
if (!program)
|
|
1307
|
+
throw this.snapshot.dispose(), new Error(`TypeScript created no program for ${configFileName ?? "inferred files"}`);
|
|
1308
|
+
this.project = program.getProject();
|
|
1309
|
+
}
|
|
1310
|
+
getCommandLine() {
|
|
1311
|
+
return this.commandLine;
|
|
1312
|
+
}
|
|
1313
|
+
hasSourceFile(fileName) {
|
|
1314
|
+
return this.project.program.getSourceFile(fileName) !== void 0;
|
|
1315
|
+
}
|
|
1316
|
+
getSourceFilePaths() {
|
|
1317
|
+
return filterSourceFilePaths(this.project.program.getSourceFileNames());
|
|
1318
|
+
}
|
|
1319
|
+
getSourceFile(fileName) {
|
|
1320
|
+
return this.project.program.getSourceFile(fileName);
|
|
1321
|
+
}
|
|
1322
|
+
ensureFiles(fileNames) {
|
|
1323
|
+
let missing = fileNames.filter(
|
|
1324
|
+
(fileName) => !this.rootFiles.has(fileName) && !this.hasSourceFile(fileName)
|
|
1325
|
+
);
|
|
1326
|
+
if (missing.length === 0)
|
|
1327
|
+
return;
|
|
1328
|
+
let rootFiles = /* @__PURE__ */ new Set([...this.rootFiles, ...missing]);
|
|
1329
|
+
this.replaceSnapshot(
|
|
1330
|
+
this.snapshot.update({
|
|
1331
|
+
reconfigurePrograms: [this.reconfigureParams(rootFiles, this.commandLine)]
|
|
1332
|
+
})
|
|
1333
|
+
), this.rootFiles = rootFiles;
|
|
1334
|
+
}
|
|
1335
|
+
onFilesChanged(changes) {
|
|
1336
|
+
if (!this.disposed)
|
|
1337
|
+
try {
|
|
1338
|
+
this.applyFileChanges(changes) && this.afterFilesChanged();
|
|
1339
|
+
} catch (error) {
|
|
1340
|
+
logger.debug(`[component-meta] Ignoring file changes for ${this.configFileName}: ${error}`);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
afterFilesChanged() {
|
|
1344
|
+
}
|
|
1345
|
+
dispose() {
|
|
1346
|
+
this.disposed || (this.disposed = !0, this.moduleResolver?.dispose(), this.snapshot.dispose());
|
|
1347
|
+
}
|
|
1348
|
+
ensureFresh(fileNames) {
|
|
1349
|
+
let changed = [], mtimes = /* @__PURE__ */ new Map();
|
|
1350
|
+
for (let fileName of new Set(fileNames)) {
|
|
1351
|
+
let mtime = modifiedTime(fileName);
|
|
1352
|
+
(this.fileMtimes.has(fileName) ? this.fileMtimes.get(fileName) !== mtime : mtime !== void 0 && mtime > this.createdAt) && changed.push(fileName), mtimes.set(fileName, mtime);
|
|
1353
|
+
}
|
|
1354
|
+
changed.length > 0 && this.replaceSnapshot(
|
|
1355
|
+
this.snapshot.update({ fileNotifications: { changed }, ensurePrograms: !0 })
|
|
1356
|
+
);
|
|
1357
|
+
for (let [fileName, mtime] of mtimes)
|
|
1358
|
+
this.fileMtimes.set(fileName, mtime);
|
|
1359
|
+
return changed.length > 0;
|
|
1360
|
+
}
|
|
1361
|
+
getChecker() {
|
|
1362
|
+
return this.facades ??= new NativeFacades(this.project, this.typescript), this.facades.createChecker();
|
|
1363
|
+
}
|
|
1364
|
+
resolveModule(importId, fromFile) {
|
|
1365
|
+
return this.getModuleResolver().resolveModuleName(importId, dirname2(fromFile), void 0, {
|
|
1366
|
+
snapshot: this.snapshot
|
|
1367
|
+
}).resolvedModule?.resolvedFileName;
|
|
1368
|
+
}
|
|
1369
|
+
applyFileChanges(changes) {
|
|
1370
|
+
let byType = (type) => changes.filter((change) => change.type === type).map((change) => change.filePath), created = byType("created"), deleted = byType("deleted"), changed = byType("changed"), known = changes.some((change) => this.hasSourceFile(change.filePath)), commandLine = this.commandLine, rootFiles = this.rootFiles;
|
|
1371
|
+
if ((created.length > 0 || deleted.length > 0) && this.getCommandLineFn) {
|
|
1372
|
+
commandLine = this.getCommandLineFn(), rootFiles = /* @__PURE__ */ new Set([...this.rootFiles, ...commandLine.fileNames]);
|
|
1373
|
+
for (let fileName of deleted)
|
|
1374
|
+
rootFiles.delete(fileName);
|
|
1375
|
+
}
|
|
1376
|
+
let rootsChanged = rootFiles.size !== this.rootFiles.size || [...rootFiles].some((fileName) => !this.rootFiles.has(fileName)), reachesProgram = known || rootsChanged || created.length > 0;
|
|
1377
|
+
if (reachesProgram) {
|
|
1378
|
+
this.replaceSnapshot(
|
|
1379
|
+
this.snapshot.update({
|
|
1380
|
+
fileNotifications: { changed, created, deleted },
|
|
1381
|
+
reconfigurePrograms: rootsChanged ? [this.reconfigureParams(rootFiles, commandLine)] : void 0,
|
|
1382
|
+
ensurePrograms: !0
|
|
1383
|
+
})
|
|
1384
|
+
);
|
|
1385
|
+
for (let fileName of [...changed, ...created])
|
|
1386
|
+
this.fileMtimes.set(fileName, modifiedTime(fileName));
|
|
1387
|
+
for (let fileName of deleted)
|
|
1388
|
+
this.fileMtimes.delete(fileName);
|
|
1389
|
+
}
|
|
1390
|
+
return commandLine !== this.commandLine && (this.commandLine = commandLine, this.rootFiles = rootFiles, this.moduleResolver?.dispose(), this.moduleResolver = void 0), reachesProgram;
|
|
1391
|
+
}
|
|
1392
|
+
programParams(rootFiles, commandLine) {
|
|
1393
|
+
let options = {
|
|
1394
|
+
projectReferences: commandLine.projectReferences?.map(({ path: path2 }) => ({ path: path2 }))
|
|
1395
|
+
};
|
|
1396
|
+
return { rootFiles: [...rootFiles], compilerOptions: commandLine.options, options };
|
|
1397
|
+
}
|
|
1398
|
+
reconfigureParams(rootFiles, commandLine) {
|
|
1399
|
+
return { id: this.project.id, ...this.programParams(rootFiles, commandLine) };
|
|
1400
|
+
}
|
|
1401
|
+
getModuleResolver() {
|
|
1402
|
+
return this.moduleResolver ??= this.api.createModuleResolver(this.commandLine.options), this.moduleResolver;
|
|
1403
|
+
}
|
|
1404
|
+
replaceSnapshot(next) {
|
|
1405
|
+
let project = next.getProgram(this.project.id)?.getProject();
|
|
1406
|
+
if (!project)
|
|
1407
|
+
throw next.dispose(), new Error(
|
|
1408
|
+
`TypeScript dropped the program of ${this.configFileName ?? "inferred files"}`
|
|
1409
|
+
);
|
|
1410
|
+
let previous = this.snapshot;
|
|
1411
|
+
this.snapshot = next, this.project = project, this.facades = void 0, previous.dispose();
|
|
1412
|
+
}
|
|
1413
|
+
}, modifiedTime = (fileName) => {
|
|
1414
|
+
try {
|
|
1415
|
+
return statSync2(fileName).mtimeMs;
|
|
1416
|
+
} catch {
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1419
|
+
};
|
|
1420
|
+
function createNativeBackend(modules, ProjectClass, inferredOptions) {
|
|
1421
|
+
let api = new modules.sync.API({ cwd: process.cwd() }), typescript = createNativeDocgenTypeScript(modules, api);
|
|
1422
|
+
return {
|
|
1423
|
+
fileSystem: typescript,
|
|
1424
|
+
factory: {
|
|
1425
|
+
parseCommandLine: (tsconfig) => {
|
|
1426
|
+
let { fileNames, options, projectReferences } = api.parseConfigFile(tsconfig);
|
|
1427
|
+
return {
|
|
1428
|
+
fileNames: [...fileNames],
|
|
1429
|
+
options,
|
|
1430
|
+
projectReferences
|
|
1431
|
+
};
|
|
1432
|
+
},
|
|
1433
|
+
createConfiguredProject: (commandLine, tsconfig, getCommandLine) => new ProjectClass(api, typescript, commandLine, tsconfig, getCommandLine),
|
|
1434
|
+
createInferredProject: () => new ProjectClass(api, typescript, { fileNames: [], options: inferredOptions }, void 0),
|
|
1435
|
+
dispose: () => api.close()
|
|
1436
|
+
}
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
function createComponentMetaBackend(loaded, create) {
|
|
1440
|
+
return loaded.api === "native" ? create.native(loaded.typescript) : create.compiler(loaded.typescript);
|
|
1441
|
+
}
|
|
1442
|
+
var isAngularCoreOrUnresolved = (ctx, node) => {
|
|
392
1443
|
let symbol = resolvedSymbol(ctx, node);
|
|
393
1444
|
return !symbol?.declarations?.length || isDeclaredInAngularCore(symbol);
|
|
394
1445
|
}, isDeclaredInAngularCore = (symbol) => symbol.declarations?.some(
|
|
@@ -665,7 +1716,7 @@ ${detailLines(lines).join(`
|
|
|
665
1716
|
candidate = candidate.parent;
|
|
666
1717
|
return candidate?.name?.text ?? "an anonymous class";
|
|
667
1718
|
}, dropped = (node, name, reason) => {
|
|
668
|
-
|
|
1719
|
+
logger2.debug(`[angular-cm] ${owningClassName(node)}.${name} left out of docgen: ${reason}`);
|
|
669
1720
|
}, ANGULAR_GENERATED_STATIC = /^(ngAcceptInputType_|ɵ)/;
|
|
670
1721
|
function visitClassMembers(ctx, classNode, kind) {
|
|
671
1722
|
let { ts } = ctx, members = { inputs: [], outputs: [], properties: [], methods: [] }, visitedAccessors = /* @__PURE__ */ new Set();
|
|
@@ -769,7 +1820,7 @@ var reclassify = (members, entry, inputFields) => {
|
|
|
769
1820
|
value: {
|
|
770
1821
|
name: config.alias ?? memberName(ctx.ts, member.name),
|
|
771
1822
|
...type === void 0 ? {} : { type },
|
|
772
|
-
optional: config.required !== void 0 ? !config.required :
|
|
1823
|
+
optional: config.required !== void 0 ? !config.required : ctx.ts.hasQuestionToken(member),
|
|
773
1824
|
...config.required === void 0 ? {} : { required: config.required },
|
|
774
1825
|
...member.initializer ? { initializer: defaultInitializer(ctx, member.initializer) } : {},
|
|
775
1826
|
...memberApiFields(ctx, member),
|
|
@@ -793,7 +1844,7 @@ var reclassify = (members, entry, inputFields) => {
|
|
|
793
1844
|
return {
|
|
794
1845
|
name: memberName(ctx.ts, member.name),
|
|
795
1846
|
...type === void 0 ? {} : { type },
|
|
796
|
-
optional:
|
|
1847
|
+
optional: ctx.ts.hasQuestionToken(member),
|
|
797
1848
|
...member.initializer ? { initializer: defaultInitializer(ctx, member.initializer) } : {},
|
|
798
1849
|
...memberApiFields(ctx, member),
|
|
799
1850
|
...getJsDocDescription(ctx.ts, member),
|
|
@@ -973,7 +2024,7 @@ var extendsClauseFor = (ctx, classNode, declaration) => {
|
|
|
973
2024
|
return substitutions;
|
|
974
2025
|
let args = clause.typeArguments ?? [];
|
|
975
2026
|
for (let [index, parameter] of parameters.entries()) {
|
|
976
|
-
let argument = args[index] ?? parameter
|
|
2027
|
+
let argument = args[index] ?? ctx.ts.getTypeParameterDefault(parameter), symbol = ctx.checker.getSymbolAtLocation(parameter.name);
|
|
977
2028
|
!argument || !symbol || substitutions.set(symbol, argument);
|
|
978
2029
|
}
|
|
979
2030
|
return substitutions;
|
|
@@ -1123,7 +2174,7 @@ function emitMembers(members) {
|
|
|
1123
2174
|
methods: values(members.methods)
|
|
1124
2175
|
};
|
|
1125
2176
|
}
|
|
1126
|
-
var stripImportQualifiers = (text) => text.replace(/import\("[^"]*"\)\./g, ""), collapseWhitespace = (text) => text.replace(/\s+/g, " ").trim(), TypeIndex = class {
|
|
2177
|
+
var stripImportQualifiers = (text) => text.replace(/import\("[^"]*"\)\./g, ""), collapseWhitespace = (text) => text.replace(/\s+/g, " ").trim(), printedWithoutSubstitution = /* @__PURE__ */ new WeakMap(), TypeIndex = class {
|
|
1127
2178
|
constructor(ts, checker) {
|
|
1128
2179
|
this.ts = ts, this.checker = checker, this.typealiases = /* @__PURE__ */ new Map(), this.enumerations = /* @__PURE__ */ new Map(), this.aliasCycleGuard = /* @__PURE__ */ new Set();
|
|
1129
2180
|
}
|
|
@@ -1192,35 +2243,38 @@ var stripImportQualifiers = (text) => text.replace(/import\("[^"]*"\)\./g, ""),
|
|
|
1192
2243
|
this.addFromTypeNode(typeNode);
|
|
1193
2244
|
for (let replacement of substitutions.values())
|
|
1194
2245
|
this.addFromTypeNode(replacement);
|
|
1195
|
-
|
|
1196
|
-
(
|
|
1197
|
-
|
|
1198
|
-
if (this.ts.isTypeReferenceNode(node) && this.ts.isIdentifier(node.typeName)) {
|
|
1199
|
-
let symbol = this.checker.getSymbolAtLocation(node.typeName), replacement = symbol && substitutions.get(symbol);
|
|
1200
|
-
if (symbol && replacement && !resolving.has(symbol)) {
|
|
1201
|
-
resolving.add(symbol);
|
|
1202
|
-
let resolved = this.ts.visitNode(replacement, visit);
|
|
1203
|
-
return resolving.delete(symbol), resolved;
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
return this.ts.isLiteralTypeNode(node) && (this.ts.isStringLiteral(node.literal) || this.ts.isNoSubstitutionTemplateLiteral(node.literal)) ? this.ts.factory.createLiteralTypeNode(
|
|
1207
|
-
this.ts.factory.createStringLiteral(node.literal.text)
|
|
1208
|
-
) : this.ts.visitEachChild(node, visit, context);
|
|
1209
|
-
};
|
|
1210
|
-
return (root) => this.ts.visitNode(root, visit);
|
|
1211
|
-
}
|
|
1212
|
-
]);
|
|
1213
|
-
try {
|
|
1214
|
-
return collapseWhitespace(
|
|
1215
|
-
this.ts.createPrinter({ removeComments: !0 }).printNode(
|
|
1216
|
-
this.ts.EmitHint.Unspecified,
|
|
1217
|
-
transformed.transformed[0],
|
|
1218
|
-
typeNode.getSourceFile()
|
|
1219
|
-
)
|
|
1220
|
-
);
|
|
1221
|
-
} finally {
|
|
1222
|
-
transformed.dispose();
|
|
2246
|
+
if (!this.referencesAny(typeNode, substitutions)) {
|
|
2247
|
+
let printed = printedWithoutSubstitution.get(typeNode);
|
|
2248
|
+
return printed === void 0 && (printed = this.printInstantiated(typeNode, substitutions), printedWithoutSubstitution.set(typeNode, printed)), printed;
|
|
1223
2249
|
}
|
|
2250
|
+
return this.printInstantiated(typeNode, substitutions);
|
|
2251
|
+
}
|
|
2252
|
+
referencesAny(node, substitutions) {
|
|
2253
|
+
if (this.ts.isTypeReferenceNode(node) && this.ts.isIdentifier(node.typeName)) {
|
|
2254
|
+
let symbol = this.checker.getSymbolAtLocation(node.typeName);
|
|
2255
|
+
if (symbol && substitutions.has(symbol))
|
|
2256
|
+
return !0;
|
|
2257
|
+
}
|
|
2258
|
+
return !!this.ts.forEachChild(
|
|
2259
|
+
node,
|
|
2260
|
+
(child) => this.referencesAny(child, substitutions) || void 0
|
|
2261
|
+
);
|
|
2262
|
+
}
|
|
2263
|
+
printInstantiated(typeNode, substitutions) {
|
|
2264
|
+
let resolving = /* @__PURE__ */ new Set(), visit = (node, visitChildren) => {
|
|
2265
|
+
if (this.ts.isTypeReferenceNode(node) && this.ts.isIdentifier(node.typeName)) {
|
|
2266
|
+
let symbol = this.checker.getSymbolAtLocation(node.typeName), replacement = symbol && substitutions.get(symbol);
|
|
2267
|
+
if (symbol && replacement && !resolving.has(symbol)) {
|
|
2268
|
+
resolving.add(symbol);
|
|
2269
|
+
let resolved = visit(replacement, visitChildren);
|
|
2270
|
+
return resolving.delete(symbol), resolved;
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
return this.ts.isLiteralTypeNode(node) && (this.ts.isStringLiteral(node.literal) || this.ts.isNoSubstitutionTemplateLiteral(node.literal)) ? this.ts.factory.createLiteralTypeNode(
|
|
2274
|
+
this.ts.factory.createStringLiteral(node.literal.text)
|
|
2275
|
+
) : visitChildren(node);
|
|
2276
|
+
};
|
|
2277
|
+
return collapseWhitespace(this.ts.printNode(typeNode, visit));
|
|
1224
2278
|
}
|
|
1225
2279
|
/** Widen and render a declaration's inferred type, as the legacy pipeline did (`'v1'` to `string`). */
|
|
1226
2280
|
infer(node) {
|
|
@@ -1301,8 +2355,7 @@ var stripImportQualifiers = (text) => text.replace(/import\("[^"]*"\)\./g, ""),
|
|
|
1301
2355
|
ctype: "miscellaneous",
|
|
1302
2356
|
subtype: "typealias",
|
|
1303
2357
|
rawtype,
|
|
1304
|
-
file: declaration.getSourceFile().fileName
|
|
1305
|
-
kind: declaration.type.kind
|
|
2358
|
+
file: declaration.getSourceFile().fileName
|
|
1306
2359
|
});
|
|
1307
2360
|
}
|
|
1308
2361
|
// What the extractor's enum path can resolve without help: it splits `rawtype` on `|` and
|
|
@@ -1359,16 +2412,16 @@ function analyzeSourceFile(ts, sourceFile, checker, context = analyzerContext(ts
|
|
|
1359
2412
|
if (!ts.isClassDeclaration(statement) || !statement.name)
|
|
1360
2413
|
continue;
|
|
1361
2414
|
if (hasJsDocTag(ts, statement, "ignore")) {
|
|
1362
|
-
|
|
2415
|
+
logger3.debug(`[angular-cm] ${statement.name.text} left out of docgen: tagged @ignore`);
|
|
1363
2416
|
continue;
|
|
1364
2417
|
}
|
|
1365
2418
|
let kind = classify(ctx, statement);
|
|
1366
2419
|
if (kind === "ngmodule") {
|
|
1367
|
-
|
|
2420
|
+
logger3.debug(`[angular-cm] ${statement.name.text} left out of docgen: an @NgModule`);
|
|
1368
2421
|
continue;
|
|
1369
2422
|
}
|
|
1370
2423
|
if (kind === "class" && sourceFile.isDeclarationFile) {
|
|
1371
|
-
|
|
2424
|
+
logger3.debug(
|
|
1372
2425
|
`[angular-cm] ${statement.name.text} left out of docgen: a declaration-file class with no compiled \u0275cmp`
|
|
1373
2426
|
);
|
|
1374
2427
|
continue;
|
|
@@ -1480,9 +2533,140 @@ var KNOWN_DECORATORS = {
|
|
|
1480
2533
|
}, pipeName = (ctx, node) => {
|
|
1481
2534
|
let metadata = decoratorObjectArg(ctx, node, "Pipe");
|
|
1482
2535
|
return metadata && stringOption(ctx, metadata, "name");
|
|
2536
|
+
}, debugExtraction = (configFileName, message) => logger4.debug(`[angular-cm] ${message}${configFileName ? ` (${configFileName})` : ""}`);
|
|
2537
|
+
function extractComponent(typescript, checker, sourceFile, names, debug) {
|
|
2538
|
+
let context = analyzerContext(typescript, sourceFile, checker), fileMeta = analyzeSourceFile(typescript, sourceFile, checker, context), entry = pickEntry(typescript, fileMeta, sourceFile, names);
|
|
2539
|
+
if (entry)
|
|
2540
|
+
return debug(`${describe(entry)} from ${sourceFile.fileName}`), {
|
|
2541
|
+
entry,
|
|
2542
|
+
json: fileMeta,
|
|
2543
|
+
context,
|
|
2544
|
+
...jsDocInfoField(
|
|
2545
|
+
typescript,
|
|
2546
|
+
checker,
|
|
2547
|
+
findClassDeclaration(typescript, sourceFile, entry.name)
|
|
2548
|
+
)
|
|
2549
|
+
};
|
|
2550
|
+
let viaExports = extractViaModuleExports(
|
|
2551
|
+
typescript,
|
|
2552
|
+
checker,
|
|
2553
|
+
sourceFile,
|
|
2554
|
+
fileMeta,
|
|
2555
|
+
context,
|
|
2556
|
+
names
|
|
2557
|
+
);
|
|
2558
|
+
if (viaExports)
|
|
2559
|
+
return debug(`${describe(viaExports.entry)} from ${sourceFile.fileName}, reached through its exports`), viaExports;
|
|
2560
|
+
debug(
|
|
2561
|
+
`no class named ${[names.exportName, names.localName].filter(Boolean).join(" or ")} in ${sourceFile.fileName}; it declares ${declaredNames(fileMeta).join(", ") || "no classes"}`
|
|
2562
|
+
);
|
|
2563
|
+
}
|
|
2564
|
+
var importClosure = (typescript, checker, entry) => {
|
|
2565
|
+
let closure = /* @__PURE__ */ new Set(), queue = [entry];
|
|
2566
|
+
for (; queue.length > 0; ) {
|
|
2567
|
+
let file = queue.pop();
|
|
2568
|
+
if (!(closure.has(file.fileName) || isInNodeModules2(file.fileName))) {
|
|
2569
|
+
closure.add(file.fileName);
|
|
2570
|
+
for (let statement of file.statements) {
|
|
2571
|
+
let specifier = typescript.isImportDeclaration(statement) || typescript.isExportDeclaration(statement) ? statement.moduleSpecifier : void 0;
|
|
2572
|
+
if (specifier)
|
|
2573
|
+
for (let declaration of checker.getSymbolAtLocation(specifier)?.declarations ?? [])
|
|
2574
|
+
typescript.isSourceFile(declaration) && queue.push(declaration);
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
return [...closure];
|
|
2579
|
+
}, pickEntry = (typescript, fileMeta, sourceFile, { exportName, localName }) => {
|
|
2580
|
+
let direct = findRecord(fileMeta, exportName);
|
|
2581
|
+
if (direct)
|
|
2582
|
+
return direct;
|
|
2583
|
+
if (exportName === "default") {
|
|
2584
|
+
let viaDefault = findRecord(fileMeta, findDefaultExportedClassName(typescript, sourceFile));
|
|
2585
|
+
if (viaDefault)
|
|
2586
|
+
return viaDefault;
|
|
2587
|
+
}
|
|
2588
|
+
return findRecord(fileMeta, localName);
|
|
2589
|
+
}, extractViaModuleExports = (typescript, checker, sourceFile, fileMeta, context, { exportName, localName }) => {
|
|
2590
|
+
let { SymbolFlags, isClassDeclaration } = typescript, moduleSymbol = checker.getSymbolAtLocation(sourceFile);
|
|
2591
|
+
if (!moduleSymbol)
|
|
2592
|
+
return;
|
|
2593
|
+
let moduleExports = checker.getExportsOfModule(moduleSymbol);
|
|
2594
|
+
for (let name of [exportName, localName]) {
|
|
2595
|
+
let exported = name && moduleExports.find((symbol) => symbol.name === name);
|
|
2596
|
+
if (!exported)
|
|
2597
|
+
continue;
|
|
2598
|
+
let declaration = (exported.flags & SymbolFlags.Alias ? checker.getAliasedSymbol(exported) : exported).declarations?.find(
|
|
2599
|
+
(candidate) => isClassDeclaration(candidate)
|
|
2600
|
+
);
|
|
2601
|
+
if (!declaration?.name)
|
|
2602
|
+
continue;
|
|
2603
|
+
let declarationFile = declaration.getSourceFile(), targetContext = declarationFile === sourceFile ? context : analyzerContext(typescript, declarationFile, checker), targetMeta = declarationFile === sourceFile ? fileMeta : analyzeSourceFile(typescript, declarationFile, checker, targetContext), entry = findRecord(targetMeta, declaration.name.text);
|
|
2604
|
+
if (entry)
|
|
2605
|
+
return {
|
|
2606
|
+
entry,
|
|
2607
|
+
json: targetMeta,
|
|
2608
|
+
context: targetContext,
|
|
2609
|
+
...jsDocInfoField(typescript, checker, declaration)
|
|
2610
|
+
};
|
|
2611
|
+
}
|
|
2612
|
+
}, allRecords = (fileMeta) => [
|
|
2613
|
+
...fileMeta.components,
|
|
2614
|
+
...fileMeta.directives,
|
|
2615
|
+
...fileMeta.pipes,
|
|
2616
|
+
...fileMeta.injectables,
|
|
2617
|
+
...fileMeta.classes
|
|
2618
|
+
], declaredNames = (fileMeta) => allRecords(fileMeta).map((record) => `${record.name} (${record.type})`), describe = (entry) => {
|
|
2619
|
+
let counts = "inputsClass" in entry ? `${entry.inputsClass?.length ?? 0} input(s), ${entry.outputsClass?.length ?? 0} output(s), ${"propertiesClass" in entry ? entry.propertiesClass?.length ?? 0 : 0} propertie(s)` : `${entry.properties.length} propertie(s), ${entry.methods.length} method(s)`;
|
|
2620
|
+
return `extracted ${entry.type} ${entry.name} with ${counts}`;
|
|
2621
|
+
}, findRecord = (fileMeta, name) => name ? allRecords(fileMeta).find((record) => record.name === name) : void 0;
|
|
2622
|
+
function findClassDeclaration(typescript, sourceFile, name) {
|
|
2623
|
+
return sourceFile.statements.find(
|
|
2624
|
+
(statement) => typescript.isClassDeclaration(statement) && statement.name?.text === name
|
|
2625
|
+
);
|
|
2626
|
+
}
|
|
2627
|
+
function jsDocInfoField(typescript, checker, declaration) {
|
|
2628
|
+
let symbol = declaration?.name && checker.getSymbolAtLocation(declaration.name);
|
|
2629
|
+
return symbol ? { jsDocInfo: extractComponentJsDocInfo(typescript, checker, symbol) } : {};
|
|
2630
|
+
}
|
|
2631
|
+
function findDefaultExportedClassName(typescript, sourceFile) {
|
|
2632
|
+
for (let statement of sourceFile.statements) {
|
|
2633
|
+
if (typescript.isClassDeclaration(statement) && statement.name && statement.modifiers?.some(
|
|
2634
|
+
(modifier) => modifier.kind === typescript.SyntaxKind.DefaultKeyword
|
|
2635
|
+
))
|
|
2636
|
+
return statement.name.text;
|
|
2637
|
+
if (typescript.isExportAssignment(statement) && !statement.isExportEquals && typescript.isIdentifier(statement.expression))
|
|
2638
|
+
return statement.expression.text;
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
var NativeAngularComponentMetaProject = class extends NativeProject {
|
|
2642
|
+
extract(componentPath, names) {
|
|
2643
|
+
if (this.disposed)
|
|
2644
|
+
return;
|
|
2645
|
+
let fileName = slash(componentPath);
|
|
2646
|
+
this.ensureFiles([fileName]), this.ensureFresh([fileName]);
|
|
2647
|
+
let sourceFile = this.getSourceFile(fileName);
|
|
2648
|
+
if (!sourceFile) {
|
|
2649
|
+
this.debug(`${fileName} is in no TypeScript program, so nothing was extracted from it`);
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
if (this.ensureFresh(importClosure(this.typescript, this.getChecker(), sourceFile)) && (sourceFile = this.getSourceFile(fileName), !sourceFile)) {
|
|
2653
|
+
this.debug(`${fileName} left the program while being refreshed`);
|
|
2654
|
+
return;
|
|
2655
|
+
}
|
|
2656
|
+
return extractComponent(
|
|
2657
|
+
this.typescript,
|
|
2658
|
+
this.getChecker(),
|
|
2659
|
+
sourceFile,
|
|
2660
|
+
names,
|
|
2661
|
+
(message) => this.debug(message)
|
|
2662
|
+
);
|
|
2663
|
+
}
|
|
2664
|
+
debug(message) {
|
|
2665
|
+
debugExtraction(this.configFileName, message);
|
|
2666
|
+
}
|
|
1483
2667
|
}, AngularComponentMetaProject = class extends ProgramBackedProject {
|
|
1484
2668
|
constructor(typescript, commandLine, configFileName, fsFileSnapshots = /* @__PURE__ */ new Map(), getCommandLineFn, documentRegistry) {
|
|
1485
|
-
super(), this.typescript = typescript, this.commandLine = commandLine, this.configFileName = configFileName, this.documentRegistry = documentRegistry, this.files = new ProjectFileTracker(
|
|
2669
|
+
super(), this.typescript = typescript, this.commandLine = commandLine, this.configFileName = configFileName, this.documentRegistry = documentRegistry, this.docgenTypeScript = createCompilerDocgenTypeScript(typescript), this.files = new ProjectFileTracker(
|
|
1486
2670
|
typescript,
|
|
1487
2671
|
commandLine,
|
|
1488
2672
|
fsFileSnapshots,
|
|
@@ -1513,128 +2697,41 @@ var KNOWN_DECORATORS = {
|
|
|
1513
2697
|
return this.commandLine;
|
|
1514
2698
|
}
|
|
1515
2699
|
extract(componentPath, names) {
|
|
1516
|
-
let fileName =
|
|
2700
|
+
let fileName = slash2(componentPath);
|
|
1517
2701
|
this.files.ensureFresh([fileName]);
|
|
1518
2702
|
let program = this.service.getProgram(), sourceFile = program?.getSourceFile(fileName);
|
|
1519
2703
|
if (sourceFile || (this.ensureFiles([fileName]), program = this.service.getProgram(), sourceFile = program?.getSourceFile(fileName)), !program || !sourceFile) {
|
|
1520
2704
|
this.debug(`${fileName} is in no TypeScript program, so nothing was extracted from it`);
|
|
1521
2705
|
return;
|
|
1522
2706
|
}
|
|
1523
|
-
if (this.files.ensureFresh(
|
|
2707
|
+
if (this.files.ensureFresh(
|
|
2708
|
+
importClosure(this.docgenTypeScript, program.getTypeChecker(), sourceFile)
|
|
2709
|
+
) && (program = this.service.getProgram(), sourceFile = program?.getSourceFile(fileName), !program || !sourceFile)) {
|
|
1524
2710
|
this.debug(`${fileName} left the program while being refreshed`);
|
|
1525
2711
|
return;
|
|
1526
2712
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
...jsDocInfoField(
|
|
1534
|
-
this.typescript,
|
|
1535
|
-
checker,
|
|
1536
|
-
findClassDeclaration(this.typescript, sourceFile, entry.name)
|
|
1537
|
-
)
|
|
1538
|
-
};
|
|
1539
|
-
let viaExports = this.extractViaModuleExports(checker, sourceFile, fileMeta, context, names);
|
|
1540
|
-
if (viaExports)
|
|
1541
|
-
return this.debug(`${describe(viaExports.entry)} from ${fileName}, reached through its exports`), viaExports;
|
|
1542
|
-
this.debug(
|
|
1543
|
-
`no class named ${[names.exportName, names.localName].filter(Boolean).join(" or ")} in ${fileName}; it declares ${declaredNames(fileMeta).join(", ") || "no classes"}`
|
|
2713
|
+
return extractComponent(
|
|
2714
|
+
this.docgenTypeScript,
|
|
2715
|
+
program.getTypeChecker(),
|
|
2716
|
+
sourceFile,
|
|
2717
|
+
names,
|
|
2718
|
+
(message) => this.debug(message)
|
|
1544
2719
|
);
|
|
1545
2720
|
}
|
|
1546
2721
|
debug(message) {
|
|
1547
|
-
|
|
1548
|
-
`[angular-cm] ${message}${this.configFileName ? ` (${this.configFileName})` : ""}`
|
|
1549
|
-
);
|
|
1550
|
-
}
|
|
1551
|
-
pickEntry(fileMeta, sourceFile, { exportName, localName }) {
|
|
1552
|
-
let direct = findRecord(fileMeta, exportName);
|
|
1553
|
-
if (direct)
|
|
1554
|
-
return direct;
|
|
1555
|
-
if (exportName === "default") {
|
|
1556
|
-
let viaDefault = findRecord(
|
|
1557
|
-
fileMeta,
|
|
1558
|
-
findDefaultExportedClassName(this.typescript, sourceFile)
|
|
1559
|
-
);
|
|
1560
|
-
if (viaDefault)
|
|
1561
|
-
return viaDefault;
|
|
1562
|
-
}
|
|
1563
|
-
return findRecord(fileMeta, localName);
|
|
2722
|
+
debugExtraction(this.configFileName, message);
|
|
1564
2723
|
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
if (!exported)
|
|
1573
|
-
continue;
|
|
1574
|
-
let declaration = (exported.flags & SymbolFlags.Alias ? checker.getAliasedSymbol(exported) : exported).declarations?.find(
|
|
1575
|
-
(candidate) => isClassDeclaration(candidate)
|
|
1576
|
-
);
|
|
1577
|
-
if (!declaration?.name)
|
|
1578
|
-
continue;
|
|
1579
|
-
let declarationFile = declaration.getSourceFile(), targetContext = declarationFile === sourceFile ? context : analyzerContext(this.typescript, declarationFile, checker), targetMeta = declarationFile === sourceFile ? fileMeta : analyzeSourceFile(this.typescript, declarationFile, checker, targetContext), entry = findRecord(targetMeta, declaration.name.text);
|
|
1580
|
-
if (entry)
|
|
1581
|
-
return {
|
|
1582
|
-
entry,
|
|
1583
|
-
json: targetMeta,
|
|
1584
|
-
context: targetContext,
|
|
1585
|
-
...jsDocInfoField(this.typescript, checker, declaration)
|
|
1586
|
-
};
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
}, importClosure = (typescript, program, entry) => {
|
|
1590
|
-
let checker = program.getTypeChecker(), closure = /* @__PURE__ */ new Set(), queue = [entry];
|
|
1591
|
-
for (; queue.length > 0; ) {
|
|
1592
|
-
let file = queue.pop();
|
|
1593
|
-
if (!(closure.has(file.fileName) || isInNodeModules2(file.fileName))) {
|
|
1594
|
-
closure.add(file.fileName);
|
|
1595
|
-
for (let statement of file.statements) {
|
|
1596
|
-
let specifier = typescript.isImportDeclaration(statement) || typescript.isExportDeclaration(statement) ? statement.moduleSpecifier : void 0;
|
|
1597
|
-
if (specifier)
|
|
1598
|
-
for (let declaration of checker.getSymbolAtLocation(specifier)?.declarations ?? [])
|
|
1599
|
-
typescript.isSourceFile(declaration) && queue.push(declaration);
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
return [...closure];
|
|
1604
|
-
}, allRecords = (fileMeta) => [
|
|
1605
|
-
...fileMeta.components,
|
|
1606
|
-
...fileMeta.directives,
|
|
1607
|
-
...fileMeta.pipes,
|
|
1608
|
-
...fileMeta.injectables,
|
|
1609
|
-
...fileMeta.classes
|
|
1610
|
-
], declaredNames = (fileMeta) => allRecords(fileMeta).map((record) => `${record.name} (${record.type})`), describe = (entry) => {
|
|
1611
|
-
let counts = "inputsClass" in entry ? `${entry.inputsClass?.length ?? 0} input(s), ${entry.outputsClass?.length ?? 0} output(s), ${"propertiesClass" in entry ? entry.propertiesClass?.length ?? 0 : 0} propertie(s)` : `${entry.properties.length} propertie(s), ${entry.methods.length} method(s)`;
|
|
1612
|
-
return `extracted ${entry.type} ${entry.name} with ${counts}`;
|
|
1613
|
-
}, findRecord = (fileMeta, name) => name ? allRecords(fileMeta).find((record) => record.name === name) : void 0;
|
|
1614
|
-
function findClassDeclaration(typescript, sourceFile, name) {
|
|
1615
|
-
return sourceFile.statements.find(
|
|
1616
|
-
(statement) => typescript.isClassDeclaration(statement) && statement.name?.text === name
|
|
1617
|
-
);
|
|
1618
|
-
}
|
|
1619
|
-
function jsDocInfoField(typescript, checker, declaration) {
|
|
1620
|
-
let symbol = declaration?.name && checker.getSymbolAtLocation(declaration.name);
|
|
1621
|
-
return symbol ? { jsDocInfo: extractComponentJsDocInfo(typescript, checker, symbol) } : {};
|
|
1622
|
-
}
|
|
1623
|
-
function findDefaultExportedClassName(typescript, sourceFile) {
|
|
1624
|
-
for (let statement of sourceFile.statements) {
|
|
1625
|
-
if (typescript.isClassDeclaration(statement) && statement.name && statement.modifiers?.some(
|
|
1626
|
-
(modifier) => modifier.kind === typescript.SyntaxKind.DefaultKeyword
|
|
1627
|
-
))
|
|
1628
|
-
return statement.name.text;
|
|
1629
|
-
if (typescript.isExportAssignment(statement) && !statement.isExportEquals && typescript.isIdentifier(statement.expression))
|
|
1630
|
-
return statement.expression.text;
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
function createAngularProjectFactory(typescript) {
|
|
2724
|
+
}, INFERRED_OPTIONS = {
|
|
2725
|
+
strict: !1,
|
|
2726
|
+
allowJs: !0,
|
|
2727
|
+
skipLibCheck: !0,
|
|
2728
|
+
experimentalDecorators: !0
|
|
2729
|
+
};
|
|
2730
|
+
function createCompilerApiBackend(typescript) {
|
|
1634
2731
|
let fsFileSnapshots = /* @__PURE__ */ new Map(), documentRegistry = typescript.createDocumentRegistry(
|
|
1635
2732
|
typescript.sys.useCaseSensitiveFileNames
|
|
1636
2733
|
);
|
|
1637
|
-
return {
|
|
2734
|
+
return { fileSystem: typescript, factory: {
|
|
1638
2735
|
parseCommandLine: (tsconfig) => parseTsconfigCommandLine(typescript, tsconfig),
|
|
1639
2736
|
createConfiguredProject: (commandLine, tsconfig, getCommandLine) => new AngularComponentMetaProject(
|
|
1640
2737
|
typescript,
|
|
@@ -1648,11 +2745,7 @@ function createAngularProjectFactory(typescript) {
|
|
|
1648
2745
|
typescript,
|
|
1649
2746
|
{
|
|
1650
2747
|
options: {
|
|
1651
|
-
|
|
1652
|
-
strict: !1,
|
|
1653
|
-
allowJs: !0,
|
|
1654
|
-
skipLibCheck: !0,
|
|
1655
|
-
experimentalDecorators: !0,
|
|
2748
|
+
...INFERRED_OPTIONS,
|
|
1656
2749
|
target: typescript.ScriptTarget.Latest,
|
|
1657
2750
|
module: typescript.ModuleKind.ESNext,
|
|
1658
2751
|
moduleResolution: typescript.ModuleResolutionKind.Bundler
|
|
@@ -1669,11 +2762,20 @@ function createAngularProjectFactory(typescript) {
|
|
|
1669
2762
|
// any single one and have to be dropped alongside them.
|
|
1670
2763
|
recycle: () => fsFileSnapshots.clear(),
|
|
1671
2764
|
dispose: () => fsFileSnapshots.clear()
|
|
1672
|
-
};
|
|
2765
|
+
} };
|
|
1673
2766
|
}
|
|
1674
2767
|
var AngularComponentMetaManager = class extends ComponentMetaManager {
|
|
1675
2768
|
constructor(typescript) {
|
|
1676
|
-
|
|
2769
|
+
let { fileSystem, factory } = createComponentMetaBackend(typescript, {
|
|
2770
|
+
compiler: createCompilerApiBackend,
|
|
2771
|
+
native: (modules) => createNativeBackend(modules, NativeAngularComponentMetaProject, {
|
|
2772
|
+
...INFERRED_OPTIONS,
|
|
2773
|
+
target: modules.ast.ScriptTarget.Latest,
|
|
2774
|
+
module: modules.sync.ModuleKind.ESNext,
|
|
2775
|
+
moduleResolution: modules.sync.ModuleResolutionKind.Bundler
|
|
2776
|
+
})
|
|
2777
|
+
});
|
|
2778
|
+
super(fileSystem, factory);
|
|
1677
2779
|
}
|
|
1678
2780
|
/**
|
|
1679
2781
|
* Extract the metadata for one component, or `undefined` when neither the file nor its
|
|
@@ -1688,9 +2790,362 @@ var AngularComponentMetaManager = class extends ComponentMetaManager {
|
|
|
1688
2790
|
}
|
|
1689
2791
|
};
|
|
1690
2792
|
|
|
2793
|
+
// ../../lib/component-meta-typescript/dist/index.js
|
|
2794
|
+
import CJS_COMPAT_NODE_URL_6lg7c74mo834 from "node:url";
|
|
2795
|
+
import CJS_COMPAT_NODE_PATH_6lg7c74mo834 from "node:path";
|
|
2796
|
+
import CJS_COMPAT_NODE_MODULE_6lg7c74mo834 from "node:module";
|
|
2797
|
+
|
|
2798
|
+
// ../../lib/component-meta-typescript/dist/_node-chunks/chunk-3F3YNNK2.js
|
|
2799
|
+
import CJS_COMPAT_NODE_URL_6lg7c74mo833 from "node:url";
|
|
2800
|
+
import CJS_COMPAT_NODE_PATH_6lg7c74mo833 from "node:path";
|
|
2801
|
+
import CJS_COMPAT_NODE_MODULE_6lg7c74mo833 from "node:module";
|
|
2802
|
+
import { pathToFileURL } from "node:url";
|
|
2803
|
+
import {
|
|
2804
|
+
getTypeScriptDocgenApi as getTypeScriptDocgenApi2,
|
|
2805
|
+
isModuleNotFoundError as isModuleNotFoundError2,
|
|
2806
|
+
isTypeScriptUsableForDocgen as isTypeScriptUsableForDocgen2,
|
|
2807
|
+
readTypeScriptPackageForDocgen as readTypeScriptPackageForDocgen2
|
|
2808
|
+
} from "storybook/internal/common";
|
|
2809
|
+
import {
|
|
2810
|
+
TypeScriptMissingForDocgenError as TypeScriptMissingForDocgenError2,
|
|
2811
|
+
TypeScriptWithoutCompilerApiError as TypeScriptWithoutCompilerApiError2
|
|
2812
|
+
} from "storybook/internal/server-errors";
|
|
2813
|
+
var __filename3 = CJS_COMPAT_NODE_URL_6lg7c74mo833.fileURLToPath(import.meta.url), __dirname3 = CJS_COMPAT_NODE_PATH_6lg7c74mo833.dirname(__filename3), require4 = CJS_COMPAT_NODE_MODULE_6lg7c74mo833.createRequire(import.meta.url), _lazyMatch2 = () => {
|
|
2814
|
+
var __lib__ = (() => {
|
|
2815
|
+
var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
|
|
2816
|
+
for (var n in e) m(r, n, { get: e[n], enumerable: !0 });
|
|
2817
|
+
}, H = (r, e, n, a) => {
|
|
2818
|
+
if (e && typeof e == "object" || typeof e == "function") for (let t of G(e)) !T.call(r, t) && t !== n && m(r, t, { get: () => e[t], enumerable: !(a = V(e, t)) || a.enumerable });
|
|
2819
|
+
return r;
|
|
2820
|
+
}, J = (r) => H(m({}, "__esModule", { value: !0 }), r), w = {};
|
|
2821
|
+
q(w, { default: () => re });
|
|
2822
|
+
var A = (r) => Array.isArray(r), d = (r) => typeof r == "function", Q = (r) => r.length === 0, W = (r) => typeof r == "number", K = (r) => typeof r == "object" && r !== null, X = (r) => r instanceof RegExp, b = (r) => typeof r == "string", h = (r) => r === void 0, Y = (r) => {
|
|
2823
|
+
let e = /* @__PURE__ */ new Map();
|
|
2824
|
+
return (n) => {
|
|
2825
|
+
let a = e.get(n);
|
|
2826
|
+
if (a) return a;
|
|
2827
|
+
let t = r(n);
|
|
2828
|
+
return e.set(n, t), t;
|
|
2829
|
+
};
|
|
2830
|
+
}, rr = (r, e, n = {}) => {
|
|
2831
|
+
let a = { cache: {}, input: r, index: 0, indexMax: 0, options: n, output: [] };
|
|
2832
|
+
if (v(e)(a) && a.index === r.length) return a.output;
|
|
2833
|
+
throw new Error(`Failed to parse at index ${a.indexMax}`);
|
|
2834
|
+
}, i = (r, e) => A(r) ? er(r, e) : b(r) ? ar(r, e) : nr(r, e), er = (r, e) => {
|
|
2835
|
+
let n = {};
|
|
2836
|
+
for (let a of r) {
|
|
2837
|
+
if (a.length !== 1) throw new Error(`Invalid character: "${a}"`);
|
|
2838
|
+
let t = a.charCodeAt(0);
|
|
2839
|
+
n[t] = !0;
|
|
2840
|
+
}
|
|
2841
|
+
return (a) => {
|
|
2842
|
+
let t = a.index, o = a.input;
|
|
2843
|
+
for (; a.index < o.length && o.charCodeAt(a.index) in n; ) a.index += 1;
|
|
2844
|
+
let u = a.index;
|
|
2845
|
+
if (u > t) {
|
|
2846
|
+
if (!h(e) && !a.options.silent) {
|
|
2847
|
+
let s = a.input.slice(t, u), c = d(e) ? e(s, o, String(t)) : e;
|
|
2848
|
+
h(c) || a.output.push(c);
|
|
2849
|
+
}
|
|
2850
|
+
a.indexMax = Math.max(a.indexMax, a.index);
|
|
2851
|
+
}
|
|
2852
|
+
return !0;
|
|
2853
|
+
};
|
|
2854
|
+
}, nr = (r, e) => {
|
|
2855
|
+
let n = r.source, a = r.flags.replace(/y|$/, "y"), t = new RegExp(n, a);
|
|
2856
|
+
return g((o) => {
|
|
2857
|
+
t.lastIndex = o.index;
|
|
2858
|
+
let u = t.exec(o.input);
|
|
2859
|
+
if (u) {
|
|
2860
|
+
if (!h(e) && !o.options.silent) {
|
|
2861
|
+
let s = d(e) ? e(...u, o.input, String(o.index)) : e;
|
|
2862
|
+
h(s) || o.output.push(s);
|
|
2863
|
+
}
|
|
2864
|
+
return o.index += u[0].length, o.indexMax = Math.max(o.indexMax, o.index), !0;
|
|
2865
|
+
} else return !1;
|
|
2866
|
+
});
|
|
2867
|
+
}, ar = (r, e) => (n) => {
|
|
2868
|
+
if (n.input.startsWith(r, n.index)) {
|
|
2869
|
+
if (!h(e) && !n.options.silent) {
|
|
2870
|
+
let t = d(e) ? e(r, n.input, String(n.index)) : e;
|
|
2871
|
+
h(t) || n.output.push(t);
|
|
2872
|
+
}
|
|
2873
|
+
return n.index += r.length, n.indexMax = Math.max(n.indexMax, n.index), !0;
|
|
2874
|
+
} else return !1;
|
|
2875
|
+
}, C = (r, e, n, a) => {
|
|
2876
|
+
let t = v(r);
|
|
2877
|
+
return g(_(M((o) => {
|
|
2878
|
+
let u = 0;
|
|
2879
|
+
for (; u < n; ) {
|
|
2880
|
+
let s = o.index;
|
|
2881
|
+
if (!t(o) || (u += 1, o.index === s)) break;
|
|
2882
|
+
}
|
|
2883
|
+
return u >= e;
|
|
2884
|
+
})));
|
|
2885
|
+
}, tr = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, 1 / 0), x = (r, e) => {
|
|
2886
|
+
let n = r.map(v);
|
|
2887
|
+
return g(_(M((a) => {
|
|
2888
|
+
for (let t = 0, o = n.length; t < o; t++) if (!n[t](a)) return !1;
|
|
2889
|
+
return !0;
|
|
2890
|
+
})));
|
|
2891
|
+
}, l = (r, e) => {
|
|
2892
|
+
let n = r.map(v);
|
|
2893
|
+
return g(_((a) => {
|
|
2894
|
+
for (let t = 0, o = n.length; t < o; t++) if (n[t](a)) return !0;
|
|
2895
|
+
return !1;
|
|
2896
|
+
}));
|
|
2897
|
+
}, M = (r, e = !1) => {
|
|
2898
|
+
let n = v(r);
|
|
2899
|
+
return (a) => {
|
|
2900
|
+
let t = a.index, o = a.output.length, u = n(a);
|
|
2901
|
+
return (!u || e) && (a.index = t, a.output.length !== o && (a.output.length = o)), u;
|
|
2902
|
+
};
|
|
2903
|
+
}, _ = (r, e) => v(r), g = /* @__PURE__ */ (() => {
|
|
2904
|
+
let r = 0;
|
|
2905
|
+
return (e) => {
|
|
2906
|
+
let n = v(e), a = r += 1;
|
|
2907
|
+
return (t) => {
|
|
2908
|
+
var o;
|
|
2909
|
+
if (t.options.memoization === !1) return n(t);
|
|
2910
|
+
let u = t.index, s = (o = t.cache)[a] || (o[a] = /* @__PURE__ */ new Map()), c = s.get(u);
|
|
2911
|
+
if (c === !1) return !1;
|
|
2912
|
+
if (W(c)) return t.index = c, !0;
|
|
2913
|
+
if (c) return t.index = c.index, c.output?.length && t.output.push(...c.output), !0;
|
|
2914
|
+
{
|
|
2915
|
+
let Z = t.output.length;
|
|
2916
|
+
if (n(t)) {
|
|
2917
|
+
let D = t.index, U = t.output.length;
|
|
2918
|
+
if (U > Z) {
|
|
2919
|
+
let ee = t.output.slice(Z, U);
|
|
2920
|
+
s.set(u, { index: D, output: ee });
|
|
2921
|
+
} else s.set(u, D);
|
|
2922
|
+
return !0;
|
|
2923
|
+
} else return s.set(u, !1), !1;
|
|
2924
|
+
}
|
|
2925
|
+
};
|
|
2926
|
+
};
|
|
2927
|
+
})(), E = (r) => {
|
|
2928
|
+
let e;
|
|
2929
|
+
return (n) => (e || (e = v(r())), e(n));
|
|
2930
|
+
}, v = Y((r) => {
|
|
2931
|
+
if (d(r)) return Q(r) ? E(r) : r;
|
|
2932
|
+
if (b(r) || X(r)) return i(r);
|
|
2933
|
+
if (A(r)) return x(r);
|
|
2934
|
+
if (K(r)) return l(Object.values(r));
|
|
2935
|
+
throw new Error("Invalid rule");
|
|
2936
|
+
}), P = "abcdefghijklmnopqrstuvwxyz", ir = (r) => {
|
|
2937
|
+
let e = "";
|
|
2938
|
+
for (; r > 0; ) {
|
|
2939
|
+
let n = (r - 1) % 26;
|
|
2940
|
+
e = P[n] + e, r = Math.floor((r - 1) / 26);
|
|
2941
|
+
}
|
|
2942
|
+
return e;
|
|
2943
|
+
}, O = (r) => {
|
|
2944
|
+
let e = 0;
|
|
2945
|
+
for (let n = 0, a = r.length; n < a; n++) e = e * 26 + P.indexOf(r[n]) + 1;
|
|
2946
|
+
return e;
|
|
2947
|
+
}, S = (r, e) => {
|
|
2948
|
+
if (e < r) return S(e, r);
|
|
2949
|
+
let n = [];
|
|
2950
|
+
for (; r <= e; ) n.push(r++);
|
|
2951
|
+
return n;
|
|
2952
|
+
}, or = (r, e, n) => S(r, e).map((a) => String(a).padStart(n, "0")), R = (r, e) => S(O(r), O(e)).map(ir), p = (r) => r, z = (r) => ur((e) => rr(e, r, { memoization: !1 }).join("")), ur = (r) => {
|
|
2953
|
+
let e = {};
|
|
2954
|
+
return (n) => e[n] ?? (e[n] = r(n));
|
|
2955
|
+
}, sr = i(/^\*\*\/\*$/, ".*"), cr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (r, e, n) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}`), lr = i(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (r, e, n, a) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}(?:${a.replaceAll(",", "|").replaceAll(".", "\\.")})`), y = i(/\\./, p), pr = i(/[$.*+?^(){}[\]\|]/, (r) => `\\${r}`), vr = i(/./, p), hr = i(/^(?:!!)*!(.*)$/, (r, e) => `(?!^${L(e)}$).*?`), dr = i(/^(!!)+/, ""), fr = l([hr, dr]), xr = i(/\/(\*\*\/)+/, "(?:/.+/|/)"), gr = i(/^(\*\*\/)+/, "(?:^|.*/)"), mr = i(/\/(\*\*)$/, "(?:/.*|$)"), _r = i(/\*\*/, ".*"), j = l([xr, gr, mr, _r]), Sr = i(/\*\/(?!\*\*\/)/, "[^/]*/"), yr = i(/\*/, "[^/]*"), N = l([Sr, yr]), k = i("?", "[^/]"), $r = i("[", p), wr = i("]", p), Ar = i(/[!^]/, "^/"), br = i(/[a-z]-[a-z]|[0-9]-[0-9]/i, p), Cr = i(/[$.*+?^(){}[\|]/, (r) => `\\${r}`), Mr = i(/[^\]]/, p), Er = l([y, Cr, br, Mr]), B = x([$r, tr(Ar), f(Er), wr]), Pr = i("{", "(?:"), Or = i("}", ")"), Rr = i(/(\d+)\.\.(\d+)/, (r, e, n) => or(+e, +n, Math.min(e.length, n.length)).join("|")), zr = i(/([a-z]+)\.\.([a-z]+)/, (r, e, n) => R(e, n).join("|")), jr = i(/([A-Z]+)\.\.([A-Z]+)/, (r, e, n) => R(e.toLowerCase(), n.toLowerCase()).join("|").toUpperCase()), Nr = l([Rr, zr, jr]), I = x([Pr, Nr, Or]), kr = i("{", "(?:"), Br = i("}", ")"), Ir = i(",", "|"), Fr = i(/[$.*+?^(){[\]\|]/, (r) => `\\${r}`), Lr = i(/[^}]/, p), Zr = E(() => F), Dr = l([j, N, k, B, I, Zr, y, Fr, Ir, Lr]), F = x([kr, f(Dr), Br]), Ur = f(l([sr, cr, lr, fr, j, N, k, B, I, F, y, pr, vr])), Vr = Ur, Gr = z(Vr), L = Gr, Tr = i(/\\./, p), qr = i(/./, p), Hr = i(/\*\*\*+/, "*"), Jr = i(/([^/{[(!])\*\*/, (r, e) => `${e}*`), Qr = i(/(^|.)\*\*(?=[^*/)\]}])/, (r, e) => `${e}*`), Wr = f(l([Tr, Hr, Jr, Qr, qr])), Kr = Wr, Xr = z(Kr), Yr = Xr, $ = (r, e) => {
|
|
2956
|
+
let n = Array.isArray(r) ? r : [r];
|
|
2957
|
+
if (!n.length) return !1;
|
|
2958
|
+
let a = n.map($.compile), t = n.every((s) => /(\/(?:\*\*)?|\[\/\])$/.test(s)), o = e.replace(/[\\\/]+/g, "/").replace(/\/$/, t ? "/" : "");
|
|
2959
|
+
return a.some((s) => s.test(o));
|
|
2960
|
+
};
|
|
2961
|
+
$.compile = (r) => new RegExp(`^${L(Yr(r))}$`, "s");
|
|
2962
|
+
var re = $;
|
|
2963
|
+
return J(w);
|
|
2964
|
+
})();
|
|
2965
|
+
return __lib__.default || __lib__;
|
|
2966
|
+
}, _match2, zeptomatch2 = (path2, pattern) => (_match2 || (_match2 = _lazyMatch2(), _lazyMatch2 = null), _match2(path2, pattern)), _DRIVE_LETTER_START_RE2 = /^[A-Za-z]:\//;
|
|
2967
|
+
function normalizeWindowsPath2(input = "") {
|
|
2968
|
+
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE2, (r) => r.toUpperCase());
|
|
2969
|
+
}
|
|
2970
|
+
var _UNC_REGEX2 = /^[/\\]{2}/, _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE2 = /^[A-Za-z]:$/, _ROOT_FOLDER_RE2 = /^\/([A-Za-z]:)?$/, _EXTNAME_RE2 = /.(\.[^./]+|\.)$/, _PATH_ROOT_RE2 = /^[/\\]|^[a-zA-Z]:[/\\]/, sep2 = "/", normalize2 = function(path2) {
|
|
2971
|
+
if (path2.length === 0)
|
|
2972
|
+
return ".";
|
|
2973
|
+
path2 = normalizeWindowsPath2(path2);
|
|
2974
|
+
let isUNCPath = path2.match(_UNC_REGEX2), isPathAbsolute = isAbsolute2(path2), trailingSeparator = path2[path2.length - 1] === "/";
|
|
2975
|
+
return path2 = normalizeString2(path2, !isPathAbsolute), path2.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path2 += "/"), _DRIVE_LETTER_RE2.test(path2) && (path2 += "/"), isUNCPath ? isPathAbsolute ? `//${path2}` : `//./${path2}` : isPathAbsolute && !isAbsolute2(path2) ? `/${path2}` : path2);
|
|
2976
|
+
}, join2 = function(...segments) {
|
|
2977
|
+
let path2 = "";
|
|
2978
|
+
for (let seg of segments)
|
|
2979
|
+
if (seg)
|
|
2980
|
+
if (path2.length > 0) {
|
|
2981
|
+
let pathTrailing = path2[path2.length - 1] === "/", segLeading = seg[0] === "/";
|
|
2982
|
+
pathTrailing && segLeading ? path2 += seg.slice(1) : path2 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
2983
|
+
} else
|
|
2984
|
+
path2 += seg;
|
|
2985
|
+
return normalize2(path2);
|
|
2986
|
+
};
|
|
2987
|
+
function cwd2() {
|
|
2988
|
+
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
2989
|
+
}
|
|
2990
|
+
var resolve2 = function(...arguments_) {
|
|
2991
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath2(argument));
|
|
2992
|
+
let resolvedPath = "", resolvedAbsolute = !1;
|
|
2993
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
2994
|
+
let path2 = index >= 0 ? arguments_[index] : cwd2();
|
|
2995
|
+
!path2 || path2.length === 0 || (resolvedPath = `${path2}/${resolvedPath}`, resolvedAbsolute = isAbsolute2(path2));
|
|
2996
|
+
}
|
|
2997
|
+
return resolvedPath = normalizeString2(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute2(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
|
|
2998
|
+
};
|
|
2999
|
+
function normalizeString2(path2, allowAboveRoot) {
|
|
3000
|
+
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
3001
|
+
for (let index = 0; index <= path2.length; ++index) {
|
|
3002
|
+
if (index < path2.length)
|
|
3003
|
+
char = path2[index];
|
|
3004
|
+
else {
|
|
3005
|
+
if (char === "/")
|
|
3006
|
+
break;
|
|
3007
|
+
char = "/";
|
|
3008
|
+
}
|
|
3009
|
+
if (char === "/") {
|
|
3010
|
+
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
|
3011
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
3012
|
+
if (res.length > 2) {
|
|
3013
|
+
let lastSlashIndex = res.lastIndexOf("/");
|
|
3014
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
|
3015
|
+
continue;
|
|
3016
|
+
} else if (res.length > 0) {
|
|
3017
|
+
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
|
3018
|
+
continue;
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
|
3022
|
+
} else
|
|
3023
|
+
res.length > 0 ? res += `/${path2.slice(lastSlash + 1, index)}` : res = path2.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
|
3024
|
+
lastSlash = index, dots = 0;
|
|
3025
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
|
3026
|
+
}
|
|
3027
|
+
return res;
|
|
3028
|
+
}
|
|
3029
|
+
var isAbsolute2 = function(p) {
|
|
3030
|
+
return _IS_ABSOLUTE_RE2.test(p);
|
|
3031
|
+
}, toNamespacedPath2 = function(p) {
|
|
3032
|
+
return normalizeWindowsPath2(p);
|
|
3033
|
+
}, extname2 = function(p) {
|
|
3034
|
+
if (p === "..") return "";
|
|
3035
|
+
let match = _EXTNAME_RE2.exec(normalizeWindowsPath2(p));
|
|
3036
|
+
return match && match[1] || "";
|
|
3037
|
+
}, relative2 = function(from, to) {
|
|
3038
|
+
let _from = resolve2(from).replace(_ROOT_FOLDER_RE2, "$1").split("/"), _to = resolve2(to).replace(_ROOT_FOLDER_RE2, "$1").split("/");
|
|
3039
|
+
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0])
|
|
3040
|
+
return _to.join("/");
|
|
3041
|
+
let _fromCopy = [..._from];
|
|
3042
|
+
for (let segment of _fromCopy) {
|
|
3043
|
+
if (_to[0] !== segment)
|
|
3044
|
+
break;
|
|
3045
|
+
_from.shift(), _to.shift();
|
|
3046
|
+
}
|
|
3047
|
+
return [..._from.map(() => ".."), ..._to].join("/");
|
|
3048
|
+
}, dirname3 = function(p) {
|
|
3049
|
+
let segments = normalizeWindowsPath2(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
3050
|
+
return segments.length === 1 && _DRIVE_LETTER_RE2.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute2(p) ? "/" : ".");
|
|
3051
|
+
}, format2 = function(p) {
|
|
3052
|
+
let ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "", segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
|
|
3053
|
+
Boolean
|
|
3054
|
+
);
|
|
3055
|
+
return normalizeWindowsPath2(
|
|
3056
|
+
p.root ? resolve2(...segments) : segments.join("/")
|
|
3057
|
+
);
|
|
3058
|
+
}, basename2 = function(p, extension) {
|
|
3059
|
+
let segments = normalizeWindowsPath2(p).split("/"), lastSegment = "";
|
|
3060
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
3061
|
+
let val = segments[i];
|
|
3062
|
+
if (val) {
|
|
3063
|
+
lastSegment = val;
|
|
3064
|
+
break;
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
3068
|
+
}, parse2 = function(p) {
|
|
3069
|
+
let root = _PATH_ROOT_RE2.exec(p)?.[0]?.replace(/\\/g, "/") || "", base = basename2(p), extension = extname2(base);
|
|
3070
|
+
return {
|
|
3071
|
+
root,
|
|
3072
|
+
dir: dirname3(p),
|
|
3073
|
+
base,
|
|
3074
|
+
ext: extension,
|
|
3075
|
+
name: base.slice(0, base.length - extension.length)
|
|
3076
|
+
};
|
|
3077
|
+
}, matchesGlob2 = (path2, pattern) => zeptomatch2(pattern, normalize2(path2)), _path2 = {
|
|
3078
|
+
__proto__: null,
|
|
3079
|
+
basename: basename2,
|
|
3080
|
+
dirname: dirname3,
|
|
3081
|
+
extname: extname2,
|
|
3082
|
+
format: format2,
|
|
3083
|
+
isAbsolute: isAbsolute2,
|
|
3084
|
+
join: join2,
|
|
3085
|
+
matchesGlob: matchesGlob2,
|
|
3086
|
+
normalize: normalize2,
|
|
3087
|
+
normalizeString: normalizeString2,
|
|
3088
|
+
parse: parse2,
|
|
3089
|
+
relative: relative2,
|
|
3090
|
+
resolve: resolve2,
|
|
3091
|
+
sep: sep2,
|
|
3092
|
+
toNamespacedPath: toNamespacedPath2
|
|
3093
|
+
}, delimiter2 = globalThis.process?.platform === "win32" ? ";" : ":", _platforms2 = { posix: void 0, win32: void 0 }, mix2 = (del = delimiter2) => new Proxy(_path2, {
|
|
3094
|
+
get(_, prop) {
|
|
3095
|
+
return prop === "delimiter" ? del : prop === "posix" ? posix2 : prop === "win32" ? win322 : _platforms2[prop] || _path2[prop];
|
|
3096
|
+
}
|
|
3097
|
+
}), posix2 = mix2(":"), win322 = mix2(";"), DOCGEN_APIS = ["compiler", "native"], NATIVE_ENTRY_POINTS = { sync: "./sync", ast: "./ast", factory: "./ast/factory" };
|
|
3098
|
+
async function loadNativeTypeScriptModules(importEntry) {
|
|
3099
|
+
let [sync, ast, factory] = await Promise.all(
|
|
3100
|
+
Object.values(NATIVE_ENTRY_POINTS).map((subpath) => importEntry(subpath))
|
|
3101
|
+
);
|
|
3102
|
+
return { sync, ast, factory };
|
|
3103
|
+
}
|
|
3104
|
+
async function loadTypeScriptForDocgen(importEntry, specifier) {
|
|
3105
|
+
let typescript;
|
|
3106
|
+
try {
|
|
3107
|
+
let imported = await importEntry(".");
|
|
3108
|
+
typescript = imported.default ?? imported;
|
|
3109
|
+
} catch (cause) {
|
|
3110
|
+
throw isModuleNotFoundError2(cause) ? new TypeScriptMissingForDocgenError2({ cause, apis: DOCGEN_APIS }) : cause;
|
|
3111
|
+
}
|
|
3112
|
+
let { version } = typescript;
|
|
3113
|
+
if (!isTypeScriptUsableForDocgen2(version, DOCGEN_APIS))
|
|
3114
|
+
throw new TypeScriptWithoutCompilerApiError2({ version, apis: DOCGEN_APIS, specifier });
|
|
3115
|
+
return getTypeScriptDocgenApi2(version) === "native" ? { api: "native", typescript: await loadNativeTypeScriptModules(importEntry) } : { api: "compiler", typescript };
|
|
3116
|
+
}
|
|
3117
|
+
var importPackageEntry = ({ version, packageDir, main, exports }, subpath) => {
|
|
3118
|
+
let entry = exports ? exports[subpath] : subpath === "." ? main ?? "index.js" : void 0;
|
|
3119
|
+
if (typeof entry != "string")
|
|
3120
|
+
throw new Error(
|
|
3121
|
+
`TypeScript ${version} at ${packageDir} has no "${subpath}" entry point that Storybook can import`
|
|
3122
|
+
);
|
|
3123
|
+
return import(pathToFileURL(join2(packageDir, entry)).href);
|
|
3124
|
+
};
|
|
3125
|
+
function loadDocgenTypeScript(typeScriptSpecifier) {
|
|
3126
|
+
if (typeScriptSpecifier) {
|
|
3127
|
+
let typeScriptPackage = readTypeScriptPackageForDocgen2(typeScriptSpecifier, DOCGEN_APIS);
|
|
3128
|
+
return loadTypeScriptForDocgen(
|
|
3129
|
+
(subpath) => importPackageEntry(typeScriptPackage, subpath),
|
|
3130
|
+
typeScriptSpecifier.specifier
|
|
3131
|
+
);
|
|
3132
|
+
}
|
|
3133
|
+
return loadTypeScriptForDocgen((subpath) => import(`typescript${subpath.slice(1)}`));
|
|
3134
|
+
}
|
|
3135
|
+
|
|
3136
|
+
// ../../lib/component-meta-typescript/dist/index.js
|
|
3137
|
+
import {
|
|
3138
|
+
filterSourceFilePaths as filterSourceFilePaths2
|
|
3139
|
+
} from "storybook/internal/component-meta";
|
|
3140
|
+
import { logger as logger5 } from "storybook/internal/node-logger";
|
|
3141
|
+
var __filename4 = CJS_COMPAT_NODE_URL_6lg7c74mo834.fileURLToPath(import.meta.url), __dirname4 = CJS_COMPAT_NODE_PATH_6lg7c74mo834.dirname(__filename4), require5 = CJS_COMPAT_NODE_MODULE_6lg7c74mo834.createRequire(import.meta.url);
|
|
3142
|
+
|
|
1691
3143
|
// src/docgen/build-docgen.ts
|
|
1692
|
-
import {
|
|
1693
|
-
|
|
3144
|
+
import {
|
|
3145
|
+
getComponentIdFromEntry,
|
|
3146
|
+
getStoryImportPathFromEntry
|
|
3147
|
+
} from "storybook/internal/common";
|
|
3148
|
+
import { resolve as resolve3 } from "node:path";
|
|
1694
3149
|
|
|
1695
3150
|
// src/docgen/api-description.ts
|
|
1696
3151
|
var readMember = (name, argType) => {
|
|
@@ -1783,13 +3238,13 @@ var inputsOf = (entry) => "inputsClass" in entry ? entry.inputsClass ?? [] : [],
|
|
|
1783
3238
|
}))
|
|
1784
3239
|
};
|
|
1785
3240
|
}, errorPayload = (base, name, message) => ({ ...base, jsDocTags: {}, error: { name, message } }), buildDocgenPayload = (input, context) => {
|
|
1786
|
-
let { manager, options, logger:
|
|
3241
|
+
let { manager, options, logger: logger7 } = context, storyImportPath = getStoryImportPathFromEntry(input.entry);
|
|
1787
3242
|
if (!storyImportPath)
|
|
1788
3243
|
return;
|
|
1789
|
-
let storyFilePath = (context.resolvePath ?? ((importPath) =>
|
|
3244
|
+
let storyFilePath = (context.resolvePath ?? ((importPath) => resolve3(process.cwd(), importPath)))(storyImportPath), resolved = resolveStoryComponent(storyFilePath, input.entry.title);
|
|
1790
3245
|
if ("reason" in resolved) {
|
|
1791
3246
|
if (resolved.reason === "no-meta-component") {
|
|
1792
|
-
|
|
3247
|
+
logger7.debug(`No Angular component resolved from ${storyFilePath}: ${resolved.reason}.`);
|
|
1793
3248
|
return;
|
|
1794
3249
|
}
|
|
1795
3250
|
let unreadableBase = {
|
|
@@ -1848,14 +3303,14 @@ Check that the file exports the component class and is covered by a tsconfig.jso
|
|
|
1848
3303
|
let argTypes = extractArgTypesFromData(meta.entry, {
|
|
1849
3304
|
metadataJson: meta.json,
|
|
1850
3305
|
propsTable: options.propsTable,
|
|
1851
|
-
logger:
|
|
3306
|
+
logger: logger7,
|
|
1852
3307
|
// Named-type table detail resolves against the analyzer's live context; absent for stubbed
|
|
1853
3308
|
// analyzers, which keeps those payloads flat.
|
|
1854
3309
|
context: meta.context
|
|
1855
3310
|
}), apiArgTypes = options.propsTable === "api" ? argTypes : extractArgTypesFromData(meta.entry, {
|
|
1856
3311
|
metadataJson: meta.json,
|
|
1857
3312
|
propsTable: "api",
|
|
1858
|
-
logger:
|
|
3313
|
+
logger: logger7,
|
|
1859
3314
|
context: meta.context
|
|
1860
3315
|
}), jsDocTags = meta.jsDocInfo?.jsDocTags ?? analyzerJsDocTags(meta.entry), description = describedBy(meta.jsDocInfo?.description) ?? describedBy(meta.entry.rawdescription) ?? describedBy(meta.entry.description);
|
|
1861
3316
|
return {
|
|
@@ -1874,16 +3329,16 @@ Check that the file exports the component class and is covered by a tsconfig.jso
|
|
|
1874
3329
|
|
|
1875
3330
|
// src/docgen/docgen-worker.ts
|
|
1876
3331
|
var workerLogger = {
|
|
1877
|
-
warn: (message) =>
|
|
1878
|
-
debug: (message) =>
|
|
1879
|
-
}, createManager = async () => {
|
|
3332
|
+
warn: (message) => logger6.warn(`[storybook-angular-vite] ${message}`),
|
|
3333
|
+
debug: (message) => logger6.debug(`[storybook-angular-vite] ${message}`)
|
|
3334
|
+
}, createManager = async (typeScriptSpecifier) => {
|
|
1880
3335
|
try {
|
|
1881
3336
|
let manager = new AngularComponentMetaManager(
|
|
1882
|
-
await
|
|
3337
|
+
await loadDocgenTypeScript(typeScriptSpecifier)
|
|
1883
3338
|
);
|
|
1884
3339
|
return manager.startWatching(), manager;
|
|
1885
3340
|
} catch (error) {
|
|
1886
|
-
|
|
3341
|
+
logger6.warn(
|
|
1887
3342
|
`Angular docgen is unavailable: the component meta analyzer could not be created. ${error instanceof Error ? error.message : String(error)}`
|
|
1888
3343
|
);
|
|
1889
3344
|
return;
|
|
@@ -1894,7 +3349,7 @@ var workerLogger = {
|
|
|
1894
3349
|
let storyImportPath = getStoryImportPathFromEntry2(input.entry);
|
|
1895
3350
|
if (!storyImportPath || !STORY_FILE_TEST_REGEXP.test(storyImportPath))
|
|
1896
3351
|
return nextDocgen(input);
|
|
1897
|
-
let manager = await (managerPromise ??= createManager());
|
|
3352
|
+
let manager = await (managerPromise ??= createManager(options.typeScriptSpecifier));
|
|
1898
3353
|
if (!manager)
|
|
1899
3354
|
return nextDocgen(input);
|
|
1900
3355
|
let ours = buildDocgenPayload(input, { manager, options, logger: workerLogger });
|