sdocs 0.0.9 → 0.0.11

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/app-gen.js CHANGED
@@ -1,13 +1,28 @@
1
- import { mkdir, writeFile, rm, readFile, copyFile } from 'node:fs/promises';
2
- import { dirname, resolve } from 'node:path';
1
+ import { mkdir, writeFile, rm, readFile, copyFile, readdir } from 'node:fs/promises';
2
+ import { dirname, resolve, join } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { discoverDocFiles, getSdocKind } from './server/discovery.js';
5
5
  import { extractSnippets, hasDefaultSnippet } from './server/snippet-extractor.js';
6
6
  import { base64urlEncode } from './server/snippet-compiler.js';
7
7
  const __dirname = dirname(fileURLToPath(import.meta.url));
8
- /** Absolute path to the client App.svelte in the installed package */
9
- function getAppComponentPath() {
10
- return resolve(__dirname, 'client', 'App.svelte');
8
+ /** Source client directory in the installed package */
9
+ function getClientSourceDir() {
10
+ return resolve(__dirname, 'client');
11
+ }
12
+ /** Copy a directory recursively */
13
+ async function copyDir(src, dest) {
14
+ await mkdir(dest, { recursive: true });
15
+ const entries = await readdir(src, { withFileTypes: true });
16
+ for (const entry of entries) {
17
+ const srcPath = join(src, entry.name);
18
+ const destPath = join(dest, entry.name);
19
+ if (entry.isDirectory()) {
20
+ await copyDir(srcPath, destPath);
21
+ }
22
+ else {
23
+ await copyFile(srcPath, destPath);
24
+ }
25
+ }
11
26
  }
12
27
  /** Generate the main index.html */
13
28
  function generateIndexHtml(title) {
@@ -27,10 +42,9 @@ function generateIndexHtml(title) {
27
42
  }
28
43
  /** Generate the entry.js that mounts the App */
29
44
  function generateEntryJs(config) {
30
- const appPath = getAppComponentPath().replace(/\\/g, '/');
31
45
  return `import { mount } from 'svelte';
32
46
  import { docs, cssNames } from 'virtual:sdocs';
33
- import App from '${appPath}';
47
+ import App from './client/App.svelte';
34
48
 
35
49
  mount(App, {
36
50
  target: document.getElementById('app'),
@@ -87,11 +101,6 @@ function generatePreviewHtml(iframeVirtualId, css) {
87
101
  </body>
88
102
  </html>`;
89
103
  }
90
- /** Copy the favicon.png into the .sdocs/ directory */
91
- async function copyFavicon(sdocsDir) {
92
- const src = resolve(__dirname, 'client', 'favicon.png');
93
- await copyFile(src, resolve(sdocsDir, 'favicon.png'));
94
- }
95
104
  /** Discover doc files and extract snippet names (lightweight, no highlighting) */
96
105
  async function discoverSnippets(config, cwd) {
97
106
  const files = await discoverDocFiles(config.include, cwd);
@@ -117,18 +126,20 @@ async function discoverSnippets(config, cwd) {
117
126
  export async function generateDevFiles(config, cwd) {
118
127
  const sdocsDir = resolve(cwd, '.sdocs');
119
128
  await mkdir(sdocsDir, { recursive: true });
129
+ // Copy client components into .sdocs/client/ so they're compiled outside node_modules
130
+ await copyDir(getClientSourceDir(), resolve(sdocsDir, 'client'));
120
131
  await writeFile(resolve(sdocsDir, 'index.html'), generateIndexHtml(config.logo));
121
132
  await writeFile(resolve(sdocsDir, 'entry.js'), generateEntryJs(config));
122
- await copyFavicon(sdocsDir);
123
133
  return sdocsDir;
124
134
  }
125
135
  /** Generate .sdocs/ directory with entry + preview HTML files for build mode */
126
136
  export async function generateBuildFiles(config, cwd) {
127
137
  const sdocsDir = resolve(cwd, '.sdocs');
128
138
  await mkdir(sdocsDir, { recursive: true });
139
+ // Copy client components into .sdocs/client/
140
+ await copyDir(getClientSourceDir(), resolve(sdocsDir, 'client'));
129
141
  await writeFile(resolve(sdocsDir, 'index.html'), generateIndexHtml(config.logo));
130
142
  await writeFile(resolve(sdocsDir, 'entry.js'), generateEntryJs(config));
131
- await copyFavicon(sdocsDir);
132
143
  const inputs = {
133
144
  main: resolve(sdocsDir, 'index.html'),
134
145
  };
@@ -29,9 +29,6 @@ export async function buildCommand() {
29
29
  input: inputs,
30
30
  },
31
31
  },
32
- optimizeDeps: {
33
- exclude: ['sdocs'],
34
- },
35
32
  });
36
33
  console.log(`[sdocs] Build complete → dist/`);
37
34
  }
@@ -26,9 +26,6 @@ export async function devCommand() {
26
26
  allow: [cwd],
27
27
  },
28
28
  },
29
- optimizeDeps: {
30
- exclude: ['sdocs'],
31
- },
32
29
  });
33
30
  await server.listen();
34
31
  server.printUrls();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdocs",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "A lightweight documentation tool for Svelte 5 components",
5
5
  "type": "module",
6
6
  "license": "MIT",