@stainless-api/docs-ui 0.1.0-beta.8 → 0.1.0-beta.81
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/chunk-BYypO7fO.js +18 -0
- package/dist/components/MaskedInput.d.ts +14 -0
- package/dist/components/MaskedInput.js +76 -0
- package/dist/components/breadcrumbs.d.ts +25 -0
- package/dist/components/breadcrumbs.js +64 -0
- package/dist/components/icons.d.ts +65 -0
- package/dist/components/icons.js +941 -0
- package/dist/components/index.d.ts +16 -0
- package/dist/components/index.js +75 -0
- package/dist/components/method.d.ts +59 -0
- package/dist/components/method.js +97 -0
- package/dist/components/overview.d.ts +39 -0
- package/dist/components/overview.js +139 -0
- package/dist/components/primitives.d.ts +107 -0
- package/dist/components/primitives.js +253 -0
- package/dist/components/properties.d.ts +54 -0
- package/dist/components/properties.js +146 -0
- package/dist/components/sdk-sidebar.d.ts +15 -0
- package/dist/components/sdk-sidebar.js +52 -0
- package/dist/components/sdk.d.ts +128 -0
- package/dist/components/sdk.js +490 -0
- package/dist/components/snippets.d.ts +71 -0
- package/dist/components/snippets.js +184 -0
- package/dist/components/stl-sidebar.d.ts +58 -0
- package/dist/components/stl-sidebar.js +114 -0
- package/dist/contexts/component-generics.d.ts +30 -0
- package/dist/contexts/component-generics.js +33 -0
- package/dist/contexts/component-types.d.ts +8 -0
- package/dist/contexts/component-types.js +0 -0
- package/dist/contexts/component.d.ts +21 -0
- package/dist/contexts/component.js +24 -0
- package/dist/contexts/docs.d.ts +62 -0
- package/dist/contexts/docs.js +91 -0
- package/dist/contexts/index.d.ts +13 -0
- package/dist/contexts/index.js +45 -0
- package/dist/contexts/markdown.d.ts +22 -0
- package/dist/contexts/markdown.js +49 -0
- package/dist/contexts/navigation.d.ts +29 -0
- package/dist/contexts/navigation.js +24 -0
- package/dist/contexts/use-components.d.ts +6 -0
- package/dist/contexts/use-components.js +8 -0
- package/dist/index-pvh-w1xa.d.ts +1776 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +9 -7542
- package/dist/languages/cli.d.ts +38 -0
- package/dist/languages/cli.js +167 -0
- package/dist/languages/csharp.d.ts +42 -0
- package/dist/languages/csharp.js +284 -0
- package/dist/languages/go.d.ts +40 -0
- package/dist/languages/go.js +304 -0
- package/dist/languages/http.d.ts +46 -0
- package/dist/languages/http.js +387 -0
- package/dist/languages/index.d.ts +51 -0
- package/dist/languages/index.js +33 -0
- package/dist/languages/java.d.ts +43 -0
- package/dist/languages/java.js +404 -0
- package/dist/languages/php.d.ts +40 -0
- package/dist/languages/php.js +313 -0
- package/dist/languages/python.d.ts +40 -0
- package/dist/languages/python.js +270 -0
- package/dist/languages/ruby.d.ts +40 -0
- package/dist/languages/ruby.js +388 -0
- package/dist/languages/terraform.d.ts +48 -0
- package/dist/languages/terraform.js +244 -0
- package/dist/languages/typescript.d.ts +40 -0
- package/dist/languages/typescript.js +450 -0
- package/dist/markdown/index.d.ts +11 -0
- package/dist/markdown/index.js +80 -0
- package/dist/markdown/md.d.ts +15 -0
- package/dist/markdown/md.js +41 -0
- package/dist/markdown/printer.d.ts +13 -0
- package/dist/markdown/printer.js +76 -0
- package/dist/markdown/utils.d.ts +21 -0
- package/dist/markdown/utils.js +31 -0
- package/dist/routing.d.ts +61 -0
- package/dist/routing.js +176 -150
- package/dist/spec.d.ts +65 -0
- package/dist/spec.js +167 -0
- package/dist/style.d.ts +178 -0
- package/dist/style.js +179 -0
- package/dist/styles/main.css +784 -752
- package/dist/styles/main.js +0 -0
- package/dist/styles/primitives.css +408 -446
- package/dist/styles/primitives.js +0 -0
- package/dist/styles/resets.css +32 -41
- package/dist/styles/resets.js +0 -0
- package/dist/styles/search.css +192 -270
- package/dist/styles/search.js +0 -0
- package/dist/styles/sidebar.css +182 -69
- package/dist/styles/sidebar.js +0 -0
- package/dist/styles/variables.css +28 -89
- package/dist/styles/variables.js +0 -0
- package/dist/styles.css +3423 -0
- package/dist/styles.mjs +1 -0
- package/dist/use-strict-context-L0c8JKg4.js +16 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.js +54 -0
- package/package.json +74 -22
- package/dist/mcp.js +0 -16003
- package/dist/styles/snippets.css +0 -132
- package/src/components/breadcrumbs.tsx +0 -94
- package/src/components/chat.tsx +0 -154
- package/src/components/dropdown.tsx +0 -91
- package/src/components/icons.tsx +0 -584
- package/src/components/index.ts +0 -9
- package/src/components/method.tsx +0 -146
- package/src/components/overview.tsx +0 -160
- package/src/components/primitives.tsx +0 -284
- package/src/components/properties.tsx +0 -130
- package/src/components/scripts/dropdown.ts +0 -78
- package/src/components/sdk.tsx +0 -403
- package/src/components/sidebar.tsx +0 -99
- package/src/components/snippets.tsx +0 -180
- package/src/contexts/component-generics.tsx +0 -48
- package/src/contexts/component-types.tsx +0 -5
- package/src/contexts/component.tsx +0 -32
- package/src/contexts/docs.tsx +0 -75
- package/src/contexts/index.tsx +0 -17
- package/src/contexts/markdown.tsx +0 -43
- package/src/contexts/navigation.tsx +0 -44
- package/src/contexts/search.tsx +0 -28
- package/src/contexts/use-components.tsx +0 -4
- package/src/index.ts +0 -6
- package/src/languages/go.tsx +0 -281
- package/src/languages/http.tsx +0 -321
- package/src/languages/index.ts +0 -26
- package/src/languages/java.tsx +0 -358
- package/src/languages/python.tsx +0 -255
- package/src/languages/ruby.tsx +0 -320
- package/src/languages/typescript.tsx +0 -393
- package/src/markdown/index.ts +0 -107
- package/src/markdown/md.ts +0 -45
- package/src/markdown/utils.ts +0 -49
- package/src/routing.ts +0 -238
- package/src/search/form.tsx +0 -127
- package/src/search/index.tsx +0 -1
- package/src/search/indexer.ts +0 -246
- package/src/search/mcp.ts +0 -61
- package/src/search/printer.tsx +0 -86
- package/src/search/providers/algolia.ts +0 -88
- package/src/search/providers/fuse.ts +0 -19
- package/src/search/providers/pagefind.ts +0 -17
- package/src/search/providers/walker.ts +0 -30
- package/src/search/results.tsx +0 -182
- package/src/search/state.ts +0 -64
- package/src/search/types.ts +0 -116
- package/src/style.ts +0 -196
- package/src/styles/main.css +0 -986
- package/src/styles/primitives.css +0 -580
- package/src/styles/resets.css +0 -39
- package/src/styles/search.css +0 -341
- package/src/styles/sidebar.css +0 -85
- package/src/styles/snippets.css +0 -130
- package/src/styles/variables.css +0 -86
- package/src/utils.ts +0 -41
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { useDeclaration, useLanguage, useSnippet, useSnippetIds, useSnippetResponse } from "../contexts/docs.js";
|
|
2
|
+
import "../use-strict-context-L0c8JKg4.js";
|
|
3
|
+
import { useHighlight } from "../contexts/markdown.js";
|
|
4
|
+
import "../contexts/index.js";
|
|
5
|
+
import { useComponents } from "../contexts/use-components.js";
|
|
6
|
+
import style_default from "../style.js";
|
|
7
|
+
import * as React$1 from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import clsx from "clsx";
|
|
10
|
+
import { CheckIcon, CircleAlertIcon, CopyIcon } from "lucide-react";
|
|
11
|
+
import { Badge, Button, getHttpMethod } from "@stainless-api/ui-primitives";
|
|
12
|
+
|
|
13
|
+
//#region src/components/snippets.tsx
|
|
14
|
+
function SnippetCode({ content, language }) {
|
|
15
|
+
const lang = useLanguage();
|
|
16
|
+
const highlighted = useHighlight(content, language || lang);
|
|
17
|
+
return /* @__PURE__ */ jsx("div", {
|
|
18
|
+
className: style_default.SnippetCode,
|
|
19
|
+
"data-stldocs-copy-content": true,
|
|
20
|
+
dangerouslySetInnerHTML: { __html: highlighted }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function SnippetContainer({ children, className, ...props }) {
|
|
24
|
+
return /* @__PURE__ */ jsx("div", {
|
|
25
|
+
className: clsx(style_default.Snippet, className),
|
|
26
|
+
...props,
|
|
27
|
+
children
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function SnippetRequestContainer({ children }) {
|
|
31
|
+
return /* @__PURE__ */ jsx("div", { children });
|
|
32
|
+
}
|
|
33
|
+
function Snippet({ requestTitle, method, snippet, transformRequestSnippet }) {
|
|
34
|
+
const Docs = useComponents();
|
|
35
|
+
const language = useLanguage();
|
|
36
|
+
const originalSnippetContent = useSnippet(method.stainlessPath, void 0, snippet);
|
|
37
|
+
const snippetResponses = useSnippetResponse(method.stainlessPath, snippet);
|
|
38
|
+
const decl = useDeclaration(method.stainlessPath, false);
|
|
39
|
+
const signature = decl && "qualified" in decl ? decl.qualified : void 0;
|
|
40
|
+
if (!originalSnippetContent) {
|
|
41
|
+
console.warn(`Snippet not found for method '${method.stainlessPath}'`);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const snippetContent = transformRequestSnippet ? transformRequestSnippet({
|
|
45
|
+
snippet: originalSnippetContent,
|
|
46
|
+
language
|
|
47
|
+
}) : originalSnippetContent;
|
|
48
|
+
const httpMethod = getHttpMethod(method.httpMethod);
|
|
49
|
+
return /* @__PURE__ */ jsxs(Docs.SnippetContainer, {
|
|
50
|
+
signature,
|
|
51
|
+
method,
|
|
52
|
+
children: [snippetContent && /* @__PURE__ */ jsx(Docs.SnippetRequestContainer, {
|
|
53
|
+
signature,
|
|
54
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
55
|
+
className: style_default.SnippetRequest,
|
|
56
|
+
"data-stldocs-copy-parent": true,
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ jsxs("div", {
|
|
59
|
+
className: style_default.SnippetRequestTitle,
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ jsxs("div", {
|
|
62
|
+
className: style_default.SnippetRequestTitleMethod,
|
|
63
|
+
children: [httpMethod && /* @__PURE__ */ jsx(Badge.HTTP, {
|
|
64
|
+
method: httpMethod,
|
|
65
|
+
iconOnly: true
|
|
66
|
+
}), /* @__PURE__ */ jsx("h3", { children: method.summary || method.title })]
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ jsx("div", {
|
|
69
|
+
className: style_default.SnippetRequestTitleContent,
|
|
70
|
+
children: requestTitle
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ jsx(Docs.SnippetButtons, { content: snippetContent })
|
|
73
|
+
]
|
|
74
|
+
}),
|
|
75
|
+
/* @__PURE__ */ jsx(Docs.SnippetCode, {
|
|
76
|
+
content: snippetContent,
|
|
77
|
+
signature
|
|
78
|
+
}),
|
|
79
|
+
/* @__PURE__ */ jsx(Docs.SnippetFooter, {})
|
|
80
|
+
]
|
|
81
|
+
})
|
|
82
|
+
}), /* @__PURE__ */ jsx(Docs.SnippetResponse, { responses: snippetResponses })]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function MultiSnippets({ requestTitle, method }) {
|
|
86
|
+
const snippetIds = useSnippetIds(method.stainlessPath)?.filter((id) => id !== "default");
|
|
87
|
+
const radioId = React$1.useId();
|
|
88
|
+
const Docs = useComponents();
|
|
89
|
+
if (!snippetIds) return null;
|
|
90
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
91
|
+
className: style_default.SnippetMulti,
|
|
92
|
+
"data-stldocs-multi-snippet-container": true,
|
|
93
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
94
|
+
className: style_default.SnippetMultiTabs,
|
|
95
|
+
"data-stldocs-multi-snippet-tabs": true,
|
|
96
|
+
children: snippetIds.map((snid, idx) => /* @__PURE__ */ jsxs("label", {
|
|
97
|
+
className: style_default.SnippetMultiTab,
|
|
98
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
99
|
+
type: "radio",
|
|
100
|
+
name: `snippet-example-radio-${radioId}`,
|
|
101
|
+
value: idx,
|
|
102
|
+
defaultChecked: idx === 0
|
|
103
|
+
}), /* @__PURE__ */ jsx("span", { children: snid.slice(7) })]
|
|
104
|
+
}, `snippet-example-${idx}`))
|
|
105
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
106
|
+
className: style_default.SnippetMultiContent,
|
|
107
|
+
children: snippetIds.map((snid, idx) => {
|
|
108
|
+
return /* @__PURE__ */ jsx("div", {
|
|
109
|
+
className: clsx(style_default.SnippetMultiPane, idx === 0 && style_default.SnippetMultiPaneActive),
|
|
110
|
+
"data-stldocs-multi-snippet-id": idx,
|
|
111
|
+
children: /* @__PURE__ */ jsx(Docs.Snippet, {
|
|
112
|
+
method,
|
|
113
|
+
snippet: snid,
|
|
114
|
+
requestTitle
|
|
115
|
+
})
|
|
116
|
+
}, `snippet-example-content-${idx}`);
|
|
117
|
+
})
|
|
118
|
+
})]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function SnippetButtons({ content }) {
|
|
122
|
+
const [CopyButtonIcon, setCopyIcon] = React$1.useState(CopyIcon);
|
|
123
|
+
async function handleCopy() {
|
|
124
|
+
try {
|
|
125
|
+
await navigator.clipboard.writeText(content);
|
|
126
|
+
setCopyIcon(CheckIcon);
|
|
127
|
+
} catch {
|
|
128
|
+
setCopyIcon(CircleAlertIcon);
|
|
129
|
+
}
|
|
130
|
+
setTimeout(() => setCopyIcon(CopyIcon), 1e3);
|
|
131
|
+
}
|
|
132
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
133
|
+
variant: "outline",
|
|
134
|
+
"data-stldocs-snippet-copy": true,
|
|
135
|
+
children: /* @__PURE__ */ jsx(CopyButtonIcon, {
|
|
136
|
+
size: 16,
|
|
137
|
+
className: style_default.Icon,
|
|
138
|
+
onClick: handleCopy
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function SnippetFooter() {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
function SnippetResponse({ responses }) {
|
|
146
|
+
const Docs = useComponents();
|
|
147
|
+
if (!responses || responses.length === 0) return null;
|
|
148
|
+
const tabs = responses.map(({ status }, index) => ({
|
|
149
|
+
status,
|
|
150
|
+
index,
|
|
151
|
+
label: status ? `${status} example` : null
|
|
152
|
+
}));
|
|
153
|
+
const hasTabs = tabs.length > 1 || tabs.some((tab) => tab.label);
|
|
154
|
+
return /* @__PURE__ */ jsx("div", {
|
|
155
|
+
className: style_default.SnippetMultiResponse,
|
|
156
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
157
|
+
className: clsx(style_default.Snippet),
|
|
158
|
+
children: [hasTabs && /* @__PURE__ */ jsx("div", {
|
|
159
|
+
className: clsx(style_default.SnippetResponseTab, tabs.length === 1 && style_default.SnippetResponseTabSingleReturn),
|
|
160
|
+
children: tabs.map(({ status, label }, index) => /* @__PURE__ */ jsx("div", {
|
|
161
|
+
"data-snippet-response-tab-id": `snippet-response-tab-${status}-${index}`,
|
|
162
|
+
className: clsx(style_default.SnippetResponseTabItem, index === 0 && style_default.SnippetResponseTabItemActive),
|
|
163
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
164
|
+
disabled: responses.length === 1,
|
|
165
|
+
variant: "ghost",
|
|
166
|
+
children: label ?? `Example ${index + 1}`
|
|
167
|
+
})
|
|
168
|
+
}, `snippet-response-tab-item-${status}-${index}`))
|
|
169
|
+
}), responses.map(({ status, content, contentType }, index) => {
|
|
170
|
+
return typeof content === "string" ? /* @__PURE__ */ jsx("div", {
|
|
171
|
+
className: clsx(style_default.SnippetResponsePane, index === 0 && style_default.SnippetResponsePaneActive),
|
|
172
|
+
"data-snippet-response-pane-id": `snippet-response-tab-${status}-${index}`,
|
|
173
|
+
children: /* @__PURE__ */ jsx(Docs.SnippetCode, {
|
|
174
|
+
content,
|
|
175
|
+
language: contentType === "application/json" || !contentType ? "json" : "none"
|
|
176
|
+
})
|
|
177
|
+
}, `snippet-response-${status}-${index}`) : null;
|
|
178
|
+
})]
|
|
179
|
+
})
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
//#endregion
|
|
184
|
+
export { MultiSnippets, Snippet, SnippetButtons, SnippetCode, SnippetContainer, SnippetFooter, SnippetRequestContainer, SnippetResponse };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/stl-sidebar.d.ts
|
|
5
|
+
declare module 'react' {
|
|
6
|
+
namespace JSX {
|
|
7
|
+
interface IntrinsicElements {
|
|
8
|
+
/**
|
|
9
|
+
* Custom element defined by Starlight's <SidebarPersister>.
|
|
10
|
+
*/
|
|
11
|
+
'sl-sidebar-restore': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
type StlSidebarTarget = {
|
|
16
|
+
type: 'href';
|
|
17
|
+
href: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'stainlessPath';
|
|
20
|
+
stainlessPath: string;
|
|
21
|
+
};
|
|
22
|
+
interface StlSidebarLink {
|
|
23
|
+
type: 'link';
|
|
24
|
+
icon?: ReactNode;
|
|
25
|
+
label: string;
|
|
26
|
+
/** Current sidebar item is highlighted. */
|
|
27
|
+
isCurrent?: boolean;
|
|
28
|
+
target: StlSidebarTarget;
|
|
29
|
+
/** Additional HTML attributes that will be attached to the anchor element. */
|
|
30
|
+
attrs?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
interface StlSidebarGroup {
|
|
33
|
+
type: 'group';
|
|
34
|
+
icon?: ReactNode;
|
|
35
|
+
label: string;
|
|
36
|
+
entries: Array<StlSidebarLink | StlSidebarGroup>;
|
|
37
|
+
/** Defaults to true. */
|
|
38
|
+
collapsible?: boolean;
|
|
39
|
+
collapsed?: boolean;
|
|
40
|
+
/** Current sidebar item is highlighted. */
|
|
41
|
+
isCurrent?: boolean;
|
|
42
|
+
target?: StlSidebarTarget;
|
|
43
|
+
}
|
|
44
|
+
type StlSidebarEntry = StlSidebarLink | StlSidebarGroup;
|
|
45
|
+
type StlSidebarProps = {
|
|
46
|
+
entries: StlSidebarEntry[];
|
|
47
|
+
/**
|
|
48
|
+
* If set, add <sl-sidebar-restore> custom elements (as defined by Starlight's SidebarPersister)
|
|
49
|
+
* which are used to save/restore sidebar state.
|
|
50
|
+
*/
|
|
51
|
+
withStarlightRestoration?: boolean;
|
|
52
|
+
};
|
|
53
|
+
declare function StlSidebar({
|
|
54
|
+
entries,
|
|
55
|
+
withStarlightRestoration
|
|
56
|
+
}: StlSidebarProps): react_jsx_runtime0.JSX.Element;
|
|
57
|
+
//#endregion
|
|
58
|
+
export { StlSidebar, StlSidebarEntry, StlSidebarGroup, StlSidebarLink, StlSidebarProps, StlSidebarTarget };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import "../use-strict-context-L0c8JKg4.js";
|
|
2
|
+
import { useComponents } from "../contexts/use-components.js";
|
|
3
|
+
import style_default from "../style.js";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { ChevronRight } from "lucide-react";
|
|
7
|
+
|
|
8
|
+
//#region src/components/stl-sidebar.tsx
|
|
9
|
+
function targetToAttributes(target) {
|
|
10
|
+
return {
|
|
11
|
+
href: target.type === "href" ? target.href : void 0,
|
|
12
|
+
stainlessPath: target.type === "stainlessPath" ? target.stainlessPath : void 0
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function StlSidebarSublist({ entries, entryToIndex }) {
|
|
16
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
17
|
+
className: style_default.SidebarList,
|
|
18
|
+
children: entries.map((entry, index) => entry.type === "link" ? /* @__PURE__ */ jsx(LinkEntry, { entry }, index) : /* @__PURE__ */ jsx(GroupEntry, {
|
|
19
|
+
entry,
|
|
20
|
+
entryToIndex
|
|
21
|
+
}, index))
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function EntryItem({ className, children }) {
|
|
25
|
+
return /* @__PURE__ */ jsx("li", {
|
|
26
|
+
className: clsx(style_default.SidebarEntry, className),
|
|
27
|
+
children
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function LinkEntry({ entry }) {
|
|
31
|
+
const Docs = useComponents();
|
|
32
|
+
return /* @__PURE__ */ jsx(EntryItem, {
|
|
33
|
+
className: style_default.SidebarEntryLink,
|
|
34
|
+
children: /* @__PURE__ */ jsxs(Docs.Link, {
|
|
35
|
+
...targetToAttributes(entry.target),
|
|
36
|
+
"aria-current": entry.isCurrent ? "page" : void 0,
|
|
37
|
+
...entry.attrs,
|
|
38
|
+
children: [entry.icon, entry.label]
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function GroupEntry({ entry, entryToIndex }) {
|
|
43
|
+
const Docs = useComponents();
|
|
44
|
+
const restorePointIndex = entryToIndex?.get(entry);
|
|
45
|
+
const { collapsible = true } = entry;
|
|
46
|
+
const labelWithIcon = /* @__PURE__ */ jsxs(Fragment, { children: [entry.label, entry.icon] });
|
|
47
|
+
const GroupElement = collapsible ? "details" : "div";
|
|
48
|
+
const GroupLabelElement = collapsible ? "summary" : "div";
|
|
49
|
+
return /* @__PURE__ */ jsxs(EntryItem, {
|
|
50
|
+
className: style_default.SidebarEntryGroup,
|
|
51
|
+
children: [entry.target && /* @__PURE__ */ jsx(Docs.Link, {
|
|
52
|
+
...targetToAttributes(entry.target),
|
|
53
|
+
"aria-current": entry.isCurrent ? "page" : void 0,
|
|
54
|
+
children: labelWithIcon
|
|
55
|
+
}), /* @__PURE__ */ jsxs(GroupElement, {
|
|
56
|
+
className: style_default.SidebarExpander,
|
|
57
|
+
...collapsible ? { open: !entry.collapsed || isAnyItemCurrent(entry.entries) } : {},
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsxs(GroupLabelElement, {
|
|
60
|
+
className: style_default.ExpanderSummary,
|
|
61
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
62
|
+
"aria-hidden": entry.target ? "true" : void 0,
|
|
63
|
+
children: labelWithIcon
|
|
64
|
+
}), entry.entries.length > 0 && collapsible && /* @__PURE__ */ jsx(ChevronRight, {
|
|
65
|
+
size: 16,
|
|
66
|
+
strokeWidth: 1,
|
|
67
|
+
className: `${style_default.Icon} ${style_default.ExpanderSummaryIcon}`
|
|
68
|
+
})]
|
|
69
|
+
}),
|
|
70
|
+
restorePointIndex !== void 0 && /* @__PURE__ */ jsx("sl-sidebar-restore", { "data-index": restorePointIndex }),
|
|
71
|
+
entry.entries.length > 0 && /* @__PURE__ */ jsx(StlSidebarSublist, {
|
|
72
|
+
entries: entry.entries,
|
|
73
|
+
entryToIndex
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
})]
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function StlSidebar({ entries, withStarlightRestoration }) {
|
|
80
|
+
const entryToIndex = withStarlightRestoration ? computeEntryToIndex(entries) : void 0;
|
|
81
|
+
return /* @__PURE__ */ jsx("div", {
|
|
82
|
+
className: `${style_default.Root} ${style_default.Sidebar}`,
|
|
83
|
+
children: /* @__PURE__ */ jsx(StlSidebarSublist, {
|
|
84
|
+
entries,
|
|
85
|
+
entryToIndex
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function computeEntryToIndex(allEntries) {
|
|
90
|
+
const entryToIndex = /* @__PURE__ */ new Map();
|
|
91
|
+
let currentIndex = 0;
|
|
92
|
+
function addEntries(entries) {
|
|
93
|
+
for (const entry of entries) if (entry.type === "group") {
|
|
94
|
+
entryToIndex.set(entry, currentIndex);
|
|
95
|
+
currentIndex++;
|
|
96
|
+
addEntries(entry.entries);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
addEntries(allEntries);
|
|
100
|
+
return entryToIndex;
|
|
101
|
+
}
|
|
102
|
+
function* walkSidebar(entries) {
|
|
103
|
+
for (const entry of entries) {
|
|
104
|
+
yield entry;
|
|
105
|
+
if (entry.type === "group") yield* walkSidebar(entry.entries);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function isAnyItemCurrent(entries) {
|
|
109
|
+
for (const e of walkSidebar(entries)) if (e.isCurrent) return true;
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { StlSidebar };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/contexts/component-generics.d.ts
|
|
5
|
+
type DeepPartialMap<L> = { [K in keyof L]?: Partial<L[K]> };
|
|
6
|
+
type ComponentsContextType<C, L> = {
|
|
7
|
+
components: C;
|
|
8
|
+
language: L;
|
|
9
|
+
};
|
|
10
|
+
declare const useComponentContext: () => ComponentsContextType<any, any>;
|
|
11
|
+
declare function useComponents<C = unknown>(): C;
|
|
12
|
+
declare function customizeComponents<C, L>(defaults: {
|
|
13
|
+
components: C;
|
|
14
|
+
language: L;
|
|
15
|
+
}, overrides?: {
|
|
16
|
+
components?: Partial<C>;
|
|
17
|
+
language?: DeepPartialMap<L>;
|
|
18
|
+
}): {
|
|
19
|
+
components: C;
|
|
20
|
+
language: L;
|
|
21
|
+
};
|
|
22
|
+
declare function ComponentProvider<C, L>({
|
|
23
|
+
value,
|
|
24
|
+
children
|
|
25
|
+
}: {
|
|
26
|
+
value: ComponentsContextType<C, L>;
|
|
27
|
+
children: React$1.ReactNode;
|
|
28
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { ComponentProvider, ComponentsContextType, customizeComponents, useComponentContext, useComponents };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { t as createStrictContext } from "../use-strict-context-L0c8JKg4.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/contexts/component-generics.tsx
|
|
6
|
+
const [Provider, useComponentContext] = createStrictContext("Component");
|
|
7
|
+
function useComponents() {
|
|
8
|
+
return useComponentContext().components;
|
|
9
|
+
}
|
|
10
|
+
function customizeComponents(defaults, overrides = {}) {
|
|
11
|
+
return {
|
|
12
|
+
components: {
|
|
13
|
+
...defaults.components,
|
|
14
|
+
...overrides.components ?? {}
|
|
15
|
+
},
|
|
16
|
+
language: Object.keys(defaults.language).reduce((acc, key) => {
|
|
17
|
+
acc[key] = {
|
|
18
|
+
...defaults.language[key],
|
|
19
|
+
...overrides.language?.[key] ?? {}
|
|
20
|
+
};
|
|
21
|
+
return acc;
|
|
22
|
+
}, {})
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function ComponentProvider({ value, children }) {
|
|
26
|
+
return /* @__PURE__ */ jsx(Provider, {
|
|
27
|
+
value,
|
|
28
|
+
children
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { ComponentProvider, customizeComponents, useComponentContext, useComponents };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { t as index_d_exports } from "../languages/index.js";
|
|
2
|
+
import { t as index_d_exports$1 } from "../components/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/contexts/component-types.d.ts
|
|
5
|
+
type AppComponents = typeof index_d_exports$1;
|
|
6
|
+
type AppLanguage = typeof index_d_exports;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { AppComponents, AppLanguage };
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { t as index_d_exports } from "../languages/index.js";
|
|
2
|
+
import { ComponentsContextType } from "./component-generics.js";
|
|
3
|
+
import { t as index_d_exports$1 } from "../components/index.js";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/contexts/component.d.ts
|
|
8
|
+
type AppComponents = typeof index_d_exports$1;
|
|
9
|
+
type AppLanguage = typeof index_d_exports;
|
|
10
|
+
declare const defaultContextValue: ComponentsContextType<AppComponents, AppLanguage>;
|
|
11
|
+
declare function ComponentProvider({
|
|
12
|
+
components,
|
|
13
|
+
language,
|
|
14
|
+
children
|
|
15
|
+
}: {
|
|
16
|
+
components?: Partial<AppComponents>;
|
|
17
|
+
language?: { [K in keyof AppLanguage]?: Partial<AppLanguage[K]> };
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { AppComponents, AppLanguage, ComponentProvider, defaultContextValue };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "../use-strict-context-L0c8JKg4.js";
|
|
2
|
+
import { ComponentProvider as ComponentProvider$1, customizeComponents } from "./component-generics.js";
|
|
3
|
+
import { t as components_exports } from "../components/index.js";
|
|
4
|
+
import { t as languages_exports } from "../languages/index.js";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/contexts/component.tsx
|
|
9
|
+
const defaultContextValue = {
|
|
10
|
+
components: components_exports,
|
|
11
|
+
language: languages_exports
|
|
12
|
+
};
|
|
13
|
+
function ComponentProvider({ components, language, children }) {
|
|
14
|
+
return /* @__PURE__ */ jsx(ComponentProvider$1, {
|
|
15
|
+
value: React.useMemo(() => customizeComponents(defaultContextValue, {
|
|
16
|
+
components,
|
|
17
|
+
language
|
|
18
|
+
}), [components, language]),
|
|
19
|
+
children
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ComponentProvider, defaultContextValue };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { h as Resource, u as LanguageDeclNodes, v as Spec, y as SpecLanguage } from "../index-pvh-w1xa.js";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/contexts/docs.d.ts
|
|
6
|
+
type ContentPanelLayout = 'double-pane' | 'single-pane';
|
|
7
|
+
type PropertySettingsType = {
|
|
8
|
+
types?: 'simple' | 'rich';
|
|
9
|
+
includeModelProperties?: boolean | 'method-page';
|
|
10
|
+
collapseDescription?: boolean | 'show-first-line';
|
|
11
|
+
showTitle?: boolean;
|
|
12
|
+
expandDepth?: number;
|
|
13
|
+
};
|
|
14
|
+
type DocsContextType = {
|
|
15
|
+
language: SpecLanguage;
|
|
16
|
+
spec: Spec | null;
|
|
17
|
+
settings?: {
|
|
18
|
+
properties?: PropertySettingsType;
|
|
19
|
+
contentPanelLayout?: ContentPanelLayout;
|
|
20
|
+
virtualExpanders?: boolean;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
declare function useDocs(): DocsContextType;
|
|
24
|
+
declare function useSpec(): Spec | null;
|
|
25
|
+
declare function useSettings(): {
|
|
26
|
+
properties?: PropertySettingsType;
|
|
27
|
+
contentPanelLayout?: ContentPanelLayout;
|
|
28
|
+
virtualExpanders?: boolean;
|
|
29
|
+
} | undefined;
|
|
30
|
+
declare function useSnippets(stainlessPath: string, language?: SpecLanguage): {
|
|
31
|
+
[key: `custom:${string}`]: {
|
|
32
|
+
content: string;
|
|
33
|
+
};
|
|
34
|
+
default: {
|
|
35
|
+
content: string;
|
|
36
|
+
};
|
|
37
|
+
} | undefined;
|
|
38
|
+
declare function useSnippetIds(stainlessPath: string, language?: SpecLanguage): SnippetId[] | undefined;
|
|
39
|
+
type SnippetId = keyof NonNullable<ReturnType<typeof useSnippets>>;
|
|
40
|
+
declare function useSnippet(stainlessPath: string, language?: SpecLanguage, snippetId?: SnippetId): string | undefined;
|
|
41
|
+
declare function useSnippetResponse(stainlessPath: string, snippetId?: SnippetId): {
|
|
42
|
+
status?: string;
|
|
43
|
+
content: string;
|
|
44
|
+
}[] | undefined;
|
|
45
|
+
type Declaration = LanguageDeclNodes[SpecLanguage];
|
|
46
|
+
declare function useDeclaration<Required extends boolean>(stainlessPath: string, required: Required, language?: SpecLanguage): (Required extends true ? never : undefined) | Declaration;
|
|
47
|
+
declare function useAvailableLanguages(stainlessPath: string): SpecLanguage[];
|
|
48
|
+
declare function useIgnoredResources(): string[];
|
|
49
|
+
declare function useResource(name: string): Resource | undefined;
|
|
50
|
+
declare function useLanguage(): "http" | "node" | "python" | "go" | "typescript" | "terraform" | "ruby" | "java" | "kotlin" | "csharp" | "php" | "cli";
|
|
51
|
+
declare function useContentPanelLayout(): ContentPanelLayout;
|
|
52
|
+
type DocsProviderProps = DocsContextType & {
|
|
53
|
+
children: React$1.ReactNode;
|
|
54
|
+
};
|
|
55
|
+
declare function DocsProvider({
|
|
56
|
+
spec,
|
|
57
|
+
language,
|
|
58
|
+
settings,
|
|
59
|
+
children
|
|
60
|
+
}: DocsProviderProps): react_jsx_runtime0.JSX.Element;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { ContentPanelLayout, Declaration, DocsContextType, DocsProvider, DocsProviderProps, PropertySettingsType, useAvailableLanguages, useContentPanelLayout, useDeclaration, useDocs, useIgnoredResources, useLanguage, useResource, useSettings, useSnippet, useSnippetIds, useSnippetResponse, useSnippets, useSpec };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/contexts/docs.tsx
|
|
5
|
+
const DocsContextDefaults = {
|
|
6
|
+
settings: {},
|
|
7
|
+
language: "node",
|
|
8
|
+
spec: null
|
|
9
|
+
};
|
|
10
|
+
const DocsContext = React$1.createContext(DocsContextDefaults);
|
|
11
|
+
function useDocs() {
|
|
12
|
+
return React$1.use(DocsContext);
|
|
13
|
+
}
|
|
14
|
+
function useSpec() {
|
|
15
|
+
return useDocs().spec;
|
|
16
|
+
}
|
|
17
|
+
function useSettings() {
|
|
18
|
+
return useDocs().settings;
|
|
19
|
+
}
|
|
20
|
+
function useSnippets(stainlessPath, language) {
|
|
21
|
+
const defaultLanguage = useLanguage();
|
|
22
|
+
const lang = language ?? defaultLanguage;
|
|
23
|
+
const snippetLanguage = lang === "http" ? "http.curl" : `${lang}.default`;
|
|
24
|
+
return useSpec()?.snippets?.[snippetLanguage]?.[stainlessPath];
|
|
25
|
+
}
|
|
26
|
+
function useSnippetIds(stainlessPath, language) {
|
|
27
|
+
const snippets = useSnippets(stainlessPath, language);
|
|
28
|
+
if (!snippets) return void 0;
|
|
29
|
+
return Object.keys(snippets).flatMap((key) => {
|
|
30
|
+
const customPrefix = "custom:";
|
|
31
|
+
if (key.startsWith(customPrefix)) return `${customPrefix}${key.slice(7)}`;
|
|
32
|
+
if (key === "default") return "default";
|
|
33
|
+
return [];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/** Find a custom snippet named Default (case-insensitive); otherwise use the generated default */
|
|
37
|
+
function getDefaultSnippet(snippets) {
|
|
38
|
+
return Object.entries(snippets).find(([key]) => key.toLowerCase() === "custom:default")?.[1] ?? snippets.default;
|
|
39
|
+
}
|
|
40
|
+
function useSnippet(stainlessPath, language, snippetId) {
|
|
41
|
+
const snippets = useSnippets(stainlessPath, language);
|
|
42
|
+
if (!snippets) return void 0;
|
|
43
|
+
if (!snippetId) return getDefaultSnippet(snippets)?.content;
|
|
44
|
+
return snippets?.[snippetId]?.content;
|
|
45
|
+
}
|
|
46
|
+
function useSnippetResponse(stainlessPath, snippetId) {
|
|
47
|
+
const responses = useSpec()?.snippetResponses?.http?.[stainlessPath];
|
|
48
|
+
if (!responses) return void 0;
|
|
49
|
+
if (!snippetId) return getDefaultSnippet(responses);
|
|
50
|
+
return responses[snippetId];
|
|
51
|
+
}
|
|
52
|
+
function useDeclaration(stainlessPath, required, language) {
|
|
53
|
+
const defaultLanguage = useLanguage();
|
|
54
|
+
const decl = useSpec()?.decls?.[language ?? defaultLanguage]?.[stainlessPath];
|
|
55
|
+
if (required && !decl) throw new Error(`Declaration not found for '${stainlessPath}'`);
|
|
56
|
+
return decl;
|
|
57
|
+
}
|
|
58
|
+
function useAvailableLanguages(stainlessPath) {
|
|
59
|
+
const spec = useSpec();
|
|
60
|
+
return Object.keys(spec?.decls ?? {}).filter((lang) => spec?.decls?.[lang]?.[stainlessPath] !== void 0).filter((e) => spec?.docs?.languages?.includes(e));
|
|
61
|
+
}
|
|
62
|
+
function useIgnoredResources() {
|
|
63
|
+
return ["(resource) webhooks > (model) unwrap_webhook_event > (schema)"];
|
|
64
|
+
}
|
|
65
|
+
function useResource(name) {
|
|
66
|
+
return useSpec()?.resources?.[name];
|
|
67
|
+
}
|
|
68
|
+
function useLanguage() {
|
|
69
|
+
return useDocs().language;
|
|
70
|
+
}
|
|
71
|
+
function useContentPanelLayout() {
|
|
72
|
+
return useDocs().settings?.contentPanelLayout ?? "double-pane";
|
|
73
|
+
}
|
|
74
|
+
function DocsProvider({ spec, language, settings, children }) {
|
|
75
|
+
return /* @__PURE__ */ jsx(DocsContext, {
|
|
76
|
+
value: React$1.useMemo(() => ({
|
|
77
|
+
...DocsContextDefaults,
|
|
78
|
+
spec,
|
|
79
|
+
settings: settings ?? DocsContextDefaults.settings,
|
|
80
|
+
language: language ?? DocsContextDefaults.language
|
|
81
|
+
}), [
|
|
82
|
+
spec,
|
|
83
|
+
language,
|
|
84
|
+
settings
|
|
85
|
+
]),
|
|
86
|
+
children
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
export { DocsProvider, useAvailableLanguages, useContentPanelLayout, useDeclaration, useDocs, useIgnoredResources, useLanguage, useResource, useSettings, useSnippet, useSnippetIds, useSnippetResponse, useSnippets, useSpec };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LanguageComponentDefinition } from "../languages/index.js";
|
|
2
|
+
import { NavigationContextType, NavigationHandler, NavigationProvider, NavigationProviderProps, useNavigation } from "./navigation.js";
|
|
3
|
+
import { MarkdownContext, MarkdownProvider, MarkdownProviderProps, useHighlight, useMarkdownContext, useRenderMarkdown } from "./markdown.js";
|
|
4
|
+
import { ComponentProvider, ComponentsContextType, customizeComponents, useComponentContext, useComponents } from "./component-generics.js";
|
|
5
|
+
import { ContentPanelLayout, Declaration, DocsContextType, DocsProvider, DocsProviderProps, PropertySettingsType, useAvailableLanguages, useContentPanelLayout, useDeclaration, useDocs, useIgnoredResources, useLanguage, useResource, useSettings, useSnippet, useSnippetIds, useSnippetResponse, useSnippets, useSpec } from "./docs.js";
|
|
6
|
+
|
|
7
|
+
//#region src/contexts/index.d.ts
|
|
8
|
+
declare namespace index_d_exports {
|
|
9
|
+
export { ComponentProvider, ComponentsContextType, ContentPanelLayout, Declaration, DocsContextType, DocsProvider, DocsProviderProps, MarkdownContext, MarkdownProvider, MarkdownProviderProps, NavigationContextType, NavigationHandler, NavigationProvider, NavigationProviderProps, PropertySettingsType, customizeComponents, useAvailableLanguages, useComponentContext, useComponents, useContentPanelLayout, useDeclaration, useDocs, useHighlight, useIgnoredResources, useLanguage, useLanguageComponents, useMarkdownContext, useNavigation, useRenderMarkdown, useResource, useSettings, useSnippet, useSnippetIds, useSnippetResponse, useSnippets, useSpec };
|
|
10
|
+
}
|
|
11
|
+
declare function useLanguageComponents(): LanguageComponentDefinition;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ComponentProvider, ComponentsContextType, ContentPanelLayout, Declaration, DocsContextType, DocsProvider, DocsProviderProps, MarkdownContext, MarkdownProvider, MarkdownProviderProps, NavigationContextType, NavigationHandler, NavigationProvider, NavigationProviderProps, PropertySettingsType, customizeComponents, index_d_exports as t, useAvailableLanguages, useComponentContext, useComponents, useContentPanelLayout, useDeclaration, useDocs, useHighlight, useIgnoredResources, useLanguage, useLanguageComponents, useMarkdownContext, useNavigation, useRenderMarkdown, useResource, useSettings, useSnippet, useSnippetIds, useSnippetResponse, useSnippets, useSpec };
|