@dreamlake/dockit 0.2.29 → 0.2.30
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/components/TOC.js +6 -3
- package/dist/components/Topbar.js +3 -2
- package/dist/lib/dev-metadata-plugin.d.ts +3 -0
- package/dist/lib/dev-metadata-plugin.js +81 -0
- package/dist/vite.js +2 -0
- package/package.json +8 -8
- package/templates/set-version.mjs +0 -0
- package/templates/version-branch.sh +0 -0
package/dist/components/TOC.js
CHANGED
|
@@ -3,6 +3,7 @@ import { useState, useRef, useEffect, useMemo } from "react";
|
|
|
3
3
|
import { usePageContext } from "vike-react/usePageContext";
|
|
4
4
|
import { normalizePath, findPage } from "../lib/navigation.js";
|
|
5
5
|
import { siteConfig } from "../site-config.js";
|
|
6
|
+
import { useHiddenToggle } from "../lib/use-hidden-toggle.js";
|
|
6
7
|
const TOC_KEY_PREFIX = "toc-collapsed:";
|
|
7
8
|
const X0 = 4;
|
|
8
9
|
const X_INDENT_H3 = 12;
|
|
@@ -52,19 +53,21 @@ function scrollToHeading(e, id) {
|
|
|
52
53
|
function TOC() {
|
|
53
54
|
const { urlPathname } = usePageContext();
|
|
54
55
|
const currentPath = normalizePath(urlPathname);
|
|
56
|
+
const [showDeveloperLinks] = useHiddenToggle();
|
|
55
57
|
const mdHref = (() => {
|
|
56
58
|
const meta = findPage(urlPathname);
|
|
57
59
|
if (!meta || meta.noindex) return null;
|
|
58
60
|
return currentPath === "/" ? "/index.md" : `${currentPath}.md`;
|
|
59
61
|
})();
|
|
60
62
|
const editHref = (() => {
|
|
63
|
+
if (!showDeveloperLinks || !siteConfig.docsRepoUrl) return null;
|
|
61
64
|
const meta = findPage(urlPathname);
|
|
62
65
|
if (!meta) return null;
|
|
63
66
|
const slug = currentPath === "/" ? "index" : currentPath.replace(/^\//, "");
|
|
64
67
|
const pagesPath = siteConfig.docsPagesPath ?? "docs/pages";
|
|
65
|
-
return `${siteConfig.docsRepoUrl}/edit/${siteConfig.docsBranch}/${pagesPath}/${slug}/+Page.mdx`;
|
|
68
|
+
return `${siteConfig.docsRepoUrl}/edit/${encodeURIComponent(siteConfig.docsBranch)}/${pagesPath}/${slug}/+Page.mdx`;
|
|
66
69
|
})();
|
|
67
|
-
const issueHref = `${siteConfig.docsRepoUrl}/issues/new
|
|
70
|
+
const issueHref = showDeveloperLinks && siteConfig.docsRepoUrl ? `${siteConfig.docsRepoUrl}/issues/new` : null;
|
|
68
71
|
const [headings, setHeadings] = useState([]);
|
|
69
72
|
const [endPos, setEndPos] = useState(null);
|
|
70
73
|
const [pathD, setPathD] = useState("");
|
|
@@ -643,7 +646,7 @@ function TOC() {
|
|
|
643
646
|
children: "Edit this page"
|
|
644
647
|
}
|
|
645
648
|
),
|
|
646
|
-
/* @__PURE__ */ jsx(
|
|
649
|
+
issueHref && /* @__PURE__ */ jsx(
|
|
647
650
|
"a",
|
|
648
651
|
{
|
|
649
652
|
href: issueHref,
|
|
@@ -38,6 +38,7 @@ const SEARCH_INSET = `max(${SEARCH_GUTTER}px, calc((100vw - ${SEARCH_MAX_W}px) /
|
|
|
38
38
|
function Topbar({ searchOpen, onOpenSearch, onCloseSearch, query, setQuery }) {
|
|
39
39
|
const { urlPathname } = usePageContext();
|
|
40
40
|
const current = findPage(urlPathname);
|
|
41
|
+
const [showDeveloperLinks] = useHiddenToggle();
|
|
41
42
|
const hasTabs = TABS.length > 0;
|
|
42
43
|
const activeTab = internalTabs().find((t) => t.id === tabForUrl(urlPathname));
|
|
43
44
|
const versionChips = activeTab?.versionChips ?? siteConfig.versionChips ?? [];
|
|
@@ -353,7 +354,7 @@ function Topbar({ searchOpen, onOpenSearch, onCloseSearch, query, setQuery }) {
|
|
|
353
354
|
},
|
|
354
355
|
chip.label
|
|
355
356
|
)),
|
|
356
|
-
siteConfig.gitHash && /* @__PURE__ */ jsxs(
|
|
357
|
+
showDeveloperLinks && siteConfig.gitHash && /* @__PURE__ */ jsxs(
|
|
357
358
|
"span",
|
|
358
359
|
{
|
|
359
360
|
className: "hidden md:inline-flex items-center text-doc-template-muted border border-doc-template-faint",
|
|
@@ -553,7 +554,7 @@ function Topbar({ searchOpen, onOpenSearch, onCloseSearch, query, setQuery }) {
|
|
|
553
554
|
className: "flex items-stretch gap-2.5 md:gap-3.5 pr-[14px] md:pr-[22px]",
|
|
554
555
|
style: { gridColumn: 3, gridRow: 1, justifySelf: "end", ...palFade(searchOpen) },
|
|
555
556
|
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3.5", children: [
|
|
556
|
-
siteConfig.repoUrl && /* @__PURE__ */ jsx(
|
|
557
|
+
showDeveloperLinks && siteConfig.repoUrl && /* @__PURE__ */ jsx(
|
|
557
558
|
"a",
|
|
558
559
|
{
|
|
559
560
|
href: siteConfig.repoUrl,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { transformWithEsbuild } from "vite";
|
|
2
|
+
const fields = /* @__PURE__ */ new Set(["repoUrl", "docsRepoUrl", "docsBranch", "docsPagesPath", "gitHash"]);
|
|
3
|
+
function staticString(node) {
|
|
4
|
+
if (node.type === "Literal" && typeof node.value === "string") return node.value;
|
|
5
|
+
if (node.type === "TemplateLiteral") {
|
|
6
|
+
const parts = node.quasis;
|
|
7
|
+
const expressions = node.expressions;
|
|
8
|
+
let value = parts[0].value.cooked;
|
|
9
|
+
for (let i = 0; i < expressions.length; i++) {
|
|
10
|
+
const part = staticString(expressions[i]);
|
|
11
|
+
if (part === null) return null;
|
|
12
|
+
value += part + parts[i + 1].value.cooked;
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
function devMetadataPlugin() {
|
|
19
|
+
let define = {};
|
|
20
|
+
return {
|
|
21
|
+
name: "dockit-dev-metadata",
|
|
22
|
+
enforce: "pre",
|
|
23
|
+
apply: "build",
|
|
24
|
+
configResolved(config) {
|
|
25
|
+
define = Object.fromEntries(Object.entries(config.define ?? {}).map(([key, value]) => [
|
|
26
|
+
key,
|
|
27
|
+
typeof value === "string" ? value : JSON.stringify(value)
|
|
28
|
+
]));
|
|
29
|
+
if (config.build.sourcemap) {
|
|
30
|
+
throw new Error("Dockit developer metadata requires build.sourcemap: false");
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
async transform(source, id) {
|
|
34
|
+
if (!/(?:^|\/)site\.config\.[cm]?[jt]s$/.test(id)) return null;
|
|
35
|
+
const compiled = await transformWithEsbuild(source, id, {
|
|
36
|
+
loader: "ts",
|
|
37
|
+
target: "esnext",
|
|
38
|
+
define,
|
|
39
|
+
sourcemap: false,
|
|
40
|
+
legalComments: "none"
|
|
41
|
+
});
|
|
42
|
+
const edits = [];
|
|
43
|
+
const visit = (node) => {
|
|
44
|
+
if (node.type === "Property") {
|
|
45
|
+
const key = node.key;
|
|
46
|
+
const name = key.type === "Identifier" && !node.computed ? key.name : key.value;
|
|
47
|
+
if (typeof name === "string" && fields.has(name)) {
|
|
48
|
+
const value = node.value;
|
|
49
|
+
const text = staticString(value);
|
|
50
|
+
if (text === null) {
|
|
51
|
+
this.error(`Dockit ${name} must be a string literal or a build-time define in ${id}`);
|
|
52
|
+
}
|
|
53
|
+
const bytes = Array.from({ length: text.length }, (_, i) => text.charCodeAt(i) ^ 90);
|
|
54
|
+
edits.push({
|
|
55
|
+
start: value.start,
|
|
56
|
+
end: value.end,
|
|
57
|
+
text: `[${bytes.join(",")}].map(n=>String.fromCharCode(n^90)).join("")`
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (const value of Object.values(node)) {
|
|
63
|
+
if (Array.isArray(value)) {
|
|
64
|
+
for (const item of value) if (item?.type) visit(item);
|
|
65
|
+
} else if (value && typeof value === "object" && "type" in value) {
|
|
66
|
+
visit(value);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
visit(this.parse(compiled.code));
|
|
71
|
+
let code = compiled.code;
|
|
72
|
+
for (const edit of edits.sort((a, b) => b.start - a.start)) {
|
|
73
|
+
code = code.slice(0, edit.start) + edit.text + code.slice(edit.end);
|
|
74
|
+
}
|
|
75
|
+
return { code, map: { mappings: "" } };
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
devMetadataPlugin
|
|
81
|
+
};
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mdxFrontmatterLoader } from "./lib/mdx-frontmatter-loader.js";
|
|
2
|
+
import { devMetadataPlugin } from "./lib/dev-metadata-plugin.js";
|
|
2
3
|
import { readFile } from "node:fs/promises";
|
|
3
4
|
import react from "@vitejs/plugin-react";
|
|
4
5
|
import vike from "vike/plugin";
|
|
@@ -30,6 +31,7 @@ function mdxRawLoader() {
|
|
|
30
31
|
}
|
|
31
32
|
function dockit() {
|
|
32
33
|
return [
|
|
34
|
+
devMetadataPlugin(),
|
|
33
35
|
tailwindcss(),
|
|
34
36
|
mdxRawLoader(),
|
|
35
37
|
mdxFrontmatterLoader(),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamlake/dockit",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "The DreamLake documentation shell
|
|
3
|
+
"version": "0.2.30",
|
|
4
|
+
"description": "The DreamLake documentation shell \u2014 Vike + React + Tailwind v4 + MDX docs framework with sidebar, TOC, search, and theming",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
},
|
|
39
39
|
"./styles.css": "./dist/styles.css"
|
|
40
40
|
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "vite build",
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
44
|
+
"test": "node --test tests/*.test.mjs"
|
|
45
|
+
},
|
|
41
46
|
"peerDependencies": {
|
|
42
47
|
"@mdx-js/react": ">=3.0.0",
|
|
43
48
|
"react": ">=19.0.0",
|
|
@@ -80,10 +85,5 @@
|
|
|
80
85
|
"vike-react": "^0.5.0",
|
|
81
86
|
"vite": "^7.0.0",
|
|
82
87
|
"vite-plugin-dts": "^4.3.0"
|
|
83
|
-
},
|
|
84
|
-
"scripts": {
|
|
85
|
-
"build": "vite build",
|
|
86
|
-
"typecheck": "tsc --noEmit",
|
|
87
|
-
"test": "node --test tests/*.test.mjs"
|
|
88
88
|
}
|
|
89
|
-
}
|
|
89
|
+
}
|
|
File without changes
|
|
File without changes
|