@docs-sdk-dev/solid 0.0.0-stage → 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lenso contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
- # Temporary Holding Version
1
+ # Docs SDK Solid Adapter
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@docs-sdk-dev/solid` supplies the Solid 2 static site renderer and UI SDK example previews for the Docs SDK CLI. Install it alongside Core and CLI at the same version.
4
+
5
+ Import `componentReference` from `@docs-sdk-dev/solid/component-reference` to build pages from exported Solid component functions with local props interfaces. Register each runnable `site/*-example.tsx` as an entry's example source. The module should export a default component. Interactive previews load only when opened. Supply `site/style.css` to override the default stylesheet.
@@ -0,0 +1,49 @@
1
+ import { createSignal } from "solid-js"
2
+ import { render, type JSX } from "@solidjs/web"
3
+ import { Collapsible, CollapsibleTrigger, CollapsiblePanel } from "@ui-sdk/solid/collapsible"
4
+
5
+ type Example = () => JSX.Element
6
+ type Loader = () => Promise<{ default: Example }>
7
+ const examples = import.meta.glob<{ default: Example }>("/site/*-example.tsx")
8
+
9
+ function Playground(props: { name: string; load: Loader }) {
10
+ const [example, setExample] = createSignal<Example>()
11
+ const [error, setError] = createSignal(false)
12
+ let pending: Promise<void> | undefined
13
+ function open(opened: boolean) {
14
+ if (!opened || pending || example()) return
15
+ setError(false)
16
+ pending = props.load().then(module => { setExample(() => module.default) }).catch(() => { setError(true) })
17
+ .finally(() => { pending = undefined })
18
+ }
19
+ return <Collapsible onOpenChange={open}>
20
+ <CollapsibleTrigger aria-label={`Run ${props.name} example`}>Run example</CollapsibleTrigger>
21
+ <CollapsiblePanel>
22
+ <div class="example-body" aria-live="polite">
23
+ {(() => {
24
+ const Component = example()
25
+ if (Component) return <Component />
26
+ return error() ? "Example could not load. Close and reopen to retry." : "Loading example…"
27
+ })()}
28
+ </div>
29
+ </CollapsiblePanel>
30
+ </Collapsible>
31
+ }
32
+
33
+ async function mount() {
34
+ if (["localhost", "127.0.0.1"].includes(location.hostname)
35
+ && new URLSearchParams(location.search).get("agent") === "1") {
36
+ const { createAgent } = await import("@ui-sdk/solid/agent")
37
+ const agent = createAgent({ allow: ({ component }) => component === "collapsible" })
38
+ Object.defineProperty(window, "docsExamples", { value: agent })
39
+ }
40
+ for (const element of document.querySelectorAll<HTMLElement>("[data-docs-example]")) {
41
+ const file = element.dataset.docsExample
42
+ const name = element.dataset.docsExampleName
43
+ if (!file || !name) continue
44
+ const load = examples["/" + file]
45
+ if (load) render(() => <Playground name={name} load={load} />, element)
46
+ }
47
+ }
48
+
49
+ void mount()
@@ -0,0 +1,60 @@
1
+ import { renderToString } from "@solidjs/web"
2
+ import type { Document } from "@docs-sdk-dev/core"
3
+
4
+ export function htmlPage(document: Document, documents: Document[], revision: string, assets: { script?: string; styles: string[] }) {
5
+ const examples = document.sections.some(section => section.artifacts.some(artifact => artifact.example))
6
+ const groups = [...new Set(documents.map(page => page.identity.scope))]
7
+ const guides = documents.find(page => page.identity.scope === "guide")
8
+ const releases = documents.find(page => page.identity.scope === "releases")
9
+ const page = renderToString(() => <html lang={document.identity.dimensions.locale ?? "en"}>
10
+ <head>
11
+ <meta charset="utf-8" />
12
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
13
+ <meta name="docs-build" content={revision} />
14
+ <title>{document.title} · Docs SDK</title>
15
+ {assets.styles.map(style => <link rel="stylesheet" href={style} />)}
16
+ {examples && assets.script && <script type="module" src={assets.script}></script>}
17
+ </head>
18
+ <body>
19
+ <a class="skip" href="#main">Skip to content</a>
20
+ <header class="bar">
21
+ <a class="brand" href="/">Docs SDK</a>
22
+ <nav aria-label="Primary">
23
+ <a href={guides?.route ?? "/"}>Docs</a>
24
+ {releases && <a href={releases.route}>Releases</a>}
25
+ </nav>
26
+ <a class="manifest" href="/manifest.json">Manifest ↗</a>
27
+ </header>
28
+ <div class="layout">
29
+ <nav class="sidebar" aria-label="Documentation">
30
+ {groups.map(group => <div class="nav-group">
31
+ <p>{group === "guide" ? "Guide" : group === "components" ? "Components" : group === "releases" ? "Releases" : group}</p>
32
+ {documents.filter(page => page.identity.scope === group).map(page =>
33
+ <a aria-current={page.key === document.key ? "page" : undefined} href={page.route}>{page.title}</a>)}
34
+ </div>)}
35
+ </nav>
36
+ <main id="main">
37
+ <p class="scope">{document.identity.scope}</p>
38
+ <h1>{document.title}</h1>
39
+ {document.sections.map(section =>
40
+ <section id={section.id} aria-labelledby={section.title ? `${section.id}-heading` : undefined}>
41
+ {section.title && <h2 id={`${section.id}-heading`}>{section.title}</h2>}
42
+ {section.artifacts.map(artifact => <>
43
+ <div class="prose" innerHTML={artifact.html}></div>
44
+ {artifact.example && <div class="example" data-docs-example={artifact.example.source} data-docs-example-name={artifact.example.id}></div>}
45
+ </>)}
46
+ </section>)}
47
+ </main>
48
+ <aside class="outline">
49
+ <nav aria-label="On this page">
50
+ {document.sections.some(section => section.title) && <p>On this page</p>}
51
+ {document.sections.filter(section => section.title).map(section =>
52
+ <a href={`#${section.id}`}>{section.title}</a>)}
53
+ </nav>
54
+ <a class="download" href={`/content${document.route}index.md`}>Read as Markdown ↗</a>
55
+ </aside>
56
+ </div>
57
+ </body>
58
+ </html>)
59
+ return "<!doctype html>\n" + page
60
+ }
@@ -0,0 +1,226 @@
1
+ :root {
2
+ color-scheme: light dark;
3
+ --bg: #fcfcfc;
4
+ --fg: #171717;
5
+ --muted: #5d5d5d;
6
+ --line: #e5e5e5;
7
+ --subtle: #f3f3f3;
8
+ --accent: #204fd6;
9
+ font: 15px/1.65 system-ui,sans-serif;
10
+ }
11
+ @media(prefers-color-scheme:dark) {
12
+ :root {
13
+ --bg: #141414;
14
+ --fg: #f4f4f4;
15
+ --muted: #b7b7b7;
16
+ --line: #353535;
17
+ --subtle: #212121;
18
+ --accent: #a8bbff;
19
+ }
20
+ }
21
+ * {
22
+ box-sizing: border-box;
23
+ }
24
+ body {
25
+ margin: 0;
26
+ background: var(--bg);
27
+ color: var(--fg);
28
+ }
29
+ a {
30
+ color: inherit;
31
+ text-decoration: none;
32
+ }
33
+ a:hover {
34
+ text-decoration: underline;
35
+ }
36
+ button {
37
+ font: inherit;
38
+ color: inherit;
39
+ }
40
+ .skip {
41
+ position: absolute;
42
+ left: 1rem;
43
+ top: 1rem;
44
+ transform: translateY(-220%);
45
+ }
46
+ .skip:focus {
47
+ transform: none;
48
+ background: var(--bg);
49
+ z-index: 2;
50
+ }
51
+ .bar {
52
+ display: flex;
53
+ align-items: center;
54
+ gap: 2.5rem;
55
+ padding: 0 2rem;
56
+ border-bottom: 1px solid var(--line);
57
+ height: 64px;
58
+ }
59
+ .brand {
60
+ font-size: 17px;
61
+ font-weight: 650;
62
+ letter-spacing: -.035em;
63
+ }
64
+ .bar nav {
65
+ display: flex;
66
+ gap: 1.3rem;
67
+ }
68
+ .bar nav,.manifest {
69
+ font-size: 14px;
70
+ color: var(--muted);
71
+ }
72
+ .manifest {
73
+ margin-left: auto;
74
+ }
75
+ .layout {
76
+ display: grid;
77
+ grid-template-columns: 220px minmax(0,760px) 180px;
78
+ gap: 3rem;
79
+ max-width: 1340px;
80
+ margin: auto;
81
+ padding: 0 2rem;
82
+ }
83
+ .sidebar {
84
+ border-right: 1px solid var(--line);
85
+ padding: 3rem 1.25rem 2rem 0;
86
+ }
87
+ .nav-group {
88
+ margin-bottom: 1.6rem;
89
+ }
90
+ .nav-group p,.outline p {
91
+ margin: 0 0 .45rem;
92
+ font-size: 13px;
93
+ font-weight: 650;
94
+ }
95
+ .sidebar a,.outline a {
96
+ display: block;
97
+ color: var(--muted);
98
+ font-size: 13px;
99
+ padding: .22rem 0;
100
+ }
101
+ .sidebar a {
102
+ padding-left: .55rem;
103
+ border-radius: 5px;
104
+ }
105
+ .sidebar [aria-current] {
106
+ background: var(--subtle);
107
+ color: var(--fg);
108
+ font-weight: 600;
109
+ }
110
+ main {
111
+ padding: 3rem 0 5rem;
112
+ min-width: 0;
113
+ }
114
+ .scope {
115
+ font: 12px ui-monospace,monospace;
116
+ color: var(--muted);
117
+ text-transform: capitalize;
118
+ margin: 0;
119
+ }
120
+ h1 {
121
+ font-size: clamp(2rem,5vw,3.1rem);
122
+ line-height: 1.13;
123
+ letter-spacing: -.055em;
124
+ margin: .55rem 0 1.5rem;
125
+ }
126
+ h2 {
127
+ font-size: 1.4rem;
128
+ letter-spacing: -.025em;
129
+ margin: 2rem 0 .6rem;
130
+ }
131
+ section {
132
+ scroll-margin-top: 1rem;
133
+ }
134
+ .prose a {
135
+ color: var(--accent);
136
+ text-decoration: underline;
137
+ }
138
+ .outline {
139
+ padding-top: 3rem;
140
+ }
141
+ .download {
142
+ margin-top: 1.15rem;
143
+ }
144
+ pre,table,.example:not(:empty) {
145
+ border: 1px solid var(--line);
146
+ border-radius: 8px;
147
+ }
148
+ pre {
149
+ padding: 1rem;
150
+ overflow: auto;
151
+ background: var(--subtle);
152
+ }
153
+ code {
154
+ font-size: .89em;
155
+ }
156
+ table {
157
+ border-spacing: 0;
158
+ width: 100%;
159
+ font-size: 14px;
160
+ }
161
+ th,td {
162
+ text-align: left;
163
+ padding: .5rem .75rem;
164
+ border-bottom: 1px solid var(--line);
165
+ }
166
+ tr:last-child td {
167
+ border: 0;
168
+ }
169
+ .example:not(:empty) {
170
+ padding: .75rem;
171
+ margin-top: 1rem;
172
+ }
173
+ .example button {
174
+ background: var(--subtle);
175
+ border: 1px solid var(--line);
176
+ border-radius: 6px;
177
+ padding: .35rem .75rem;
178
+ cursor: pointer;
179
+ }
180
+ .example-body {
181
+ padding: 1rem .35rem .25rem;
182
+ }
183
+ .callout {
184
+ border-left: 2px solid var(--accent);
185
+ padding: .25rem .75rem;
186
+ }
187
+ @media(max-width:900px) {
188
+ .layout {
189
+ grid-template-columns: 175px minmax(0,1fr);
190
+ gap: 1.75rem;
191
+ }
192
+ .outline {
193
+ grid-column: 2;
194
+ padding: 0 0 2rem;
195
+ }
196
+ .sidebar {
197
+ grid-row: 1/3;
198
+ }
199
+ }
200
+ @media(max-width:560px) {
201
+ .layout {
202
+ display: block;
203
+ padding: 0 1rem;
204
+ }
205
+ .bar {
206
+ padding: 0 1rem;
207
+ gap: 1rem;
208
+ }
209
+ .sidebar {
210
+ border: 0;
211
+ border-bottom: 1px solid var(--line);
212
+ padding: 1rem 0;
213
+ display: flex;
214
+ flex-wrap: wrap;
215
+ gap: .75rem 1.15rem;
216
+ }
217
+ .nav-group {
218
+ margin: 0;
219
+ }
220
+ .sidebar a {
221
+ padding-left: 0;
222
+ }
223
+ main {
224
+ padding: 1.5rem 0;
225
+ }
226
+ }
@@ -0,0 +1,20 @@
1
+ import { type Entry, type ReadSource } from "@docs-sdk-dev/core";
2
+ type ComponentInput = {
3
+ source: string;
4
+ export: string;
5
+ example: string;
6
+ summary: string;
7
+ accessibility: string;
8
+ };
9
+ type ComponentData = ComponentInput & {
10
+ code: string;
11
+ properties: string;
12
+ revision: string;
13
+ };
14
+ export declare function componentReference(options: {
15
+ id: string;
16
+ scope: string;
17
+ templateConfig?: string;
18
+ entries: readonly Entry<ComponentInput>[];
19
+ }, read: ReadSource): import("@docs-sdk-dev/core").Collection<ComponentData>;
20
+ export {};
@@ -0,0 +1,50 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFileSync } from "node:fs";
3
+ import ts from "typescript";
4
+ import { DocsError, defineCollection, defineTemplate, markdown } from "@docs-sdk-dev/core";
5
+ const quote = (text) => text.replaceAll("|", "\\|").replaceAll("\n", " ");
6
+ function codeFence(code) {
7
+ const fence = "`".repeat(Math.max(2, ...[...code.matchAll(/`+/g)].map(match => match[0].length)) + 1);
8
+ return `${fence}tsx\n${code.trim()}\n${fence}`;
9
+ }
10
+ async function extract(input, read) {
11
+ const [component, example] = await Promise.all([read(input.source), read(input.example)]);
12
+ const file = ts.createSourceFile(input.source, component.text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
13
+ const fn = file.statements.find(node => ts.isFunctionDeclaration(node) && node.name?.text === input.export
14
+ && node.modifiers?.some(modifier => modifier.kind === ts.SyntaxKind.ExportKeyword));
15
+ const type = fn?.parameters[0]?.type?.getText(file);
16
+ const props = file.statements.find(node => ts.isInterfaceDeclaration(node) && node.name.text === type);
17
+ if (!props)
18
+ throw new DocsError("DOCS_COMPONENT_PROPS", "Expected an exported component with a local props interface.", { source: input.source });
19
+ const rows = props.members.filter(ts.isPropertySignature).map(property => {
20
+ const doc = ts.getJSDocCommentsAndTags(property).find(ts.isJSDoc)?.comment;
21
+ return `| \`${property.name.getText(file)}\` | \`${quote(property.type?.getText(file) ?? "unknown")}\` | ${property.questionToken ? "No" : "Yes"} | ${quote(typeof doc === "string" ? doc : "")} |`;
22
+ });
23
+ return { ...input, code: example.text, revision: component.revision,
24
+ properties: ["| Prop | Type | Required | Description |", "| --- | --- | --- | --- |", ...rows].join("\n") };
25
+ }
26
+ const component = defineTemplate({
27
+ id: "component-reference", source: "@docs-sdk-dev/solid/component-reference",
28
+ revision: createHash("sha256").update(readFileSync(new URL(import.meta.url))).digest("hex"),
29
+ sections: [
30
+ { id: "overview", required: true, build: ({ data }) => markdown(data.summary) },
31
+ { id: "installation", title: "Installation", build: ({ data }) => markdown(`Copy \`${data.source}\` into a Solid 2 project with \`@solidjs/web\`.`) },
32
+ { id: "preview", title: "Preview", build: ({ data }) => ({
33
+ markdown: `The ${data.export} example below demonstrates the component's default state and content.`,
34
+ source: data.example, example: { id: data.export, source: data.example },
35
+ }) },
36
+ { id: "usage", title: "Usage", build: ({ data }) => markdown(codeFence(`import { ${data.export} } from "./${data.source.split("/").at(-1)}"`), data.source) },
37
+ { id: "examples", title: "Examples", build: ({ data }) => markdown(codeFence(data.code), data.example) },
38
+ { id: "props", title: "Props", required: true, build: ({ data }) => markdown(data.properties, data.source) },
39
+ { id: "accessibility", title: "Accessibility", build: ({ data }) => markdown(data.accessibility) },
40
+ { id: "source", title: "Source", build: ({ data }) => markdown(`\`${data.source}\` exports \`${data.export}\` at revision \`${data.revision.slice(0, 12)}\`.`, data.source) },
41
+ ],
42
+ });
43
+ export function componentReference(options, read) {
44
+ return defineCollection({
45
+ id: options.id, scope: options.scope, templateConfig: options.templateConfig, template: component,
46
+ async load() {
47
+ return Promise.all(options.entries.map(async (entry) => entry.replace !== undefined ? entry : { ...entry, data: await extract(entry.data, read) }));
48
+ },
49
+ });
50
+ }
@@ -0,0 +1,15 @@
1
+ import type { Document } from "@docs-sdk-dev/core";
2
+ type Assets = {
3
+ script: string;
4
+ styles: string[];
5
+ };
6
+ type Render = (document: Document, documents: Document[], revision: string, assets: Assets) => string;
7
+ export declare function buildSite(root: string, stage: string, css?: string): Promise<{
8
+ render: Render;
9
+ assets: {
10
+ script: string;
11
+ styles: string[];
12
+ };
13
+ examples: Set<string>;
14
+ }>;
15
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFile, writeFile } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
+ import solid from "@solidjs/vite-plugin";
6
+ import { build } from "vite";
7
+ export async function buildSite(root, stage, css) {
8
+ const server = join(stage, "server");
9
+ const output = join(stage, "public");
10
+ const renderer = fileURLToPath(new URL("../assets/render.tsx", import.meta.url));
11
+ const client = fileURLToPath(new URL("../assets/client.tsx", import.meta.url));
12
+ const common = { root, configFile: false, logLevel: "silent", publicDir: false };
13
+ await build({ ...common, plugins: [solid()], build: {
14
+ outDir: server, ssr: renderer, minify: false,
15
+ } });
16
+ const { htmlPage } = await import(pathToFileURL(join(server, "render.js")).href);
17
+ await build({ ...common, plugins: [solid()], build: {
18
+ outDir: output, manifest: true, rolldownOptions: { input: client },
19
+ } });
20
+ const manifest = JSON.parse(await readFile(join(output, ".vite/manifest.json"), "utf8"));
21
+ const entry = Object.values(manifest).find(chunk => chunk.isEntry);
22
+ if (!entry)
23
+ throw new Error("Missing Solid client entry in the Vite manifest.");
24
+ const styles = css ?? await readFile(new URL("../assets/style.css", import.meta.url), "utf8");
25
+ const hash = createHash("sha256").update(styles).digest("hex").slice(0, 12);
26
+ const style = `/assets/docs-${hash}.css`;
27
+ await writeFile(join(output, style), styles);
28
+ const examples = new Set(Object.entries(manifest).filter(([, chunk]) => chunk.isDynamicEntry).map(([file]) => file));
29
+ return { render: htmlPage, assets: { script: "/" + entry.file, styles: [style] }, examples };
30
+ }
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "@docs-sdk-dev/solid",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "Solid 2 static site adapter and component reference preset for Docs SDK",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=22.12.0"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "files": [
14
+ "dist/*.js",
15
+ "dist/*.d.ts",
16
+ "assets"
17
+ ],
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "./component-reference": {
24
+ "types": "./dist/component-reference.d.ts",
25
+ "default": "./dist/component-reference.js"
26
+ }
27
+ },
28
+ "dependencies": {
29
+ "@docs-sdk-dev/core": "0.0.1",
30
+ "@solidjs/vite-plugin": "3.0.1",
31
+ "@solidjs/web": "2.0.3",
32
+ "@ui-sdk/core": "0.1.0-beta.16",
33
+ "@ui-sdk/solid": "0.1.0-beta.16",
34
+ "solid-js": "2.0.3",
35
+ "typescript": "6.0.3",
36
+ "vite": "8.3.8"
37
+ }
38
+ }