imprensa 0.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +51 -0
  3. package/default.css +239 -0
  4. package/dist/client-runtime-D7MhMWCo.d.mts +45 -0
  5. package/dist/components/doc.d.mts +2 -0
  6. package/dist/components/doc.mjs +2 -0
  7. package/dist/components/icons.d.mts +23 -0
  8. package/dist/components/icons.mjs +40 -0
  9. package/dist/components/index.d.mts +33 -0
  10. package/dist/components/index.mjs +253 -0
  11. package/dist/core/client-runtime.d.mts +2 -0
  12. package/dist/core/client-runtime.mjs +121 -0
  13. package/dist/core/prerender-core.d.mts +2 -0
  14. package/dist/core/prerender-core.mjs +2 -0
  15. package/dist/core/runtime.d.mts +3 -0
  16. package/dist/core/runtime.mjs +3 -0
  17. package/dist/core/shiki-build.d.mts +9 -0
  18. package/dist/core/shiki-build.mjs +34 -0
  19. package/dist/doc-pager-D-YhwEQN.d.mts +27 -0
  20. package/dist/doc-toolbar-DUQS2gnK.mjs +460 -0
  21. package/dist/docs/config.d.mts +13 -0
  22. package/dist/docs/config.mjs +10 -0
  23. package/dist/docs/landing-shiki.d.mts +7 -0
  24. package/dist/docs/landing-shiki.mjs +7 -0
  25. package/dist/docs/mdx.d.mts +79 -0
  26. package/dist/docs/mdx.mjs +293 -0
  27. package/dist/docs/rehype.d.mts +25 -0
  28. package/dist/docs/rehype.mjs +2 -0
  29. package/dist/frontmatter-DVneGjCO.mjs +16 -0
  30. package/dist/global-search-Dfv8DYN3.mjs +310 -0
  31. package/dist/index.d.mts +41 -0
  32. package/dist/index.mjs +668 -0
  33. package/dist/prerender-core-D4Li--RS.mjs +172 -0
  34. package/dist/prerender-core-DBi9ntWW.d.mts +48 -0
  35. package/dist/rehype-BWpGaBql.mjs +182 -0
  36. package/dist/search-store-DDGHRAKl.mjs +64 -0
  37. package/dist/shiki-gFey7C-z.d.mts +3289 -0
  38. package/dist/sidebar-layout-DsEhSkJS.mjs +43 -0
  39. package/dist/socials-BIszPk-A.d.mts +8 -0
  40. package/docs/architecture.md +26 -0
  41. package/docs/integration-notes.md +6 -0
  42. package/index.d.ts +49 -0
  43. package/package.json +128 -0
  44. package/tsconfig.json +28 -0
