@lexibase/rdx-core 3.0.0 → 3.1.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/{chunk-GSIKV6MV.js → chunk-KPVVN2MN.js} +173 -5
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +11 -3
- package/dist/{index-2qiAhOwp.d.ts → index-CIBgPARs.d.ts} +6 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mdx/index.d.ts +4 -2
- package/dist/mdx/index.js +66 -3952
- package/package.json +5 -4
- package/dist/chunk-J674JOK2.js +0 -310
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/config/index.ts
|
|
2
|
-
import
|
|
3
|
-
import { existsSync, readdirSync } from "fs";
|
|
2
|
+
import path7 from "path";
|
|
3
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "fs";
|
|
4
|
+
import { bundledThemes } from "shiki/themes";
|
|
4
5
|
|
|
5
6
|
// src/config/error.ts
|
|
6
7
|
var RdxConfigError = class extends Error {
|
|
@@ -578,6 +579,90 @@ function getEditPageHref(project, source, sourcePath) {
|
|
|
578
579
|
return url.href;
|
|
579
580
|
}
|
|
580
581
|
|
|
582
|
+
// src/config/document-dates.ts
|
|
583
|
+
import { execFileSync } from "child_process";
|
|
584
|
+
import fs5 from "fs";
|
|
585
|
+
import path6 from "path";
|
|
586
|
+
var snapshotDatesFilename = "_rdx-last-updated.json";
|
|
587
|
+
var datePattern = /^\d{4}-\d{2}-\d{2}$/;
|
|
588
|
+
function relativeFile(root, file) {
|
|
589
|
+
const relative = path6.relative(root, file);
|
|
590
|
+
if (!relative || path6.isAbsolute(relative) || relative.split(path6.sep)[0] === "..")
|
|
591
|
+
return;
|
|
592
|
+
return relative.split(path6.sep).join("/");
|
|
593
|
+
}
|
|
594
|
+
function createDocumentDateReader(root) {
|
|
595
|
+
const git = (...args) => execFileSync("git", ["--literal-pathspecs", ...args], {
|
|
596
|
+
cwd: root,
|
|
597
|
+
encoding: "utf8",
|
|
598
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
599
|
+
timeout: 3e3,
|
|
600
|
+
windowsHide: true
|
|
601
|
+
}).trim();
|
|
602
|
+
let shallow;
|
|
603
|
+
try {
|
|
604
|
+
shallow = git("rev-parse", "--is-shallow-repository") === "true";
|
|
605
|
+
} catch {
|
|
606
|
+
return () => void 0;
|
|
607
|
+
}
|
|
608
|
+
return (file) => {
|
|
609
|
+
const relative = relativeFile(root, file);
|
|
610
|
+
if (!relative) return;
|
|
611
|
+
try {
|
|
612
|
+
git("ls-files", "--error-unmatch", "--", relative);
|
|
613
|
+
git("diff", "--quiet", "--no-ext-diff", "HEAD", "--", relative);
|
|
614
|
+
const [date, parents] = git(
|
|
615
|
+
"log",
|
|
616
|
+
"-1",
|
|
617
|
+
"--format=%cs%x00%P",
|
|
618
|
+
"HEAD",
|
|
619
|
+
"--",
|
|
620
|
+
relative
|
|
621
|
+
).split("\0");
|
|
622
|
+
if (date && datePattern.test(date) && (!shallow || parents)) return date;
|
|
623
|
+
} catch {
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
function collectSnapshotDocumentDates(directory, dateFor) {
|
|
628
|
+
const dates = /* @__PURE__ */ Object.create(null);
|
|
629
|
+
function visit(folder) {
|
|
630
|
+
for (const entry of fs5.readdirSync(
|
|
631
|
+
/* turbopackIgnore: true */
|
|
632
|
+
folder,
|
|
633
|
+
{ withFileTypes: true }
|
|
634
|
+
).sort((a, b) => a.name.localeCompare(b.name, "en"))) {
|
|
635
|
+
const file = path6.join(folder, entry.name);
|
|
636
|
+
if (entry.isDirectory()) visit(file);
|
|
637
|
+
else if (entry.isFile() && /\.mdx?$/.test(entry.name)) {
|
|
638
|
+
const date = dateFor(file);
|
|
639
|
+
if (date) dates[relativeFile(directory, file)] = date;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
visit(directory);
|
|
644
|
+
return Object.keys(dates).length ? JSON.stringify(dates, null, 2) + "\n" : void 0;
|
|
645
|
+
}
|
|
646
|
+
function getSnapshotDocumentDate(directory, file) {
|
|
647
|
+
const relative = relativeFile(directory, file);
|
|
648
|
+
if (!relative) return;
|
|
649
|
+
try {
|
|
650
|
+
const filename = path6.join(directory, snapshotDatesFilename);
|
|
651
|
+
const dates = JSON.parse(
|
|
652
|
+
fs5.readFileSync(
|
|
653
|
+
/* turbopackIgnore: true */
|
|
654
|
+
filename,
|
|
655
|
+
"utf8"
|
|
656
|
+
)
|
|
657
|
+
);
|
|
658
|
+
if (!dates || typeof dates !== "object" || !Object.hasOwn(dates, relative))
|
|
659
|
+
return;
|
|
660
|
+
const date = dates[relative];
|
|
661
|
+
if (typeof date === "string" && datePattern.test(date)) return date;
|
|
662
|
+
} catch {
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
581
666
|
// src/config/index.ts
|
|
582
667
|
function record(value) {
|
|
583
668
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -632,7 +717,8 @@ function resolveConfig(input) {
|
|
|
632
717
|
"homepage",
|
|
633
718
|
"TOC",
|
|
634
719
|
"search",
|
|
635
|
-
"editPage"
|
|
720
|
+
"editPage",
|
|
721
|
+
"syntaxHighlighting"
|
|
636
722
|
],
|
|
637
723
|
""
|
|
638
724
|
);
|
|
@@ -644,6 +730,44 @@ function resolveConfig(input) {
|
|
|
644
730
|
text(config.description, "description", true);
|
|
645
731
|
if (config.lang !== void 0) text(config.lang, "lang");
|
|
646
732
|
validateMetadata(config.metadata);
|
|
733
|
+
if (config.syntaxHighlighting !== void 0) {
|
|
734
|
+
const highlighting = object(config.syntaxHighlighting, "syntaxHighlighting");
|
|
735
|
+
keys(highlighting, ["languages", "themes"], "syntaxHighlighting.");
|
|
736
|
+
if (highlighting.themes !== void 0) {
|
|
737
|
+
const themes = object(highlighting.themes, "syntaxHighlighting.themes");
|
|
738
|
+
keys(themes, ["light", "dark"], "syntaxHighlighting.themes.");
|
|
739
|
+
for (const [mode, value] of Object.entries(themes)) {
|
|
740
|
+
const field = `syntaxHighlighting.themes.${mode}`;
|
|
741
|
+
const name = text(value, field);
|
|
742
|
+
if (!Object.hasOwn(bundledThemes, name))
|
|
743
|
+
throw new RdxConfigError(
|
|
744
|
+
`${field} must name a bundled Shiki theme. Unknown theme "${name}".`
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
const languages = object(
|
|
749
|
+
highlighting.languages === void 0 ? {} : highlighting.languages,
|
|
750
|
+
"syntaxHighlighting.languages"
|
|
751
|
+
);
|
|
752
|
+
for (const [name, filename] of Object.entries(languages)) {
|
|
753
|
+
const field = `syntaxHighlighting.languages.${name}`;
|
|
754
|
+
if (!/^[a-z0-9][a-z0-9_+-]*$/.test(name) || [
|
|
755
|
+
"ansi",
|
|
756
|
+
"diff",
|
|
757
|
+
"folder",
|
|
758
|
+
"mermaid",
|
|
759
|
+
"plain",
|
|
760
|
+
"plaintext",
|
|
761
|
+
"text",
|
|
762
|
+
"txt"
|
|
763
|
+
].includes(name))
|
|
764
|
+
throw new RdxConfigError(
|
|
765
|
+
`${field} must use a lowercase, non-reserved fence name.`
|
|
766
|
+
);
|
|
767
|
+
if (!text(filename, field).endsWith(".json"))
|
|
768
|
+
throw new RdxConfigError(`${field} must point to a TextMate JSON file.`);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
647
771
|
if (config.editPage !== void 0 && config.editPage !== false) {
|
|
648
772
|
const editPage = object(config.editPage, "editPage");
|
|
649
773
|
keys(editPage, ["baseUrl"], "editPage.");
|
|
@@ -778,7 +902,7 @@ async function createRdxProject(input, {
|
|
|
778
902
|
rootDir = process.cwd(),
|
|
779
903
|
command = "runtime"
|
|
780
904
|
} = {}) {
|
|
781
|
-
rootDir =
|
|
905
|
+
rootDir = path7.resolve(
|
|
782
906
|
/* turbopackIgnore: true */
|
|
783
907
|
rootDir
|
|
784
908
|
);
|
|
@@ -798,6 +922,45 @@ async function createRdxProject(input, {
|
|
|
798
922
|
];
|
|
799
923
|
const commands = [];
|
|
800
924
|
const runtimeFiles = /* @__PURE__ */ new Set();
|
|
925
|
+
const syntaxGrammars = Object.entries(
|
|
926
|
+
config.syntaxHighlighting?.languages ?? {}
|
|
927
|
+
).map(([name, filename]) => {
|
|
928
|
+
const field = `syntaxHighlighting.languages.${name}`;
|
|
929
|
+
const resolved = boundedProjectPath(rootDir, filename, field);
|
|
930
|
+
let grammar;
|
|
931
|
+
try {
|
|
932
|
+
if (!statSync(
|
|
933
|
+
/* turbopackIgnore: true */
|
|
934
|
+
resolved
|
|
935
|
+
).isFile())
|
|
936
|
+
throw new Error("Expected a regular file");
|
|
937
|
+
grammar = JSON.parse(
|
|
938
|
+
readFileSync(
|
|
939
|
+
/* turbopackIgnore: true */
|
|
940
|
+
resolved,
|
|
941
|
+
"utf8"
|
|
942
|
+
)
|
|
943
|
+
);
|
|
944
|
+
} catch (error) {
|
|
945
|
+
throw new RdxConfigError(
|
|
946
|
+
`${field} could not read "${filename}": ${error.message}`
|
|
947
|
+
);
|
|
948
|
+
}
|
|
949
|
+
if (!record(grammar) || typeof grammar.scopeName !== "string" || !grammar.scopeName.trim() || !Array.isArray(grammar.patterns))
|
|
950
|
+
throw new RdxConfigError(
|
|
951
|
+
`${field} must contain a TextMate grammar with scopeName and patterns.`
|
|
952
|
+
);
|
|
953
|
+
runtimeFiles.add(
|
|
954
|
+
path7.relative(rootDir, resolveProjectPath(rootDir, filename, field))
|
|
955
|
+
);
|
|
956
|
+
runtimeFiles.add(path7.relative(rootDir, resolved));
|
|
957
|
+
return {
|
|
958
|
+
...grammar,
|
|
959
|
+
name,
|
|
960
|
+
scopeName: grammar.scopeName,
|
|
961
|
+
patterns: grammar.patterns
|
|
962
|
+
};
|
|
963
|
+
});
|
|
801
964
|
let localization;
|
|
802
965
|
const commandNames = /* @__PURE__ */ new Set([
|
|
803
966
|
"dev",
|
|
@@ -854,7 +1017,7 @@ async function createRdxProject(input, {
|
|
|
854
1017
|
const field = `plugin "${plugin.name}" runtimeFiles`;
|
|
855
1018
|
const filename = text(value, field);
|
|
856
1019
|
const resolved = resolveProjectPath(rootDir, filename, field);
|
|
857
|
-
runtimeFiles.add(
|
|
1020
|
+
runtimeFiles.add(path7.relative(rootDir, resolved));
|
|
858
1021
|
}
|
|
859
1022
|
}
|
|
860
1023
|
if (contribution.sources === void 0) continue;
|
|
@@ -956,6 +1119,7 @@ async function createRdxProject(input, {
|
|
|
956
1119
|
sources,
|
|
957
1120
|
commands,
|
|
958
1121
|
runtimeFiles: [...runtimeFiles],
|
|
1122
|
+
...syntaxGrammars.length ? { syntaxGrammars } : {},
|
|
959
1123
|
...localization ? { localization } : {}
|
|
960
1124
|
};
|
|
961
1125
|
}
|
|
@@ -966,6 +1130,10 @@ export {
|
|
|
966
1130
|
resolveProjectPath,
|
|
967
1131
|
collectSnapshotContributions,
|
|
968
1132
|
getEditPageHref,
|
|
1133
|
+
snapshotDatesFilename,
|
|
1134
|
+
createDocumentDateReader,
|
|
1135
|
+
collectSnapshotDocumentDates,
|
|
1136
|
+
getSnapshotDocumentDate,
|
|
969
1137
|
resolveConfig,
|
|
970
1138
|
defineConfig,
|
|
971
1139
|
createRdxProject
|
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,
|
|
2
|
+
export { R as RdxConfigError, h as collectSnapshotContributions, j as collectSnapshotDocumentDates, k as createDocumentDateReader, c as createRdxProject, d as defineConfig, g as getContentSources, l as getEditPageHref, m as getSnapshotDocumentDate, n as normalizeLocalization, r as resolveConfig, f as resolveProjectPath, s as snapshotDatesFilename } from '../index-CIBgPARs.js';
|
package/dist/config/index.js
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RdxConfigError,
|
|
3
3
|
collectSnapshotContributions,
|
|
4
|
+
collectSnapshotDocumentDates,
|
|
5
|
+
createDocumentDateReader,
|
|
4
6
|
createRdxProject,
|
|
5
7
|
defineConfig,
|
|
6
8
|
getEditPageHref,
|
|
9
|
+
getSnapshotDocumentDate,
|
|
7
10
|
normalizeLocalization,
|
|
8
11
|
resolveConfig,
|
|
9
|
-
resolveProjectPath
|
|
10
|
-
|
|
12
|
+
resolveProjectPath,
|
|
13
|
+
snapshotDatesFilename
|
|
14
|
+
} from "../chunk-KPVVN2MN.js";
|
|
11
15
|
import {
|
|
12
16
|
getContentSources
|
|
13
17
|
} from "../chunk-SNNEXRLQ.js";
|
|
14
18
|
export {
|
|
15
19
|
RdxConfigError,
|
|
16
20
|
collectSnapshotContributions,
|
|
21
|
+
collectSnapshotDocumentDates,
|
|
22
|
+
createDocumentDateReader,
|
|
17
23
|
createRdxProject,
|
|
18
24
|
defineConfig,
|
|
19
25
|
getContentSources,
|
|
20
26
|
getEditPageHref,
|
|
27
|
+
getSnapshotDocumentDate,
|
|
21
28
|
normalizeLocalization,
|
|
22
29
|
resolveConfig,
|
|
23
|
-
resolveProjectPath
|
|
30
|
+
resolveProjectPath,
|
|
31
|
+
snapshotDatesFilename
|
|
24
32
|
};
|
|
@@ -41,6 +41,11 @@ declare function isFallbackPage(project: RdxProject, source: RdxContentSource, s
|
|
|
41
41
|
|
|
42
42
|
declare function getEditPageHref(project: Pick<RdxProject, 'config' | 'rootDir'>, source: Pick<RdxContentSource, 'id'> | undefined, sourcePath: string): string | undefined;
|
|
43
43
|
|
|
44
|
+
declare const snapshotDatesFilename = "_rdx-last-updated.json";
|
|
45
|
+
declare function createDocumentDateReader(root: string): (file: string) => string | undefined;
|
|
46
|
+
declare function collectSnapshotDocumentDates(directory: string, dateFor: (file: string) => string | undefined): string | undefined;
|
|
47
|
+
declare function getSnapshotDocumentDate(directory: string, file: string): string | undefined;
|
|
48
|
+
|
|
44
49
|
declare function resolveConfig(input: unknown): ResolvedRdxConfig;
|
|
45
50
|
declare function defineConfig(config: RDXConfig): RDXConfig;
|
|
46
51
|
declare function createRdxProject(input: unknown, { rootDir, command, }?: {
|
|
@@ -48,4 +53,4 @@ declare function createRdxProject(input: unknown, { rootDir, command, }?: {
|
|
|
48
53
|
command?: string;
|
|
49
54
|
}): Promise<RdxProject>;
|
|
50
55
|
|
|
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,
|
|
56
|
+
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, collectSnapshotDocumentDates as j, createDocumentDateReader as k, getEditPageHref as l, getSnapshotDocumentDate as m, normalizeLocalization as n, resolveConfig as r, snapshotDatesFilename as s };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
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-CIBgPARs.js';
|
|
4
4
|
export { D as DocumentLinkOptions, R as RdxDocumentLinkError, c as createDocumentLinkResolver } from './document-links-fo6ul9xz.js';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/index.js
CHANGED
package/dist/mdx/index.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ import { D as DocumentLinkOptions } from '../document-links-fo6ul9xz.js';
|
|
|
2
2
|
export { r as remarkDocumentLinks } from '../document-links-fo6ul9xz.js';
|
|
3
3
|
export { default as rehypeDocumentationHeadings } from 'rehype-slug';
|
|
4
4
|
import rehypeShiki from '@shikijs/rehype';
|
|
5
|
+
import { RdxProject, RDXConfig } from '@lexibase/rdx-types';
|
|
5
6
|
import remarkDirective from 'remark-directive';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
type SyntaxGrammars = NonNullable<RdxProject['syntaxGrammars']>;
|
|
9
|
+
/** Apply syntax highlighting to Markdown code blocks on the server. */
|
|
10
|
+
declare function rehypeDocumentationCode(this: ThisParameterType<typeof rehypeShiki>, grammars?: SyntaxGrammars, configuredThemes?: NonNullable<RDXConfig['syntaxHighlighting']>['themes']): ReturnType<typeof rehypeShiki>;
|
|
9
11
|
|
|
10
12
|
/** Markdown authoring adapters for the shared shadcn/Base UI components. */
|
|
11
13
|
declare function remarkDocumentationComponents(this: ThisParameterType<typeof remarkDirective>): (tree: unknown, file: {
|