@openpkg-ts/doc-generator 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +3 -5
- package/dist/index.js +14 -16
- package/dist/react-styled.js +922 -175
- package/dist/react.js +769 -18
- package/dist/shared/{chunk-7hg53zpt.js → server-83s9r625.js} +174 -14
- package/package.json +1 -1
- package/dist/shared/chunk-e5fkh3kh.js +0 -679
- package/dist/shared/chunk-taeg9090.js +0 -171
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
-
|
|
20
|
-
// src/core/query.ts
|
|
21
|
-
function formatSchema(schema) {
|
|
22
|
-
if (!schema)
|
|
23
|
-
return "unknown";
|
|
24
|
-
if (typeof schema === "string")
|
|
25
|
-
return schema;
|
|
26
|
-
if (typeof schema === "object" && schema !== null) {
|
|
27
|
-
if ("$ref" in schema && typeof schema.$ref === "string") {
|
|
28
|
-
return schema.$ref.replace("#/types/", "");
|
|
29
|
-
}
|
|
30
|
-
if ("anyOf" in schema && Array.isArray(schema.anyOf)) {
|
|
31
|
-
return schema.anyOf.map((s) => formatSchema(s)).join(" | ");
|
|
32
|
-
}
|
|
33
|
-
if ("allOf" in schema && Array.isArray(schema.allOf)) {
|
|
34
|
-
return schema.allOf.map((s) => formatSchema(s)).join(" & ");
|
|
35
|
-
}
|
|
36
|
-
if ("type" in schema && schema.type === "array") {
|
|
37
|
-
const items = "items" in schema ? formatSchema(schema.items) : "unknown";
|
|
38
|
-
return `${items}[]`;
|
|
39
|
-
}
|
|
40
|
-
if ("type" in schema && schema.type === "tuple" && "items" in schema) {
|
|
41
|
-
const items = schema.items.map(formatSchema).join(", ");
|
|
42
|
-
return `[${items}]`;
|
|
43
|
-
}
|
|
44
|
-
if ("type" in schema && schema.type === "object") {
|
|
45
|
-
if ("properties" in schema && schema.properties) {
|
|
46
|
-
const props = Object.entries(schema.properties).map(([k, v]) => `${k}: ${formatSchema(v)}`).join("; ");
|
|
47
|
-
return `{ ${props} }`;
|
|
48
|
-
}
|
|
49
|
-
return "object";
|
|
50
|
-
}
|
|
51
|
-
if ("type" in schema && typeof schema.type === "string") {
|
|
52
|
-
return schema.type;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return "unknown";
|
|
56
|
-
}
|
|
57
|
-
function formatTypeParameters(typeParams) {
|
|
58
|
-
if (!typeParams?.length)
|
|
59
|
-
return "";
|
|
60
|
-
const params = typeParams.map((tp) => {
|
|
61
|
-
let str = tp.name;
|
|
62
|
-
if (tp.constraint)
|
|
63
|
-
str += ` extends ${tp.constraint}`;
|
|
64
|
-
if (tp.default)
|
|
65
|
-
str += ` = ${tp.default}`;
|
|
66
|
-
return str;
|
|
67
|
-
});
|
|
68
|
-
return `<${params.join(", ")}>`;
|
|
69
|
-
}
|
|
70
|
-
function formatParameters(sig) {
|
|
71
|
-
if (!sig?.parameters?.length)
|
|
72
|
-
return "()";
|
|
73
|
-
const params = sig.parameters.map((p) => {
|
|
74
|
-
const optional = p.required === false ? "?" : "";
|
|
75
|
-
const rest = p.rest ? "..." : "";
|
|
76
|
-
const type = formatSchema(p.schema);
|
|
77
|
-
return `${rest}${p.name}${optional}: ${type}`;
|
|
78
|
-
});
|
|
79
|
-
return `(${params.join(", ")})`;
|
|
80
|
-
}
|
|
81
|
-
function formatReturnType(sig) {
|
|
82
|
-
if (!sig?.returns)
|
|
83
|
-
return "void";
|
|
84
|
-
return formatSchema(sig.returns.schema);
|
|
85
|
-
}
|
|
86
|
-
function buildSignatureString(exp, sigIndex = 0) {
|
|
87
|
-
const sig = exp.signatures?.[sigIndex];
|
|
88
|
-
const typeParams = formatTypeParameters(exp.typeParameters || sig?.typeParameters);
|
|
89
|
-
switch (exp.kind) {
|
|
90
|
-
case "function": {
|
|
91
|
-
const params = formatParameters(sig);
|
|
92
|
-
const returnType = formatReturnType(sig);
|
|
93
|
-
return `function ${exp.name}${typeParams}${params}: ${returnType}`;
|
|
94
|
-
}
|
|
95
|
-
case "class": {
|
|
96
|
-
const ext = exp.extends ? ` extends ${exp.extends}` : "";
|
|
97
|
-
const impl = exp.implements?.length ? ` implements ${exp.implements.join(", ")}` : "";
|
|
98
|
-
return `class ${exp.name}${typeParams}${ext}${impl}`;
|
|
99
|
-
}
|
|
100
|
-
case "interface": {
|
|
101
|
-
const ext = exp.extends ? ` extends ${exp.extends}` : "";
|
|
102
|
-
return `interface ${exp.name}${typeParams}${ext}`;
|
|
103
|
-
}
|
|
104
|
-
case "type": {
|
|
105
|
-
const typeValue = typeof exp.type === "string" ? exp.type : formatSchema(exp.schema);
|
|
106
|
-
return `type ${exp.name}${typeParams} = ${typeValue}`;
|
|
107
|
-
}
|
|
108
|
-
case "enum": {
|
|
109
|
-
return `enum ${exp.name}`;
|
|
110
|
-
}
|
|
111
|
-
case "variable": {
|
|
112
|
-
const typeValue = typeof exp.type === "string" ? exp.type : formatSchema(exp.schema);
|
|
113
|
-
return `const ${exp.name}: ${typeValue}`;
|
|
114
|
-
}
|
|
115
|
-
default:
|
|
116
|
-
return exp.name;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function resolveTypeRef(ref, spec) {
|
|
120
|
-
const id = ref.replace("#/types/", "");
|
|
121
|
-
return spec.types?.find((t) => t.id === id);
|
|
122
|
-
}
|
|
123
|
-
function isMethod(member) {
|
|
124
|
-
return !!member.signatures?.length;
|
|
125
|
-
}
|
|
126
|
-
function isProperty(member) {
|
|
127
|
-
return !member.signatures?.length;
|
|
128
|
-
}
|
|
129
|
-
function getMethods(members) {
|
|
130
|
-
return members?.filter(isMethod) ?? [];
|
|
131
|
-
}
|
|
132
|
-
function getProperties(members) {
|
|
133
|
-
return members?.filter(isProperty) ?? [];
|
|
134
|
-
}
|
|
135
|
-
function groupByVisibility(members) {
|
|
136
|
-
const groups = {
|
|
137
|
-
public: [],
|
|
138
|
-
protected: [],
|
|
139
|
-
private: []
|
|
140
|
-
};
|
|
141
|
-
for (const member of members ?? []) {
|
|
142
|
-
const visibility = member.visibility ?? "public";
|
|
143
|
-
groups[visibility].push(member);
|
|
144
|
-
}
|
|
145
|
-
return groups;
|
|
146
|
-
}
|
|
147
|
-
function sortByName(items) {
|
|
148
|
-
return [...items].sort((a, b) => a.name.localeCompare(b.name));
|
|
149
|
-
}
|
|
150
|
-
function sortByKindThenName(exports) {
|
|
151
|
-
const kindOrder = {
|
|
152
|
-
function: 0,
|
|
153
|
-
class: 1,
|
|
154
|
-
interface: 2,
|
|
155
|
-
type: 3,
|
|
156
|
-
enum: 4,
|
|
157
|
-
variable: 5,
|
|
158
|
-
namespace: 6,
|
|
159
|
-
module: 7,
|
|
160
|
-
reference: 8,
|
|
161
|
-
external: 9
|
|
162
|
-
};
|
|
163
|
-
return [...exports].sort((a, b) => {
|
|
164
|
-
const kindDiff = kindOrder[a.kind] - kindOrder[b.kind];
|
|
165
|
-
if (kindDiff !== 0)
|
|
166
|
-
return kindDiff;
|
|
167
|
-
return a.name.localeCompare(b.name);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export { __toESM, __require, formatSchema, formatTypeParameters, formatParameters, formatReturnType, buildSignatureString, resolveTypeRef, isMethod, isProperty, getMethods, getProperties, groupByVisibility, sortByName, sortByKindThenName };
|