@domphy/press 0.19.1 → 0.20.0
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/{build-QKFFWX4D.js → build-SVIPUB2K.js} +1174 -391
- package/dist/cli.js +24 -9
- package/dist/index.d.ts +57 -38
- package/dist/index.js +79 -220
- package/dist/index.js.map +1 -1
- package/dist/{serve-LQBYPP6C.js → serve-CMS6MDDF.js} +19 -5
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -23,11 +23,18 @@ async function loadConfig(configFile) {
|
|
|
23
23
|
if (command === "build") {
|
|
24
24
|
const config = await loadConfig(flag("--config") ?? "press.config.ts");
|
|
25
25
|
const srcDir = resolve(process.cwd(), flag("--src") ?? config.srcDir ?? ".");
|
|
26
|
-
const outDir = resolve(
|
|
26
|
+
const outDir = resolve(
|
|
27
|
+
process.cwd(),
|
|
28
|
+
flag("--out") ?? config.outDir ?? "dist"
|
|
29
|
+
);
|
|
27
30
|
const publicDir = resolve(process.cwd(), "public");
|
|
28
|
-
const { buildSite } = await import("./build-
|
|
31
|
+
const { buildSite } = await import("./build-SVIPUB2K.js");
|
|
29
32
|
await buildSite({
|
|
30
|
-
config: {
|
|
33
|
+
config: {
|
|
34
|
+
...config,
|
|
35
|
+
srcDir: config.srcDir ?? ".",
|
|
36
|
+
outDir: config.outDir ?? "dist"
|
|
37
|
+
},
|
|
31
38
|
srcDir,
|
|
32
39
|
outDir,
|
|
33
40
|
publicDir: existsSync(publicDir) ? publicDir : void 0
|
|
@@ -37,15 +44,22 @@ if (command === "build") {
|
|
|
37
44
|
const configFile = flag("--config") ?? "press.config.ts";
|
|
38
45
|
const config = await loadConfig(configFile);
|
|
39
46
|
const srcDir = resolve(process.cwd(), flag("--src") ?? config.srcDir ?? ".");
|
|
40
|
-
const outDir = resolve(
|
|
47
|
+
const outDir = resolve(
|
|
48
|
+
process.cwd(),
|
|
49
|
+
flag("--out") ?? config.outDir ?? ".press-dev"
|
|
50
|
+
);
|
|
41
51
|
const publicDir = resolve(process.cwd(), "public");
|
|
42
|
-
const { buildSite } = await import("./build-
|
|
43
|
-
const { startDevServer } = await import("./serve-
|
|
52
|
+
const { buildSite } = await import("./build-SVIPUB2K.js");
|
|
53
|
+
const { startDevServer } = await import("./serve-CMS6MDDF.js");
|
|
44
54
|
async function rebuild() {
|
|
45
55
|
const start = Date.now();
|
|
46
56
|
try {
|
|
47
57
|
await buildSite({
|
|
48
|
-
config: {
|
|
58
|
+
config: {
|
|
59
|
+
...config,
|
|
60
|
+
srcDir: config.srcDir ?? ".",
|
|
61
|
+
outDir: config.outDir ?? ".press-dev"
|
|
62
|
+
},
|
|
49
63
|
srcDir,
|
|
50
64
|
outDir,
|
|
51
65
|
publicDir: existsSync(publicDir) ? publicDir : void 0
|
|
@@ -59,7 +73,8 @@ if (command === "build") {
|
|
|
59
73
|
const { notify } = startDevServer(outDir, port);
|
|
60
74
|
let rebuildTimer = null;
|
|
61
75
|
watch(srcDir, { recursive: true }, (_event, filename) => {
|
|
62
|
-
if (!filename?.endsWith(".md") && !filename?.endsWith(".ts") && !filename?.endsWith(".js"))
|
|
76
|
+
if (!filename?.endsWith(".md") && !filename?.endsWith(".ts") && !filename?.endsWith(".js"))
|
|
77
|
+
return;
|
|
63
78
|
if (rebuildTimer) clearTimeout(rebuildTimer);
|
|
64
79
|
rebuildTimer = setTimeout(async () => {
|
|
65
80
|
rebuildTimer = null;
|
|
@@ -83,7 +98,7 @@ if (command === "build") {
|
|
|
83
98
|
console.error(`No build at ${outDir}. Run "domphy-press build" first.`);
|
|
84
99
|
process.exit(1);
|
|
85
100
|
}
|
|
86
|
-
const { startServer } = await import("./serve-
|
|
101
|
+
const { startServer } = await import("./serve-CMS6MDDF.js");
|
|
87
102
|
startServer(outDir, port);
|
|
88
103
|
} else {
|
|
89
104
|
console.error(`Unknown command: ${command ?? "(none)"}`);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DomphyElement, ElementNode } from '@domphy/core';
|
|
2
|
+
export { DomphyElement } from '@domphy/core';
|
|
2
3
|
import { TocEntry } from '@domphy/markdown';
|
|
3
4
|
export { TocEntry } from '@domphy/markdown';
|
|
4
5
|
import { Server } from 'node:http';
|
|
@@ -33,6 +34,22 @@ interface EditLink {
|
|
|
33
34
|
pattern: string;
|
|
34
35
|
text?: string;
|
|
35
36
|
}
|
|
37
|
+
/** Override built-in layout slots. Each function receives the full LayoutContext
|
|
38
|
+
* and must return a DomphyElement (or null to omit the slot entirely). */
|
|
39
|
+
interface LayoutSlots {
|
|
40
|
+
/** Replace the entire header bar. */
|
|
41
|
+
header?: (ctx: unknown) => DomphyElement | null;
|
|
42
|
+
/** Replace the sidebar navigation. */
|
|
43
|
+
sidebar?: (ctx: unknown) => DomphyElement | null;
|
|
44
|
+
/** Replace the TOC aside panel. */
|
|
45
|
+
aside?: (ctx: unknown) => DomphyElement | null;
|
|
46
|
+
/** Replace the prev/next pagination row. */
|
|
47
|
+
prevNext?: (ctx: unknown) => DomphyElement | null;
|
|
48
|
+
/** Replace the doc footer (edit link + last updated). */
|
|
49
|
+
docFooter?: (ctx: unknown) => DomphyElement | null;
|
|
50
|
+
/** Replace the page footer bar. */
|
|
51
|
+
footer?: (ctx: unknown) => DomphyElement | null;
|
|
52
|
+
}
|
|
36
53
|
interface ThemeConfig {
|
|
37
54
|
nav: NavItem[];
|
|
38
55
|
/** Keys are route prefixes (e.g. "/guide/"). Longest match wins. */
|
|
@@ -65,6 +82,8 @@ interface ThemeConfig {
|
|
|
65
82
|
text: string;
|
|
66
83
|
dismissible?: boolean;
|
|
67
84
|
};
|
|
85
|
+
/** Override individual layout slots with custom components. */
|
|
86
|
+
slots?: LayoutSlots;
|
|
68
87
|
}
|
|
69
88
|
interface LocaleConfig {
|
|
70
89
|
label: string;
|
|
@@ -115,6 +134,14 @@ interface PageEntry {
|
|
|
115
134
|
filePath: string;
|
|
116
135
|
}
|
|
117
136
|
|
|
137
|
+
interface BuildOptions {
|
|
138
|
+
config: SiteConfig;
|
|
139
|
+
srcDir: string;
|
|
140
|
+
outDir: string;
|
|
141
|
+
publicDir?: string;
|
|
142
|
+
}
|
|
143
|
+
declare function buildSite(options: BuildOptions): Promise<void>;
|
|
144
|
+
|
|
118
145
|
type UserConfig = Omit<SiteConfig, "base" | "srcDir" | "outDir" | "head"> & {
|
|
119
146
|
base?: string;
|
|
120
147
|
srcDir?: string;
|
|
@@ -123,19 +150,32 @@ type UserConfig = Omit<SiteConfig, "base" | "srcDir" | "outDir" | "head"> & {
|
|
|
123
150
|
};
|
|
124
151
|
declare function defineConfig(config: UserConfig): SiteConfig;
|
|
125
152
|
|
|
126
|
-
interface
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
153
|
+
interface FenceMeta {
|
|
154
|
+
lang: string;
|
|
155
|
+
highlightLines: Set<number>;
|
|
156
|
+
lineNumbers: boolean;
|
|
157
|
+
title: string | null;
|
|
131
158
|
}
|
|
132
|
-
declare function
|
|
159
|
+
declare function parseFenceInfo(info: string): FenceMeta;
|
|
160
|
+
declare function createHighlighter(): Promise<(code: string, lang: string) => string>;
|
|
161
|
+
declare function renderFence(code: string, info: string, highlight: (code: string, lang: string) => string): string;
|
|
133
162
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
163
|
+
interface LayoutContext {
|
|
164
|
+
route: string;
|
|
165
|
+
title: string;
|
|
166
|
+
body: DomphyElement[];
|
|
167
|
+
toc: TocEntry[];
|
|
168
|
+
frontmatter: Record<string, unknown>;
|
|
169
|
+
config: SiteConfig;
|
|
170
|
+
/** ISO date string from git log, if lastUpdated:true and git available. */
|
|
171
|
+
lastUpdated?: string;
|
|
172
|
+
/** Estimated reading time in minutes. */
|
|
173
|
+
readingTime?: number;
|
|
174
|
+
/** Relative path from srcDir (e.g. "guide/index.md"), used for editLink. */
|
|
175
|
+
filePath?: string;
|
|
176
|
+
}
|
|
177
|
+
declare function pageShell(ctx: LayoutContext): DomphyElement;
|
|
178
|
+
declare function homeShell(ctx: LayoutContext): DomphyElement;
|
|
139
179
|
|
|
140
180
|
declare function renderDoc(source: string, options: RenderDocOptions): Promise<RenderedDoc>;
|
|
141
181
|
|
|
@@ -177,33 +217,12 @@ interface SearchWidgetOptions {
|
|
|
177
217
|
declare function searchWidget(options?: SearchWidgetOptions): DomphyElement;
|
|
178
218
|
declare function mountSearch(host: HTMLElement, options?: SearchWidgetOptions): ElementNode;
|
|
179
219
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
declare function parseFenceInfo(info: string): FenceMeta;
|
|
187
|
-
declare function createHighlighter(): Promise<(code: string, lang: string) => string>;
|
|
188
|
-
declare function renderFence(code: string, info: string, highlight: (code: string, lang: string) => string): string;
|
|
189
|
-
|
|
190
|
-
interface LayoutContext {
|
|
191
|
-
route: string;
|
|
192
|
-
title: string;
|
|
193
|
-
body: DomphyElement[];
|
|
194
|
-
toc: TocEntry[];
|
|
195
|
-
frontmatter: Record<string, unknown>;
|
|
196
|
-
config: SiteConfig;
|
|
197
|
-
/** ISO date string from git log, if lastUpdated:true and git available. */
|
|
198
|
-
lastUpdated?: string;
|
|
199
|
-
/** Estimated reading time in minutes. */
|
|
200
|
-
readingTime?: number;
|
|
201
|
-
/** Relative path from srcDir (e.g. "guide/index.md"), used for editLink. */
|
|
202
|
-
filePath?: string;
|
|
203
|
-
}
|
|
204
|
-
declare function pageShell(ctx: LayoutContext): DomphyElement;
|
|
205
|
-
declare function homeShell(ctx: LayoutContext): DomphyElement;
|
|
220
|
+
declare function startServer(root: string, port: number): Server;
|
|
221
|
+
declare function startDevServer(root: string, port: number): {
|
|
222
|
+
server: Server;
|
|
223
|
+
notify: () => void;
|
|
224
|
+
};
|
|
206
225
|
|
|
207
226
|
declare function pressCSS(): string;
|
|
208
227
|
|
|
209
|
-
export { type EditLink, type FenceMeta, type IslandRef, type LayoutContext, type LocaleConfig, type NavItem, type PageEntry, type RenderDocOptions, type RenderedDoc, type SearchDocument, type SearchResult, type SearchWidgetOptions, type SidebarItem, type SiteConfig, type SocialLink, type ThemeConfig, type UserConfig, buildSearchIndex, buildSite, createHighlighter, defineConfig, discoverPages, flattenSidebar, homeShell, mountSearch, outFileForRoute, pageShell, parseFenceInfo, pressCSS, prevNextForRoute, queryIndex, renderDoc, renderFence, routeForFile, searchWidget, sidebarForRoute, startDevServer, startServer };
|
|
228
|
+
export { type EditLink, type FenceMeta, type IslandRef, type LayoutContext, type LayoutSlots, type LocaleConfig, type NavItem, type PageEntry, type RenderDocOptions, type RenderedDoc, type SearchDocument, type SearchResult, type SearchWidgetOptions, type SidebarItem, type SiteConfig, type SocialLink, type ThemeConfig, type UserConfig, buildSearchIndex, buildSite, createHighlighter, defineConfig, discoverPages, flattenSidebar, homeShell, mountSearch, outFileForRoute, pageShell, parseFenceInfo, pressCSS, prevNextForRoute, queryIndex, renderDoc, renderFence, routeForFile, searchWidget, sidebarForRoute, startDevServer, startServer };
|