grimoire3d 0.1.0-dev.b00149d → 0.1.0-dev.fc14cb4

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 (103) hide show
  1. package/cli/cli.js +5 -3
  2. package/cli/content.js +29 -1
  3. package/cli/head-file.js +133 -0
  4. package/cli/markdown.js +5 -0
  5. package/cli/static-pages.js +19 -5
  6. package/dist/site/assets/BookReader-Dn0DGCvp.js +2 -0
  7. package/dist/site/assets/{BookScene-DiAiTP9V.js → BookScene-Gz0X4LHo.js} +1 -1
  8. package/dist/site/assets/MermaidDiagram-ehlJnVnE.js +44 -0
  9. package/dist/site/assets/{PageMarkdown-ENP_TuEU.js → PageMarkdown-CuLmPCnh.js} +3 -3
  10. package/dist/site/assets/{abnfDiagram-S7VZAUFO-CPn8kyCz.js → abnfDiagram-S7VZAUFO-BszrGB5S.js} +1 -1
  11. package/dist/site/assets/{architecture-WOLXFQ4H-Czsdswwl.js → architecture-WOLXFQ4H-ChbXG9v4.js} +1 -1
  12. package/dist/site/assets/{architectureDiagram-YGSQEFNW-C_9i0B1c.js → architectureDiagram-YGSQEFNW-vLa-6bvw.js} +1 -1
  13. package/dist/site/assets/{blockDiagram-APKKGZFW-B4TEuCLK.js → blockDiagram-APKKGZFW-X69okCoY.js} +1 -1
  14. package/dist/site/assets/{c4Diagram-KJ2TOQU5-CH_Uv_Fz.js → c4Diagram-KJ2TOQU5-DMLw6sUR.js} +1 -1
  15. package/dist/site/assets/{chunk-6MUBBAK2-C4kh7Z3T.js → chunk-6MUBBAK2-bH5libpZ.js} +1 -1
  16. package/dist/site/assets/{chunk-AXFCVDMN-B_taAhLl.js → chunk-AXFCVDMN-DYtb5ThM.js} +1 -1
  17. package/dist/site/assets/{chunk-BG4553SI-Cn6LMB1q.js → chunk-BG4553SI-D_js9Q2w.js} +1 -1
  18. package/dist/site/assets/{chunk-DQASFODM-BsDpj_0k.js → chunk-DQASFODM-CYrB0eGC.js} +1 -1
  19. package/dist/site/assets/{chunk-HFQBQIA3-DLIuoeT3.js → chunk-HFQBQIA3-SkoeoiEw.js} +1 -1
  20. package/dist/site/assets/{chunk-KQLB2F66-AFzkv6d3.js → chunk-KQLB2F66-Cq9Rx94L.js} +1 -1
  21. package/dist/site/assets/{chunk-KS47KZWR-DjywFwRy.js → chunk-KS47KZWR-Bi7608qL.js} +1 -1
  22. package/dist/site/assets/{chunk-LEVMRMFU-BrDnuOnu.js → chunk-LEVMRMFU-DXRWL7g5.js} +1 -1
  23. package/dist/site/assets/{chunk-M57EVK23-BikTvdAr.js → chunk-M57EVK23-DSw_NCBZ.js} +1 -1
  24. package/dist/site/assets/{chunk-OY52VR5R-Nk28J3qR.js → chunk-OY52VR5R-C6vsrhIx.js} +1 -1
  25. package/dist/site/assets/{chunk-QB3YPZ4I-OgBmaa_y.js → chunk-QB3YPZ4I-CzM4qYBx.js} +1 -1
  26. package/dist/site/assets/{chunk-R3KSYZAL-CdwBI4dZ.js → chunk-R3KSYZAL-DeK_CSTY.js} +1 -1
  27. package/dist/site/assets/{chunk-STOXU5M4-BZAF-H6I.js → chunk-STOXU5M4-D9slbdoa.js} +1 -1
  28. package/dist/site/assets/{chunk-TU62E6Q5-C6WlEf5k.js → chunk-TU62E6Q5-OvPxW4-R.js} +1 -1
  29. package/dist/site/assets/{chunk-X4PVCEUW-BYepnSMY.js → chunk-X4PVCEUW-DII_FaZO.js} +1 -1
  30. package/dist/site/assets/{chunk-XXDRQBXY-DN9ONrwM.js → chunk-XXDRQBXY-BGkuj3Lj.js} +1 -1
  31. package/dist/site/assets/{classDiagram-v2-L25IHNXF-ChtKa3P5.js → classDiagram-v2-L25IHNXF-KCMYaVKA.js} +1 -1
  32. package/dist/site/assets/{cose-bilkent-JH36ORCC-kNFKiV_g.js → cose-bilkent-JH36ORCC-Da7M24_u.js} +1 -1
  33. package/dist/site/assets/cynefin-EF2NZ3EQ-CWPadAJs.js +1 -0
  34. package/dist/site/assets/{cynefinDiagram-L36ESFBY-sq_xQVi7.js → cynefinDiagram-L36ESFBY-Bq0lDSxM.js} +1 -1
  35. package/dist/site/assets/{d3-selection-DIUqvUVB.js → d3-selection-4tsjLZDr.js} +1 -1
  36. package/dist/site/assets/{dagre-SPEB5RXH-DqoO0sGc.js → dagre-SPEB5RXH-DGll8e_9.js} +1 -1
  37. package/dist/site/assets/{diagram-3B7GL73J-M26Lh06i.js → diagram-3B7GL73J-PpRUbkDD.js} +1 -1
  38. package/dist/site/assets/{diagram-DNEMPZML-ZZQRAEJq.js → diagram-DNEMPZML-C8tYs8OC.js} +1 -1
  39. package/dist/site/assets/{diagram-L3MUGCDN-CjsMyH3f.js → diagram-L3MUGCDN-DeHxMM1S.js} +1 -1
  40. package/dist/site/assets/{diagram-LA4NIPWU-B1tD-62P.js → diagram-LA4NIPWU-CLpVj3V6.js} +1 -1
  41. package/dist/site/assets/{diagram-MHCOC4E2-B0jKQ9HQ.js → diagram-MHCOC4E2-i9jVrp5_.js} +1 -1
  42. package/dist/site/assets/{diagram-XPFHEONP-BelYHEVT.js → diagram-XPFHEONP-fpb6qVSb.js} +1 -1
  43. package/dist/site/assets/{dist-ppXrr7du.js → dist-TCI8ugrE.js} +1 -1
  44. package/dist/site/assets/{ebnfDiagram-UZSYDL2S-BlM2_kcX.js → ebnfDiagram-UZSYDL2S-DStEfLnW.js} +1 -1
  45. package/dist/site/assets/{elk-XV6XMXQE-DGFBMQyB.js → elk-XV6XMXQE-CLUnDHF-.js} +1 -1
  46. package/dist/site/assets/{erDiagram-EYBAPDEH-BYeh4LuC.js → erDiagram-EYBAPDEH-Dpho2UHH.js} +1 -1
  47. package/dist/site/assets/{eventmodeling-K75KTNOO-CJHo0aIb.js → eventmodeling-K75KTNOO-Dp9IuSNv.js} +1 -1
  48. package/dist/site/assets/flowDiagram-MALGAFMO-4QFzEbff.js +1 -0
  49. package/dist/site/assets/{ganttDiagram-23REXITY-BlApGIuJ.js → ganttDiagram-23REXITY-DoXyHdP6.js} +1 -1
  50. package/dist/site/assets/gitGraph-VSP46ZUC-CiqM-4-1.js +1 -0
  51. package/dist/site/assets/{gitGraphDiagram-STJD7YCW-BJXE5oWq.js → gitGraphDiagram-STJD7YCW-3XayJkqG.js} +1 -1
  52. package/dist/site/assets/index-54wd-TKD.css +1 -0
  53. package/dist/site/assets/index-D2pcSqWr.js +2 -0
  54. package/dist/site/assets/info-OHQRW6UA-Cx3RbBFK.js +1 -0
  55. package/dist/site/assets/{infoDiagram-KBXO4MBG-DseLOSIt.js → infoDiagram-KBXO4MBG-BBr6nNzC.js} +1 -1
  56. package/dist/site/assets/{ishikawaDiagram-M35NCXHK-D3nXJVhq.js → ishikawaDiagram-M35NCXHK-77u0YVCD.js} +1 -1
  57. package/dist/site/assets/{journeyDiagram-OPLOXDXO-Dwmf_2yx.js → journeyDiagram-OPLOXDXO-YIGAZhBX.js} +1 -1
  58. package/dist/site/assets/{kanban-definition-BZKZHSQY-D8hRo5NB.js → kanban-definition-BZKZHSQY-NVyhaHVj.js} +1 -1
  59. package/dist/site/assets/{mermaid-parser.core-CRzqu-zz.js → mermaid-parser.core-CEkapwez.js} +3 -3
  60. package/dist/site/assets/{mindmap-definition-I2QAS2VK-C_KsVBJE.js → mindmap-definition-I2QAS2VK-n1USX9wN.js} +1 -1
  61. package/dist/site/assets/packet-JDAUHWVQ-DLeV0H7E.js +1 -0
  62. package/dist/site/assets/{pegDiagram-FD4XPPHP-CsAJzLE2.js → pegDiagram-FD4XPPHP-Mu0uBBkA.js} +1 -1
  63. package/dist/site/assets/pie-XZMESJXO-HYzgEYMd.js +1 -0
  64. package/dist/site/assets/{pieDiagram-J4AKIIQI-C0Z-TuM1.js → pieDiagram-J4AKIIQI-CLk3ciJf.js} +1 -1
  65. package/dist/site/assets/{quadrantDiagram-XTYBLID2-BfwNOGbp.js → quadrantDiagram-XTYBLID2-DBW4dtli.js} +1 -1
  66. package/dist/site/assets/radar-ABXABTNO-qQvzFpFl.js +1 -0
  67. package/dist/site/assets/railroad-I3PHUGI6-v8Ca-DV3.js +1 -0
  68. package/dist/site/assets/{railroad-abnf-LNEFI6M7-BsS9Vk34.js → railroad-abnf-LNEFI6M7-Bt182hG_.js} +1 -1
  69. package/dist/site/assets/{railroad-ebnf-DWYD2UWJ-Cx8TyVDx.js → railroad-ebnf-DWYD2UWJ-D9qkXuEi.js} +1 -1
  70. package/dist/site/assets/{railroad-peg-JR7BVNR7-C2s9CJ5A.js → railroad-peg-JR7BVNR7-DIMidVd9.js} +1 -1
  71. package/dist/site/assets/{railroadDiagram-MRQ6NCDL-nXlyo8yi.js → railroadDiagram-MRQ6NCDL-B4Uc4ppc.js} +1 -1
  72. package/dist/site/assets/{requirementDiagram-Y7LWUY3S-C_jfLPMO.js → requirementDiagram-Y7LWUY3S-CRsL_qqm.js} +1 -1
  73. package/dist/site/assets/{sankeyDiagram-WGJFYUXA-DiLclJAZ.js → sankeyDiagram-WGJFYUXA-BL0PIBfg.js} +1 -1
  74. package/dist/site/assets/{sequenceDiagram-5NDRBG5M-B9sM-5ZJ.js → sequenceDiagram-5NDRBG5M-BgKbHFXZ.js} +1 -1
  75. package/dist/site/assets/{stateDiagram-v2-FJ4FJNEA-Dkis5g_v.js → stateDiagram-v2-FJ4FJNEA-B9CZPOzW.js} +1 -1
  76. package/dist/site/assets/{swimlanes-UMQ2AFYF-DB6kjOv7.js → swimlanes-UMQ2AFYF-DWUh1d0H.js} +1 -1
  77. package/dist/site/assets/swimlanesDiagram-OMPLPG4O-DE8mEnjN.js +8 -0
  78. package/dist/site/assets/{timeline-definition-SEUHKTQE-2CMebGt0.js → timeline-definition-SEUHKTQE-Dv_UF9nq.js} +1 -1
  79. package/dist/site/assets/treeView-D4JQ5SDB-B0oEySz8.js +1 -0
  80. package/dist/site/assets/treemap-SAJKECNS-UVEDd9TK.js +1 -0
  81. package/dist/site/assets/{usecaseDiagram-AFA6YXN4-BACx6ppv.js → usecaseDiagram-AFA6YXN4-BWphalJw.js} +1 -1
  82. package/dist/site/assets/{vennDiagram-NNMJR3RB-B8NLdumI.js → vennDiagram-NNMJR3RB-DtWXMPMJ.js} +1 -1
  83. package/dist/site/assets/wardley-7MLQ67FV-os2V8rXm.js +1 -0
  84. package/dist/site/assets/{wardleyDiagram-S7YFUSEH-WKBfzjEM.js → wardleyDiagram-S7YFUSEH-DsO7dnGZ.js} +1 -1
  85. package/dist/site/assets/{xychartDiagram-GGNKY7IX-BUciDj2U.js → xychartDiagram-GGNKY7IX-Bbc9nXAc.js} +1 -1
  86. package/dist/site/index.html +2 -2
  87. package/package.json +2 -1
  88. package/dist/site/assets/BookReader-DudAXdp3.js +0 -2
  89. package/dist/site/assets/MermaidDiagram-2mwgnVgM.js +0 -44
  90. package/dist/site/assets/cynefin-EF2NZ3EQ-lzZSPZ0f.js +0 -1
  91. package/dist/site/assets/flowDiagram-MALGAFMO-4xnU_Dv7.js +0 -1
  92. package/dist/site/assets/gitGraph-VSP46ZUC-Dwcg1pSB.js +0 -1
  93. package/dist/site/assets/index-D4HJC4TW.js +0 -2
  94. package/dist/site/assets/index-fT8cj2JB.css +0 -1
  95. package/dist/site/assets/info-OHQRW6UA-BEW1vxOL.js +0 -1
  96. package/dist/site/assets/packet-JDAUHWVQ-vLUg6kma.js +0 -1
  97. package/dist/site/assets/pie-XZMESJXO-C5OiZ5I_.js +0 -1
  98. package/dist/site/assets/radar-ABXABTNO-DlOAhNu8.js +0 -1
  99. package/dist/site/assets/railroad-I3PHUGI6-BUpxKd8T.js +0 -1
  100. package/dist/site/assets/swimlanesDiagram-OMPLPG4O-IMFdS7Zf.js +0 -8
  101. package/dist/site/assets/treeView-D4JQ5SDB-BZ52mw7_.js +0 -1
  102. package/dist/site/assets/treemap-SAJKECNS-C-pobFuU.js +0 -1
  103. package/dist/site/assets/wardley-7MLQ67FV-BWJ-dzdI.js +0 -1
