@lexibase/rdx-core 2.2.0 → 3.0.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/check/index.js +3 -3
- package/dist/{chunk-J7VCQHSL.js → chunk-6WNFE2QG.js} +15 -1
- package/dist/chunk-GBW4LSBN.js +312 -0
- package/dist/{chunk-GYLAW7YX.js → chunk-GSIKV6MV.js} +29 -4
- package/dist/{chunk-M32EH5KP.js → chunk-J674JOK2.js} +57 -36
- package/dist/{chunk-36CTLWNI.js → chunk-L7FZDK6G.js} +34 -11
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +3 -1
- package/dist/{document-links-B9zsPsqx.d.ts → document-links-fo6ul9xz.d.ts} +1 -0
- package/dist/{index-DjuvW7o_.d.ts → index-2qiAhOwp.d.ts} +3 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -9
- package/dist/mdx/index.d.ts +6 -2
- package/dist/mdx/index.js +3973 -33
- package/dist/search/index.js +2 -2
- package/package.json +5 -4
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
// src/content/document-links.ts
|
|
2
|
+
import path2 from "path";
|
|
3
|
+
|
|
4
|
+
// src/content/filenames.ts
|
|
2
5
|
import path from "path";
|
|
6
|
+
var documentExtension = /\.mdx?$/;
|
|
7
|
+
var DEFAULT_POSITION = Number.MAX_SAFE_INTEGER;
|
|
8
|
+
function orderedName(name) {
|
|
9
|
+
const match = /^(\d{2})-(.+)$/.exec(name);
|
|
10
|
+
return match && match[2] !== "." && match[2] !== ".." ? { name: match[2], position: Number(match[1]) } : { name, position: DEFAULT_POSITION };
|
|
11
|
+
}
|
|
12
|
+
function slugFromRelativePath(relativePath) {
|
|
13
|
+
return relativePath.replace(documentExtension, "").split(path.sep).map((segment) => orderedName(segment).name).join("/");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/content/document-links.ts
|
|
3
17
|
var RdxDocumentLinkError = class extends Error {
|
|
4
18
|
constructor(sourcePath, href, reason) {
|
|
5
19
|
super(`[RDX] Invalid document link "${href}" in ${sourcePath}: ${reason}`);
|
|
@@ -9,16 +23,16 @@ var RdxDocumentLinkError = class extends Error {
|
|
|
9
23
|
reason;
|
|
10
24
|
};
|
|
11
25
|
function createDocumentLinkResolver(options) {
|
|
12
|
-
const root =
|
|
13
|
-
const current =
|
|
26
|
+
const root = path2.resolve(options.sourceRoot);
|
|
27
|
+
const current = path2.resolve(options.sourcePath);
|
|
14
28
|
const documents = new Map(
|
|
15
29
|
options.documents.flatMap((page) => [
|
|
16
|
-
[
|
|
30
|
+
[path2.resolve(page.sourcePath), page.slug],
|
|
17
31
|
...options.virtualPaths ? [
|
|
18
32
|
[
|
|
19
|
-
|
|
33
|
+
path2.resolve(
|
|
20
34
|
root,
|
|
21
|
-
`${page.slug}${
|
|
35
|
+
`${page.slug}${path2.extname(page.sourcePath)}`
|
|
22
36
|
),
|
|
23
37
|
page.slug
|
|
24
38
|
]
|
|
@@ -49,18 +63,23 @@ function createDocumentLinkResolver(options) {
|
|
|
49
63
|
const fail = (reason) => {
|
|
50
64
|
throw new RdxDocumentLinkError(current, href, reason);
|
|
51
65
|
};
|
|
52
|
-
if (
|
|
66
|
+
if (path2.isAbsolute(decoded) || decoded.includes("\\") || decoded.includes("\0"))
|
|
53
67
|
fail("use forward-slash relative paths without null characters.");
|
|
54
|
-
const target =
|
|
55
|
-
const relative =
|
|
56
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
68
|
+
const target = path2.resolve(path2.dirname(current), decoded);
|
|
69
|
+
const relative = path2.relative(root, target);
|
|
70
|
+
if (relative === ".." || relative.startsWith(`..${path2.sep}`) || path2.isAbsolute(relative))
|
|
57
71
|
fail("the destination escapes this documentation source.");
|
|
58
|
-
const slug = documents.get(target) ??
|
|
72
|
+
const slug = documents.get(target) ?? (options.virtualPaths ? documents.get(
|
|
73
|
+
path2.resolve(
|
|
74
|
+
root,
|
|
75
|
+
`${slugFromRelativePath(relative)}${path2.extname(relative)}`
|
|
76
|
+
)
|
|
77
|
+
) : void 0) ?? fail(
|
|
59
78
|
`"${relative}" does not exist in this documentation source${options.routePrefix ? ` (${options.routePrefix})` : ""}.`
|
|
60
79
|
);
|
|
61
80
|
if ((routeCounts.get(slug) ?? 0) > 1)
|
|
62
81
|
fail("the destination has an ambiguous documentation route.");
|
|
63
|
-
const route = [
|
|
82
|
+
const route = options.documentHref?.(slug) ?? [
|
|
64
83
|
options.basePath ?? "/docs",
|
|
65
84
|
options.routePrefix && encodeURIComponent(options.routePrefix),
|
|
66
85
|
...slug.split("/").map(encodeURIComponent)
|
|
@@ -114,6 +133,10 @@ function remarkDocumentLinks(options) {
|
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
export {
|
|
136
|
+
documentExtension,
|
|
137
|
+
DEFAULT_POSITION,
|
|
138
|
+
orderedName,
|
|
139
|
+
slugFromRelativePath,
|
|
117
140
|
RdxDocumentLinkError,
|
|
118
141
|
createDocumentLinkResolver,
|
|
119
142
|
remarkDocumentLinks
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '@lexibase/rdx-types';
|
|
2
|
-
export { R as RdxConfigError, h as collectSnapshotContributions, c as createRdxProject, d as defineConfig, g as getContentSources, n as normalizeLocalization, r as resolveConfig, f as resolveProjectPath } from '../index-
|
|
2
|
+
export { R as RdxConfigError, h as collectSnapshotContributions, c as createRdxProject, d as defineConfig, g as getContentSources, j as getEditPageHref, n as normalizeLocalization, r as resolveConfig, f as resolveProjectPath } from '../index-2qiAhOwp.js';
|
package/dist/config/index.js
CHANGED
|
@@ -3,10 +3,11 @@ import {
|
|
|
3
3
|
collectSnapshotContributions,
|
|
4
4
|
createRdxProject,
|
|
5
5
|
defineConfig,
|
|
6
|
+
getEditPageHref,
|
|
6
7
|
normalizeLocalization,
|
|
7
8
|
resolveConfig,
|
|
8
9
|
resolveProjectPath
|
|
9
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-GSIKV6MV.js";
|
|
10
11
|
import {
|
|
11
12
|
getContentSources
|
|
12
13
|
} from "../chunk-SNNEXRLQ.js";
|
|
@@ -16,6 +17,7 @@ export {
|
|
|
16
17
|
createRdxProject,
|
|
17
18
|
defineConfig,
|
|
18
19
|
getContentSources,
|
|
20
|
+
getEditPageHref,
|
|
19
21
|
normalizeLocalization,
|
|
20
22
|
resolveConfig,
|
|
21
23
|
resolveProjectPath
|
|
@@ -39,6 +39,8 @@ declare function getLanguageLinks(project: RdxProject, source: RdxContentSource,
|
|
|
39
39
|
}[];
|
|
40
40
|
declare function isFallbackPage(project: RdxProject, source: RdxContentSource, sourcePath: string): boolean;
|
|
41
41
|
|
|
42
|
+
declare function getEditPageHref(project: Pick<RdxProject, 'config' | 'rootDir'>, source: Pick<RdxContentSource, 'id'> | undefined, sourcePath: string): string | undefined;
|
|
43
|
+
|
|
42
44
|
declare function resolveConfig(input: unknown): ResolvedRdxConfig;
|
|
43
45
|
declare function defineConfig(config: RDXConfig): RDXConfig;
|
|
44
46
|
declare function createRdxProject(input: unknown, { rootDir, command, }?: {
|
|
@@ -46,4 +48,4 @@ declare function createRdxProject(input: unknown, { rootDir, command, }?: {
|
|
|
46
48
|
command?: string;
|
|
47
49
|
}): Promise<RdxProject>;
|
|
48
50
|
|
|
49
|
-
export { RdxConfigError as R, getDocsHref as a, getLanguageLinks as b, createRdxProject as c, defineConfig as d, getLocalizedProject as e, resolveProjectPath as f, getContentSources as g, collectSnapshotContributions as h, isFallbackPage as i, normalizeLocalization as n, resolveConfig as r };
|
|
51
|
+
export { RdxConfigError as R, getDocsHref as a, getLanguageLinks as b, createRdxProject as c, defineConfig as d, getLocalizedProject as e, resolveProjectPath as f, getContentSources as g, collectSnapshotContributions as h, isFallbackPage as i, getEditPageHref as j, normalizeLocalization as n, resolveConfig as r };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _lexibase_rdx_types from '@lexibase/rdx-types';
|
|
2
2
|
import { RdxDocsOptions, RdxDocCategory, RdxDocument, RdxProject, RdxContentSource } from '@lexibase/rdx-types';
|
|
3
|
-
export { R as RdxConfigError, c as createRdxProject, d as defineConfig, g as getContentSources, a as getDocsHref, b as getLanguageLinks, e as getLocalizedProject, i as isFallbackPage, r as resolveConfig, f as resolveProjectPath } from './index-
|
|
4
|
-
export { D as DocumentLinkOptions, R as RdxDocumentLinkError, c as createDocumentLinkResolver } from './document-links-
|
|
3
|
+
export { R as RdxConfigError, c as createRdxProject, d as defineConfig, g as getContentSources, a as getDocsHref, b as getLanguageLinks, e as getLocalizedProject, i as isFallbackPage, r as resolveConfig, f as resolveProjectPath } from './index-2qiAhOwp.js';
|
|
4
|
+
export { D as DocumentLinkOptions, R as RdxDocumentLinkError, c as createDocumentLinkResolver } from './document-links-fo6ul9xz.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Reads the documentation tree from the user's project. The URL slug always
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RdxConfigError,
|
|
3
|
-
createRdxProject,
|
|
4
|
-
defineConfig,
|
|
5
|
-
resolveConfig,
|
|
6
|
-
resolveProjectPath
|
|
7
|
-
} from "./chunk-GYLAW7YX.js";
|
|
8
1
|
import {
|
|
9
2
|
getDocsIndex,
|
|
10
3
|
getDocsPaths,
|
|
@@ -12,7 +5,14 @@ import {
|
|
|
12
5
|
getProjectDocsPaths,
|
|
13
6
|
getSourceOptions,
|
|
14
7
|
resolveDocsRoute
|
|
15
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GBW4LSBN.js";
|
|
9
|
+
import {
|
|
10
|
+
RdxConfigError,
|
|
11
|
+
createRdxProject,
|
|
12
|
+
defineConfig,
|
|
13
|
+
resolveConfig,
|
|
14
|
+
resolveProjectPath
|
|
15
|
+
} from "./chunk-GSIKV6MV.js";
|
|
16
16
|
import {
|
|
17
17
|
getContentSources,
|
|
18
18
|
getDocsHref,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import {
|
|
24
24
|
RdxDocumentLinkError,
|
|
25
25
|
createDocumentLinkResolver
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-L7FZDK6G.js";
|
|
27
27
|
export {
|
|
28
28
|
RdxConfigError,
|
|
29
29
|
RdxDocumentLinkError,
|
package/dist/mdx/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { D as DocumentLinkOptions } from '../document-links-fo6ul9xz.js';
|
|
2
|
+
export { r as remarkDocumentLinks } from '../document-links-fo6ul9xz.js';
|
|
2
3
|
export { default as rehypeDocumentationHeadings } from 'rehype-slug';
|
|
3
4
|
import rehypeShiki from '@shikijs/rehype';
|
|
4
5
|
import remarkDirective from 'remark-directive';
|
|
@@ -11,4 +12,7 @@ declare function remarkDocumentationComponents(this: ThisParameterType<typeof re
|
|
|
11
12
|
value: unknown;
|
|
12
13
|
}) => void;
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
/** Serialize document content without evaluating or publishing MDX JavaScript. */
|
|
16
|
+
declare function exportMarkdownBody(content: string, links: DocumentLinkOptions): string;
|
|
17
|
+
|
|
18
|
+
export { DocumentLinkOptions, exportMarkdownBody, rehypeDocumentationCode, remarkDocumentationComponents };
|