@octanejs/docusaurus 0.0.1

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/src/mdx.js ADDED
@@ -0,0 +1,319 @@
1
+ import { compileMdx, compileMdxSync, defaultRemarkPlugins } from '@octanejs/mdx/compile';
2
+ import GithubSlugger from 'github-slugger';
3
+
4
+ const DATA_KEY = 'octaneDocusaurus';
5
+
6
+ function walk(node, visit) {
7
+ if (!node || typeof node !== 'object') return;
8
+ visit(node);
9
+ for (const [key, value] of Object.entries(node)) {
10
+ if (key === 'position' || key === 'data') continue;
11
+ if (Array.isArray(value)) {
12
+ for (const child of value) walk(child, visit);
13
+ } else {
14
+ walk(value, visit);
15
+ }
16
+ }
17
+ }
18
+
19
+ function textContent(node) {
20
+ let text = '';
21
+ walk(node, (child) => {
22
+ if (child === node) return;
23
+ if (child.type === 'text' || child.type === 'inlineCode') text += child.value ?? '';
24
+ if (child.type === 'image') text += child.alt ?? '';
25
+ });
26
+ return text.trim();
27
+ }
28
+
29
+ function createSlugger(maintainCase) {
30
+ const slugger = new GithubSlugger();
31
+ return {
32
+ explicit(value) {
33
+ return slugger.slug(value, true);
34
+ },
35
+ generated(value) {
36
+ return slugger.slug(value, maintainCase);
37
+ },
38
+ };
39
+ }
40
+
41
+ function transformImageUrl(transform, url, sourceFilePath) {
42
+ if (typeof transform !== 'function') return url;
43
+ const transformed = transform({ url, sourceFilePath });
44
+ if (typeof transformed !== 'string') {
45
+ throw new TypeError('A Docusaurus MDX image transform must return a string.');
46
+ }
47
+ return transformed;
48
+ }
49
+
50
+ function transformMarkdownLink(transform, url, sourceFilePath) {
51
+ if (typeof transform !== 'function') return url;
52
+ if (/^(?:[a-z][a-z\d+.-]*:|\/\/|#)/i.test(url)) return url;
53
+ const match = /^([^?#]*)(.*)$/.exec(url);
54
+ const linkPathname = match?.[1] ?? url;
55
+ if (!/\.mdx?$/i.test(linkPathname)) return url;
56
+ const transformed = transform({ linkPathname, sourceFilePath });
57
+ if (transformed === null) return url;
58
+ if (typeof transformed !== 'string') {
59
+ throw new TypeError('A Docusaurus Markdown link resolver must return a string or null.');
60
+ }
61
+ return transformed + (match?.[2] ?? '');
62
+ }
63
+
64
+ function classicHeadingId(heading, headingText) {
65
+ const match = /\s*\{#((?:.(?!\{#|\}))*.)\}$/.exec(headingText);
66
+ if (!match) return undefined;
67
+ const id = match[1].trim();
68
+ const last = heading.children?.at(-1);
69
+ if (last?.type === 'text') {
70
+ last.value = String(last.value).replace(/\s*\{#(?:.(?!\{#|\}))*.\}$/, '');
71
+ if (!last.value && heading.children.length > 1) heading.children.pop();
72
+ }
73
+ return id;
74
+ }
75
+
76
+ function commentHeadingId(heading) {
77
+ const last = heading.children?.at(-1);
78
+ if (last?.type !== 'mdxTextExpression' || !last.data?.estree) return undefined;
79
+ const program = last.data.estree;
80
+ if (program.body?.length !== 0 || program.comments?.length !== 1) return undefined;
81
+ const first = String(program.comments[0].value).trim().split(' ')[0];
82
+ if (!first?.startsWith('#') || first.length === 1) return undefined;
83
+ heading.children.pop();
84
+ const newLast = heading.children.at(-1);
85
+ if (newLast?.type === 'text') newLast.value = newLast.value.trimEnd();
86
+ return first.slice(1);
87
+ }
88
+
89
+ function headingId(node, headingText, slugger) {
90
+ const existing = node.data?.hProperties?.id;
91
+ if (typeof existing === 'string' && existing) return slugger.explicit(existing);
92
+ return (
93
+ commentHeadingId(node) ?? classicHeadingId(node, headingText) ?? slugger.generated(headingText)
94
+ );
95
+ }
96
+
97
+ export function remarkDocusaurusPageData(options = {}) {
98
+ return (tree, file) => {
99
+ const slugger = createSlugger(options.anchorsMaintainCase === true);
100
+ const toc = [];
101
+ let contentTitle;
102
+ let titleIndex = -1;
103
+ let contentTitleCandidate = true;
104
+ const children = Array.isArray(tree.children) ? tree.children : [];
105
+
106
+ for (let index = 0; index < children.length; index++) {
107
+ const node = children[index];
108
+ if (node.type === 'heading') {
109
+ const originalValue = textContent(node);
110
+ node.data ??= {};
111
+ node.data.hProperties ??= {};
112
+ const id = headingId(node, originalValue, slugger);
113
+ node.data.hProperties.id = id;
114
+ node.data.id = id;
115
+ const value = textContent(node);
116
+ if (contentTitleCandidate && node.depth === 1) {
117
+ contentTitle = value;
118
+ titleIndex = index;
119
+ contentTitleCandidate = false;
120
+ } else if (contentTitleCandidate) {
121
+ contentTitleCandidate = false;
122
+ }
123
+ if (
124
+ node.depth >= (options.tocMinHeadingLevel ?? 2) &&
125
+ node.depth <= (options.tocMaxHeadingLevel ?? 3)
126
+ ) {
127
+ toc.push({ value, id, level: node.depth });
128
+ }
129
+ }
130
+ if (node.type === 'thematicBreak') contentTitleCandidate = false;
131
+ }
132
+
133
+ const sourceFilePath = String(file.path ?? '');
134
+ walk(tree, (node) => {
135
+ if ((node.type === 'link' || node.type === 'definition') && typeof node.url === 'string') {
136
+ node.url = transformMarkdownLink(options.resolveMarkdownLink, node.url, sourceFilePath);
137
+ }
138
+ if (node.type === 'image' && typeof node.url === 'string') {
139
+ node.url = transformImageUrl(options.resolveMarkdownImage, node.url, sourceFilePath);
140
+ }
141
+ });
142
+
143
+ if (titleIndex !== -1) {
144
+ if (options.removeContentTitle === true) {
145
+ children.splice(titleIndex, 1);
146
+ } else {
147
+ children[titleIndex] = {
148
+ type: 'mdxJsxFlowElement',
149
+ name: 'header',
150
+ attributes: [],
151
+ children: [children[titleIndex]],
152
+ };
153
+ }
154
+ }
155
+ file.data[DATA_KEY] = {
156
+ toc,
157
+ contentTitle,
158
+ metadata: options.metadata ?? {},
159
+ assets:
160
+ typeof options.createAssets === 'function'
161
+ ? options.createAssets({
162
+ frontMatter: options.metadata?.frontMatter ?? {},
163
+ filePath: sourceFilePath,
164
+ })
165
+ : {},
166
+ };
167
+ };
168
+ }
169
+
170
+ function literal(value) {
171
+ if (value === undefined) {
172
+ return { type: 'Identifier', name: 'undefined' };
173
+ }
174
+ if (value === null || typeof value === 'string' || typeof value === 'boolean') {
175
+ return { type: 'Literal', value };
176
+ }
177
+ if (typeof value === 'number') {
178
+ if (!Number.isFinite(value)) {
179
+ throw new TypeError('Docusaurus MDX exports must contain finite numbers.');
180
+ }
181
+ return { type: 'Literal', value };
182
+ }
183
+ if (Array.isArray(value)) {
184
+ return { type: 'ArrayExpression', elements: value.map(literal) };
185
+ }
186
+ if (value && typeof value === 'object') {
187
+ return {
188
+ type: 'ObjectExpression',
189
+ properties: Object.entries(value)
190
+ .filter(([, item]) => item !== undefined)
191
+ .map(([key, item]) => ({
192
+ type: 'Property',
193
+ method: false,
194
+ shorthand: false,
195
+ computed: false,
196
+ kind: 'init',
197
+ key: /^[A-Za-z_$][\w$]*$/.test(key)
198
+ ? { type: 'Identifier', name: key }
199
+ : { type: 'Literal', value: key },
200
+ value: literal(item),
201
+ })),
202
+ };
203
+ }
204
+ throw new TypeError(`Docusaurus MDX export value ${String(value)} is not serializable.`);
205
+ }
206
+
207
+ function exportedConstant(name, expression) {
208
+ return {
209
+ type: 'ExportNamedDeclaration',
210
+ declaration: {
211
+ type: 'VariableDeclaration',
212
+ kind: 'const',
213
+ declarations: [
214
+ {
215
+ type: 'VariableDeclarator',
216
+ id: { type: 'Identifier', name },
217
+ init: expression,
218
+ },
219
+ ],
220
+ },
221
+ specifiers: [],
222
+ source: null,
223
+ };
224
+ }
225
+
226
+ export function recmaDocusaurusPageExports() {
227
+ return (tree, file) => {
228
+ const data = file.data[DATA_KEY] ?? {
229
+ toc: [],
230
+ contentTitle: undefined,
231
+ metadata: {},
232
+ assets: {},
233
+ };
234
+ tree.body.push(
235
+ exportedConstant('frontMatter', { type: 'Identifier', name: 'frontmatter' }),
236
+ exportedConstant('contentTitle', literal(data.contentTitle)),
237
+ exportedConstant('toc', literal(data.toc)),
238
+ exportedConstant('metadata', literal(data.metadata)),
239
+ exportedConstant('assets', literal(data.assets)),
240
+ );
241
+ };
242
+ }
243
+
244
+ function compileOptions(options) {
245
+ const {
246
+ beforeDefaultRemarkPlugins = [],
247
+ remarkPlugins = [],
248
+ beforeDefaultRehypePlugins = [],
249
+ rehypePlugins = [],
250
+ recmaPlugins = [],
251
+ metadata,
252
+ createAssets,
253
+ resolveMarkdownLink,
254
+ resolveMarkdownImage,
255
+ removeContentTitle,
256
+ anchorsMaintainCase,
257
+ tocMinHeadingLevel,
258
+ tocMaxHeadingLevel,
259
+ ...base
260
+ } = options;
261
+ const pageDataOptions = {
262
+ metadata,
263
+ createAssets,
264
+ resolveMarkdownLink,
265
+ resolveMarkdownImage,
266
+ removeContentTitle,
267
+ anchorsMaintainCase,
268
+ tocMinHeadingLevel,
269
+ tocMaxHeadingLevel,
270
+ };
271
+ return {
272
+ ...base,
273
+ remarkPlugins: [
274
+ ...beforeDefaultRemarkPlugins,
275
+ ...defaultRemarkPlugins,
276
+ [remarkDocusaurusPageData, pageDataOptions],
277
+ ...remarkPlugins,
278
+ ],
279
+ rehypePlugins: [...beforeDefaultRehypePlugins, ...rehypePlugins],
280
+ recmaPlugins: [...recmaPlugins, recmaDocusaurusPageExports],
281
+ };
282
+ }
283
+
284
+ function escapeMarkdownHeadingIds(source) {
285
+ const lines = source.split('\n');
286
+ let fence;
287
+
288
+ for (let index = 0; index < lines.length; index++) {
289
+ const line = lines[index];
290
+ const match = /^ {0,3}(`{3,}|~{3,})/.exec(line);
291
+ if (match) {
292
+ const marker = match[1];
293
+ if (fence === undefined) {
294
+ fence = { character: marker[0], length: marker.length };
295
+ } else if (
296
+ marker[0] === fence.character &&
297
+ marker.length >= fence.length &&
298
+ /^[\t ]*\r?$/.test(line.slice(match[0].length))
299
+ ) {
300
+ fence = undefined;
301
+ }
302
+ continue;
303
+ }
304
+ if (fence !== undefined) continue;
305
+ lines[index] = line.replace(/^#{1,6}(?!#).*/, (heading) =>
306
+ heading.replace('{#', '\\{#').replace('\\\\{#', '\\{#'),
307
+ );
308
+ }
309
+
310
+ return lines.join('\n');
311
+ }
312
+
313
+ export function compileDocusaurusMdx(source, id, options = {}) {
314
+ return compileMdx(escapeMarkdownHeadingIds(source), id, compileOptions(options));
315
+ }
316
+
317
+ export function compileDocusaurusMdxSync(source, id, options = {}) {
318
+ return compileMdxSync(escapeMarkdownHeadingIds(source), id, compileOptions(options));
319
+ }
package/src/version.js ADDED
@@ -0,0 +1,68 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { createRequire } from 'node:module';
4
+
5
+ export const SUPPORTED_DOCUSARUS_VERSION = '3.10.1';
6
+ export const MINIMUM_DOCUSARUS_NODE_VERSION = '20.0.0';
7
+
8
+ const packageRequire = createRequire(import.meta.url);
9
+
10
+ function versionParts(version) {
11
+ return version.split('.', 3).map((part) => Number.parseInt(part, 10) || 0);
12
+ }
13
+
14
+ function versionAtLeast(version, minimum) {
15
+ const received = versionParts(version);
16
+ const required = versionParts(minimum);
17
+ for (let index = 0; index < 3; index++) {
18
+ if (received[index] > required[index]) return true;
19
+ if (received[index] < required[index]) return false;
20
+ }
21
+ return true;
22
+ }
23
+
24
+ function siteRequire(siteDir) {
25
+ return createRequire(path.join(path.resolve(siteDir), 'package.json'));
26
+ }
27
+
28
+ export async function resolveDocusaurusCore(siteDir) {
29
+ let manifestPath;
30
+ try {
31
+ manifestPath = siteRequire(siteDir).resolve('@docusaurus/core/package.json');
32
+ } catch (siteError) {
33
+ try {
34
+ manifestPath = packageRequire.resolve('@docusaurus/core/package.json');
35
+ } catch {
36
+ throw new Error(
37
+ `[@octanejs/docusaurus] Could not resolve @docusaurus/core from ${path.resolve(siteDir)}. ` +
38
+ `Install @docusaurus/core@${SUPPORTED_DOCUSARUS_VERSION} in the site.`,
39
+ { cause: siteError },
40
+ );
41
+ }
42
+ }
43
+ const manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
44
+ return {
45
+ manifestPath,
46
+ packageRoot: path.dirname(manifestPath),
47
+ version: String(manifest.version ?? ''),
48
+ };
49
+ }
50
+
51
+ export function assertSupportedDocusaurusRuntime(resolved, options = {}) {
52
+ if (!versionAtLeast(process.versions.node, MINIMUM_DOCUSARUS_NODE_VERSION)) {
53
+ throw new Error(
54
+ `[@octanejs/docusaurus] Docusaurus ${SUPPORTED_DOCUSARUS_VERSION} requires Node ` +
55
+ `${MINIMUM_DOCUSARUS_NODE_VERSION} or newer; received ${process.versions.node}.`,
56
+ );
57
+ }
58
+ if (
59
+ resolved.version !== SUPPORTED_DOCUSARUS_VERSION &&
60
+ options.allowUnsupportedVersion !== true
61
+ ) {
62
+ throw new Error(
63
+ `[@octanejs/docusaurus] This integration is pinned to @docusaurus/core@` +
64
+ `${SUPPORTED_DOCUSARUS_VERSION}; resolved ${resolved.version || 'an unknown version'}. ` +
65
+ `Pass allowUnsupportedVersion: true only for an explicit compatibility experiment.`,
66
+ );
67
+ }
68
+ }
package/src/vite.js ADDED
@@ -0,0 +1,202 @@
1
+ import path from 'node:path';
2
+ import { createOctaneCompiler } from 'octane/compiler/bundler';
3
+ import { compileDocusaurusMdx } from './mdx.js';
4
+ import { loadDocusaurusSite } from './load-site.js';
5
+ import { createDocusaurusManifest, resolveDocusaurusId } from './manifest.js';
6
+
7
+ export const DOCUSAURUS_MANIFEST_ID = 'virtual:octane-docusaurus-manifest';
8
+ const RESOLVED_DOCUSAURUS_MANIFEST_ID = `\0${DOCUSAURUS_MANIFEST_ID}`;
9
+
10
+ function cleanId(id) {
11
+ return id.split(/[?#]/, 1)[0];
12
+ }
13
+
14
+ function createContentIndex(manifest) {
15
+ const result = new Map();
16
+ for (const [source, metadata] of Object.entries(manifest.content)) {
17
+ const resolved = path.isAbsolute(source) ? source : resolveDocusaurusId(source, manifest);
18
+ if (resolved !== null) result.set(cleanId(resolved), metadata);
19
+ }
20
+ return result;
21
+ }
22
+
23
+ function serializableManifest(manifest) {
24
+ return JSON.stringify(manifest)
25
+ .replace(/\u2028/g, '\\u2028')
26
+ .replace(/\u2029/g, '\\u2029')
27
+ .replace(/</g, '\\u003c');
28
+ }
29
+
30
+ function createSharedState(options) {
31
+ let loaded;
32
+ let manifest;
33
+ let contentIndex = new Map();
34
+ let loading;
35
+ let root = path.resolve(process.cwd(), options.siteDir ?? '.');
36
+
37
+ async function refresh() {
38
+ if (loading) return loading;
39
+ loading = (async () => {
40
+ const nextLoaded = await loadDocusaurusSite({
41
+ siteDir: root,
42
+ outDir: options.outDir,
43
+ config: options.config,
44
+ locale: options.locale,
45
+ automaticBaseUrlLocalizationDisabled: options.automaticBaseUrlLocalizationDisabled,
46
+ allowUnsupportedVersion: options.allowUnsupportedVersion,
47
+ });
48
+ const nextManifest = await createDocusaurusManifest(nextLoaded);
49
+ const nextContentIndex = createContentIndex(nextManifest);
50
+ loaded = nextLoaded;
51
+ manifest = nextManifest;
52
+ contentIndex = nextContentIndex;
53
+ return nextManifest;
54
+ })().finally(() => {
55
+ loading = undefined;
56
+ });
57
+ return loading;
58
+ }
59
+
60
+ return {
61
+ setRoot(value) {
62
+ root = path.resolve(value, options.siteDir ?? '.');
63
+ },
64
+ refresh,
65
+ async getManifest() {
66
+ return loading ?? manifest ?? refresh();
67
+ },
68
+ getLoaded() {
69
+ return loaded;
70
+ },
71
+ async metadataFor(id) {
72
+ await this.getManifest();
73
+ return contentIndex.get(cleanId(id));
74
+ },
75
+ };
76
+ }
77
+
78
+ export function docusaurusBridge(options = {}, shared = createSharedState(options)) {
79
+ return {
80
+ name: 'octane-docusaurus-bridge',
81
+ enforce: 'pre',
82
+ api: {
83
+ getManifest: () => shared.getManifest(),
84
+ reload: () => shared.refresh(),
85
+ },
86
+ async configResolved(config) {
87
+ shared.setRoot(config.root ?? process.cwd());
88
+ await shared.refresh();
89
+ },
90
+ async buildStart() {
91
+ const manifest = await shared.getManifest();
92
+ const loaded = shared.getLoaded();
93
+ const siteConfigPath = loaded?.site?.props?.siteConfigPath;
94
+ if (typeof siteConfigPath === 'string') this.addWatchFile?.(siteConfigPath);
95
+ for (const plugin of loaded?.site?.props?.plugins ?? []) {
96
+ if (typeof plugin.getPathsToWatch !== 'function') continue;
97
+ for (const watched of (await plugin.getPathsToWatch()) ?? []) {
98
+ this.addWatchFile?.(watched);
99
+ }
100
+ }
101
+ for (const source of Object.keys(manifest.content)) {
102
+ const resolved = path.isAbsolute(source) ? source : resolveDocusaurusId(source, manifest);
103
+ if (resolved !== null) this.addWatchFile?.(cleanId(resolved));
104
+ }
105
+ },
106
+ async watchChange() {
107
+ await shared.refresh();
108
+ },
109
+ async resolveId(id) {
110
+ if (id === DOCUSAURUS_MANIFEST_ID) return RESOLVED_DOCUSAURUS_MANIFEST_ID;
111
+ const manifest = await shared.getManifest();
112
+ return resolveDocusaurusId(id, manifest);
113
+ },
114
+ async load(id) {
115
+ if (id !== RESOLVED_DOCUSAURUS_MANIFEST_ID) return null;
116
+ return `export default ${serializableManifest(await shared.getManifest())};\n`;
117
+ },
118
+ };
119
+ }
120
+
121
+ export function docusaurusMdx(options = {}) {
122
+ const { ssr: forceSsr, md, hmr, profile, metadata: metadataOption, ...compileOptions } = options;
123
+ let hmrEnabled = hmr;
124
+ let projectRoot = process.cwd();
125
+ let profileIds = createOctaneCompiler({ root: projectRoot });
126
+ const includeMd = md !== false;
127
+ const warnedByFile = new Map();
128
+
129
+ return {
130
+ name: 'octane-docusaurus-mdx',
131
+ enforce: 'pre',
132
+ configResolved(config) {
133
+ projectRoot = config.root ?? projectRoot;
134
+ profileIds = createOctaneCompiler({ root: projectRoot });
135
+ if (hmrEnabled === undefined) hmrEnabled = config.command === 'serve';
136
+ },
137
+ watchChange(id) {
138
+ profileIds.invalidate(id);
139
+ warnedByFile.delete(cleanId(id));
140
+ },
141
+ async transform(code, id, transformOptions) {
142
+ const [file, query = ''] = id.split('?');
143
+ if (!(file.endsWith('.mdx') || (includeMd && file.endsWith('.md')))) return null;
144
+ if (/(^|&)(raw|url|inline|worker|sharedworker)(=|&|$)/.test(query)) return null;
145
+ const ssr =
146
+ forceSsr !== undefined
147
+ ? forceSsr
148
+ : transformOptions?.ssr === true || this.environment?.config?.consumer === 'server';
149
+ const profiling = !ssr && profile === true;
150
+ const profileIdentity = profiling ? profileIds.resolveProfileModuleId(file) : null;
151
+ for (const dependency of profileIdentity?.dependencies ?? []) {
152
+ this.addWatchFile?.(dependency);
153
+ }
154
+ const metadata =
155
+ typeof metadataOption === 'function' ? await metadataOption(file) : metadataOption;
156
+ const result = await compileDocusaurusMdx(code, profileIdentity?.id ?? file, {
157
+ ...compileOptions,
158
+ metadata,
159
+ mode: ssr ? 'server' : 'client',
160
+ hmr: !ssr && !!hmrEnabled,
161
+ dev: !ssr && !!hmrEnabled,
162
+ profile: profiling,
163
+ });
164
+ let warned = warnedByFile.get(file);
165
+ if (warned === undefined) {
166
+ warned = new Set();
167
+ warnedByFile.set(file, warned);
168
+ }
169
+ for (const diagnostic of result.diagnostics) {
170
+ const key = `${diagnostic.code}:${diagnostic.start.offset}:${diagnostic.end.offset}:${diagnostic.message}`;
171
+ if (warned.has(key)) continue;
172
+ warned.add(key);
173
+ this.warn?.({
174
+ code: diagnostic.code,
175
+ message: diagnostic.message,
176
+ id: diagnostic.filename,
177
+ loc: {
178
+ file: diagnostic.filename,
179
+ line: diagnostic.start.line,
180
+ column: diagnostic.start.column,
181
+ },
182
+ });
183
+ }
184
+ return result;
185
+ },
186
+ };
187
+ }
188
+
189
+ export function docusaurus(options = {}) {
190
+ const shared = createSharedState(options);
191
+ const bridge = docusaurusBridge(options, shared);
192
+ const mdx = docusaurusMdx({
193
+ ...options.mdx,
194
+ metadata: async (id) => {
195
+ const fromSite = await shared.metadataFor(id);
196
+ if (fromSite !== undefined) return fromSite;
197
+ const configured = options.mdx?.metadata;
198
+ return typeof configured === 'function' ? configured(id) : configured;
199
+ },
200
+ });
201
+ return [bridge, mdx];
202
+ }
@@ -0,0 +1,107 @@
1
+ export declare const SUPPORTED_DOCUSARUS_VERSION = '3.10.1';
2
+ export declare const MINIMUM_DOCUSARUS_NODE_VERSION = '20.0.0';
3
+
4
+ export interface ResolvedDocusaurusCore {
5
+ manifestPath: string;
6
+ packageRoot: string;
7
+ version: string;
8
+ }
9
+
10
+ export interface LoadDocusaurusSiteOptions {
11
+ siteDir?: string;
12
+ outDir?: string;
13
+ config?: string;
14
+ locale?: string;
15
+ automaticBaseUrlLocalizationDisabled?: boolean;
16
+ allowUnsupportedVersion?: boolean;
17
+ }
18
+
19
+ export interface LoadedDocusaurusSite {
20
+ corePath: string;
21
+ docusaurusVersion: string;
22
+ site: {
23
+ props: Record<string, any> & {
24
+ siteDir: string;
25
+ generatedFilesDir: string;
26
+ outDir: string;
27
+ baseUrl: string;
28
+ routesPaths: string[];
29
+ routes: any[];
30
+ plugins: any[];
31
+ };
32
+ params: Record<string, any>;
33
+ };
34
+ }
35
+
36
+ export interface ImportedDocusaurusModule {
37
+ __import: true;
38
+ path: string;
39
+ query?: unknown;
40
+ }
41
+
42
+ export type DocusaurusModule = string | ImportedDocusaurusModule;
43
+
44
+ export interface DocusaurusManifestRoute {
45
+ id: string;
46
+ path: string;
47
+ component: DocusaurusModule;
48
+ exact: boolean;
49
+ priority?: number;
50
+ modules?: Record<string, DocusaurusModule | DocusaurusModule[]>;
51
+ context?: unknown;
52
+ props?: unknown;
53
+ metadata?: unknown;
54
+ plugin?: unknown;
55
+ attributes?: Record<string, unknown>;
56
+ children: DocusaurusManifestRoute[];
57
+ }
58
+
59
+ export interface DocusaurusManifestAliases {
60
+ site: string;
61
+ generated: string;
62
+ docs: string;
63
+ theme: Record<string, string>;
64
+ themeOriginal: Record<string, string>;
65
+ themeInit: Record<string, string>;
66
+ }
67
+
68
+ export interface DocusaurusManifest {
69
+ schemaVersion: 1;
70
+ docusaurusVersion: string;
71
+ siteDir: string;
72
+ generatedFilesDir: string;
73
+ outDir: string;
74
+ baseUrl: string;
75
+ routesPaths: string[];
76
+ routes: DocusaurusManifestRoute[];
77
+ globalData: Record<string, unknown>;
78
+ content: Record<string, Record<string, any>>;
79
+ aliases: DocusaurusManifestAliases;
80
+ }
81
+
82
+ export declare function resolveDocusaurusCore(siteDir: string): Promise<ResolvedDocusaurusCore>;
83
+
84
+ export declare function assertSupportedDocusaurusRuntime(
85
+ resolved: ResolvedDocusaurusCore,
86
+ options?: { allowUnsupportedVersion?: boolean },
87
+ ): void;
88
+
89
+ export declare function loadDocusaurusSite(
90
+ options?: LoadDocusaurusSiteOptions,
91
+ ): Promise<LoadedDocusaurusSite>;
92
+
93
+ export declare function createDocusaurusManifest(
94
+ loaded: LoadedDocusaurusSite,
95
+ ): Promise<DocusaurusManifest>;
96
+
97
+ export declare function resolveDocusaurusId(
98
+ id: string,
99
+ manifest: DocusaurusManifest,
100
+ ): string | null;
101
+
102
+ export declare function writeDocusaurusManifest(
103
+ manifest: DocusaurusManifest,
104
+ filename: string,
105
+ ): Promise<string>;
106
+
107
+ export declare function readDocusaurusManifest(filename: string): Promise<DocusaurusManifest>;