sdocs 0.0.45 → 0.0.46
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/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.0.46] - 2026-07-04
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **`npx sdocs` works in projects without a local install again.** The
|
|
15
|
+
Explorer's lazy syntax highlighter (added in 0.0.36) imports `shiki`,
|
|
16
|
+
which a bare project couldn't resolve from the staging directory — the
|
|
17
|
+
dev server failed with `Failed to resolve import "shiki/core"`. The
|
|
18
|
+
staging directory now links sdocs' own `shiki` (and `svelte`, when the
|
|
19
|
+
project has none) into place; a project-local `svelte` still wins.
|
|
20
|
+
|
|
10
21
|
## [0.0.45] - 2026-07-04
|
|
11
22
|
|
|
12
23
|
### Fixed
|
|
@@ -9,7 +9,7 @@ export interface TreeNode {
|
|
|
9
9
|
children: TreeNode[];
|
|
10
10
|
/** The doc entry (only for component/page/layout nodes) */
|
|
11
11
|
doc?: DocEntry;
|
|
12
|
-
/**
|
|
12
|
+
/** Example titles for component nodes (sidebar sub-pages) */
|
|
13
13
|
examples?: string[];
|
|
14
14
|
/** Whether this node should be expanded by default */
|
|
15
15
|
defaultExpanded?: boolean;
|
package/dist/server/app-gen.js
CHANGED
|
@@ -1,13 +1,38 @@
|
|
|
1
|
-
import { mkdir, mkdtemp, writeFile, rm, readFile, copyFile, readdir } from 'node:fs/promises';
|
|
1
|
+
import { mkdir, mkdtemp, writeFile, rm, readFile, copyFile, readdir, symlink } from 'node:fs/promises';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { dirname, resolve, join } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
6
7
|
import { discoverDocFiles } from './discovery.js';
|
|
7
8
|
import { parseSdoc } from '../language/index.js';
|
|
8
9
|
import { planEntitySnippets } from './doc-model.js';
|
|
9
10
|
import { encodeEntityId, setDocPathRoot } from './snippet-compiler.js';
|
|
10
11
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
/**
|
|
14
|
+
* Make the staging dir self-sufficient: the staged Explorer imports shiki
|
|
15
|
+
* (and svelte) as bare specifiers, but when the staging dir sits inside a
|
|
16
|
+
* bare project (npx run, no local install), walking up never reaches sdocs'
|
|
17
|
+
* own dependency tree. Link what the Explorer needs into the staging dir's
|
|
18
|
+
* node_modules — svelte only when the project has no copy of its own, so a
|
|
19
|
+
* project-local svelte keeps winning (two svelte runtimes don't mix).
|
|
20
|
+
*/
|
|
21
|
+
async function linkStagedDeps(sdocsDir, cwd) {
|
|
22
|
+
const nodeModules = resolve(sdocsDir, 'node_modules');
|
|
23
|
+
await mkdir(nodeModules, { recursive: true });
|
|
24
|
+
const link = async (pkg) => {
|
|
25
|
+
const target = dirname(require.resolve(`${pkg}/package.json`));
|
|
26
|
+
await symlink(target, resolve(nodeModules, pkg), 'junction').catch(() => { });
|
|
27
|
+
};
|
|
28
|
+
await link('shiki');
|
|
29
|
+
try {
|
|
30
|
+
require.resolve('svelte/package.json', { paths: [cwd] });
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
await link('svelte');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
11
36
|
/** Source Explorer directory in the installed package (dist/explorer, next to dist/server) */
|
|
12
37
|
function getExplorerSourceDir() {
|
|
13
38
|
return resolve(__dirname, '../explorer');
|
|
@@ -164,6 +189,7 @@ export async function generateDevFiles(config, cwd) {
|
|
|
164
189
|
const sdocsDir = await createStagingDir(cwd);
|
|
165
190
|
// Copy Explorer components into the staging dir so they're compiled outside node_modules
|
|
166
191
|
await copyExplorerApp(sdocsDir);
|
|
192
|
+
await linkStagedDeps(sdocsDir, cwd);
|
|
167
193
|
await writeFile(resolve(sdocsDir, 'index.html'), generateIndexHtml(config.logo));
|
|
168
194
|
await writeFile(resolve(sdocsDir, 'entry.js'), generateEntryJs(config));
|
|
169
195
|
return sdocsDir;
|
|
@@ -176,6 +202,7 @@ export async function generateBuildFiles(config, cwd) {
|
|
|
176
202
|
setDocPathRoot(sdocsDir);
|
|
177
203
|
// Copy Explorer components into the staging dir
|
|
178
204
|
await copyExplorerApp(sdocsDir);
|
|
205
|
+
await linkStagedDeps(sdocsDir, cwd);
|
|
179
206
|
await writeFile(resolve(sdocsDir, 'index.html'), generateIndexHtml(config.logo));
|
|
180
207
|
await writeFile(resolve(sdocsDir, 'entry.js'), generateEntryJs(config));
|
|
181
208
|
const inputs = {
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
/** Discover all .sdoc files matching the include patterns */
|
|
2
2
|
export declare function discoverDocFiles(include: string[], root: string): Promise<string[]>;
|
|
3
|
-
/** Get the absolute path for a relative import */
|
|
4
|
-
export declare function resolveImportPath(importPath: string, fromFile: string): string;
|
package/dist/server/discovery.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { glob } from 'tinyglobby';
|
|
2
|
-
import { resolve } from 'node:path';
|
|
3
2
|
/** Discover all .sdoc files matching the include patterns */
|
|
4
3
|
export async function discoverDocFiles(include, root) {
|
|
5
4
|
const files = await glob(include, {
|
|
@@ -8,8 +7,3 @@ export async function discoverDocFiles(include, root) {
|
|
|
8
7
|
});
|
|
9
8
|
return files.sort();
|
|
10
9
|
}
|
|
11
|
-
/** Get the absolute path for a relative import */
|
|
12
|
-
export function resolveImportPath(importPath, fromFile) {
|
|
13
|
-
const dir = fromFile.substring(0, fromFile.lastIndexOf('/'));
|
|
14
|
-
return resolve(dir, importPath);
|
|
15
|
-
}
|