sdocs 0.0.15 → 0.0.16
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/sdocs.js +1 -1
- package/dist/client/App.svelte +16 -39
- package/dist/client/App.svelte.d.ts +1 -1
- package/dist/client/favicon.png +0 -0
- package/dist/client/tree-builder.js +57 -14
- package/dist/client/{CollapsiblePanel.svelte → views/CollapsiblePanel.svelte} +5 -5
- package/dist/client/{ComponentView.svelte → views/ComponentView.svelte} +39 -13
- package/dist/client/{ComponentView.svelte.d.ts → views/ComponentView.svelte.d.ts} +1 -1
- package/dist/client/{ControlsPanel.svelte → views/ControlsPanel.svelte} +10 -15
- package/dist/client/{ControlsPanel.svelte.d.ts → views/ControlsPanel.svelte.d.ts} +1 -1
- package/dist/client/{DataTable.svelte → views/DataTable.svelte} +8 -8
- package/dist/client/{HomePage.svelte → views/HomePage.svelte} +10 -8
- package/dist/client/{HomePage.svelte.d.ts → views/HomePage.svelte.d.ts} +1 -1
- package/dist/client/{LayoutView.svelte → views/LayoutView.svelte} +1 -1
- package/dist/client/{LayoutView.svelte.d.ts → views/LayoutView.svelte.d.ts} +1 -1
- package/dist/client/{PageView.svelte → views/PageView.svelte} +7 -7
- package/dist/client/{PageView.svelte.d.ts → views/PageView.svelte.d.ts} +1 -1
- package/dist/client/{PreviewFrame.svelte → views/PreviewFrame.svelte} +10 -3
- package/dist/client/views/Sidebar.svelte +369 -0
- package/dist/client/{Sidebar.svelte.d.ts → views/Sidebar.svelte.d.ts} +2 -2
- package/dist/commands/build.js +2 -2
- package/dist/commands/dev.js +2 -2
- package/dist/commands/init.js +4 -4
- package/dist/commands/preview.js +1 -1
- package/dist/{app-gen.d.ts → server/app-gen.d.ts} +1 -1
- package/dist/{app-gen.js → server/app-gen.js} +4 -4
- package/dist/{cli.js → server/cli.js} +4 -4
- package/dist/{config.d.ts → server/config.d.ts} +1 -1
- package/dist/{config.js → server/config.js} +7 -2
- package/dist/server/discovery.d.ts +1 -1
- package/dist/server/discovery.js +1 -1
- package/dist/server/meta-parser.js +1 -1
- package/dist/server/prop-parser.js +12 -4
- package/dist/server/snippet-compiler.js +8 -0
- package/dist/server/snippet-extractor.d.ts +1 -1
- package/dist/server/snippet-extractor.js +40 -5
- package/dist/server/toc-extractor.d.ts +0 -2
- package/dist/server/toc-extractor.js +0 -14
- package/dist/types.d.ts +3 -3
- package/dist/ui/About.page.sdoc +37 -0
- package/dist/ui/Button/Button.sdoc +51 -0
- package/dist/ui/Button/Button.svelte +90 -0
- package/dist/ui/Button/Button.svelte.d.ts +27 -0
- package/dist/ui/Button/index.d.ts +1 -0
- package/dist/ui/Button/index.js +1 -0
- package/dist/ui/Control/Checkbox.sdoc +17 -0
- package/dist/{client/controls/CheckboxControl.svelte → ui/Control/Checkbox.svelte} +1 -1
- package/dist/ui/Control/Checkbox.svelte.d.ts +8 -0
- package/dist/ui/Control/Color.sdoc +17 -0
- package/dist/{client/controls/ColorControl.svelte → ui/Control/Color.svelte} +4 -4
- package/dist/ui/Control/Color.svelte.d.ts +8 -0
- package/dist/ui/Control/Dimension.sdoc +17 -0
- package/dist/{client/controls/DimensionControl.svelte → ui/Control/Dimension.svelte} +5 -5
- package/dist/ui/Control/Dimension.svelte.d.ts +8 -0
- package/dist/ui/Control/Number.sdoc +17 -0
- package/dist/{client/controls/NumberControl.svelte → ui/Control/Number.svelte} +4 -4
- package/dist/ui/Control/Number.svelte.d.ts +8 -0
- package/dist/ui/Control/Select.sdoc +18 -0
- package/dist/{client/controls/SelectControl.svelte → ui/Control/Select.svelte} +4 -4
- package/dist/ui/Control/Select.svelte.d.ts +9 -0
- package/dist/ui/Control/Text.sdoc +17 -0
- package/dist/{client/controls/TextControl.svelte → ui/Control/Text.svelte} +4 -4
- package/dist/ui/Control/Text.svelte.d.ts +8 -0
- package/dist/ui/Control/index.d.ts +6 -0
- package/dist/ui/Control/index.js +6 -0
- package/dist/ui/Dashboard.layout.sdoc +60 -0
- package/dist/ui/Frame/Frame.sdoc +54 -0
- package/dist/ui/Frame/Frame.svelte +88 -0
- package/dist/ui/Frame/Frame.svelte.d.ts +15 -0
- package/dist/ui/Frame/index.d.ts +1 -0
- package/dist/ui/Frame/index.js +1 -0
- package/dist/ui/Icon/Icon.sdoc +45 -0
- package/dist/ui/Icon/Icon.svelte +47 -0
- package/dist/ui/Icon/Icon.svelte.d.ts +16 -0
- package/dist/ui/Icon/icons/bookmark.svg +1 -0
- package/dist/ui/Icon/icons/chevron-down.svg +1 -0
- package/dist/ui/Icon/icons/chevron-left.svg +1 -0
- package/dist/ui/Icon/icons/chevron-right.svg +1 -0
- package/dist/ui/Icon/icons/chevron-up.svg +1 -0
- package/dist/ui/Icon/icons/code.svg +1 -0
- package/dist/ui/Icon/icons/component.svg +1 -0
- package/dist/ui/Icon/icons/copy.svg +1 -0
- package/dist/ui/Icon/icons/diamond.svg +1 -0
- package/dist/ui/Icon/icons/file-code.svg +1 -0
- package/dist/ui/Icon/icons/file-text.svg +1 -0
- package/dist/ui/Icon/icons/folder-open.svg +1 -0
- package/dist/ui/Icon/icons/folder.svg +1 -0
- package/dist/ui/Icon/icons/panels-top-left.svg +1 -0
- package/dist/ui/Icon/icons/sdocs.svg +8 -0
- package/dist/ui/Icon/index.d.ts +1 -0
- package/dist/ui/Icon/index.js +1 -0
- package/dist/ui/NavTree/Group.sdoc +46 -0
- package/dist/ui/NavTree/Group.svelte +82 -0
- package/dist/ui/NavTree/Group.svelte.d.ts +11 -0
- package/dist/ui/NavTree/Item.sdoc +70 -0
- package/dist/ui/NavTree/Item.svelte +164 -0
- package/dist/ui/NavTree/Item.svelte.d.ts +33 -0
- package/dist/ui/NavTree/NavTree.sdoc +119 -0
- package/dist/ui/NavTree/NavTree.svelte +31 -0
- package/dist/ui/NavTree/NavTree.svelte.d.ts +8 -0
- package/dist/ui/NavTree/index.js +6 -0
- package/dist/ui/Stack/Stack.sdoc +44 -0
- package/dist/ui/Stack/Stack.svelte +41 -0
- package/dist/ui/Stack/Stack.svelte.d.ts +19 -0
- package/dist/ui/Stack/index.d.ts +1 -0
- package/dist/ui/Stack/index.js +1 -0
- package/dist/ui/index.d.ts +6 -0
- package/dist/ui/index.js +6 -0
- package/dist/{client/theme.css → ui/styles/fonts.css} +0 -37
- package/dist/ui/styles/theme.css +910 -0
- package/dist/vite.js +47 -51
- package/package.json +5 -2
- package/dist/client/Sidebar.svelte +0 -329
- package/dist/client/controls/CheckboxControl.svelte.d.ts +0 -8
- package/dist/client/controls/ColorControl.svelte.d.ts +0 -8
- package/dist/client/controls/DimensionControl.svelte.d.ts +0 -8
- package/dist/client/controls/NumberControl.svelte.d.ts +0 -8
- package/dist/client/controls/SelectControl.svelte.d.ts +0 -9
- package/dist/client/controls/TextControl.svelte.d.ts +0 -8
- package/dist/server/sdocx-parser.d.ts +0 -11
- package/dist/server/sdocx-parser.js +0 -197
- /package/dist/client/{CollapsiblePanel.svelte.d.ts → views/CollapsiblePanel.svelte.d.ts} +0 -0
- /package/dist/client/{DataTable.svelte.d.ts → views/DataTable.svelte.d.ts} +0 -0
- /package/dist/client/{PreviewFrame.svelte.d.ts → views/PreviewFrame.svelte.d.ts} +0 -0
- /package/dist/{cli.d.ts → server/cli.d.ts} +0 -0
- /package/dist/{client → ui/styles}/fonts/figtree-italic-latin-ext.woff2 +0 -0
- /package/dist/{client → ui/styles}/fonts/figtree-italic-latin.woff2 +0 -0
- /package/dist/{client → ui/styles}/fonts/figtree-latin-ext.woff2 +0 -0
- /package/dist/{client → ui/styles}/fonts/figtree-latin.woff2 +0 -0
- /package/dist/{client → ui/styles}/fonts/jetbrains-mono-italic-latin-ext.woff2 +0 -0
- /package/dist/{client → ui/styles}/fonts/jetbrains-mono-italic-latin.woff2 +0 -0
- /package/dist/{client → ui/styles}/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
- /package/dist/{client → ui/styles}/fonts/jetbrains-mono-latin.woff2 +0 -0
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { compile } from 'mdsvex';
|
|
2
|
-
import { resolve, dirname } from 'node:path';
|
|
3
|
-
import { extractTocFromMarkdown } from './toc-extractor.js';
|
|
4
|
-
/** Parse a .sdocx file (markdown format) */
|
|
5
|
-
export async function parseSdocx(source, filePath, kind) {
|
|
6
|
-
// Compile the full source through mdsvex to extract frontmatter metadata
|
|
7
|
-
const compiled = await compile(source, { extension: '.sdocx' });
|
|
8
|
-
if (!compiled) {
|
|
9
|
-
return {
|
|
10
|
-
meta: { title: guessTitle(filePath) },
|
|
11
|
-
componentPath: null,
|
|
12
|
-
imports: [],
|
|
13
|
-
snippets: [],
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
// Extract metadata from the module script mdsvex generates
|
|
17
|
-
const metadata = extractMetadata(compiled.code);
|
|
18
|
-
const { title, description } = extractTitleAndDescription(source);
|
|
19
|
-
const meta = {
|
|
20
|
-
title: title ?? guessTitle(filePath),
|
|
21
|
-
description,
|
|
22
|
-
args: metadata.args,
|
|
23
|
-
settings: metadata.settings,
|
|
24
|
-
};
|
|
25
|
-
// Resolve component path for component kind
|
|
26
|
-
let componentPath = null;
|
|
27
|
-
if (kind === 'component' && metadata.component) {
|
|
28
|
-
componentPath = resolve(dirname(filePath), metadata.component);
|
|
29
|
-
}
|
|
30
|
-
// Extract user <script> imports (not the module script mdsvex adds)
|
|
31
|
-
const imports = extractUserImports(source);
|
|
32
|
-
// Auto-import the component if specified and not already imported
|
|
33
|
-
if (componentPath && metadata.component) {
|
|
34
|
-
const componentName = componentPath.split('/').pop()?.replace('.svelte', '') ?? '';
|
|
35
|
-
const hasImport = imports.some((imp) => imp.includes(componentName));
|
|
36
|
-
if (!hasImport && componentName) {
|
|
37
|
-
imports.unshift(`import ${componentName} from '${metadata.component}'`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
let snippets;
|
|
41
|
-
let toc;
|
|
42
|
-
if (kind === 'component') {
|
|
43
|
-
snippets = await extractComponentSnippets(source, compiled.code);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
// Page/layout: the entire body is one "Content" snippet
|
|
47
|
-
const body = extractMarkdownBody(source);
|
|
48
|
-
const compiledBody = await compile(body, { extension: '.sdocx' });
|
|
49
|
-
const htmlBody = compiledBody
|
|
50
|
-
? removeModuleScript(compiledBody.code)
|
|
51
|
-
: body;
|
|
52
|
-
snippets = [{ name: 'Content', body: htmlBody }];
|
|
53
|
-
if (kind === 'page') {
|
|
54
|
-
toc = extractTocFromMarkdown(body);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return { meta, componentPath, imports, snippets, toc };
|
|
58
|
-
}
|
|
59
|
-
/** Extract metadata from the mdsvex-generated module script */
|
|
60
|
-
function extractMetadata(code) {
|
|
61
|
-
const match = code.match(/export\s+const\s+metadata\s*=\s*(\{[\s\S]*?\});/);
|
|
62
|
-
if (!match)
|
|
63
|
-
return {};
|
|
64
|
-
try {
|
|
65
|
-
return JSON.parse(match[1]);
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
return {};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/** Extract title (# heading) and description (first paragraph after #) from raw markdown */
|
|
72
|
-
function extractTitleAndDescription(source) {
|
|
73
|
-
// Remove frontmatter
|
|
74
|
-
const body = source.replace(/^---[\s\S]*?---\s*/, '');
|
|
75
|
-
const lines = body.split('\n');
|
|
76
|
-
let title = null;
|
|
77
|
-
let description = null;
|
|
78
|
-
for (let i = 0; i < lines.length; i++) {
|
|
79
|
-
const line = lines[i].trim();
|
|
80
|
-
if (!line)
|
|
81
|
-
continue;
|
|
82
|
-
if (line.startsWith('# ') && !title) {
|
|
83
|
-
title = line.slice(2).trim();
|
|
84
|
-
// Look for the first paragraph after the heading
|
|
85
|
-
for (let j = i + 1; j < lines.length; j++) {
|
|
86
|
-
const next = lines[j].trim();
|
|
87
|
-
if (!next)
|
|
88
|
-
continue;
|
|
89
|
-
if (next.startsWith('#') || next.startsWith('<'))
|
|
90
|
-
break;
|
|
91
|
-
description = next;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return { title, description };
|
|
98
|
-
}
|
|
99
|
-
/** Extract user-written <script> imports from raw markdown source */
|
|
100
|
-
function extractUserImports(source) {
|
|
101
|
-
// Remove frontmatter first
|
|
102
|
-
const body = source.replace(/^---[\s\S]*?---\s*/, '');
|
|
103
|
-
const scriptMatch = body.match(/<script[^>]*>([\s\S]*?)<\/script>/);
|
|
104
|
-
if (!scriptMatch)
|
|
105
|
-
return [];
|
|
106
|
-
const imports = [];
|
|
107
|
-
const regex = /^\s*import\s+.+$/gm;
|
|
108
|
-
let match;
|
|
109
|
-
while ((match = regex.exec(scriptMatch[1])) !== null) {
|
|
110
|
-
imports.push(match[0].trim());
|
|
111
|
-
}
|
|
112
|
-
return imports;
|
|
113
|
-
}
|
|
114
|
-
/** Extract the markdown body after frontmatter, removing the # title and first description paragraph */
|
|
115
|
-
function extractMarkdownBody(source) {
|
|
116
|
-
const body = source.replace(/^---[\s\S]*?---\s*/, '');
|
|
117
|
-
const lines = body.split('\n');
|
|
118
|
-
let startIndex = 0;
|
|
119
|
-
let foundTitle = false;
|
|
120
|
-
let skippedDescription = false;
|
|
121
|
-
for (let i = 0; i < lines.length; i++) {
|
|
122
|
-
const line = lines[i].trim();
|
|
123
|
-
if (!line)
|
|
124
|
-
continue;
|
|
125
|
-
if (line.startsWith('# ') && !foundTitle) {
|
|
126
|
-
foundTitle = true;
|
|
127
|
-
startIndex = i + 1;
|
|
128
|
-
// Skip the description paragraph
|
|
129
|
-
for (let j = i + 1; j < lines.length; j++) {
|
|
130
|
-
const next = lines[j].trim();
|
|
131
|
-
if (!next)
|
|
132
|
-
continue;
|
|
133
|
-
if (next.startsWith('#') || next.startsWith('<script')) {
|
|
134
|
-
startIndex = j;
|
|
135
|
-
skippedDescription = true;
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
// This is the description paragraph, skip it
|
|
139
|
-
startIndex = j + 1;
|
|
140
|
-
skippedDescription = true;
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return lines.slice(startIndex).join('\n').trim();
|
|
147
|
-
}
|
|
148
|
-
/** Extract component snippets from ## sections in markdown */
|
|
149
|
-
async function extractComponentSnippets(source, _compiledCode) {
|
|
150
|
-
const body = extractMarkdownBody(source);
|
|
151
|
-
const sections = splitBySections(body);
|
|
152
|
-
const snippets = [];
|
|
153
|
-
for (const section of sections) {
|
|
154
|
-
const compiled = await compile(section.body, { extension: '.sdocx' });
|
|
155
|
-
const html = compiled ? removeModuleScript(compiled.code) : section.body;
|
|
156
|
-
snippets.push({
|
|
157
|
-
name: section.name,
|
|
158
|
-
body: html.trim(),
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
return snippets;
|
|
162
|
-
}
|
|
163
|
-
/** Split markdown body by ## headings into named sections */
|
|
164
|
-
function splitBySections(body) {
|
|
165
|
-
const sections = [];
|
|
166
|
-
const lines = body.split('\n');
|
|
167
|
-
let currentName = null;
|
|
168
|
-
let currentLines = [];
|
|
169
|
-
for (const line of lines) {
|
|
170
|
-
const headingMatch = line.match(/^##\s+(.+)$/);
|
|
171
|
-
if (headingMatch) {
|
|
172
|
-
if (currentName !== null) {
|
|
173
|
-
sections.push({ name: currentName, body: currentLines.join('\n').trim() });
|
|
174
|
-
}
|
|
175
|
-
currentName = headingMatch[1].trim();
|
|
176
|
-
currentLines = [];
|
|
177
|
-
}
|
|
178
|
-
else if (currentName !== null) {
|
|
179
|
-
currentLines.push(line);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (currentName !== null) {
|
|
183
|
-
sections.push({ name: currentName, body: currentLines.join('\n').trim() });
|
|
184
|
-
}
|
|
185
|
-
return sections;
|
|
186
|
-
}
|
|
187
|
-
/** Remove the mdsvex-generated module script from compiled code */
|
|
188
|
-
function removeModuleScript(code) {
|
|
189
|
-
return code.replace(/<script context="module">[\s\S]*?<\/script>\s*/, '').trim();
|
|
190
|
-
}
|
|
191
|
-
/** Guess a title from the file path */
|
|
192
|
-
function guessTitle(filePath) {
|
|
193
|
-
const fileName = filePath.split('/').pop() ?? '';
|
|
194
|
-
return fileName
|
|
195
|
-
.replace(/\.(page|layout|component)?\.(sdoc|sdocx)$/, '')
|
|
196
|
-
.replace(/\./g, ' ');
|
|
197
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|