grimoire3d 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 kkm-horikawa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # grimoire3d
2
+
3
+ [![npm version](https://badge.fury.io/js/grimoire3d.svg)](https://badge.fury.io/js/grimoire3d)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ A 3D magical book documentation generator. Transform your docs into an interactive grimoire with realistic page-flip animations.
7
+
8
+ ## What is this?
9
+
10
+ Grimoire3D transforms your Markdown documentation into an interactive 3D book. Perfect for:
11
+
12
+ - Project documentation
13
+ - Design specifications
14
+ - Technical notes
15
+ - Portfolios
16
+ - Tutorials
17
+
18
+ ## Features
19
+
20
+ - Realistic 3D page-flip animation
21
+ - Markdown rendering
22
+ - HTML support
23
+ - Mermaid diagram support (planned)
24
+ - Multiple themes
25
+ - Static site generation
26
+ - Zero-config setup
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ npm install grimoire3d
32
+ # or
33
+ pnpm add grimoire3d
34
+ # or
35
+ yarn add grimoire3d
36
+ ```
37
+
38
+ ## Quick Start
39
+
40
+ ### 1. Create your docs directory
41
+
42
+ ```
43
+ my-project/
44
+ ├── grimoire.yml # Configuration (optional)
45
+ └── docs/
46
+ ├── index.md # Cover page
47
+ ├── 01-overview.md
48
+ ├── 02-features.md
49
+ └── assets/
50
+ └── diagram.png
51
+ ```
52
+
53
+ ### 2. Write your content
54
+
55
+ ```markdown
56
+ <!-- docs/index.md -->
57
+ # My Project
58
+
59
+ Welcome to the documentation.
60
+
61
+ ## Overview
62
+
63
+ This is an amazing project...
64
+ ```
65
+
66
+ ### 3. Start the dev server
67
+
68
+ ```bash
69
+ npx grimoire3d serve
70
+ ```
71
+
72
+ ### 4. Build for production
73
+
74
+ ```bash
75
+ npx grimoire3d build
76
+ ```
77
+
78
+ ## Configuration
79
+
80
+ Create a `grimoire.yml` file in your project root:
81
+
82
+ ```yaml
83
+ title: "My Project Documentation"
84
+ theme: "vintage-red" # or "modern-dark", "paper-white"
85
+ pages:
86
+ - index.md
87
+ - 01-overview.md
88
+ - 02-features.md
89
+ # Omit 'pages' to auto-detect all .md files
90
+ ```
91
+
92
+ ## Using as a React Component
93
+
94
+ ```tsx
95
+ import { BookViewer } from "grimoire3d/components";
96
+
97
+ const pages = [
98
+ {
99
+ id: "cover",
100
+ title: "Cover",
101
+ front: <CoverPage />,
102
+ back: <AboutPage />,
103
+ tabColor: "#E57373",
104
+ tabLabel: "Cover",
105
+ },
106
+ // ... more pages
107
+ ];
108
+
109
+ function App() {
110
+ return <BookViewer pages={pages} />;
111
+ }
112
+ ```
113
+
114
+ ## Themes
115
+
116
+ | Theme | Description |
117
+ |-------|-------------|
118
+ | `vintage-red` | Classic red leather book cover |
119
+ | `modern-dark` | Sleek dark mode |
120
+ | `paper-white` | Clean minimal design |
121
+ | `forest-green` | Nature-inspired |
122
+
123
+ ## Roadmap
124
+
125
+ - [ ] v0.1.0 - MVP with basic page-flip and Markdown support
126
+ - [ ] v0.2.0 - Mermaid diagrams and code highlighting
127
+ - [ ] v0.3.0 - CLI for static site generation
128
+ - [ ] v0.4.0 - Theme customization and plugins
129
+
130
+ ## Documentation
131
+
132
+ - [Architecture & Design Decisions](docs/ARCHITECTURE.md)
133
+ - [Glossary of Terms](docs/GLOSSARY.md)
134
+ - [Contributing Guide](CONTRIBUTING.md)
135
+
136
+ ## Requirements
137
+
138
+ - Node.js 22+
139
+ - React 19+
140
+
141
+ ## License
142
+
143
+ MIT License. See [LICENSE](LICENSE) for details.
144
+
145
+ ## Inspiration
146
+
147
+ - Ancient grimoires and magical tomes
148
+ - Vintage technical manuals
149
+ - React component libraries
@@ -0,0 +1,504 @@
1
+ import ae, { forwardRef as B, createElement as S, useState as se } from "react";
2
+ var j = { exports: {} }, k = {};
3
+ var z;
4
+ function le() {
5
+ if (z) return k;
6
+ z = 1;
7
+ var t = Symbol.for("react.transitional.element"), a = Symbol.for("react.fragment");
8
+ function u(c, o, l) {
9
+ var m = null;
10
+ if (l !== void 0 && (m = "" + l), o.key !== void 0 && (m = "" + o.key), "key" in o) {
11
+ l = {};
12
+ for (var p in o)
13
+ p !== "key" && (l[p] = o[p]);
14
+ } else l = o;
15
+ return o = l.ref, {
16
+ $$typeof: t,
17
+ type: c,
18
+ key: m,
19
+ ref: o !== void 0 ? o : null,
20
+ props: l
21
+ };
22
+ }
23
+ return k.Fragment = a, k.jsx = u, k.jsxs = u, k;
24
+ }
25
+ var y = {};
26
+ var U;
27
+ function ie() {
28
+ return U || (U = 1, process.env.NODE_ENV !== "production" && (function() {
29
+ function t(e) {
30
+ if (e == null) return null;
31
+ if (typeof e == "function")
32
+ return e.$$typeof === te ? null : e.displayName || e.name || null;
33
+ if (typeof e == "string") return e;
34
+ switch (e) {
35
+ case h:
36
+ return "Fragment";
37
+ case X:
38
+ return "Profiler";
39
+ case J:
40
+ return "StrictMode";
41
+ case K:
42
+ return "Suspense";
43
+ case Q:
44
+ return "SuspenseList";
45
+ case re:
46
+ return "Activity";
47
+ }
48
+ if (typeof e == "object")
49
+ switch (typeof e.tag == "number" && console.error(
50
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
51
+ ), e.$$typeof) {
52
+ case T:
53
+ return "Portal";
54
+ case Z:
55
+ return e.displayName || "Context";
56
+ case G:
57
+ return (e._context.displayName || "Context") + ".Consumer";
58
+ case H:
59
+ var r = e.render;
60
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
61
+ case ee:
62
+ return r = e.displayName || null, r !== null ? r : t(e.type) || "Memo";
63
+ case N:
64
+ r = e._payload, e = e._init;
65
+ try {
66
+ return t(e(r));
67
+ } catch {
68
+ }
69
+ }
70
+ return null;
71
+ }
72
+ function a(e) {
73
+ return "" + e;
74
+ }
75
+ function u(e) {
76
+ try {
77
+ a(e);
78
+ var r = !1;
79
+ } catch {
80
+ r = !0;
81
+ }
82
+ if (r) {
83
+ r = console;
84
+ var s = r.error, d = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
85
+ return s.call(
86
+ r,
87
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
88
+ d
89
+ ), a(e);
90
+ }
91
+ }
92
+ function c(e) {
93
+ if (e === h) return "<>";
94
+ if (typeof e == "object" && e !== null && e.$$typeof === N)
95
+ return "<...>";
96
+ try {
97
+ var r = t(e);
98
+ return r ? "<" + r + ">" : "<...>";
99
+ } catch {
100
+ return "<...>";
101
+ }
102
+ }
103
+ function o() {
104
+ var e = C.A;
105
+ return e === null ? null : e.getOwner();
106
+ }
107
+ function l() {
108
+ return Error("react-stack-top-frame");
109
+ }
110
+ function m(e) {
111
+ if (F.call(e, "key")) {
112
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
113
+ if (r && r.isReactWarning) return !1;
114
+ }
115
+ return e.key !== void 0;
116
+ }
117
+ function p(e, r) {
118
+ function s() {
119
+ $ || ($ = !0, console.error(
120
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
121
+ r
122
+ ));
123
+ }
124
+ s.isReactWarning = !0, Object.defineProperty(e, "key", {
125
+ get: s,
126
+ configurable: !0
127
+ });
128
+ }
129
+ function x() {
130
+ var e = t(this.type);
131
+ return Y[e] || (Y[e] = !0, console.error(
132
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
133
+ )), e = this.props.ref, e !== void 0 ? e : null;
134
+ }
135
+ function g(e, r, s, d, R, A) {
136
+ var f = s.ref;
137
+ return e = {
138
+ $$typeof: E,
139
+ type: e,
140
+ key: r,
141
+ props: s,
142
+ _owner: d
143
+ }, (f !== void 0 ? f : null) !== null ? Object.defineProperty(e, "ref", {
144
+ enumerable: !1,
145
+ get: x
146
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
147
+ configurable: !1,
148
+ enumerable: !1,
149
+ writable: !0,
150
+ value: 0
151
+ }), Object.defineProperty(e, "_debugInfo", {
152
+ configurable: !1,
153
+ enumerable: !1,
154
+ writable: !0,
155
+ value: null
156
+ }), Object.defineProperty(e, "_debugStack", {
157
+ configurable: !1,
158
+ enumerable: !1,
159
+ writable: !0,
160
+ value: R
161
+ }), Object.defineProperty(e, "_debugTask", {
162
+ configurable: !1,
163
+ enumerable: !1,
164
+ writable: !0,
165
+ value: A
166
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
167
+ }
168
+ function i(e, r, s, d, R, A) {
169
+ var f = r.children;
170
+ if (f !== void 0)
171
+ if (d)
172
+ if (oe(f)) {
173
+ for (d = 0; d < f.length; d++)
174
+ b(f[d]);
175
+ Object.freeze && Object.freeze(f);
176
+ } else
177
+ console.error(
178
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
179
+ );
180
+ else b(f);
181
+ if (F.call(r, "key")) {
182
+ f = t(e);
183
+ var _ = Object.keys(r).filter(function(ne) {
184
+ return ne !== "key";
185
+ });
186
+ d = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", L[f + d] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ `A props object containing a "key" prop is being spread into JSX:
188
+ let props = %s;
189
+ <%s {...props} />
190
+ React keys must be passed directly to JSX without using spread:
191
+ let props = %s;
192
+ <%s key={someKey} {...props} />`,
193
+ d,
194
+ f,
195
+ _,
196
+ f
197
+ ), L[f + d] = !0);
198
+ }
199
+ if (f = null, s !== void 0 && (u(s), f = "" + s), m(r) && (u(r.key), f = "" + r.key), "key" in r) {
200
+ s = {};
201
+ for (var O in r)
202
+ O !== "key" && (s[O] = r[O]);
203
+ } else s = r;
204
+ return f && p(
205
+ s,
206
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
207
+ ), g(
208
+ e,
209
+ f,
210
+ s,
211
+ o(),
212
+ R,
213
+ A
214
+ );
215
+ }
216
+ function b(e) {
217
+ v(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === N && (e._payload.status === "fulfilled" ? v(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
218
+ }
219
+ function v(e) {
220
+ return typeof e == "object" && e !== null && e.$$typeof === E;
221
+ }
222
+ var w = ae, E = Symbol.for("react.transitional.element"), T = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), J = Symbol.for("react.strict_mode"), X = Symbol.for("react.profiler"), G = Symbol.for("react.consumer"), Z = Symbol.for("react.context"), H = Symbol.for("react.forward_ref"), K = Symbol.for("react.suspense"), Q = Symbol.for("react.suspense_list"), ee = Symbol.for("react.memo"), N = Symbol.for("react.lazy"), re = Symbol.for("react.activity"), te = Symbol.for("react.client.reference"), C = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, F = Object.prototype.hasOwnProperty, oe = Array.isArray, P = console.createTask ? console.createTask : function() {
223
+ return null;
224
+ };
225
+ w = {
226
+ react_stack_bottom_frame: function(e) {
227
+ return e();
228
+ }
229
+ };
230
+ var $, Y = {}, I = w.react_stack_bottom_frame.bind(
231
+ w,
232
+ l
233
+ )(), D = P(c(l)), L = {};
234
+ y.Fragment = h, y.jsx = function(e, r, s) {
235
+ var d = 1e4 > C.recentlyCreatedOwnerStacks++;
236
+ return i(
237
+ e,
238
+ r,
239
+ s,
240
+ !1,
241
+ d ? Error("react-stack-top-frame") : I,
242
+ d ? P(c(e)) : D
243
+ );
244
+ }, y.jsxs = function(e, r, s) {
245
+ var d = 1e4 > C.recentlyCreatedOwnerStacks++;
246
+ return i(
247
+ e,
248
+ r,
249
+ s,
250
+ !0,
251
+ d ? Error("react-stack-top-frame") : I,
252
+ d ? P(c(e)) : D
253
+ );
254
+ };
255
+ })()), y;
256
+ }
257
+ var W;
258
+ function ce() {
259
+ return W || (W = 1, process.env.NODE_ENV === "production" ? j.exports = le() : j.exports = ie()), j.exports;
260
+ }
261
+ var n = ce();
262
+ const ue = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), de = (t) => t.replace(
263
+ /^([A-Z])|[\s-_]+(\w)/g,
264
+ (a, u, c) => c ? c.toUpperCase() : u.toLowerCase()
265
+ ), M = (t) => {
266
+ const a = de(t);
267
+ return a.charAt(0).toUpperCase() + a.slice(1);
268
+ }, q = (...t) => t.filter((a, u, c) => !!a && a.trim() !== "" && c.indexOf(a) === u).join(" ").trim(), fe = (t) => {
269
+ for (const a in t)
270
+ if (a.startsWith("aria-") || a === "role" || a === "title")
271
+ return !0;
272
+ };
273
+ var be = {
274
+ xmlns: "http://www.w3.org/2000/svg",
275
+ width: 24,
276
+ height: 24,
277
+ viewBox: "0 0 24 24",
278
+ fill: "none",
279
+ stroke: "currentColor",
280
+ strokeWidth: 2,
281
+ strokeLinecap: "round",
282
+ strokeLinejoin: "round"
283
+ };
284
+ const me = B(
285
+ ({
286
+ color: t = "currentColor",
287
+ size: a = 24,
288
+ strokeWidth: u = 2,
289
+ absoluteStrokeWidth: c,
290
+ className: o = "",
291
+ children: l,
292
+ iconNode: m,
293
+ ...p
294
+ }, x) => S(
295
+ "svg",
296
+ {
297
+ ref: x,
298
+ ...be,
299
+ width: a,
300
+ height: a,
301
+ stroke: t,
302
+ strokeWidth: c ? Number(u) * 24 / Number(a) : u,
303
+ className: q("lucide", o),
304
+ ...!l && !fe(p) && { "aria-hidden": "true" },
305
+ ...p
306
+ },
307
+ [
308
+ ...m.map(([g, i]) => S(g, i)),
309
+ ...Array.isArray(l) ? l : [l]
310
+ ]
311
+ )
312
+ );
313
+ const V = (t, a) => {
314
+ const u = B(
315
+ ({ className: c, ...o }, l) => S(me, {
316
+ ref: l,
317
+ iconNode: a,
318
+ className: q(
319
+ `lucide-${ue(M(t))}`,
320
+ `lucide-${t}`,
321
+ c
322
+ ),
323
+ ...o
324
+ })
325
+ );
326
+ return u.displayName = M(t), u;
327
+ };
328
+ const pe = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], ve = V("chevron-right", pe);
329
+ const he = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]], xe = V("chevron-left", he);
330
+ function Ee({
331
+ pages: t,
332
+ initialPage: a = 0,
333
+ className: u = "",
334
+ onPageChange: c
335
+ }) {
336
+ const [o, l] = se(a), m = t.length, p = () => {
337
+ if (o < m) {
338
+ const i = o + 1;
339
+ l(i), c?.(i);
340
+ }
341
+ }, x = () => {
342
+ if (o > 0) {
343
+ const i = o - 1;
344
+ l(i), c?.(i);
345
+ }
346
+ }, g = (i) => {
347
+ l(i), c?.(i);
348
+ };
349
+ return /* @__PURE__ */ n.jsxs(
350
+ "div",
351
+ {
352
+ className: `folio-container w-full h-screen flex flex-col items-center justify-center overflow-hidden relative ${u}`,
353
+ style: { backgroundColor: "#251612" },
354
+ children: [
355
+ /* @__PURE__ */ n.jsx("div", { className: "absolute inset-0 pointer-events-none opacity-20 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-black via-[#1a0f0c] to-[#0f0806]" }),
356
+ /* @__PURE__ */ n.jsx("div", { className: "relative w-full max-w-5xl aspect-[1.4/1] md:aspect-[2/1] flex items-center justify-center p-4 md:p-12 perspective-2000", children: /* @__PURE__ */ n.jsxs("div", { className: "relative w-full h-full transform-style-3d shadow-2xl bg-[#2a1810] rounded-lg", children: [
357
+ /* @__PURE__ */ n.jsx(we, {}),
358
+ t.map((i, b) => {
359
+ const v = b < o, w = v ? b : m - b, E = () => {
360
+ !v && b === o && p(), v && b === o - 1 && x();
361
+ }, T = (h) => {
362
+ (h.key === "Enter" || h.key === " ") && (h.preventDefault(), E());
363
+ };
364
+ return /* @__PURE__ */ n.jsxs(
365
+ "button",
366
+ {
367
+ type: "button",
368
+ "aria-label": `Page ${b + 1}: ${i.title}`,
369
+ className: "absolute inset-0 w-1/2 h-full left-1/2 origin-left transition-transform duration-700 ease-in-out transform-style-3d cursor-pointer appearance-none border-none bg-transparent p-0 text-left",
370
+ style: {
371
+ zIndex: w,
372
+ transform: v ? "rotateY(-180deg)" : "rotateY(0deg)"
373
+ },
374
+ onClick: E,
375
+ onKeyDown: T,
376
+ children: [
377
+ /* @__PURE__ */ n.jsxs(
378
+ "div",
379
+ {
380
+ className: "absolute inset-0 w-full h-full backface-hidden rounded-r-lg shadow-inner overflow-hidden border-l border-stone-200",
381
+ style: { backgroundColor: "#FDF6E3" },
382
+ children: [
383
+ i.front,
384
+ /* @__PURE__ */ n.jsx("div", { className: "absolute bottom-4 right-4 text-[10px] font-mono text-stone-400", children: b * 2 + 1 }),
385
+ /* @__PURE__ */ n.jsx("div", { className: "absolute inset-y-0 left-0 w-8 bg-gradient-to-r from-black/20 to-transparent pointer-events-none" })
386
+ ]
387
+ }
388
+ ),
389
+ /* @__PURE__ */ n.jsxs(
390
+ "div",
391
+ {
392
+ className: "absolute inset-0 w-full h-full backface-hidden rounded-l-lg shadow-inner overflow-hidden border-r border-stone-200",
393
+ style: {
394
+ backgroundColor: "#FDF6E3",
395
+ transform: "rotateY(180deg)"
396
+ },
397
+ children: [
398
+ i.back,
399
+ /* @__PURE__ */ n.jsx("div", { className: "absolute bottom-4 left-4 text-[10px] font-mono text-stone-400", children: b * 2 + 2 }),
400
+ /* @__PURE__ */ n.jsx("div", { className: "absolute inset-y-0 right-0 w-8 bg-gradient-to-l from-black/20 to-transparent pointer-events-none" })
401
+ ]
402
+ }
403
+ )
404
+ ]
405
+ },
406
+ i.id
407
+ );
408
+ }),
409
+ t.map((i, b) => /* @__PURE__ */ n.jsx(
410
+ _e,
411
+ {
412
+ page: i,
413
+ index: b,
414
+ activeIndex: o,
415
+ onClick: () => g(b)
416
+ },
417
+ i.id
418
+ )),
419
+ /* @__PURE__ */ n.jsx("div", { className: "absolute inset-0 rounded-lg shadow-[0_20px_50px_rgba(0,0,0,0.5)] -z-10 bg-[#2a1810]" })
420
+ ] }) }),
421
+ /* @__PURE__ */ n.jsxs("div", { className: "absolute bottom-8 flex gap-8 z-50", children: [
422
+ /* @__PURE__ */ n.jsx(
423
+ "button",
424
+ {
425
+ type: "button",
426
+ onClick: x,
427
+ disabled: o === 0,
428
+ className: "bg-[#00B0FF] hover:bg-[#40C4FF] disabled:bg-stone-700 disabled:opacity-50 disabled:cursor-not-allowed text-white p-4 rounded-xl shadow-[0_4px_0_#0080B0] active:shadow-none active:translate-y-1 transition-all",
429
+ children: /* @__PURE__ */ n.jsx(xe, { size: 24 })
430
+ }
431
+ ),
432
+ /* @__PURE__ */ n.jsxs("div", { className: "px-6 py-4 bg-stone-800/80 backdrop-blur rounded-xl text-white font-mono text-sm border border-stone-700 flex flex-col items-center", children: [
433
+ /* @__PURE__ */ n.jsx("span", { className: "text-[10px] text-stone-400 mb-1", children: "CURRENT SECTION" }),
434
+ /* @__PURE__ */ n.jsx("span", { className: "font-bold text-[#00B0FF]", children: o < m ? t[o]?.title ?? "Untitled" : "End" })
435
+ ] }),
436
+ /* @__PURE__ */ n.jsx(
437
+ "button",
438
+ {
439
+ type: "button",
440
+ onClick: p,
441
+ disabled: o === m,
442
+ className: "bg-[#00B0FF] hover:bg-[#40C4FF] disabled:bg-stone-700 disabled:opacity-50 disabled:cursor-not-allowed text-white p-4 rounded-xl shadow-[0_4px_0_#0080B0] active:shadow-none active:translate-y-1 transition-all",
443
+ children: /* @__PURE__ */ n.jsx(ve, { size: 24 })
444
+ }
445
+ )
446
+ ] }),
447
+ /* @__PURE__ */ n.jsx("style", { children: `
448
+ .perspective-2000 {
449
+ perspective: 2000px;
450
+ }
451
+ .transform-style-3d {
452
+ transform-style: preserve-3d;
453
+ }
454
+ .backface-hidden {
455
+ backface-visibility: hidden;
456
+ -webkit-backface-visibility: hidden;
457
+ }
458
+ .scrollbar-thin::-webkit-scrollbar {
459
+ width: 4px;
460
+ }
461
+ .scrollbar-thin::-webkit-scrollbar-track {
462
+ background: transparent;
463
+ }
464
+ .scrollbar-thin::-webkit-scrollbar-thumb {
465
+ background-color: #d6d3d1;
466
+ border-radius: 20px;
467
+ }
468
+ ` })
469
+ ]
470
+ }
471
+ );
472
+ }
473
+ function we() {
474
+ return /* @__PURE__ */ n.jsx("div", { className: "absolute left-1/2 top-0 bottom-0 w-8 -ml-4 z-50 flex flex-col justify-evenly py-8 pointer-events-none", children: [1, 2, 3].map((t) => /* @__PURE__ */ n.jsxs("div", { className: "relative w-full h-8", children: [
475
+ /* @__PURE__ */ n.jsx("div", { className: "absolute top-1/2 left-1/2 -ml-6 -mt-4 w-12 h-8 rounded-full border-4 border-stone-400 shadow-md transform rotate-12" }),
476
+ /* @__PURE__ */ n.jsx("div", { className: "absolute top-1/2 left-0 w-3 h-3 bg-[#251612] rounded-full -mt-1.5 ml-1 shadow-inner" }),
477
+ /* @__PURE__ */ n.jsx("div", { className: "absolute top-1/2 right-0 w-3 h-3 bg-[#251612] rounded-full -mt-1.5 mr-1 shadow-inner" })
478
+ ] }, t)) });
479
+ }
480
+ function _e({ page: t, index: a, activeIndex: u, onClick: c }) {
481
+ const o = a < u;
482
+ return /* @__PURE__ */ n.jsx(
483
+ "button",
484
+ {
485
+ type: "button",
486
+ onClick: c,
487
+ className: "absolute right-0 w-8 md:w-10 h-16 rounded-r-lg flex items-center justify-center text-[10px] font-bold tracking-widest cursor-pointer transition-all duration-500 hover:w-12 shadow-md border-l border-black/10 z-0",
488
+ style: {
489
+ top: `${80 + a * 70}px`,
490
+ backgroundColor: t.tabColor || "#E0E0E0",
491
+ color: "#2c1a16",
492
+ writingMode: "vertical-rl",
493
+ textOrientation: "mixed",
494
+ transform: o ? "translateX(-20px) scale(0.9)" : "translateX(100%)",
495
+ opacity: o ? 0 : 1,
496
+ zIndex: 100 - a
497
+ },
498
+ children: t.tabLabel || t.id
499
+ }
500
+ );
501
+ }
502
+ export {
503
+ Ee as BookViewer
504
+ };
@@ -0,0 +1,27 @@
1
+ (function(v,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],p):(v=typeof globalThis<"u"?globalThis:v||self,p(v.Grimoire3D={},v.React))})(this,(function(v,p){"use strict";var T={exports:{}},k={};var Y;function G(){if(Y)return k;Y=1;var r=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function u(c,o,l){var m=null;if(l!==void 0&&(m=""+l),o.key!==void 0&&(m=""+o.key),"key"in o){l={};for(var h in o)h!=="key"&&(l[h]=o[h])}else l=o;return o=l.ref,{$$typeof:r,type:c,key:m,ref:o!==void 0?o:null,props:l}}return k.Fragment=a,k.jsx=u,k.jsxs=u,k}var y={};var I;function X(){return I||(I=1,process.env.NODE_ENV!=="production"&&(function(){function r(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===pe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case le:return"Profiler";case se:return"StrictMode";case de:return"Suspense";case fe:return"SuspenseList";case me:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case C:return"Portal";case ce:return e.displayName||"Context";case ie:return(e._context.displayName||"Context")+".Consumer";case ue:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case be:return t=e.displayName||null,t!==null?t:r(e.type)||"Memo";case P:t=e._payload,e=e._init;try{return r(e(t))}catch{}}return null}function a(e){return""+e}function u(e){try{a(e);var t=!1}catch{t=!0}if(t){t=console;var s=t.error,d=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return s.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",d),a(e)}}function c(e){if(e===w)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===P)return"<...>";try{var t=r(e);return t?"<"+t+">":"<...>"}catch{return"<...>"}}function o(){var e=A.A;return e===null?null:e.getOwner()}function l(){return Error("react-stack-top-frame")}function m(e){if(M.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function h(e,t){function s(){W||(W=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}s.isReactWarning=!0,Object.defineProperty(e,"key",{get:s,configurable:!0})}function _(){var e=r(this.type);return $[e]||($[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function R(e,t,s,d,N,S){var f=s.ref;return e={$$typeof:j,type:e,key:t,props:s,_owner:d},(f!==void 0?f:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:_}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:N}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:S}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function i(e,t,s,d,N,S){var f=t.children;if(f!==void 0)if(d)if(he(f)){for(d=0;d<f.length;d++)b(f[d]);Object.freeze&&Object.freeze(f)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b(f);if(M.call(t,"key")){f=r(e);var g=Object.keys(t).filter(function(ve){return ve!=="key"});d=0<g.length?"{key: someKey, "+g.join(": ..., ")+": ...}":"{key: someKey}",J[f+d]||(g=0<g.length?"{"+g.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,d,f,g,f),J[f+d]=!0)}if(f=null,s!==void 0&&(u(s),f=""+s),m(t)&&(u(t.key),f=""+t.key),"key"in t){s={};for(var F in t)F!=="key"&&(s[F]=t[F])}else s=t;return f&&h(s,typeof e=="function"?e.displayName||e.name||"Unknown":e),R(e,f,s,o(),N,S)}function b(e){x(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===P&&(e._payload.status==="fulfilled"?x(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function x(e){return typeof e=="object"&&e!==null&&e.$$typeof===j}var E=p,j=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),se=Symbol.for("react.strict_mode"),le=Symbol.for("react.profiler"),ie=Symbol.for("react.consumer"),ce=Symbol.for("react.context"),ue=Symbol.for("react.forward_ref"),de=Symbol.for("react.suspense"),fe=Symbol.for("react.suspense_list"),be=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),me=Symbol.for("react.activity"),pe=Symbol.for("react.client.reference"),A=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=Object.prototype.hasOwnProperty,he=Array.isArray,O=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(e){return e()}};var W,$={},B=E.react_stack_bottom_frame.bind(E,l)(),V=O(c(l)),J={};y.Fragment=w,y.jsx=function(e,t,s){var d=1e4>A.recentlyCreatedOwnerStacks++;return i(e,t,s,!1,d?Error("react-stack-top-frame"):B,d?O(c(e)):V)},y.jsxs=function(e,t,s){var d=1e4>A.recentlyCreatedOwnerStacks++;return i(e,t,s,!0,d?Error("react-stack-top-frame"):B,d?O(c(e)):V)}})()),y}var D;function Z(){return D||(D=1,process.env.NODE_ENV==="production"?T.exports=G():T.exports=X()),T.exports}var n=Z();const q=r=>r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),H=r=>r.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,u,c)=>c?c.toUpperCase():u.toLowerCase()),L=r=>{const a=H(r);return a.charAt(0).toUpperCase()+a.slice(1)},z=(...r)=>r.filter((a,u,c)=>!!a&&a.trim()!==""&&c.indexOf(a)===u).join(" ").trim(),K=r=>{for(const a in r)if(a.startsWith("aria-")||a==="role"||a==="title")return!0};var Q={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ee=p.forwardRef(({color:r="currentColor",size:a=24,strokeWidth:u=2,absoluteStrokeWidth:c,className:o="",children:l,iconNode:m,...h},_)=>p.createElement("svg",{ref:_,...Q,width:a,height:a,stroke:r,strokeWidth:c?Number(u)*24/Number(a):u,className:z("lucide",o),...!l&&!K(h)&&{"aria-hidden":"true"},...h},[...m.map(([R,i])=>p.createElement(R,i)),...Array.isArray(l)?l:[l]]));const U=(r,a)=>{const u=p.forwardRef(({className:c,...o},l)=>p.createElement(ee,{ref:l,iconNode:a,className:z(`lucide-${q(L(r))}`,`lucide-${r}`,c),...o}));return u.displayName=L(r),u};const te=U("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const re=U("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);function oe({pages:r,initialPage:a=0,className:u="",onPageChange:c}){const[o,l]=p.useState(a),m=r.length,h=()=>{if(o<m){const i=o+1;l(i),c?.(i)}},_=()=>{if(o>0){const i=o-1;l(i),c?.(i)}},R=i=>{l(i),c?.(i)};return n.jsxs("div",{className:`folio-container w-full h-screen flex flex-col items-center justify-center overflow-hidden relative ${u}`,style:{backgroundColor:"#251612"},children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none opacity-20 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-black via-[#1a0f0c] to-[#0f0806]"}),n.jsx("div",{className:"relative w-full max-w-5xl aspect-[1.4/1] md:aspect-[2/1] flex items-center justify-center p-4 md:p-12 perspective-2000",children:n.jsxs("div",{className:"relative w-full h-full transform-style-3d shadow-2xl bg-[#2a1810] rounded-lg",children:[n.jsx(ne,{}),r.map((i,b)=>{const x=b<o,E=x?b:m-b,j=()=>{!x&&b===o&&h(),x&&b===o-1&&_()},C=w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),j())};return n.jsxs("button",{type:"button","aria-label":`Page ${b+1}: ${i.title}`,className:"absolute inset-0 w-1/2 h-full left-1/2 origin-left transition-transform duration-700 ease-in-out transform-style-3d cursor-pointer appearance-none border-none bg-transparent p-0 text-left",style:{zIndex:E,transform:x?"rotateY(-180deg)":"rotateY(0deg)"},onClick:j,onKeyDown:C,children:[n.jsxs("div",{className:"absolute inset-0 w-full h-full backface-hidden rounded-r-lg shadow-inner overflow-hidden border-l border-stone-200",style:{backgroundColor:"#FDF6E3"},children:[i.front,n.jsx("div",{className:"absolute bottom-4 right-4 text-[10px] font-mono text-stone-400",children:b*2+1}),n.jsx("div",{className:"absolute inset-y-0 left-0 w-8 bg-gradient-to-r from-black/20 to-transparent pointer-events-none"})]}),n.jsxs("div",{className:"absolute inset-0 w-full h-full backface-hidden rounded-l-lg shadow-inner overflow-hidden border-r border-stone-200",style:{backgroundColor:"#FDF6E3",transform:"rotateY(180deg)"},children:[i.back,n.jsx("div",{className:"absolute bottom-4 left-4 text-[10px] font-mono text-stone-400",children:b*2+2}),n.jsx("div",{className:"absolute inset-y-0 right-0 w-8 bg-gradient-to-l from-black/20 to-transparent pointer-events-none"})]})]},i.id)}),r.map((i,b)=>n.jsx(ae,{page:i,index:b,activeIndex:o,onClick:()=>R(b)},i.id)),n.jsx("div",{className:"absolute inset-0 rounded-lg shadow-[0_20px_50px_rgba(0,0,0,0.5)] -z-10 bg-[#2a1810]"})]})}),n.jsxs("div",{className:"absolute bottom-8 flex gap-8 z-50",children:[n.jsx("button",{type:"button",onClick:_,disabled:o===0,className:"bg-[#00B0FF] hover:bg-[#40C4FF] disabled:bg-stone-700 disabled:opacity-50 disabled:cursor-not-allowed text-white p-4 rounded-xl shadow-[0_4px_0_#0080B0] active:shadow-none active:translate-y-1 transition-all",children:n.jsx(re,{size:24})}),n.jsxs("div",{className:"px-6 py-4 bg-stone-800/80 backdrop-blur rounded-xl text-white font-mono text-sm border border-stone-700 flex flex-col items-center",children:[n.jsx("span",{className:"text-[10px] text-stone-400 mb-1",children:"CURRENT SECTION"}),n.jsx("span",{className:"font-bold text-[#00B0FF]",children:o<m?r[o]?.title??"Untitled":"End"})]}),n.jsx("button",{type:"button",onClick:h,disabled:o===m,className:"bg-[#00B0FF] hover:bg-[#40C4FF] disabled:bg-stone-700 disabled:opacity-50 disabled:cursor-not-allowed text-white p-4 rounded-xl shadow-[0_4px_0_#0080B0] active:shadow-none active:translate-y-1 transition-all",children:n.jsx(te,{size:24})})]}),n.jsx("style",{children:`
7
+ .perspective-2000 {
8
+ perspective: 2000px;
9
+ }
10
+ .transform-style-3d {
11
+ transform-style: preserve-3d;
12
+ }
13
+ .backface-hidden {
14
+ backface-visibility: hidden;
15
+ -webkit-backface-visibility: hidden;
16
+ }
17
+ .scrollbar-thin::-webkit-scrollbar {
18
+ width: 4px;
19
+ }
20
+ .scrollbar-thin::-webkit-scrollbar-track {
21
+ background: transparent;
22
+ }
23
+ .scrollbar-thin::-webkit-scrollbar-thumb {
24
+ background-color: #d6d3d1;
25
+ border-radius: 20px;
26
+ }
27
+ `})]})}function ne(){return n.jsx("div",{className:"absolute left-1/2 top-0 bottom-0 w-8 -ml-4 z-50 flex flex-col justify-evenly py-8 pointer-events-none",children:[1,2,3].map(r=>n.jsxs("div",{className:"relative w-full h-8",children:[n.jsx("div",{className:"absolute top-1/2 left-1/2 -ml-6 -mt-4 w-12 h-8 rounded-full border-4 border-stone-400 shadow-md transform rotate-12"}),n.jsx("div",{className:"absolute top-1/2 left-0 w-3 h-3 bg-[#251612] rounded-full -mt-1.5 ml-1 shadow-inner"}),n.jsx("div",{className:"absolute top-1/2 right-0 w-3 h-3 bg-[#251612] rounded-full -mt-1.5 mr-1 shadow-inner"})]},r))})}function ae({page:r,index:a,activeIndex:u,onClick:c}){const o=a<u;return n.jsx("button",{type:"button",onClick:c,className:"absolute right-0 w-8 md:w-10 h-16 rounded-r-lg flex items-center justify-center text-[10px] font-bold tracking-widest cursor-pointer transition-all duration-500 hover:w-12 shadow-md border-l border-black/10 z-0",style:{top:`${80+a*70}px`,backgroundColor:r.tabColor||"#E0E0E0",color:"#2c1a16",writingMode:"vertical-rl",textOrientation:"mixed",transform:o?"translateX(-20px) scale(0.9)":"translateX(100%)",opacity:o?0:1,zIndex:100-a},children:r.tabLabel||r.id})}v.BookViewer=oe,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "grimoire3d",
3
+ "version": "0.0.0",
4
+ "description": "3D magical book documentation generator - Transform your docs into an interactive grimoire",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./components": {
15
+ "types": "./dist/components/index.d.ts",
16
+ "import": "./dist/components/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "templates"
22
+ ],
23
+ "scripts": {
24
+ "dev": "vite",
25
+ "build": "tsc && vite build",
26
+ "preview": "vite preview",
27
+ "lint": "biome lint src",
28
+ "lint:fix": "biome lint --write src",
29
+ "format": "biome format --write src",
30
+ "format:check": "biome format src",
31
+ "check": "biome check src",
32
+ "check:fix": "biome check --write src",
33
+ "typecheck": "tsc --noEmit",
34
+ "test": "vitest",
35
+ "test:coverage": "vitest --coverage",
36
+ "prepare": "husky"
37
+ },
38
+ "keywords": [
39
+ "documentation",
40
+ "docs",
41
+ "static-site-generator",
42
+ "markdown",
43
+ "mermaid",
44
+ "page-flip",
45
+ "book",
46
+ "react",
47
+ "3d",
48
+ "grimoire",
49
+ "webgl"
50
+ ],
51
+ "author": "kkm-horikawa",
52
+ "license": "MIT",
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/kkm-horikawa/grimoire3d.git"
56
+ },
57
+ "bugs": {
58
+ "url": "https://github.com/kkm-horikawa/grimoire3d/issues"
59
+ },
60
+ "homepage": "https://github.com/kkm-horikawa/grimoire3d#readme",
61
+ "engines": {
62
+ "node": ">=22.0.0"
63
+ },
64
+ "peerDependencies": {
65
+ "react": "^19.0.0",
66
+ "react-dom": "^19.0.0"
67
+ },
68
+ "dependencies": {
69
+ "lucide-react": "^0.555.0"
70
+ },
71
+ "devDependencies": {
72
+ "react": "^19.0.0",
73
+ "react-dom": "^19.0.0",
74
+ "@biomejs/biome": "^2.0.0",
75
+ "@tailwindcss/vite": "^4.1.13",
76
+ "@testing-library/dom": "^10.0.0",
77
+ "@testing-library/jest-dom": "^6.6.3",
78
+ "@testing-library/react": "^16.3.0",
79
+ "@types/node": "^22.10.0",
80
+ "@types/react": "^19.0.0",
81
+ "@types/react-dom": "^19.0.0",
82
+ "@vitejs/plugin-react": "^4.3.4",
83
+ "husky": "^9.1.7",
84
+ "jsdom": "^26.0.0",
85
+ "lint-staged": "^15.2.10",
86
+ "tailwindcss": "^4.1.13",
87
+ "typescript": "^5.9.0",
88
+ "vite": "^7.0.0",
89
+ "vitest": "^4.0.0"
90
+ },
91
+ "lint-staged": {
92
+ "*.{ts,tsx,js,jsx,json}": [
93
+ "biome check --write"
94
+ ]
95
+ }
96
+ }