sdocs 0.0.32 → 0.0.33
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 +9 -0
- package/dist/explorer/Explorer.svelte +13 -2
- package/dist/explorer/views/PreviewFrame.svelte +7 -2
- package/dist/vite.js +11 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.0.33] - 2026-07-03
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Embedded apps can deploy under a sub-path.** Preview URLs pick up the
|
|
15
|
+
host Vite `base` automatically; SvelteKit apps (whose base Vite doesn't
|
|
16
|
+
see) pass it explicitly via the new `previewBase` prop on `Explorer` —
|
|
17
|
+
e.g. `previewBase={base}` with `base` from `$app/paths`.
|
|
18
|
+
|
|
10
19
|
## [0.0.32] - 2026-07-03
|
|
11
20
|
|
|
12
21
|
### Changed
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import PageView from './views/PageView.svelte';
|
|
8
8
|
import LayoutView from './views/LayoutView.svelte';
|
|
9
9
|
import HomePage from './views/HomePage.svelte';
|
|
10
|
-
import { onMount } from 'svelte';
|
|
10
|
+
import { onMount, setContext } from 'svelte';
|
|
11
11
|
import '../ui/styles/sdocs.css';
|
|
12
12
|
|
|
13
13
|
type ThemeMode = 'light' | 'dark';
|
|
@@ -17,13 +17,24 @@
|
|
|
17
17
|
logo?: string;
|
|
18
18
|
icon?: string | false;
|
|
19
19
|
cssNames?: string[];
|
|
20
|
+
/** URL prefix for preview pages when the host app is served under a sub-path (e.g. SvelteKit's base). */
|
|
21
|
+
previewBase?: string;
|
|
20
22
|
sidebarConfig?: {
|
|
21
23
|
order?: Record<string, string[]>;
|
|
22
24
|
open?: string[];
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
let {
|
|
28
|
+
let {
|
|
29
|
+
docs,
|
|
30
|
+
logo = 'sdocs',
|
|
31
|
+
icon = 'sdocs',
|
|
32
|
+
cssNames = [],
|
|
33
|
+
previewBase = '',
|
|
34
|
+
sidebarConfig
|
|
35
|
+
}: Props = $props();
|
|
36
|
+
|
|
37
|
+
setContext('sdocs-preview-base', previewBase);
|
|
27
38
|
|
|
28
39
|
let sidebarHidden = $state(false);
|
|
29
40
|
let activeStylesheet = $state<string | undefined>(undefined);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { onMount, untrack } from 'svelte';
|
|
2
|
+
import { getContext, onMount, untrack } from 'svelte';
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
5
5
|
src: string;
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
let { src, props = {}, cssVars = {}, activeStylesheet, fullHeight = false }: Props = $props();
|
|
13
|
+
|
|
14
|
+
// Preview URLs are root-absolute; hosts serving under a sub-path pass the
|
|
15
|
+
// prefix via the Explorer's previewBase prop (see Explorer.svelte).
|
|
16
|
+
const previewBase = (getContext('sdocs-preview-base') as string | undefined) ?? '';
|
|
17
|
+
const resolvedSrc = $derived(previewBase.replace(/\/$/, '') + src);
|
|
13
18
|
let iframe: HTMLIFrameElement;
|
|
14
19
|
let ready = $state(false);
|
|
15
20
|
let contentHeight = $state(0);
|
|
@@ -73,7 +78,7 @@
|
|
|
73
78
|
<div class="sdocs-preview-frame" class:full-height={fullHeight}>
|
|
74
79
|
<iframe
|
|
75
80
|
bind:this={iframe}
|
|
76
|
-
{
|
|
81
|
+
src={resolvedSrc}
|
|
77
82
|
title="Component preview"
|
|
78
83
|
class="sdocs-iframe"
|
|
79
84
|
scrolling="no"
|
package/dist/vite.js
CHANGED
|
@@ -21,6 +21,9 @@ export function sdocsPlugin(userConfig) {
|
|
|
21
21
|
const buildMode = userConfig?._buildMode ?? false;
|
|
22
22
|
let isBuild = false;
|
|
23
23
|
let isSsrBuild = false;
|
|
24
|
+
// Host app's base path ('/' when served at the domain root); preview URLs
|
|
25
|
+
// are root-absolute and must carry it so embedding works under a sub-path.
|
|
26
|
+
let base = '/';
|
|
24
27
|
// Previews planned for emission into a host app's build (embedded mode)
|
|
25
28
|
let plannedPreviews = [];
|
|
26
29
|
let emittedCssLinks = [];
|
|
@@ -30,6 +33,7 @@ export function sdocsPlugin(userConfig) {
|
|
|
30
33
|
root = resolvedConfig.root;
|
|
31
34
|
isBuild = resolvedConfig.command === 'build';
|
|
32
35
|
isSsrBuild = !!resolvedConfig.build?.ssr;
|
|
36
|
+
base = resolvedConfig.base || '/';
|
|
33
37
|
const fileConfig = await loadRawConfig(root);
|
|
34
38
|
const merged = { ...fileConfig, ...userConfig };
|
|
35
39
|
config = resolveAndFinalize(merged, root);
|
|
@@ -320,9 +324,13 @@ export function sdocsPlugin(userConfig) {
|
|
|
320
324
|
name: s.name,
|
|
321
325
|
body: s.body,
|
|
322
326
|
highlightedHtml: s.highlightedHtml,
|
|
323
|
-
previewUrl:
|
|
324
|
-
|
|
325
|
-
|
|
327
|
+
previewUrl:
|
|
328
|
+
// Only absolute bases prefix here; SvelteKit builds with a relative
|
|
329
|
+
// base ('./') and passes its real path via the Explorer's previewBase.
|
|
330
|
+
(base.startsWith('/') && base !== '/' ? base.replace(/\/$/, '') : '') +
|
|
331
|
+
(buildMode || isBuild
|
|
332
|
+
? buildPreviewUrl(e.filePath, s.name)
|
|
333
|
+
: previewUrl(e.filePath, s.name)),
|
|
326
334
|
})),
|
|
327
335
|
highlightedSource: e.highlightedSource,
|
|
328
336
|
toc: e.toc,
|