grimoire3d 0.0.0 → 0.1.0-dev.9361940

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 (153) hide show
  1. package/README.md +23 -123
  2. package/cli/cli.js +350 -0
  3. package/cli/content.js +403 -0
  4. package/cli/cover-options.d.ts +15 -0
  5. package/cli/cover-options.js +105 -0
  6. package/cli/head-file.js +133 -0
  7. package/cli/library-footer.d.ts +10 -0
  8. package/cli/library-footer.js +21 -0
  9. package/cli/markdown.js +139 -0
  10. package/cli/markup.d.ts +3 -0
  11. package/cli/markup.js +60 -0
  12. package/cli/routes.d.ts +6 -0
  13. package/cli/routes.js +19 -0
  14. package/cli/static-pages.js +481 -0
  15. package/cli/video-url.d.ts +5 -0
  16. package/cli/video-url.js +51 -0
  17. package/dist/BookViewer-GXuBR_bC.js +339 -0
  18. package/dist/components/BookModel.d.ts +20 -0
  19. package/dist/components/BookViewer.d.ts +17 -0
  20. package/dist/components/index.d.ts +2 -0
  21. package/dist/components/index.js +1 -0
  22. package/dist/grimoire3d.css +3 -0
  23. package/dist/index.d.ts +8 -0
  24. package/dist/index.js +1 -0
  25. package/dist/main.d.ts +1 -0
  26. package/dist/site/assets/BookReader-DudAXdp3.js +2 -0
  27. package/dist/site/assets/BookScene-DiAiTP9V.js +4294 -0
  28. package/dist/site/assets/MermaidDiagram-2mwgnVgM.js +44 -0
  29. package/dist/site/assets/PageMarkdown-ENP_TuEU.js +37 -0
  30. package/dist/site/assets/abnfDiagram-S7VZAUFO-CPn8kyCz.js +1 -0
  31. package/dist/site/assets/alcove-cyX4Tv3E.avif +0 -0
  32. package/dist/site/assets/architecture-WOLXFQ4H-Czsdswwl.js +1 -0
  33. package/dist/site/assets/architectureDiagram-YGSQEFNW-C_9i0B1c.js +36 -0
  34. package/dist/site/assets/blockDiagram-APKKGZFW-B4TEuCLK.js +140 -0
  35. package/dist/site/assets/bpmnIcons-APHXDYXF-C0jbCElo.js +1 -0
  36. package/dist/site/assets/c4Diagram-KJ2TOQU5-CH_Uv_Fz.js +38 -0
  37. package/dist/site/assets/catalog-07-UR91A.avif +0 -0
  38. package/dist/site/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  39. package/dist/site/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
  40. package/dist/site/assets/chunk-6MUBBAK2-C4kh7Z3T.js +2 -0
  41. package/dist/site/assets/chunk-AXFCVDMN-B_taAhLl.js +62 -0
  42. package/dist/site/assets/chunk-BG4553SI-Cn6LMB1q.js +129 -0
  43. package/dist/site/assets/chunk-DQASFODM-BsDpj_0k.js +10 -0
  44. package/dist/site/assets/chunk-DUW6YSOI-Dgx8z5s3.js +1 -0
  45. package/dist/site/assets/chunk-HFQBQIA3-DLIuoeT3.js +1 -0
  46. package/dist/site/assets/chunk-J5ZVWO5B-oDCd-gWO.js +1 -0
  47. package/dist/site/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  48. package/dist/site/assets/chunk-KQLB2F66-AFzkv6d3.js +2 -0
  49. package/dist/site/assets/chunk-KS47KZWR-DjywFwRy.js +1 -0
  50. package/dist/site/assets/chunk-LEVMRMFU-BrDnuOnu.js +1 -0
  51. package/dist/site/assets/chunk-M57EVK23-BikTvdAr.js +1 -0
  52. package/dist/site/assets/chunk-NGNAAXSQ-DI_UYJZ4.js +136 -0
  53. package/dist/site/assets/chunk-OY52VR5R-Nk28J3qR.js +88 -0
  54. package/dist/site/assets/chunk-QB3YPZ4I-OgBmaa_y.js +213 -0
  55. package/dist/site/assets/chunk-R3KSYZAL-CdwBI4dZ.js +1 -0
  56. package/dist/site/assets/chunk-STOXU5M4-BZAF-H6I.js +72 -0
  57. package/dist/site/assets/chunk-TU62E6Q5-C6WlEf5k.js +1 -0
  58. package/dist/site/assets/chunk-X4PVCEUW-BYepnSMY.js +1 -0
  59. package/dist/site/assets/chunk-XXDRQBXY-DN9ONrwM.js +1 -0
  60. package/dist/site/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  61. package/dist/site/assets/classDiagram-v2-L25IHNXF-ChtKa3P5.js +217 -0
  62. package/dist/site/assets/cose-bilkent-JH36ORCC-kNFKiV_g.js +1 -0
  63. package/dist/site/assets/cover-blue-Bh8Xp4T5.avif +0 -0
  64. package/dist/site/assets/cover-blue-mobile-YcuYIg0I.avif +0 -0
  65. package/dist/site/assets/cover-green-By13JjUx.avif +0 -0
  66. package/dist/site/assets/cover-green-mobile-BNTgNt7v.avif +0 -0
  67. package/dist/site/assets/cover-red-mobile-DHOCz3wI.avif +0 -0
  68. package/dist/site/assets/cover-red-qvZEk3PI.avif +0 -0
  69. package/dist/site/assets/cynefin-EF2NZ3EQ-lzZSPZ0f.js +1 -0
  70. package/dist/site/assets/cynefinDiagram-L36ESFBY-sq_xQVi7.js +62 -0
  71. package/dist/site/assets/cytoscape.esm-nTrd5EVq.js +321 -0
  72. package/dist/site/assets/d3-scale-CElPUUud.js +1 -0
  73. package/dist/site/assets/d3-selection-DIUqvUVB.js +1 -0
  74. package/dist/site/assets/dagre-SPEB5RXH-DqoO0sGc.js +4 -0
  75. package/dist/site/assets/diagram-3B7GL73J-M26Lh06i.js +200 -0
  76. package/dist/site/assets/diagram-DNEMPZML-ZZQRAEJq.js +24 -0
  77. package/dist/site/assets/diagram-L3MUGCDN-CjsMyH3f.js +41 -0
  78. package/dist/site/assets/diagram-LA4NIPWU-B1tD-62P.js +24 -0
  79. package/dist/site/assets/diagram-MHCOC4E2-B0jKQ9HQ.js +3 -0
  80. package/dist/site/assets/diagram-XPFHEONP-BelYHEVT.js +30 -0
  81. package/dist/site/assets/dist-ppXrr7du.js +1 -0
  82. package/dist/site/assets/ebnfDiagram-UZSYDL2S-BlM2_kcX.js +1 -0
  83. package/dist/site/assets/elk-XV6XMXQE-DGFBMQyB.js +27 -0
  84. package/dist/site/assets/erDiagram-EYBAPDEH-BYeh4LuC.js +99 -0
  85. package/dist/site/assets/es-YYQGP5MR.js +2 -0
  86. package/dist/site/assets/eventmodeling-K75KTNOO-CJHo0aIb.js +1 -0
  87. package/dist/site/assets/favicon-C9YRygge.png +0 -0
  88. package/dist/site/assets/flowDiagram-MALGAFMO-4xnU_Dv7.js +1 -0
  89. package/dist/site/assets/ganttDiagram-23REXITY-BlApGIuJ.js +292 -0
  90. package/dist/site/assets/gitGraph-VSP46ZUC-Dwcg1pSB.js +1 -0
  91. package/dist/site/assets/gitGraphDiagram-STJD7YCW-BJXE5oWq.js +106 -0
  92. package/dist/site/assets/graphlib-DS17s2tU.js +1 -0
  93. package/dist/site/assets/index-D4HJC4TW.js +2 -0
  94. package/dist/site/assets/index-fT8cj2JB.css +1 -0
  95. package/dist/site/assets/info-OHQRW6UA-BEW1vxOL.js +1 -0
  96. package/dist/site/assets/infoDiagram-KBXO4MBG-DseLOSIt.js +2 -0
  97. package/dist/site/assets/ishikawaDiagram-M35NCXHK-D3nXJVhq.js +70 -0
  98. package/dist/site/assets/journeyDiagram-OPLOXDXO-Dwmf_2yx.js +139 -0
  99. package/dist/site/assets/jsxRuntime-WpZ1bTm4.js +1 -0
  100. package/dist/site/assets/kanban-definition-BZKZHSQY-D8hRo5NB.js +89 -0
  101. package/dist/site/assets/katex-MEuSR36T.js +257 -0
  102. package/dist/site/assets/mermaid-parser.core-CRzqu-zz.js +7 -0
  103. package/dist/site/assets/mindmap-definition-I2QAS2VK-C_KsVBJE.js +98 -0
  104. package/dist/site/assets/mobile-cabinet-BUr9vtlo.avif +0 -0
  105. package/dist/site/assets/mobile-cabinet-sm-pauJUfRH.avif +0 -0
  106. package/dist/site/assets/mobile-paper-DF0CuLes.avif +0 -0
  107. package/dist/site/assets/mobile-paper-sm-77eJHX6h.avif +0 -0
  108. package/dist/site/assets/open-nWGD2hyb.glb +0 -0
  109. package/dist/site/assets/packet-JDAUHWVQ-vLUg6kma.js +1 -0
  110. package/dist/site/assets/pegDiagram-FD4XPPHP-CsAJzLE2.js +1 -0
  111. package/dist/site/assets/pie-XZMESJXO-C5OiZ5I_.js +1 -0
  112. package/dist/site/assets/pieDiagram-J4AKIIQI-C0Z-TuM1.js +39 -0
  113. package/dist/site/assets/quadrantDiagram-XTYBLID2-BfwNOGbp.js +7 -0
  114. package/dist/site/assets/radar-ABXABTNO-DlOAhNu8.js +1 -0
  115. package/dist/site/assets/railroad-I3PHUGI6-BUpxKd8T.js +1 -0
  116. package/dist/site/assets/railroad-abnf-LNEFI6M7-BsS9Vk34.js +1 -0
  117. package/dist/site/assets/railroad-ebnf-DWYD2UWJ-Cx8TyVDx.js +1 -0
  118. package/dist/site/assets/railroad-peg-JR7BVNR7-C2s9CJ5A.js +1 -0
  119. package/dist/site/assets/railroadDiagram-MRQ6NCDL-nXlyo8yi.js +1 -0
  120. package/dist/site/assets/requirementDiagram-Y7LWUY3S-C_jfLPMO.js +84 -0
  121. package/dist/site/assets/resting-amber-BSjsErIg.avif +0 -0
  122. package/dist/site/assets/resting-black-DDQ4XMJI.avif +0 -0
  123. package/dist/site/assets/resting-blue-DDOT8IQ8.avif +0 -0
  124. package/dist/site/assets/resting-green-DkRrV8eX.avif +0 -0
  125. package/dist/site/assets/resting-ivory-CEqoG5yI.avif +0 -0
  126. package/dist/site/assets/resting-plum-B-8tkSmP.avif +0 -0
  127. package/dist/site/assets/resting-red-D0hLpMpz.avif +0 -0
  128. package/dist/site/assets/resting-slate-CH8Z_Rky.avif +0 -0
  129. package/dist/site/assets/resting-teal-CGt6jFmT.avif +0 -0
  130. package/dist/site/assets/resting-walnut-t3WgHgUO.avif +0 -0
  131. package/dist/site/assets/rough.esm-Dy-Kn_BL.js +1 -0
  132. package/dist/site/assets/sankeyDiagram-WGJFYUXA-DiLclJAZ.js +40 -0
  133. package/dist/site/assets/search-stage-B8cH1AE_.avif +0 -0
  134. package/dist/site/assets/search-stage-mobile-BZ58ew4F.avif +0 -0
  135. package/dist/site/assets/sequenceDiagram-5NDRBG5M-B9sM-5ZJ.js +169 -0
  136. package/dist/site/assets/sizeCapture-INFHLROL-3uHXrFqA.js +1 -0
  137. package/dist/site/assets/stateDiagram-v2-FJ4FJNEA-Dkis5g_v.js +291 -0
  138. package/dist/site/assets/swimlanes-UMQ2AFYF-DB6kjOv7.js +1 -0
  139. package/dist/site/assets/swimlanesDiagram-OMPLPG4O-IMFdS7Zf.js +8 -0
  140. package/dist/site/assets/three-core-B1q6MRTI.js +5 -0
  141. package/dist/site/assets/timeline-definition-SEUHKTQE-2CMebGt0.js +120 -0
  142. package/dist/site/assets/treeView-D4JQ5SDB-BZ52mw7_.js +1 -0
  143. package/dist/site/assets/treemap-SAJKECNS-C-pobFuU.js +1 -0
  144. package/dist/site/assets/usecaseDiagram-AFA6YXN4-BACx6ppv.js +328 -0
  145. package/dist/site/assets/vennDiagram-NNMJR3RB-B8NLdumI.js +34 -0
  146. package/dist/site/assets/wardley-7MLQ67FV-BWJ-dzdI.js +1 -0
  147. package/dist/site/assets/wardleyDiagram-S7YFUSEH-WKBfzjEM.js +78 -0
  148. package/dist/site/assets/xychartDiagram-GGNKY7IX-BUciDj2U.js +7 -0
  149. package/dist/site/index.html +15 -0
  150. package/dist/types/index.d.ts +163 -0
  151. package/package.json +51 -28
  152. package/dist/grimoire3d.js +0 -504
  153. package/dist/grimoire3d.umd.cjs +0 -27