package/cli/cli.js CHANGED
@@ -28,6 +28,7 @@ import { fileURLToPath } from "node:url";
28
28
  import { parseArgs } from "node:util";
29
29
  import { contentType, lookup } from "mime-types";
30
30
  import { readLibrary, readSettings } from "./content.js";
31
+ import { readHeadFile } from "./head-file.js";
31
32
  import { previewHead, writeStaticPages } from "./static-pages.js";
32
33
 
33
34
  const template = fileURLToPath(new URL("../dist/site/", import.meta.url));
@@ -80,7 +81,7 @@ function serializedLibrary(library) {
80
81
  ]);
81
82
  }
82
83
 
83
- async function writeStaticSite(cwd, outDir, library) {
84
+ async function writeStaticSite(cwd, outDir, library, headMarkup) {
84
85
  const output = resolve(cwd, outDir);
85
86
  const { locale } = library.manifest;
86
87
  const exists = await existingOutput(output, locale);
@@ -102,7 +103,7 @@ async function writeStaticSite(cwd, outDir, library) {
102
103
  await mkdir(dirname(path), { recursive: true });
103
104
  await copyFile(source, path);
104
105
  }
105
- await writeStaticPages(template, staging, library);
106
+ await writeStaticPages(template, staging, library, headMarkup);
106
107
  await writeFile(join(staging, marker), json(await listFiles(staging)));
107
108
  if (exists) await rename(output, backup);
108
109
  try {
@@ -325,7 +326,8 @@ async function main() {
325
326
  const output = await writeStaticSite(
326
327
  cwd,
327
328
  values["out-dir"] ?? settings.outDir ?? "dist",
328
- library
329
+ library,
330
+ await readHeadFile(cwd, settings.headFile)
329
331
  );
330
332
  const label = settings.locale === "ja" ? "書き出し先" : "Built to";
331
333
  console.log(`${label}: ${basename(output)}/ (${output})`);
package/cli/content.js CHANGED
@@ -59,6 +59,24 @@ function comparePages(a, b) {
59
59
  );
60
60
  }
61
61
 
62
+ function readPublicationDate(index) {
63
+ const raw = index?.metadata.date;
64
+ const date = typeof raw === "string" ? raw.trim() : raw;
65
+ if (date == null || date === "") return undefined;
66
+
67
+ if (typeof date === "string" && /^\d{4}-\d{2}-\d{2}$/.test(date)) {
68
+ const parsed = new Date(date);
69
+ if (
70
+ Number.isFinite(parsed.getTime()) &&
71
+ parsed.toISOString().slice(0, 10) === date
72
+ )
73
+ return date;
74
+ }
75
+ throw new Error(
76
+ `${index.path}: date must be a valid publication date in YYYY-MM-DD format.`
77
+ );
78
+ }
79
+
62
80
  function describeBook(pages, folder, fallback) {
63
81
  const index = pages.find(
64
82
  (page) =>
@@ -81,6 +99,8 @@ function describeBook(pages, folder, fallback) {
81
99
  id,
82
100
  title,
83
101
  cover,
102
+ category: index?.metadata.category,
103
+ date: readPublicationDate(index),
84
104
  chapters: pages.sort(comparePages).map((page) => {
85
105
  const group = posix.dirname(page.path);
86
106
  const inBook = folder ? page.path.slice(folder.length + 1) : page.path;
@@ -144,6 +164,7 @@ export async function readSettings(cwd) {
144
164
  author,
145
165
  magicMode,
146
166
  footer,
167
+ headFile,
147
168
  } = settings;
148
169
  if (
149
170
  typeof settings !== "object" ||
@@ -182,6 +203,7 @@ export async function readSettings(cwd) {
182
203
  author,
183
204
  magicMode,
184
205
  footer: readFooter(footer),
206
+ headFile,
185
207
  siteUrl: siteUrl && normalizeSiteUrl(siteUrl),
186
208
  };
187
209
  }
@@ -383,7 +405,13 @@ export async function readLibrary(cwd, settings) {
383
405
  author: settings.author,
384
406
  magicMode: settings.magicMode,
385
407
  footer: settings.footer,
386
- books: books.map(({ id, title, cover }) => ({ id, title, cover })),
408
+ books: books.map(({ id, title, cover, category, date }) => ({
409
+ id,
410
+ title,
411
+ cover,
412
+ category,
413
+ date,
414
+ })),
387
415
  },
388
416
  books: publishedBooks,
389
417
  documents,
@@ -0,0 +1,133 @@
1
+ import { readFile, realpath, stat } from "node:fs/promises";
2
+ import { isAbsolute, relative, resolve, sep } from "node:path";
3
+ import { parse } from "parse5";
4
+
5
+ const managedMeta = new Set([
6
+ "author",
7
+ "description",
8
+ "grimoire-preview",
9
+ "grimoire-static",
10
+ "og:description",
11
+ "og:image",
12
+ "og:locale",
13
+ "og:site_name",
14
+ "og:title",
15
+ "og:type",
16
+ "og:url",
17
+ "twitter:card",
18
+ "viewport",
19
+ ]);
20
+ const headElements = new Set(["link", "meta", "script", "style"]);
21
+ const headStart = "<!doctype html><html><head>\n";
22
+
23
+ function managedTag(node) {
24
+ const attrs = Object.fromEntries(
25
+ node.attrs.map(({ name, value }) => [name, value])
26
+ );
27
+ if (node.tagName === "title" || node.tagName === "base")
28
+ return `<${node.tagName}>`;
29
+ if (node.tagName === "link") {
30
+ const rel = attrs.rel?.toLowerCase().trim().split(/\s+/) ?? [];
31
+ if (rel.includes("canonical")) return '<link rel="canonical">';
32
+ if (rel.includes("icon")) return '<link rel="icon">';
33
+ }
34
+ if (node.tagName === "meta") {
35
+ if ("charset" in attrs) return "<meta charset>";
36
+ if (attrs["http-equiv"]?.trim().toLowerCase() === "content-type")
37
+ return '<meta http-equiv="content-type">';
38
+ for (const attr of ["name", "property"]) {
39
+ const key = attrs[attr]?.trim().toLowerCase();
40
+ if (managedMeta.has(key)) return `<meta ${attr}="${key}">`;
41
+ }
42
+ }
43
+ }
44
+
45
+ function checkHeadFragment(markup, label) {
46
+ const fileError = (line, message) =>
47
+ new Error(`${label}:${Math.max(1, line - 1)}: ${message}`);
48
+ const document = parse(`${headStart}${markup}</head><body></body></html>`, {
49
+ sourceCodeLocationInfo: true,
50
+ onParseError(error) {
51
+ throw fileError(error.startLine, `Invalid HTML (${error.code}).`);
52
+ },
53
+ });
54
+ const html = document.childNodes.find(({ nodeName }) => nodeName === "html");
55
+ const head = html.childNodes.find(({ nodeName }) => nodeName === "head");
56
+ if (
57
+ head.sourceCodeLocation?.endTag?.startOffset !==
58
+ headStart.length + markup.length
59
+ ) {
60
+ throw new Error(
61
+ `${label}: Expected an HTML head fragment. Use metadata, links, scripts, or styles inside the file.`
62
+ );
63
+ }
64
+
65
+ for (const node of head.childNodes) {
66
+ if (
67
+ node.nodeName === "#comment" ||
68
+ (node.nodeName === "#text" && !node.value.trim())
69
+ )
70
+ continue;
71
+
72
+ const { startLine } = node.sourceCodeLocation;
73
+ const conflict = node.attrs && managedTag(node);
74
+ if (conflict) {
75
+ throw fileError(
76
+ startLine,
77
+ `${conflict} is managed by Grimoire3D. Use the existing site and chapter settings.`
78
+ );
79
+ }
80
+ if (!headElements.has(node.tagName)) {
81
+ throw fileError(
82
+ startLine,
83
+ "Expected a meta, link, script, or style tag."
84
+ );
85
+ }
86
+ }
87
+ }
88
+
89
+ function insideProject(project, path) {
90
+ const location = relative(project, path);
91
+ return !isAbsolute(location) && location.split(sep)[0] !== "..";
92
+ }
93
+
94
+ export async function readHeadFile(cwd, setting) {
95
+ if (setting === undefined) return "";
96
+ if (
97
+ typeof setting !== "string" ||
98
+ !setting.trim() ||
99
+ isAbsolute(setting) ||
100
+ /^[a-z][a-z\d+.-]*:/i.test(setting)
101
+ ) {
102
+ throw new Error(
103
+ "grimoire.yml: headFile must be a relative path within the project."
104
+ );
105
+ }
106
+
107
+ const label = `grimoire.yml: headFile ${JSON.stringify(setting)}`;
108
+ const project = await realpath(cwd);
109
+ const requested = resolve(project, setting);
110
+ const outside = () => new Error(`${label}: Use a path within the project.`);
111
+ if (!insideProject(project, requested)) throw outside();
112
+
113
+ const unreadable = (cause) =>
114
+ new Error(
115
+ `${label}: Cannot read the HTML file. Check that it exists and is readable.`,
116
+ { cause }
117
+ );
118
+ const path = await realpath(requested).catch((error) => {
119
+ throw unreadable(error);
120
+ });
121
+ if (!insideProject(project, path)) throw outside();
122
+
123
+ let markup;
124
+ try {
125
+ if (!(await stat(path)).isFile()) throw new Error("Expected a file.");
126
+ markup = (await readFile(path, "utf8")).replace(/^\uFEFF/, "");
127
+ } catch (error) {
128
+ throw unreadable(error);
129
+ }
130
+
131
+ checkHeadFragment(markup, label);
132
+ return markup;
133
+ }
package/cli/markdown.js CHANGED
@@ -127,6 +127,11 @@ export function readMarkdown(source) {
127
127
  typeof metadata.socialImage === "string"
128
128
  ? metadata.socialImage.trim()
129
129
  : undefined,
130
+ category:
131
+ typeof metadata.category === "string"
132
+ ? metadata.category.trim() || undefined
133
+ : undefined,
134
+ date: metadata.date,
130
135
  },
131
136
  excerpt: [...excerpt].slice(0, 170).join(""),
132
137
  markdown,
@@ -185,8 +185,8 @@ function initialBookMarkup(book, chapter, locale) {
185
185
  };
186
186
  }
187
187
 
188
- function replaceShell(template, site, head, prefix, body, reader) {
189
- return template
188
+ function replaceShell(template, site, head, prefix, body, reader, headMarkup) {
189
+ const html = template
190
190
  .replace('<html lang="en">', `<html lang="${site.locale}">`)
191
191
  .replace(
192
192
  /<script type="module"[^>]*src="([^"]+)"[^>]*><\/script>/,
@@ -205,6 +205,12 @@ function replaceShell(template, site, head, prefix, body, reader) {
205
205
  () => `<title>${escapeHtml(head.title)}</title>\n${head.metadata}`
206
206
  )
207
207
  .replace('<div id="root"></div>', () => `<div id="root">${body}</div>`);
208
+ return headMarkup
209
+ ? html.replace(
210
+ /<head>(\s*<meta charset="[^"]+"\s*\/?>)?/i,
211
+ (start) => `${start}\n${headMarkup}\n`
212
+ )
213
+ : html;
208
214
  }
209
215
 
210
216
  function startAfterArtwork(entry, reader) {
@@ -256,6 +262,8 @@ function assetNamed(assets, prefix, name, ext = ".avif") {
256
262
 
257
263
  function staticShelf(site, prefix, assets, label) {
258
264
  const books = site.books.slice(0, 12);
265
+ // Catalog controls move the shelf when the interactive library starts.
266
+ const reuseShelfArt = !site.books.some((book) => book.category || book.date);
259
267
  const button = site.locale === "ja" ? "目録" : "Index";
260
268
  const titleStyle = (finish) =>
261
269
  finish.lettering
@@ -281,7 +289,7 @@ function staticShelf(site, prefix, assets, label) {
281
289
  .join("");
282
290
  return `<main class="library"><header class="library-brand brand">${escapeHtml(site.title)}</header>
283
291
  <div class="library-heading${site.books.length > 6 ? " library-heading-sticky" : ""}"><h1>${label}</h1></div>
284
- <div class="shelf resting-shelf${site.books.length > 6 ? " shelf-many" : ""}"${books.length >= 3 && books.length <= 4 ? ' data-mobile-rows="2"' : ""}><div class="shelf-art" data-initial-shelf aria-hidden="true"></div><div class="shelf-grid">${covers}</div></div>
292
+ <div class="shelf resting-shelf${site.books.length > 6 ? " shelf-many" : ""}"${books.length >= 3 && books.length <= 4 ? ' data-mobile-rows="2"' : ""}><div class="shelf-art"${reuseShelfArt ? " data-initial-shelf" : ""} aria-hidden="true"></div><div class="shelf-grid">${covers}</div></div>
285
293
  ${site.books.length > 12 ? `<details><summary>${button}</summary>${linkList(site.books.map((book) => ({ title: book.title, href: prefix + readerPath(book.id) })))}</details>` : ""}
286
294
  ${renderToStaticMarkup(element(LibraryFooter, { publisher: site.footer }))}
287
295
  </main>`;
@@ -336,7 +344,12 @@ function staticChapter({ site, book, page, prefix, assets, libraryLabel }) {
336
344
  </main>`;
337
345
  }
338
346
 
339
- export async function writeStaticPages(templateDir, destination, library) {
347
+ export async function writeStaticPages(
348
+ templateDir,
349
+ destination,
350
+ library,
351
+ headMarkup = ""
352
+ ) {
340
353
  const template = await readFile(join(templateDir, "index.html"), "utf8");
341
354
  const site = library.manifest;
342
355
  const books = new Map(library.books.map((book) => [book.id, book]));
@@ -417,7 +430,8 @@ export async function writeStaticPages(templateDir, destination, library) {
417
430
  head,
418
431
  prefix,
419
432
  body(prefix),
420
- book ? reader : undefined
433
+ book ? reader : undefined,
434
+ headMarkup
421
435
  )
422
436
  );
423
437
  if (head.canonical) urls.push(head.canonical);
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BookScene-Gz0X4LHo.js","./jsxRuntime-WpZ1bTm4.js","./three-core-B1q6MRTI.js","./index-D2pcSqWr.js","./index-54wd-TKD.css","./PageMarkdown-CuLmPCnh.js"])))=>i.map(i=>d[i]);
2
+ import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,t as f,u as p}from"./index-D2pcSqWr.js";import{a as m,d as h,f as g,g as _,h as v,l as y,p as b,r as ee,t as x,u as S}from"./jsxRuntime-WpZ1bTm4.js";var C={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};C.node;var te=u(C),w={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};w.node;var ne=u(w),re={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};re.node;var ie=u(re);function T(e,t){let n=t?.querySelectorAll(`video`),r=Array.from(e.querySelectorAll(`video`),(e,t)=>{let r=n?.[t]??e,i=document.createElement(`canvas`);i.className=e.className,i.width=Math.max(1,e.clientWidth),i.height=Math.max(1,e.clientHeight);let a=i.getContext(`2d`);return a&&r.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&new URL(r.currentSrc,document.baseURI).origin===window.location.origin&&a.drawImage(r,0,0,i.width,i.height),e.replaceWith(i),{video:e,still:i}});return()=>{for(let{video:e,still:t}of r)t.replaceWith(e)}}function ae(e,t){let n=t?.querySelectorAll(`.paper-table`),r=[];for(let[t,i]of Array.from(e.querySelectorAll(`.paper-table > table`)).entries()){let e=n?.[t]?.scrollLeft||0;if(e){i.style.translate=`${-e}px`,r.push(i);for(let t of i.querySelectorAll(`tr > :first-child`))t.style.translate=`${e}px`,r.push(t)}}return()=>{for(let e of r)e.style.removeProperty(`translate`)}}function oe(e,t){let n=`.paper-diagram, .paper-diagram-source`,r=t?.querySelectorAll(n),i=[];for(let[t,a]of Array.from(e.querySelectorAll(n)).entries()){let e=r?.[t];if(!(e instanceof HTMLImageElement))continue;let n=e.cloneNode();n instanceof HTMLImageElement&&(n.classList.add(`paper-diagram-copy`),a.parentNode?.insertBefore(n,a),i.push(n))}return()=>{for(let e of i)e.remove()}}async function se(e,t,n,r){let{toCanvas:i}=await f(async()=>{let{toCanvas:e}=await import(`./es-YYQGP5MR.js`);return{toCanvas:e}},[],import.meta.url);await document.fonts.ready;let a=T(e,r),o=ae(e,r),s=oe(e,r),c=t.getBoundingClientRect(),l=await i(t,{pixelRatio:1.4,skipFonts:!0,style:{position:`relative`,inset:`auto`,overflow:`hidden`,visibility:`visible`,backgroundColor:`transparent`}}).finally(()=>{s(),o(),a()}),u=document.createElement(`canvas`),d=Math.min(1.35,2304/n.width,1440/n.height);u.width=Math.round(n.width*d),u.height=Math.round(n.height*d);let p=u.getContext(`2d`);return!p||!l.width?null:(p.drawImage(l,(c.left-n.left)/n.width*u.width,(c.top-n.top)/n.height*u.height,c.width/n.width*u.width,c.height/n.height*u.height),u)}var ce=[`left`,`right`,`front`,`back`];function E(e,t){return t?Math.floor(e/2)*2:e}function le(e,t){let n=E(e,!0),r=E(t,!0);if(n===r)return null;let i=n<r?1:-1,a=Math.min(n,r),o=Math.max(n,r);return{to:t,direction:i,panels:{left:{index:a,side:`left`},right:{index:o+1,side:`right`},front:{index:a+1,side:`right`},back:{index:o,side:`left`}}}}function ue(e,t){return{width:Math.min(e*.86,t*2.2),height:Math.min(t*.88,e*.82)}}var D=860;function de(e,t){let n=document.createRange();return n.selectNodeContents(e),[...n.getClientRects()].filter(e=>e.width>0&&e.height>0&&e.bottom>t.top&&e.top<t.bottom)}function O(e,t,n){let r=document.createElement(`span`);return r.className=n,r.style.left=`${t.left-e.bounds.left}px`,r.style.top=`${t.top-e.bounds.top}px`,r.style.width=`${t.width}px`,r.style.height=`${t.height}px`,e.overlay.append(r),r}function fe(e,t,n){let r=de(t,e.bounds);if(!r.length||r.length>6)return;t.classList.add(`spell-drawing-${n}`),e.changed.push(t);let i=D/r.length,a=r.flatMap((t,r)=>{let a=O(e,t,`spell-ink spell-ink-${n}`),o=document.createElement(`span`);o.className=`spell-stroke`,a.append(o);let s={delay:r*i,duration:i,fill:`both`},c=o.animate([{transform:`scaleX(0)`},{transform:`scaleX(0)`,offset:.12},{transform:`scaleX(1)`,offset:.84},{transform:`scaleX(1)`}],s);if(n===`underline`)return[c];let l=document.createElement(`span`);return l.className=n===`mark`?`spell-marker-tip`:`spell-ink-dust`,a.append(l),[c,l.animate([{transform:`translate(0,-.45em)`,opacity:0},{transform:`translateX(0)`,opacity:1,offset:.12},{transform:`translateX(${t.width}px)`,opacity:1,offset:.84},{transform:`translate(${t.width}px,-.55em)`,opacity:0}],s)]});e.running.push(...a),Promise.allSettled(a.map(e=>e.finished)).then(()=>{t.classList.remove(`spell-drawing-${n}`);for(let e of a)e.effect instanceof KeyframeEffect&&e.effect.target instanceof Element&&e.effect.target.parentElement?.remove()})}function k(e,t,n){if(t.childNodes.length!==1||!(t.firstChild instanceof Text))return;let r=t.firstChild,i=[...new Intl.Segmenter().segment(r.data)];if(!i.length||i.length>46)return;let a=document.createRange(),o=getComputedStyle(t).font,s=[];for(let{index:t,segment:n}of i){if(!n.trim())continue;a.setStart(r,t),a.setEnd(r,t+n.length);let i=a.getBoundingClientRect();if(!i.width||i.bottom<=e.bounds.top||i.top>=e.bounds.bottom){for(let{glyph:e}of s)e.remove();return}let c=O(e,i,`spell-letter`);c.style.font=o,c.textContent=n,s.push({glyph:c,rect:i})}if(!s.length)return;let c=s.map(({glyph:t,rect:n})=>{a.selectNodeContents(t);let r=a.getBoundingClientRect();return{glyph:t,left:n.left-e.bounds.left+n.left-r.left,top:n.top-e.bounds.top+n.top-r.top}});for(let{glyph:e,left:t,top:n}of c)e.style.left=`${t}px`,e.style.top=`${n}px`;t.classList.add(`spell-letters-rising`),e.changed.push(t);let l=s.map(({glyph:e},t)=>e.animate([{transform:`translateY(0)`},{transform:`translate(${n?(t%3-1)*.4:0}em,${n?-.9-t%2*.35:-.38}em) rotate(${t%2?9:-7}deg)`,offset:.48},{transform:`translateY(0)`}],{duration:n?810:520,delay:Math.min(t*38,250),easing:`ease-in-out`,fill:`both`}));e.running.push(...l),Promise.allSettled(l.map(e=>e.finished)).then(()=>{t.classList.remove(`spell-letters-rising`);for(let{glyph:e}of s)e.remove()})}function A(e,t){if(t.matches(`.paper-alert`)){let n=O(e,t.getBoundingClientRect(),`spell-seal`);n.textContent=`!`,e.running.push(n.animate([{transform:`translateY(-1em) scale(1.5) rotate(-18deg)`,opacity:0},{transform:`scale(1)`,opacity:1,offset:.45},{transform:`scale(1)`,opacity:0}],{duration:920,fill:`both`}));return}if(t.matches(`.paper-red`)){let n=O(e,t.getBoundingClientRect(),`spell-red-drop`);e.running.push(n.animate([{transform:`translateY(-.9em)`,opacity:0},{transform:`translateY(0)`,opacity:1,offset:.54},{transform:`translateY(.22em) scale(1.35,.45)`,opacity:0}],{duration:680,fill:`both`}));return}if(t.localName===`code`){if(t.closest(`pre`))return;let n=O(e,t.getBoundingClientRect(),`spell-code-frame`),r=document.createElement(`span`),i=document.createElement(`span`);r.textContent=`[`,i.textContent=`]`,n.append(r,i);for(let[t,n]of[r,i].entries())e.running.push(n.animate([{transform:`translateX(${t?.8:-.8}em)`,opacity:0},{transform:`translateX(0)`,opacity:.7,offset:.62},{transform:`translateX(0)`,opacity:0}],{duration:790,fill:`both`}));return}let n=t.classList.contains(`paper-diagram`)?[{clipPath:`inset(0 0 100% 0)`},{clipPath:`inset(0)`}]:[{opacity:.78,textShadow:`0 .17em .08em #5639235c`},{opacity:1,textShadow:`none`}];e.running.push(t.animate(n,{duration:660,easing:`ease-out`}))}function pe(e){let t=[];for(let n of e.querySelectorAll(`:scope > .book-sheet .page-text`)){let e=document.createElement(`div`);e.className=`spell-overlay`,e.setAttribute(`aria-hidden`,`true`),e.style.insetInlineStart=`${n.scrollLeft}px`,e.style.insetBlockStart=`${n.scrollTop}px`,e.style.width=`${n.clientWidth}px`,e.style.height=`${n.clientHeight}px`,n.append(e);let r={article:n,bounds:n.getBoundingClientRect(),overlay:e,running:[],changed:[]},i=n.querySelectorAll(`mark,u,del,strong,em,h1,h2,h3,code,.paper-red,.paper-alert,.paper-diagram`);for(let e of[...i].slice(0,24)){let t=e.getBoundingClientRect();t.bottom<r.bounds.top||t.top>r.bounds.bottom||(e.matches(`mark,u,del`)?fe(r,e,e.localName===`mark`?`mark`:e.localName===`u`?`underline`:`cross`):e.matches(`strong,em`)?k(r,e,e.matches(`strong`)):A(r,e))}if(!r.running.length){e.remove();continue}let a=!1,o=()=>{if(!a){a=!0,n.removeEventListener(`scroll`,o),window.removeEventListener(`resize`,o);for(let e of r.running)e.cancel();for(let e of r.changed)e.classList.remove(`spell-drawing-mark`,`spell-drawing-underline`,`spell-drawing-cross`,`spell-letters-rising`);e.remove()}};n.addEventListener(`scroll`,o,{passive:!0}),window.addEventListener(`resize`,o),t.push(o),Promise.allSettled(r.running.map(e=>e.finished)).then(o)}return()=>{for(let e of t)e()}}var me=m(()=>f(()=>import(`./BookScene-Gz0X4LHo.js`),__vite__mapDeps([0,1,2,3,4]),import.meta.url)),he=()=>f(()=>import(`./PageMarkdown-CuLmPCnh.js`),__vite__mapDeps([5,1,3,4]),import.meta.url),j=m(he),ge=`(min-width: 700px)`,_e=`(prefers-reduced-motion: reduce)`;function ve(e){let[t,n]=b(()=>matchMedia(e).matches);return y(()=>{let t=matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function ye({page:e,number:t,side:n,anchor:r,bookTitle:i,text:a,locale:o}){let s=h(null),c=g(()=>{if(!s.current||(s.current.scrollTop=0,!r))return;let e=Array.from(s.current.querySelectorAll(`[id]`)).find(e=>e.id===r);e&&(s.current.scrollTop=e.getBoundingClientRect().top-s.current.getBoundingClientRect().top)},[r]);S(()=>c(),[c]);let l=g(()=>{c(),s.current?.dispatchEvent(new Event(`grimoire-content`,{bubbles:!0}))},[c]);return x(`div`,{className:`book-sheet book-sheet--${n}`,"data-sheet":n,"data-page-id":e?.id,"data-page-key":e&&d(e),"data-section-id":e?.section?.id,children:e&&x(_,{children:[e.preparedHtml===void 0?x(`article`,{ref:s,"aria-label":e.section?.title||e.title,className:`page-text`,children:[n===`left`&&e.group&&x(`p`,{className:`page-running-head`,children:i}),x(ee,{fallback:x(`p`,{"data-markdown-loading":!0,"aria-busy":`true`,children:a.loading}),children:x(j,{page:e,text:a,locale:o,onReady:l})})]}):x(`article`,{ref:s,"aria-label":e.section?.title||e.title,className:`page-text`,dangerouslySetInnerHTML:{__html:e.preparedHtml}}),x(`span`,{"aria-hidden":`true`,className:`folio-number`,children:t})]})})}function be(e,t){let n=[];for(let[r,i]of e.entries()){let e=n.at(-1);e?.id!==i.id&&(e={id:i.id,label:r===0&&i.id===`index`?t:i.title,first:r,sections:[]},n.push(e)),i.section&&e.sections.push({section:i.section,position:r})}return n}function xe({library:u,text:f,book:m,pageId:_,anchor:C,onPaperReady:w,onReturn:re}){let[T,ae]=b(!1),[oe,D]=b(!1),[de,O]=b(!1),[fe,k]=b(),A=h(new Map),[j,xe]=b(!1),[M,Se]=b(!1),[N,Ce]=b(u.magicMode??!1),P=h(void 0),[we,Te]=b(()=>new Set),F=h(null),Ee=h(null),I=h(null),L=h(null),De=h(null),R=e?.dataset.initialBook===m.id?e:null,z=ve(ge),B=ve(_e),V=z&&!M,Oe=h(!!w);y(()=>{!w&&Oe.current&&z&&!B&&(Oe.current=!1,D(!0))},[w,B,z]),y(()=>{z||ae(!1)},[z]);let{pages:H}=m,{binding:ke,style:Ae}=s(m.id,m.cover??(u.shelf?void 0:`red`)),je=v(()=>M?be(H,f.cover):[],[M,H,f.cover]),U=c(H,_,C),[W,Me]=b(U),[Ne,Pe]=b(null),Fe=h(null),G=v(()=>z&&!j&&!B?le(W,U):null,[j,B,U,W,z]),Ie=G?U:fe,K=v(()=>Ie===void 0||!z||j||B?null:le(W,Ie),[Ie,B,j,W,z]),q=T&&G&&Ne?.plan===K?Ne:null,Le=z&&!B&&(oe||!!G),Re=T&&(!!q||de);y(()=>{G&&D(!0)},[G]);let ze=g(e=>{ae(e),xe(!e)},[]),J=G?W:U,Y=E(J,z),Be=J===U?C:null,X=h(void 0);S(()=>{if(!N){X.current=void 0;return}let e=I.current;if(!e||B||w||M||G||X.current===Y)return;let t,n=0,r=!1,i=!1,a=()=>{i||n||r||X.current===Y||(n=requestAnimationFrame(()=>{if(n=0,e.querySelector(`:scope > .book-sheet [data-markdown-loading]`))return;let i=[...e.querySelectorAll(`:scope > .book-sheet`)].flatMap(e=>e.getAnimations()).filter(e=>e.pending||e.playState===`running`);i.length?(r=!0,Promise.allSettled(i.map(e=>e.finished)).then(()=>{r=!1,a()})):(X.current=Y,t=pe(e))}))};return e.addEventListener(`grimoire-content`,a),a(),()=>{i=!0,e.removeEventListener(`grimoire-content`,a),cancelAnimationFrame(n),t?.()}},[N,M,w,B,Y,G]);let Ve=g(e=>{O(!0),Me(e.plan.to),Pe(null);let t=E(e.plan.to,!0)+e.plan.direction*2;k(t>=0&&t<H.length?t:void 0)},[H.length]);function Z(e){!z||B||j||G||!H[e]||(D(!0),k(e),H[e]?.preparedHtml===void 0&&he())}y(()=>{let e=()=>{A.current.clear(),k(void 0)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),S(()=>{if(q)for(let e of I.current?.querySelectorAll(`:scope > .book-sheet video`)??[])e.pause()},[q]),S(()=>{let e=I.current;if(!e||!V)return;let t=()=>{let t=ue(e.clientWidth,e.clientHeight);e.style.setProperty(`--read-paper-width`,`${t.width}px`),e.style.setProperty(`--read-paper-height`,`${t.height}px`)},n=new ResizeObserver(t);return t(),n.observe(e),()=>{n.disconnect(),e.style.removeProperty(`--read-paper-width`),e.style.removeProperty(`--read-paper-height`)}},[V]),S(()=>{let e=De.current;if(R instanceof HTMLDivElement&&e)return e.append(R),L.current=R,()=>{R.remove(),L.current=null}},[R]),S(()=>{w&&L.current&&w(L.current)},[w]),y(()=>{G||Me(U)},[U,G]),y(()=>{if(!K){Pe(null);return}let e=Fe.current;if(!T||M||!e)return;let t=K,n=!0;async function r(){if(e?.querySelector(`[data-markdown-loading]`)&&(await he(),await new Promise(e=>requestAnimationFrame(()=>e()))),!n)return;let r=I.current,i=r?.getBoundingClientRect();if(!i)throw Error(`Missing book dimensions`);let a=i;async function o(n){let i=t.panels[n],o=H[i.index];if(!o)return null;let s=e?.querySelector(`[data-ink-face="${n}"] .book-sheet`),c=s?.querySelector(`article`);if(!s||!c)throw Error(`Missing turning page`);let l=r?.querySelector(`:scope > [data-sheet="${i.side}"]`),u=l?.dataset.pageKey===d(o)?l.querySelector(`article`)??void 0:void 0,f=u??c,p=f.scrollTop,m=[...f.querySelectorAll(`.paper-table`)],h=[d(o),i.side,Math.round(a.width),Math.round(a.height),p,...m.map(e=>e.scrollLeft)].join(`:`),g=!f.querySelector(`video,iframe,.paper-diagram-source,[aria-busy=true]`);if(g){let e=A.current.get(h);if(e)return e}let _=c.firstElementChild;if(p&&_ instanceof HTMLElement){let e=Number.parseFloat(getComputedStyle(_).marginTop)||0;c.style.height=`${f.clientHeight}px`,_.style.marginTop=`${e-p}px`}let v=await se(c,s,a,u);if(v&&g){let e=A.current;if(e.size>=6){let t=e.keys().next().value;t!==void 0&&e.delete(t)}e.set(h,v)}if(!v)throw Error(`Unable to render turning page`);return v}let[s,c,l,u]=await Promise.all([o(`left`),o(`right`),o(`front`),o(`back`)]);n&&Pe({plan:t,ink:{left:s,right:c,front:l,back:u}})}return r().catch(()=>{n&&xe(!0)}),()=>{n=!1}},[K,M,H,T]);let He=z&&Y+1<H.length,Ue=z?2:1,Q=Y-Ue,$=Y+Ue,We=H[J],Ge=We?.title||m.title;y(()=>{if(!M)return;let e=F.current;e&&!e.open&&(e.showModal(),e.querySelector(`[aria-current=page]`)?.scrollIntoView({block:`nearest`}))},[M]),y(()=>{let e=e=>{if(M||w||G||document.querySelector(`.diagram-viewer[open]`)||e.altKey||e.metaKey||e.ctrlKey||e.defaultPrevented||e.target instanceof HTMLElement&&e.target.closest(`input,textarea,select,video,[contenteditable],.paper-table,.paper-embed`))return;let t=e.key===`ArrowLeft`?H[Q]:e.key===`ArrowRight`?H[$]:void 0;t&&(e.preventDefault(),l(a(m.id,t.id,t.section?.id)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m.id,$,w,M,H,Q,G]);function Ke(e){P.current=void 0,z||M||w||e.pointerType!==`touch`||!e.isPrimary||e.target instanceof Element&&e.target.closest(`a,button,input,select,textarea,video,iframe,pre,.paper-table,.paper-embed,[contenteditable]`)||(P.current={id:e.pointerId,x:e.clientX,y:e.clientY})}function qe(e){let t=P.current;if(P.current=void 0,!t||t.id!==e.pointerId||M||z)return;let n=e.clientX-t.x,r=e.clientY-t.y;if(Math.abs(n)<48||Math.abs(n)<=1.4*Math.abs(r))return;let i=H[n<0?$:Q];i&&l(a(m.id,i.id,i.section?.id))}function Je(){Se(!1),requestAnimationFrame(()=>Ee.current?.focus())}let Ye=z?Y+1:Y,Xe=H[Ye],Ze=Ye+1;return x(`main`,{tabIndex:-1,"data-magic":N||void 0,className:`reader ${M?`reader--catalog`:``}`,children:[x(`header`,{className:`reader-header`,"data-magic-control":u.magicMode||void 0,children:[u.shelf?x(`a`,{href:t,className:`brand`,onClick:re,children:[x(te,{size:23,"aria-hidden":!0}),f.library]}):x(`span`,{className:`brand`,children:[x(r,{size:26,"aria-hidden":!0}),u.title]}),u.magicMode&&x(`button`,{className:`magic-mode`,type:`button`,"aria-pressed":N,onClick:()=>Ce(!N),children:[x(ie,{size:18,"aria-hidden":!0}),` `,f.magic]}),x(`button`,{type:`button`,ref:Ee,className:`contents-button`,"aria-haspopup":`dialog`,disabled:!!G,onClick:()=>Se(!0),children:[x(ne,{size:22,"aria-hidden":!0}),f.contents]})]}),x(`div`,{className:`reader-stage`,ref:I,"data-ready":Re,"data-binding":ke,style:Ae,"data-wide":z,"data-frame":V?`reading`:void 0,"data-page-turn":!!q,onScrollCapture:()=>{G||k(void 0)},onPointerDown:Ke,onPointerUp:qe,onPointerCancel:()=>{P.current=void 0},children:[R?x(`div`,{className:`resting-art-slot`,ref:De,"aria-hidden":`true`}):x(`div`,{className:`book-fallback`,ref:L,"aria-hidden":`true`,children:z&&x(`div`,{className:`book-resting`,style:{backgroundImage:`url("${i(ke)}")`}})}),G&&!q&&x(`span`,{className:`page-pickup`,"data-direction":G.direction,"aria-hidden":`true`}),Le&&x(`div`,{className:`book-scene`,"aria-hidden":`true`,children:x(ee,{fallback:null,children:x(me,{binding:ke,fittedRead:V,onReady:ze,turn:q,onTurnDone:Ve})})}),z&&x(ye,{page:H[Y],side:`left`,number:Y+1,anchor:Y===J?Be:null,bookTitle:m.title,text:f,locale:u.locale},H[Y]?d(H[Y]):`blank`),x(ye,{page:Xe,side:`right`,number:Ze,anchor:J===Ye?Be:null,bookTitle:m.title,text:f,locale:u.locale},Xe?d(Xe):`blank-right`),K&&T&&!q&&!M&&x(`div`,{className:`turn-capture`,ref:Fe,"aria-hidden":`true`,inert:!0,children:ce.map(e=>{let t=K.panels[e];return H[t.index]&&x(`div`,{className:`turn-capture-face`,"data-ink-face":e,children:x(ye,{page:H[t.index],number:t.index+1,side:t.side,anchor:null,bookTitle:m.title,text:f,locale:u.locale})},e)})})]}),x(`nav`,{className:`reader-pagination`,"aria-label":f.contents,children:[H[Q]?x(`a`,{className:`turn-button`,href:a(m.id,H[Q].id,H[Q].section?.id),"aria-label":f.previous,"aria-disabled":!!G,tabIndex:G?-1:void 0,onClick:e=>{G&&e.preventDefault()},onPointerEnter:()=>Z(Q),onFocus:()=>Z(Q),children:x(te,{"aria-hidden":!0,size:24})}):x(`button`,{type:`button`,className:`turn-button`,"aria-label":f.previous,disabled:!0,children:x(te,{size:24})}),x(`div`,{className:`reading-position`,"aria-live":`polite`,children:[x(`span`,{title:Ge,children:Ge}),x(`span`,{children:[He?`${Y+1}–${Y+2}`:Y+1,` / `,H.length]})]}),H[$]?x(`a`,{className:`turn-button`,href:a(m.id,H[$].id,H[$].section?.id),"aria-label":f.next,"aria-disabled":!!G,tabIndex:G?-1:void 0,onClick:e=>{G&&e.preventDefault()},onPointerEnter:()=>Z($),onFocus:()=>Z($),children:x(p,{"aria-hidden":!0,size:24})}):x(`button`,{type:`button`,className:`turn-button`,"aria-label":f.next,disabled:!0,children:x(p,{size:24})})]}),x(`dialog`,{className:`catalog`,ref:F,onPointerDown:e=>{e.target===e.currentTarget&&F.current?.close()},onClose:Je,"aria-labelledby":M?`catalog-title`:void 0,children:M&&x(`div`,{className:`catalog-paper`,children:[x(`div`,{className:`catalog-header`,children:[x(`h2`,{id:`catalog-title`,children:f.contents}),x(`button`,{type:`button`,"aria-label":f.close,onClick:()=>F.current?.close(),children:x(o,{"aria-hidden":!0,size:24})})]}),x(`ol`,{className:`catalog-pages`,style:{"--folio-digits":String(H.length).length},children:je.map(e=>{let t=We?.id===e.id,r=e.sections,i=r.length>0&&!we.has(e.id),o=t&&i&&(J>e.first||Be)?We.section?.id:void 0;return x(`li`,{children:[x(`div`,{className:`catalog-row`,"data-expandable":r.length>0||void 0,children:[x(`a`,{href:a(m.id,e.id),"aria-current":t&&!o?`page`:void 0,onClick:()=>F.current?.close(),children:[x(`span`,{className:`catalog-label`,children:e.label}),x(`span`,{className:`catalog-leader`,"aria-hidden":`true`}),x(`span`,{className:`catalog-folio`,children:e.first+1})]}),r.length>0&&x(`button`,{type:`button`,className:`catalog-expand`,"aria-label":f.chapterPages(e.label),"aria-expanded":i,onClick:()=>Te(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),children:x(n,{"aria-hidden":!0,size:15})})]}),i&&x(`ol`,{className:`catalog-nested`,children:r.map(({section:t,position:n})=>x(`li`,{children:x(`a`,{href:a(m.id,e.id,t.id),"aria-current":o===t.id?`page`:void 0,onClick:()=>F.current?.close(),children:[x(`span`,{className:`catalog-label`,children:t.title}),x(`span`,{className:`catalog-leader`,"aria-hidden":`true`}),x(`span`,{className:`catalog-folio`,children:n+1})]})},t.id))})]},e.id)})})]})})]})}export{xe as BookReader,ce as n,ue as t};
@@ -1,4 +1,4 @@
1
- import{d as e,l as t,t as n,u as r}from"./jsxRuntime-WpZ1bTm4.js";import{$ as i,$n as a,A as o,An as s,At as c,B as l,Bn as u,C as d,Cn as f,Ct as p,D as m,Dn as h,Dt as g,E as _,Et as v,F as y,Fn as b,Ft as x,G as S,Gn as C,H as w,Hn as T,I as E,In as D,J as O,Jn as k,K as A,Kn as ee,L as j,Mn as M,N as te,Nn as N,O as P,On as F,Ot as ne,P as re,Pn as ie,Pt as ae,Q as I,Qn as oe,R as se,Rn as ce,S as L,Sn as le,St as ue,T as de,Tn as fe,Tt as pe,U as me,Un as he,V as ge,Vn as _e,W as ve,Wn as R,X as ye,Xn as be,Y as xe,Yn as Se,Z as Ce,Zn as we,_ as Te,_n as Ee,_t as De,a as Oe,ar as z,at as B,b as ke,bt as Ae,c as je,cr as Me,ct as Ne,d as V,dn as Pe,dt as H,er as U,et as Fe,f as W,fn as Ie,ft as G,g as Le,gn as K,gt as q,h as Re,hn as ze,ht as Be,i as Ve,ir as He,it as Ue,j as We,jn as Ge,k as Ke,kn as qe,lt as Je,m as Ye,mt as Xe,n as Ze,nr as Qe,nt as $e,o as et,or as tt,ot as nt,p as J,pn as rt,pt as it,q as at,qn as ot,r as st,rr as ct,rt as lt,s as ut,sr as Y,st as dt,tr as ft,tt as pt,u as mt,ut as ht,v as gt,vt as _t,w as vt,wn as yt,wt as bt,x as xt,xt as St,y as Ct,yt as wt}from"./three-core-B1q6MRTI.js";import{p as Tt}from"./index-D4HJC4TW.js";import{n as Et,t as Dt}from"./BookReader-DudAXdp3.js";function Ot(){let e=null,t=!1,n=null,r=null;function i(t,a){r=e.requestAnimationFrame(i),n(t,a)}return{start:function(){t!==!0&&n!==null&&e!==null&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e!==null&&e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function kt(e){let t=new WeakMap;function n(t,n){let r=t.array,i=t.usage,a=r.byteLength,o=e.createBuffer();e.bindBuffer(n,o),e.bufferData(n,r,i),t.onUploadCallback();let s;if(r instanceof Float32Array)s=e.FLOAT;else if(typeof Float16Array<`u`&&r instanceof Float16Array)s=e.HALF_FLOAT;else if(r instanceof Uint16Array)s=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)s=e.SHORT;else if(r instanceof Uint32Array)s=e.UNSIGNED_INT;else if(r instanceof Int32Array)s=e.INT;else if(r instanceof Int8Array)s=e.BYTE;else if(r instanceof Uint8Array)s=e.UNSIGNED_BYTE;else if(r instanceof Uint8ClampedArray)s=e.UNSIGNED_BYTE;else throw Error(`THREE.WebGLAttributes: Unsupported buffer data format: `+r);return{buffer:o,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:a}}function r(t,n,r){let i=n.array,a=n.updateRanges;if(e.bindBuffer(r,t),a.length===0)e.bufferSubData(r,0,i);else{a.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<a.length;e++){let n=a[t],r=a[e];r.start<=n.start+n.count+1?n.count=Math.max(n.count,r.start+r.count-n.start):(++t,a[t]=r)}a.length=t+1;for(let t=0,n=a.length;t<n;t++){let n=a[t];e.bufferSubData(r,n.start*i.BYTES_PER_ELEMENT,i,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}function i(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)}function a(n){n.isInterleavedBufferAttribute&&(n=n.data);let r=t.get(n);r&&(e.deleteBuffer(r.buffer),t.delete(n))}function o(e,i){if(e.isInterleavedBufferAttribute&&(e=e.data),e.isGLBufferAttribute){let n=t.get(e);(!n||n.version<e.version)&&t.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version});return}let a=t.get(e);if(a===void 0)t.set(e,n(e,i));else if(a.version<e.version){if(a.size!==e.array.byteLength)throw Error(`THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.`);r(a.buffer,e,i),a.version=e.version}}return{get:i,remove:a,update:o}}var X={alphahash_fragment:`#ifdef USE_ALPHAHASH
1
+ import{d as e,l as t,t as n,u as r}from"./jsxRuntime-WpZ1bTm4.js";import{$ as i,$n as a,A as o,An as s,At as c,B as l,Bn as u,C as d,Cn as f,Ct as p,D as m,Dn as h,Dt as g,E as _,Et as v,F as y,Fn as b,Ft as x,G as S,Gn as C,H as w,Hn as T,I as E,In as D,J as O,Jn as k,K as A,Kn as ee,L as j,Mn as M,N as te,Nn as N,O as P,On as F,Ot as ne,P as re,Pn as ie,Pt as ae,Q as I,Qn as oe,R as se,Rn as ce,S as L,Sn as le,St as ue,T as de,Tn as fe,Tt as pe,U as me,Un as he,V as ge,Vn as _e,W as ve,Wn as R,X as ye,Xn as be,Y as xe,Yn as Se,Z as Ce,Zn as we,_ as Te,_n as Ee,_t as De,a as Oe,ar as z,at as B,b as ke,bt as Ae,c as je,cr as Me,ct as Ne,d as V,dn as Pe,dt as H,er as U,et as Fe,f as W,fn as Ie,ft as G,g as Le,gn as K,gt as q,h as Re,hn as ze,ht as Be,i as Ve,ir as He,it as Ue,j as We,jn as Ge,k as Ke,kn as qe,lt as Je,m as Ye,mt as Xe,n as Ze,nr as Qe,nt as $e,o as et,or as tt,ot as nt,p as J,pn as rt,pt as it,q as at,qn as ot,r as st,rr as ct,rt as lt,s as ut,sr as Y,st as dt,tr as ft,tt as pt,u as mt,ut as ht,v as gt,vt as _t,w as vt,wn as yt,wt as bt,x as xt,xt as St,y as Ct,yt as wt}from"./three-core-B1q6MRTI.js";import{m as Tt}from"./index-D2pcSqWr.js";import{n as Et,t as Dt}from"./BookReader-Dn0DGCvp.js";function Ot(){let e=null,t=!1,n=null,r=null;function i(t,a){r=e.requestAnimationFrame(i),n(t,a)}return{start:function(){t!==!0&&n!==null&&e!==null&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e!==null&&e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function kt(e){let t=new WeakMap;function n(t,n){let r=t.array,i=t.usage,a=r.byteLength,o=e.createBuffer();e.bindBuffer(n,o),e.bufferData(n,r,i),t.onUploadCallback();let s;if(r instanceof Float32Array)s=e.FLOAT;else if(typeof Float16Array<`u`&&r instanceof Float16Array)s=e.HALF_FLOAT;else if(r instanceof Uint16Array)s=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)s=e.SHORT;else if(r instanceof Uint32Array)s=e.UNSIGNED_INT;else if(r instanceof Int32Array)s=e.INT;else if(r instanceof Int8Array)s=e.BYTE;else if(r instanceof Uint8Array)s=e.UNSIGNED_BYTE;else if(r instanceof Uint8ClampedArray)s=e.UNSIGNED_BYTE;else throw Error(`THREE.WebGLAttributes: Unsupported buffer data format: `+r);return{buffer:o,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:a}}function r(t,n,r){let i=n.array,a=n.updateRanges;if(e.bindBuffer(r,t),a.length===0)e.bufferSubData(r,0,i);else{a.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<a.length;e++){let n=a[t],r=a[e];r.start<=n.start+n.count+1?n.count=Math.max(n.count,r.start+r.count-n.start):(++t,a[t]=r)}a.length=t+1;for(let t=0,n=a.length;t<n;t++){let n=a[t];e.bufferSubData(r,n.start*i.BYTES_PER_ELEMENT,i,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}function i(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)}function a(n){n.isInterleavedBufferAttribute&&(n=n.data);let r=t.get(n);r&&(e.deleteBuffer(r.buffer),t.delete(n))}function o(e,i){if(e.isInterleavedBufferAttribute&&(e=e.data),e.isGLBufferAttribute){let n=t.get(e);(!n||n.version<e.version)&&t.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version});return}let a=t.get(e);if(a===void 0)t.set(e,n(e,i));else if(a.version<e.version){if(a.size!==e.array.byteLength)throw Error(`THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.`);r(a.buffer,e,i),a.version=e.version}}return{get:i,remove:a,update:o}}var X={alphahash_fragment:`#ifdef USE_ALPHAHASH
2
2
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
3
3
  #endif`,alphahash_pars_fragment:`#ifdef USE_ALPHAHASH
4
4
  const float ALPHA_HASH_SCALE = 0.05;