@clidey/dory 0.30.0 → 0.31.0
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/bin/dist/dory.js +1 -8
- package/bin/dist/dory.js.map +1 -1
- package/index.html +54 -0
- package/package.json +12 -4
- package/src/app.css +5 -0
- package/src/app.tsx +13 -0
- package/src/components/dropdown.tsx +53 -0
- package/src/components/hooks.tsx +36 -0
- package/src/components/loading.tsx +21 -0
- package/src/components/mdx-provider.tsx +13 -0
- package/src/components/navigation.tsx +58 -0
- package/src/components/notification.tsx +13 -0
- package/src/components/routes.tsx +92 -0
- package/src/components/search-index.ts +43 -0
- package/src/components/search.tsx +448 -0
- package/src/components/store.ts +216 -0
- package/src/config/mdx.js +12 -0
- package/src/config/mdx.ts +12 -0
- package/src/embed/loader.ts +200 -0
- package/src/embed/types.ts +54 -0
- package/src/embed/widget-iframe.ts +302 -0
- package/src/main.tsx +22 -0
- package/src/mdx/accordion.tsx +41 -0
- package/src/mdx/api-playground.tsx +659 -0
- package/src/mdx/api.tsx +354 -0
- package/src/mdx/async-api.tsx +353 -0
- package/src/mdx/callout.tsx +64 -0
- package/src/mdx/card.tsx +54 -0
- package/src/mdx/code.tsx +289 -0
- package/src/mdx/expandable.tsx +36 -0
- package/src/mdx/fence.tsx +74 -0
- package/src/mdx/icon.tsx +73 -0
- package/src/mdx/latex.tsx +26 -0
- package/src/mdx/list.tsx +7 -0
- package/src/mdx/mdx.tsx +47 -0
- package/src/mdx/mermaid.tsx +147 -0
- package/src/mdx/open-api.tsx +311 -0
- package/src/mdx/processor.ts +174 -0
- package/src/mdx/source.tsx +58 -0
- package/src/mdx/step.tsx +51 -0
- package/src/mdx/table.tsx +20 -0
- package/src/mdx/tag.tsx +53 -0
- package/src/mdx/text.tsx +99 -0
- package/src/mdx/websocket-playground.tsx +824 -0
- package/src/plugins/docs-assets.ts +79 -0
- package/src/plugins/frontmatter-dev-server.ts +158 -0
- package/src/plugins/frontmatter-generator.ts +157 -0
- package/src/plugins/html-files-middleware.ts +108 -0
- package/src/plugins/html-metadata-injector.ts +76 -0
- package/src/plugins/llm-txt-dev-server.ts +183 -0
- package/src/plugins/llm-txt-generator.ts +186 -0
- package/src/plugins/sanitize.ts +163 -0
- package/src/plugins/unified-mdx-plugin.ts +35 -0
- package/src/sdk/index.ts +89 -0
- package/src/sdk/react.tsx +139 -0
- package/src/sdk/vue.ts +107 -0
- package/src/theme.scss +72 -0
- package/src/types/config.ts +89 -0
- package/src/ui/header.tsx +96 -0
- package/src/ui/layout.tsx +237 -0
- package/src/ui/mobile-navigation.tsx +72 -0
- package/src/ui/prev-next-link.tsx +74 -0
- package/src/ui/table-of-content.tsx +167 -0
- package/src/utils/colors.ts +54 -0
- package/src/utils/fonts.ts +23 -0
- package/src/utils/functions.ts +12 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.app.json +33 -0
- package/tsconfig.bin.json +25 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.embed-loader.ts +28 -0
- package/vite.config.embed-widget.ts +31 -0
- package/vite.config.ts +45 -0
package/src/mdx/step.tsx
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import classNames from "classnames"
|
|
2
|
+
import { Children } from "preact/compat"
|
|
3
|
+
|
|
4
|
+
export function Steps({ children }: { children: preact.ComponentChildren }) {
|
|
5
|
+
const steps = Children.toArray(children) as preact.ComponentChildren[];
|
|
6
|
+
return (
|
|
7
|
+
<nav aria-label="Progress" className="py-16">
|
|
8
|
+
<div className="overflow-hidden">
|
|
9
|
+
{steps.map((step, stepIdx) => {
|
|
10
|
+
const stepElement = Children.toArray(step)[0] as preact.JSX.Element;
|
|
11
|
+
return (
|
|
12
|
+
<div key={stepIdx} className={classNames(
|
|
13
|
+
{
|
|
14
|
+
"pb-10": stepIdx !== steps.length - 1,
|
|
15
|
+
"pb-2": stepIdx === steps.length - 1,
|
|
16
|
+
},
|
|
17
|
+
'relative'
|
|
18
|
+
)}>
|
|
19
|
+
<div aria-hidden="true" className="absolute top-10 left-4 h-full w-[0.5px] bg-gray-300/50 dark:bg-gray-600/50" style={{ top: '40px', height: 'calc(100% - 44px)' }} />
|
|
20
|
+
<div className="group relative flex items-start">
|
|
21
|
+
<span className="flex h-9 items-center">
|
|
22
|
+
<span className="relative z-10 flex size-8 items-center justify-center rounded-full bg-white dark:bg-gray-800 group-hover:border-gray-400">
|
|
23
|
+
<span className="text-sm font-medium text-gray-500 dark:text-white">
|
|
24
|
+
{stepIdx + 1}
|
|
25
|
+
</span>
|
|
26
|
+
</span>
|
|
27
|
+
</span>
|
|
28
|
+
<span className="ml-4 flex min-w-0 flex-col">
|
|
29
|
+
<p className="text-lg font-medium text-inherit">{stepElement.props.title}</p>
|
|
30
|
+
</span>
|
|
31
|
+
</div>
|
|
32
|
+
<div className="ml-12 not-prose">
|
|
33
|
+
{stepElement.props.children}
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
})}
|
|
38
|
+
</div>
|
|
39
|
+
</nav>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function Step({
|
|
44
|
+
title: _title,
|
|
45
|
+
children
|
|
46
|
+
}: {
|
|
47
|
+
title?: string;
|
|
48
|
+
children: preact.ComponentChildren
|
|
49
|
+
}) {
|
|
50
|
+
return <p className='text-sm'>{children}</p>
|
|
51
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { JSX } from 'preact/jsx-runtime';
|
|
2
|
+
import {
|
|
3
|
+
Table as UXTable,
|
|
4
|
+
TableHead,
|
|
5
|
+
TableCell
|
|
6
|
+
} from '@clidey/ux'
|
|
7
|
+
|
|
8
|
+
export const Table = (props: JSX.IntrinsicElements['table']) => (
|
|
9
|
+
<div className="overflow-x-auto rounded-lg my-8">
|
|
10
|
+
<UXTable {...props} />
|
|
11
|
+
</div>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export const Th = (props: JSX.IntrinsicElements['th']) => (
|
|
15
|
+
<TableHead {...props} />
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export const Td = (props: JSX.IntrinsicElements['td']) => (
|
|
19
|
+
<TableCell {...props} />
|
|
20
|
+
);
|
package/src/mdx/tag.tsx
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Badge } from '@clidey/ux'
|
|
2
|
+
import classNames from 'classnames'
|
|
3
|
+
|
|
4
|
+
const valueColorMap = {
|
|
5
|
+
GET: 'default',
|
|
6
|
+
POST: 'secondary',
|
|
7
|
+
PUT: 'outline',
|
|
8
|
+
DELETE: 'destructive',
|
|
9
|
+
} as const
|
|
10
|
+
|
|
11
|
+
const customColorClasses = {
|
|
12
|
+
emerald: 'bg-emerald-400/10 text-emerald-500 dark:text-emerald-400 border-emerald-300 dark:border-emerald-400/30',
|
|
13
|
+
sky: 'bg-sky-400/10 text-sky-500 dark:text-sky-400 border-sky-300 dark:border-sky-400/30',
|
|
14
|
+
amber: 'bg-amber-400/10 text-amber-500 dark:text-amber-400 border-amber-300 dark:border-amber-400/30',
|
|
15
|
+
rose: 'bg-rose-50 text-red-500 dark:bg-rose-400/10 dark:text-rose-400 border-rose-200 dark:border-rose-500/20',
|
|
16
|
+
zinc: 'bg-zinc-50 text-zinc-500 dark:bg-zinc-400/10 dark:text-zinc-400 border-zinc-200 dark:border-zinc-500/20',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const methodColors: Record<string, keyof typeof customColorClasses> = {
|
|
20
|
+
GET: 'emerald',
|
|
21
|
+
POST: 'sky',
|
|
22
|
+
PUT: 'amber',
|
|
23
|
+
DELETE: 'rose',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function Tag({
|
|
27
|
+
children,
|
|
28
|
+
variant = 'medium',
|
|
29
|
+
color,
|
|
30
|
+
className,
|
|
31
|
+
}: {
|
|
32
|
+
children: string
|
|
33
|
+
variant?: 'small' | 'medium'
|
|
34
|
+
color?: keyof typeof customColorClasses
|
|
35
|
+
className?: string
|
|
36
|
+
}) {
|
|
37
|
+
const colorKey = color || methodColors[children] || 'zinc'
|
|
38
|
+
const badgeVariant = valueColorMap[children as keyof typeof valueColorMap] || 'outline'
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Badge
|
|
42
|
+
variant={badgeVariant}
|
|
43
|
+
className={classNames(
|
|
44
|
+
'font-mono text-[0.625rem]/6 font-semibold',
|
|
45
|
+
customColorClasses[colorKey],
|
|
46
|
+
variant === 'small' && 'px-1 py-0',
|
|
47
|
+
className,
|
|
48
|
+
)}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</Badge>
|
|
52
|
+
)
|
|
53
|
+
}
|
package/src/mdx/text.tsx
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { cn } from "@clidey/ux"
|
|
2
|
+
import classNames from "classnames"
|
|
3
|
+
import { useState } from "preact/hooks"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const h1 = function H1(props: preact.JSX.HTMLAttributes<HTMLHeadingElement>) {
|
|
7
|
+
return <h1 className="text-4xl font-bold mb-4 mt-12" {...props} />
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const h2 = function H2(props: preact.JSX.HTMLAttributes<HTMLHeadingElement>) {
|
|
11
|
+
return <h2 className="text-3xl font-bold mb-3 mt-10" {...props} />
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const h3 = function H3(props: preact.JSX.HTMLAttributes<HTMLHeadingElement>) {
|
|
15
|
+
return <h3 className="text-2xl font-bold mb-2 mt-8" {...props} />
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const h4 = function H4(props: preact.JSX.HTMLAttributes<HTMLHeadingElement>) {
|
|
19
|
+
return <h4 className="text-xl font-bold mb-2 mt-6" {...props} />
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const h5 = function H5(props: preact.JSX.HTMLAttributes<HTMLHeadingElement>) {
|
|
23
|
+
return <h5 className="text-lg font-bold mb-2" {...props} />
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const h6 = function H6(props: preact.JSX.HTMLAttributes<HTMLHeadingElement>) {
|
|
27
|
+
return <h6 className="text-base font-bold mb-2" {...props} />
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const p = function P(props: preact.JSX.HTMLAttributes<HTMLParagraphElement>) {
|
|
31
|
+
return <p className="mb-2 inline-block" {...props} />
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function Row({ children, cols = 1, className }: { children: preact.ComponentChildren, cols?: number, className?: string }) {
|
|
35
|
+
return (
|
|
36
|
+
<div className={cn(`py-6 grid grid-cols-1 items-start gap-x-16 gap-y-10 xl:max-w-none`, className)} style={{ gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))` }}>
|
|
37
|
+
{children}
|
|
38
|
+
</div>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function Col({
|
|
43
|
+
children,
|
|
44
|
+
sticky = false,
|
|
45
|
+
rows = 1,
|
|
46
|
+
gap = 4
|
|
47
|
+
}: {
|
|
48
|
+
children: preact.ComponentChildren
|
|
49
|
+
sticky?: boolean
|
|
50
|
+
rows?: number
|
|
51
|
+
gap?: number
|
|
52
|
+
}) {
|
|
53
|
+
return (
|
|
54
|
+
<div
|
|
55
|
+
className={classNames("[&>:first-child]:mt-0 [&>:last-child]:mb-0", {
|
|
56
|
+
'xl:sticky xl:top-24': sticky,
|
|
57
|
+
})}
|
|
58
|
+
style={{
|
|
59
|
+
display: 'grid',
|
|
60
|
+
gridTemplateRows: `repeat(${rows}, minmax(0, 1fr))`,
|
|
61
|
+
gap: `${gap * 0.25}rem`
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
{children}
|
|
65
|
+
</div>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
export function Anchor({ children, href }: { children: preact.ComponentChildren, href: string }) {
|
|
71
|
+
return <a href={href} className="text-blue-500 hover:text-blue-600">{children}</a>
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function Image({ src, alt }: { src: string, alt: string }) {
|
|
75
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<>
|
|
79
|
+
<img
|
|
80
|
+
src={src}
|
|
81
|
+
alt={alt}
|
|
82
|
+
className="w-full h-auto cursor-pointer"
|
|
83
|
+
onClick={() => setIsExpanded(true)}
|
|
84
|
+
/>
|
|
85
|
+
{isExpanded && (
|
|
86
|
+
<div
|
|
87
|
+
className="fixed inset-0 bg-black bg-opacity-90 z-50 flex items-center justify-center"
|
|
88
|
+
onClick={() => setIsExpanded(false)}
|
|
89
|
+
>
|
|
90
|
+
<img
|
|
91
|
+
src={src}
|
|
92
|
+
alt={alt}
|
|
93
|
+
className="max-h-[90vh] max-w-[90vw] object-contain"
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
</>
|
|
98
|
+
);
|
|
99
|
+
}
|