storybook 9.0.0-alpha.1 → 9.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -29
- package/assets/browser/favicon.svg +1 -0
- package/assets/browser/nunito-sans-bold-italic.woff2 +0 -0
- package/assets/browser/nunito-sans-bold.woff2 +0 -0
- package/assets/browser/nunito-sans-italic.woff2 +0 -0
- package/assets/browser/nunito-sans-regular.woff2 +0 -0
- package/assets/docs/addon-controls-args-annotated.png +0 -0
- package/assets/docs/addon-controls-args-background-color.png +0 -0
- package/assets/docs/addon-controls-args-background-string.png +0 -0
- package/assets/docs/addon-controls-args-docs.png +0 -0
- package/assets/docs/addon-controls-args-logging.png +0 -0
- package/assets/docs/addon-controls-args-no-annotation.png +0 -0
- package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
- package/assets/docs/addon-controls-args-reflow.png +0 -0
- package/assets/docs/addon-controls-args-template.png +0 -0
- package/assets/docs/addon-controls-expanded.png +0 -0
- package/assets/docs/addon-controls-hero.gif +0 -0
- package/assets/docs/addon-controls-install.png +0 -0
- package/assets/docs/hero.gif +0 -0
- package/assets/docs/message-reference.png +0 -0
- package/assets/docs/viewport.png +0 -0
- package/assets/server/addon.tsconfig.json +6 -0
- package/assets/server/base-preview-body.html +119 -0
- package/assets/server/base-preview-head.html +451 -0
- package/assets/server/template.ejs +87 -0
- package/bin/index.cjs +1 -1
- package/dist/actions/decorator.d.ts +6 -0
- package/dist/actions/decorator.js +139 -0
- package/dist/actions/index.cjs +127 -0
- package/dist/actions/index.d.ts +105 -0
- package/dist/actions/index.js +112 -0
- package/dist/actions/manager.js +1196 -0
- package/dist/actions/preview.cjs +165 -0
- package/dist/actions/preview.d.ts +55 -0
- package/dist/actions/preview.js +156 -0
- package/dist/babel/index.cjs +54034 -0
- package/dist/babel/index.d.ts +7488 -0
- package/dist/babel/index.js +54044 -0
- package/dist/bin/index.cjs +119 -0
- package/dist/bin/index.js +113 -0
- package/dist/builder-manager/index.cjs +2140 -0
- package/dist/builder-manager/index.d.ts +19 -0
- package/dist/builder-manager/index.js +2162 -0
- package/dist/channels/index.cjs +1913 -0
- package/dist/channels/index.d.ts +108 -0
- package/dist/channels/index.js +1881 -0
- package/dist/cli/bin/index.cjs +2687 -0
- package/dist/cli/bin/index.d.ts +2 -0
- package/dist/cli/bin/index.js +2707 -0
- package/dist/cli/index.cjs +17327 -0
- package/dist/cli/index.d.ts +209 -0
- package/dist/cli/index.js +17349 -0
- package/dist/client-logger/index.cjs +80 -0
- package/dist/client-logger/index.d.ts +29 -0
- package/dist/client-logger/index.js +64 -0
- package/dist/common/index.cjs +20569 -0
- package/dist/common/index.d.ts +949 -0
- package/dist/common/index.js +20654 -0
- package/dist/components/index.cjs +27924 -0
- package/dist/components/index.d.ts +1423 -0
- package/dist/components/index.js +24673 -0
- package/dist/controls/decorator.d.ts +5 -0
- package/dist/controls/decorator.js +8 -0
- package/dist/controls/index.cjs +26 -0
- package/dist/controls/index.d.ts +39 -0
- package/dist/controls/index.js +6 -0
- package/dist/controls/manager.js +5545 -0
- package/dist/controls/preview.cjs +26 -0
- package/dist/controls/preview.d.ts +55 -0
- package/dist/controls/preview.js +9 -0
- package/dist/core-events/index.cjs +167 -0
- package/dist/core-events/index.d.ts +426 -0
- package/dist/core-events/index.js +149 -0
- package/dist/core-server/index.cjs +38183 -0
- package/dist/core-server/index.d.ts +720 -0
- package/dist/core-server/index.js +38272 -0
- package/dist/core-server/presets/common-manager.js +20 -0
- package/dist/core-server/presets/common-override-preset.cjs +4824 -0
- package/dist/core-server/presets/common-override-preset.js +4829 -0
- package/dist/core-server/presets/common-preset.cjs +10231 -0
- package/dist/core-server/presets/common-preset.js +10309 -0
- package/dist/csf/index.cjs +179 -0
- package/dist/csf/index.d.ts +750 -0
- package/dist/csf/index.js +172 -0
- package/dist/csf-tools/index.cjs +1422 -0
- package/dist/csf-tools/index.d.ts +250 -0
- package/dist/csf-tools/index.js +1439 -0
- package/dist/docs-tools/index.cjs +2891 -0
- package/dist/docs-tools/index.d.ts +162 -0
- package/dist/docs-tools/index.js +2876 -0
- package/dist/index.cjs +17 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -7
- package/dist/instrumenter/index.cjs +3485 -0
- package/dist/instrumenter/index.d.ts +104 -0
- package/dist/instrumenter/index.js +4965 -0
- package/dist/manager/globals-module-info.cjs +817 -0
- package/dist/manager/globals-module-info.d.ts +36 -0
- package/dist/manager/globals-module-info.js +804 -0
- package/dist/manager/globals-runtime.js +77536 -0
- package/dist/manager/globals.cjs +47 -0
- package/dist/manager/globals.d.ts +24 -0
- package/dist/manager/globals.js +34 -0
- package/dist/manager/runtime.js +12323 -0
- package/dist/manager-api/index.cjs +11074 -0
- package/dist/manager-api/index.d.ts +1512 -0
- package/dist/manager-api/index.js +4835 -0
- package/dist/manager-errors.d.ts +89 -0
- package/dist/manager-errors.js +99 -0
- package/dist/node-logger/index.cjs +1642 -0
- package/dist/node-logger/index.d.ts +117 -0
- package/dist/node-logger/index.js +1652 -0
- package/dist/preview/globals.cjs +38 -0
- package/dist/preview/globals.d.ts +15 -0
- package/dist/preview/globals.js +25 -0
- package/dist/preview/runtime.js +43629 -0
- package/dist/preview-api/index.cjs +5224 -0
- package/dist/preview-api/index.d.ts +1093 -0
- package/dist/preview-api/index.js +5292 -0
- package/dist/preview-errors.cjs +503 -0
- package/dist/preview-errors.d.ts +212 -0
- package/dist/preview-errors.js +449 -0
- package/dist/router/index.cjs +3296 -0
- package/dist/router/index.d.ts +385 -0
- package/dist/router/index.js +1843 -0
- package/dist/server-errors.cjs +727 -0
- package/dist/server-errors.d.ts +296 -0
- package/dist/server-errors.js +728 -0
- package/dist/telemetry/index.cjs +2756 -0
- package/dist/telemetry/index.d.ts +133 -0
- package/dist/telemetry/index.js +2797 -0
- package/dist/test/index.cjs +35685 -0
- package/dist/test/index.d.ts +186 -0
- package/dist/test/index.js +33751 -0
- package/dist/test/preview.cjs +15869 -0
- package/dist/test/preview.d.ts +54 -0
- package/dist/test/preview.js +14440 -0
- package/dist/test/spy.cjs +257 -0
- package/dist/test/spy.d.ts +66 -0
- package/dist/test/spy.js +239 -0
- package/dist/theming/create.cjs +232 -0
- package/dist/theming/create.d.ts +50 -0
- package/dist/theming/create.js +216 -0
- package/dist/theming/index.cjs +2665 -0
- package/dist/theming/index.d.ts +11939 -0
- package/dist/theming/index.js +2485 -0
- package/dist/types/index.cjs +27 -0
- package/dist/types/index.d.ts +2795 -0
- package/dist/types/index.js +7 -0
- package/dist/viewport/index.cjs +310 -0
- package/dist/viewport/index.d.ts +320 -0
- package/dist/viewport/index.js +290 -0
- package/dist/viewport/manager.js +400 -0
- package/dist/viewport/preview.cjs +35 -0
- package/dist/viewport/preview.d.ts +69 -0
- package/dist/viewport/preview.js +19 -0
- package/package.json +518 -209
- package/.eslintrc.cjs +0 -31
- package/__mocks__/@aw-web-design/x-default-browser.js +0 -2
- package/core/babel/index.cjs +0 -1
- package/core/babel/index.d.ts +0 -2
- package/core/babel/index.js +0 -1
- package/core/builder-manager/index.cjs +0 -1
- package/core/builder-manager/index.d.ts +0 -2
- package/core/builder-manager/index.js +0 -1
- package/core/channels/index.cjs +0 -1
- package/core/channels/index.d.ts +0 -2
- package/core/channels/index.js +0 -1
- package/core/cli/bin/index.cjs +0 -1
- package/core/cli/bin/index.d.ts +0 -2
- package/core/cli/bin/index.js +0 -1
- package/core/cli/index.cjs +0 -1
- package/core/cli/index.d.ts +0 -2
- package/core/cli/index.js +0 -1
- package/core/client-logger/index.cjs +0 -1
- package/core/client-logger/index.d.ts +0 -2
- package/core/client-logger/index.js +0 -1
- package/core/common/index.cjs +0 -1
- package/core/common/index.d.ts +0 -2
- package/core/common/index.js +0 -1
- package/core/components/index.cjs +0 -1
- package/core/components/index.d.ts +0 -2
- package/core/components/index.js +0 -1
- package/core/core-events/index.cjs +0 -1
- package/core/core-events/index.d.ts +0 -2
- package/core/core-events/index.js +0 -1
- package/core/core-server/index.cjs +0 -1
- package/core/core-server/index.d.ts +0 -2
- package/core/core-server/index.js +0 -1
- package/core/core-server/presets/common-manager.js +0 -1
- package/core/core-server/presets/common-override-preset.cjs +0 -1
- package/core/core-server/presets/common-override-preset.js +0 -1
- package/core/core-server/presets/common-preset.cjs +0 -1
- package/core/core-server/presets/common-preset.js +0 -1
- package/core/csf/index.cjs +0 -1
- package/core/csf/index.d.ts +0 -2
- package/core/csf/index.js +0 -1
- package/core/csf-tools/index.cjs +0 -1
- package/core/csf-tools/index.d.ts +0 -2
- package/core/csf-tools/index.js +0 -1
- package/core/docs-tools/index.cjs +0 -1
- package/core/docs-tools/index.d.ts +0 -2
- package/core/docs-tools/index.js +0 -1
- package/core/index.cjs +0 -1
- package/core/index.d.ts +0 -2
- package/core/index.js +0 -1
- package/core/manager/globals-module-info.cjs +0 -1
- package/core/manager/globals-module-info.d.ts +0 -2
- package/core/manager/globals-module-info.js +0 -1
- package/core/manager/globals-runtime.js +0 -1
- package/core/manager/globals.cjs +0 -1
- package/core/manager/globals.d.ts +0 -2
- package/core/manager/globals.js +0 -1
- package/core/manager-api/index.cjs +0 -1
- package/core/manager-api/index.d.ts +0 -2
- package/core/manager-api/index.js +0 -1
- package/core/manager-errors.d.ts +0 -2
- package/core/manager-errors.js +0 -1
- package/core/node-logger/index.cjs +0 -1
- package/core/node-logger/index.d.ts +0 -2
- package/core/node-logger/index.js +0 -1
- package/core/preview/globals.cjs +0 -1
- package/core/preview/globals.d.ts +0 -2
- package/core/preview/globals.js +0 -1
- package/core/preview/runtime.js +0 -1
- package/core/preview-api/index.cjs +0 -1
- package/core/preview-api/index.d.ts +0 -2
- package/core/preview-api/index.js +0 -1
- package/core/preview-errors.cjs +0 -1
- package/core/preview-errors.d.ts +0 -2
- package/core/preview-errors.js +0 -1
- package/core/router/index.cjs +0 -1
- package/core/router/index.d.ts +0 -2
- package/core/router/index.js +0 -1
- package/core/server-errors.cjs +0 -1
- package/core/server-errors.d.ts +0 -2
- package/core/server-errors.js +0 -1
- package/core/telemetry/index.cjs +0 -1
- package/core/telemetry/index.d.ts +0 -2
- package/core/telemetry/index.js +0 -1
- package/core/theming/create.cjs +0 -1
- package/core/theming/create.d.ts +0 -2
- package/core/theming/create.js +0 -1
- package/core/theming/index.cjs +0 -1
- package/core/theming/index.d.ts +0 -2
- package/core/theming/index.js +0 -1
- package/core/types/index.cjs +0 -1
- package/core/types/index.d.ts +0 -2
- package/core/types/index.js +0 -1
- package/core.cjs +0 -0
- package/core.d.ts +0 -0
- package/core.js +0 -1
- package/dist/chunk-OWLSIX54.js +0 -8
- package/dist/core-path.cjs +0 -1
- package/dist/core-path.d.ts +0 -3
- package/dist/core-path.js +0 -9
- package/dist/proxy.cjs +0 -1
- package/dist/proxy.d.ts +0 -2
- package/dist/proxy.js +0 -9
|
@@ -0,0 +1,2891 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var dr = Object.create;
|
|
3
|
+
var z = Object.defineProperty;
|
|
4
|
+
var Tr = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var gr = Object.getOwnPropertyNames;
|
|
6
|
+
var hr = Object.getPrototypeOf, xr = Object.prototype.hasOwnProperty;
|
|
7
|
+
var r = (n, s) => z(n, "name", { value: s, configurable: !0 });
|
|
8
|
+
var Jr = (n, s) => () => (s || n((s = { exports: {} }).exports, s), s.exports), wr = (n, s) => {
|
|
9
|
+
for (var a in s)
|
|
10
|
+
z(n, a, { get: s[a], enumerable: !0 });
|
|
11
|
+
}, st = (n, s, a, p) => {
|
|
12
|
+
if (s && typeof s == "object" || typeof s == "function")
|
|
13
|
+
for (let c of gr(s))
|
|
14
|
+
!xr.call(n, c) && c !== a && z(n, c, { get: () => s[c], enumerable: !(p = Tr(s, c)) || p.enumerable });
|
|
15
|
+
return n;
|
|
16
|
+
};
|
|
17
|
+
var Pr = (n, s, a) => (a = n != null ? dr(hr(n)) : {}, st(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
s || !n || !n.__esModule ? z(a, "default", { value: n, enumerable: !0 }) : a,
|
|
23
|
+
n
|
|
24
|
+
)), br = (n) => st(z({}, "__esModule", { value: !0 }), n);
|
|
25
|
+
|
|
26
|
+
// ../node_modules/jsdoc-type-pratt-parser/dist/index.js
|
|
27
|
+
var dt = Jr((le, ft) => {
|
|
28
|
+
(function(n, s) {
|
|
29
|
+
typeof le == "object" && typeof ft < "u" ? s(le) : typeof define == "function" && define.amd ? define(["exports"], s) : (n = typeof globalThis <
|
|
30
|
+
"u" ? globalThis : n || self, s(n.jtpp = {}));
|
|
31
|
+
})(le, function(n) {
|
|
32
|
+
"use strict";
|
|
33
|
+
function s(e) {
|
|
34
|
+
return e.text !== void 0 && e.text !== "" ? `'${e.type}' with value '${e.text}'` : `'${e.type}'`;
|
|
35
|
+
}
|
|
36
|
+
r(s, "tokenToString");
|
|
37
|
+
class a extends Error {
|
|
38
|
+
static {
|
|
39
|
+
r(this, "NoParsletFoundError");
|
|
40
|
+
}
|
|
41
|
+
constructor(t) {
|
|
42
|
+
super(`No parslet found for token: ${s(t)}`), this.token = t, Object.setPrototypeOf(this, a.prototype);
|
|
43
|
+
}
|
|
44
|
+
getToken() {
|
|
45
|
+
return this.token;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
class p extends Error {
|
|
49
|
+
static {
|
|
50
|
+
r(this, "EarlyEndOfParseError");
|
|
51
|
+
}
|
|
52
|
+
constructor(t) {
|
|
53
|
+
super(`The parsing ended early. The next token was: ${s(t)}`), this.token = t, Object.setPrototypeOf(this, p.prototype);
|
|
54
|
+
}
|
|
55
|
+
getToken() {
|
|
56
|
+
return this.token;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
class c extends Error {
|
|
60
|
+
static {
|
|
61
|
+
r(this, "UnexpectedTypeError");
|
|
62
|
+
}
|
|
63
|
+
constructor(t, o) {
|
|
64
|
+
let i = `Unexpected type: '${t.type}'.`;
|
|
65
|
+
o !== void 0 && (i += ` Message: ${o}`), super(i), Object.setPrototypeOf(this, c.prototype);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function u(e) {
|
|
69
|
+
return (t) => t.startsWith(e) ? { type: e, text: e } : null;
|
|
70
|
+
}
|
|
71
|
+
r(u, "makePunctuationRule");
|
|
72
|
+
function y(e) {
|
|
73
|
+
let t = 0, o, i = e[0], l = !1;
|
|
74
|
+
if (i !== "'" && i !== '"')
|
|
75
|
+
return null;
|
|
76
|
+
for (; t < e.length; ) {
|
|
77
|
+
if (t++, o = e[t], !l && o === i) {
|
|
78
|
+
t++;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
l = !l && o === "\\";
|
|
82
|
+
}
|
|
83
|
+
if (o !== i)
|
|
84
|
+
throw new Error("Unterminated String");
|
|
85
|
+
return e.slice(0, t);
|
|
86
|
+
}
|
|
87
|
+
r(y, "getQuoted");
|
|
88
|
+
let T = /[$_\p{ID_Start}]|\\u\p{Hex_Digit}{4}|\\u\{0*(?:\p{Hex_Digit}{1,5}|10\p{Hex_Digit}{4})\}/u, g = /[$\-\p{ID_Continue}\u200C\u200D]|\\u\p{Hex_Digit}{4}|\\u\{0*(?:\p{Hex_Digit}{1,5}|10\p{Hex_Digit}{4})\}/u;
|
|
89
|
+
function P(e) {
|
|
90
|
+
let t = e[0];
|
|
91
|
+
if (!T.test(t))
|
|
92
|
+
return null;
|
|
93
|
+
let o = 1;
|
|
94
|
+
do {
|
|
95
|
+
if (t = e[o], !g.test(t))
|
|
96
|
+
break;
|
|
97
|
+
o++;
|
|
98
|
+
} while (o < e.length);
|
|
99
|
+
return e.slice(0, o);
|
|
100
|
+
}
|
|
101
|
+
r(P, "getIdentifier");
|
|
102
|
+
let b = /^(NaN|-?((\d*\.\d+|\d+)([Ee][+-]?\d+)?|Infinity))/;
|
|
103
|
+
function ye(e) {
|
|
104
|
+
var t, o;
|
|
105
|
+
return (o = (t = b.exec(e)) === null || t === void 0 ? void 0 : t[0]) !== null && o !== void 0 ? o : null;
|
|
106
|
+
}
|
|
107
|
+
r(ye, "getNumber");
|
|
108
|
+
let $ = /* @__PURE__ */ r((e) => {
|
|
109
|
+
let t = P(e);
|
|
110
|
+
return t == null ? null : {
|
|
111
|
+
type: "Identifier",
|
|
112
|
+
text: t
|
|
113
|
+
};
|
|
114
|
+
}, "identifierRule");
|
|
115
|
+
function E(e) {
|
|
116
|
+
return (t) => {
|
|
117
|
+
if (!t.startsWith(e))
|
|
118
|
+
return null;
|
|
119
|
+
let o = t[e.length];
|
|
120
|
+
return o !== void 0 && g.test(o) ? null : {
|
|
121
|
+
type: e,
|
|
122
|
+
text: e
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
r(E, "makeKeyWordRule");
|
|
127
|
+
let H = /* @__PURE__ */ r((e) => {
|
|
128
|
+
let t = y(e);
|
|
129
|
+
return t == null ? null : {
|
|
130
|
+
type: "StringValue",
|
|
131
|
+
text: t
|
|
132
|
+
};
|
|
133
|
+
}, "stringValueRule"), fe = /* @__PURE__ */ r((e) => e.length > 0 ? null : {
|
|
134
|
+
type: "EOF",
|
|
135
|
+
text: ""
|
|
136
|
+
}, "eofRule"), de = /* @__PURE__ */ r((e) => {
|
|
137
|
+
let t = ye(e);
|
|
138
|
+
return t === null ? null : {
|
|
139
|
+
type: "Number",
|
|
140
|
+
text: t
|
|
141
|
+
};
|
|
142
|
+
}, "numberRule"), Ft = [
|
|
143
|
+
fe,
|
|
144
|
+
u("=>"),
|
|
145
|
+
u("("),
|
|
146
|
+
u(")"),
|
|
147
|
+
u("{"),
|
|
148
|
+
u("}"),
|
|
149
|
+
u("["),
|
|
150
|
+
u("]"),
|
|
151
|
+
u("|"),
|
|
152
|
+
u("&"),
|
|
153
|
+
u("<"),
|
|
154
|
+
u(">"),
|
|
155
|
+
u(","),
|
|
156
|
+
u(";"),
|
|
157
|
+
u("*"),
|
|
158
|
+
u("?"),
|
|
159
|
+
u("!"),
|
|
160
|
+
u("="),
|
|
161
|
+
u(":"),
|
|
162
|
+
u("..."),
|
|
163
|
+
u("."),
|
|
164
|
+
u("#"),
|
|
165
|
+
u("~"),
|
|
166
|
+
u("/"),
|
|
167
|
+
u("@"),
|
|
168
|
+
E("undefined"),
|
|
169
|
+
E("null"),
|
|
170
|
+
E("function"),
|
|
171
|
+
E("this"),
|
|
172
|
+
E("new"),
|
|
173
|
+
E("module"),
|
|
174
|
+
E("event"),
|
|
175
|
+
E("external"),
|
|
176
|
+
E("typeof"),
|
|
177
|
+
E("keyof"),
|
|
178
|
+
E("readonly"),
|
|
179
|
+
E("import"),
|
|
180
|
+
E("is"),
|
|
181
|
+
E("in"),
|
|
182
|
+
de,
|
|
183
|
+
$,
|
|
184
|
+
H
|
|
185
|
+
], jt = /^\s*\n\s*/;
|
|
186
|
+
class q {
|
|
187
|
+
static {
|
|
188
|
+
r(this, "Lexer");
|
|
189
|
+
}
|
|
190
|
+
static create(t) {
|
|
191
|
+
let o = this.read(t);
|
|
192
|
+
t = o.text;
|
|
193
|
+
let i = this.read(t);
|
|
194
|
+
return t = i.text, new q(t, void 0, o.token, i.token);
|
|
195
|
+
}
|
|
196
|
+
constructor(t, o, i, l) {
|
|
197
|
+
this.text = "", this.text = t, this.previous = o, this.current = i, this.next = l;
|
|
198
|
+
}
|
|
199
|
+
static read(t, o = !1) {
|
|
200
|
+
o = o || jt.test(t), t = t.trim();
|
|
201
|
+
for (let i of Ft) {
|
|
202
|
+
let l = i(t);
|
|
203
|
+
if (l !== null) {
|
|
204
|
+
let m = Object.assign(Object.assign({}, l), { startOfLine: o });
|
|
205
|
+
return t = t.slice(m.text.length), { text: t, token: m };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
throw new Error("Unexpected Token " + t);
|
|
209
|
+
}
|
|
210
|
+
advance() {
|
|
211
|
+
let t = q.read(this.text);
|
|
212
|
+
return new q(t.text, this.current, this.next, t.token);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function w(e) {
|
|
216
|
+
if (e === void 0)
|
|
217
|
+
throw new Error("Unexpected undefined");
|
|
218
|
+
if (e.type === "JsdocTypeKeyValue" || e.type === "JsdocTypeParameterList" || e.type === "JsdocTypeProperty" || e.type === "JsdocTypeRe\
|
|
219
|
+
adonlyProperty" || e.type === "JsdocTypeObjectField" || e.type === "JsdocTypeJsdocObjectField" || e.type === "JsdocTypeIndexSignature" || e.
|
|
220
|
+
type === "JsdocTypeMappedType")
|
|
221
|
+
throw new c(e);
|
|
222
|
+
return e;
|
|
223
|
+
}
|
|
224
|
+
r(w, "assertRootResult");
|
|
225
|
+
function Te(e) {
|
|
226
|
+
return e.type === "JsdocTypeKeyValue" ? Q(e) : w(e);
|
|
227
|
+
}
|
|
228
|
+
r(Te, "assertPlainKeyValueOrRootResult");
|
|
229
|
+
function _t(e) {
|
|
230
|
+
return e.type === "JsdocTypeName" ? e : Q(e);
|
|
231
|
+
}
|
|
232
|
+
r(_t, "assertPlainKeyValueOrNameResult");
|
|
233
|
+
function Q(e) {
|
|
234
|
+
if (e.type !== "JsdocTypeKeyValue")
|
|
235
|
+
throw new c(e);
|
|
236
|
+
return e;
|
|
237
|
+
}
|
|
238
|
+
r(Q, "assertPlainKeyValueResult");
|
|
239
|
+
function Lt(e) {
|
|
240
|
+
var t;
|
|
241
|
+
if (e.type === "JsdocTypeVariadic") {
|
|
242
|
+
if (((t = e.element) === null || t === void 0 ? void 0 : t.type) === "JsdocTypeName")
|
|
243
|
+
return e;
|
|
244
|
+
throw new c(e);
|
|
245
|
+
}
|
|
246
|
+
if (e.type !== "JsdocTypeNumber" && e.type !== "JsdocTypeName")
|
|
247
|
+
throw new c(e);
|
|
248
|
+
return e;
|
|
249
|
+
}
|
|
250
|
+
r(Lt, "assertNumberOrVariadicNameResult");
|
|
251
|
+
function ge(e) {
|
|
252
|
+
return e.type === "JsdocTypeIndexSignature" || e.type === "JsdocTypeMappedType";
|
|
253
|
+
}
|
|
254
|
+
r(ge, "isSquaredProperty");
|
|
255
|
+
var f;
|
|
256
|
+
(function(e) {
|
|
257
|
+
e[e.ALL = 0] = "ALL", e[e.PARAMETER_LIST = 1] = "PARAMETER_LIST", e[e.OBJECT = 2] = "OBJECT", e[e.KEY_VALUE = 3] = "KEY_VALUE", e[e.UNION =
|
|
258
|
+
4] = "UNION", e[e.INTERSECTION = 5] = "INTERSECTION", e[e.PREFIX = 6] = "PREFIX", e[e.INFIX = 7] = "INFIX", e[e.TUPLE = 8] = "TUPLE", e[e.
|
|
259
|
+
SYMBOL = 9] = "SYMBOL", e[e.OPTIONAL = 10] = "OPTIONAL", e[e.NULLABLE = 11] = "NULLABLE", e[e.KEY_OF_TYPE_OF = 12] = "KEY_OF_TYPE_OF",
|
|
260
|
+
e[e.FUNCTION = 13] = "FUNCTION", e[e.ARROW = 14] = "ARROW", e[e.ARRAY_BRACKETS = 15] = "ARRAY_BRACKETS", e[e.GENERIC = 16] = "GENERIC",
|
|
261
|
+
e[e.NAME_PATH = 17] = "NAME_PATH", e[e.PARENTHESIS = 18] = "PARENTHESIS", e[e.SPECIAL_TYPES = 19] = "SPECIAL_TYPES";
|
|
262
|
+
})(f || (f = {}));
|
|
263
|
+
class V {
|
|
264
|
+
static {
|
|
265
|
+
r(this, "Parser");
|
|
266
|
+
}
|
|
267
|
+
constructor(t, o, i) {
|
|
268
|
+
this.grammar = t, typeof o == "string" ? this._lexer = q.create(o) : this._lexer = o, this.baseParser = i;
|
|
269
|
+
}
|
|
270
|
+
get lexer() {
|
|
271
|
+
return this._lexer;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Parses a given string and throws an error if the parse ended before the end of the string.
|
|
275
|
+
*/
|
|
276
|
+
parse() {
|
|
277
|
+
let t = this.parseType(f.ALL);
|
|
278
|
+
if (this.lexer.current.type !== "EOF")
|
|
279
|
+
throw new p(this.lexer.current);
|
|
280
|
+
return t;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Parses with the current lexer and asserts that the result is a {@link RootResult}.
|
|
284
|
+
*/
|
|
285
|
+
parseType(t) {
|
|
286
|
+
return w(this.parseIntermediateType(t));
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* The main parsing function. First it tries to parse the current state in the prefix step, and then it continues
|
|
290
|
+
* to parse the state in the infix step.
|
|
291
|
+
*/
|
|
292
|
+
parseIntermediateType(t) {
|
|
293
|
+
let o = this.tryParslets(null, t);
|
|
294
|
+
if (o === null)
|
|
295
|
+
throw new a(this.lexer.current);
|
|
296
|
+
return this.parseInfixIntermediateType(o, t);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* In the infix parsing step the parser continues to parse the current state with all parslets until none returns
|
|
300
|
+
* a result.
|
|
301
|
+
*/
|
|
302
|
+
parseInfixIntermediateType(t, o) {
|
|
303
|
+
let i = this.tryParslets(t, o);
|
|
304
|
+
for (; i !== null; )
|
|
305
|
+
t = i, i = this.tryParslets(t, o);
|
|
306
|
+
return t;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Tries to parse the current state with all parslets in the grammar and returns the first non null result.
|
|
310
|
+
*/
|
|
311
|
+
tryParslets(t, o) {
|
|
312
|
+
for (let i of this.grammar) {
|
|
313
|
+
let l = i(this, o, t);
|
|
314
|
+
if (l !== null)
|
|
315
|
+
return l;
|
|
316
|
+
}
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* If the given type equals the current type of the {@link Lexer} advance the lexer. Return true if the lexer was
|
|
321
|
+
* advanced.
|
|
322
|
+
*/
|
|
323
|
+
consume(t) {
|
|
324
|
+
return Array.isArray(t) || (t = [t]), t.includes(this.lexer.current.type) ? (this._lexer = this.lexer.advance(), !0) : !1;
|
|
325
|
+
}
|
|
326
|
+
acceptLexerState(t) {
|
|
327
|
+
this._lexer = t.lexer;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function We(e) {
|
|
331
|
+
return e === "EOF" || e === "|" || e === "," || e === ")" || e === ">";
|
|
332
|
+
}
|
|
333
|
+
r(We, "isQuestionMarkUnknownType");
|
|
334
|
+
let he = /* @__PURE__ */ r((e, t, o) => {
|
|
335
|
+
let i = e.lexer.current.type, l = e.lexer.next.type;
|
|
336
|
+
return o == null && i === "?" && !We(l) || o != null && i === "?" ? (e.consume("?"), o == null ? {
|
|
337
|
+
type: "JsdocTypeNullable",
|
|
338
|
+
element: e.parseType(f.NULLABLE),
|
|
339
|
+
meta: {
|
|
340
|
+
position: "prefix"
|
|
341
|
+
}
|
|
342
|
+
} : {
|
|
343
|
+
type: "JsdocTypeNullable",
|
|
344
|
+
element: w(o),
|
|
345
|
+
meta: {
|
|
346
|
+
position: "suffix"
|
|
347
|
+
}
|
|
348
|
+
}) : null;
|
|
349
|
+
}, "nullableParslet");
|
|
350
|
+
function h(e) {
|
|
351
|
+
let t = /* @__PURE__ */ r((o, i, l) => {
|
|
352
|
+
let m = o.lexer.current.type, d = o.lexer.next.type;
|
|
353
|
+
if (l === null) {
|
|
354
|
+
if ("parsePrefix" in e && e.accept(m, d))
|
|
355
|
+
return e.parsePrefix(o);
|
|
356
|
+
} else if ("parseInfix" in e && e.precedence > i && e.accept(m, d))
|
|
357
|
+
return e.parseInfix(o, l);
|
|
358
|
+
return null;
|
|
359
|
+
}, "parslet");
|
|
360
|
+
return Object.defineProperty(t, "name", {
|
|
361
|
+
value: e.name
|
|
362
|
+
}), t;
|
|
363
|
+
}
|
|
364
|
+
r(h, "composeParslet");
|
|
365
|
+
let Z = h({
|
|
366
|
+
name: "optionalParslet",
|
|
367
|
+
accept: /* @__PURE__ */ r((e) => e === "=", "accept"),
|
|
368
|
+
precedence: f.OPTIONAL,
|
|
369
|
+
parsePrefix: /* @__PURE__ */ r((e) => (e.consume("="), {
|
|
370
|
+
type: "JsdocTypeOptional",
|
|
371
|
+
element: e.parseType(f.OPTIONAL),
|
|
372
|
+
meta: {
|
|
373
|
+
position: "prefix"
|
|
374
|
+
}
|
|
375
|
+
}), "parsePrefix"),
|
|
376
|
+
parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("="), {
|
|
377
|
+
type: "JsdocTypeOptional",
|
|
378
|
+
element: w(t),
|
|
379
|
+
meta: {
|
|
380
|
+
position: "suffix"
|
|
381
|
+
}
|
|
382
|
+
}), "parseInfix")
|
|
383
|
+
}), ee = h({
|
|
384
|
+
name: "numberParslet",
|
|
385
|
+
accept: /* @__PURE__ */ r((e) => e === "Number", "accept"),
|
|
386
|
+
parsePrefix: /* @__PURE__ */ r((e) => {
|
|
387
|
+
let t = parseFloat(e.lexer.current.text);
|
|
388
|
+
return e.consume("Number"), {
|
|
389
|
+
type: "JsdocTypeNumber",
|
|
390
|
+
value: t
|
|
391
|
+
};
|
|
392
|
+
}, "parsePrefix")
|
|
393
|
+
}), Vt = h({
|
|
394
|
+
name: "parenthesisParslet",
|
|
395
|
+
accept: /* @__PURE__ */ r((e) => e === "(", "accept"),
|
|
396
|
+
parsePrefix: /* @__PURE__ */ r((e) => {
|
|
397
|
+
if (e.consume("("), e.consume(")"))
|
|
398
|
+
return {
|
|
399
|
+
type: "JsdocTypeParameterList",
|
|
400
|
+
elements: []
|
|
401
|
+
};
|
|
402
|
+
let t = e.parseIntermediateType(f.ALL);
|
|
403
|
+
if (!e.consume(")"))
|
|
404
|
+
throw new Error("Unterminated parenthesis");
|
|
405
|
+
return t.type === "JsdocTypeParameterList" ? t : t.type === "JsdocTypeKeyValue" ? {
|
|
406
|
+
type: "JsdocTypeParameterList",
|
|
407
|
+
elements: [t]
|
|
408
|
+
} : {
|
|
409
|
+
type: "JsdocTypeParenthesis",
|
|
410
|
+
element: w(t)
|
|
411
|
+
};
|
|
412
|
+
}, "parsePrefix")
|
|
413
|
+
}), Ut = h({
|
|
414
|
+
name: "specialTypesParslet",
|
|
415
|
+
accept: /* @__PURE__ */ r((e, t) => e === "?" && We(t) || e === "null" || e === "undefined" || e === "*", "accept"),
|
|
416
|
+
parsePrefix: /* @__PURE__ */ r((e) => {
|
|
417
|
+
if (e.consume("null"))
|
|
418
|
+
return {
|
|
419
|
+
type: "JsdocTypeNull"
|
|
420
|
+
};
|
|
421
|
+
if (e.consume("undefined"))
|
|
422
|
+
return {
|
|
423
|
+
type: "JsdocTypeUndefined"
|
|
424
|
+
};
|
|
425
|
+
if (e.consume("*"))
|
|
426
|
+
return {
|
|
427
|
+
type: "JsdocTypeAny"
|
|
428
|
+
};
|
|
429
|
+
if (e.consume("?"))
|
|
430
|
+
return {
|
|
431
|
+
type: "JsdocTypeUnknown"
|
|
432
|
+
};
|
|
433
|
+
throw new Error("Unacceptable token: " + e.lexer.current.text);
|
|
434
|
+
}, "parsePrefix")
|
|
435
|
+
}), Bt = h({
|
|
436
|
+
name: "notNullableParslet",
|
|
437
|
+
accept: /* @__PURE__ */ r((e) => e === "!", "accept"),
|
|
438
|
+
precedence: f.NULLABLE,
|
|
439
|
+
parsePrefix: /* @__PURE__ */ r((e) => (e.consume("!"), {
|
|
440
|
+
type: "JsdocTypeNotNullable",
|
|
441
|
+
element: e.parseType(f.NULLABLE),
|
|
442
|
+
meta: {
|
|
443
|
+
position: "prefix"
|
|
444
|
+
}
|
|
445
|
+
}), "parsePrefix"),
|
|
446
|
+
parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("!"), {
|
|
447
|
+
type: "JsdocTypeNotNullable",
|
|
448
|
+
element: w(t),
|
|
449
|
+
meta: {
|
|
450
|
+
position: "suffix"
|
|
451
|
+
}
|
|
452
|
+
}), "parseInfix")
|
|
453
|
+
});
|
|
454
|
+
function Ct({ allowTrailingComma: e }) {
|
|
455
|
+
return h({
|
|
456
|
+
name: "parameterListParslet",
|
|
457
|
+
accept: /* @__PURE__ */ r((t) => t === ",", "accept"),
|
|
458
|
+
precedence: f.PARAMETER_LIST,
|
|
459
|
+
parseInfix: /* @__PURE__ */ r((t, o) => {
|
|
460
|
+
let i = [
|
|
461
|
+
Te(o)
|
|
462
|
+
];
|
|
463
|
+
t.consume(",");
|
|
464
|
+
do
|
|
465
|
+
try {
|
|
466
|
+
let l = t.parseIntermediateType(f.PARAMETER_LIST);
|
|
467
|
+
i.push(Te(l));
|
|
468
|
+
} catch (l) {
|
|
469
|
+
if (e && l instanceof a)
|
|
470
|
+
break;
|
|
471
|
+
throw l;
|
|
472
|
+
}
|
|
473
|
+
while (t.consume(","));
|
|
474
|
+
if (i.length > 0 && i.slice(0, -1).some((l) => l.type === "JsdocTypeVariadic"))
|
|
475
|
+
throw new Error("Only the last parameter may be a rest parameter");
|
|
476
|
+
return {
|
|
477
|
+
type: "JsdocTypeParameterList",
|
|
478
|
+
elements: i
|
|
479
|
+
};
|
|
480
|
+
}, "parseInfix")
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
r(Ct, "createParameterListParslet");
|
|
484
|
+
let Mt = h({
|
|
485
|
+
name: "genericParslet",
|
|
486
|
+
accept: /* @__PURE__ */ r((e, t) => e === "<" || e === "." && t === "<", "accept"),
|
|
487
|
+
precedence: f.GENERIC,
|
|
488
|
+
parseInfix: /* @__PURE__ */ r((e, t) => {
|
|
489
|
+
let o = e.consume(".");
|
|
490
|
+
e.consume("<");
|
|
491
|
+
let i = [];
|
|
492
|
+
do
|
|
493
|
+
i.push(e.parseType(f.PARAMETER_LIST));
|
|
494
|
+
while (e.consume(","));
|
|
495
|
+
if (!e.consume(">"))
|
|
496
|
+
throw new Error("Unterminated generic parameter list");
|
|
497
|
+
return {
|
|
498
|
+
type: "JsdocTypeGeneric",
|
|
499
|
+
left: w(t),
|
|
500
|
+
elements: i,
|
|
501
|
+
meta: {
|
|
502
|
+
brackets: "angle",
|
|
503
|
+
dot: o
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
}, "parseInfix")
|
|
507
|
+
}), Kt = h({
|
|
508
|
+
name: "unionParslet",
|
|
509
|
+
accept: /* @__PURE__ */ r((e) => e === "|", "accept"),
|
|
510
|
+
precedence: f.UNION,
|
|
511
|
+
parseInfix: /* @__PURE__ */ r((e, t) => {
|
|
512
|
+
e.consume("|");
|
|
513
|
+
let o = [];
|
|
514
|
+
do
|
|
515
|
+
o.push(e.parseType(f.UNION));
|
|
516
|
+
while (e.consume("|"));
|
|
517
|
+
return {
|
|
518
|
+
type: "JsdocTypeUnion",
|
|
519
|
+
elements: [w(t), ...o]
|
|
520
|
+
};
|
|
521
|
+
}, "parseInfix")
|
|
522
|
+
}), xe = [
|
|
523
|
+
he,
|
|
524
|
+
Z,
|
|
525
|
+
ee,
|
|
526
|
+
Vt,
|
|
527
|
+
Ut,
|
|
528
|
+
Bt,
|
|
529
|
+
Ct({
|
|
530
|
+
allowTrailingComma: !0
|
|
531
|
+
}),
|
|
532
|
+
Mt,
|
|
533
|
+
Kt,
|
|
534
|
+
Z
|
|
535
|
+
];
|
|
536
|
+
function te({ allowSquareBracketsOnAnyType: e, allowJsdocNamePaths: t, pathGrammar: o }) {
|
|
537
|
+
return /* @__PURE__ */ r(function(l, m, d) {
|
|
538
|
+
if (d == null || m >= f.NAME_PATH)
|
|
539
|
+
return null;
|
|
540
|
+
let x = l.lexer.current.type, N = l.lexer.next.type;
|
|
541
|
+
if (!(x === "." && N !== "<" || x === "[" && (e || d.type === "JsdocTypeName") || t && (x === "~" || x === "#")))
|
|
542
|
+
return null;
|
|
543
|
+
let O, oe = !1;
|
|
544
|
+
l.consume(".") ? O = "property" : l.consume("[") ? (O = "property-brackets", oe = !0) : l.consume("~") ? O = "inner" : (l.consume("#"),
|
|
545
|
+
O = "instance");
|
|
546
|
+
let nt = o !== null ? new V(o, l.lexer, l) : l, k = nt.parseIntermediateType(f.NAME_PATH);
|
|
547
|
+
l.acceptLexerState(nt);
|
|
548
|
+
let G;
|
|
549
|
+
switch (k.type) {
|
|
550
|
+
case "JsdocTypeName":
|
|
551
|
+
G = {
|
|
552
|
+
type: "JsdocTypeProperty",
|
|
553
|
+
value: k.value,
|
|
554
|
+
meta: {
|
|
555
|
+
quote: void 0
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
break;
|
|
559
|
+
case "JsdocTypeNumber":
|
|
560
|
+
G = {
|
|
561
|
+
type: "JsdocTypeProperty",
|
|
562
|
+
value: k.value.toString(10),
|
|
563
|
+
meta: {
|
|
564
|
+
quote: void 0
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
break;
|
|
568
|
+
case "JsdocTypeStringValue":
|
|
569
|
+
G = {
|
|
570
|
+
type: "JsdocTypeProperty",
|
|
571
|
+
value: k.value,
|
|
572
|
+
meta: {
|
|
573
|
+
quote: k.meta.quote
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
break;
|
|
577
|
+
case "JsdocTypeSpecialNamePath":
|
|
578
|
+
if (k.specialType === "event")
|
|
579
|
+
G = k;
|
|
580
|
+
else
|
|
581
|
+
throw new c(k, "Type 'JsdocTypeSpecialNamePath' is only allowed with specialType 'event'");
|
|
582
|
+
break;
|
|
583
|
+
default:
|
|
584
|
+
throw new c(k, "Expecting 'JsdocTypeName', 'JsdocTypeNumber', 'JsdocStringValue' or 'JsdocTypeSpecialNamePath'");
|
|
585
|
+
}
|
|
586
|
+
if (oe && !l.consume("]")) {
|
|
587
|
+
let ot = l.lexer.current;
|
|
588
|
+
throw new Error(`Unterminated square brackets. Next token is '${ot.type}' with text '${ot.text}'`);
|
|
589
|
+
}
|
|
590
|
+
return {
|
|
591
|
+
type: "JsdocTypeNamePath",
|
|
592
|
+
left: w(d),
|
|
593
|
+
right: G,
|
|
594
|
+
pathType: O
|
|
595
|
+
};
|
|
596
|
+
}, "namePathParslet");
|
|
597
|
+
}
|
|
598
|
+
r(te, "createNamePathParslet");
|
|
599
|
+
function R({ allowedAdditionalTokens: e }) {
|
|
600
|
+
return h({
|
|
601
|
+
name: "nameParslet",
|
|
602
|
+
accept: /* @__PURE__ */ r((t) => t === "Identifier" || t === "this" || t === "new" || e.includes(t), "accept"),
|
|
603
|
+
parsePrefix: /* @__PURE__ */ r((t) => {
|
|
604
|
+
let { type: o, text: i } = t.lexer.current;
|
|
605
|
+
return t.consume(o), {
|
|
606
|
+
type: "JsdocTypeName",
|
|
607
|
+
value: i
|
|
608
|
+
};
|
|
609
|
+
}, "parsePrefix")
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
r(R, "createNameParslet");
|
|
613
|
+
let Y = h({
|
|
614
|
+
name: "stringValueParslet",
|
|
615
|
+
accept: /* @__PURE__ */ r((e) => e === "StringValue", "accept"),
|
|
616
|
+
parsePrefix: /* @__PURE__ */ r((e) => {
|
|
617
|
+
let t = e.lexer.current.text;
|
|
618
|
+
return e.consume("StringValue"), {
|
|
619
|
+
type: "JsdocTypeStringValue",
|
|
620
|
+
value: t.slice(1, -1),
|
|
621
|
+
meta: {
|
|
622
|
+
quote: t[0] === "'" ? "single" : "double"
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
}, "parsePrefix")
|
|
626
|
+
});
|
|
627
|
+
function re({ pathGrammar: e, allowedTypes: t }) {
|
|
628
|
+
return h({
|
|
629
|
+
name: "specialNamePathParslet",
|
|
630
|
+
accept: /* @__PURE__ */ r((o) => t.includes(o), "accept"),
|
|
631
|
+
parsePrefix: /* @__PURE__ */ r((o) => {
|
|
632
|
+
let i = o.lexer.current.type;
|
|
633
|
+
if (o.consume(i), !o.consume(":"))
|
|
634
|
+
return {
|
|
635
|
+
type: "JsdocTypeName",
|
|
636
|
+
value: i
|
|
637
|
+
};
|
|
638
|
+
let l, m = o.lexer.current;
|
|
639
|
+
if (o.consume("StringValue"))
|
|
640
|
+
l = {
|
|
641
|
+
type: "JsdocTypeSpecialNamePath",
|
|
642
|
+
value: m.text.slice(1, -1),
|
|
643
|
+
specialType: i,
|
|
644
|
+
meta: {
|
|
645
|
+
quote: m.text[0] === "'" ? "single" : "double"
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
else {
|
|
649
|
+
let N = "", S = ["Identifier", "@", "/"];
|
|
650
|
+
for (; S.some((O) => o.consume(O)); )
|
|
651
|
+
N += m.text, m = o.lexer.current;
|
|
652
|
+
l = {
|
|
653
|
+
type: "JsdocTypeSpecialNamePath",
|
|
654
|
+
value: N,
|
|
655
|
+
specialType: i,
|
|
656
|
+
meta: {
|
|
657
|
+
quote: void 0
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
let d = new V(e, o.lexer, o), x = d.parseInfixIntermediateType(l, f.ALL);
|
|
662
|
+
return o.acceptLexerState(d), w(x);
|
|
663
|
+
}, "parsePrefix")
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
r(re, "createSpecialNamePathParslet");
|
|
667
|
+
let Ge = [
|
|
668
|
+
R({
|
|
669
|
+
allowedAdditionalTokens: ["external", "module"]
|
|
670
|
+
}),
|
|
671
|
+
Y,
|
|
672
|
+
ee,
|
|
673
|
+
te({
|
|
674
|
+
allowSquareBracketsOnAnyType: !1,
|
|
675
|
+
allowJsdocNamePaths: !0,
|
|
676
|
+
pathGrammar: null
|
|
677
|
+
})
|
|
678
|
+
], U = [
|
|
679
|
+
...Ge,
|
|
680
|
+
re({
|
|
681
|
+
allowedTypes: ["event"],
|
|
682
|
+
pathGrammar: Ge
|
|
683
|
+
})
|
|
684
|
+
];
|
|
685
|
+
function Je(e) {
|
|
686
|
+
let t;
|
|
687
|
+
if (e.type === "JsdocTypeParameterList")
|
|
688
|
+
t = e.elements;
|
|
689
|
+
else if (e.type === "JsdocTypeParenthesis")
|
|
690
|
+
t = [e.element];
|
|
691
|
+
else
|
|
692
|
+
throw new c(e);
|
|
693
|
+
return t.map((o) => Te(o));
|
|
694
|
+
}
|
|
695
|
+
r(Je, "getParameters");
|
|
696
|
+
function $t(e) {
|
|
697
|
+
let t = Je(e);
|
|
698
|
+
if (t.some((o) => o.type === "JsdocTypeKeyValue"))
|
|
699
|
+
throw new Error("No parameter should be named");
|
|
700
|
+
return t;
|
|
701
|
+
}
|
|
702
|
+
r($t, "getUnnamedParameters");
|
|
703
|
+
function we({ allowNamedParameters: e, allowNoReturnType: t, allowWithoutParenthesis: o, allowNewAsFunctionKeyword: i }) {
|
|
704
|
+
return h({
|
|
705
|
+
name: "functionParslet",
|
|
706
|
+
accept: /* @__PURE__ */ r((l, m) => l === "function" || i && l === "new" && m === "(", "accept"),
|
|
707
|
+
parsePrefix: /* @__PURE__ */ r((l) => {
|
|
708
|
+
let m = l.consume("new");
|
|
709
|
+
l.consume("function");
|
|
710
|
+
let d = l.lexer.current.type === "(";
|
|
711
|
+
if (!d) {
|
|
712
|
+
if (!o)
|
|
713
|
+
throw new Error("function is missing parameter list");
|
|
714
|
+
return {
|
|
715
|
+
type: "JsdocTypeName",
|
|
716
|
+
value: "function"
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
let x = {
|
|
720
|
+
type: "JsdocTypeFunction",
|
|
721
|
+
parameters: [],
|
|
722
|
+
arrow: !1,
|
|
723
|
+
constructor: m,
|
|
724
|
+
parenthesis: d
|
|
725
|
+
}, N = l.parseIntermediateType(f.FUNCTION);
|
|
726
|
+
if (e === void 0)
|
|
727
|
+
x.parameters = $t(N);
|
|
728
|
+
else {
|
|
729
|
+
if (m && N.type === "JsdocTypeFunction" && N.arrow)
|
|
730
|
+
return x = N, x.constructor = !0, x;
|
|
731
|
+
x.parameters = Je(N);
|
|
732
|
+
for (let S of x.parameters)
|
|
733
|
+
if (S.type === "JsdocTypeKeyValue" && !e.includes(S.key))
|
|
734
|
+
throw new Error(`only allowed named parameters are ${e.join(", ")} but got ${S.type}`);
|
|
735
|
+
}
|
|
736
|
+
if (l.consume(":"))
|
|
737
|
+
x.returnType = l.parseType(f.PREFIX);
|
|
738
|
+
else if (!t)
|
|
739
|
+
throw new Error("function is missing return type");
|
|
740
|
+
return x;
|
|
741
|
+
}, "parsePrefix")
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
r(we, "createFunctionParslet");
|
|
745
|
+
function Pe({ allowPostfix: e, allowEnclosingBrackets: t }) {
|
|
746
|
+
return h({
|
|
747
|
+
name: "variadicParslet",
|
|
748
|
+
accept: /* @__PURE__ */ r((o) => o === "...", "accept"),
|
|
749
|
+
precedence: f.PREFIX,
|
|
750
|
+
parsePrefix: /* @__PURE__ */ r((o) => {
|
|
751
|
+
o.consume("...");
|
|
752
|
+
let i = t && o.consume("[");
|
|
753
|
+
try {
|
|
754
|
+
let l = o.parseType(f.PREFIX);
|
|
755
|
+
if (i && !o.consume("]"))
|
|
756
|
+
throw new Error("Unterminated variadic type. Missing ']'");
|
|
757
|
+
return {
|
|
758
|
+
type: "JsdocTypeVariadic",
|
|
759
|
+
element: w(l),
|
|
760
|
+
meta: {
|
|
761
|
+
position: "prefix",
|
|
762
|
+
squareBrackets: i
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
} catch (l) {
|
|
766
|
+
if (l instanceof a) {
|
|
767
|
+
if (i)
|
|
768
|
+
throw new Error("Empty square brackets for variadic are not allowed.");
|
|
769
|
+
return {
|
|
770
|
+
type: "JsdocTypeVariadic",
|
|
771
|
+
meta: {
|
|
772
|
+
position: void 0,
|
|
773
|
+
squareBrackets: !1
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
} else
|
|
777
|
+
throw l;
|
|
778
|
+
}
|
|
779
|
+
}, "parsePrefix"),
|
|
780
|
+
parseInfix: e ? (o, i) => (o.consume("..."), {
|
|
781
|
+
type: "JsdocTypeVariadic",
|
|
782
|
+
element: w(i),
|
|
783
|
+
meta: {
|
|
784
|
+
position: "suffix",
|
|
785
|
+
squareBrackets: !1
|
|
786
|
+
}
|
|
787
|
+
}) : void 0
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
r(Pe, "createVariadicParslet");
|
|
791
|
+
let ze = h({
|
|
792
|
+
name: "symbolParslet",
|
|
793
|
+
accept: /* @__PURE__ */ r((e) => e === "(", "accept"),
|
|
794
|
+
precedence: f.SYMBOL,
|
|
795
|
+
parseInfix: /* @__PURE__ */ r((e, t) => {
|
|
796
|
+
if (t.type !== "JsdocTypeName")
|
|
797
|
+
throw new Error("Symbol expects a name on the left side. (Reacting on '(')");
|
|
798
|
+
e.consume("(");
|
|
799
|
+
let o = {
|
|
800
|
+
type: "JsdocTypeSymbol",
|
|
801
|
+
value: t.value
|
|
802
|
+
};
|
|
803
|
+
if (!e.consume(")")) {
|
|
804
|
+
let i = e.parseIntermediateType(f.SYMBOL);
|
|
805
|
+
if (o.element = Lt(i), !e.consume(")"))
|
|
806
|
+
throw new Error("Symbol does not end after value");
|
|
807
|
+
}
|
|
808
|
+
return o;
|
|
809
|
+
}, "parseInfix")
|
|
810
|
+
}), Xe = h({
|
|
811
|
+
name: "arrayBracketsParslet",
|
|
812
|
+
precedence: f.ARRAY_BRACKETS,
|
|
813
|
+
accept: /* @__PURE__ */ r((e, t) => e === "[" && t === "]", "accept"),
|
|
814
|
+
parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("["), e.consume("]"), {
|
|
815
|
+
type: "JsdocTypeGeneric",
|
|
816
|
+
left: {
|
|
817
|
+
type: "JsdocTypeName",
|
|
818
|
+
value: "Array"
|
|
819
|
+
},
|
|
820
|
+
elements: [
|
|
821
|
+
w(t)
|
|
822
|
+
],
|
|
823
|
+
meta: {
|
|
824
|
+
brackets: "square",
|
|
825
|
+
dot: !1
|
|
826
|
+
}
|
|
827
|
+
}), "parseInfix")
|
|
828
|
+
});
|
|
829
|
+
function be({ objectFieldGrammar: e, allowKeyTypes: t }) {
|
|
830
|
+
return h({
|
|
831
|
+
name: "objectParslet",
|
|
832
|
+
accept: /* @__PURE__ */ r((o) => o === "{", "accept"),
|
|
833
|
+
parsePrefix: /* @__PURE__ */ r((o) => {
|
|
834
|
+
o.consume("{");
|
|
835
|
+
let i = {
|
|
836
|
+
type: "JsdocTypeObject",
|
|
837
|
+
meta: {
|
|
838
|
+
separator: "comma"
|
|
839
|
+
},
|
|
840
|
+
elements: []
|
|
841
|
+
};
|
|
842
|
+
if (!o.consume("}")) {
|
|
843
|
+
let l, m = new V(e, o.lexer, o);
|
|
844
|
+
for (; ; ) {
|
|
845
|
+
m.acceptLexerState(o);
|
|
846
|
+
let d = m.parseIntermediateType(f.OBJECT);
|
|
847
|
+
o.acceptLexerState(m), d === void 0 && t && (d = o.parseIntermediateType(f.OBJECT));
|
|
848
|
+
let x = !1;
|
|
849
|
+
if (d.type === "JsdocTypeNullable" && (x = !0, d = d.element), d.type === "JsdocTypeNumber" || d.type === "JsdocTypeName" || d.
|
|
850
|
+
type === "JsdocTypeStringValue") {
|
|
851
|
+
let S;
|
|
852
|
+
d.type === "JsdocTypeStringValue" && (S = d.meta.quote), i.elements.push({
|
|
853
|
+
type: "JsdocTypeObjectField",
|
|
854
|
+
key: d.value.toString(),
|
|
855
|
+
right: void 0,
|
|
856
|
+
optional: x,
|
|
857
|
+
readonly: !1,
|
|
858
|
+
meta: {
|
|
859
|
+
quote: S
|
|
860
|
+
}
|
|
861
|
+
});
|
|
862
|
+
} else if (d.type === "JsdocTypeObjectField" || d.type === "JsdocTypeJsdocObjectField")
|
|
863
|
+
i.elements.push(d);
|
|
864
|
+
else
|
|
865
|
+
throw new c(d);
|
|
866
|
+
if (o.lexer.current.startOfLine)
|
|
867
|
+
l = "linebreak";
|
|
868
|
+
else if (o.consume(","))
|
|
869
|
+
l = "comma";
|
|
870
|
+
else if (o.consume(";"))
|
|
871
|
+
l = "semicolon";
|
|
872
|
+
else
|
|
873
|
+
break;
|
|
874
|
+
if (o.lexer.current.type === "}")
|
|
875
|
+
break;
|
|
876
|
+
}
|
|
877
|
+
if (i.meta.separator = l ?? "comma", !o.consume("}"))
|
|
878
|
+
throw new Error("Unterminated record type. Missing '}'");
|
|
879
|
+
}
|
|
880
|
+
return i;
|
|
881
|
+
}, "parsePrefix")
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
r(be, "createObjectParslet");
|
|
885
|
+
function Ee({ allowSquaredProperties: e, allowKeyTypes: t, allowReadonly: o, allowOptional: i }) {
|
|
886
|
+
return h({
|
|
887
|
+
name: "objectFieldParslet",
|
|
888
|
+
precedence: f.KEY_VALUE,
|
|
889
|
+
accept: /* @__PURE__ */ r((l) => l === ":", "accept"),
|
|
890
|
+
parseInfix: /* @__PURE__ */ r((l, m) => {
|
|
891
|
+
var d;
|
|
892
|
+
let x = !1, N = !1;
|
|
893
|
+
i && m.type === "JsdocTypeNullable" && (x = !0, m = m.element), o && m.type === "JsdocTypeReadonlyProperty" && (N = !0, m = m.element);
|
|
894
|
+
let S = (d = l.baseParser) !== null && d !== void 0 ? d : l;
|
|
895
|
+
if (S.acceptLexerState(l), m.type === "JsdocTypeNumber" || m.type === "JsdocTypeName" || m.type === "JsdocTypeStringValue" || ge(m)) {
|
|
896
|
+
if (ge(m) && !e)
|
|
897
|
+
throw new c(m);
|
|
898
|
+
S.consume(":");
|
|
899
|
+
let O;
|
|
900
|
+
m.type === "JsdocTypeStringValue" && (O = m.meta.quote);
|
|
901
|
+
let oe = S.parseType(f.KEY_VALUE);
|
|
902
|
+
return l.acceptLexerState(S), {
|
|
903
|
+
type: "JsdocTypeObjectField",
|
|
904
|
+
key: ge(m) ? m : m.value.toString(),
|
|
905
|
+
right: oe,
|
|
906
|
+
optional: x,
|
|
907
|
+
readonly: N,
|
|
908
|
+
meta: {
|
|
909
|
+
quote: O
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
} else {
|
|
913
|
+
if (!t)
|
|
914
|
+
throw new c(m);
|
|
915
|
+
S.consume(":");
|
|
916
|
+
let O = S.parseType(f.KEY_VALUE);
|
|
917
|
+
return l.acceptLexerState(S), {
|
|
918
|
+
type: "JsdocTypeJsdocObjectField",
|
|
919
|
+
left: w(m),
|
|
920
|
+
right: O
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
}, "parseInfix")
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
r(Ee, "createObjectFieldParslet");
|
|
927
|
+
function Se({ allowOptional: e, allowVariadic: t }) {
|
|
928
|
+
return h({
|
|
929
|
+
name: "keyValueParslet",
|
|
930
|
+
precedence: f.KEY_VALUE,
|
|
931
|
+
accept: /* @__PURE__ */ r((o) => o === ":", "accept"),
|
|
932
|
+
parseInfix: /* @__PURE__ */ r((o, i) => {
|
|
933
|
+
let l = !1, m = !1;
|
|
934
|
+
if (e && i.type === "JsdocTypeNullable" && (l = !0, i = i.element), t && i.type === "JsdocTypeVariadic" && i.element !== void 0 &&
|
|
935
|
+
(m = !0, i = i.element), i.type !== "JsdocTypeName")
|
|
936
|
+
throw new c(i);
|
|
937
|
+
o.consume(":");
|
|
938
|
+
let d = o.parseType(f.KEY_VALUE);
|
|
939
|
+
return {
|
|
940
|
+
type: "JsdocTypeKeyValue",
|
|
941
|
+
key: i.value,
|
|
942
|
+
right: d,
|
|
943
|
+
optional: l,
|
|
944
|
+
variadic: m
|
|
945
|
+
};
|
|
946
|
+
}, "parseInfix")
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
r(Se, "createKeyValueParslet");
|
|
950
|
+
let He = [
|
|
951
|
+
...xe,
|
|
952
|
+
we({
|
|
953
|
+
allowWithoutParenthesis: !0,
|
|
954
|
+
allowNamedParameters: ["this", "new"],
|
|
955
|
+
allowNoReturnType: !0,
|
|
956
|
+
allowNewAsFunctionKeyword: !1
|
|
957
|
+
}),
|
|
958
|
+
Y,
|
|
959
|
+
re({
|
|
960
|
+
allowedTypes: ["module", "external", "event"],
|
|
961
|
+
pathGrammar: U
|
|
962
|
+
}),
|
|
963
|
+
Pe({
|
|
964
|
+
allowEnclosingBrackets: !0,
|
|
965
|
+
allowPostfix: !0
|
|
966
|
+
}),
|
|
967
|
+
R({
|
|
968
|
+
allowedAdditionalTokens: ["keyof"]
|
|
969
|
+
}),
|
|
970
|
+
ze,
|
|
971
|
+
Xe,
|
|
972
|
+
te({
|
|
973
|
+
allowSquareBracketsOnAnyType: !1,
|
|
974
|
+
allowJsdocNamePaths: !0,
|
|
975
|
+
pathGrammar: U
|
|
976
|
+
})
|
|
977
|
+
], qt = [
|
|
978
|
+
...He,
|
|
979
|
+
be({
|
|
980
|
+
// jsdoc syntax allows full types as keys, so we need to pull in the full grammar here
|
|
981
|
+
// we leave out the object type deliberately
|
|
982
|
+
objectFieldGrammar: [
|
|
983
|
+
R({
|
|
984
|
+
allowedAdditionalTokens: ["module", "in"]
|
|
985
|
+
}),
|
|
986
|
+
Ee({
|
|
987
|
+
allowSquaredProperties: !1,
|
|
988
|
+
allowKeyTypes: !0,
|
|
989
|
+
allowOptional: !1,
|
|
990
|
+
allowReadonly: !1
|
|
991
|
+
}),
|
|
992
|
+
...He
|
|
993
|
+
],
|
|
994
|
+
allowKeyTypes: !0
|
|
995
|
+
}),
|
|
996
|
+
Se({
|
|
997
|
+
allowOptional: !0,
|
|
998
|
+
allowVariadic: !0
|
|
999
|
+
})
|
|
1000
|
+
], Qe = h({
|
|
1001
|
+
name: "typeOfParslet",
|
|
1002
|
+
accept: /* @__PURE__ */ r((e) => e === "typeof", "accept"),
|
|
1003
|
+
parsePrefix: /* @__PURE__ */ r((e) => (e.consume("typeof"), {
|
|
1004
|
+
type: "JsdocTypeTypeof",
|
|
1005
|
+
element: w(e.parseType(f.KEY_OF_TYPE_OF))
|
|
1006
|
+
}), "parsePrefix")
|
|
1007
|
+
}), Yt = [
|
|
1008
|
+
R({
|
|
1009
|
+
allowedAdditionalTokens: ["module", "keyof", "event", "external", "in"]
|
|
1010
|
+
}),
|
|
1011
|
+
he,
|
|
1012
|
+
Z,
|
|
1013
|
+
Y,
|
|
1014
|
+
ee,
|
|
1015
|
+
Ee({
|
|
1016
|
+
allowSquaredProperties: !1,
|
|
1017
|
+
allowKeyTypes: !1,
|
|
1018
|
+
allowOptional: !1,
|
|
1019
|
+
allowReadonly: !1
|
|
1020
|
+
})
|
|
1021
|
+
], Wt = [
|
|
1022
|
+
...xe,
|
|
1023
|
+
be({
|
|
1024
|
+
allowKeyTypes: !1,
|
|
1025
|
+
objectFieldGrammar: Yt
|
|
1026
|
+
}),
|
|
1027
|
+
R({
|
|
1028
|
+
allowedAdditionalTokens: ["event", "external", "in"]
|
|
1029
|
+
}),
|
|
1030
|
+
Qe,
|
|
1031
|
+
we({
|
|
1032
|
+
allowWithoutParenthesis: !1,
|
|
1033
|
+
allowNamedParameters: ["this", "new"],
|
|
1034
|
+
allowNoReturnType: !0,
|
|
1035
|
+
allowNewAsFunctionKeyword: !1
|
|
1036
|
+
}),
|
|
1037
|
+
Pe({
|
|
1038
|
+
allowEnclosingBrackets: !1,
|
|
1039
|
+
allowPostfix: !1
|
|
1040
|
+
}),
|
|
1041
|
+
// additional name parslet is needed for some special cases
|
|
1042
|
+
R({
|
|
1043
|
+
allowedAdditionalTokens: ["keyof"]
|
|
1044
|
+
}),
|
|
1045
|
+
re({
|
|
1046
|
+
allowedTypes: ["module"],
|
|
1047
|
+
pathGrammar: U
|
|
1048
|
+
}),
|
|
1049
|
+
te({
|
|
1050
|
+
allowSquareBracketsOnAnyType: !1,
|
|
1051
|
+
allowJsdocNamePaths: !0,
|
|
1052
|
+
pathGrammar: U
|
|
1053
|
+
}),
|
|
1054
|
+
Se({
|
|
1055
|
+
allowOptional: !1,
|
|
1056
|
+
allowVariadic: !1
|
|
1057
|
+
}),
|
|
1058
|
+
ze
|
|
1059
|
+
];
|
|
1060
|
+
function Gt({ allowQuestionMark: e }) {
|
|
1061
|
+
return h({
|
|
1062
|
+
name: "tupleParslet",
|
|
1063
|
+
accept: /* @__PURE__ */ r((t) => t === "[", "accept"),
|
|
1064
|
+
parsePrefix: /* @__PURE__ */ r((t) => {
|
|
1065
|
+
t.consume("[");
|
|
1066
|
+
let o = {
|
|
1067
|
+
type: "JsdocTypeTuple",
|
|
1068
|
+
elements: []
|
|
1069
|
+
};
|
|
1070
|
+
if (t.consume("]"))
|
|
1071
|
+
return o;
|
|
1072
|
+
let i = t.parseIntermediateType(f.ALL);
|
|
1073
|
+
if (i.type === "JsdocTypeParameterList" ? i.elements[0].type === "JsdocTypeKeyValue" ? o.elements = i.elements.map(Q) : o.elements =
|
|
1074
|
+
i.elements.map(w) : i.type === "JsdocTypeKeyValue" ? o.elements = [Q(i)] : o.elements = [w(i)], !t.consume("]"))
|
|
1075
|
+
throw new Error("Unterminated '['");
|
|
1076
|
+
if (!e && o.elements.some((l) => l.type === "JsdocTypeUnknown"))
|
|
1077
|
+
throw new Error("Question mark in tuple not allowed");
|
|
1078
|
+
return o;
|
|
1079
|
+
}, "parsePrefix")
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
r(Gt, "createTupleParslet");
|
|
1083
|
+
let zt = h({
|
|
1084
|
+
name: "keyOfParslet",
|
|
1085
|
+
accept: /* @__PURE__ */ r((e) => e === "keyof", "accept"),
|
|
1086
|
+
parsePrefix: /* @__PURE__ */ r((e) => (e.consume("keyof"), {
|
|
1087
|
+
type: "JsdocTypeKeyof",
|
|
1088
|
+
element: w(e.parseType(f.KEY_OF_TYPE_OF))
|
|
1089
|
+
}), "parsePrefix")
|
|
1090
|
+
}), Xt = h({
|
|
1091
|
+
name: "importParslet",
|
|
1092
|
+
accept: /* @__PURE__ */ r((e) => e === "import", "accept"),
|
|
1093
|
+
parsePrefix: /* @__PURE__ */ r((e) => {
|
|
1094
|
+
if (e.consume("import"), !e.consume("("))
|
|
1095
|
+
throw new Error("Missing parenthesis after import keyword");
|
|
1096
|
+
let t = e.parseType(f.PREFIX);
|
|
1097
|
+
if (t.type !== "JsdocTypeStringValue")
|
|
1098
|
+
throw new Error("Only string values are allowed as paths for imports");
|
|
1099
|
+
if (!e.consume(")"))
|
|
1100
|
+
throw new Error("Missing closing parenthesis after import keyword");
|
|
1101
|
+
return {
|
|
1102
|
+
type: "JsdocTypeImport",
|
|
1103
|
+
element: t
|
|
1104
|
+
};
|
|
1105
|
+
}, "parsePrefix")
|
|
1106
|
+
}), Ht = h({
|
|
1107
|
+
name: "readonlyPropertyParslet",
|
|
1108
|
+
accept: /* @__PURE__ */ r((e) => e === "readonly", "accept"),
|
|
1109
|
+
parsePrefix: /* @__PURE__ */ r((e) => (e.consume("readonly"), {
|
|
1110
|
+
type: "JsdocTypeReadonlyProperty",
|
|
1111
|
+
element: e.parseType(f.KEY_VALUE)
|
|
1112
|
+
}), "parsePrefix")
|
|
1113
|
+
}), Qt = h({
|
|
1114
|
+
name: "arrowFunctionParslet",
|
|
1115
|
+
precedence: f.ARROW,
|
|
1116
|
+
accept: /* @__PURE__ */ r((e) => e === "=>", "accept"),
|
|
1117
|
+
parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("=>"), {
|
|
1118
|
+
type: "JsdocTypeFunction",
|
|
1119
|
+
parameters: Je(t).map(_t),
|
|
1120
|
+
arrow: !0,
|
|
1121
|
+
constructor: !1,
|
|
1122
|
+
parenthesis: !0,
|
|
1123
|
+
returnType: e.parseType(f.OBJECT)
|
|
1124
|
+
}), "parseInfix")
|
|
1125
|
+
}), Zt = h({
|
|
1126
|
+
name: "intersectionParslet",
|
|
1127
|
+
accept: /* @__PURE__ */ r((e) => e === "&", "accept"),
|
|
1128
|
+
precedence: f.INTERSECTION,
|
|
1129
|
+
parseInfix: /* @__PURE__ */ r((e, t) => {
|
|
1130
|
+
e.consume("&");
|
|
1131
|
+
let o = [];
|
|
1132
|
+
do
|
|
1133
|
+
o.push(e.parseType(f.INTERSECTION));
|
|
1134
|
+
while (e.consume("&"));
|
|
1135
|
+
return {
|
|
1136
|
+
type: "JsdocTypeIntersection",
|
|
1137
|
+
elements: [w(t), ...o]
|
|
1138
|
+
};
|
|
1139
|
+
}, "parseInfix")
|
|
1140
|
+
}), er = h({
|
|
1141
|
+
name: "predicateParslet",
|
|
1142
|
+
precedence: f.INFIX,
|
|
1143
|
+
accept: /* @__PURE__ */ r((e) => e === "is", "accept"),
|
|
1144
|
+
parseInfix: /* @__PURE__ */ r((e, t) => {
|
|
1145
|
+
if (t.type !== "JsdocTypeName")
|
|
1146
|
+
throw new c(t, "A typescript predicate always has to have a name on the left side.");
|
|
1147
|
+
return e.consume("is"), {
|
|
1148
|
+
type: "JsdocTypePredicate",
|
|
1149
|
+
left: t,
|
|
1150
|
+
right: w(e.parseIntermediateType(f.INFIX))
|
|
1151
|
+
};
|
|
1152
|
+
}, "parseInfix")
|
|
1153
|
+
}), tr = h({
|
|
1154
|
+
name: "objectSquareBracketPropertyParslet",
|
|
1155
|
+
accept: /* @__PURE__ */ r((e) => e === "[", "accept"),
|
|
1156
|
+
parsePrefix: /* @__PURE__ */ r((e) => {
|
|
1157
|
+
if (e.baseParser === void 0)
|
|
1158
|
+
throw new Error("Only allowed inside object grammar");
|
|
1159
|
+
e.consume("[");
|
|
1160
|
+
let t = e.lexer.current.text;
|
|
1161
|
+
e.consume("Identifier");
|
|
1162
|
+
let o;
|
|
1163
|
+
if (e.consume(":")) {
|
|
1164
|
+
let i = e.baseParser;
|
|
1165
|
+
i.acceptLexerState(e), o = {
|
|
1166
|
+
type: "JsdocTypeIndexSignature",
|
|
1167
|
+
key: t,
|
|
1168
|
+
right: i.parseType(f.ARRAY_BRACKETS)
|
|
1169
|
+
}, e.acceptLexerState(i);
|
|
1170
|
+
} else if (e.consume("in")) {
|
|
1171
|
+
let i = e.baseParser;
|
|
1172
|
+
i.acceptLexerState(e), o = {
|
|
1173
|
+
type: "JsdocTypeMappedType",
|
|
1174
|
+
key: t,
|
|
1175
|
+
right: i.parseType(f.ARRAY_BRACKETS)
|
|
1176
|
+
}, e.acceptLexerState(i);
|
|
1177
|
+
} else
|
|
1178
|
+
throw new Error("Missing ':' or 'in' inside square bracketed property.");
|
|
1179
|
+
if (!e.consume("]"))
|
|
1180
|
+
throw new Error("Unterminated square brackets");
|
|
1181
|
+
return o;
|
|
1182
|
+
}, "parsePrefix")
|
|
1183
|
+
}), rr = [
|
|
1184
|
+
Ht,
|
|
1185
|
+
R({
|
|
1186
|
+
allowedAdditionalTokens: ["module", "event", "keyof", "event", "external", "in"]
|
|
1187
|
+
}),
|
|
1188
|
+
he,
|
|
1189
|
+
Z,
|
|
1190
|
+
Y,
|
|
1191
|
+
ee,
|
|
1192
|
+
Ee({
|
|
1193
|
+
allowSquaredProperties: !0,
|
|
1194
|
+
allowKeyTypes: !1,
|
|
1195
|
+
allowOptional: !0,
|
|
1196
|
+
allowReadonly: !0
|
|
1197
|
+
}),
|
|
1198
|
+
tr
|
|
1199
|
+
], nr = [
|
|
1200
|
+
...xe,
|
|
1201
|
+
be({
|
|
1202
|
+
allowKeyTypes: !1,
|
|
1203
|
+
objectFieldGrammar: rr
|
|
1204
|
+
}),
|
|
1205
|
+
Qe,
|
|
1206
|
+
zt,
|
|
1207
|
+
Xt,
|
|
1208
|
+
Y,
|
|
1209
|
+
we({
|
|
1210
|
+
allowWithoutParenthesis: !0,
|
|
1211
|
+
allowNoReturnType: !1,
|
|
1212
|
+
allowNamedParameters: ["this", "new", "args"],
|
|
1213
|
+
allowNewAsFunctionKeyword: !0
|
|
1214
|
+
}),
|
|
1215
|
+
Gt({
|
|
1216
|
+
allowQuestionMark: !1
|
|
1217
|
+
}),
|
|
1218
|
+
Pe({
|
|
1219
|
+
allowEnclosingBrackets: !1,
|
|
1220
|
+
allowPostfix: !1
|
|
1221
|
+
}),
|
|
1222
|
+
R({
|
|
1223
|
+
allowedAdditionalTokens: ["event", "external", "in"]
|
|
1224
|
+
}),
|
|
1225
|
+
re({
|
|
1226
|
+
allowedTypes: ["module"],
|
|
1227
|
+
pathGrammar: U
|
|
1228
|
+
}),
|
|
1229
|
+
Xe,
|
|
1230
|
+
Qt,
|
|
1231
|
+
te({
|
|
1232
|
+
allowSquareBracketsOnAnyType: !0,
|
|
1233
|
+
allowJsdocNamePaths: !1,
|
|
1234
|
+
pathGrammar: U
|
|
1235
|
+
}),
|
|
1236
|
+
Zt,
|
|
1237
|
+
er,
|
|
1238
|
+
Se({
|
|
1239
|
+
allowVariadic: !0,
|
|
1240
|
+
allowOptional: !0
|
|
1241
|
+
})
|
|
1242
|
+
];
|
|
1243
|
+
function Ze(e, t) {
|
|
1244
|
+
switch (t) {
|
|
1245
|
+
case "closure":
|
|
1246
|
+
return new V(Wt, e).parse();
|
|
1247
|
+
case "jsdoc":
|
|
1248
|
+
return new V(qt, e).parse();
|
|
1249
|
+
case "typescript":
|
|
1250
|
+
return new V(nr, e).parse();
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
r(Ze, "parse");
|
|
1254
|
+
function or(e, t = ["typescript", "closure", "jsdoc"]) {
|
|
1255
|
+
let o;
|
|
1256
|
+
for (let i of t)
|
|
1257
|
+
try {
|
|
1258
|
+
return Ze(e, i);
|
|
1259
|
+
} catch (l) {
|
|
1260
|
+
o = l;
|
|
1261
|
+
}
|
|
1262
|
+
throw o;
|
|
1263
|
+
}
|
|
1264
|
+
r(or, "tryParse");
|
|
1265
|
+
function W(e, t) {
|
|
1266
|
+
let o = e[t.type];
|
|
1267
|
+
if (o === void 0)
|
|
1268
|
+
throw new Error(`In this set of transform rules exists no rule for type ${t.type}.`);
|
|
1269
|
+
return o(t, (i) => W(e, i));
|
|
1270
|
+
}
|
|
1271
|
+
r(W, "transform");
|
|
1272
|
+
function D(e) {
|
|
1273
|
+
throw new Error("This transform is not available. Are you trying the correct parsing mode?");
|
|
1274
|
+
}
|
|
1275
|
+
r(D, "notAvailableTransform");
|
|
1276
|
+
function et(e) {
|
|
1277
|
+
let t = {
|
|
1278
|
+
params: []
|
|
1279
|
+
};
|
|
1280
|
+
for (let o of e.parameters)
|
|
1281
|
+
o.type === "JsdocTypeKeyValue" ? o.key === "this" ? t.this = o.right : o.key === "new" ? t.new = o.right : t.params.push(o) : t.params.
|
|
1282
|
+
push(o);
|
|
1283
|
+
return t;
|
|
1284
|
+
}
|
|
1285
|
+
r(et, "extractSpecialParams");
|
|
1286
|
+
function ne(e, t, o) {
|
|
1287
|
+
return e === "prefix" ? o + t : t + o;
|
|
1288
|
+
}
|
|
1289
|
+
r(ne, "applyPosition");
|
|
1290
|
+
function I(e, t) {
|
|
1291
|
+
switch (t) {
|
|
1292
|
+
case "double":
|
|
1293
|
+
return `"${e}"`;
|
|
1294
|
+
case "single":
|
|
1295
|
+
return `'${e}'`;
|
|
1296
|
+
case void 0:
|
|
1297
|
+
return e;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
r(I, "quote");
|
|
1301
|
+
function tt() {
|
|
1302
|
+
return {
|
|
1303
|
+
JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => `(${e.element !== void 0 ? t(e.element) : ""})`, "JsdocTypeParenthesis"),
|
|
1304
|
+
JsdocTypeKeyof: /* @__PURE__ */ r((e, t) => `keyof ${t(e.element)}`, "JsdocTypeKeyof"),
|
|
1305
|
+
JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
|
|
1306
|
+
if (e.arrow) {
|
|
1307
|
+
if (e.returnType === void 0)
|
|
1308
|
+
throw new Error("Arrow function needs a return type.");
|
|
1309
|
+
let o = `(${e.parameters.map(t).join(", ")}) => ${t(e.returnType)}`;
|
|
1310
|
+
return e.constructor && (o = "new " + o), o;
|
|
1311
|
+
} else {
|
|
1312
|
+
let o = e.constructor ? "new" : "function";
|
|
1313
|
+
return e.parenthesis && (o += `(${e.parameters.map(t).join(", ")})`, e.returnType !== void 0 && (o += `: ${t(e.returnType)}`)), o;
|
|
1314
|
+
}
|
|
1315
|
+
}, "JsdocTypeFunction"),
|
|
1316
|
+
JsdocTypeName: /* @__PURE__ */ r((e) => e.value, "JsdocTypeName"),
|
|
1317
|
+
JsdocTypeTuple: /* @__PURE__ */ r((e, t) => `[${e.elements.map(t).join(", ")}]`, "JsdocTypeTuple"),
|
|
1318
|
+
JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => e.meta.position === void 0 ? "..." : ne(e.meta.position, t(e.element), "..."), "Jsdoc\
|
|
1319
|
+
TypeVariadic"),
|
|
1320
|
+
JsdocTypeNamePath: /* @__PURE__ */ r((e, t) => {
|
|
1321
|
+
let o = t(e.left), i = t(e.right);
|
|
1322
|
+
switch (e.pathType) {
|
|
1323
|
+
case "inner":
|
|
1324
|
+
return `${o}~${i}`;
|
|
1325
|
+
case "instance":
|
|
1326
|
+
return `${o}#${i}`;
|
|
1327
|
+
case "property":
|
|
1328
|
+
return `${o}.${i}`;
|
|
1329
|
+
case "property-brackets":
|
|
1330
|
+
return `${o}[${i}]`;
|
|
1331
|
+
}
|
|
1332
|
+
}, "JsdocTypeNamePath"),
|
|
1333
|
+
JsdocTypeStringValue: /* @__PURE__ */ r((e) => I(e.value, e.meta.quote), "JsdocTypeStringValue"),
|
|
1334
|
+
JsdocTypeAny: /* @__PURE__ */ r(() => "*", "JsdocTypeAny"),
|
|
1335
|
+
JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => {
|
|
1336
|
+
if (e.meta.brackets === "square") {
|
|
1337
|
+
let o = e.elements[0], i = t(o);
|
|
1338
|
+
return o.type === "JsdocTypeUnion" || o.type === "JsdocTypeIntersection" ? `(${i})[]` : `${i}[]`;
|
|
1339
|
+
} else
|
|
1340
|
+
return `${t(e.left)}${e.meta.dot ? "." : ""}<${e.elements.map(t).join(", ")}>`;
|
|
1341
|
+
}, "JsdocTypeGeneric"),
|
|
1342
|
+
JsdocTypeImport: /* @__PURE__ */ r((e, t) => `import(${t(e.element)})`, "JsdocTypeImport"),
|
|
1343
|
+
JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => {
|
|
1344
|
+
let o = "";
|
|
1345
|
+
return e.readonly && (o += "readonly "), typeof e.key == "string" ? o += I(e.key, e.meta.quote) : o += t(e.key), e.optional && (o +=
|
|
1346
|
+
"?"), e.right === void 0 ? o : o + `: ${t(e.right)}`;
|
|
1347
|
+
}, "JsdocTypeObjectField"),
|
|
1348
|
+
JsdocTypeJsdocObjectField: /* @__PURE__ */ r((e, t) => `${t(e.left)}: ${t(e.right)}`, "JsdocTypeJsdocObjectField"),
|
|
1349
|
+
JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => {
|
|
1350
|
+
let o = e.key;
|
|
1351
|
+
return e.optional && (o += "?"), e.variadic && (o = "..." + o), e.right === void 0 ? o : o + `: ${t(e.right)}`;
|
|
1352
|
+
}, "JsdocTypeKeyValue"),
|
|
1353
|
+
JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => `${e.specialType}:${I(e.value, e.meta.quote)}`, "JsdocTypeSpecialNamePath"),
|
|
1354
|
+
JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => ne(e.meta.position, t(e.element), "!"), "JsdocTypeNotNullable"),
|
|
1355
|
+
JsdocTypeNull: /* @__PURE__ */ r(() => "null", "JsdocTypeNull"),
|
|
1356
|
+
JsdocTypeNullable: /* @__PURE__ */ r((e, t) => ne(e.meta.position, t(e.element), "?"), "JsdocTypeNullable"),
|
|
1357
|
+
JsdocTypeNumber: /* @__PURE__ */ r((e) => e.value.toString(), "JsdocTypeNumber"),
|
|
1358
|
+
JsdocTypeObject: /* @__PURE__ */ r((e, t) => `{${e.elements.map(t).join((e.meta.separator === "comma" ? "," : ";") + " ")}}`, "Jsdoc\
|
|
1359
|
+
TypeObject"),
|
|
1360
|
+
JsdocTypeOptional: /* @__PURE__ */ r((e, t) => ne(e.meta.position, t(e.element), "="), "JsdocTypeOptional"),
|
|
1361
|
+
JsdocTypeSymbol: /* @__PURE__ */ r((e, t) => `${e.value}(${e.element !== void 0 ? t(e.element) : ""})`, "JsdocTypeSymbol"),
|
|
1362
|
+
JsdocTypeTypeof: /* @__PURE__ */ r((e, t) => `typeof ${t(e.element)}`, "JsdocTypeTypeof"),
|
|
1363
|
+
JsdocTypeUndefined: /* @__PURE__ */ r(() => "undefined", "JsdocTypeUndefined"),
|
|
1364
|
+
JsdocTypeUnion: /* @__PURE__ */ r((e, t) => e.elements.map(t).join(" | "), "JsdocTypeUnion"),
|
|
1365
|
+
JsdocTypeUnknown: /* @__PURE__ */ r(() => "?", "JsdocTypeUnknown"),
|
|
1366
|
+
JsdocTypeIntersection: /* @__PURE__ */ r((e, t) => e.elements.map(t).join(" & "), "JsdocTypeIntersection"),
|
|
1367
|
+
JsdocTypeProperty: /* @__PURE__ */ r((e) => I(e.value, e.meta.quote), "JsdocTypeProperty"),
|
|
1368
|
+
JsdocTypePredicate: /* @__PURE__ */ r((e, t) => `${t(e.left)} is ${t(e.right)}`, "JsdocTypePredicate"),
|
|
1369
|
+
JsdocTypeIndexSignature: /* @__PURE__ */ r((e, t) => `[${e.key}: ${t(e.right)}]`, "JsdocTypeIndexSignature"),
|
|
1370
|
+
JsdocTypeMappedType: /* @__PURE__ */ r((e, t) => `[${e.key} in ${t(e.right)}]`, "JsdocTypeMappedType")
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
r(tt, "stringifyRules");
|
|
1374
|
+
let sr = tt();
|
|
1375
|
+
function ar(e) {
|
|
1376
|
+
return W(sr, e);
|
|
1377
|
+
}
|
|
1378
|
+
r(ar, "stringify");
|
|
1379
|
+
let ir = [
|
|
1380
|
+
"null",
|
|
1381
|
+
"true",
|
|
1382
|
+
"false",
|
|
1383
|
+
"break",
|
|
1384
|
+
"case",
|
|
1385
|
+
"catch",
|
|
1386
|
+
"class",
|
|
1387
|
+
"const",
|
|
1388
|
+
"continue",
|
|
1389
|
+
"debugger",
|
|
1390
|
+
"default",
|
|
1391
|
+
"delete",
|
|
1392
|
+
"do",
|
|
1393
|
+
"else",
|
|
1394
|
+
"export",
|
|
1395
|
+
"extends",
|
|
1396
|
+
"finally",
|
|
1397
|
+
"for",
|
|
1398
|
+
"function",
|
|
1399
|
+
"if",
|
|
1400
|
+
"import",
|
|
1401
|
+
"in",
|
|
1402
|
+
"instanceof",
|
|
1403
|
+
"new",
|
|
1404
|
+
"return",
|
|
1405
|
+
"super",
|
|
1406
|
+
"switch",
|
|
1407
|
+
"this",
|
|
1408
|
+
"throw",
|
|
1409
|
+
"try",
|
|
1410
|
+
"typeof",
|
|
1411
|
+
"var",
|
|
1412
|
+
"void",
|
|
1413
|
+
"while",
|
|
1414
|
+
"with",
|
|
1415
|
+
"yield"
|
|
1416
|
+
];
|
|
1417
|
+
function F(e) {
|
|
1418
|
+
let t = {
|
|
1419
|
+
type: "NameExpression",
|
|
1420
|
+
name: e
|
|
1421
|
+
};
|
|
1422
|
+
return ir.includes(e) && (t.reservedWord = !0), t;
|
|
1423
|
+
}
|
|
1424
|
+
r(F, "makeName");
|
|
1425
|
+
let pr = {
|
|
1426
|
+
JsdocTypeOptional: /* @__PURE__ */ r((e, t) => {
|
|
1427
|
+
let o = t(e.element);
|
|
1428
|
+
return o.optional = !0, o;
|
|
1429
|
+
}, "JsdocTypeOptional"),
|
|
1430
|
+
JsdocTypeNullable: /* @__PURE__ */ r((e, t) => {
|
|
1431
|
+
let o = t(e.element);
|
|
1432
|
+
return o.nullable = !0, o;
|
|
1433
|
+
}, "JsdocTypeNullable"),
|
|
1434
|
+
JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => {
|
|
1435
|
+
let o = t(e.element);
|
|
1436
|
+
return o.nullable = !1, o;
|
|
1437
|
+
}, "JsdocTypeNotNullable"),
|
|
1438
|
+
JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => {
|
|
1439
|
+
if (e.element === void 0)
|
|
1440
|
+
throw new Error("dots without value are not allowed in catharsis mode");
|
|
1441
|
+
let o = t(e.element);
|
|
1442
|
+
return o.repeatable = !0, o;
|
|
1443
|
+
}, "JsdocTypeVariadic"),
|
|
1444
|
+
JsdocTypeAny: /* @__PURE__ */ r(() => ({
|
|
1445
|
+
type: "AllLiteral"
|
|
1446
|
+
}), "JsdocTypeAny"),
|
|
1447
|
+
JsdocTypeNull: /* @__PURE__ */ r(() => ({
|
|
1448
|
+
type: "NullLiteral"
|
|
1449
|
+
}), "JsdocTypeNull"),
|
|
1450
|
+
JsdocTypeStringValue: /* @__PURE__ */ r((e) => F(I(e.value, e.meta.quote)), "JsdocTypeStringValue"),
|
|
1451
|
+
JsdocTypeUndefined: /* @__PURE__ */ r(() => ({
|
|
1452
|
+
type: "UndefinedLiteral"
|
|
1453
|
+
}), "JsdocTypeUndefined"),
|
|
1454
|
+
JsdocTypeUnknown: /* @__PURE__ */ r(() => ({
|
|
1455
|
+
type: "UnknownLiteral"
|
|
1456
|
+
}), "JsdocTypeUnknown"),
|
|
1457
|
+
JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
|
|
1458
|
+
let o = et(e), i = {
|
|
1459
|
+
type: "FunctionType",
|
|
1460
|
+
params: o.params.map(t)
|
|
1461
|
+
};
|
|
1462
|
+
return o.this !== void 0 && (i.this = t(o.this)), o.new !== void 0 && (i.new = t(o.new)), e.returnType !== void 0 && (i.result = t(e.
|
|
1463
|
+
returnType)), i;
|
|
1464
|
+
}, "JsdocTypeFunction"),
|
|
1465
|
+
JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => ({
|
|
1466
|
+
type: "TypeApplication",
|
|
1467
|
+
applications: e.elements.map((o) => t(o)),
|
|
1468
|
+
expression: t(e.left)
|
|
1469
|
+
}), "JsdocTypeGeneric"),
|
|
1470
|
+
JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => F(e.specialType + ":" + I(e.value, e.meta.quote)), "JsdocTypeSpecialNamePath"),
|
|
1471
|
+
JsdocTypeName: /* @__PURE__ */ r((e) => e.value !== "function" ? F(e.value) : {
|
|
1472
|
+
type: "FunctionType",
|
|
1473
|
+
params: []
|
|
1474
|
+
}, "JsdocTypeName"),
|
|
1475
|
+
JsdocTypeNumber: /* @__PURE__ */ r((e) => F(e.value.toString()), "JsdocTypeNumber"),
|
|
1476
|
+
JsdocTypeObject: /* @__PURE__ */ r((e, t) => {
|
|
1477
|
+
let o = {
|
|
1478
|
+
type: "RecordType",
|
|
1479
|
+
fields: []
|
|
1480
|
+
};
|
|
1481
|
+
for (let i of e.elements)
|
|
1482
|
+
i.type !== "JsdocTypeObjectField" && i.type !== "JsdocTypeJsdocObjectField" ? o.fields.push({
|
|
1483
|
+
type: "FieldType",
|
|
1484
|
+
key: t(i),
|
|
1485
|
+
value: void 0
|
|
1486
|
+
}) : o.fields.push(t(i));
|
|
1487
|
+
return o;
|
|
1488
|
+
}, "JsdocTypeObject"),
|
|
1489
|
+
JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => {
|
|
1490
|
+
if (typeof e.key != "string")
|
|
1491
|
+
throw new Error("Index signatures and mapped types are not supported");
|
|
1492
|
+
return {
|
|
1493
|
+
type: "FieldType",
|
|
1494
|
+
key: F(I(e.key, e.meta.quote)),
|
|
1495
|
+
value: e.right === void 0 ? void 0 : t(e.right)
|
|
1496
|
+
};
|
|
1497
|
+
}, "JsdocTypeObjectField"),
|
|
1498
|
+
JsdocTypeJsdocObjectField: /* @__PURE__ */ r((e, t) => ({
|
|
1499
|
+
type: "FieldType",
|
|
1500
|
+
key: t(e.left),
|
|
1501
|
+
value: t(e.right)
|
|
1502
|
+
}), "JsdocTypeJsdocObjectField"),
|
|
1503
|
+
JsdocTypeUnion: /* @__PURE__ */ r((e, t) => ({
|
|
1504
|
+
type: "TypeUnion",
|
|
1505
|
+
elements: e.elements.map((o) => t(o))
|
|
1506
|
+
}), "JsdocTypeUnion"),
|
|
1507
|
+
JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => ({
|
|
1508
|
+
type: "FieldType",
|
|
1509
|
+
key: F(e.key),
|
|
1510
|
+
value: e.right === void 0 ? void 0 : t(e.right)
|
|
1511
|
+
}), "JsdocTypeKeyValue"),
|
|
1512
|
+
JsdocTypeNamePath: /* @__PURE__ */ r((e, t) => {
|
|
1513
|
+
let o = t(e.left), i;
|
|
1514
|
+
e.right.type === "JsdocTypeSpecialNamePath" ? i = t(e.right).name : i = I(e.right.value, e.right.meta.quote);
|
|
1515
|
+
let l = e.pathType === "inner" ? "~" : e.pathType === "instance" ? "#" : ".";
|
|
1516
|
+
return F(`${o.name}${l}${i}`);
|
|
1517
|
+
}, "JsdocTypeNamePath"),
|
|
1518
|
+
JsdocTypeSymbol: /* @__PURE__ */ r((e) => {
|
|
1519
|
+
let t = "", o = e.element, i = !1;
|
|
1520
|
+
return o?.type === "JsdocTypeVariadic" && (o.meta.position === "prefix" ? t = "..." : i = !0, o = o.element), o?.type === "JsdocType\
|
|
1521
|
+
Name" ? t += o.value : o?.type === "JsdocTypeNumber" && (t += o.value.toString()), i && (t += "..."), F(`${e.value}(${t})`);
|
|
1522
|
+
}, "JsdocTypeSymbol"),
|
|
1523
|
+
JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => t(w(e.element)), "JsdocTypeParenthesis"),
|
|
1524
|
+
JsdocTypeMappedType: D,
|
|
1525
|
+
JsdocTypeIndexSignature: D,
|
|
1526
|
+
JsdocTypeImport: D,
|
|
1527
|
+
JsdocTypeKeyof: D,
|
|
1528
|
+
JsdocTypeTuple: D,
|
|
1529
|
+
JsdocTypeTypeof: D,
|
|
1530
|
+
JsdocTypeIntersection: D,
|
|
1531
|
+
JsdocTypeProperty: D,
|
|
1532
|
+
JsdocTypePredicate: D
|
|
1533
|
+
};
|
|
1534
|
+
function cr(e) {
|
|
1535
|
+
return W(pr, e);
|
|
1536
|
+
}
|
|
1537
|
+
r(cr, "catharsisTransform");
|
|
1538
|
+
function _(e) {
|
|
1539
|
+
switch (e) {
|
|
1540
|
+
case void 0:
|
|
1541
|
+
return "none";
|
|
1542
|
+
case "single":
|
|
1543
|
+
return "single";
|
|
1544
|
+
case "double":
|
|
1545
|
+
return "double";
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
r(_, "getQuoteStyle");
|
|
1549
|
+
function lr(e) {
|
|
1550
|
+
switch (e) {
|
|
1551
|
+
case "inner":
|
|
1552
|
+
return "INNER_MEMBER";
|
|
1553
|
+
case "instance":
|
|
1554
|
+
return "INSTANCE_MEMBER";
|
|
1555
|
+
case "property":
|
|
1556
|
+
return "MEMBER";
|
|
1557
|
+
case "property-brackets":
|
|
1558
|
+
return "MEMBER";
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
r(lr, "getMemberType");
|
|
1562
|
+
function Ne(e, t) {
|
|
1563
|
+
return t.length === 2 ? {
|
|
1564
|
+
type: e,
|
|
1565
|
+
left: t[0],
|
|
1566
|
+
right: t[1]
|
|
1567
|
+
} : {
|
|
1568
|
+
type: e,
|
|
1569
|
+
left: t[0],
|
|
1570
|
+
right: Ne(e, t.slice(1))
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
r(Ne, "nestResults");
|
|
1574
|
+
let ur = {
|
|
1575
|
+
JsdocTypeOptional: /* @__PURE__ */ r((e, t) => ({
|
|
1576
|
+
type: "OPTIONAL",
|
|
1577
|
+
value: t(e.element),
|
|
1578
|
+
meta: {
|
|
1579
|
+
syntax: e.meta.position === "prefix" ? "PREFIX_EQUAL_SIGN" : "SUFFIX_EQUALS_SIGN"
|
|
1580
|
+
}
|
|
1581
|
+
}), "JsdocTypeOptional"),
|
|
1582
|
+
JsdocTypeNullable: /* @__PURE__ */ r((e, t) => ({
|
|
1583
|
+
type: "NULLABLE",
|
|
1584
|
+
value: t(e.element),
|
|
1585
|
+
meta: {
|
|
1586
|
+
syntax: e.meta.position === "prefix" ? "PREFIX_QUESTION_MARK" : "SUFFIX_QUESTION_MARK"
|
|
1587
|
+
}
|
|
1588
|
+
}), "JsdocTypeNullable"),
|
|
1589
|
+
JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => ({
|
|
1590
|
+
type: "NOT_NULLABLE",
|
|
1591
|
+
value: t(e.element),
|
|
1592
|
+
meta: {
|
|
1593
|
+
syntax: e.meta.position === "prefix" ? "PREFIX_BANG" : "SUFFIX_BANG"
|
|
1594
|
+
}
|
|
1595
|
+
}), "JsdocTypeNotNullable"),
|
|
1596
|
+
JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => {
|
|
1597
|
+
let o = {
|
|
1598
|
+
type: "VARIADIC",
|
|
1599
|
+
meta: {
|
|
1600
|
+
syntax: e.meta.position === "prefix" ? "PREFIX_DOTS" : e.meta.position === "suffix" ? "SUFFIX_DOTS" : "ONLY_DOTS"
|
|
1601
|
+
}
|
|
1602
|
+
};
|
|
1603
|
+
return e.element !== void 0 && (o.value = t(e.element)), o;
|
|
1604
|
+
}, "JsdocTypeVariadic"),
|
|
1605
|
+
JsdocTypeName: /* @__PURE__ */ r((e) => ({
|
|
1606
|
+
type: "NAME",
|
|
1607
|
+
name: e.value
|
|
1608
|
+
}), "JsdocTypeName"),
|
|
1609
|
+
JsdocTypeTypeof: /* @__PURE__ */ r((e, t) => ({
|
|
1610
|
+
type: "TYPE_QUERY",
|
|
1611
|
+
name: t(e.element)
|
|
1612
|
+
}), "JsdocTypeTypeof"),
|
|
1613
|
+
JsdocTypeTuple: /* @__PURE__ */ r((e, t) => ({
|
|
1614
|
+
type: "TUPLE",
|
|
1615
|
+
entries: e.elements.map(t)
|
|
1616
|
+
}), "JsdocTypeTuple"),
|
|
1617
|
+
JsdocTypeKeyof: /* @__PURE__ */ r((e, t) => ({
|
|
1618
|
+
type: "KEY_QUERY",
|
|
1619
|
+
value: t(e.element)
|
|
1620
|
+
}), "JsdocTypeKeyof"),
|
|
1621
|
+
JsdocTypeImport: /* @__PURE__ */ r((e) => ({
|
|
1622
|
+
type: "IMPORT",
|
|
1623
|
+
path: {
|
|
1624
|
+
type: "STRING_VALUE",
|
|
1625
|
+
quoteStyle: _(e.element.meta.quote),
|
|
1626
|
+
string: e.element.value
|
|
1627
|
+
}
|
|
1628
|
+
}), "JsdocTypeImport"),
|
|
1629
|
+
JsdocTypeUndefined: /* @__PURE__ */ r(() => ({
|
|
1630
|
+
type: "NAME",
|
|
1631
|
+
name: "undefined"
|
|
1632
|
+
}), "JsdocTypeUndefined"),
|
|
1633
|
+
JsdocTypeAny: /* @__PURE__ */ r(() => ({
|
|
1634
|
+
type: "ANY"
|
|
1635
|
+
}), "JsdocTypeAny"),
|
|
1636
|
+
JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
|
|
1637
|
+
let o = et(e), i = {
|
|
1638
|
+
type: e.arrow ? "ARROW" : "FUNCTION",
|
|
1639
|
+
params: o.params.map((l) => {
|
|
1640
|
+
if (l.type === "JsdocTypeKeyValue") {
|
|
1641
|
+
if (l.right === void 0)
|
|
1642
|
+
throw new Error("Function parameter without ':' is not expected to be 'KEY_VALUE'");
|
|
1643
|
+
return {
|
|
1644
|
+
type: "NAMED_PARAMETER",
|
|
1645
|
+
name: l.key,
|
|
1646
|
+
typeName: t(l.right)
|
|
1647
|
+
};
|
|
1648
|
+
} else
|
|
1649
|
+
return t(l);
|
|
1650
|
+
}),
|
|
1651
|
+
new: null,
|
|
1652
|
+
returns: null
|
|
1653
|
+
};
|
|
1654
|
+
return o.this !== void 0 ? i.this = t(o.this) : e.arrow || (i.this = null), o.new !== void 0 && (i.new = t(o.new)), e.returnType !==
|
|
1655
|
+
void 0 && (i.returns = t(e.returnType)), i;
|
|
1656
|
+
}, "JsdocTypeFunction"),
|
|
1657
|
+
JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => {
|
|
1658
|
+
let o = {
|
|
1659
|
+
type: "GENERIC",
|
|
1660
|
+
subject: t(e.left),
|
|
1661
|
+
objects: e.elements.map(t),
|
|
1662
|
+
meta: {
|
|
1663
|
+
syntax: e.meta.brackets === "square" ? "SQUARE_BRACKET" : e.meta.dot ? "ANGLE_BRACKET_WITH_DOT" : "ANGLE_BRACKET"
|
|
1664
|
+
}
|
|
1665
|
+
};
|
|
1666
|
+
return e.meta.brackets === "square" && e.elements[0].type === "JsdocTypeFunction" && !e.elements[0].parenthesis && (o.objects[0] = {
|
|
1667
|
+
type: "NAME",
|
|
1668
|
+
name: "function"
|
|
1669
|
+
}), o;
|
|
1670
|
+
}, "JsdocTypeGeneric"),
|
|
1671
|
+
JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => {
|
|
1672
|
+
if (typeof e.key != "string")
|
|
1673
|
+
throw new Error("Index signatures and mapped types are not supported");
|
|
1674
|
+
if (e.right === void 0)
|
|
1675
|
+
return {
|
|
1676
|
+
type: "RECORD_ENTRY",
|
|
1677
|
+
key: e.key,
|
|
1678
|
+
quoteStyle: _(e.meta.quote),
|
|
1679
|
+
value: null,
|
|
1680
|
+
readonly: !1
|
|
1681
|
+
};
|
|
1682
|
+
let o = t(e.right);
|
|
1683
|
+
return e.optional && (o = {
|
|
1684
|
+
type: "OPTIONAL",
|
|
1685
|
+
value: o,
|
|
1686
|
+
meta: {
|
|
1687
|
+
syntax: "SUFFIX_KEY_QUESTION_MARK"
|
|
1688
|
+
}
|
|
1689
|
+
}), {
|
|
1690
|
+
type: "RECORD_ENTRY",
|
|
1691
|
+
key: e.key.toString(),
|
|
1692
|
+
quoteStyle: _(e.meta.quote),
|
|
1693
|
+
value: o,
|
|
1694
|
+
readonly: !1
|
|
1695
|
+
};
|
|
1696
|
+
}, "JsdocTypeObjectField"),
|
|
1697
|
+
JsdocTypeJsdocObjectField: /* @__PURE__ */ r(() => {
|
|
1698
|
+
throw new Error("Keys may not be typed in jsdoctypeparser.");
|
|
1699
|
+
}, "JsdocTypeJsdocObjectField"),
|
|
1700
|
+
JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => {
|
|
1701
|
+
if (e.right === void 0)
|
|
1702
|
+
return {
|
|
1703
|
+
type: "RECORD_ENTRY",
|
|
1704
|
+
key: e.key,
|
|
1705
|
+
quoteStyle: "none",
|
|
1706
|
+
value: null,
|
|
1707
|
+
readonly: !1
|
|
1708
|
+
};
|
|
1709
|
+
let o = t(e.right);
|
|
1710
|
+
return e.optional && (o = {
|
|
1711
|
+
type: "OPTIONAL",
|
|
1712
|
+
value: o,
|
|
1713
|
+
meta: {
|
|
1714
|
+
syntax: "SUFFIX_KEY_QUESTION_MARK"
|
|
1715
|
+
}
|
|
1716
|
+
}), {
|
|
1717
|
+
type: "RECORD_ENTRY",
|
|
1718
|
+
key: e.key,
|
|
1719
|
+
quoteStyle: "none",
|
|
1720
|
+
value: o,
|
|
1721
|
+
readonly: !1
|
|
1722
|
+
};
|
|
1723
|
+
}, "JsdocTypeKeyValue"),
|
|
1724
|
+
JsdocTypeObject: /* @__PURE__ */ r((e, t) => {
|
|
1725
|
+
let o = [];
|
|
1726
|
+
for (let i of e.elements)
|
|
1727
|
+
(i.type === "JsdocTypeObjectField" || i.type === "JsdocTypeJsdocObjectField") && o.push(t(i));
|
|
1728
|
+
return {
|
|
1729
|
+
type: "RECORD",
|
|
1730
|
+
entries: o
|
|
1731
|
+
};
|
|
1732
|
+
}, "JsdocTypeObject"),
|
|
1733
|
+
JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => {
|
|
1734
|
+
if (e.specialType !== "module")
|
|
1735
|
+
throw new Error(`jsdoctypeparser does not support type ${e.specialType} at this point.`);
|
|
1736
|
+
return {
|
|
1737
|
+
type: "MODULE",
|
|
1738
|
+
value: {
|
|
1739
|
+
type: "FILE_PATH",
|
|
1740
|
+
quoteStyle: _(e.meta.quote),
|
|
1741
|
+
path: e.value
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1744
|
+
}, "JsdocTypeSpecialNamePath"),
|
|
1745
|
+
JsdocTypeNamePath: /* @__PURE__ */ r((e, t) => {
|
|
1746
|
+
let o = !1, i, l;
|
|
1747
|
+
e.right.type === "JsdocTypeSpecialNamePath" && e.right.specialType === "event" ? (o = !0, i = e.right.value, l = _(e.right.meta.quote)) :
|
|
1748
|
+
(i = e.right.value, l = _(e.right.meta.quote));
|
|
1749
|
+
let m = {
|
|
1750
|
+
type: lr(e.pathType),
|
|
1751
|
+
owner: t(e.left),
|
|
1752
|
+
name: i,
|
|
1753
|
+
quoteStyle: l,
|
|
1754
|
+
hasEventPrefix: o
|
|
1755
|
+
};
|
|
1756
|
+
if (m.owner.type === "MODULE") {
|
|
1757
|
+
let d = m.owner;
|
|
1758
|
+
return m.owner = m.owner.value, d.value = m, d;
|
|
1759
|
+
} else
|
|
1760
|
+
return m;
|
|
1761
|
+
}, "JsdocTypeNamePath"),
|
|
1762
|
+
JsdocTypeUnion: /* @__PURE__ */ r((e, t) => Ne("UNION", e.elements.map(t)), "JsdocTypeUnion"),
|
|
1763
|
+
JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => ({
|
|
1764
|
+
type: "PARENTHESIS",
|
|
1765
|
+
value: t(w(e.element))
|
|
1766
|
+
}), "JsdocTypeParenthesis"),
|
|
1767
|
+
JsdocTypeNull: /* @__PURE__ */ r(() => ({
|
|
1768
|
+
type: "NAME",
|
|
1769
|
+
name: "null"
|
|
1770
|
+
}), "JsdocTypeNull"),
|
|
1771
|
+
JsdocTypeUnknown: /* @__PURE__ */ r(() => ({
|
|
1772
|
+
type: "UNKNOWN"
|
|
1773
|
+
}), "JsdocTypeUnknown"),
|
|
1774
|
+
JsdocTypeStringValue: /* @__PURE__ */ r((e) => ({
|
|
1775
|
+
type: "STRING_VALUE",
|
|
1776
|
+
quoteStyle: _(e.meta.quote),
|
|
1777
|
+
string: e.value
|
|
1778
|
+
}), "JsdocTypeStringValue"),
|
|
1779
|
+
JsdocTypeIntersection: /* @__PURE__ */ r((e, t) => Ne("INTERSECTION", e.elements.map(t)), "JsdocTypeIntersection"),
|
|
1780
|
+
JsdocTypeNumber: /* @__PURE__ */ r((e) => ({
|
|
1781
|
+
type: "NUMBER_VALUE",
|
|
1782
|
+
number: e.value.toString()
|
|
1783
|
+
}), "JsdocTypeNumber"),
|
|
1784
|
+
JsdocTypeSymbol: D,
|
|
1785
|
+
JsdocTypeProperty: D,
|
|
1786
|
+
JsdocTypePredicate: D,
|
|
1787
|
+
JsdocTypeMappedType: D,
|
|
1788
|
+
JsdocTypeIndexSignature: D
|
|
1789
|
+
};
|
|
1790
|
+
function mr(e) {
|
|
1791
|
+
return W(ur, e);
|
|
1792
|
+
}
|
|
1793
|
+
r(mr, "jtpTransform");
|
|
1794
|
+
function yr() {
|
|
1795
|
+
return {
|
|
1796
|
+
JsdocTypeIntersection: /* @__PURE__ */ r((e, t) => ({
|
|
1797
|
+
type: "JsdocTypeIntersection",
|
|
1798
|
+
elements: e.elements.map(t)
|
|
1799
|
+
}), "JsdocTypeIntersection"),
|
|
1800
|
+
JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => ({
|
|
1801
|
+
type: "JsdocTypeGeneric",
|
|
1802
|
+
left: t(e.left),
|
|
1803
|
+
elements: e.elements.map(t),
|
|
1804
|
+
meta: {
|
|
1805
|
+
dot: e.meta.dot,
|
|
1806
|
+
brackets: e.meta.brackets
|
|
1807
|
+
}
|
|
1808
|
+
}), "JsdocTypeGeneric"),
|
|
1809
|
+
JsdocTypeNullable: /* @__PURE__ */ r((e) => e, "JsdocTypeNullable"),
|
|
1810
|
+
JsdocTypeUnion: /* @__PURE__ */ r((e, t) => ({
|
|
1811
|
+
type: "JsdocTypeUnion",
|
|
1812
|
+
elements: e.elements.map(t)
|
|
1813
|
+
}), "JsdocTypeUnion"),
|
|
1814
|
+
JsdocTypeUnknown: /* @__PURE__ */ r((e) => e, "JsdocTypeUnknown"),
|
|
1815
|
+
JsdocTypeUndefined: /* @__PURE__ */ r((e) => e, "JsdocTypeUndefined"),
|
|
1816
|
+
JsdocTypeTypeof: /* @__PURE__ */ r((e, t) => ({
|
|
1817
|
+
type: "JsdocTypeTypeof",
|
|
1818
|
+
element: t(e.element)
|
|
1819
|
+
}), "JsdocTypeTypeof"),
|
|
1820
|
+
JsdocTypeSymbol: /* @__PURE__ */ r((e, t) => {
|
|
1821
|
+
let o = {
|
|
1822
|
+
type: "JsdocTypeSymbol",
|
|
1823
|
+
value: e.value
|
|
1824
|
+
};
|
|
1825
|
+
return e.element !== void 0 && (o.element = t(e.element)), o;
|
|
1826
|
+
}, "JsdocTypeSymbol"),
|
|
1827
|
+
JsdocTypeOptional: /* @__PURE__ */ r((e, t) => ({
|
|
1828
|
+
type: "JsdocTypeOptional",
|
|
1829
|
+
element: t(e.element),
|
|
1830
|
+
meta: {
|
|
1831
|
+
position: e.meta.position
|
|
1832
|
+
}
|
|
1833
|
+
}), "JsdocTypeOptional"),
|
|
1834
|
+
JsdocTypeObject: /* @__PURE__ */ r((e, t) => ({
|
|
1835
|
+
type: "JsdocTypeObject",
|
|
1836
|
+
meta: {
|
|
1837
|
+
separator: "comma"
|
|
1838
|
+
},
|
|
1839
|
+
elements: e.elements.map(t)
|
|
1840
|
+
}), "JsdocTypeObject"),
|
|
1841
|
+
JsdocTypeNumber: /* @__PURE__ */ r((e) => e, "JsdocTypeNumber"),
|
|
1842
|
+
JsdocTypeNull: /* @__PURE__ */ r((e) => e, "JsdocTypeNull"),
|
|
1843
|
+
JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => ({
|
|
1844
|
+
type: "JsdocTypeNotNullable",
|
|
1845
|
+
element: t(e.element),
|
|
1846
|
+
meta: {
|
|
1847
|
+
position: e.meta.position
|
|
1848
|
+
}
|
|
1849
|
+
}), "JsdocTypeNotNullable"),
|
|
1850
|
+
JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => e, "JsdocTypeSpecialNamePath"),
|
|
1851
|
+
JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => ({
|
|
1852
|
+
type: "JsdocTypeObjectField",
|
|
1853
|
+
key: e.key,
|
|
1854
|
+
right: e.right === void 0 ? void 0 : t(e.right),
|
|
1855
|
+
optional: e.optional,
|
|
1856
|
+
readonly: e.readonly,
|
|
1857
|
+
meta: e.meta
|
|
1858
|
+
}), "JsdocTypeObjectField"),
|
|
1859
|
+
JsdocTypeJsdocObjectField: /* @__PURE__ */ r((e, t) => ({
|
|
1860
|
+
type: "JsdocTypeJsdocObjectField",
|
|
1861
|
+
left: t(e.left),
|
|
1862
|
+
right: t(e.right)
|
|
1863
|
+
}), "JsdocTypeJsdocObjectField"),
|
|
1864
|
+
JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => ({
|
|
1865
|
+
type: "JsdocTypeKeyValue",
|
|
1866
|
+
key: e.key,
|
|
1867
|
+
right: e.right === void 0 ? void 0 : t(e.right),
|
|
1868
|
+
optional: e.optional,
|
|
1869
|
+
variadic: e.variadic
|
|
1870
|
+
}), "JsdocTypeKeyValue"),
|
|
1871
|
+
JsdocTypeImport: /* @__PURE__ */ r((e, t) => ({
|
|
1872
|
+
type: "JsdocTypeImport",
|
|
1873
|
+
element: t(e.element)
|
|
1874
|
+
}), "JsdocTypeImport"),
|
|
1875
|
+
JsdocTypeAny: /* @__PURE__ */ r((e) => e, "JsdocTypeAny"),
|
|
1876
|
+
JsdocTypeStringValue: /* @__PURE__ */ r((e) => e, "JsdocTypeStringValue"),
|
|
1877
|
+
JsdocTypeNamePath: /* @__PURE__ */ r((e) => e, "JsdocTypeNamePath"),
|
|
1878
|
+
JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => {
|
|
1879
|
+
let o = {
|
|
1880
|
+
type: "JsdocTypeVariadic",
|
|
1881
|
+
meta: {
|
|
1882
|
+
position: e.meta.position,
|
|
1883
|
+
squareBrackets: e.meta.squareBrackets
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1886
|
+
return e.element !== void 0 && (o.element = t(e.element)), o;
|
|
1887
|
+
}, "JsdocTypeVariadic"),
|
|
1888
|
+
JsdocTypeTuple: /* @__PURE__ */ r((e, t) => ({
|
|
1889
|
+
type: "JsdocTypeTuple",
|
|
1890
|
+
elements: e.elements.map(t)
|
|
1891
|
+
}), "JsdocTypeTuple"),
|
|
1892
|
+
JsdocTypeName: /* @__PURE__ */ r((e) => e, "JsdocTypeName"),
|
|
1893
|
+
JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
|
|
1894
|
+
let o = {
|
|
1895
|
+
type: "JsdocTypeFunction",
|
|
1896
|
+
arrow: e.arrow,
|
|
1897
|
+
parameters: e.parameters.map(t),
|
|
1898
|
+
constructor: e.constructor,
|
|
1899
|
+
parenthesis: e.parenthesis
|
|
1900
|
+
};
|
|
1901
|
+
return e.returnType !== void 0 && (o.returnType = t(e.returnType)), o;
|
|
1902
|
+
}, "JsdocTypeFunction"),
|
|
1903
|
+
JsdocTypeKeyof: /* @__PURE__ */ r((e, t) => ({
|
|
1904
|
+
type: "JsdocTypeKeyof",
|
|
1905
|
+
element: t(e.element)
|
|
1906
|
+
}), "JsdocTypeKeyof"),
|
|
1907
|
+
JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => ({
|
|
1908
|
+
type: "JsdocTypeParenthesis",
|
|
1909
|
+
element: t(e.element)
|
|
1910
|
+
}), "JsdocTypeParenthesis"),
|
|
1911
|
+
JsdocTypeProperty: /* @__PURE__ */ r((e) => e, "JsdocTypeProperty"),
|
|
1912
|
+
JsdocTypePredicate: /* @__PURE__ */ r((e, t) => ({
|
|
1913
|
+
type: "JsdocTypePredicate",
|
|
1914
|
+
left: t(e.left),
|
|
1915
|
+
right: t(e.right)
|
|
1916
|
+
}), "JsdocTypePredicate"),
|
|
1917
|
+
JsdocTypeIndexSignature: /* @__PURE__ */ r((e, t) => ({
|
|
1918
|
+
type: "JsdocTypeIndexSignature",
|
|
1919
|
+
key: e.key,
|
|
1920
|
+
right: t(e.right)
|
|
1921
|
+
}), "JsdocTypeIndexSignature"),
|
|
1922
|
+
JsdocTypeMappedType: /* @__PURE__ */ r((e, t) => ({
|
|
1923
|
+
type: "JsdocTypeMappedType",
|
|
1924
|
+
key: e.key,
|
|
1925
|
+
right: t(e.right)
|
|
1926
|
+
}), "JsdocTypeMappedType")
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1929
|
+
r(yr, "identityTransformRules");
|
|
1930
|
+
let rt = {
|
|
1931
|
+
JsdocTypeAny: [],
|
|
1932
|
+
JsdocTypeFunction: ["parameters", "returnType"],
|
|
1933
|
+
JsdocTypeGeneric: ["left", "elements"],
|
|
1934
|
+
JsdocTypeImport: [],
|
|
1935
|
+
JsdocTypeIndexSignature: ["right"],
|
|
1936
|
+
JsdocTypeIntersection: ["elements"],
|
|
1937
|
+
JsdocTypeKeyof: ["element"],
|
|
1938
|
+
JsdocTypeKeyValue: ["right"],
|
|
1939
|
+
JsdocTypeMappedType: ["right"],
|
|
1940
|
+
JsdocTypeName: [],
|
|
1941
|
+
JsdocTypeNamePath: ["left", "right"],
|
|
1942
|
+
JsdocTypeNotNullable: ["element"],
|
|
1943
|
+
JsdocTypeNull: [],
|
|
1944
|
+
JsdocTypeNullable: ["element"],
|
|
1945
|
+
JsdocTypeNumber: [],
|
|
1946
|
+
JsdocTypeObject: ["elements"],
|
|
1947
|
+
JsdocTypeObjectField: ["right"],
|
|
1948
|
+
JsdocTypeJsdocObjectField: ["left", "right"],
|
|
1949
|
+
JsdocTypeOptional: ["element"],
|
|
1950
|
+
JsdocTypeParenthesis: ["element"],
|
|
1951
|
+
JsdocTypeSpecialNamePath: [],
|
|
1952
|
+
JsdocTypeStringValue: [],
|
|
1953
|
+
JsdocTypeSymbol: ["element"],
|
|
1954
|
+
JsdocTypeTuple: ["elements"],
|
|
1955
|
+
JsdocTypeTypeof: ["element"],
|
|
1956
|
+
JsdocTypeUndefined: [],
|
|
1957
|
+
JsdocTypeUnion: ["elements"],
|
|
1958
|
+
JsdocTypeUnknown: [],
|
|
1959
|
+
JsdocTypeVariadic: ["element"],
|
|
1960
|
+
JsdocTypeProperty: [],
|
|
1961
|
+
JsdocTypePredicate: ["left", "right"]
|
|
1962
|
+
};
|
|
1963
|
+
function De(e, t, o, i, l) {
|
|
1964
|
+
i?.(e, t, o);
|
|
1965
|
+
let m = rt[e.type];
|
|
1966
|
+
for (let d of m) {
|
|
1967
|
+
let x = e[d];
|
|
1968
|
+
if (x !== void 0)
|
|
1969
|
+
if (Array.isArray(x))
|
|
1970
|
+
for (let N of x)
|
|
1971
|
+
De(N, e, d, i, l);
|
|
1972
|
+
else
|
|
1973
|
+
De(x, e, d, i, l);
|
|
1974
|
+
}
|
|
1975
|
+
l?.(e, t, o);
|
|
1976
|
+
}
|
|
1977
|
+
r(De, "_traverse");
|
|
1978
|
+
function fr(e, t, o) {
|
|
1979
|
+
De(e, void 0, void 0, t, o);
|
|
1980
|
+
}
|
|
1981
|
+
r(fr, "traverse"), n.catharsisTransform = cr, n.identityTransformRules = yr, n.jtpTransform = mr, n.parse = Ze, n.stringify = ar, n.stringifyRules =
|
|
1982
|
+
tt, n.transform = W, n.traverse = fr, n.tryParse = or, n.visitorKeys = rt;
|
|
1983
|
+
});
|
|
1984
|
+
});
|
|
1985
|
+
|
|
1986
|
+
// src/docs-tools/index.ts
|
|
1987
|
+
var bn = {};
|
|
1988
|
+
wr(bn, {
|
|
1989
|
+
ADDON_ID: () => Ye,
|
|
1990
|
+
MAX_DEFAULT_VALUE_SUMMARY_LENGTH: () => Zr,
|
|
1991
|
+
MAX_TYPE_SUMMARY_LENGTH: () => Qr,
|
|
1992
|
+
PANEL_ID: () => hn,
|
|
1993
|
+
PARAM_KEY: () => xn,
|
|
1994
|
+
SNIPPET_RENDERED: () => Jn,
|
|
1995
|
+
SourceType: () => It,
|
|
1996
|
+
TypeSystem: () => ct,
|
|
1997
|
+
convert: () => X,
|
|
1998
|
+
createSummaryValue: () => J,
|
|
1999
|
+
enhanceArgTypes: () => gn,
|
|
2000
|
+
extractComponentDescription: () => Tn,
|
|
2001
|
+
extractComponentProps: () => dn,
|
|
2002
|
+
extractComponentSectionArray: () => vt,
|
|
2003
|
+
extractComponentSectionObject: () => kt,
|
|
2004
|
+
getDocgenDescription: () => Ie,
|
|
2005
|
+
getDocgenSection: () => Re,
|
|
2006
|
+
hasDocgen: () => ke,
|
|
2007
|
+
hasDocsOrControls: () => Pn,
|
|
2008
|
+
isDefaultValueBlacklisted: () => L,
|
|
2009
|
+
isTooLongForDefaultValueSummary: () => $e,
|
|
2010
|
+
isTooLongForTypeSummary: () => ue,
|
|
2011
|
+
isValidDocgenSection: () => Ae,
|
|
2012
|
+
normalizeNewlines: () => en,
|
|
2013
|
+
parseJsDoc: () => Ke,
|
|
2014
|
+
str: () => ve
|
|
2015
|
+
});
|
|
2016
|
+
module.exports = br(bn);
|
|
2017
|
+
|
|
2018
|
+
// src/docs-tools/argTypes/convert/flow/convert.ts
|
|
2019
|
+
var at = require("storybook/internal/preview-errors");
|
|
2020
|
+
var Er = /* @__PURE__ */ r((n) => n.name === "literal", "isLiteral"), Sr = /* @__PURE__ */ r((n) => n.value.replace(/['|"]/g, ""), "toEnumOp\
|
|
2021
|
+
tion"), Nr = /* @__PURE__ */ r((n) => {
|
|
2022
|
+
switch (n.type) {
|
|
2023
|
+
case "function":
|
|
2024
|
+
return { name: "function" };
|
|
2025
|
+
case "object":
|
|
2026
|
+
let s = {};
|
|
2027
|
+
return n.signature.properties.forEach((a) => {
|
|
2028
|
+
s[a.key] = B(a.value);
|
|
2029
|
+
}), {
|
|
2030
|
+
name: "object",
|
|
2031
|
+
value: s
|
|
2032
|
+
};
|
|
2033
|
+
default:
|
|
2034
|
+
throw new at.UnknownArgTypesError({ type: n, language: "Flow" });
|
|
2035
|
+
}
|
|
2036
|
+
}, "convertSig"), B = /* @__PURE__ */ r((n) => {
|
|
2037
|
+
let { name: s, raw: a } = n, p = {};
|
|
2038
|
+
switch (typeof a < "u" && (p.raw = a), n.name) {
|
|
2039
|
+
case "literal":
|
|
2040
|
+
return { ...p, name: "other", value: n.value };
|
|
2041
|
+
case "string":
|
|
2042
|
+
case "number":
|
|
2043
|
+
case "symbol":
|
|
2044
|
+
case "boolean":
|
|
2045
|
+
return { ...p, name: s };
|
|
2046
|
+
case "Array":
|
|
2047
|
+
return { ...p, name: "array", value: n.elements.map(B) };
|
|
2048
|
+
case "signature":
|
|
2049
|
+
return { ...p, ...Nr(n) };
|
|
2050
|
+
case "union":
|
|
2051
|
+
return n.elements?.every(Er) ? { ...p, name: "enum", value: n.elements?.map(Sr) } : { ...p, name: s, value: n.elements?.map(B) };
|
|
2052
|
+
case "intersection":
|
|
2053
|
+
return { ...p, name: s, value: n.elements?.map(B) };
|
|
2054
|
+
default:
|
|
2055
|
+
return { ...p, name: "other", value: s };
|
|
2056
|
+
}
|
|
2057
|
+
}, "convert");
|
|
2058
|
+
|
|
2059
|
+
// ../node_modules/es-toolkit/dist/object/mapValues.mjs
|
|
2060
|
+
function Oe(n, s) {
|
|
2061
|
+
let a = {}, p = Object.keys(n);
|
|
2062
|
+
for (let c = 0; c < p.length; c++) {
|
|
2063
|
+
let u = p[c], y = n[u];
|
|
2064
|
+
a[u] = s(y, u, n);
|
|
2065
|
+
}
|
|
2066
|
+
return a;
|
|
2067
|
+
}
|
|
2068
|
+
r(Oe, "mapValues");
|
|
2069
|
+
|
|
2070
|
+
// src/docs-tools/argTypes/convert/utils.ts
|
|
2071
|
+
var it = /^['"]|['"]$/g, Dr = /* @__PURE__ */ r((n) => n.replace(it, ""), "trimQuotes"), Or = /* @__PURE__ */ r((n) => it.test(n), "includes\
|
|
2072
|
+
Quotes"), se = /* @__PURE__ */ r((n) => {
|
|
2073
|
+
let s = Dr(n);
|
|
2074
|
+
return Or(n) || Number.isNaN(Number(s)) ? s : Number(s);
|
|
2075
|
+
}, "parseLiteral");
|
|
2076
|
+
|
|
2077
|
+
// src/docs-tools/argTypes/convert/proptypes/convert.ts
|
|
2078
|
+
var vr = /^\(.*\) => /, C = /* @__PURE__ */ r((n) => {
|
|
2079
|
+
let { name: s, raw: a, computed: p, value: c } = n, u = {};
|
|
2080
|
+
switch (typeof a < "u" && (u.raw = a), s) {
|
|
2081
|
+
case "enum": {
|
|
2082
|
+
let T = p ? c : c.map((g) => se(g.value));
|
|
2083
|
+
return { ...u, name: s, value: T };
|
|
2084
|
+
}
|
|
2085
|
+
case "string":
|
|
2086
|
+
case "number":
|
|
2087
|
+
case "symbol":
|
|
2088
|
+
return { ...u, name: s };
|
|
2089
|
+
case "func":
|
|
2090
|
+
return { ...u, name: "function" };
|
|
2091
|
+
case "bool":
|
|
2092
|
+
case "boolean":
|
|
2093
|
+
return { ...u, name: "boolean" };
|
|
2094
|
+
case "arrayOf":
|
|
2095
|
+
case "array":
|
|
2096
|
+
return { ...u, name: "array", value: c && C(c) };
|
|
2097
|
+
case "object":
|
|
2098
|
+
return { ...u, name: s };
|
|
2099
|
+
case "objectOf":
|
|
2100
|
+
return { ...u, name: s, value: C(c) };
|
|
2101
|
+
case "shape":
|
|
2102
|
+
case "exact":
|
|
2103
|
+
let y = Oe(c, (T) => C(T));
|
|
2104
|
+
return { ...u, name: "object", value: y };
|
|
2105
|
+
case "union":
|
|
2106
|
+
return { ...u, name: "union", value: c.map((T) => C(T)) };
|
|
2107
|
+
case "instanceOf":
|
|
2108
|
+
case "element":
|
|
2109
|
+
case "elementType":
|
|
2110
|
+
default: {
|
|
2111
|
+
if (s?.indexOf("|") > 0)
|
|
2112
|
+
try {
|
|
2113
|
+
let P = s.split("|").map((b) => JSON.parse(b));
|
|
2114
|
+
return { ...u, name: "enum", value: P };
|
|
2115
|
+
} catch {
|
|
2116
|
+
}
|
|
2117
|
+
let T = c ? `${s}(${c})` : s, g = vr.test(s) ? "function" : "other";
|
|
2118
|
+
return { ...u, name: g, value: T };
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
}, "convert");
|
|
2122
|
+
|
|
2123
|
+
// src/docs-tools/argTypes/convert/typescript/convert.ts
|
|
2124
|
+
var pt = require("storybook/internal/preview-errors");
|
|
2125
|
+
var kr = /* @__PURE__ */ r((n) => {
|
|
2126
|
+
switch (n.type) {
|
|
2127
|
+
case "function":
|
|
2128
|
+
return { name: "function" };
|
|
2129
|
+
case "object":
|
|
2130
|
+
let s = {};
|
|
2131
|
+
return n.signature.properties.forEach((a) => {
|
|
2132
|
+
s[a.key] = M(a.value);
|
|
2133
|
+
}), {
|
|
2134
|
+
name: "object",
|
|
2135
|
+
value: s
|
|
2136
|
+
};
|
|
2137
|
+
default:
|
|
2138
|
+
throw new pt.UnknownArgTypesError({ type: n, language: "Typescript" });
|
|
2139
|
+
}
|
|
2140
|
+
}, "convertSig"), M = /* @__PURE__ */ r((n) => {
|
|
2141
|
+
let { name: s, raw: a } = n, p = {};
|
|
2142
|
+
switch (typeof a < "u" && (p.raw = a), n.name) {
|
|
2143
|
+
case "string":
|
|
2144
|
+
case "number":
|
|
2145
|
+
case "symbol":
|
|
2146
|
+
case "boolean":
|
|
2147
|
+
return { ...p, name: s };
|
|
2148
|
+
case "Array":
|
|
2149
|
+
return { ...p, name: "array", value: n.elements.map(M) };
|
|
2150
|
+
case "signature":
|
|
2151
|
+
return { ...p, ...kr(n) };
|
|
2152
|
+
case "union":
|
|
2153
|
+
let c;
|
|
2154
|
+
return n.elements?.every((u) => u.name === "literal") ? c = {
|
|
2155
|
+
...p,
|
|
2156
|
+
name: "enum",
|
|
2157
|
+
// @ts-expect-error fix types
|
|
2158
|
+
value: n.elements?.map((u) => se(u.value))
|
|
2159
|
+
} : c = { ...p, name: s, value: n.elements?.map(M) }, c;
|
|
2160
|
+
case "intersection":
|
|
2161
|
+
return { ...p, name: s, value: n.elements?.map(M) };
|
|
2162
|
+
default:
|
|
2163
|
+
return { ...p, name: "other", value: s };
|
|
2164
|
+
}
|
|
2165
|
+
}, "convert");
|
|
2166
|
+
|
|
2167
|
+
// src/docs-tools/argTypes/convert/index.ts
|
|
2168
|
+
var X = /* @__PURE__ */ r((n) => {
|
|
2169
|
+
let { type: s, tsType: a, flowType: p } = n;
|
|
2170
|
+
try {
|
|
2171
|
+
if (s != null)
|
|
2172
|
+
return C(s);
|
|
2173
|
+
if (a != null)
|
|
2174
|
+
return M(a);
|
|
2175
|
+
if (p != null)
|
|
2176
|
+
return B(p);
|
|
2177
|
+
} catch (c) {
|
|
2178
|
+
console.error(c);
|
|
2179
|
+
}
|
|
2180
|
+
return null;
|
|
2181
|
+
}, "convert");
|
|
2182
|
+
|
|
2183
|
+
// src/docs-tools/argTypes/docgen/types.ts
|
|
2184
|
+
var ct = /* @__PURE__ */ ((c) => (c.JAVASCRIPT = "JavaScript", c.FLOW = "Flow", c.TYPESCRIPT = "TypeScript", c.UNKNOWN = "Unknown", c))(ct ||
|
|
2185
|
+
{});
|
|
2186
|
+
|
|
2187
|
+
// src/docs-tools/argTypes/docgen/utils/defaultValue.ts
|
|
2188
|
+
var Ar = ["null", "undefined"];
|
|
2189
|
+
function L(n) {
|
|
2190
|
+
return Ar.some((s) => s === n);
|
|
2191
|
+
}
|
|
2192
|
+
r(L, "isDefaultValueBlacklisted");
|
|
2193
|
+
|
|
2194
|
+
// src/docs-tools/argTypes/docgen/utils/string.ts
|
|
2195
|
+
var ve = /* @__PURE__ */ r((n) => {
|
|
2196
|
+
if (!n)
|
|
2197
|
+
return "";
|
|
2198
|
+
if (typeof n == "string")
|
|
2199
|
+
return n;
|
|
2200
|
+
throw new Error(`Description: expected string, got: ${JSON.stringify(n)}`);
|
|
2201
|
+
}, "str");
|
|
2202
|
+
|
|
2203
|
+
// src/docs-tools/argTypes/docgen/utils/docgenInfo.ts
|
|
2204
|
+
function ke(n) {
|
|
2205
|
+
return !!n.__docgenInfo;
|
|
2206
|
+
}
|
|
2207
|
+
r(ke, "hasDocgen");
|
|
2208
|
+
function Ae(n) {
|
|
2209
|
+
return n != null && Object.keys(n).length > 0;
|
|
2210
|
+
}
|
|
2211
|
+
r(Ae, "isValidDocgenSection");
|
|
2212
|
+
function Re(n, s) {
|
|
2213
|
+
return ke(n) ? n.__docgenInfo[s] : null;
|
|
2214
|
+
}
|
|
2215
|
+
r(Re, "getDocgenSection");
|
|
2216
|
+
function Ie(n) {
|
|
2217
|
+
return ke(n) ? ve(n.__docgenInfo.description) : "";
|
|
2218
|
+
}
|
|
2219
|
+
r(Ie, "getDocgenDescription");
|
|
2220
|
+
|
|
2221
|
+
// ../node_modules/comment-parser/es6/primitives.js
|
|
2222
|
+
var v;
|
|
2223
|
+
(function(n) {
|
|
2224
|
+
n.start = "/**", n.nostart = "/***", n.delim = "*", n.end = "*/";
|
|
2225
|
+
})(v = v || (v = {}));
|
|
2226
|
+
|
|
2227
|
+
// ../node_modules/comment-parser/es6/util.js
|
|
2228
|
+
function Fe(n) {
|
|
2229
|
+
return /^\s+$/.test(n);
|
|
2230
|
+
}
|
|
2231
|
+
r(Fe, "isSpace");
|
|
2232
|
+
function lt(n) {
|
|
2233
|
+
let s = n.match(/\r+$/);
|
|
2234
|
+
return s == null ? ["", n] : [n.slice(-s[0].length), n.slice(0, -s[0].length)];
|
|
2235
|
+
}
|
|
2236
|
+
r(lt, "splitCR");
|
|
2237
|
+
function A(n) {
|
|
2238
|
+
let s = n.match(/^\s+/);
|
|
2239
|
+
return s == null ? ["", n] : [n.slice(0, s[0].length), n.slice(s[0].length)];
|
|
2240
|
+
}
|
|
2241
|
+
r(A, "splitSpace");
|
|
2242
|
+
function ut(n) {
|
|
2243
|
+
return n.split(/\n/);
|
|
2244
|
+
}
|
|
2245
|
+
r(ut, "splitLines");
|
|
2246
|
+
function mt(n = {}) {
|
|
2247
|
+
return Object.assign({ tag: "", name: "", type: "", optional: !1, description: "", problems: [], source: [] }, n);
|
|
2248
|
+
}
|
|
2249
|
+
r(mt, "seedSpec");
|
|
2250
|
+
function je(n = {}) {
|
|
2251
|
+
return Object.assign({ start: "", delimiter: "", postDelimiter: "", tag: "", postTag: "", name: "", postName: "", type: "", postType: "", description: "",
|
|
2252
|
+
end: "", lineEnd: "" }, n);
|
|
2253
|
+
}
|
|
2254
|
+
r(je, "seedTokens");
|
|
2255
|
+
|
|
2256
|
+
// ../node_modules/comment-parser/es6/parser/block-parser.js
|
|
2257
|
+
var Rr = /^@\S+/;
|
|
2258
|
+
function _e({ fence: n = "```" } = {}) {
|
|
2259
|
+
let s = Ir(n), a = /* @__PURE__ */ r((p, c) => s(p) ? !c : c, "toggleFence");
|
|
2260
|
+
return /* @__PURE__ */ r(function(c) {
|
|
2261
|
+
let u = [[]], y = !1;
|
|
2262
|
+
for (let T of c)
|
|
2263
|
+
Rr.test(T.tokens.description) && !y ? u.push([T]) : u[u.length - 1].push(T), y = a(T.tokens.description, y);
|
|
2264
|
+
return u;
|
|
2265
|
+
}, "parseBlock");
|
|
2266
|
+
}
|
|
2267
|
+
r(_e, "getParser");
|
|
2268
|
+
function Ir(n) {
|
|
2269
|
+
return typeof n == "string" ? (s) => s.split(n).length % 2 === 0 : n;
|
|
2270
|
+
}
|
|
2271
|
+
r(Ir, "getFencer");
|
|
2272
|
+
|
|
2273
|
+
// ../node_modules/comment-parser/es6/parser/source-parser.js
|
|
2274
|
+
function Le({ startLine: n = 0, markers: s = v } = {}) {
|
|
2275
|
+
let a = null, p = n;
|
|
2276
|
+
return /* @__PURE__ */ r(function(u) {
|
|
2277
|
+
let y = u, T = je();
|
|
2278
|
+
if ([T.lineEnd, y] = lt(y), [T.start, y] = A(y), a === null && y.startsWith(s.start) && !y.startsWith(s.nostart) && (a = [], T.delimiter =
|
|
2279
|
+
y.slice(0, s.start.length), y = y.slice(s.start.length), [T.postDelimiter, y] = A(y)), a === null)
|
|
2280
|
+
return p++, null;
|
|
2281
|
+
let g = y.trimRight().endsWith(s.end);
|
|
2282
|
+
if (T.delimiter === "" && y.startsWith(s.delim) && !y.startsWith(s.end) && (T.delimiter = s.delim, y = y.slice(s.delim.length), [T.postDelimiter,
|
|
2283
|
+
y] = A(y)), g) {
|
|
2284
|
+
let P = y.trimRight();
|
|
2285
|
+
T.end = y.slice(P.length - s.end.length), y = P.slice(0, -s.end.length);
|
|
2286
|
+
}
|
|
2287
|
+
if (T.description = y, a.push({ number: p, source: u, tokens: T }), p++, g) {
|
|
2288
|
+
let P = a.slice();
|
|
2289
|
+
return a = null, P;
|
|
2290
|
+
}
|
|
2291
|
+
return null;
|
|
2292
|
+
}, "parseSource");
|
|
2293
|
+
}
|
|
2294
|
+
r(Le, "getParser");
|
|
2295
|
+
|
|
2296
|
+
// ../node_modules/comment-parser/es6/parser/spec-parser.js
|
|
2297
|
+
function Ve({ tokenizers: n }) {
|
|
2298
|
+
return /* @__PURE__ */ r(function(a) {
|
|
2299
|
+
var p;
|
|
2300
|
+
let c = mt({ source: a });
|
|
2301
|
+
for (let u of n)
|
|
2302
|
+
if (c = u(c), !((p = c.problems[c.problems.length - 1]) === null || p === void 0) && p.critical)
|
|
2303
|
+
break;
|
|
2304
|
+
return c;
|
|
2305
|
+
}, "parseSpec");
|
|
2306
|
+
}
|
|
2307
|
+
r(Ve, "getParser");
|
|
2308
|
+
|
|
2309
|
+
// ../node_modules/comment-parser/es6/parser/tokenizers/tag.js
|
|
2310
|
+
function ae() {
|
|
2311
|
+
return (n) => {
|
|
2312
|
+
let { tokens: s } = n.source[0], a = s.description.match(/\s*(@(\S+))(\s*)/);
|
|
2313
|
+
return a === null ? (n.problems.push({
|
|
2314
|
+
code: "spec:tag:prefix",
|
|
2315
|
+
message: 'tag should start with "@" symbol',
|
|
2316
|
+
line: n.source[0].number,
|
|
2317
|
+
critical: !0
|
|
2318
|
+
}), n) : (s.tag = a[1], s.postTag = a[3], s.description = s.description.slice(a[0].length), n.tag = a[2], n);
|
|
2319
|
+
};
|
|
2320
|
+
}
|
|
2321
|
+
r(ae, "tagTokenizer");
|
|
2322
|
+
|
|
2323
|
+
// ../node_modules/comment-parser/es6/parser/tokenizers/type.js
|
|
2324
|
+
function ie(n = "compact") {
|
|
2325
|
+
let s = jr(n);
|
|
2326
|
+
return (a) => {
|
|
2327
|
+
let p = 0, c = [];
|
|
2328
|
+
for (let [T, { tokens: g }] of a.source.entries()) {
|
|
2329
|
+
let P = "";
|
|
2330
|
+
if (T === 0 && g.description[0] !== "{")
|
|
2331
|
+
return a;
|
|
2332
|
+
for (let b of g.description)
|
|
2333
|
+
if (b === "{" && p++, b === "}" && p--, P += b, p === 0)
|
|
2334
|
+
break;
|
|
2335
|
+
if (c.push([g, P]), p === 0)
|
|
2336
|
+
break;
|
|
2337
|
+
}
|
|
2338
|
+
if (p !== 0)
|
|
2339
|
+
return a.problems.push({
|
|
2340
|
+
code: "spec:type:unpaired-curlies",
|
|
2341
|
+
message: "unpaired curlies",
|
|
2342
|
+
line: a.source[0].number,
|
|
2343
|
+
critical: !0
|
|
2344
|
+
}), a;
|
|
2345
|
+
let u = [], y = c[0][0].postDelimiter.length;
|
|
2346
|
+
for (let [T, [g, P]] of c.entries())
|
|
2347
|
+
g.type = P, T > 0 && (g.type = g.postDelimiter.slice(y) + P, g.postDelimiter = g.postDelimiter.slice(0, y)), [g.postType, g.description] =
|
|
2348
|
+
A(g.description.slice(P.length)), u.push(g.type);
|
|
2349
|
+
return u[0] = u[0].slice(1), u[u.length - 1] = u[u.length - 1].slice(0, -1), a.type = s(u), a;
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
r(ie, "typeTokenizer");
|
|
2353
|
+
var Fr = /* @__PURE__ */ r((n) => n.trim(), "trim");
|
|
2354
|
+
function jr(n) {
|
|
2355
|
+
return n === "compact" ? (s) => s.map(Fr).join("") : n === "preserve" ? (s) => s.join(`
|
|
2356
|
+
`) : n;
|
|
2357
|
+
}
|
|
2358
|
+
r(jr, "getJoiner");
|
|
2359
|
+
|
|
2360
|
+
// ../node_modules/comment-parser/es6/parser/tokenizers/name.js
|
|
2361
|
+
var _r = /* @__PURE__ */ r((n) => n && n.startsWith('"') && n.endsWith('"'), "isQuoted");
|
|
2362
|
+
function pe() {
|
|
2363
|
+
let n = /* @__PURE__ */ r((s, { tokens: a }, p) => a.type === "" ? s : p, "typeEnd");
|
|
2364
|
+
return (s) => {
|
|
2365
|
+
let { tokens: a } = s.source[s.source.reduce(n, 0)], p = a.description.trimLeft(), c = p.split('"');
|
|
2366
|
+
if (c.length > 1 && c[0] === "" && c.length % 2 === 1)
|
|
2367
|
+
return s.name = c[1], a.name = `"${c[1]}"`, [a.postName, a.description] = A(p.slice(a.name.length)), s;
|
|
2368
|
+
let u = 0, y = "", T = !1, g;
|
|
2369
|
+
for (let b of p) {
|
|
2370
|
+
if (u === 0 && Fe(b))
|
|
2371
|
+
break;
|
|
2372
|
+
b === "[" && u++, b === "]" && u--, y += b;
|
|
2373
|
+
}
|
|
2374
|
+
if (u !== 0)
|
|
2375
|
+
return s.problems.push({
|
|
2376
|
+
code: "spec:name:unpaired-brackets",
|
|
2377
|
+
message: "unpaired brackets",
|
|
2378
|
+
line: s.source[0].number,
|
|
2379
|
+
critical: !0
|
|
2380
|
+
}), s;
|
|
2381
|
+
let P = y;
|
|
2382
|
+
if (y[0] === "[" && y[y.length - 1] === "]") {
|
|
2383
|
+
T = !0, y = y.slice(1, -1);
|
|
2384
|
+
let b = y.split("=");
|
|
2385
|
+
if (y = b[0].trim(), b[1] !== void 0 && (g = b.slice(1).join("=").trim()), y === "")
|
|
2386
|
+
return s.problems.push({
|
|
2387
|
+
code: "spec:name:empty-name",
|
|
2388
|
+
message: "empty name",
|
|
2389
|
+
line: s.source[0].number,
|
|
2390
|
+
critical: !0
|
|
2391
|
+
}), s;
|
|
2392
|
+
if (g === "")
|
|
2393
|
+
return s.problems.push({
|
|
2394
|
+
code: "spec:name:empty-default",
|
|
2395
|
+
message: "empty default value",
|
|
2396
|
+
line: s.source[0].number,
|
|
2397
|
+
critical: !0
|
|
2398
|
+
}), s;
|
|
2399
|
+
if (!_r(g) && /=(?!>)/.test(g))
|
|
2400
|
+
return s.problems.push({
|
|
2401
|
+
code: "spec:name:invalid-default",
|
|
2402
|
+
message: "invalid default value syntax",
|
|
2403
|
+
line: s.source[0].number,
|
|
2404
|
+
critical: !0
|
|
2405
|
+
}), s;
|
|
2406
|
+
}
|
|
2407
|
+
return s.optional = T, s.name = y, a.name = P, g !== void 0 && (s.default = g), [a.postName, a.description] = A(p.slice(a.name.length)),
|
|
2408
|
+
s;
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
r(pe, "nameTokenizer");
|
|
2412
|
+
|
|
2413
|
+
// ../node_modules/comment-parser/es6/parser/tokenizers/description.js
|
|
2414
|
+
function ce(n = "compact", s = v) {
|
|
2415
|
+
let a = Ue(n);
|
|
2416
|
+
return (p) => (p.description = a(p.source, s), p);
|
|
2417
|
+
}
|
|
2418
|
+
r(ce, "descriptionTokenizer");
|
|
2419
|
+
function Ue(n) {
|
|
2420
|
+
return n === "compact" ? Lr : n === "preserve" ? Br : n;
|
|
2421
|
+
}
|
|
2422
|
+
r(Ue, "getJoiner");
|
|
2423
|
+
function Lr(n, s = v) {
|
|
2424
|
+
return n.map(({ tokens: { description: a } }) => a.trim()).filter((a) => a !== "").join(" ");
|
|
2425
|
+
}
|
|
2426
|
+
r(Lr, "compactJoiner");
|
|
2427
|
+
var Vr = /* @__PURE__ */ r((n, { tokens: s }, a) => s.type === "" ? n : a, "lineNo"), Ur = /* @__PURE__ */ r(({ tokens: n }) => (n.delimiter ===
|
|
2428
|
+
"" ? n.start : n.postDelimiter.slice(1)) + n.description, "getDescription");
|
|
2429
|
+
function Br(n, s = v) {
|
|
2430
|
+
if (n.length === 0)
|
|
2431
|
+
return "";
|
|
2432
|
+
n[0].tokens.description === "" && n[0].tokens.delimiter === s.start && (n = n.slice(1));
|
|
2433
|
+
let a = n[n.length - 1];
|
|
2434
|
+
return a !== void 0 && a.tokens.description === "" && a.tokens.end.endsWith(s.end) && (n = n.slice(0, -1)), n = n.slice(n.reduce(Vr, 0)), n.
|
|
2435
|
+
map(Ur).join(`
|
|
2436
|
+
`);
|
|
2437
|
+
}
|
|
2438
|
+
r(Br, "preserveJoiner");
|
|
2439
|
+
|
|
2440
|
+
// ../node_modules/comment-parser/es6/parser/index.js
|
|
2441
|
+
function Be({ startLine: n = 0, fence: s = "```", spacing: a = "compact", markers: p = v, tokenizers: c = [
|
|
2442
|
+
ae(),
|
|
2443
|
+
ie(a),
|
|
2444
|
+
pe(),
|
|
2445
|
+
ce(a)
|
|
2446
|
+
] } = {}) {
|
|
2447
|
+
if (n < 0 || n % 1 > 0)
|
|
2448
|
+
throw new Error("Invalid startLine");
|
|
2449
|
+
let u = Le({ startLine: n, markers: p }), y = _e({ fence: s }), T = Ve({ tokenizers: c }), g = Ue(a);
|
|
2450
|
+
return function(P) {
|
|
2451
|
+
let b = [];
|
|
2452
|
+
for (let ye of ut(P)) {
|
|
2453
|
+
let $ = u(ye);
|
|
2454
|
+
if ($ === null)
|
|
2455
|
+
continue;
|
|
2456
|
+
let E = y($), H = E.slice(1).map(T);
|
|
2457
|
+
b.push({
|
|
2458
|
+
description: g(E[0], p),
|
|
2459
|
+
tags: H,
|
|
2460
|
+
source: $,
|
|
2461
|
+
problems: H.reduce((fe, de) => fe.concat(de.problems), [])
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
return b;
|
|
2465
|
+
};
|
|
2466
|
+
}
|
|
2467
|
+
r(Be, "getParser");
|
|
2468
|
+
|
|
2469
|
+
// ../node_modules/comment-parser/es6/stringifier/index.js
|
|
2470
|
+
function Cr(n) {
|
|
2471
|
+
return n.start + n.delimiter + n.postDelimiter + n.tag + n.postTag + n.type + n.postType + n.name + n.postName + n.description + n.end + n.
|
|
2472
|
+
lineEnd;
|
|
2473
|
+
}
|
|
2474
|
+
r(Cr, "join");
|
|
2475
|
+
function Ce() {
|
|
2476
|
+
return (n) => n.source.map(({ tokens: s }) => Cr(s)).join(`
|
|
2477
|
+
`);
|
|
2478
|
+
}
|
|
2479
|
+
r(Ce, "getStringifier");
|
|
2480
|
+
|
|
2481
|
+
// ../node_modules/comment-parser/es6/stringifier/inspect.js
|
|
2482
|
+
var Mr = {
|
|
2483
|
+
line: 0,
|
|
2484
|
+
start: 0,
|
|
2485
|
+
delimiter: 0,
|
|
2486
|
+
postDelimiter: 0,
|
|
2487
|
+
tag: 0,
|
|
2488
|
+
postTag: 0,
|
|
2489
|
+
name: 0,
|
|
2490
|
+
postName: 0,
|
|
2491
|
+
type: 0,
|
|
2492
|
+
postType: 0,
|
|
2493
|
+
description: 0,
|
|
2494
|
+
end: 0,
|
|
2495
|
+
lineEnd: 0
|
|
2496
|
+
};
|
|
2497
|
+
var zo = Object.keys(Mr);
|
|
2498
|
+
|
|
2499
|
+
// ../node_modules/comment-parser/es6/index.js
|
|
2500
|
+
function yt(n, s = {}) {
|
|
2501
|
+
return Be(s)(n);
|
|
2502
|
+
}
|
|
2503
|
+
r(yt, "parse");
|
|
2504
|
+
var Ts = Ce();
|
|
2505
|
+
|
|
2506
|
+
// src/docs-tools/argTypes/jsdocParser.ts
|
|
2507
|
+
var K = Pr(dt(), 1);
|
|
2508
|
+
function Kr(n) {
|
|
2509
|
+
return n != null && n.includes("@");
|
|
2510
|
+
}
|
|
2511
|
+
r(Kr, "containsJsDoc");
|
|
2512
|
+
function $r(n) {
|
|
2513
|
+
let p = `/**
|
|
2514
|
+
` + (n ?? "").split(`
|
|
2515
|
+
`).map((u) => ` * ${u}`).join(`
|
|
2516
|
+
`) + `
|
|
2517
|
+
*/`, c = yt(p, {
|
|
2518
|
+
spacing: "preserve"
|
|
2519
|
+
});
|
|
2520
|
+
if (!c || c.length === 0)
|
|
2521
|
+
throw new Error("Cannot parse JSDoc tags.");
|
|
2522
|
+
return c[0];
|
|
2523
|
+
}
|
|
2524
|
+
r($r, "parse");
|
|
2525
|
+
var qr = {
|
|
2526
|
+
tags: ["param", "arg", "argument", "returns", "ignore", "deprecated"]
|
|
2527
|
+
}, Ke = /* @__PURE__ */ r((n, s = qr) => {
|
|
2528
|
+
if (!Kr(n))
|
|
2529
|
+
return {
|
|
2530
|
+
includesJsDoc: !1,
|
|
2531
|
+
ignore: !1
|
|
2532
|
+
};
|
|
2533
|
+
let a = $r(n), p = Yr(a, s.tags);
|
|
2534
|
+
return p.ignore ? {
|
|
2535
|
+
includesJsDoc: !0,
|
|
2536
|
+
ignore: !0
|
|
2537
|
+
} : {
|
|
2538
|
+
includesJsDoc: !0,
|
|
2539
|
+
ignore: !1,
|
|
2540
|
+
// Always use the parsed description to ensure JSDoc is removed from the description.
|
|
2541
|
+
description: a.description.trim(),
|
|
2542
|
+
extractedTags: p
|
|
2543
|
+
};
|
|
2544
|
+
}, "parseJsDoc");
|
|
2545
|
+
function Yr(n, s) {
|
|
2546
|
+
let a = {
|
|
2547
|
+
params: null,
|
|
2548
|
+
deprecated: null,
|
|
2549
|
+
returns: null,
|
|
2550
|
+
ignore: !1
|
|
2551
|
+
};
|
|
2552
|
+
for (let p of n.tags)
|
|
2553
|
+
if (!(s !== void 0 && !s.includes(p.tag)))
|
|
2554
|
+
if (p.tag === "ignore") {
|
|
2555
|
+
a.ignore = !0;
|
|
2556
|
+
break;
|
|
2557
|
+
} else
|
|
2558
|
+
switch (p.tag) {
|
|
2559
|
+
// arg & argument are aliases for param.
|
|
2560
|
+
case "param":
|
|
2561
|
+
case "arg":
|
|
2562
|
+
case "argument": {
|
|
2563
|
+
let c = Gr(p);
|
|
2564
|
+
c != null && (a.params == null && (a.params = []), a.params.push(c));
|
|
2565
|
+
break;
|
|
2566
|
+
}
|
|
2567
|
+
case "deprecated": {
|
|
2568
|
+
let c = zr(p);
|
|
2569
|
+
c != null && (a.deprecated = c);
|
|
2570
|
+
break;
|
|
2571
|
+
}
|
|
2572
|
+
case "returns": {
|
|
2573
|
+
let c = Xr(p);
|
|
2574
|
+
c != null && (a.returns = c);
|
|
2575
|
+
break;
|
|
2576
|
+
}
|
|
2577
|
+
default:
|
|
2578
|
+
break;
|
|
2579
|
+
}
|
|
2580
|
+
return a;
|
|
2581
|
+
}
|
|
2582
|
+
r(Yr, "extractJsDocTags");
|
|
2583
|
+
function Wr(n) {
|
|
2584
|
+
return n.replace(/[\.-]$/, "");
|
|
2585
|
+
}
|
|
2586
|
+
r(Wr, "normaliseParamName");
|
|
2587
|
+
function Gr(n) {
|
|
2588
|
+
if (!n.name || n.name === "-")
|
|
2589
|
+
return null;
|
|
2590
|
+
let s = ht(n.type);
|
|
2591
|
+
return {
|
|
2592
|
+
name: n.name,
|
|
2593
|
+
type: s,
|
|
2594
|
+
description: gt(n.description),
|
|
2595
|
+
getPrettyName: /* @__PURE__ */ r(() => Wr(n.name), "getPrettyName"),
|
|
2596
|
+
getTypeName: /* @__PURE__ */ r(() => s ? xt(s) : null, "getTypeName")
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
r(Gr, "extractParam");
|
|
2600
|
+
function zr(n) {
|
|
2601
|
+
return n.name ? Tt(n.name, n.description) : null;
|
|
2602
|
+
}
|
|
2603
|
+
r(zr, "extractDeprecated");
|
|
2604
|
+
function Tt(n, s) {
|
|
2605
|
+
let a = n === "" ? s : `${n} ${s}`;
|
|
2606
|
+
return gt(a);
|
|
2607
|
+
}
|
|
2608
|
+
r(Tt, "joinNameAndDescription");
|
|
2609
|
+
function gt(n) {
|
|
2610
|
+
let s = n.replace(/^- /g, "").trim();
|
|
2611
|
+
return s === "" ? null : s;
|
|
2612
|
+
}
|
|
2613
|
+
r(gt, "normaliseDescription");
|
|
2614
|
+
function Xr(n) {
|
|
2615
|
+
let s = ht(n.type);
|
|
2616
|
+
return s ? {
|
|
2617
|
+
type: s,
|
|
2618
|
+
description: Tt(n.name, n.description),
|
|
2619
|
+
getTypeName: /* @__PURE__ */ r(() => xt(s), "getTypeName")
|
|
2620
|
+
} : null;
|
|
2621
|
+
}
|
|
2622
|
+
r(Xr, "extractReturns");
|
|
2623
|
+
var j = (0, K.stringifyRules)(), Hr = j.JsdocTypeObject;
|
|
2624
|
+
j.JsdocTypeAny = () => "any";
|
|
2625
|
+
j.JsdocTypeObject = (n, s) => `(${Hr(n, s)})`;
|
|
2626
|
+
j.JsdocTypeOptional = (n, s) => s(n.element);
|
|
2627
|
+
j.JsdocTypeNullable = (n, s) => s(n.element);
|
|
2628
|
+
j.JsdocTypeNotNullable = (n, s) => s(n.element);
|
|
2629
|
+
j.JsdocTypeUnion = (n, s) => n.elements.map(s).join("|");
|
|
2630
|
+
function ht(n) {
|
|
2631
|
+
try {
|
|
2632
|
+
return (0, K.parse)(n, "typescript");
|
|
2633
|
+
} catch {
|
|
2634
|
+
return null;
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
r(ht, "extractType");
|
|
2638
|
+
function xt(n) {
|
|
2639
|
+
return (0, K.transform)(j, n);
|
|
2640
|
+
}
|
|
2641
|
+
r(xt, "extractTypeName");
|
|
2642
|
+
|
|
2643
|
+
// src/docs-tools/argTypes/utils.ts
|
|
2644
|
+
var Qr = 90, Zr = 50;
|
|
2645
|
+
function ue(n) {
|
|
2646
|
+
return n.length > 90;
|
|
2647
|
+
}
|
|
2648
|
+
r(ue, "isTooLongForTypeSummary");
|
|
2649
|
+
function $e(n) {
|
|
2650
|
+
return n.length > 50;
|
|
2651
|
+
}
|
|
2652
|
+
r($e, "isTooLongForDefaultValueSummary");
|
|
2653
|
+
function J(n, s) {
|
|
2654
|
+
return n === s ? { summary: n } : { summary: n, detail: s };
|
|
2655
|
+
}
|
|
2656
|
+
r(J, "createSummaryValue");
|
|
2657
|
+
var en = /* @__PURE__ */ r((n) => n.replace(/\\r\\n/g, "\\n"), "normalizeNewlines");
|
|
2658
|
+
|
|
2659
|
+
// src/docs-tools/argTypes/docgen/flow/createDefaultValue.ts
|
|
2660
|
+
function Jt(n, s) {
|
|
2661
|
+
if (n != null) {
|
|
2662
|
+
let { value: a } = n;
|
|
2663
|
+
if (!L(a))
|
|
2664
|
+
return $e(a) ? J(s?.name, a) : J(a);
|
|
2665
|
+
}
|
|
2666
|
+
return null;
|
|
2667
|
+
}
|
|
2668
|
+
r(Jt, "createDefaultValue");
|
|
2669
|
+
|
|
2670
|
+
// src/docs-tools/argTypes/docgen/flow/createType.ts
|
|
2671
|
+
function wt({ name: n, value: s, elements: a, raw: p }) {
|
|
2672
|
+
return s ?? (a != null ? a.map(wt).join(" | ") : p ?? n);
|
|
2673
|
+
}
|
|
2674
|
+
r(wt, "generateUnionElement");
|
|
2675
|
+
function tn({ name: n, raw: s, elements: a }) {
|
|
2676
|
+
return a != null ? J(a.map(wt).join(" | ")) : s != null ? J(s.replace(/^\|\s*/, "")) : J(n);
|
|
2677
|
+
}
|
|
2678
|
+
r(tn, "generateUnion");
|
|
2679
|
+
function rn({ type: n, raw: s }) {
|
|
2680
|
+
return s != null ? J(s) : J(n);
|
|
2681
|
+
}
|
|
2682
|
+
r(rn, "generateFuncSignature");
|
|
2683
|
+
function nn({ type: n, raw: s }) {
|
|
2684
|
+
return s != null ? ue(s) ? J(n, s) : J(s) : J(n);
|
|
2685
|
+
}
|
|
2686
|
+
r(nn, "generateObjectSignature");
|
|
2687
|
+
function on(n) {
|
|
2688
|
+
let { type: s } = n;
|
|
2689
|
+
return s === "object" ? nn(n) : rn(n);
|
|
2690
|
+
}
|
|
2691
|
+
r(on, "generateSignature");
|
|
2692
|
+
function sn({ name: n, raw: s }) {
|
|
2693
|
+
return s != null ? ue(s) ? J(n, s) : J(s) : J(n);
|
|
2694
|
+
}
|
|
2695
|
+
r(sn, "generateDefault");
|
|
2696
|
+
function Pt(n) {
|
|
2697
|
+
if (n == null)
|
|
2698
|
+
return null;
|
|
2699
|
+
switch (n.name) {
|
|
2700
|
+
case "union":
|
|
2701
|
+
return tn(n);
|
|
2702
|
+
case "signature":
|
|
2703
|
+
return on(n);
|
|
2704
|
+
default:
|
|
2705
|
+
return sn(n);
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
r(Pt, "createType");
|
|
2709
|
+
|
|
2710
|
+
// src/docs-tools/argTypes/docgen/flow/createPropDef.ts
|
|
2711
|
+
var bt = /* @__PURE__ */ r((n, s) => {
|
|
2712
|
+
let { flowType: a, description: p, required: c, defaultValue: u } = s;
|
|
2713
|
+
return {
|
|
2714
|
+
name: n,
|
|
2715
|
+
type: Pt(a),
|
|
2716
|
+
required: c,
|
|
2717
|
+
description: p,
|
|
2718
|
+
defaultValue: Jt(u ?? null, a ?? null)
|
|
2719
|
+
};
|
|
2720
|
+
}, "createFlowPropDef");
|
|
2721
|
+
|
|
2722
|
+
// src/docs-tools/argTypes/docgen/typeScript/createDefaultValue.ts
|
|
2723
|
+
function Et({ defaultValue: n }) {
|
|
2724
|
+
if (n != null) {
|
|
2725
|
+
let { value: s } = n;
|
|
2726
|
+
if (!L(s))
|
|
2727
|
+
return J(s);
|
|
2728
|
+
}
|
|
2729
|
+
return null;
|
|
2730
|
+
}
|
|
2731
|
+
r(Et, "createDefaultValue");
|
|
2732
|
+
|
|
2733
|
+
// src/docs-tools/argTypes/docgen/typeScript/createType.ts
|
|
2734
|
+
function St({ tsType: n, required: s }) {
|
|
2735
|
+
if (n == null)
|
|
2736
|
+
return null;
|
|
2737
|
+
let a = n.name;
|
|
2738
|
+
return s || (a = a.replace(" | undefined", "")), J(
|
|
2739
|
+
["Array", "Record", "signature"].includes(n.name) ? n.raw : a
|
|
2740
|
+
);
|
|
2741
|
+
}
|
|
2742
|
+
r(St, "createType");
|
|
2743
|
+
|
|
2744
|
+
// src/docs-tools/argTypes/docgen/typeScript/createPropDef.ts
|
|
2745
|
+
var Nt = /* @__PURE__ */ r((n, s) => {
|
|
2746
|
+
let { description: a, required: p } = s;
|
|
2747
|
+
return {
|
|
2748
|
+
name: n,
|
|
2749
|
+
type: St(s),
|
|
2750
|
+
required: p,
|
|
2751
|
+
description: a,
|
|
2752
|
+
defaultValue: Et(s)
|
|
2753
|
+
};
|
|
2754
|
+
}, "createTsPropDef");
|
|
2755
|
+
|
|
2756
|
+
// src/docs-tools/argTypes/docgen/createPropDef.ts
|
|
2757
|
+
function an(n) {
|
|
2758
|
+
return n != null ? J(n.name) : null;
|
|
2759
|
+
}
|
|
2760
|
+
r(an, "createType");
|
|
2761
|
+
function pn(n) {
|
|
2762
|
+
let { computed: s, func: a } = n;
|
|
2763
|
+
return typeof s > "u" && typeof a > "u";
|
|
2764
|
+
}
|
|
2765
|
+
r(pn, "isReactDocgenTypescript");
|
|
2766
|
+
function cn(n) {
|
|
2767
|
+
return n ? n.name === "string" ? !0 : n.name === "enum" ? Array.isArray(n.value) && n.value.every(
|
|
2768
|
+
({ value: s }) => typeof s == "string" && s[0] === '"' && s[s.length - 1] === '"'
|
|
2769
|
+
) : !1 : !1;
|
|
2770
|
+
}
|
|
2771
|
+
r(cn, "isStringValued");
|
|
2772
|
+
function ln(n, s) {
|
|
2773
|
+
if (n != null) {
|
|
2774
|
+
let { value: a } = n;
|
|
2775
|
+
if (!L(a))
|
|
2776
|
+
return pn(n) && cn(s) ? J(JSON.stringify(a)) : J(a);
|
|
2777
|
+
}
|
|
2778
|
+
return null;
|
|
2779
|
+
}
|
|
2780
|
+
r(ln, "createDefaultValue");
|
|
2781
|
+
function Dt(n, s, a) {
|
|
2782
|
+
let { description: p, required: c, defaultValue: u } = a;
|
|
2783
|
+
return {
|
|
2784
|
+
name: n,
|
|
2785
|
+
type: an(s),
|
|
2786
|
+
required: c,
|
|
2787
|
+
description: p,
|
|
2788
|
+
defaultValue: ln(u, s)
|
|
2789
|
+
};
|
|
2790
|
+
}
|
|
2791
|
+
r(Dt, "createBasicPropDef");
|
|
2792
|
+
function me(n, s) {
|
|
2793
|
+
if (s?.includesJsDoc) {
|
|
2794
|
+
let { description: a, extractedTags: p } = s;
|
|
2795
|
+
a != null && (n.description = s.description);
|
|
2796
|
+
let c = {
|
|
2797
|
+
...p,
|
|
2798
|
+
params: p?.params?.map(
|
|
2799
|
+
(u) => ({
|
|
2800
|
+
name: u.getPrettyName(),
|
|
2801
|
+
description: u.description
|
|
2802
|
+
})
|
|
2803
|
+
)
|
|
2804
|
+
};
|
|
2805
|
+
Object.values(c).filter(Boolean).length > 0 && (n.jsDocTags = c);
|
|
2806
|
+
}
|
|
2807
|
+
return n;
|
|
2808
|
+
}
|
|
2809
|
+
r(me, "applyJsDocResult");
|
|
2810
|
+
var un = /* @__PURE__ */ r((n, s, a) => {
|
|
2811
|
+
let p = Dt(n, s.type, s);
|
|
2812
|
+
return p.sbType = X(s), me(p, a);
|
|
2813
|
+
}, "javaScriptFactory"), mn = /* @__PURE__ */ r((n, s, a) => {
|
|
2814
|
+
let p = Nt(n, s);
|
|
2815
|
+
return p.sbType = X(s), me(p, a);
|
|
2816
|
+
}, "tsFactory"), yn = /* @__PURE__ */ r((n, s, a) => {
|
|
2817
|
+
let p = bt(n, s);
|
|
2818
|
+
return p.sbType = X(s), me(p, a);
|
|
2819
|
+
}, "flowFactory"), fn = /* @__PURE__ */ r((n, s, a) => {
|
|
2820
|
+
let p = Dt(n, { name: "unknown" }, s);
|
|
2821
|
+
return me(p, a);
|
|
2822
|
+
}, "unknownFactory"), qe = /* @__PURE__ */ r((n) => {
|
|
2823
|
+
switch (n) {
|
|
2824
|
+
case "JavaScript":
|
|
2825
|
+
return un;
|
|
2826
|
+
case "TypeScript":
|
|
2827
|
+
return mn;
|
|
2828
|
+
case "Flow":
|
|
2829
|
+
return yn;
|
|
2830
|
+
default:
|
|
2831
|
+
return fn;
|
|
2832
|
+
}
|
|
2833
|
+
}, "getPropDefFactory");
|
|
2834
|
+
|
|
2835
|
+
// src/docs-tools/argTypes/docgen/extractDocgenProps.ts
|
|
2836
|
+
var Ot = /* @__PURE__ */ r((n) => n.type != null ? "JavaScript" : n.flowType != null ? "Flow" : n.tsType != null ? "TypeScript" : "Unknown",
|
|
2837
|
+
"getTypeSystem"), vt = /* @__PURE__ */ r((n) => {
|
|
2838
|
+
let s = Ot(n[0]), a = qe(s);
|
|
2839
|
+
return n.map((p) => {
|
|
2840
|
+
let c = p;
|
|
2841
|
+
return p.type?.elements && (c = {
|
|
2842
|
+
...p,
|
|
2843
|
+
type: {
|
|
2844
|
+
...p.type,
|
|
2845
|
+
value: p.type.elements
|
|
2846
|
+
}
|
|
2847
|
+
}), At(c.name, c, s, a);
|
|
2848
|
+
});
|
|
2849
|
+
}, "extractComponentSectionArray"), kt = /* @__PURE__ */ r((n) => {
|
|
2850
|
+
let s = Object.keys(n), a = Ot(n[s[0]]), p = qe(a);
|
|
2851
|
+
return s.map((c) => {
|
|
2852
|
+
let u = n[c];
|
|
2853
|
+
return u != null ? At(c, u, a, p) : null;
|
|
2854
|
+
}).filter(Boolean);
|
|
2855
|
+
}, "extractComponentSectionObject"), dn = /* @__PURE__ */ r((n, s) => {
|
|
2856
|
+
let a = Re(n, s);
|
|
2857
|
+
return Ae(a) ? Array.isArray(a) ? vt(a) : kt(a) : [];
|
|
2858
|
+
}, "extractComponentProps");
|
|
2859
|
+
function At(n, s, a, p) {
|
|
2860
|
+
let c = Ke(s.description);
|
|
2861
|
+
return c.includesJsDoc && c.ignore ? null : {
|
|
2862
|
+
propDef: p(n, s, c),
|
|
2863
|
+
jsDocTags: c.extractedTags,
|
|
2864
|
+
docgenInfo: s,
|
|
2865
|
+
typeSystem: a
|
|
2866
|
+
};
|
|
2867
|
+
}
|
|
2868
|
+
r(At, "extractProp");
|
|
2869
|
+
function Tn(n) {
|
|
2870
|
+
return n != null ? Ie(n) : "";
|
|
2871
|
+
}
|
|
2872
|
+
r(Tn, "extractComponentDescription");
|
|
2873
|
+
|
|
2874
|
+
// src/docs-tools/argTypes/enhanceArgTypes.ts
|
|
2875
|
+
var Rt = require("storybook/preview-api");
|
|
2876
|
+
var gn = /* @__PURE__ */ r((n) => {
|
|
2877
|
+
let {
|
|
2878
|
+
component: s,
|
|
2879
|
+
argTypes: a,
|
|
2880
|
+
parameters: { docs: p = {} }
|
|
2881
|
+
} = n, { extractArgTypes: c } = p, u = c && s ? c(s) : {};
|
|
2882
|
+
return u ? (0, Rt.combineParameters)(u, a) : a;
|
|
2883
|
+
}, "enhanceArgTypes");
|
|
2884
|
+
|
|
2885
|
+
// src/docs-tools/shared.ts
|
|
2886
|
+
var Ye = "storybook/docs", hn = `${Ye}/panel`, xn = "docs", Jn = `${Ye}/snippet-rendered`, It = /* @__PURE__ */ ((p) => (p.AUTO = "auto", p.
|
|
2887
|
+
CODE = "code", p.DYNAMIC = "dynamic", p))(It || {});
|
|
2888
|
+
|
|
2889
|
+
// src/docs-tools/hasDocsOrControls.ts
|
|
2890
|
+
var wn = /(addons\/|addon-|addon-essentials\/)(docs|controls)/, Pn = /* @__PURE__ */ r((n) => n.presetsList?.some((s) => wn.test(s.name)), "\
|
|
2891
|
+
hasDocsOrControls");
|