@@ -0,0 +1,139 @@
1
+ import { fromMarkdown } from "mdast-util-from-markdown";
2
+ import { gfmFromMarkdown } from "mdast-util-gfm";
3
+ import { gfm } from "micromark-extension-gfm";
4
+ import { parse } from "yaml";
5
+
6
+ function textOf(node) {
7
+ if (node.type === "image") return node.alt ?? "";
8
+ return node.value ?? node.children?.map(textOf).join("") ?? "";
9
+ }
10
+
11
+ function headingSlug(title) {
12
+ return (
13
+ title
14
+ .toLowerCase()
15
+ .trim()
16
+ .replace(/[^\p{Letter}\p{Number}\s_-]/gu, "")
17
+ .replace(/\s+/g, "-") || "section"
18
+ );
19
+ }
20
+
21
+ function isDefinition(node) {
22
+ return node.type === "definition" || node.type === "footnoteDefinition";
23
+ }
24
+
25
+ export function readMarkdown(source) {
26
+ const front = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(source);
27
+ let raw;
28
+ if (front) {
29
+ try {
30
+ raw = parse(front[1]);
31
+ } catch {
32
+ raw = undefined;
33
+ }
34
+ }
35
+ const metadata =
36
+ raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
37
+ const markdown = raw === metadata ? source.slice(front[0].length) : source;
38
+ const tree = fromMarkdown(markdown, {
39
+ extensions: [gfm()],
40
+ mdastExtensions: [gfmFromMarkdown()],
41
+ });
42
+ const headings = new Map();
43
+ const anchors = new Set();
44
+ const urls = new Set();
45
+ function visit(node) {
46
+ if (node.type === "heading") {
47
+ const title = textOf(node).trim();
48
+ const slug = headingSlug(title);
49
+ let id = slug;
50
+ for (let suffix = 1; anchors.has(id); suffix += 1) {
51
+ id = `${slug}-${suffix}`;
52
+ }
53
+ anchors.add(id);
54
+ headings.set(node, { id, title });
55
+ }
56
+ if (["link", "image", "definition"].includes(node.type)) urls.add(node.url);
57
+ node.children?.forEach(visit);
58
+ }
59
+ visit(tree);
60
+
61
+ const heading = tree.children.find(
62
+ (node) => node.type === "heading" && node.depth === 1
63
+ );
64
+ const boundaries = [{ start: 0 }];
65
+ let hasChapterContent = false;
66
+ for (const node of tree.children) {
67
+ if (node.type === "heading" && node.depth === 2) {
68
+ const section = headings.get(node);
69
+ if (hasChapterContent) {
70
+ boundaries.push({ start: node.position.start.offset, section });
71
+ } else {
72
+ // The chapter already starts on a fresh page, so its title can share that page.
73
+ boundaries[0].section = section;
74
+ }
75
+ }
76
+ if (node !== heading && !isDefinition(node)) hasChapterContent = true;
77
+ }
78
+
79
+ const definitions = tree.children.filter(isDefinition);
80
+ const headingOffsets = [...headings].map(([node, { id }]) => ({
81
+ offset: node.position.start.offset,
82
+ id,
83
+ }));
84
+ let nextHeading = 0;
85
+ const sheets = boundaries.map(({ start, section }, index) => {
86
+ const end = boundaries[index + 1]?.start ?? markdown.length;
87
+ const headingIds = {};
88
+ while (headingOffsets[nextHeading]?.offset < end) {
89
+ const { offset, id } = headingOffsets[nextHeading];
90
+ headingIds[offset - start] = id;
91
+ nextHeading += 1;
92
+ }
93
+ const references = definitions
94
+ .filter(
95
+ ({ position }) =>
96
+ position.start.offset < start || position.start.offset >= end
97
+ )
98
+ .map(({ position }) =>
99
+ markdown.slice(position.start.offset, position.end.offset)
100
+ );
101
+ const content = markdown.slice(start, end);
102
+ return {
103
+ markdown: references.length
104
+ ? [content, ...references].join("\n\n")
105
+ : content,
106
+ headingIds,
107
+ section,
108
+ };
109
+ });
110
+
111
+ const paragraph = tree.children.find((node) => node.type === "paragraph");
112
+ const excerpt = paragraph
113
+ ? textOf(paragraph).replace(/\s+/g, " ").trim()
114
+ : "";
115
+ return {
116
+ heading: headings.get(heading)?.title,
117
+ metadata: {
118
+ cover:
119
+ typeof metadata.cover === "string" ? metadata.cover.trim() : undefined,
120
+ title:
121
+ typeof metadata.title === "string" ? metadata.title.trim() : undefined,
122
+ description:
123
+ typeof metadata.description === "string"
124
+ ? metadata.description.trim()
125
+ : undefined,
126
+ socialImage:
127
+ typeof metadata.socialImage === "string"
128
+ ? metadata.socialImage.trim()
129
+ : undefined,
130
+ },
131
+ excerpt: [...excerpt].slice(0, 170).join(""),
132
+ markdown,
133
+ headingIds: Object.fromEntries(
134
+ headingOffsets.map(({ offset, id }) => [offset, id])
135
+ ),
136
+ sheets,
137
+ urls: [...urls],
138
+ };
139
+ }
@@ -0,0 +1,3 @@
1
+ import type { Root } from "mdast";
2
+ import type { Plugin } from "unified";
3
+ export const remarkGrimoire: Plugin<[locale?: "en" | "ja"], Root>;
package/cli/markup.js ADDED
@@ -0,0 +1,60 @@
1
+ const inline = {
2
+ underline: "u",
3
+ highlight: "mark",
4
+ red: "span",
5
+ };
6
+ const alertNames = {
7
+ en: {
8
+ NOTE: "Note",
9
+ TIP: "Tip",
10
+ IMPORTANT: "Important",
11
+ WARNING: "Warning",
12
+ CAUTION: "Caution",
13
+ },
14
+ ja: {
15
+ NOTE: "注記",
16
+ TIP: "ヒント",
17
+ IMPORTANT: "重要",
18
+ WARNING: "警告",
19
+ CAUTION: "注意",
20
+ },
21
+ };
22
+
23
+ /** @param {"en" | "ja"} [locale] */
24
+ export function remarkGrimoire(locale = "en") {
25
+ /** @param {any} node */
26
+ function visit(node) {
27
+ if (node.type === "textDirective" && Object.hasOwn(inline, node.name)) {
28
+ node.data = { hName: inline[node.name] };
29
+ if (node.name === "red")
30
+ node.data.hProperties = { className: ["paper-red"] };
31
+ }
32
+ if (node.type === "blockquote") {
33
+ const paragraph = node.children[0];
34
+ const first = paragraph?.type === "paragraph" && paragraph.children[0];
35
+ const marker =
36
+ first?.type === "text" &&
37
+ /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\](?:\r?\n|$)/.exec(
38
+ first.value
39
+ );
40
+ if (marker) {
41
+ const name = marker[1];
42
+ first.value = first.value.slice(marker[0].length);
43
+ if (!first.value) paragraph.children.shift();
44
+ if (!paragraph.children.length) node.children.shift();
45
+ node.children.unshift({
46
+ type: "paragraph",
47
+ data: { hProperties: { className: ["paper-alert-label"] } },
48
+ children: [{ type: "text", value: alertNames[locale][name] }],
49
+ });
50
+ node.data = {
51
+ hProperties: {
52
+ className: ["paper-alert", `paper-alert-${name.toLowerCase()}`],
53
+ },
54
+ };
55
+ }
56
+ }
57
+ node.children?.forEach(visit);
58
+ }
59
+ return visit;
60
+ }
@@ -0,0 +1,6 @@
1
+ export function readerPath(book: string, chapter?: string): string;
2
+ export function readLegacyRoute(hash: string): {
3
+ book: string | undefined;
4
+ page: string | undefined;
5
+ anchor: string | null;
6
+ };
package/cli/routes.js ADDED
@@ -0,0 +1,19 @@
1
+ /** @param {string} book @param {string} [chapter] */
2
+ export function readerPath(book, chapter) {
3
+ return `read/${[book, ...(chapter?.split("/") ?? [])].map(encodeURIComponent).join("/")}/`;
4
+ }
5
+
6
+ /** @param {string} hash */
7
+ export function readLegacyRoute(hash) {
8
+ const [path, search] = hash.slice(1).split("?", 2);
9
+ try {
10
+ const [, book, chapter] = (path ?? "").split("/");
11
+ return {
12
+ book: book ? decodeURIComponent(book) : undefined,
13
+ page: chapter ? decodeURIComponent(chapter) : undefined,
14
+ anchor: new URLSearchParams(search).get("anchor"),
15
+ };
16
+ } catch {
17
+ return { book: undefined, page: undefined, anchor: null };
18
+ }
19
+ }