hyperbook 0.87.2 → 0.88.1
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/index.js +561 -216
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -55361,7 +55361,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
55361
55361
|
};
|
|
55362
55362
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
55363
55363
|
exports.ASSETS_FOLDER = void 0;
|
|
55364
|
+
exports.buildSingleBookPage = buildSingleBookPage;
|
|
55365
|
+
exports.buildSingleGlossaryPage = buildSingleGlossaryPage;
|
|
55364
55366
|
exports.runBuildProject = runBuildProject;
|
|
55367
|
+
exports.makeBaseCtx = makeBaseCtx;
|
|
55365
55368
|
const path_1 = __importStar(__nccwpck_require__(16928));
|
|
55366
55369
|
const promises_1 = __importStar(__nccwpck_require__(91943));
|
|
55367
55370
|
const chalk_1 = __importDefault(__nccwpck_require__(2434));
|
|
@@ -55375,6 +55378,108 @@ const lunr_1 = __importDefault(__nccwpck_require__(12203));
|
|
|
55375
55378
|
const markdown_1 = __nccwpck_require__(61549);
|
|
55376
55379
|
const package_json_1 = __importDefault(__nccwpck_require__(8330));
|
|
55377
55380
|
exports.ASSETS_FOLDER = "__hyperbook_assets";
|
|
55381
|
+
async function buildSingleBookPage(file, baseCtx, pageList, pagesAndSections, rootOut, assetsOut, hyperbookJson) {
|
|
55382
|
+
const n1 = await fs_1.hyperbook.getNavigationForFile(pageList, file);
|
|
55383
|
+
const navigation = {
|
|
55384
|
+
...n1,
|
|
55385
|
+
...pagesAndSections,
|
|
55386
|
+
};
|
|
55387
|
+
const ctx = {
|
|
55388
|
+
...baseCtx,
|
|
55389
|
+
navigation,
|
|
55390
|
+
};
|
|
55391
|
+
const result = await (0, markdown_1.process)(file.markdown.content, ctx);
|
|
55392
|
+
const searchDocuments = [...(result.data.searchDocuments || [])];
|
|
55393
|
+
const directives = Object.keys(result.data.directives || {});
|
|
55394
|
+
for (const generated of result.data.generatedFiles || []) {
|
|
55395
|
+
let genDir;
|
|
55396
|
+
if (generated.relativeTo === "page") {
|
|
55397
|
+
genDir = path_1.default.join(rootOut, file.path.directory);
|
|
55398
|
+
}
|
|
55399
|
+
else {
|
|
55400
|
+
genDir = path_1.default.join(assetsOut, `directive-${generated.directive}`);
|
|
55401
|
+
}
|
|
55402
|
+
await (0, make_dir_1.makeDir)(genDir, { recursive: true });
|
|
55403
|
+
await promises_1.default.writeFile(path_1.default.join(genDir, generated.filename), generated.content);
|
|
55404
|
+
}
|
|
55405
|
+
let directoryOut = path_1.default.join(rootOut, file.path.directory);
|
|
55406
|
+
let href;
|
|
55407
|
+
if (file.name === "index") {
|
|
55408
|
+
href = path_1.default.posix.join(file.path.href || "", "index.html");
|
|
55409
|
+
}
|
|
55410
|
+
else if (hyperbookJson.trailingSlash) {
|
|
55411
|
+
directoryOut = path_1.default.join(directoryOut, file.name);
|
|
55412
|
+
href = path_1.default.posix.join(file.path.href || "", "index.html");
|
|
55413
|
+
}
|
|
55414
|
+
else {
|
|
55415
|
+
href = file.path.href + ".html";
|
|
55416
|
+
}
|
|
55417
|
+
const fileOut = path_1.default.join(rootOut, href);
|
|
55418
|
+
await (0, make_dir_1.makeDir)(directoryOut, { recursive: true });
|
|
55419
|
+
if (file.markdown.data.permaid) {
|
|
55420
|
+
const permaOut = path_1.default.join(rootOut, "@");
|
|
55421
|
+
await (0, make_dir_1.makeDir)(permaOut, { recursive: true });
|
|
55422
|
+
const permaFileOut = path_1.default.join(permaOut, file.markdown.data.permaid + ".html");
|
|
55423
|
+
await promises_1.default.writeFile(permaFileOut, result.value);
|
|
55424
|
+
}
|
|
55425
|
+
await promises_1.default.writeFile(fileOut, result.value);
|
|
55426
|
+
return { searchDocuments, directives };
|
|
55427
|
+
}
|
|
55428
|
+
async function buildSingleGlossaryPage(file, baseCtx, pageList, pagesAndSections, rootOut, assetsOut, hyperbookJson) {
|
|
55429
|
+
const n1 = await fs_1.hyperbook.getNavigationForFile(pageList, file);
|
|
55430
|
+
const navigation = {
|
|
55431
|
+
...n1,
|
|
55432
|
+
...pagesAndSections,
|
|
55433
|
+
};
|
|
55434
|
+
if (!navigation.current && file.markdown.data) {
|
|
55435
|
+
navigation.current = {
|
|
55436
|
+
name: file.markdown.data.name || file.name,
|
|
55437
|
+
href: file.path.href || undefined,
|
|
55438
|
+
path: file.path,
|
|
55439
|
+
scripts: file.markdown.data.scripts,
|
|
55440
|
+
styles: file.markdown.data.styles,
|
|
55441
|
+
description: file.markdown.data.description,
|
|
55442
|
+
keywords: file.markdown.data.keywords,
|
|
55443
|
+
lang: file.markdown.data.lang,
|
|
55444
|
+
qrcode: file.markdown.data.qrcode,
|
|
55445
|
+
toc: file.markdown.data.toc,
|
|
55446
|
+
layout: file.markdown.data.layout,
|
|
55447
|
+
};
|
|
55448
|
+
}
|
|
55449
|
+
const ctx = {
|
|
55450
|
+
...baseCtx,
|
|
55451
|
+
navigation,
|
|
55452
|
+
};
|
|
55453
|
+
const result = await (0, markdown_1.process)(file.markdown.content, ctx);
|
|
55454
|
+
const searchDocuments = [...(result.data.searchDocuments || [])];
|
|
55455
|
+
const directives = Object.keys(result.data.directives || {});
|
|
55456
|
+
for (const generated of result.data.generatedFiles || []) {
|
|
55457
|
+
let genDir;
|
|
55458
|
+
if (generated.relativeTo === "page") {
|
|
55459
|
+
genDir = path_1.default.join(rootOut, file.path.directory);
|
|
55460
|
+
}
|
|
55461
|
+
else {
|
|
55462
|
+
genDir = path_1.default.join(assetsOut, `directive-${generated.directive}`);
|
|
55463
|
+
}
|
|
55464
|
+
await (0, make_dir_1.makeDir)(genDir, { recursive: true });
|
|
55465
|
+
await promises_1.default.writeFile(path_1.default.join(genDir, generated.filename), generated.content);
|
|
55466
|
+
}
|
|
55467
|
+
const glossaryOut = path_1.default.join(rootOut, "glossary");
|
|
55468
|
+
let href = file.path.href + ".html";
|
|
55469
|
+
let fileOut = path_1.default.join(rootOut, href);
|
|
55470
|
+
if (hyperbookJson.trailingSlash) {
|
|
55471
|
+
href = path_1.default.posix.join(file.path.href || "", "index.html");
|
|
55472
|
+
fileOut = path_1.default.join(rootOut, file.path.href || "", "index.html");
|
|
55473
|
+
await (0, make_dir_1.makeDir)(path_1.default.join(rootOut, file.path.href || ""), {
|
|
55474
|
+
recursive: true,
|
|
55475
|
+
});
|
|
55476
|
+
}
|
|
55477
|
+
else {
|
|
55478
|
+
await (0, make_dir_1.makeDir)(glossaryOut, { recursive: true });
|
|
55479
|
+
}
|
|
55480
|
+
await promises_1.default.writeFile(fileOut, result.value);
|
|
55481
|
+
return { searchDocuments, directives };
|
|
55482
|
+
}
|
|
55378
55483
|
/**
|
|
55379
55484
|
* Generates an llms.txt file by combining all markdown files in order
|
|
55380
55485
|
*/
|
|
@@ -55502,49 +55607,12 @@ async function runBuildProject(project, rootProject, out, filter) {
|
|
|
55502
55607
|
}
|
|
55503
55608
|
}
|
|
55504
55609
|
}
|
|
55505
|
-
|
|
55506
|
-
|
|
55507
|
-
console.log(`${chalk_1.default.blue(`[${prefix}]`)} Reading hyperbook.json.`);
|
|
55508
|
-
const hyperbookJson = await fs_1.hyperbook.getJson(root);
|
|
55509
|
-
if (!basePath && (hyperbookJson === null || hyperbookJson === void 0 ? void 0 : hyperbookJson.basePath)) {
|
|
55510
|
-
basePath = hyperbookJson.basePath;
|
|
55511
|
-
}
|
|
55512
|
-
if (basePath && !basePath.startsWith("/")) {
|
|
55513
|
-
basePath = "/" + basePath;
|
|
55514
|
-
}
|
|
55515
|
-
if (basePath && basePath.endsWith("/")) {
|
|
55516
|
-
basePath = basePath.slice(0, -1);
|
|
55517
|
-
}
|
|
55518
|
-
hyperbookJson.basePath = basePath;
|
|
55519
|
-
fs_1.vfile.clean(root);
|
|
55520
|
-
let link = undefined;
|
|
55521
|
-
if (rootProject.type === "library") {
|
|
55522
|
-
link = await fs_1.hyperproject.getLink(rootProject, hyperbookJson.language);
|
|
55523
|
-
}
|
|
55524
|
-
if (link) {
|
|
55525
|
-
if (!hyperbookJson.links) {
|
|
55526
|
-
hyperbookJson.links = [link];
|
|
55527
|
-
}
|
|
55528
|
-
else {
|
|
55529
|
-
hyperbookJson.links.push(link);
|
|
55530
|
-
}
|
|
55531
|
-
}
|
|
55532
|
-
let rootOut = path_1.default.join(root, ".hyperbook", "out");
|
|
55533
|
-
if (out) {
|
|
55534
|
-
rootOut = path_1.default.join(out, ".hyperbook", "out", basePath || "");
|
|
55535
|
-
}
|
|
55536
|
-
const assetsOut = path_1.default.join(rootOut, exports.ASSETS_FOLDER);
|
|
55537
|
-
console.log(`${chalk_1.default.blue(`[${prefix}]`)} Cleaning output folder ${rootOut}.`);
|
|
55538
|
-
await (0, archive_1.runArchive)(root, rootOut, prefix);
|
|
55539
|
-
// Helper function to resolve relative paths
|
|
55540
|
-
const resolveRelativePath = (path, page) => {
|
|
55610
|
+
function makeBaseCtx(root, hyperbookJson, basePath, rootProject) {
|
|
55611
|
+
const resolveRelativePath = (p, page) => {
|
|
55541
55612
|
var _a;
|
|
55542
|
-
|
|
55543
|
-
|
|
55544
|
-
return path;
|
|
55613
|
+
if (p.startsWith("/")) {
|
|
55614
|
+
return p;
|
|
55545
55615
|
}
|
|
55546
|
-
// Get the directory of the current page
|
|
55547
|
-
// Use page.path.directory if available, otherwise derive from href
|
|
55548
55616
|
let currentPageDir;
|
|
55549
55617
|
if ((_a = page.path) === null || _a === void 0 ? void 0 : _a.directory) {
|
|
55550
55618
|
currentPageDir = path_1.posix.join("/", page.path.directory);
|
|
@@ -55552,67 +55620,99 @@ async function runBuild(root, rootProject, basePath, prefix, out, filter) {
|
|
|
55552
55620
|
else {
|
|
55553
55621
|
currentPageDir = path_1.posix.dirname(page.href || "/");
|
|
55554
55622
|
}
|
|
55555
|
-
|
|
55556
|
-
const resolvedPath = path_1.posix.normalize(path_1.posix.resolve(currentPageDir, path));
|
|
55557
|
-
return resolvedPath;
|
|
55623
|
+
return path_1.posix.normalize(path_1.posix.resolve(currentPageDir, p));
|
|
55558
55624
|
};
|
|
55559
|
-
|
|
55625
|
+
return {
|
|
55560
55626
|
root,
|
|
55561
55627
|
config: hyperbookJson,
|
|
55562
|
-
makeUrl: (
|
|
55563
|
-
if (typeof
|
|
55564
|
-
|
|
55565
|
-
|
|
55566
|
-
return path;
|
|
55628
|
+
makeUrl: (p, base, page, options = { versioned: true }) => {
|
|
55629
|
+
if (typeof p === "string") {
|
|
55630
|
+
if (p.includes("://") || p.startsWith("data:")) {
|
|
55631
|
+
return p;
|
|
55567
55632
|
}
|
|
55568
|
-
if (
|
|
55569
|
-
|
|
55633
|
+
if (p.endsWith(".md")) {
|
|
55634
|
+
p = p.slice(0, -3);
|
|
55570
55635
|
}
|
|
55571
|
-
else if (
|
|
55572
|
-
|
|
55636
|
+
else if (p.endsWith(".md.json")) {
|
|
55637
|
+
p = p.slice(0, -8);
|
|
55573
55638
|
}
|
|
55574
|
-
else if (
|
|
55575
|
-
|
|
55639
|
+
else if (p.endsWith(".md.yml")) {
|
|
55640
|
+
p = p.slice(0, -7);
|
|
55576
55641
|
}
|
|
55577
|
-
|
|
55578
|
-
|
|
55579
|
-
path = resolveRelativePath(path, page);
|
|
55642
|
+
if (page && !p.startsWith("/")) {
|
|
55643
|
+
p = resolveRelativePath(p, page);
|
|
55580
55644
|
}
|
|
55581
|
-
|
|
55645
|
+
p = [p];
|
|
55582
55646
|
}
|
|
55583
|
-
|
|
55584
|
-
|
|
55585
|
-
path = path.map((segment) => {
|
|
55647
|
+
if (Array.isArray(p) && page) {
|
|
55648
|
+
p = p.map((segment) => {
|
|
55586
55649
|
if (typeof segment === "string" && !segment.startsWith("/")) {
|
|
55587
55650
|
return resolveRelativePath(segment, page);
|
|
55588
55651
|
}
|
|
55589
55652
|
return segment;
|
|
55590
55653
|
});
|
|
55591
55654
|
}
|
|
55655
|
+
const pathArr = p;
|
|
55592
55656
|
switch (base) {
|
|
55593
55657
|
case "glossary":
|
|
55594
|
-
return path_1.posix.join("/", basePath || "", "glossary", ...
|
|
55658
|
+
return path_1.posix.join("/", basePath || "", "glossary", ...pathArr);
|
|
55595
55659
|
case "book":
|
|
55596
|
-
return path_1.posix.join(basePath || "", ...
|
|
55660
|
+
return path_1.posix.join(basePath || "", ...pathArr);
|
|
55597
55661
|
case "public":
|
|
55598
|
-
return path_1.posix.join(basePath || "", ...
|
|
55662
|
+
return path_1.posix.join(basePath || "", ...pathArr);
|
|
55599
55663
|
case "archive":
|
|
55600
|
-
return path_1.posix.join("/", basePath || "", "archives", ...
|
|
55664
|
+
return path_1.posix.join("/", basePath || "", "archives", ...pathArr);
|
|
55601
55665
|
case "assets":
|
|
55602
|
-
if (
|
|
55603
|
-
return `${path_1.posix.join("/", basePath || "", exports.ASSETS_FOLDER, ...
|
|
55666
|
+
if (pathArr.length === 1 && pathArr[0] === "/") {
|
|
55667
|
+
return `${path_1.posix.join("/", basePath || "", exports.ASSETS_FOLDER, ...pathArr)}`;
|
|
55604
55668
|
}
|
|
55605
55669
|
else {
|
|
55606
|
-
let
|
|
55670
|
+
let result = `${path_1.posix.join("/", basePath || "", exports.ASSETS_FOLDER, ...pathArr)}`;
|
|
55607
55671
|
if (options === null || options === void 0 ? void 0 : options.versioned) {
|
|
55608
|
-
|
|
55672
|
+
result += `?v=${package_json_1.default.version}`;
|
|
55609
55673
|
}
|
|
55610
|
-
return
|
|
55674
|
+
return result;
|
|
55611
55675
|
}
|
|
55612
55676
|
}
|
|
55613
55677
|
},
|
|
55614
55678
|
project: rootProject,
|
|
55615
55679
|
};
|
|
55680
|
+
}
|
|
55681
|
+
async function runBuild(root, rootProject, basePath, prefix, out, filter) {
|
|
55682
|
+
var _a;
|
|
55683
|
+
console.log(`${chalk_1.default.blue(`[${prefix}]`)} Reading hyperbook.json.`);
|
|
55684
|
+
const hyperbookJson = await fs_1.hyperbook.getJson(root);
|
|
55685
|
+
if (!basePath && (hyperbookJson === null || hyperbookJson === void 0 ? void 0 : hyperbookJson.basePath)) {
|
|
55686
|
+
basePath = hyperbookJson.basePath;
|
|
55687
|
+
}
|
|
55688
|
+
if (basePath && !basePath.startsWith("/")) {
|
|
55689
|
+
basePath = "/" + basePath;
|
|
55690
|
+
}
|
|
55691
|
+
if (basePath && basePath.endsWith("/")) {
|
|
55692
|
+
basePath = basePath.slice(0, -1);
|
|
55693
|
+
}
|
|
55694
|
+
hyperbookJson.basePath = basePath;
|
|
55695
|
+
fs_1.vfile.clean(root);
|
|
55696
|
+
let link = undefined;
|
|
55697
|
+
if (rootProject.type === "library") {
|
|
55698
|
+
link = await fs_1.hyperproject.getLink(rootProject, hyperbookJson.language);
|
|
55699
|
+
}
|
|
55700
|
+
if (link) {
|
|
55701
|
+
if (!hyperbookJson.links) {
|
|
55702
|
+
hyperbookJson.links = [link];
|
|
55703
|
+
}
|
|
55704
|
+
else {
|
|
55705
|
+
hyperbookJson.links.push(link);
|
|
55706
|
+
}
|
|
55707
|
+
}
|
|
55708
|
+
let rootOut = path_1.default.join(root, ".hyperbook", "out");
|
|
55709
|
+
if (out) {
|
|
55710
|
+
rootOut = path_1.default.join(out, ".hyperbook", "out", basePath || "");
|
|
55711
|
+
}
|
|
55712
|
+
const assetsOut = path_1.default.join(rootOut, exports.ASSETS_FOLDER);
|
|
55713
|
+
console.log(`${chalk_1.default.blue(`[${prefix}]`)} Cleaning output folder ${rootOut}.`);
|
|
55714
|
+
await (0, archive_1.runArchive)(root, rootOut, prefix);
|
|
55715
|
+
const baseCtx = makeBaseCtx(root, hyperbookJson, basePath, rootProject);
|
|
55616
55716
|
const directives = new Set([]);
|
|
55617
55717
|
const pagesAndSections = await fs_1.hyperbook.getPagesAndSections(root);
|
|
55618
55718
|
const pageList = fs_1.hyperbook.getPageList(pagesAndSections.sections, pagesAndSections.pages);
|
|
@@ -55623,56 +55723,11 @@ async function runBuild(root, rootProject, basePath, prefix, out, filter) {
|
|
|
55623
55723
|
}
|
|
55624
55724
|
let i = 1;
|
|
55625
55725
|
for (let file of bookFiles) {
|
|
55626
|
-
const
|
|
55627
|
-
|
|
55628
|
-
|
|
55629
|
-
...pagesAndSections,
|
|
55630
|
-
};
|
|
55631
|
-
const ctx = {
|
|
55632
|
-
...baseCtx,
|
|
55633
|
-
navigation,
|
|
55634
|
-
};
|
|
55635
|
-
const result = await (0, markdown_1.process)(file.markdown.content, ctx);
|
|
55636
|
-
searchDocuments.push(...(result.data.searchDocuments || []));
|
|
55637
|
-
for (let directive of Object.keys(result.data.directives || {})) {
|
|
55726
|
+
const pageResult = await buildSingleBookPage(file, baseCtx, pageList, pagesAndSections, rootOut, assetsOut, hyperbookJson);
|
|
55727
|
+
searchDocuments.push(...pageResult.searchDocuments);
|
|
55728
|
+
for (let directive of pageResult.directives) {
|
|
55638
55729
|
directives.add(directive);
|
|
55639
55730
|
}
|
|
55640
|
-
for (const generated of result.data.generatedFiles || []) {
|
|
55641
|
-
let genDir;
|
|
55642
|
-
if (generated.relativeTo === "page") {
|
|
55643
|
-
genDir = path_1.default.join(rootOut, file.path.directory);
|
|
55644
|
-
}
|
|
55645
|
-
else {
|
|
55646
|
-
genDir = path_1.default.join(assetsOut, `directive-${generated.directive}`);
|
|
55647
|
-
}
|
|
55648
|
-
await (0, make_dir_1.makeDir)(genDir, { recursive: true });
|
|
55649
|
-
await promises_1.default.writeFile(path_1.default.join(genDir, generated.filename), generated.content);
|
|
55650
|
-
}
|
|
55651
|
-
let directoryOut = path_1.default.join(rootOut, file.path.directory);
|
|
55652
|
-
let href;
|
|
55653
|
-
if (file.name === "index") {
|
|
55654
|
-
href = path_1.default.posix.join(file.path.href || "", "index.html");
|
|
55655
|
-
}
|
|
55656
|
-
else if (hyperbookJson.trailingSlash) {
|
|
55657
|
-
directoryOut = path_1.default.join(directoryOut, file.name);
|
|
55658
|
-
href = path_1.default.posix.join(file.path.href || "", "index.html");
|
|
55659
|
-
}
|
|
55660
|
-
else {
|
|
55661
|
-
href = file.path.href + ".html";
|
|
55662
|
-
}
|
|
55663
|
-
const fileOut = path_1.default.join(rootOut, href);
|
|
55664
|
-
await (0, make_dir_1.makeDir)(directoryOut, {
|
|
55665
|
-
recursive: true,
|
|
55666
|
-
});
|
|
55667
|
-
if (file.markdown.data.permaid) {
|
|
55668
|
-
const permaOut = path_1.default.join(rootOut, "@");
|
|
55669
|
-
await (0, make_dir_1.makeDir)(permaOut, {
|
|
55670
|
-
recursive: true,
|
|
55671
|
-
});
|
|
55672
|
-
const permaFileOut = path_1.default.join(permaOut, file.markdown.data.permaid + ".html");
|
|
55673
|
-
await promises_1.default.writeFile(permaFileOut, result.value);
|
|
55674
|
-
}
|
|
55675
|
-
await promises_1.default.writeFile(fileOut, result.value);
|
|
55676
55731
|
if (!process.env.CI) {
|
|
55677
55732
|
readline_1.default.clearLine(process.stdout, 0);
|
|
55678
55733
|
readline_1.default.cursorTo(process.stdout, 0);
|
|
@@ -55684,68 +55739,16 @@ async function runBuild(root, rootProject, basePath, prefix, out, filter) {
|
|
|
55684
55739
|
}
|
|
55685
55740
|
process.stdout.write("\n");
|
|
55686
55741
|
let glossaryFiles = await fs_1.vfile.listForFolder(root, "glossary");
|
|
55687
|
-
const glossaryOut = path_1.default.join(rootOut, "glossary");
|
|
55688
55742
|
if (filter) {
|
|
55689
55743
|
glossaryFiles = glossaryFiles.filter((f) => { var _a; return (_a = f.path.absolute) === null || _a === void 0 ? void 0 : _a.endsWith(filter); });
|
|
55690
55744
|
}
|
|
55691
55745
|
i = 1;
|
|
55692
55746
|
for (let file of glossaryFiles) {
|
|
55693
|
-
const
|
|
55694
|
-
|
|
55695
|
-
|
|
55696
|
-
...pagesAndSections,
|
|
55697
|
-
};
|
|
55698
|
-
// If current is null (glossary page not in pageList), create it from file frontmatter
|
|
55699
|
-
if (!navigation.current && file.markdown.data) {
|
|
55700
|
-
navigation.current = {
|
|
55701
|
-
name: file.markdown.data.name || file.name,
|
|
55702
|
-
href: file.path.href || undefined,
|
|
55703
|
-
path: file.path,
|
|
55704
|
-
scripts: file.markdown.data.scripts,
|
|
55705
|
-
styles: file.markdown.data.styles,
|
|
55706
|
-
description: file.markdown.data.description,
|
|
55707
|
-
keywords: file.markdown.data.keywords,
|
|
55708
|
-
lang: file.markdown.data.lang,
|
|
55709
|
-
qrcode: file.markdown.data.qrcode,
|
|
55710
|
-
toc: file.markdown.data.toc,
|
|
55711
|
-
layout: file.markdown.data.layout,
|
|
55712
|
-
};
|
|
55713
|
-
}
|
|
55714
|
-
const ctx = {
|
|
55715
|
-
...baseCtx,
|
|
55716
|
-
navigation,
|
|
55717
|
-
};
|
|
55718
|
-
const result = await (0, markdown_1.process)(file.markdown.content, ctx);
|
|
55719
|
-
searchDocuments.push(...(result.data.searchDocuments || []));
|
|
55720
|
-
for (let directive of Object.keys(result.data.directives || {})) {
|
|
55747
|
+
const pageResult = await buildSingleGlossaryPage(file, baseCtx, pageList, pagesAndSections, rootOut, assetsOut, hyperbookJson);
|
|
55748
|
+
searchDocuments.push(...pageResult.searchDocuments);
|
|
55749
|
+
for (let directive of pageResult.directives) {
|
|
55721
55750
|
directives.add(directive);
|
|
55722
55751
|
}
|
|
55723
|
-
for (const generated of result.data.generatedFiles || []) {
|
|
55724
|
-
let genDir;
|
|
55725
|
-
if (generated.relativeTo === "page") {
|
|
55726
|
-
genDir = path_1.default.join(rootOut, file.path.directory);
|
|
55727
|
-
}
|
|
55728
|
-
else {
|
|
55729
|
-
genDir = path_1.default.join(assetsOut, `directive-${generated.directive}`);
|
|
55730
|
-
}
|
|
55731
|
-
await (0, make_dir_1.makeDir)(genDir, { recursive: true });
|
|
55732
|
-
await promises_1.default.writeFile(path_1.default.join(genDir, generated.filename), generated.content);
|
|
55733
|
-
}
|
|
55734
|
-
let href = file.path.href + ".html";
|
|
55735
|
-
let fileOut = path_1.default.join(rootOut, href);
|
|
55736
|
-
if (hyperbookJson.trailingSlash) {
|
|
55737
|
-
href = path_1.default.posix.join(file.path.href || "", "index.html");
|
|
55738
|
-
fileOut = path_1.default.join(rootOut, file.path.href || "", "index.html");
|
|
55739
|
-
await (0, make_dir_1.makeDir)(path_1.default.join(rootOut, file.path.href || ""), {
|
|
55740
|
-
recursive: true,
|
|
55741
|
-
});
|
|
55742
|
-
}
|
|
55743
|
-
else {
|
|
55744
|
-
await (0, make_dir_1.makeDir)(glossaryOut, {
|
|
55745
|
-
recursive: true,
|
|
55746
|
-
});
|
|
55747
|
-
}
|
|
55748
|
-
await promises_1.default.writeFile(fileOut, result.value);
|
|
55749
55752
|
if (!process.env.CI) {
|
|
55750
55753
|
readline_1.default.clearLine(process.stdout, 0);
|
|
55751
55754
|
readline_1.default.cursorTo(process.stdout, 0);
|
|
@@ -55956,8 +55959,12 @@ async function runBuild(root, rootProject, basePath, prefix, out, filter) {
|
|
|
55956
55959
|
let foundLanguage = false;
|
|
55957
55960
|
if (hyperbookJson.language && hyperbookJson.language !== "en") {
|
|
55958
55961
|
try {
|
|
55959
|
-
|
|
55960
|
-
|
|
55962
|
+
// Only register lunr language plugins once to avoid "Overwriting" warnings
|
|
55963
|
+
if (!lunr_1.default["_hyperbook_lang_loaded_" + hyperbookJson.language]) {
|
|
55964
|
+
__nccwpck_require__(30089)(lunr_1.default);
|
|
55965
|
+
require(`./lunr-languages/lunr.${hyperbookJson.language}.min.js`)(lunr_1.default);
|
|
55966
|
+
lunr_1.default["_hyperbook_lang_loaded_" + hyperbookJson.language] = true;
|
|
55967
|
+
}
|
|
55961
55968
|
foundLanguage = true;
|
|
55962
55969
|
}
|
|
55963
55970
|
catch (e) {
|
|
@@ -56029,14 +56036,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
56029
56036
|
exports.runDev = runDev;
|
|
56030
56037
|
const chokidar_1 = __importDefault(__nccwpck_require__(39827));
|
|
56031
56038
|
const fs_1 = __nccwpck_require__(96780);
|
|
56032
|
-
const
|
|
56039
|
+
const incremental_1 = __nccwpck_require__(94153);
|
|
56033
56040
|
const path_1 = __importDefault(__nccwpck_require__(16928));
|
|
56034
56041
|
const http_1 = __importDefault(__nccwpck_require__(58611));
|
|
56035
56042
|
const fs_2 = __importDefault(__nccwpck_require__(79896));
|
|
56036
56043
|
const mime_1 = __importDefault(__nccwpck_require__(94931));
|
|
56037
56044
|
const ws_1 = __nccwpck_require__(55999);
|
|
56038
56045
|
const chalk_1 = __importDefault(__nccwpck_require__(2434));
|
|
56039
|
-
const rimraf_1 = __nccwpck_require__(52114);
|
|
56040
56046
|
const prompts_1 = __importDefault(__nccwpck_require__(63792));
|
|
56041
56047
|
const net_1 = __importDefault(__nccwpck_require__(69278));
|
|
56042
56048
|
async function isPortAvailable(port) {
|
|
@@ -56108,15 +56114,68 @@ async function runDev({ port = 8080 }) {
|
|
|
56108
56114
|
if (request.url === "/__hyperbook_dev.js") {
|
|
56109
56115
|
const responseBody = `
|
|
56110
56116
|
const socket = new WebSocket("ws://localhost:${port}");
|
|
56117
|
+
|
|
56118
|
+
// Report current page to server
|
|
56119
|
+
socket.addEventListener("open", () => {
|
|
56120
|
+
socket.send(JSON.stringify({ type: "page", href: window.location.pathname }));
|
|
56121
|
+
});
|
|
56122
|
+
|
|
56111
56123
|
socket.addEventListener("message", (event) => {
|
|
56112
|
-
|
|
56113
|
-
|
|
56114
|
-
|
|
56115
|
-
|
|
56124
|
+
let msg;
|
|
56125
|
+
try {
|
|
56126
|
+
msg = JSON.parse(event.data);
|
|
56127
|
+
} catch {
|
|
56128
|
+
// Legacy fallback
|
|
56129
|
+
if (event.data === "RELOAD") {
|
|
56130
|
+
msg = { type: "reload", changedPages: "*" };
|
|
56131
|
+
} else {
|
|
56132
|
+
return;
|
|
56133
|
+
}
|
|
56134
|
+
}
|
|
56135
|
+
|
|
56136
|
+
if (msg.type === "rebuilding") {
|
|
56137
|
+
var btn = document.getElementById("__hb_reload_btn");
|
|
56138
|
+
if (btn) {
|
|
56139
|
+
btn.style.opacity = "1";
|
|
56140
|
+
btn.style.animation = "__hb_spin 0.8s linear infinite";
|
|
56141
|
+
btn.disabled = true;
|
|
56142
|
+
btn.dataset.spinning = "1";
|
|
56143
|
+
}
|
|
56144
|
+
}
|
|
56145
|
+
|
|
56146
|
+
if (msg.type === "rebuild-complete") {
|
|
56147
|
+
// Force-reload build finished — stop spinner, don't refresh
|
|
56148
|
+
var btn = document.getElementById("__hb_reload_btn");
|
|
56149
|
+
if (btn) {
|
|
56150
|
+
btn.style.animation = "none";
|
|
56151
|
+
btn.disabled = false;
|
|
56152
|
+
delete btn.dataset.spinning;
|
|
56153
|
+
btn.innerHTML = "✓";
|
|
56154
|
+
setTimeout(function() { btn.innerHTML = "↻"; btn.style.opacity = "0.6"; }, 2000);
|
|
56155
|
+
}
|
|
56156
|
+
}
|
|
56157
|
+
|
|
56158
|
+
if (msg.type === "reload") {
|
|
56159
|
+
const currentPath = window.location.pathname;
|
|
56160
|
+
const shouldReload = msg.changedPages === "*" || msg.changedPages.some(function(p) {
|
|
56161
|
+
// Special case for root page
|
|
56162
|
+
if (p === "/" && (currentPath === "/" || currentPath === "/index.html")) {
|
|
56163
|
+
return true;
|
|
56164
|
+
}
|
|
56165
|
+
return currentPath === p || currentPath === p + "/" || currentPath === p + ".html"
|
|
56166
|
+
|| currentPath === p + "/index.html" || currentPath.startsWith(p + "/");
|
|
56167
|
+
});
|
|
56168
|
+
|
|
56169
|
+
if (shouldReload) {
|
|
56170
|
+
const main = document.querySelector("main");
|
|
56171
|
+
if (main) {
|
|
56172
|
+
localStorage.setItem("__hyperbook_dev_scroll", main.scrollTop);
|
|
56173
|
+
}
|
|
56174
|
+
window.location.reload();
|
|
56116
56175
|
}
|
|
56117
|
-
window.location.reload();
|
|
56118
56176
|
}
|
|
56119
56177
|
});
|
|
56178
|
+
|
|
56120
56179
|
window.onload = () => {
|
|
56121
56180
|
const main = document.querySelector("main");
|
|
56122
56181
|
const scrollTop = localStorage.getItem("__hyperbook_dev_scroll");
|
|
@@ -56124,6 +56183,31 @@ window.onload = () => {
|
|
|
56124
56183
|
main.scrollTop = parseInt(scrollTop, 10);
|
|
56125
56184
|
localStorage.removeItem("__hyperbook_dev_scroll");
|
|
56126
56185
|
}
|
|
56186
|
+
|
|
56187
|
+
// Force full reload button
|
|
56188
|
+
var style = document.createElement("style");
|
|
56189
|
+
style.textContent = "@keyframes __hb_spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }";
|
|
56190
|
+
document.head.appendChild(style);
|
|
56191
|
+
|
|
56192
|
+
var btn = document.createElement("button");
|
|
56193
|
+
btn.id = "__hb_reload_btn";
|
|
56194
|
+
btn.type = "button";
|
|
56195
|
+
btn.innerHTML = "↻";
|
|
56196
|
+
btn.title = "Force full rebuild";
|
|
56197
|
+
btn.style.cssText = "position:fixed;bottom:16px;right:16px;z-index:99999;"
|
|
56198
|
+
+ "width:40px;height:40px;border-radius:50%;border:none;cursor:pointer;"
|
|
56199
|
+
+ "background:#333;color:#fff;font-size:20px;line-height:1;"
|
|
56200
|
+
+ "box-shadow:0 2px 8px rgba(0,0,0,0.3);opacity:0.6;transition:opacity 0.2s;";
|
|
56201
|
+
btn.addEventListener("mouseenter", function() { btn.style.opacity = "1"; });
|
|
56202
|
+
btn.addEventListener("mouseleave", function() { if (!btn.dataset.spinning) btn.style.opacity = "0.6"; });
|
|
56203
|
+
btn.addEventListener("click", function() {
|
|
56204
|
+
btn.style.opacity = "1";
|
|
56205
|
+
btn.style.animation = "__hb_spin 0.8s linear infinite";
|
|
56206
|
+
btn.disabled = true;
|
|
56207
|
+
btn.dataset.spinning = "1";
|
|
56208
|
+
socket.send(JSON.stringify({ type: "force-reload" }));
|
|
56209
|
+
});
|
|
56210
|
+
document.body.appendChild(btn);
|
|
56127
56211
|
};
|
|
56128
56212
|
`;
|
|
56129
56213
|
response.writeHead(200, {
|
|
@@ -56192,42 +56276,72 @@ window.onload = () => {
|
|
|
56192
56276
|
const reloadServer = new ws_1.WebSocketServer({
|
|
56193
56277
|
server,
|
|
56194
56278
|
});
|
|
56195
|
-
|
|
56279
|
+
const broadcast = (msg) => {
|
|
56280
|
+
const message = JSON.stringify(msg);
|
|
56196
56281
|
reloadServer.clients.forEach((client) => {
|
|
56197
|
-
client.
|
|
56282
|
+
if (client.readyState === ws_1.WebSocket.OPEN) {
|
|
56283
|
+
client.send(message);
|
|
56284
|
+
}
|
|
56285
|
+
});
|
|
56286
|
+
};
|
|
56287
|
+
const sendReload = (changedPages) => {
|
|
56288
|
+
broadcast({ type: "reload", changedPages });
|
|
56289
|
+
};
|
|
56290
|
+
// Handle client messages (force-reload requests)
|
|
56291
|
+
reloadServer.on("connection", (ws) => {
|
|
56292
|
+
ws.on("message", (data) => {
|
|
56293
|
+
try {
|
|
56294
|
+
const msg = JSON.parse(data.toString());
|
|
56295
|
+
if (msg.type === "force-reload" && !rebuilding) {
|
|
56296
|
+
console.log(`${chalk_1.default.yellow("[Force Reload]")} Triggered by client`);
|
|
56297
|
+
rebuilding = true;
|
|
56298
|
+
broadcast({ type: "rebuilding" });
|
|
56299
|
+
builder.handleChange("hyperbook.json", "change")
|
|
56300
|
+
.then(() => {
|
|
56301
|
+
broadcast({ type: "rebuild-complete" });
|
|
56302
|
+
})
|
|
56303
|
+
.catch((e) => {
|
|
56304
|
+
console.error(`${chalk_1.default.red("[Error]")}: ${e instanceof Error ? e.message : e}`);
|
|
56305
|
+
})
|
|
56306
|
+
.finally(() => {
|
|
56307
|
+
rebuilding = false;
|
|
56308
|
+
});
|
|
56309
|
+
}
|
|
56310
|
+
}
|
|
56311
|
+
catch {
|
|
56312
|
+
// Ignore malformed messages
|
|
56313
|
+
}
|
|
56198
56314
|
});
|
|
56199
56315
|
});
|
|
56316
|
+
////////////////////
|
|
56317
|
+
// Incremental Builder
|
|
56318
|
+
////////////////////
|
|
56319
|
+
const builder = new incremental_1.IncrementalBuilder(root, rootProject);
|
|
56200
56320
|
let rebuilding = false;
|
|
56201
|
-
const
|
|
56321
|
+
const handleFileChange = (eventType) => async (file) => {
|
|
56202
56322
|
if (!rebuilding) {
|
|
56203
|
-
console.log(`${chalk_1.default.yellow(`[
|
|
56323
|
+
console.log(`${chalk_1.default.yellow(`[File ${eventType}]`)}: ${file}`);
|
|
56204
56324
|
rebuilding = true;
|
|
56325
|
+
broadcast({ type: "rebuilding" });
|
|
56205
56326
|
try {
|
|
56206
|
-
const
|
|
56207
|
-
|
|
56208
|
-
|
|
56209
|
-
const cleanOutDir = path_1.default.join(rootProject.src, ".hyperbook", "out");
|
|
56210
|
-
console.log(`${chalk_1.default.yellow(`[Cleaning]`)}: ${cleanOutDir}`);
|
|
56211
|
-
await (0, rimraf_1.rimraf)(cleanOutDir);
|
|
56212
|
-
}
|
|
56213
|
-
await (0, build_1.runBuildProject)(rootProject, rootProject);
|
|
56214
|
-
console.log(`${chalk_1.default.yellow(`[Reloading]`)}: Website`);
|
|
56215
|
-
reloadServer.emit("reload");
|
|
56327
|
+
const result = await builder.handleChange(file, eventType);
|
|
56328
|
+
console.log(`${chalk_1.default.yellow("[Reloading]")}: Website`);
|
|
56329
|
+
sendReload(result.changedPages);
|
|
56216
56330
|
}
|
|
56217
56331
|
catch (e) {
|
|
56218
56332
|
if (e instanceof Error) {
|
|
56219
|
-
console.error(`${chalk_1.default.red(
|
|
56333
|
+
console.error(`${chalk_1.default.red("[Error]")}: ${e.message}.`);
|
|
56220
56334
|
}
|
|
56221
56335
|
else {
|
|
56222
|
-
console.error(`${chalk_1.default.red(
|
|
56336
|
+
console.error(`${chalk_1.default.red("[Error]")}: ${e}.`);
|
|
56223
56337
|
}
|
|
56224
56338
|
}
|
|
56225
56339
|
rebuilding = false;
|
|
56226
56340
|
}
|
|
56227
56341
|
};
|
|
56228
|
-
await
|
|
56342
|
+
await builder.initialize();
|
|
56229
56343
|
server.listen(port, () => {
|
|
56230
|
-
console.log(`${chalk_1.default.yellow(
|
|
56344
|
+
console.log(`${chalk_1.default.yellow("[DEV-SERVER]")} is running at http://localhost:${port}`);
|
|
56231
56345
|
});
|
|
56232
56346
|
////////////////////
|
|
56233
56347
|
// File Watching
|
|
@@ -56238,11 +56352,11 @@ window.onload = () => {
|
|
|
56238
56352
|
cwd: root,
|
|
56239
56353
|
usePolling: true,
|
|
56240
56354
|
interval: 600,
|
|
56241
|
-
ignored: [outDir, path_1.default.join("archives", "*.zip")],
|
|
56355
|
+
ignored: [outDir, path_1.default.join("archives", "*.zip"), /(^|[\/\\])\./, "**/node_modules/**"],
|
|
56242
56356
|
})
|
|
56243
|
-
.on("add",
|
|
56244
|
-
.on("change",
|
|
56245
|
-
.on("unlink",
|
|
56357
|
+
.on("add", handleFileChange("add"))
|
|
56358
|
+
.on("change", handleFileChange("change"))
|
|
56359
|
+
.on("unlink", handleFileChange("unlink"));
|
|
56246
56360
|
}
|
|
56247
56361
|
|
|
56248
56362
|
|
|
@@ -56398,6 +56512,239 @@ async function makeDir(root, options = { recursive: true }) {
|
|
|
56398
56512
|
}
|
|
56399
56513
|
|
|
56400
56514
|
|
|
56515
|
+
/***/ }),
|
|
56516
|
+
|
|
56517
|
+
/***/ 94153:
|
|
56518
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
56519
|
+
|
|
56520
|
+
"use strict";
|
|
56521
|
+
|
|
56522
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
56523
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
56524
|
+
};
|
|
56525
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
56526
|
+
exports.IncrementalBuilder = void 0;
|
|
56527
|
+
const path_1 = __importDefault(__nccwpck_require__(16928));
|
|
56528
|
+
const promises_1 = __importDefault(__nccwpck_require__(91943));
|
|
56529
|
+
const promises_2 = __nccwpck_require__(91943);
|
|
56530
|
+
const chalk_1 = __importDefault(__nccwpck_require__(2434));
|
|
56531
|
+
const fs_1 = __nccwpck_require__(96780);
|
|
56532
|
+
const build_1 = __nccwpck_require__(58097);
|
|
56533
|
+
class IncrementalBuilder {
|
|
56534
|
+
constructor(root, rootProject) {
|
|
56535
|
+
this.hyperbookJson = null;
|
|
56536
|
+
this.baseCtx = null;
|
|
56537
|
+
this.pagesAndSections = null;
|
|
56538
|
+
this.pageList = null;
|
|
56539
|
+
this.searchDocuments = new Map();
|
|
56540
|
+
this.directives = new Set();
|
|
56541
|
+
this.rootOut = "";
|
|
56542
|
+
this.assetsOut = "";
|
|
56543
|
+
this.initialized = false;
|
|
56544
|
+
// Track known files for structural change detection
|
|
56545
|
+
this.knownBookFiles = new Set();
|
|
56546
|
+
this.knownGlossaryFiles = new Set();
|
|
56547
|
+
this.root = root;
|
|
56548
|
+
this.rootProject = rootProject;
|
|
56549
|
+
}
|
|
56550
|
+
async initialize() {
|
|
56551
|
+
console.log(`${chalk_1.default.yellow("[Incremental]")} Full initial build...`);
|
|
56552
|
+
await (0, build_1.runBuildProject)(this.rootProject, this.rootProject);
|
|
56553
|
+
// Populate caches after full build
|
|
56554
|
+
await this.refreshCaches();
|
|
56555
|
+
this.initialized = true;
|
|
56556
|
+
console.log(`${chalk_1.default.green("[Incremental]")} Initial build complete. Incremental mode active.`);
|
|
56557
|
+
}
|
|
56558
|
+
async refreshCaches() {
|
|
56559
|
+
var _a;
|
|
56560
|
+
const project = this.rootProject;
|
|
56561
|
+
if (project.type !== "book") {
|
|
56562
|
+
// For libraries, we don't support incremental — always full rebuild
|
|
56563
|
+
return;
|
|
56564
|
+
}
|
|
56565
|
+
this.hyperbookJson = await fs_1.hyperbook.getJson(this.root);
|
|
56566
|
+
let basePath = project.basePath;
|
|
56567
|
+
if (!basePath && ((_a = this.hyperbookJson) === null || _a === void 0 ? void 0 : _a.basePath)) {
|
|
56568
|
+
basePath = this.hyperbookJson.basePath;
|
|
56569
|
+
}
|
|
56570
|
+
if (basePath && !basePath.startsWith("/")) {
|
|
56571
|
+
basePath = "/" + basePath;
|
|
56572
|
+
}
|
|
56573
|
+
if (basePath && basePath.endsWith("/")) {
|
|
56574
|
+
basePath = basePath.slice(0, -1);
|
|
56575
|
+
}
|
|
56576
|
+
this.hyperbookJson.basePath = basePath;
|
|
56577
|
+
this.baseCtx = (0, build_1.makeBaseCtx)(this.root, this.hyperbookJson, basePath, this.rootProject);
|
|
56578
|
+
this.pagesAndSections = await fs_1.hyperbook.getPagesAndSections(this.root);
|
|
56579
|
+
this.pageList = fs_1.hyperbook.getPageList(this.pagesAndSections.sections, this.pagesAndSections.pages);
|
|
56580
|
+
this.rootOut = path_1.default.join(this.root, ".hyperbook", "out");
|
|
56581
|
+
this.assetsOut = path_1.default.join(this.rootOut, build_1.ASSETS_FOLDER);
|
|
56582
|
+
// Track known files
|
|
56583
|
+
this.knownBookFiles.clear();
|
|
56584
|
+
this.knownGlossaryFiles.clear();
|
|
56585
|
+
const bookFiles = await fs_1.vfile.listForFolder(this.root, "book");
|
|
56586
|
+
for (const f of bookFiles) {
|
|
56587
|
+
this.knownBookFiles.add(f.path.absolute);
|
|
56588
|
+
}
|
|
56589
|
+
const glossaryFiles = await fs_1.vfile.listForFolder(this.root, "glossary");
|
|
56590
|
+
for (const f of glossaryFiles) {
|
|
56591
|
+
this.knownGlossaryFiles.add(f.path.absolute);
|
|
56592
|
+
}
|
|
56593
|
+
}
|
|
56594
|
+
classifyChange(filePath, eventType) {
|
|
56595
|
+
const absPath = path_1.default.resolve(this.root, filePath);
|
|
56596
|
+
// Config changes always trigger full rebuild
|
|
56597
|
+
if (filePath === "hyperbook.json" || filePath === "hyperlibrary.json") {
|
|
56598
|
+
return "config";
|
|
56599
|
+
}
|
|
56600
|
+
// Public file changes (check before structural to avoid unnecessary full rebuilds)
|
|
56601
|
+
const publicDir = path_1.default.join(this.root, "public");
|
|
56602
|
+
const bookPublicDir = path_1.default.join(this.root, "book-public");
|
|
56603
|
+
const glossaryPublicDir = path_1.default.join(this.root, "glossary-public");
|
|
56604
|
+
if (absPath.startsWith(publicDir + path_1.default.sep) ||
|
|
56605
|
+
absPath.startsWith(bookPublicDir + path_1.default.sep) ||
|
|
56606
|
+
absPath.startsWith(glossaryPublicDir + path_1.default.sep)) {
|
|
56607
|
+
return "public";
|
|
56608
|
+
}
|
|
56609
|
+
// File add/delete is structural (affects navigation)
|
|
56610
|
+
if (eventType === "add" || eventType === "unlink") {
|
|
56611
|
+
return "structural";
|
|
56612
|
+
}
|
|
56613
|
+
// Content changes to book files
|
|
56614
|
+
const bookDir = path_1.default.join(this.root, "book");
|
|
56615
|
+
if (absPath.startsWith(bookDir + path_1.default.sep) || absPath === bookDir) {
|
|
56616
|
+
const isMarkdown = filePath.endsWith(".md") || filePath.endsWith(".md.hbs") || filePath.endsWith(".md.json") || filePath.endsWith(".md.yml");
|
|
56617
|
+
if (isMarkdown) {
|
|
56618
|
+
return "content-book";
|
|
56619
|
+
}
|
|
56620
|
+
return "public";
|
|
56621
|
+
}
|
|
56622
|
+
// Content changes to glossary files
|
|
56623
|
+
const glossaryDir = path_1.default.join(this.root, "glossary");
|
|
56624
|
+
if (absPath.startsWith(glossaryDir + path_1.default.sep) || absPath === glossaryDir) {
|
|
56625
|
+
return "content-glossary";
|
|
56626
|
+
}
|
|
56627
|
+
// Template/snippet changes or anything else → structural (full rebuild)
|
|
56628
|
+
return "structural";
|
|
56629
|
+
}
|
|
56630
|
+
async handleChange(filePath, eventType) {
|
|
56631
|
+
if (!this.initialized || this.rootProject.type !== "book") {
|
|
56632
|
+
// Fall back to full rebuild for libraries or uninitialized state
|
|
56633
|
+
await (0, build_1.runBuildProject)(this.rootProject, this.rootProject);
|
|
56634
|
+
await this.refreshCaches();
|
|
56635
|
+
return { changedPages: "*" };
|
|
56636
|
+
}
|
|
56637
|
+
const changeType = this.classifyChange(filePath, eventType);
|
|
56638
|
+
switch (changeType) {
|
|
56639
|
+
case "config":
|
|
56640
|
+
case "structural": {
|
|
56641
|
+
console.log(`${chalk_1.default.yellow("[Incremental]")} Structural change detected, full rebuild...`);
|
|
56642
|
+
fs_1.vfile.clean(this.root);
|
|
56643
|
+
await (0, build_1.runBuildProject)(this.rootProject, this.rootProject);
|
|
56644
|
+
await this.refreshCaches();
|
|
56645
|
+
return { changedPages: "*" };
|
|
56646
|
+
}
|
|
56647
|
+
case "content-book": {
|
|
56648
|
+
console.log(`${chalk_1.default.yellow("[Incremental]")} Content change: ${filePath}`);
|
|
56649
|
+
// Clear vfile cache so it re-reads the changed file
|
|
56650
|
+
fs_1.vfile.clean(this.root);
|
|
56651
|
+
// Refresh navigation (fast — reads frontmatter only)
|
|
56652
|
+
this.pagesAndSections = await fs_1.hyperbook.getPagesAndSections(this.root);
|
|
56653
|
+
this.pageList = fs_1.hyperbook.getPageList(this.pagesAndSections.sections, this.pagesAndSections.pages);
|
|
56654
|
+
const bookFiles = await fs_1.vfile.listForFolder(this.root, "book");
|
|
56655
|
+
const absPath = path_1.default.resolve(this.root, filePath);
|
|
56656
|
+
const changedFile = bookFiles.find((f) => f.path.absolute === absPath);
|
|
56657
|
+
if (!changedFile) {
|
|
56658
|
+
console.log(`${chalk_1.default.yellow("[Incremental]")} Could not find changed file, full rebuild...`);
|
|
56659
|
+
await (0, build_1.runBuildProject)(this.rootProject, this.rootProject);
|
|
56660
|
+
await this.refreshCaches();
|
|
56661
|
+
return { changedPages: "*" };
|
|
56662
|
+
}
|
|
56663
|
+
const result = await (0, build_1.buildSingleBookPage)(changedFile, this.baseCtx, this.pageList, this.pagesAndSections, this.rootOut, this.assetsOut, this.hyperbookJson);
|
|
56664
|
+
// Update search documents cache
|
|
56665
|
+
this.searchDocuments.set(changedFile.path.href || changedFile.path.absolute, result.searchDocuments);
|
|
56666
|
+
for (const directive of result.directives) {
|
|
56667
|
+
this.directives.add(directive);
|
|
56668
|
+
}
|
|
56669
|
+
// Copy any new directive assets
|
|
56670
|
+
await this.copyDirectiveAssets(result.directives);
|
|
56671
|
+
const changedHref = changedFile.path.href || "/";
|
|
56672
|
+
console.log(`${chalk_1.default.green("[Incremental]")} Rebuilt: ${changedHref}`);
|
|
56673
|
+
return { changedPages: [changedHref] };
|
|
56674
|
+
}
|
|
56675
|
+
case "content-glossary": {
|
|
56676
|
+
console.log(`${chalk_1.default.yellow("[Incremental]")} Glossary change: ${filePath}`);
|
|
56677
|
+
fs_1.vfile.clean(this.root);
|
|
56678
|
+
this.pagesAndSections = await fs_1.hyperbook.getPagesAndSections(this.root);
|
|
56679
|
+
this.pageList = fs_1.hyperbook.getPageList(this.pagesAndSections.sections, this.pagesAndSections.pages);
|
|
56680
|
+
const glossaryFiles = await fs_1.vfile.listForFolder(this.root, "glossary");
|
|
56681
|
+
const absPath = path_1.default.resolve(this.root, filePath);
|
|
56682
|
+
const changedFile = glossaryFiles.find((f) => f.path.absolute === absPath);
|
|
56683
|
+
if (!changedFile) {
|
|
56684
|
+
console.log(`${chalk_1.default.yellow("[Incremental]")} Could not find changed glossary file, full rebuild...`);
|
|
56685
|
+
await (0, build_1.runBuildProject)(this.rootProject, this.rootProject);
|
|
56686
|
+
await this.refreshCaches();
|
|
56687
|
+
return { changedPages: "*" };
|
|
56688
|
+
}
|
|
56689
|
+
const result = await (0, build_1.buildSingleGlossaryPage)(changedFile, this.baseCtx, this.pageList, this.pagesAndSections, this.rootOut, this.assetsOut, this.hyperbookJson);
|
|
56690
|
+
this.searchDocuments.set(changedFile.path.href || changedFile.path.absolute, result.searchDocuments);
|
|
56691
|
+
for (const directive of result.directives) {
|
|
56692
|
+
this.directives.add(directive);
|
|
56693
|
+
}
|
|
56694
|
+
await this.copyDirectiveAssets(result.directives);
|
|
56695
|
+
const changedHref = changedFile.path.href || "/glossary";
|
|
56696
|
+
console.log(`${chalk_1.default.green("[Incremental]")} Rebuilt: ${changedHref}`);
|
|
56697
|
+
return { changedPages: [changedHref] };
|
|
56698
|
+
}
|
|
56699
|
+
case "public": {
|
|
56700
|
+
console.log(`${chalk_1.default.yellow("[Incremental]")} Public file change: ${filePath}`);
|
|
56701
|
+
const absPath = path_1.default.resolve(this.root, filePath);
|
|
56702
|
+
// Determine which public folder it belongs to and copy it
|
|
56703
|
+
const publicDirs = [
|
|
56704
|
+
{ dir: path_1.default.join(this.root, "public"), folder: "public" },
|
|
56705
|
+
{ dir: path_1.default.join(this.root, "book-public"), folder: "book-public" },
|
|
56706
|
+
{ dir: path_1.default.join(this.root, "glossary-public"), folder: "glossary-public" },
|
|
56707
|
+
];
|
|
56708
|
+
for (const { dir } of publicDirs) {
|
|
56709
|
+
if (absPath.startsWith(dir + path_1.default.sep)) {
|
|
56710
|
+
const relativePath = path_1.default.relative(dir, absPath);
|
|
56711
|
+
const destPath = path_1.default.join(this.rootOut, relativePath);
|
|
56712
|
+
const destDir = path_1.default.dirname(destPath);
|
|
56713
|
+
try {
|
|
56714
|
+
await promises_1.default.mkdir(destDir, { recursive: true });
|
|
56715
|
+
await (0, promises_2.cp)(absPath, destPath);
|
|
56716
|
+
console.log(`${chalk_1.default.green("[Incremental]")} Copied: ${relativePath}`);
|
|
56717
|
+
}
|
|
56718
|
+
catch (e) {
|
|
56719
|
+
console.log(`${chalk_1.default.red("[Incremental]")} Failed to copy: ${relativePath}`);
|
|
56720
|
+
}
|
|
56721
|
+
break;
|
|
56722
|
+
}
|
|
56723
|
+
}
|
|
56724
|
+
// Public file changes affect all pages (images could be on any page)
|
|
56725
|
+
return { changedPages: "*" };
|
|
56726
|
+
}
|
|
56727
|
+
}
|
|
56728
|
+
}
|
|
56729
|
+
async copyDirectiveAssets(newDirectives) {
|
|
56730
|
+
const assetsPath = path_1.default.join(__dirname, "assets");
|
|
56731
|
+
for (const directive of newDirectives) {
|
|
56732
|
+
const assetsDirectivePath = path_1.default.join(assetsPath, `directive-${directive}`);
|
|
56733
|
+
const assetsDirectiveOut = path_1.default.join(this.assetsOut, `directive-${directive}`);
|
|
56734
|
+
try {
|
|
56735
|
+
await promises_1.default.access(assetsDirectivePath);
|
|
56736
|
+
await promises_1.default.mkdir(assetsDirectiveOut, { recursive: true });
|
|
56737
|
+
await (0, promises_2.cp)(assetsDirectivePath, assetsDirectiveOut, { recursive: true });
|
|
56738
|
+
}
|
|
56739
|
+
catch {
|
|
56740
|
+
// Directive has no assets or already copied
|
|
56741
|
+
}
|
|
56742
|
+
}
|
|
56743
|
+
}
|
|
56744
|
+
}
|
|
56745
|
+
exports.IncrementalBuilder = IncrementalBuilder;
|
|
56746
|
+
|
|
56747
|
+
|
|
56401
56748
|
/***/ }),
|
|
56402
56749
|
|
|
56403
56750
|
/***/ 35773:
|
|
@@ -200968,18 +201315,14 @@ var remarkDirectiveBlockflowEditor_default = (ctx) => () => {
|
|
|
200968
201315
|
const config2 = {};
|
|
200969
201316
|
if (title) config2.title = title;
|
|
200970
201317
|
if (src) config2.sb3 = ctx.makeUrl(src, "public", ctx.navigation.current || void 0);
|
|
200971
|
-
const ui = {};
|
|
200972
201318
|
if (allowExtensions !== void 0) {
|
|
200973
|
-
ui
|
|
201319
|
+
config2.ui = { allowExtensions: allowExtensions !== "false" };
|
|
200974
201320
|
}
|
|
200975
201321
|
if (showCostumesTab !== void 0) {
|
|
200976
|
-
|
|
201322
|
+
config2.costumes = { enabled: showCostumesTab !== "false" };
|
|
200977
201323
|
}
|
|
200978
201324
|
if (showSoundsTab !== void 0) {
|
|
200979
|
-
|
|
200980
|
-
}
|
|
200981
|
-
if (Object.keys(ui).length > 0) {
|
|
200982
|
-
config2.ui = ui;
|
|
201325
|
+
config2.sounds = { enabled: showSoundsTab !== "false" };
|
|
200983
201326
|
}
|
|
200984
201327
|
if (categories || Object.keys(rest).some((k) => k.startsWith("blocks-"))) {
|
|
200985
201328
|
config2.toolbox = {};
|
|
@@ -200999,9 +201342,11 @@ var remarkDirectiveBlockflowEditor_default = (ctx) => () => {
|
|
|
200999
201342
|
}
|
|
201000
201343
|
if (steps.length > 0) config2.steps = steps;
|
|
201001
201344
|
const configJson = JSON.stringify(config2);
|
|
201002
|
-
|
|
201345
|
+
const compressed = deflate_1(configJson);
|
|
201346
|
+
const encoded = "pako:" + Buffer.from(compressed).toString("base64");
|
|
201347
|
+
projectParam = encodeURIComponent(encoded);
|
|
201003
201348
|
}
|
|
201004
|
-
const iframeSrc = `https://blockflow.openpatch.org?project=${projectParam}`;
|
|
201349
|
+
const iframeSrc = `https://blockflow.openpatch.org/editor?project=${projectParam}`;
|
|
201005
201350
|
data.hName = "div";
|
|
201006
201351
|
data.hProperties = {
|
|
201007
201352
|
class: "directive-blockflow-editor",
|
|
@@ -201186,7 +201531,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"application/1d-interleaved-parityfec
|
|
|
201186
201531
|
/***/ ((module) => {
|
|
201187
201532
|
|
|
201188
201533
|
"use strict";
|
|
201189
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.
|
|
201534
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.88.1","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=18"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --no-cache --no-source-map-register --external favicons --external sharp && node postbuild.mjs"},"dependencies":{"favicons":"^7.2.0"},"devDependencies":{"create-hyperbook":"workspace:*","@hyperbook/fs":"workspace:*","@hyperbook/markdown":"workspace:*","@hyperbook/types":"workspace:*","@pnpm/exportable-manifest":"1000.0.6","@types/archiver":"6.0.3","@types/async-retry":"1.4.9","@types/cross-spawn":"6.0.6","@types/lunr":"^2.3.7","@types/prompts":"2.4.9","@types/tar":"6.1.13","@types/ws":"^8.5.14","@vercel/ncc":"0.38.3","archiver":"7.0.1","async-retry":"1.3.3","chalk":"5.4.1","chokidar":"4.0.3","commander":"12.1.0","cpy":"11.1.0","cross-spawn":"7.0.6","domutils":"^3.2.2","extract-zip":"^2.0.1","got":"12.6.0","htmlparser2":"^10.0.0","lunr":"^2.3.9","lunr-languages":"^1.14.0","mime":"^4.0.6","prompts":"2.4.2","rimraf":"6.0.1","tar":"7.4.3","update-check":"1.5.4","ws":"^8.18.0"}}');
|
|
201190
201535
|
|
|
201191
201536
|
/***/ })
|
|
201192
201537
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperbook",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.88.1",
|
|
4
4
|
"author": "Mike Barkmin",
|
|
5
5
|
"homepage": "https://github.com/openpatch/hyperbook#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"ws": "^8.18.0",
|
|
59
59
|
"create-hyperbook": "0.3.5",
|
|
60
60
|
"@hyperbook/fs": "0.25.0",
|
|
61
|
-
"@hyperbook/markdown": "0.59.
|
|
61
|
+
"@hyperbook/markdown": "0.59.3",
|
|
62
62
|
"@hyperbook/types": "0.22.1"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|