hono-decks 1.4.3 → 1.4.5
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/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/adapters/hono-markdown.d.ts +3 -7
- package/dist/adapters/hono-markdown.js +1 -2
- package/dist/advanced.d.ts +25 -57
- package/dist/advanced.js +23 -43
- package/dist/bin.js +32 -52
- package/dist/cli.d.ts +2 -4
- package/dist/cli.js +32 -52
- package/dist/client.d.ts +2 -6
- package/dist/client.js +1 -2
- package/dist/{file-transaction-NjDxX6Gt.js → file-transaction-BmX5WaTf.js} +2 -4
- package/dist/honox.d.ts +3 -6
- package/dist/honox.js +2 -4
- package/dist/{init-vite-BPRPonCD.js → init-vite-C1HAF3GF.js} +9 -13
- package/dist/mod.d.ts +7 -31
- package/dist/mod.js +10 -17
- package/dist/node.d.ts +25 -75
- package/dist/node.js +60 -107
- package/dist/vite.d.ts +3 -6
- package/dist/vite.js +31 -52
- package/package.json +7 -7
- package/skills/hono-decks/SKILL.md +20 -8
- package/skills/hono-decks/references/integrating.md +20 -10
- package/skills/hono-decks/references/r2-assets.md +13 -10
package/dist/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as normalizeRelativePath, n as normalizeDeckRoot, r as normalizePath$4, t as publishGeneratedFiles } from "./file-transaction-
|
|
2
|
+
import { i as normalizeRelativePath, n as normalizeDeckRoot, r as normalizePath$4, t as publishGeneratedFiles } from "./file-transaction-BmX5WaTf.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { existsSync, watch } from "node:fs";
|
|
5
5
|
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
@@ -15,7 +15,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
15
15
|
import { build } from "esbuild";
|
|
16
16
|
import { lookup } from "node:dns/promises";
|
|
17
17
|
import { isIP } from "node:net";
|
|
18
|
-
|
|
18
|
+
// src/routing/file-routing.ts
|
|
19
19
|
function resolveDeckFiles(paths, root = "decks", options = {}) {
|
|
20
20
|
const normalizedRoot = normalizePath$3(root).replace(/\/$/, "");
|
|
21
21
|
const decks = /* @__PURE__ */ new Map();
|
|
@@ -69,8 +69,7 @@ function assertInsideRoot(path, root) {
|
|
|
69
69
|
function normalizePath$3(path) {
|
|
70
70
|
return path.replaceAll("\\", "/").replace(/^\.\/+/, "").replace(/\/+/g, "/");
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
//#region src/deck/model.ts
|
|
72
|
+
// src/deck/model.ts
|
|
74
73
|
const SLIDE_TRANSITIONS = [
|
|
75
74
|
"none",
|
|
76
75
|
"fade",
|
|
@@ -89,8 +88,7 @@ var CompileError = class extends Error {
|
|
|
89
88
|
this.name = "CompileError";
|
|
90
89
|
}
|
|
91
90
|
};
|
|
92
|
-
|
|
93
|
-
//#region src/deck/frontmatter.ts
|
|
91
|
+
// src/deck/frontmatter.ts
|
|
94
92
|
function readFrontmatter(source) {
|
|
95
93
|
const normalized = source.replace(/\r\n/g, "\n").trimStart();
|
|
96
94
|
if (!normalized.startsWith("---\n")) return {
|
|
@@ -333,8 +331,7 @@ function takeBoolean(attrs, key) {
|
|
|
333
331
|
delete attrs[key];
|
|
334
332
|
return value;
|
|
335
333
|
}
|
|
336
|
-
|
|
337
|
-
//#region src/deck/assets.ts
|
|
334
|
+
// src/deck/assets.ts
|
|
338
335
|
function buildExternalAssetRefs(candidates) {
|
|
339
336
|
const refs = /* @__PURE__ */ new Map();
|
|
340
337
|
for (const candidate of candidates) {
|
|
@@ -453,8 +450,7 @@ function assetRefType(value) {
|
|
|
453
450
|
if (/^r2:\/\//i.test(value)) return "r2";
|
|
454
451
|
if (value.startsWith("/")) return "public";
|
|
455
452
|
}
|
|
456
|
-
|
|
457
|
-
//#region src/deck/speaker-notes.ts
|
|
453
|
+
// src/deck/speaker-notes.ts
|
|
458
454
|
function extractMdxCommentSpeakerNotes(source) {
|
|
459
455
|
const notes = [];
|
|
460
456
|
return {
|
|
@@ -473,8 +469,7 @@ function combineSpeakerNotes(...notes) {
|
|
|
473
469
|
function normalizeSpeakerNote(value) {
|
|
474
470
|
return value.replace(/\r\n/g, "\n").split("\n").map((line) => line.trim()).join("\n").trim();
|
|
475
471
|
}
|
|
476
|
-
|
|
477
|
-
//#region src/parser/parser.ts
|
|
472
|
+
// src/parser/parser.ts
|
|
478
473
|
const slideSeparator = /^---\s*$/m;
|
|
479
474
|
function parseDeckWithWarnings(markdown) {
|
|
480
475
|
const normalized = markdown.replace(/\r\n/g, "\n").trim();
|
|
@@ -911,8 +906,7 @@ function headingDepth(value) {
|
|
|
911
906
|
function stringAttr(value) {
|
|
912
907
|
return value && value.length > 0 ? value : void 0;
|
|
913
908
|
}
|
|
914
|
-
|
|
915
|
-
//#region src/generator/mdx/assets.ts
|
|
909
|
+
// src/generator/mdx/assets.ts
|
|
916
910
|
function rewriteAssetUrls(source, assets) {
|
|
917
911
|
let result = source;
|
|
918
912
|
for (const asset of assets) {
|
|
@@ -958,8 +952,7 @@ function toRelativeImportPath(fromDir, target) {
|
|
|
958
952
|
function escapeRegExp(value) {
|
|
959
953
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
960
954
|
}
|
|
961
|
-
|
|
962
|
-
//#region src/generator/assets.ts
|
|
955
|
+
// src/generator/assets.ts
|
|
963
956
|
async function buildAssetRefs(slug, assetPaths, input) {
|
|
964
957
|
return Promise.all(assetPaths.map(async (sourcePath) => ({
|
|
965
958
|
sourcePath,
|
|
@@ -980,12 +973,10 @@ function normalizeMountPath(value) {
|
|
|
980
973
|
function normalizePath$1(path) {
|
|
981
974
|
return path.replaceAll("\\", "/").replace(/^\.\/+/, "").replace(/\/+/g, "/");
|
|
982
975
|
}
|
|
983
|
-
|
|
984
|
-
//#region src/generator/package-entry.ts
|
|
976
|
+
// src/generator/package-entry.ts
|
|
985
977
|
const DECKS_RUNTIME_ENTRY = "hono-decks";
|
|
986
978
|
const DECKS_ADVANCED_ENTRY = "hono-decks/advanced";
|
|
987
|
-
|
|
988
|
-
//#region src/generator/mdx/emit.ts
|
|
979
|
+
// src/generator/mdx/emit.ts
|
|
989
980
|
function emitModuleDecksRouter(input) {
|
|
990
981
|
const runtimeEntry = JSON.stringify(DECKS_RUNTIME_ENTRY);
|
|
991
982
|
return `// @ts-nocheck
|
|
@@ -1072,8 +1063,7 @@ function serializeValue(value, depth) {
|
|
|
1072
1063
|
}
|
|
1073
1064
|
return JSON.stringify(value);
|
|
1074
1065
|
}
|
|
1075
|
-
|
|
1076
|
-
//#region src/generator/mdx/ogp.ts
|
|
1066
|
+
// src/generator/mdx/ogp.ts
|
|
1077
1067
|
async function resolveLinkCardMetadataByUrl(source, resolveOgp) {
|
|
1078
1068
|
const result = /* @__PURE__ */ new Map();
|
|
1079
1069
|
if (!resolveOgp) return result;
|
|
@@ -1088,8 +1078,7 @@ function collectLinkCardUrls(source) {
|
|
|
1088
1078
|
for (const match of source.matchAll(/@\[card\]\(([^)\s]+)\)/g)) urls.add(match[1]);
|
|
1089
1079
|
return [...urls];
|
|
1090
1080
|
}
|
|
1091
|
-
|
|
1092
|
-
//#region src/generator/mdx/syntax.ts
|
|
1081
|
+
// src/generator/mdx/syntax.ts
|
|
1093
1082
|
function remarkDeckSyntax(input = {}) {
|
|
1094
1083
|
return () => (tree) => {
|
|
1095
1084
|
transformDeckSyntaxChildren(tree, input);
|
|
@@ -1376,8 +1365,7 @@ function collectMarkdownText(node) {
|
|
|
1376
1365
|
if (!Array.isArray(node.children)) return "";
|
|
1377
1366
|
return node.children.map((child) => collectMarkdownText(child)).join(node.type === "paragraph" ? "\n" : "");
|
|
1378
1367
|
}
|
|
1379
|
-
|
|
1380
|
-
//#region src/generator/mdx-module-generator.ts
|
|
1368
|
+
// src/generator/mdx-module-generator.ts
|
|
1381
1369
|
async function compileMdxModuleDecks(input) {
|
|
1382
1370
|
const decks = await Promise.all(input.decks.map((entry) => compileMdxModuleDeck(input, entry)));
|
|
1383
1371
|
return {
|
|
@@ -1505,8 +1493,7 @@ function extractDeckPrelude(source) {
|
|
|
1505
1493
|
body: lines.slice(cursor).join("\n").trim()
|
|
1506
1494
|
};
|
|
1507
1495
|
}
|
|
1508
|
-
|
|
1509
|
-
//#region src/node/markdown-decks.ts
|
|
1496
|
+
// src/node/markdown-decks.ts
|
|
1510
1497
|
async function compileMarkdownDecks(input, adapter) {
|
|
1511
1498
|
const markdownEntries = input.decks.filter((entry) => entry.sourcePath.endsWith(".md"));
|
|
1512
1499
|
const mdx = await compileMdxModuleDecks({
|
|
@@ -1632,8 +1619,7 @@ function splitMarkdownSlides(source) {
|
|
|
1632
1619
|
}
|
|
1633
1620
|
return splitSlideSources(protectedLines.join("\n")).map((slide) => slide.replace(new RegExp(`${prefix}(\\d+)_END`, "g"), (_, id) => fences[Number(id)]));
|
|
1634
1621
|
}
|
|
1635
|
-
|
|
1636
|
-
//#region src/adapters/hono-markdown.ts
|
|
1622
|
+
// src/adapters/hono-markdown.ts
|
|
1637
1623
|
/** Node-only bridge. Existing Void configs retain their original compiler/runtime pair. */
|
|
1638
1624
|
async function createHonoMarkdownAdapter(cwd, legacy = false, options) {
|
|
1639
1625
|
const require = createRequire(resolve(cwd, "package.json"));
|
|
@@ -1704,12 +1690,12 @@ hydrateMarkdownIslands({ ${islands.map((island) => `${literal(island.id)}: () =>
|
|
|
1704
1690
|
hydrateDeckMarkdownIslands();
|
|
1705
1691
|
if (window.__honoDecksLive) window.__honoDecksLive.registerHydrator(hydrateDeckMarkdownIslands);`;
|
|
1706
1692
|
}
|
|
1707
|
-
|
|
1708
|
-
//#region src/node/markdown-adapter.ts
|
|
1693
|
+
// src/node/markdown-adapter.ts
|
|
1709
1694
|
async function loadMarkdownAdapter(selection, cwd) {
|
|
1710
1695
|
if (selection === "void") return createHonoMarkdownAdapter(cwd, true);
|
|
1711
1696
|
if (selection.adapter === "hono-decks/adapters/hono-markdown") return createHonoMarkdownAdapter(cwd, false, selection.options);
|
|
1712
|
-
const
|
|
1697
|
+
const require = createRequire(resolve(cwd, "package.json"));
|
|
1698
|
+
const module = await import(pathToFileURL(require.resolve(selection.adapter)).href);
|
|
1713
1699
|
if (typeof module.createMarkdownAdapter !== "function") throw new Error("Markdown adapter must export createMarkdownAdapter.");
|
|
1714
1700
|
const adapter = await module.createMarkdownAdapter({
|
|
1715
1701
|
cwd,
|
|
@@ -1722,8 +1708,7 @@ async function loadMarkdownAdapter(selection, cwd) {
|
|
|
1722
1708
|
].every((value) => typeof value === "function")) throw new Error("Markdown adapter must provide read, compile and client functions.");
|
|
1723
1709
|
return adapter;
|
|
1724
1710
|
}
|
|
1725
|
-
|
|
1726
|
-
//#region src/node/client-entry.ts
|
|
1711
|
+
// src/node/client-entry.ts
|
|
1727
1712
|
async function discoverClientComponentIds(input) {
|
|
1728
1713
|
const result = {};
|
|
1729
1714
|
for (const entry of input.clientEntries) {
|
|
@@ -1745,9 +1730,7 @@ async function emitClientEntryModule(input) {
|
|
|
1745
1730
|
}
|
|
1746
1731
|
const clientModules = input.clientModules ?? [];
|
|
1747
1732
|
if (registrations.length === 0 && clientModules.length === 0) return `export const decksClientEntry = ${JSON.stringify(input.extraCode ?? "")};\n`;
|
|
1748
|
-
const
|
|
1749
|
-
stdin: {
|
|
1750
|
-
contents: `${clientModules.join("\n")}
|
|
1733
|
+
const entryContents = `${clientModules.join("\n")}
|
|
1751
1734
|
import { hydrateSlideIslands } from "hono-decks/client";
|
|
1752
1735
|
${imports.join("\n")}
|
|
1753
1736
|
|
|
@@ -1760,7 +1743,10 @@ function hydrateDeckIslands() {
|
|
|
1760
1743
|
}
|
|
1761
1744
|
hydrateDeckIslands();
|
|
1762
1745
|
if (window.__honoDecksLive) window.__honoDecksLive.registerHydrator(hydrateDeckIslands);
|
|
1763
|
-
|
|
1746
|
+
`;
|
|
1747
|
+
const result = await build({
|
|
1748
|
+
stdin: {
|
|
1749
|
+
contents: entryContents,
|
|
1764
1750
|
resolveDir: input.cwd,
|
|
1765
1751
|
sourcefile: "hono-decks-client-entry.tsx",
|
|
1766
1752
|
loader: "tsx"
|
|
@@ -1828,8 +1814,7 @@ function hashString(value) {
|
|
|
1828
1814
|
function safeIdentifier(value) {
|
|
1829
1815
|
return value.replace(/[^A-Za-z0-9_$]+/g, "_").replace(/^[^A-Za-z_$]+/, "_") || "_";
|
|
1830
1816
|
}
|
|
1831
|
-
|
|
1832
|
-
//#region src/node/local-deck-io.ts
|
|
1817
|
+
// src/node/local-deck-io.ts
|
|
1833
1818
|
async function listFiles(cwd, dir) {
|
|
1834
1819
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
1835
1820
|
return (await Promise.all(entries.map(async (entry) => {
|
|
@@ -1839,9 +1824,8 @@ async function listFiles(cwd, dir) {
|
|
|
1839
1824
|
return [];
|
|
1840
1825
|
}))).flat().sort();
|
|
1841
1826
|
}
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
const MAX_OGP_BYTES = 256 * 1024;
|
|
1827
|
+
// src/node/ogp.ts
|
|
1828
|
+
const MAX_OGP_BYTES = 262144;
|
|
1845
1829
|
const MAX_OGP_REDIRECTS = 3;
|
|
1846
1830
|
async function resolveOgpMetadata(url) {
|
|
1847
1831
|
if (!isHttpUrl(url) || typeof fetch === "undefined") return void 0;
|
|
@@ -2023,8 +2007,7 @@ function isHttpUrl(value) {
|
|
|
2023
2007
|
return false;
|
|
2024
2008
|
}
|
|
2025
2009
|
}
|
|
2026
|
-
|
|
2027
|
-
//#region src/node/compile-decks.ts
|
|
2010
|
+
// src/node/compile-decks.ts
|
|
2028
2011
|
async function compileDecks(input) {
|
|
2029
2012
|
const compiled = await compileDeckModules(input);
|
|
2030
2013
|
await publishGeneratedFiles([...compiled.modules, ...compiled.cacheFile ? [compiled.cacheFile] : []]);
|
|
@@ -2248,8 +2231,7 @@ function resolveRuntimeEntry() {
|
|
|
2248
2231
|
if (existsSync(built)) return built;
|
|
2249
2232
|
return fileURLToPath(new URL("../mod.ts", import.meta.url));
|
|
2250
2233
|
}
|
|
2251
|
-
|
|
2252
|
-
//#region src/node/cli.ts
|
|
2234
|
+
// src/node/cli.ts
|
|
2253
2235
|
const USAGE = `Usage:
|
|
2254
2236
|
hono-decks init [--config hono-decks.config.ts] [--out src/decks.ts]
|
|
2255
2237
|
hono-decks compile [--config hono-decks.config.ts] [--watch] [--refresh-ogp]
|
|
@@ -2386,7 +2368,7 @@ async function runInitCommand(input, args, stdout, stderr) {
|
|
|
2386
2368
|
return { exitCode: 1 };
|
|
2387
2369
|
}
|
|
2388
2370
|
if (parsed.options.framework) try {
|
|
2389
|
-
const { initializeVite } = await import("./init-vite-
|
|
2371
|
+
const { initializeVite } = await import("./init-vite-C1HAF3GF.js");
|
|
2390
2372
|
const sampleSlug = await initializeVite(input.cwd, parsed.options.framework, parsed.options.configFile, parsed.options.entry, parsed.options.install ? { adapter: parsed.options.adapter } : void 0);
|
|
2391
2373
|
stdout(`Initialized ${parsed.options.framework} decks at /slides/${sampleSlug}. Run your usual dev or build command; no manual compile is needed.`);
|
|
2392
2374
|
return { exitCode: 0 };
|
|
@@ -2550,8 +2532,7 @@ if (typeof process !== "undefined" && process.argv[1]?.endsWith("/node/cli.ts"))
|
|
|
2550
2532
|
});
|
|
2551
2533
|
process.exitCode = result.exitCode;
|
|
2552
2534
|
}
|
|
2553
|
-
|
|
2554
|
-
//#region src/bin.ts
|
|
2535
|
+
// src/bin.ts
|
|
2555
2536
|
const result = await runHonoDecksCli({
|
|
2556
2537
|
argv: process.argv.slice(2),
|
|
2557
2538
|
cwd: process.cwd(),
|
|
@@ -2559,5 +2540,4 @@ const result = await runHonoDecksCli({
|
|
|
2559
2540
|
stderr: (line) => process.stderr.write(`${line}\n`)
|
|
2560
2541
|
});
|
|
2561
2542
|
process.exitCode = result.exitCode;
|
|
2562
|
-
//#endregion
|
|
2563
2543
|
export {};
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/node/cli.d.ts
|
|
2
1
|
interface RunHonoDecksCliInput {
|
|
3
2
|
argv: string[];
|
|
4
3
|
cwd: string;
|
|
@@ -16,6 +15,5 @@ interface RunHonoDecksCliInput {
|
|
|
16
15
|
interface RunHonoDecksCliResult {
|
|
17
16
|
exitCode: number;
|
|
18
17
|
}
|
|
19
|
-
declare function runHonoDecksCli(input: RunHonoDecksCliInput): Promise<RunHonoDecksCliResult>;
|
|
20
|
-
|
|
21
|
-
export { type RunHonoDecksCliInput, type RunHonoDecksCliResult, runHonoDecksCli };
|
|
18
|
+
export declare function runHonoDecksCli(input: RunHonoDecksCliInput): Promise<RunHonoDecksCliResult>;
|
|
19
|
+
export type { RunHonoDecksCliInput, RunHonoDecksCliResult };
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as normalizeRelativePath, n as normalizeDeckRoot, r as normalizePath$4, t as publishGeneratedFiles } from "./file-transaction-
|
|
1
|
+
import { i as normalizeRelativePath, n as normalizeDeckRoot, r as normalizePath$4, t as publishGeneratedFiles } from "./file-transaction-BmX5WaTf.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { existsSync, watch } from "node:fs";
|
|
4
4
|
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
@@ -14,7 +14,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
14
14
|
import { build } from "esbuild";
|
|
15
15
|
import { lookup } from "node:dns/promises";
|
|
16
16
|
import { isIP } from "node:net";
|
|
17
|
-
|
|
17
|
+
// src/routing/file-routing.ts
|
|
18
18
|
function resolveDeckFiles(paths, root = "decks", options = {}) {
|
|
19
19
|
const normalizedRoot = normalizePath$3(root).replace(/\/$/, "");
|
|
20
20
|
const decks = /* @__PURE__ */ new Map();
|
|
@@ -68,8 +68,7 @@ function assertInsideRoot(path, root) {
|
|
|
68
68
|
function normalizePath$3(path) {
|
|
69
69
|
return path.replaceAll("\\", "/").replace(/^\.\/+/, "").replace(/\/+/g, "/");
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
//#region src/deck/model.ts
|
|
71
|
+
// src/deck/model.ts
|
|
73
72
|
const SLIDE_TRANSITIONS = [
|
|
74
73
|
"none",
|
|
75
74
|
"fade",
|
|
@@ -88,8 +87,7 @@ var CompileError = class extends Error {
|
|
|
88
87
|
this.name = "CompileError";
|
|
89
88
|
}
|
|
90
89
|
};
|
|
91
|
-
|
|
92
|
-
//#region src/deck/frontmatter.ts
|
|
90
|
+
// src/deck/frontmatter.ts
|
|
93
91
|
function readFrontmatter(source) {
|
|
94
92
|
const normalized = source.replace(/\r\n/g, "\n").trimStart();
|
|
95
93
|
if (!normalized.startsWith("---\n")) return {
|
|
@@ -332,8 +330,7 @@ function takeBoolean(attrs, key) {
|
|
|
332
330
|
delete attrs[key];
|
|
333
331
|
return value;
|
|
334
332
|
}
|
|
335
|
-
|
|
336
|
-
//#region src/deck/assets.ts
|
|
333
|
+
// src/deck/assets.ts
|
|
337
334
|
function buildExternalAssetRefs(candidates) {
|
|
338
335
|
const refs = /* @__PURE__ */ new Map();
|
|
339
336
|
for (const candidate of candidates) {
|
|
@@ -452,8 +449,7 @@ function assetRefType(value) {
|
|
|
452
449
|
if (/^r2:\/\//i.test(value)) return "r2";
|
|
453
450
|
if (value.startsWith("/")) return "public";
|
|
454
451
|
}
|
|
455
|
-
|
|
456
|
-
//#region src/deck/speaker-notes.ts
|
|
452
|
+
// src/deck/speaker-notes.ts
|
|
457
453
|
function extractMdxCommentSpeakerNotes(source) {
|
|
458
454
|
const notes = [];
|
|
459
455
|
return {
|
|
@@ -472,8 +468,7 @@ function combineSpeakerNotes(...notes) {
|
|
|
472
468
|
function normalizeSpeakerNote(value) {
|
|
473
469
|
return value.replace(/\r\n/g, "\n").split("\n").map((line) => line.trim()).join("\n").trim();
|
|
474
470
|
}
|
|
475
|
-
|
|
476
|
-
//#region src/parser/parser.ts
|
|
471
|
+
// src/parser/parser.ts
|
|
477
472
|
const slideSeparator = /^---\s*$/m;
|
|
478
473
|
function parseDeckWithWarnings(markdown) {
|
|
479
474
|
const normalized = markdown.replace(/\r\n/g, "\n").trim();
|
|
@@ -910,8 +905,7 @@ function headingDepth(value) {
|
|
|
910
905
|
function stringAttr(value) {
|
|
911
906
|
return value && value.length > 0 ? value : void 0;
|
|
912
907
|
}
|
|
913
|
-
|
|
914
|
-
//#region src/generator/mdx/assets.ts
|
|
908
|
+
// src/generator/mdx/assets.ts
|
|
915
909
|
function rewriteAssetUrls(source, assets) {
|
|
916
910
|
let result = source;
|
|
917
911
|
for (const asset of assets) {
|
|
@@ -957,8 +951,7 @@ function toRelativeImportPath(fromDir, target) {
|
|
|
957
951
|
function escapeRegExp(value) {
|
|
958
952
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
959
953
|
}
|
|
960
|
-
|
|
961
|
-
//#region src/generator/assets.ts
|
|
954
|
+
// src/generator/assets.ts
|
|
962
955
|
async function buildAssetRefs(slug, assetPaths, input) {
|
|
963
956
|
return Promise.all(assetPaths.map(async (sourcePath) => ({
|
|
964
957
|
sourcePath,
|
|
@@ -979,12 +972,10 @@ function normalizeMountPath(value) {
|
|
|
979
972
|
function normalizePath$1(path) {
|
|
980
973
|
return path.replaceAll("\\", "/").replace(/^\.\/+/, "").replace(/\/+/g, "/");
|
|
981
974
|
}
|
|
982
|
-
|
|
983
|
-
//#region src/generator/package-entry.ts
|
|
975
|
+
// src/generator/package-entry.ts
|
|
984
976
|
const DECKS_RUNTIME_ENTRY = "hono-decks";
|
|
985
977
|
const DECKS_ADVANCED_ENTRY = "hono-decks/advanced";
|
|
986
|
-
|
|
987
|
-
//#region src/generator/mdx/emit.ts
|
|
978
|
+
// src/generator/mdx/emit.ts
|
|
988
979
|
function emitModuleDecksRouter(input) {
|
|
989
980
|
const runtimeEntry = JSON.stringify(DECKS_RUNTIME_ENTRY);
|
|
990
981
|
return `// @ts-nocheck
|
|
@@ -1071,8 +1062,7 @@ function serializeValue(value, depth) {
|
|
|
1071
1062
|
}
|
|
1072
1063
|
return JSON.stringify(value);
|
|
1073
1064
|
}
|
|
1074
|
-
|
|
1075
|
-
//#region src/generator/mdx/ogp.ts
|
|
1065
|
+
// src/generator/mdx/ogp.ts
|
|
1076
1066
|
async function resolveLinkCardMetadataByUrl(source, resolveOgp) {
|
|
1077
1067
|
const result = /* @__PURE__ */ new Map();
|
|
1078
1068
|
if (!resolveOgp) return result;
|
|
@@ -1087,8 +1077,7 @@ function collectLinkCardUrls(source) {
|
|
|
1087
1077
|
for (const match of source.matchAll(/@\[card\]\(([^)\s]+)\)/g)) urls.add(match[1]);
|
|
1088
1078
|
return [...urls];
|
|
1089
1079
|
}
|
|
1090
|
-
|
|
1091
|
-
//#region src/generator/mdx/syntax.ts
|
|
1080
|
+
// src/generator/mdx/syntax.ts
|
|
1092
1081
|
function remarkDeckSyntax(input = {}) {
|
|
1093
1082
|
return () => (tree) => {
|
|
1094
1083
|
transformDeckSyntaxChildren(tree, input);
|
|
@@ -1375,8 +1364,7 @@ function collectMarkdownText(node) {
|
|
|
1375
1364
|
if (!Array.isArray(node.children)) return "";
|
|
1376
1365
|
return node.children.map((child) => collectMarkdownText(child)).join(node.type === "paragraph" ? "\n" : "");
|
|
1377
1366
|
}
|
|
1378
|
-
|
|
1379
|
-
//#region src/generator/mdx-module-generator.ts
|
|
1367
|
+
// src/generator/mdx-module-generator.ts
|
|
1380
1368
|
async function compileMdxModuleDecks(input) {
|
|
1381
1369
|
const decks = await Promise.all(input.decks.map((entry) => compileMdxModuleDeck(input, entry)));
|
|
1382
1370
|
return {
|
|
@@ -1504,8 +1492,7 @@ function extractDeckPrelude(source) {
|
|
|
1504
1492
|
body: lines.slice(cursor).join("\n").trim()
|
|
1505
1493
|
};
|
|
1506
1494
|
}
|
|
1507
|
-
|
|
1508
|
-
//#region src/node/markdown-decks.ts
|
|
1495
|
+
// src/node/markdown-decks.ts
|
|
1509
1496
|
async function compileMarkdownDecks(input, adapter) {
|
|
1510
1497
|
const markdownEntries = input.decks.filter((entry) => entry.sourcePath.endsWith(".md"));
|
|
1511
1498
|
const mdx = await compileMdxModuleDecks({
|
|
@@ -1631,8 +1618,7 @@ function splitMarkdownSlides(source) {
|
|
|
1631
1618
|
}
|
|
1632
1619
|
return splitSlideSources(protectedLines.join("\n")).map((slide) => slide.replace(new RegExp(`${prefix}(\\d+)_END`, "g"), (_, id) => fences[Number(id)]));
|
|
1633
1620
|
}
|
|
1634
|
-
|
|
1635
|
-
//#region src/adapters/hono-markdown.ts
|
|
1621
|
+
// src/adapters/hono-markdown.ts
|
|
1636
1622
|
/** Node-only bridge. Existing Void configs retain their original compiler/runtime pair. */
|
|
1637
1623
|
async function createHonoMarkdownAdapter(cwd, legacy = false, options) {
|
|
1638
1624
|
const require = createRequire(resolve(cwd, "package.json"));
|
|
@@ -1703,12 +1689,12 @@ hydrateMarkdownIslands({ ${islands.map((island) => `${literal(island.id)}: () =>
|
|
|
1703
1689
|
hydrateDeckMarkdownIslands();
|
|
1704
1690
|
if (window.__honoDecksLive) window.__honoDecksLive.registerHydrator(hydrateDeckMarkdownIslands);`;
|
|
1705
1691
|
}
|
|
1706
|
-
|
|
1707
|
-
//#region src/node/markdown-adapter.ts
|
|
1692
|
+
// src/node/markdown-adapter.ts
|
|
1708
1693
|
async function loadMarkdownAdapter(selection, cwd) {
|
|
1709
1694
|
if (selection === "void") return createHonoMarkdownAdapter(cwd, true);
|
|
1710
1695
|
if (selection.adapter === "hono-decks/adapters/hono-markdown") return createHonoMarkdownAdapter(cwd, false, selection.options);
|
|
1711
|
-
const
|
|
1696
|
+
const require = createRequire(resolve(cwd, "package.json"));
|
|
1697
|
+
const module = await import(pathToFileURL(require.resolve(selection.adapter)).href);
|
|
1712
1698
|
if (typeof module.createMarkdownAdapter !== "function") throw new Error("Markdown adapter must export createMarkdownAdapter.");
|
|
1713
1699
|
const adapter = await module.createMarkdownAdapter({
|
|
1714
1700
|
cwd,
|
|
@@ -1721,8 +1707,7 @@ async function loadMarkdownAdapter(selection, cwd) {
|
|
|
1721
1707
|
].every((value) => typeof value === "function")) throw new Error("Markdown adapter must provide read, compile and client functions.");
|
|
1722
1708
|
return adapter;
|
|
1723
1709
|
}
|
|
1724
|
-
|
|
1725
|
-
//#region src/node/client-entry.ts
|
|
1710
|
+
// src/node/client-entry.ts
|
|
1726
1711
|
async function discoverClientComponentIds(input) {
|
|
1727
1712
|
const result = {};
|
|
1728
1713
|
for (const entry of input.clientEntries) {
|
|
@@ -1744,9 +1729,7 @@ async function emitClientEntryModule(input) {
|
|
|
1744
1729
|
}
|
|
1745
1730
|
const clientModules = input.clientModules ?? [];
|
|
1746
1731
|
if (registrations.length === 0 && clientModules.length === 0) return `export const decksClientEntry = ${JSON.stringify(input.extraCode ?? "")};\n`;
|
|
1747
|
-
const
|
|
1748
|
-
stdin: {
|
|
1749
|
-
contents: `${clientModules.join("\n")}
|
|
1732
|
+
const entryContents = `${clientModules.join("\n")}
|
|
1750
1733
|
import { hydrateSlideIslands } from "hono-decks/client";
|
|
1751
1734
|
${imports.join("\n")}
|
|
1752
1735
|
|
|
@@ -1759,7 +1742,10 @@ function hydrateDeckIslands() {
|
|
|
1759
1742
|
}
|
|
1760
1743
|
hydrateDeckIslands();
|
|
1761
1744
|
if (window.__honoDecksLive) window.__honoDecksLive.registerHydrator(hydrateDeckIslands);
|
|
1762
|
-
|
|
1745
|
+
`;
|
|
1746
|
+
const result = await build({
|
|
1747
|
+
stdin: {
|
|
1748
|
+
contents: entryContents,
|
|
1763
1749
|
resolveDir: input.cwd,
|
|
1764
1750
|
sourcefile: "hono-decks-client-entry.tsx",
|
|
1765
1751
|
loader: "tsx"
|
|
@@ -1827,8 +1813,7 @@ function hashString(value) {
|
|
|
1827
1813
|
function safeIdentifier(value) {
|
|
1828
1814
|
return value.replace(/[^A-Za-z0-9_$]+/g, "_").replace(/^[^A-Za-z_$]+/, "_") || "_";
|
|
1829
1815
|
}
|
|
1830
|
-
|
|
1831
|
-
//#region src/node/local-deck-io.ts
|
|
1816
|
+
// src/node/local-deck-io.ts
|
|
1832
1817
|
async function listFiles(cwd, dir) {
|
|
1833
1818
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
1834
1819
|
return (await Promise.all(entries.map(async (entry) => {
|
|
@@ -1838,9 +1823,8 @@ async function listFiles(cwd, dir) {
|
|
|
1838
1823
|
return [];
|
|
1839
1824
|
}))).flat().sort();
|
|
1840
1825
|
}
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
const MAX_OGP_BYTES = 256 * 1024;
|
|
1826
|
+
// src/node/ogp.ts
|
|
1827
|
+
const MAX_OGP_BYTES = 262144;
|
|
1844
1828
|
const MAX_OGP_REDIRECTS = 3;
|
|
1845
1829
|
async function resolveOgpMetadata(url) {
|
|
1846
1830
|
if (!isHttpUrl(url) || typeof fetch === "undefined") return void 0;
|
|
@@ -2022,8 +2006,7 @@ function isHttpUrl(value) {
|
|
|
2022
2006
|
return false;
|
|
2023
2007
|
}
|
|
2024
2008
|
}
|
|
2025
|
-
|
|
2026
|
-
//#region src/node/compile-decks.ts
|
|
2009
|
+
// src/node/compile-decks.ts
|
|
2027
2010
|
async function compileDecks(input) {
|
|
2028
2011
|
const compiled = await compileDeckModules(input);
|
|
2029
2012
|
await publishGeneratedFiles([...compiled.modules, ...compiled.cacheFile ? [compiled.cacheFile] : []]);
|
|
@@ -2247,8 +2230,7 @@ function resolveRuntimeEntry() {
|
|
|
2247
2230
|
if (existsSync(built)) return built;
|
|
2248
2231
|
return fileURLToPath(new URL("../mod.ts", import.meta.url));
|
|
2249
2232
|
}
|
|
2250
|
-
|
|
2251
|
-
//#region src/node/cli.ts
|
|
2233
|
+
// src/node/cli.ts
|
|
2252
2234
|
const USAGE = `Usage:
|
|
2253
2235
|
hono-decks init [--config hono-decks.config.ts] [--out src/decks.ts]
|
|
2254
2236
|
hono-decks compile [--config hono-decks.config.ts] [--watch] [--refresh-ogp]
|
|
@@ -2385,7 +2367,7 @@ async function runInitCommand(input, args, stdout, stderr) {
|
|
|
2385
2367
|
return { exitCode: 1 };
|
|
2386
2368
|
}
|
|
2387
2369
|
if (parsed.options.framework) try {
|
|
2388
|
-
const { initializeVite } = await import("./init-vite-
|
|
2370
|
+
const { initializeVite } = await import("./init-vite-C1HAF3GF.js");
|
|
2389
2371
|
const sampleSlug = await initializeVite(input.cwd, parsed.options.framework, parsed.options.configFile, parsed.options.entry, parsed.options.install ? { adapter: parsed.options.adapter } : void 0);
|
|
2390
2372
|
stdout(`Initialized ${parsed.options.framework} decks at /slides/${sampleSlug}. Run your usual dev or build command; no manual compile is needed.`);
|
|
2391
2373
|
return { exitCode: 0 };
|
|
@@ -2549,8 +2531,7 @@ if (typeof process !== "undefined" && process.argv[1]?.endsWith("/node/cli.ts"))
|
|
|
2549
2531
|
});
|
|
2550
2532
|
process.exitCode = result.exitCode;
|
|
2551
2533
|
}
|
|
2552
|
-
|
|
2553
|
-
//#region src/cli.ts
|
|
2534
|
+
// src/cli.ts
|
|
2554
2535
|
if (typeof process !== "undefined" && process.argv[1]?.endsWith("/cli.ts")) {
|
|
2555
2536
|
const result = await runHonoDecksCli({
|
|
2556
2537
|
argv: process.argv.slice(2),
|
|
@@ -2560,5 +2541,4 @@ if (typeof process !== "undefined" && process.argv[1]?.endsWith("/cli.ts")) {
|
|
|
2560
2541
|
});
|
|
2561
2542
|
process.exitCode = result.exitCode;
|
|
2562
2543
|
}
|
|
2563
|
-
//#endregion
|
|
2564
2544
|
export { runHonoDecksCli };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { Child } from "hono/jsx";
|
|
2
2
|
import { HtmlEscapedString } from "hono/utils/html";
|
|
3
|
-
//#region src/renderer/jsx-renderer.d.ts
|
|
4
3
|
type DeckRenderable = Child | HtmlEscapedString;
|
|
5
4
|
type SlideComponentProps = Record<string, unknown> & {
|
|
6
5
|
children?: DeckRenderable;
|
|
7
6
|
};
|
|
8
7
|
type SlideComponent = (props: SlideComponentProps) => DeckRenderable;
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/client/islands.d.ts
|
|
11
8
|
type ClientSlideComponentRegistry = Record<string, SlideComponent>;
|
|
12
9
|
interface HydrateSlideIslandsInput {
|
|
13
10
|
root?: ParentNode;
|
|
14
11
|
components: ClientSlideComponentRegistry;
|
|
15
12
|
}
|
|
16
|
-
declare function hydrateSlideIslands(input: HydrateSlideIslandsInput): void;
|
|
17
|
-
|
|
18
|
-
export { type ClientSlideComponentRegistry, type HydrateSlideIslandsInput, hydrateSlideIslands };
|
|
13
|
+
export declare function hydrateSlideIslands(input: HydrateSlideIslandsInput): void;
|
|
14
|
+
export type { ClientSlideComponentRegistry, HydrateSlideIslandsInput };
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { flushSync, render, useState } from "hono/jsx/dom";
|
|
2
2
|
import { jsx } from "hono/jsx/dom/jsx-runtime";
|
|
3
|
-
|
|
3
|
+
// src/client/islands.ts
|
|
4
4
|
function hydrateSlideIslands(input) {
|
|
5
5
|
const islands = (input.root ?? document).querySelectorAll("[data-hono-decks-island]");
|
|
6
6
|
for (const island of islands) {
|
|
@@ -27,5 +27,4 @@ function parseIslandProps(value) {
|
|
|
27
27
|
if (!value) return {};
|
|
28
28
|
return JSON.parse(value);
|
|
29
29
|
}
|
|
30
|
-
//#endregion
|
|
31
30
|
export { hydrateSlideIslands };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mkdir, mkdtemp, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
|
|
3
|
+
// src/node/path-utils.ts
|
|
4
4
|
function dirname$1(path) {
|
|
5
5
|
const normalized = normalizePath(path);
|
|
6
6
|
return normalized.includes("/") ? normalized.slice(0, normalized.lastIndexOf("/")) : ".";
|
|
@@ -19,8 +19,7 @@ function normalizeRelativePath(path, label) {
|
|
|
19
19
|
if (normalized === "" || normalized.startsWith("/") || /^[A-Za-z]:\//.test(normalized) || segments.includes("..")) throw new Error(`${label} must be a relative path inside the current working directory`);
|
|
20
20
|
return normalized;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
//#region src/node/file-transaction.ts
|
|
22
|
+
// src/node/file-transaction.ts
|
|
24
23
|
/** Stage every file before publishing; restore the previous files on an I/O error.
|
|
25
24
|
* Individual renames are atomic. This is rollback on failure, not a cross-process
|
|
26
25
|
* or crash-atomic filesystem transaction. Failed rollback retains recovery files.
|
|
@@ -76,5 +75,4 @@ async function publishGeneratedFiles(files, renameFile = rename) {
|
|
|
76
75
|
})));
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
|
-
//#endregion
|
|
80
78
|
export { normalizeRelativePath as i, normalizeDeckRoot as n, normalizePath as r, publishGeneratedFiles as t };
|
package/dist/honox.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
//#region src/honox.d.ts
|
|
3
2
|
/** Keep route discovery in the host's Vite graph; route composition lives here. */
|
|
4
|
-
interface HonoXDecksIntegration<R extends object> {
|
|
3
|
+
export interface HonoXDecksIntegration<R extends object> {
|
|
5
4
|
routes: Record<string, R>;
|
|
6
5
|
mountPath: string;
|
|
7
6
|
router: Hono<any>;
|
|
@@ -9,13 +8,11 @@ interface HonoXDecksIntegration<R extends object> {
|
|
|
9
8
|
/** Preserve HonoX options and mount decks through its normal routing pipeline.
|
|
10
9
|
* Uses structural types so Hono-only consumers do not need to install HonoX.
|
|
11
10
|
*/
|
|
12
|
-
declare function withHonoXDecks<T extends {
|
|
11
|
+
export declare function withHonoXDecks<T extends {
|
|
13
12
|
root?: string;
|
|
14
13
|
ROUTES?: Record<string, object>;
|
|
15
14
|
}, R extends object>(options: T, input: HonoXDecksIntegration<R>): T & {
|
|
16
15
|
ROUTES: Record<string, R | NonNullable<T["ROUTES"]>[string] | {
|
|
17
16
|
default: Hono<any>;
|
|
18
17
|
}>;
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
export { HonoXDecksIntegration, withHonoXDecks };
|
|
18
|
+
};
|
package/dist/honox.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/server/paths.ts
|
|
2
2
|
/** Normalizes a configured mount path to one leading slash and no trailing slash. */
|
|
3
3
|
function normalizeMountPath(value) {
|
|
4
4
|
const trimmed = value.trim();
|
|
@@ -9,8 +9,7 @@ function normalizeMountPath(value) {
|
|
|
9
9
|
while (end > start && trimmed[end - 1] === "/") end -= 1;
|
|
10
10
|
return `/${trimmed.slice(start, end)}`;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
//#region src/honox.ts
|
|
12
|
+
// src/honox.ts
|
|
14
13
|
/** Preserve HonoX options and mount decks through its normal routing pipeline.
|
|
15
14
|
* Uses structural types so Hono-only consumers do not need to install HonoX.
|
|
16
15
|
*/
|
|
@@ -43,5 +42,4 @@ function routesOverlap(path, mount, isApp) {
|
|
|
43
42
|
}
|
|
44
43
|
return route.length >= target.length || isApp || route.some((part) => part.startsWith("[..."));
|
|
45
44
|
}
|
|
46
|
-
//#endregion
|
|
47
45
|
export { withHonoXDecks };
|