mdzilla 0.0.0 → 0.0.2
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/LICENSE +21 -0
- package/README.md +157 -0
- package/dist/_chunks/exporter.mjs +787 -0
- package/dist/cli/main.d.mts +1 -0
- package/dist/cli/main.mjs +788 -0
- package/dist/index.d.mts +161 -0
- package/dist/index.mjs +2 -0
- package/package.json +52 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
//#region src/docs/nav.d.ts
|
|
2
|
+
interface NavEntry {
|
|
3
|
+
/** URL-friendly path segment (without numeric prefix) */
|
|
4
|
+
slug: string;
|
|
5
|
+
/** Full resolved URL path from docs root */
|
|
6
|
+
path: string;
|
|
7
|
+
/** Display title (from frontmatter → first heading → humanized slug) */
|
|
8
|
+
title: string;
|
|
9
|
+
/** Original numeric prefix used for ordering */
|
|
10
|
+
order: number;
|
|
11
|
+
/** Icon from frontmatter, navigation override, or .navigation.yml */
|
|
12
|
+
icon?: string;
|
|
13
|
+
/** Description from frontmatter or navigation override */
|
|
14
|
+
description?: string;
|
|
15
|
+
/** `false` when directory has no index page (non-clickable group) */
|
|
16
|
+
page?: false;
|
|
17
|
+
/** Nested children (for directories) */
|
|
18
|
+
children?: NavEntry[];
|
|
19
|
+
/** Arbitrary extra frontmatter/meta fields */
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/docs/sources/_base.d.ts
|
|
24
|
+
declare abstract class DocsSource {
|
|
25
|
+
abstract load(): Promise<{
|
|
26
|
+
tree: NavEntry[];
|
|
27
|
+
fileMap: Map<string, string>;
|
|
28
|
+
}>;
|
|
29
|
+
abstract readContent(filePath: string): Promise<string>;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/docs/sources/fs.d.ts
|
|
33
|
+
declare class DocsSourceFS extends DocsSource {
|
|
34
|
+
dir: string;
|
|
35
|
+
constructor(dir: string);
|
|
36
|
+
load(): Promise<{
|
|
37
|
+
tree: NavEntry[];
|
|
38
|
+
fileMap: Map<string, string>;
|
|
39
|
+
}>;
|
|
40
|
+
readContent(filePath: string): Promise<string>;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/docs/sources/git.d.ts
|
|
44
|
+
interface DocsSourceGitOptions {
|
|
45
|
+
/** Authorization token for private repos */
|
|
46
|
+
auth?: string;
|
|
47
|
+
/** Subdirectory within the repo containing docs */
|
|
48
|
+
subdir?: string;
|
|
49
|
+
}
|
|
50
|
+
declare class DocsSourceGit extends DocsSource {
|
|
51
|
+
src: string;
|
|
52
|
+
options: DocsSourceGitOptions;
|
|
53
|
+
private _fs?;
|
|
54
|
+
constructor(src: string, options?: DocsSourceGitOptions);
|
|
55
|
+
load(): Promise<{
|
|
56
|
+
tree: NavEntry[];
|
|
57
|
+
fileMap: Map<string, string>;
|
|
58
|
+
}>;
|
|
59
|
+
readContent(filePath: string): Promise<string>;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/docs/sources/http.d.ts
|
|
63
|
+
interface DocsSourceHTTPOptions {
|
|
64
|
+
/** Additional headers to send with each request */
|
|
65
|
+
headers?: Record<string, string>;
|
|
66
|
+
}
|
|
67
|
+
declare class DocsSourceHTTP extends DocsSource {
|
|
68
|
+
url: string;
|
|
69
|
+
options: DocsSourceHTTPOptions;
|
|
70
|
+
private _contentCache;
|
|
71
|
+
private _tree;
|
|
72
|
+
private _fileMap;
|
|
73
|
+
private _npmPackage?;
|
|
74
|
+
constructor(url: string, options?: DocsSourceHTTPOptions);
|
|
75
|
+
load(): Promise<{
|
|
76
|
+
tree: NavEntry[];
|
|
77
|
+
fileMap: Map<string, string>;
|
|
78
|
+
}>;
|
|
79
|
+
/** Try fetching /llms.txt and parse it into a nav tree */
|
|
80
|
+
private _tryLlmsTxt;
|
|
81
|
+
readContent(filePath: string): Promise<string>;
|
|
82
|
+
/** Crawl index.md pages and attach their links as children */
|
|
83
|
+
private _crawlTocPages;
|
|
84
|
+
/** Load an npm package README from the registry */
|
|
85
|
+
private _loadNpm;
|
|
86
|
+
private _fetch;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/docs/sources/npm.d.ts
|
|
90
|
+
interface DocsSourceNpmOptions {
|
|
91
|
+
/** Subdirectory within the package containing docs */
|
|
92
|
+
subdir?: string;
|
|
93
|
+
}
|
|
94
|
+
declare class DocsSourceNpm extends DocsSource {
|
|
95
|
+
src: string;
|
|
96
|
+
options: DocsSourceNpmOptions;
|
|
97
|
+
private _fs?;
|
|
98
|
+
constructor(src: string, options?: DocsSourceNpmOptions);
|
|
99
|
+
load(): Promise<{
|
|
100
|
+
tree: NavEntry[];
|
|
101
|
+
fileMap: Map<string, string>;
|
|
102
|
+
}>;
|
|
103
|
+
readContent(filePath: string): Promise<string>;
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/docs/manager.d.ts
|
|
107
|
+
interface FlatEntry {
|
|
108
|
+
entry: NavEntry;
|
|
109
|
+
depth: number;
|
|
110
|
+
filePath?: string;
|
|
111
|
+
}
|
|
112
|
+
declare class DocsManager {
|
|
113
|
+
source: DocsSource;
|
|
114
|
+
tree: NavEntry[];
|
|
115
|
+
flat: FlatEntry[];
|
|
116
|
+
private _fileMap;
|
|
117
|
+
private _contentCache;
|
|
118
|
+
constructor(source: DocsSource);
|
|
119
|
+
load(): Promise<void>;
|
|
120
|
+
reload(): Promise<void>;
|
|
121
|
+
/** Get raw file content for a flat entry (cached). */
|
|
122
|
+
getContent(entry: FlatEntry): Promise<string | undefined>;
|
|
123
|
+
/** Invalidate cached content for a specific file path. */
|
|
124
|
+
invalidate(filePath: string): void;
|
|
125
|
+
/** Fuzzy filter flat entries by query string. */
|
|
126
|
+
filter(query: string): FlatEntry[];
|
|
127
|
+
/** Flat entries that are navigable pages (excludes directory stubs). */
|
|
128
|
+
get pages(): FlatEntry[];
|
|
129
|
+
/** Find a flat entry by path (exact or with trailing slash). */
|
|
130
|
+
findByPath(path: string): FlatEntry | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Resolve a page path to its content, trying:
|
|
133
|
+
* 1. Exact match in the navigation tree
|
|
134
|
+
* 2. Stripped common prefix (e.g., /docs/guide/... → /guide/...)
|
|
135
|
+
* 3. Direct source fetch (for HTTP sources with uncrawled paths)
|
|
136
|
+
*/
|
|
137
|
+
resolvePage(path: string): Promise<{
|
|
138
|
+
entry?: FlatEntry;
|
|
139
|
+
raw?: string;
|
|
140
|
+
}>;
|
|
141
|
+
/** Return indices of matching flat entries (case-insensitive substring). */
|
|
142
|
+
matchIndices(query: string): number[];
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/docs/exporter.d.ts
|
|
146
|
+
interface ExportOptions {
|
|
147
|
+
/** Include entries where page === false (directory stubs). Default: false */
|
|
148
|
+
includeStubs?: boolean;
|
|
149
|
+
/** Compile markdown to plain text using md4x. Default: false */
|
|
150
|
+
plainText?: boolean;
|
|
151
|
+
}
|
|
152
|
+
declare abstract class DocsExporter {
|
|
153
|
+
abstract export(manager: DocsManager, options?: ExportOptions): Promise<void>;
|
|
154
|
+
}
|
|
155
|
+
declare class DocsExporterFS extends DocsExporter {
|
|
156
|
+
dir: string;
|
|
157
|
+
constructor(dir: string);
|
|
158
|
+
export(manager: DocsManager, options?: ExportOptions): Promise<void>;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
export { DocsExporter, DocsExporterFS, DocsManager, DocsSource, DocsSourceFS, DocsSourceGit, type DocsSourceGitOptions, DocsSourceHTTP, type DocsSourceHTTPOptions, DocsSourceNpm, type DocsSourceNpmOptions, type ExportOptions, type FlatEntry, type NavEntry };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DocsSourceGit, c as DocsManager, i as DocsSourceHTTP, n as DocsExporterFS, o as DocsSourceFS, r as DocsSourceNpm, s as DocsSource, t as DocsExporter } from "./_chunks/exporter.mjs";
|
|
2
|
+
export { DocsExporter, DocsExporterFS, DocsManager, DocsSource, DocsSourceFS, DocsSourceGit, DocsSourceHTTP, DocsSourceNpm };
|
package/package.json
CHANGED
|
@@ -1 +1,52 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "mdzilla",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "pi0/mdzilla",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mdz": "./dist/cli/main.mjs",
|
|
9
|
+
"mdzilla": "./dist/cli/main.mjs"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"types": "./dist/index.d.mts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./dist/index.mjs"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "obuild",
|
|
22
|
+
"dev": "vitest dev",
|
|
23
|
+
"fmt": "automd && oxlint . --fix && oxfmt .",
|
|
24
|
+
"lint": "oxlint . && oxfmt --check .",
|
|
25
|
+
"prepack": "pnpm build",
|
|
26
|
+
"mdzilla": "node src/cli/main.ts",
|
|
27
|
+
"mdz": "node src/cli/main.ts",
|
|
28
|
+
"release": "pnpm test && pnpm build && changelogen --release && npm publish && git push --follow-tags",
|
|
29
|
+
"test": "pnpm lint && pnpm typecheck && vitest run --coverage",
|
|
30
|
+
"typecheck": "tsgo --noEmit --skipLibCheck"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@speed-highlight/core": "^1.2.14",
|
|
34
|
+
"giget": "^3.1.2",
|
|
35
|
+
"md4x": ">=0.0.21",
|
|
36
|
+
"mdream": "^0.16.0",
|
|
37
|
+
"std-env": "4.0.0-rc.1"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "latest",
|
|
41
|
+
"@typescript/native-preview": "latest",
|
|
42
|
+
"@vitest/coverage-v8": "latest",
|
|
43
|
+
"automd": "latest",
|
|
44
|
+
"changelogen": "latest",
|
|
45
|
+
"obuild": "latest",
|
|
46
|
+
"oxfmt": "latest",
|
|
47
|
+
"oxlint": "latest",
|
|
48
|
+
"typescript": "latest",
|
|
49
|
+
"vitest": "latest"
|
|
50
|
+
},
|
|
51
|
+
"packageManager": "pnpm@10.29.3"
|
|
52
|
+
}
|