@@ -0,0 +1,253 @@
1
+ import { i as writeSidebarLayout, r as readSidebarLayout, t as DEFAULT_SIDEBAR_LAYOUT } from "../sidebar-layout-DsEhSkJS.mjs";
2
+ import { a as treeIndentClass, c as LogoButton, d as SearchSidebarTrigger, f as ThemeToggle, i as getAdjacentDocs, l as SearchNavbarTrigger, n as DocToolbar, o as NavFooterBar, r as DocPager, s as cx, t as DocArticle, u as SearchOverlay } from "../doc-toolbar-DUQS2gnK.mjs";
3
+ import { defineLayout, routeHash, useRoute } from "@ilha/router";
4
+ import ilha from "ilha";
5
+ import { Collapsible, Icon, LinkButton, Resizable, Toaster } from "areia";
6
+ import { ExternalLink } from "lucide";
7
+ import { jsx, jsxs } from "ilha/jsx-runtime";
8
+ import { contentTree } from "imprensa/mdx";
9
+ import { preview, shikiThemes } from "imprensa/config";
10
+ //#region src/components/sidebar.tsx
11
+ /** @jsxImportSource ilha */
12
+ const ACTIVE_LINK_CLASS = "border-areia-primary text-areia-primary ring-1 ring-inset ring-areia-primary/30";
13
+ function renderTree(nodes, currentPath, depth = 0) {
14
+ return nodes.map((node) => {
15
+ const href = node.type === "link" ? node.link : node.path;
16
+ const active = node.path && node.type !== "link" ? (node.path.replace(/\/$/, "") || "/") === currentPath : false;
17
+ const link = href ? /* @__PURE__ */ jsxs(LinkButton, {
18
+ href,
19
+ external: node.external,
20
+ variant: active ? "outline" : "ghost",
21
+ class: cx("w-full justify-start", node.type === "link" && node.external && "justify-between", active && ACTIVE_LINK_CLASS),
22
+ children: [/* @__PURE__ */ jsx("span", {
23
+ class: "min-w-0 truncate",
24
+ children: node.title
25
+ }), node.type === "link" && node.external ? /* @__PURE__ */ jsx(Icon, {
26
+ icon: ExternalLink,
27
+ class: "size-3.5 shrink-0"
28
+ }) : null]
29
+ }) : /* @__PURE__ */ jsx("span", {
30
+ class: "text-sm font-medium text-areia-subtle",
31
+ children: node.title
32
+ });
33
+ return /* @__PURE__ */ jsx("div", {
34
+ class: cx("mt-px flex flex-col gap-1", treeIndentClass(depth)),
35
+ children: node.children.length > 0 ? /* @__PURE__ */ jsxs(Collapsible, {
36
+ defaultOpen: true,
37
+ children: [/* @__PURE__ */ jsx(Collapsible.Trigger, {
38
+ class: "w-full rounded-md px-2 py-1 text-left hover:bg-areia-control-hover",
39
+ children: link
40
+ }), /* @__PURE__ */ jsx(Collapsible.Panel, {
41
+ class: "mt-1 flex flex-col p-px",
42
+ children: renderTree(node.children, currentPath, node.path ? depth + 1 : depth)
43
+ })]
44
+ }) : link
45
+ });
46
+ });
47
+ }
48
+ const Sidebar = ilha.render(() => {
49
+ const { path } = useRoute();
50
+ const currentPath = path().replace(/\/$/, "") || "/";
51
+ return /* @__PURE__ */ jsxs("div", {
52
+ class: "flex h-full min-h-0 flex-col gap-2 p-2",
53
+ children: [
54
+ /* @__PURE__ */ jsx("div", {
55
+ class: "flex items-center",
56
+ children: /* @__PURE__ */ jsx(LogoButton, {})
57
+ }),
58
+ /* @__PURE__ */ jsx(SearchSidebarTrigger, {}),
59
+ /* @__PURE__ */ jsx("nav", {
60
+ class: "flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto overscroll-y-contain px-0.5",
61
+ children: renderTree(contentTree, currentPath)
62
+ }),
63
+ /* @__PURE__ */ jsx(NavFooterBar, { class: "mt-auto" })
64
+ ]
65
+ });
66
+ });
67
+ //#endregion
68
+ //#region src/components/layout.tsx
69
+ /** @jsxImportSource ilha */
70
+ const initialSidebarLayout = typeof window !== "undefined" ? readSidebarLayout() : DEFAULT_SIDEBAR_LAYOUT;
71
+ function layoutsNearlyEqual(a, b) {
72
+ return a.length === 2 && Math.abs(a[0] - b[0]) < .05 && Math.abs(a[1] - b[1]) < .05;
73
+ }
74
+ function mountSidebarLayoutPersistence(host) {
75
+ let resizable = null;
76
+ let persist = false;
77
+ const stored = readSidebarLayout();
78
+ const onLayoutChange = (event) => {
79
+ if (!persist) return;
80
+ const { layout } = event.detail;
81
+ if (!Array.isArray(layout) || layout.length !== 2) return;
82
+ writeSidebarLayout(layout);
83
+ document.documentElement.dataset.imprensaSidebarLayout = "1";
84
+ document.documentElement.style.setProperty("--imprensa-sidebar-pct", String(layout[0]));
85
+ document.documentElement.style.setProperty("--imprensa-content-pct", String(layout[1]));
86
+ };
87
+ const connect = () => {
88
+ resizable = host.querySelector("[data-slot=\"resizable\"]");
89
+ if (!resizable) return;
90
+ resizable.addEventListener("resizable:change", onLayoutChange);
91
+ if (document.documentElement.dataset.imprensaSidebarLayout !== "1" && !layoutsNearlyEqual(stored, DEFAULT_SIDEBAR_LAYOUT)) resizable.dispatchEvent(new CustomEvent("resizable:set", {
92
+ detail: { layout: [...stored] },
93
+ bubbles: true
94
+ }));
95
+ persist = true;
96
+ };
97
+ queueMicrotask(connect);
98
+ return () => {
99
+ resizable?.removeEventListener("resizable:change", onLayoutChange);
100
+ };
101
+ }
102
+ const DOCS_LAYOUT_CLASS = "imprensa-docs-layout";
103
+ function mountDocsViewportLock() {
104
+ document.documentElement.classList.add(DOCS_LAYOUT_CLASS);
105
+ return () => {
106
+ document.documentElement.classList.remove(DOCS_LAYOUT_CLASS);
107
+ };
108
+ }
109
+ const RootLayout = defineLayout((children) => ilha.render(() => /* @__PURE__ */ jsxs("div", {
110
+ class: "imprensa-root bg-areia-background text-areia-default",
111
+ children: [/* @__PURE__ */ jsx(Toaster, {
112
+ richColors: true,
113
+ closeButton: true
114
+ }), /* @__PURE__ */ jsx("main", {
115
+ class: "imprensa-root-main",
116
+ children
117
+ })]
118
+ })));
119
+ const ContentLayout = defineLayout((children) => {
120
+ return ilha.effect(() => {
121
+ const hash = routeHash();
122
+ if (hash) requestAnimationFrame(() => document.getElementById(hash.slice(1))?.scrollIntoView());
123
+ }).onMount(({ host }) => {
124
+ const unlockViewport = mountDocsViewportLock();
125
+ const disconnectLayout = mountSidebarLayoutPersistence(host);
126
+ return () => {
127
+ disconnectLayout();
128
+ unlockViewport();
129
+ };
130
+ }).render(() => /* @__PURE__ */ jsx("div", {
131
+ class: "imprensa-docs-shell flex h-dvh w-full overflow-hidden bg-areia-background text-areia-default",
132
+ children: /* @__PURE__ */ jsxs(Resizable, {
133
+ direction: "horizontal",
134
+ class: "h-full min-h-0 w-full",
135
+ children: [
136
+ /* @__PURE__ */ jsx(Resizable.Panel, {
137
+ defaultSize: initialSidebarLayout[0],
138
+ minSize: 15,
139
+ maxSize: 35,
140
+ class: "imprensa-docs-sidebar-panel max-md:!hidden",
141
+ children: /* @__PURE__ */ jsx(Sidebar, {})
142
+ }),
143
+ /* @__PURE__ */ jsx(Resizable.Handle, { class: "max-md:!hidden" }),
144
+ /* @__PURE__ */ jsx(Resizable.Panel, {
145
+ defaultSize: initialSidebarLayout[1],
146
+ minSize: 50,
147
+ class: "imprensa-docs-main-panel",
148
+ children: /* @__PURE__ */ jsx("div", {
149
+ class: "imprensa-docs-main-scroll flex w-full flex-col p-4",
150
+ children
151
+ })
152
+ })
153
+ ]
154
+ })
155
+ }));
156
+ });
157
+ //#endregion
158
+ //#region src/components/preview.tsx
159
+ /** @jsxImportSource ilha */
160
+ const DEFAULT_IMPORTMAP = { imports: {} };
161
+ const DEFAULT_HEAD = ``;
162
+ function makeIframeDoc(code) {
163
+ const script = code.replace(/^export default /m, "const __island = ").replace(/^export const (\w+)/m, "const $1");
164
+ const importmap = preview.importmap ? { imports: {
165
+ ...DEFAULT_IMPORTMAP.imports,
166
+ ...JSON.parse(preview.importmap).imports
167
+ } } : DEFAULT_IMPORTMAP;
168
+ const head = preview.head ?? DEFAULT_HEAD;
169
+ return `<!DOCTYPE html>
170
+ <html>
171
+ <head>
172
+ <meta charset="utf-8">
173
+ <script>const localStorage = { getItem: () => null, setItem: () => {}, removeItem: () => {} };<\/script>
174
+ <script type="importmap">${JSON.stringify(importmap)}<\/script>
175
+ <script type="module" src="https://esm.sh/tsx"><\/script>
176
+ ${head}
177
+ </head>
178
+ <body>
179
+ <div id="root"></div>
180
+ <script type="text/babel" data-type="module">
181
+ ${script}
182
+ const __resolved = typeof __island !== 'undefined' ? __island : typeof App !== 'undefined' ? App : undefined;
183
+ if (__resolved?.mount) __resolved.mount(document.getElementById('root'));
184
+ <\/script>
185
+ </body>
186
+ </html>`;
187
+ }
188
+ const Preview = ilha.input().onMount(({ host, input }) => {
189
+ const code = atob(input.code64);
190
+ const wrapper = host.querySelector(".preview-wrapper");
191
+ const pre = document.createElement("pre");
192
+ pre.className = "rounded-lg bg-areia-surface-muted border border-areia-border p-4 overflow-x-auto text-sm";
193
+ pre.innerHTML = `<code>${code.replace(/&/g, "&amp;").replace(/</g, "&lt;")}</code>`;
194
+ wrapper.appendChild(pre);
195
+ const iframe = document.createElement("iframe");
196
+ iframe.className = "rounded-lg border border-areia-border w-full min-h-32";
197
+ iframe.setAttribute("sandbox", "allow-scripts allow-same-origin");
198
+ iframe.srcdoc = makeIframeDoc(code);
199
+ wrapper.appendChild(iframe);
200
+ iframe.addEventListener("load", () => {
201
+ const syncDark = () => {
202
+ const dark = document.documentElement.classList.contains("dark");
203
+ iframe.contentDocument?.documentElement.classList.toggle("dark", dark);
204
+ };
205
+ syncDark();
206
+ new MutationObserver(syncDark).observe(document.documentElement, { attributeFilter: ["class"] });
207
+ });
208
+ import("imprensa/shiki").then(async ({ shiki }) => {
209
+ const previewHighlighter = shiki;
210
+ await previewHighlighter.loadLanguage("tsx");
211
+ const div = document.createElement("div");
212
+ div.className = "rounded-lg overflow-hidden border border-areia-border text-sm [&_pre]:!p-4 [&_pre]:!m-0 [&_pre]:overflow-x-auto";
213
+ div.innerHTML = previewHighlighter.codeToHtml(code, {
214
+ lang: "tsx",
215
+ themes: shikiThemes
216
+ });
217
+ wrapper.replaceChild(div, pre);
218
+ });
219
+ }).render(() => /* @__PURE__ */ jsx("div", { class: "not-prose flex flex-col gap-4 preview-wrapper" }));
220
+ //#endregion
221
+ //#region src/components/snippet.tsx
222
+ /** @jsxImportSource ilha */
223
+ const WRAPPER_CLASS = "max-w-full overflow-x-auto rounded-xl border border-areia-border text-xs leading-relaxed [&_pre]:min-w-max [&_pre]:p-4 [&_pre]:text-xs [&_pre]:leading-relaxed [&_pre]:!m-0";
224
+ function escapeHtml(code) {
225
+ return code.replace(/&/g, "&amp;").replace(/</g, "&lt;");
226
+ }
227
+ const Snippet = ilha.input().onMount(({ host, input }) => {
228
+ const mount = host.querySelector("[data-imprensa-snippet]");
229
+ if (mount.querySelector(".shiki")) return;
230
+ const { code, lang } = input;
231
+ mount.replaceChildren();
232
+ const pre = document.createElement("pre");
233
+ pre.className = "rounded-lg bg-areia-surface-muted border border-areia-border p-4 overflow-x-auto text-xs leading-relaxed";
234
+ pre.innerHTML = `<code>${escapeHtml(code)}</code>`;
235
+ mount.appendChild(pre);
236
+ import("imprensa/shiki").then(async ({ shiki }) => {
237
+ const h = shiki;
238
+ await h.loadLanguage(lang);
239
+ const div = document.createElement("div");
240
+ div.innerHTML = h.codeToHtml(code, {
241
+ lang,
242
+ themes: shikiThemes
243
+ });
244
+ const highlighted = div.firstElementChild;
245
+ if (!highlighted) return;
246
+ mount.replaceChildren(highlighted);
247
+ });
248
+ }).render(() => /* @__PURE__ */ jsx("div", {
249
+ class: WRAPPER_CLASS,
250
+ "data-imprensa-snippet": true
251
+ }));
252
+ //#endregion
253
+ export { ContentLayout, DocArticle, DocPager, DocToolbar, LogoButton, Preview, RootLayout, SearchNavbarTrigger, SearchOverlay, SearchSidebarTrigger, Sidebar, Snippet, ThemeToggle, getAdjacentDocs };
@@ -0,0 +1,2 @@
1
+ import { a as getStoredTheme, c as shiki, i as createImprensa, l as shikiThemes, n as applyInitialTheme, o as mountOrHydrate, r as applyThemeToHtml, s as setStoredTheme, t as THEME_STORAGE_KEY } from "../client-runtime-D7MhMWCo.mjs";
2
+ export { THEME_STORAGE_KEY, applyInitialTheme, applyThemeToHtml, createImprensa, getStoredTheme, mountOrHydrate, setStoredTheme, shiki, shikiThemes };
@@ -0,0 +1,121 @@
1
+ import { router } from "@ilha/router";
2
+ //#region src/core/client-runtime.ts
3
+ const shiki = new Promise(() => {});
4
+ /** Overridden at app build time by the imprensa Vite plugin from `imprensa()` shiki.themes. */
5
+ const shikiThemes = {
6
+ light: "night-owl-light",
7
+ dark: "houston"
8
+ };
9
+ const THEME_STORAGE_KEY = "imprensa:theme";
10
+ function getStoredTheme() {
11
+ try {
12
+ const stored = localStorage.getItem(THEME_STORAGE_KEY);
13
+ if (stored === "dark" || stored === "light" || stored === "system") return stored;
14
+ return "system";
15
+ } catch {
16
+ return "system";
17
+ }
18
+ }
19
+ function setStoredTheme(mode) {
20
+ localStorage.setItem(THEME_STORAGE_KEY, mode);
21
+ }
22
+ function applyThemeToHtml(isDark) {
23
+ document.documentElement.classList.toggle("dark", isDark);
24
+ document.documentElement.style.colorScheme = isDark ? "dark" : "light";
25
+ }
26
+ function applyInitialTheme() {
27
+ if (typeof window === "undefined" || typeof document === "undefined") return;
28
+ try {
29
+ const stored = localStorage.getItem(THEME_STORAGE_KEY);
30
+ applyThemeToHtml(stored === "dark" || stored !== "light" && window.matchMedia("(prefers-color-scheme: dark)").matches);
31
+ } catch {
32
+ document.documentElement.classList.remove("dark");
33
+ document.documentElement.style.colorScheme = "light";
34
+ } finally {
35
+ document.documentElement.dataset.themeReady = "";
36
+ }
37
+ }
38
+ function mountOrHydrate(options) {
39
+ applyInitialTheme();
40
+ if (typeof window === "undefined" || typeof document === "undefined") return;
41
+ const { pageRouter, registry, dev = false, target = "#app" } = options;
42
+ if (options.static) return router({ mode: "static" }).hydrateStatic(registry);
43
+ if (!pageRouter) return () => {};
44
+ if (dev) return pageRouter.mount(target);
45
+ return pageRouter.hydrate(registry);
46
+ }
47
+ async function applyClientHead(getMdxHead, headDefaults) {
48
+ if (typeof window === "undefined") return;
49
+ const { createHead } = await import("unhead/client");
50
+ const globalWindow = window;
51
+ const head = globalWindow.__UNHEAD__ ?? (globalWindow.__UNHEAD__ = createHead());
52
+ let dispose;
53
+ async function apply() {
54
+ dispose?.();
55
+ const url = location.pathname.replace(/\/$/, "") || "/";
56
+ const merged = {
57
+ ...headDefaults,
58
+ ...await getMdxHead?.(url)
59
+ };
60
+ if (Object.keys(merged).length > 0) dispose = head.push(merged).dispose;
61
+ }
62
+ apply();
63
+ window.addEventListener("popstate", apply);
64
+ const orig = history.pushState.bind(history);
65
+ history.pushState = (...args) => {
66
+ orig(...args);
67
+ apply();
68
+ };
69
+ }
70
+ async function loadClientIlhaCodegen() {
71
+ return import("ilha:pages/client");
72
+ }
73
+ async function loadServerIlhaCodegen() {
74
+ return import("ilha:pages/server");
75
+ }
76
+ async function loadMdxHelpers() {
77
+ return import("imprensa/mdx");
78
+ }
79
+ function createImprensa(options = {}) {
80
+ return {
81
+ async init() {
82
+ if (typeof window === "undefined") return;
83
+ applyInitialTheme();
84
+ const dev = options.dev ?? import.meta.env.DEV;
85
+ const staticHydration = options.static ?? !dev;
86
+ const [codegen, mdx] = await Promise.all([loadClientIlhaCodegen(), loadMdxHelpers()]);
87
+ if (dev) await applyClientHead(mdx.getMdxHead, mdx.headDefaults);
88
+ const { ensureGlobalSearchMounted } = await import("../global-search-Dfv8DYN3.mjs");
89
+ ensureGlobalSearchMounted();
90
+ return mountOrHydrate({
91
+ pageRouter: codegen.pageRouter,
92
+ registry: codegen.registry,
93
+ dev,
94
+ target: options.target,
95
+ static: dev ? false : staticHydration
96
+ });
97
+ },
98
+ async prerender(data) {
99
+ const [{ createPrerender }, codegen, mdx, config] = await Promise.all([
100
+ import("imprensa/prerender"),
101
+ loadServerIlhaCodegen(),
102
+ loadMdxHelpers(),
103
+ import("imprensa/config")
104
+ ]);
105
+ const hostname = config.hostname || void 0;
106
+ return createPrerender({
107
+ pageRouter: codegen.pageRouter,
108
+ registry: codegen.registry,
109
+ mdxRoutes: mdx.mdxRoutes,
110
+ renderMdx: mdx.renderMdx,
111
+ setPrerenderedMdxHtml: mdx.setPrerenderedMdxHtml,
112
+ getMdxHead: mdx.getMdxHead,
113
+ headDefaults: mdx.headDefaults,
114
+ hostname,
115
+ shiki: config.shiki
116
+ })(data);
117
+ }
118
+ };
119
+ }
120
+ //#endregion
121
+ export { THEME_STORAGE_KEY, applyInitialTheme, applyThemeToHtml, createImprensa, getStoredTheme, mountOrHydrate, setStoredTheme, shiki, shikiThemes };
@@ -0,0 +1,2 @@
1
+ import { i as HydrateOptions, n as RouterLike, r as createPrerender, t as ImprensaPrerenderOptions } from "../prerender-core-DBi9ntWW.mjs";
2
+ export { type HydrateOptions, ImprensaPrerenderOptions, RouterLike, createPrerender };
@@ -0,0 +1,2 @@
1
+ import { t as createPrerender } from "../prerender-core-D4Li--RS.mjs";
2
+ export { createPrerender };
@@ -0,0 +1,3 @@
1
+ import { r as createPrerender, t as ImprensaPrerenderOptions } from "../prerender-core-DBi9ntWW.mjs";
2
+ import { a as getStoredTheme, c as shiki, i as createImprensa, l as shikiThemes, n as applyInitialTheme, o as mountOrHydrate, r as applyThemeToHtml, s as setStoredTheme, t as THEME_STORAGE_KEY } from "../client-runtime-D7MhMWCo.mjs";
3
+ export { type ImprensaPrerenderOptions, THEME_STORAGE_KEY, applyInitialTheme, applyThemeToHtml, createImprensa, createPrerender, getStoredTheme, mountOrHydrate, setStoredTheme, shiki, shikiThemes };
@@ -0,0 +1,3 @@
1
+ import { THEME_STORAGE_KEY, applyInitialTheme, applyThemeToHtml, createImprensa, getStoredTheme, mountOrHydrate, setStoredTheme, shiki, shikiThemes } from "./client-runtime.mjs";
2
+ import { t as createPrerender } from "../prerender-core-D4Li--RS.mjs";
3
+ export { THEME_STORAGE_KEY, applyInitialTheme, applyThemeToHtml, createImprensa, createPrerender, getStoredTheme, mountOrHydrate, setStoredTheme, shiki, shikiThemes };
@@ -0,0 +1,9 @@
1
+ import { HighlighterCore } from "shiki/core";
2
+
3
+ //#region src/core/shiki-build.d.ts
4
+ declare function resolveShikiLangModuleHref(lang: string): string;
5
+ declare function resolveShikiThemeModuleHref(theme: string): string;
6
+ /** Node/build/prerender: only the theme + lang modules you pass in. */
7
+ declare function createConfiguredHighlighterCore(themes: string[], langs: string[]): Promise<HighlighterCore>;
8
+ //#endregion
9
+ export { createConfiguredHighlighterCore, resolveShikiLangModuleHref, resolveShikiThemeModuleHref };
@@ -0,0 +1,34 @@
1
+ import { createRequire } from "node:module";
2
+ import { pathToFileURL } from "node:url";
3
+ import { createHighlighterCore } from "shiki/core";
4
+ import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
5
+ //#region src/core/shiki-build.ts
6
+ const require = createRequire(import.meta.url);
7
+ function resolveImportSpecifier(id) {
8
+ return pathToFileURL(require.resolve(id)).href;
9
+ }
10
+ function resolveShikiLangModuleHref(lang) {
11
+ return resolveImportSpecifier(`@shikijs/langs/${lang}`);
12
+ }
13
+ function resolveShikiThemeModuleHref(theme) {
14
+ return resolveImportSpecifier(`@shikijs/themes/${theme}`);
15
+ }
16
+ let cachedKey = "";
17
+ let cachedHighlighter;
18
+ /** Node/build/prerender: only the theme + lang modules you pass in. */
19
+ async function createConfiguredHighlighterCore(themes, langs) {
20
+ const key = `${themes.join(",")}|${langs.join(",")}`;
21
+ if (cachedHighlighter && cachedKey === key) return cachedHighlighter;
22
+ cachedKey = key;
23
+ cachedHighlighter = (async () => {
24
+ const [themeMods, langMods] = await Promise.all([Promise.all(themes.map((t) => import(resolveShikiThemeModuleHref(t)))), Promise.all(langs.map((l) => import(resolveShikiLangModuleHref(l))))]);
25
+ return createHighlighterCore({
26
+ themes: themeMods.map((m) => m.default ?? m),
27
+ langs: langMods.map((m) => m.default ?? m),
28
+ engine: createJavaScriptRegexEngine()
29
+ });
30
+ })();
31
+ return cachedHighlighter;
32
+ }
33
+ //#endregion
34
+ export { createConfiguredHighlighterCore, resolveShikiLangModuleHref, resolveShikiThemeModuleHref };
@@ -0,0 +1,27 @@
1
+ import { RawHtml } from "ilha";
2
+
3
+ //#region src/components/doc-toolbar.d.ts
4
+ declare const DocToolbar: import("ilha").Island<{
5
+ path: string;
6
+ }, Record<never, never>>;
7
+ declare function DocArticle(props: {
8
+ path: string;
9
+ children: RawHtml | string;
10
+ class?: string;
11
+ }): import("ilha/jsx-runtime").JSX.Element;
12
+ //#endregion
13
+ //#region src/components/doc-pager.d.ts
14
+ type DocNavItem = {
15
+ title: string;
16
+ path: string;
17
+ excerpt: string;
18
+ };
19
+ declare function getAdjacentDocs(path: string): {
20
+ prev?: DocNavItem;
21
+ next?: DocNavItem;
22
+ };
23
+ declare function DocPager(props: {
24
+ path: string;
25
+ }): import("ilha/jsx-runtime").JSX.Element | null;
26
+ //#endregion
27
+ export { DocToolbar as a, DocArticle as i, DocPager as n, getAdjacentDocs as r, DocNavItem as t };