booary 3.0.2 → 5.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/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>testpreact</title>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
package/package.json CHANGED
@@ -1,59 +1,27 @@
1
1
  {
2
2
  "name": "booary",
3
- "version": "3.0.2",
3
+ "private": false,
4
+ "version": "5.0.0",
4
5
  "type": "module",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
- "bin": {
9
- "booary": "./dist/cli.js"
10
- },
11
- "files": [
12
- "dist"
13
- ],
14
- "exports": {
15
- ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js",
18
- "require": "./dist/index.cjs"
19
- }
20
- },
21
- "peerDependencies": {
22
- "react": ">=18",
23
- "react-dom": ">=18"
24
- },
25
6
  "dependencies": {
26
- "@tailwindcss/vite": "^4.1.18",
7
+ "@types/fs-extra": "^11.0.4",
27
8
  "axios": "^1.13.5",
28
9
  "fs-extra": "^11.3.3",
29
- "inquirer": "^13.2.2",
30
- "tailwindcss": "^4.1.18"
10
+ "inquirer": "^13.2.5",
11
+ "preact": "^10.27.2",
12
+ "preact-custom-element": "^4.6.0"
31
13
  },
32
14
  "devDependencies": {
33
- "@eslint/js": "^9.39.1",
34
- "@types/axios": "^0.14.4",
35
- "@types/fs-extra": "^11.0.4",
36
- "@types/inquirer": "^9.0.9",
15
+ "@preact/preset-vite": "^2.10.2",
37
16
  "@types/node": "^24.10.1",
38
- "@types/react": "^19.2.7",
39
- "@types/react-dom": "^19.2.3",
40
- "@vitejs/plugin-react": "^5.1.1",
41
- "babel-plugin-react-compiler": "^1.0.0",
42
- "eslint": "^9.39.1",
43
- "eslint-plugin-react-hooks": "^7.0.1",
44
- "eslint-plugin-react-refresh": "^0.4.24",
45
- "globals": "^16.5.0",
46
17
  "tsup": "^8.5.1",
47
- "tsx": "^4.21.0",
48
18
  "typescript": "~5.9.3",
49
- "typescript-eslint": "^8.48.0",
50
- "vite": "^8.0.0-beta.13"
19
+ "vite": "^7.3.1"
51
20
  },
52
21
  "scripts": {
53
22
  "dev": "vite",
54
23
  "build": "tsup",
55
- "lint": "eslint .",
56
24
  "preview": "vite preview",
57
- "cli": "tsx scripts/add-book.ts"
25
+ "cli": "node scripts/add-book.ts"
58
26
  }
59
27
  }
@@ -0,0 +1,21 @@
1
+ {
2
+ "borrower": "Joshua",
3
+ "library": {
4
+ "name": "Boo Library",
5
+ "signature": "🐾"
6
+ },
7
+ "books": [
8
+ {
9
+ "key": "/works/OL27448W",
10
+ "name": "The Lord of the Rings",
11
+ "author": "J.R.R. Tolkien",
12
+ "finishedDate": "18/2/2026"
13
+ },
14
+ {
15
+ "key": "/works/OL266178W",
16
+ "name": "Het Achterhuis",
17
+ "author": "Anne Frank",
18
+ "finishedDate": "18/2/2026"
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,16 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title>Web Component Test</title>
6
+ <script src="./dist/index.global.js"></script>
7
+ <link rel="stylesheet" href="./dist/index.css" />
8
+ </head>
9
+ <body>
10
+ <x-library-card
11
+ cardlink="/library/card.json"
12
+ friends='["http://localhost:5174/library/card.json"]'
13
+ >
14
+ </x-library-card>
15
+ </body>
16
+ </html>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,73 @@
1
+ import inquirer from "inquirer";
2
+ import axios from "axios";
3
+ import fs from "fs-extra";
4
+ import path from "path";
5
+
6
+ const DIR_PATH = path.join(process.cwd(), "public/library");
7
+ const FILE_PATH = path.join(process.cwd(), "public/library/card.json");
8
+ async function runCli() {
9
+ await fs.ensureDir(DIR_PATH);
10
+
11
+ if (!fs.existsSync(FILE_PATH)) {
12
+ const profile = await inquirer.prompt([
13
+ {
14
+ type: "input",
15
+ name: "borrower",
16
+ message: "Enter borrower name",
17
+ },
18
+ {
19
+ type: "input",
20
+ name: "libName",
21
+ message: "Enter library name",
22
+ default: "Boo Library",
23
+ },
24
+ ]);
25
+ const initialData = {
26
+ borrower: profile.borrower,
27
+ library: { name: profile.libName, signature: "🐾" },
28
+ books: [],
29
+ };
30
+ await fs.writeJson(FILE_PATH, initialData, { spaces: 2 });
31
+ console.log("✨ Library card created!");
32
+ }
33
+ const { query } = await inquirer.prompt([
34
+ { type: "input", name: "query", message: "Search for a book:" },
35
+ ]);
36
+ const { data } = await axios.get(
37
+ `https://openlibrary.org/search.json?q=${encodeURIComponent(query)}`,
38
+ );
39
+ if (!data.docs?.length) {
40
+ console.log("No books found.");
41
+ return;
42
+ }
43
+
44
+ interface IBook {
45
+ key: string;
46
+ title: string;
47
+ author_name: string[];
48
+ finishedDate: string;
49
+ }
50
+
51
+ const { selectedBook } = await inquirer.prompt([
52
+ {
53
+ type: "select",
54
+ name: "selectedBook",
55
+ message: "Select a book:",
56
+ choices: data.docs.map((book: IBook) => ({
57
+ name: `${book.title} (${book.author_name?.[0] || "Unknown"})`,
58
+ value: {
59
+ key: book.key,
60
+ name: book.title,
61
+ author: book.author_name?.[0] || "Unknown",
62
+ finishedDate: new Date().toLocaleDateString("en-IN"),
63
+ },
64
+ })),
65
+ },
66
+ ]);
67
+ const cardData = await fs.readJson(FILE_PATH);
68
+ cardData.books.push(selectedBook);
69
+ await fs.writeJson(FILE_PATH, cardData, { spaces: 2 });
70
+
71
+ console.log(`Added ${selectedBook.name}`);
72
+ }
73
+ runCli();
package/src/app.css ADDED
File without changes
package/src/app.tsx ADDED
@@ -0,0 +1,11 @@
1
+ import "./app.css";
2
+ import { LibraryCard } from "./lib/libraryCard";
3
+ const myLibrary = "/library/card.json";
4
+ const friendsList = ["http://localhost:4321/library/card.json"];
5
+ export function App() {
6
+ return (
7
+ <>
8
+ <LibraryCard cardlink={myLibrary} friends={friendsList} />
9
+ </>
10
+ );
11
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="27.68" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 296"><path fill="#673AB8" d="m128 0l128 73.9v147.8l-128 73.9L0 221.7V73.9z"></path><path fill="#FFF" d="M34.865 220.478c17.016 21.78 71.095 5.185 122.15-34.704c51.055-39.888 80.24-88.345 63.224-110.126c-17.017-21.78-71.095-5.184-122.15 34.704c-51.055 39.89-80.24 88.346-63.224 110.126Zm7.27-5.68c-5.644-7.222-3.178-21.402 7.573-39.253c11.322-18.797 30.541-39.548 54.06-57.923c23.52-18.375 48.303-32.004 69.281-38.442c19.922-6.113 34.277-5.075 39.92 2.148c5.644 7.223 3.178 21.403-7.573 39.254c-11.322 18.797-30.541 39.547-54.06 57.923c-23.52 18.375-48.304 32.004-69.281 38.441c-19.922 6.114-34.277 5.076-39.92-2.147Z"></path><path fill="#FFF" d="M220.239 220.478c17.017-21.78-12.169-70.237-63.224-110.126C105.96 70.464 51.88 53.868 34.865 75.648c-17.017 21.78 12.169 70.238 63.224 110.126c51.055 39.889 105.133 56.485 122.15 34.704Zm-7.27-5.68c-5.643 7.224-19.998 8.262-39.92 2.148c-20.978-6.437-45.761-20.066-69.28-38.441c-23.52-18.376-42.74-39.126-54.06-57.923c-10.752-17.851-13.218-32.03-7.575-39.254c5.644-7.223 19.999-8.261 39.92-2.148c20.978 6.438 45.762 20.067 69.281 38.442c23.52 18.375 42.739 39.126 54.06 57.923c10.752 17.85 13.218 32.03 7.574 39.254Z"></path><path fill="#FFF" d="M127.552 167.667c10.827 0 19.603-8.777 19.603-19.604c0-10.826-8.776-19.603-19.603-19.603c-10.827 0-19.604 8.777-19.604 19.603c0 10.827 8.777 19.604 19.604 19.604Z"></path></svg>
package/src/index.css ADDED
File without changes
@@ -0,0 +1,116 @@
1
+ .card {
2
+ position: relative;
3
+ max-width: 384px;
4
+ border: 2px solid #1f2937;
5
+ background-color: #ffffff;
6
+ padding: 1.5rem;
7
+ font-family:
8
+ ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
9
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
10
+ }
11
+
12
+ .inner {
13
+ transform: rotate(-1deg);
14
+ }
15
+
16
+ .header {
17
+ display: flex;
18
+ justify-content: space-between;
19
+ border-bottom: 2px solid #1f2937;
20
+ padding-bottom: 0.5rem;
21
+ margin-bottom: 1rem;
22
+ }
23
+
24
+ .year {
25
+ font-size: 0.75rem;
26
+ text-transform: uppercase;
27
+ font-weight: 700;
28
+ }
29
+
30
+ .libraryTitle {
31
+ font-size: 1.25rem;
32
+ font-weight: 900;
33
+ letter-spacing: 0.1em;
34
+ text-transform: uppercase;
35
+ font-style: italic;
36
+ margin: 0;
37
+ }
38
+
39
+ .fieldGroup {
40
+ margin-bottom: 1rem;
41
+ }
42
+
43
+ .fieldValue {
44
+ margin: 0;
45
+ line-height: 1.2;
46
+ }
47
+ .nameValue {
48
+ font-size: 1.125rem;
49
+ }
50
+ .signatureValue {
51
+ font-size: 1.5rem;
52
+ }
53
+
54
+ .label {
55
+ display: block;
56
+ font-size: 10px;
57
+ text-transform: uppercase;
58
+ color: #6b7280;
59
+ text-decoration: underline dotted;
60
+ }
61
+
62
+ .bookSection {
63
+ border-top: 2px solid #1f2937;
64
+ padding-top: 0.5rem;
65
+ }
66
+
67
+ .bookList {
68
+ list-style: none;
69
+ padding: 0;
70
+ margin: 0;
71
+ }
72
+
73
+ .bookRow {
74
+ position: relative;
75
+ display: grid;
76
+ grid-template-cols: 1fr 1fr;
77
+ align-items: flex-end;
78
+ border-bottom: 1px solid #f3f4f6;
79
+ padding-bottom: 0.25rem;
80
+ margin-bottom: 0.5rem;
81
+ }
82
+
83
+ .bookName {
84
+ font-size: 0.875rem;
85
+ font-weight: 500;
86
+ white-space: nowrap;
87
+ overflow: hidden;
88
+ text-overflow: ellipsis;
89
+ padding-right: 0.5rem;
90
+ }
91
+
92
+ .bookDate {
93
+ font-size: 10px;
94
+ text-align: right;
95
+ color: #9ca3af;
96
+ font-style: italic;
97
+ }
98
+
99
+ .friendSignatures {
100
+ position: absolute;
101
+ right: 16px;
102
+ display: flex;
103
+ top: -4px;
104
+ }
105
+
106
+ .signatureLink {
107
+ font-size: 1.125rem;
108
+ transition: transform 0.2s;
109
+ text-decoration: none;
110
+ color: inherit;
111
+ }
112
+
113
+ .signatureLink:hover {
114
+ transform: scale(1.25);
115
+ z-index: 10;
116
+ }
@@ -0,0 +1,125 @@
1
+ import { useState, useEffect } from "preact/hooks";
2
+ import "./libraryCard.css";
3
+ import register from "preact-custom-element";
4
+
5
+ interface Book {
6
+ key: string;
7
+ name: string;
8
+ finishedDate: string;
9
+ author: string;
10
+ }
11
+
12
+ interface CardData {
13
+ borrower: string;
14
+ library: { name: string; signature: string };
15
+ books: Book[];
16
+ url?: string; // Optional URL for the card
17
+ }
18
+
19
+ interface Props {
20
+ cardlink: string;
21
+ friends?: string[]; // Array of URLs
22
+ }
23
+
24
+ export const LibraryCard = ({ cardlink, friends = [] }: Props) => {
25
+ const [data, setData] = useState<CardData | null>(null);
26
+ const [friendsData, setFriendsData] = useState<CardData[]>([]);
27
+
28
+ useEffect(() => {
29
+ const friendsArray =
30
+ typeof friends === "string" ? JSON.parse(friends) : friends;
31
+
32
+ fetch(cardlink)
33
+ .then((res) => res.json())
34
+ .then(setData);
35
+ if (Array.isArray(friendsArray) && friendsArray.length > 0) {
36
+ Promise.all(
37
+ friendsArray.map((url) =>
38
+ fetch(url)
39
+ .then((res) => res.json())
40
+ .then((json) => ({ ...json, url })),
41
+ ),
42
+ ).then(setFriendsData);
43
+ }
44
+ }, [cardlink, friends]);
45
+
46
+ if (!data) return <div className={"loading"}>Loading library card...</div>;
47
+
48
+ return (
49
+ <div className={"card"}>
50
+ <div className={"inner"}>
51
+ <div className={"header"}>
52
+ <span className={"year"}>20</span>
53
+ <span className={"year"}>26</span>
54
+ </div>
55
+
56
+ <div className={"header"}>
57
+ <h2 className={"libraryTitle"}>{data.library.name}</h2>
58
+ </div>
59
+
60
+ <div className={"fieldGroup"}>
61
+ <p className={`${"fieldValue"} ${"nameValue"}`}>{data.borrower}</p>
62
+ <label className={"label"}>Borrower's Name</label>
63
+ </div>
64
+
65
+ <div className={"fieldGroup"}>
66
+ <p className={`${"fieldValue"} ${"signatureValue"}`}>
67
+ {data.library.signature}
68
+ </p>
69
+ <label className={"label"}>Librarian's Signature</label>
70
+ </div>
71
+
72
+ <div className={"bookSection"}>
73
+ <ul className={"bookList"}>
74
+ {data.books.map((book, idx) => {
75
+ console.log("friendsData", friendsData, data);
76
+ const readersOfThisBook = friendsData.filter((friend) =>
77
+ friend.books.some((friendBook) => friendBook.key === book.key),
78
+ );
79
+ console.log("readersOfThisBook", readersOfThisBook);
80
+ return (
81
+ <li key={idx} className={"bookRow"}>
82
+ <span className={"bookName"}>
83
+ {book.name} by {book.author}
84
+ </span>
85
+ <div
86
+ style={{
87
+ display: "flex",
88
+ justifyContent: "flex-end",
89
+ alignItems: "center",
90
+ }}
91
+ >
92
+ <span className={"bookDate"}>{book.finishedDate}</span>
93
+ <div className={"friendSignatures"}>
94
+ {readersOfThisBook.length > 0 && (
95
+ <div className="friendSignatures">
96
+ {readersOfThisBook.map((friend, fIdx) => (
97
+ <a
98
+ key={fIdx}
99
+ href={
100
+ friend.url ? new URL(friend.url).origin : "#"
101
+ }
102
+ className="signatureLink"
103
+ title={`${friend.borrower} also read this`}
104
+ target="_blank"
105
+ rel="noopener noreferrer"
106
+ >
107
+ {friend.library.signature}
108
+ </a>
109
+ ))}
110
+ </div>
111
+ )}
112
+ </div>
113
+ </div>
114
+ </li>
115
+ );
116
+ })}
117
+ </ul>
118
+ </div>
119
+ </div>
120
+ </div>
121
+ );
122
+ };
123
+ register(LibraryCard, "x-library-card", ["cardlink", "friends"], {
124
+ shadow: false,
125
+ });
package/src/main.tsx ADDED
@@ -0,0 +1,5 @@
1
+ import { render } from 'preact'
2
+ import './index.css'
3
+ import { App } from './app.tsx'
4
+
5
+ render(<App />, document.getElementById('app')!)
@@ -0,0 +1,33 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
+ "target": "ES2022",
5
+ "useDefineForClassFields": true,
6
+ "module": "ESNext",
7
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
8
+ "types": ["vite/client"],
9
+ "skipLibCheck": true,
10
+ "paths": {
11
+ "react": ["./node_modules/preact/compat/"],
12
+ "react-dom": ["./node_modules/preact/compat/"]
13
+ },
14
+
15
+ /* Bundler mode */
16
+ "moduleResolution": "bundler",
17
+ "allowImportingTsExtensions": true,
18
+ "verbatimModuleSyntax": true,
19
+ "moduleDetection": "force",
20
+ "noEmit": true,
21
+ "jsx": "react-jsx",
22
+ "jsxImportSource": "preact",
23
+
24
+ /* Linting */
25
+ "strict": true,
26
+ "noUnusedLocals": true,
27
+ "noUnusedParameters": true,
28
+ "erasableSyntaxOnly": true,
29
+ "noFallthroughCasesInSwitch": true,
30
+ "noUncheckedSideEffectImports": true
31
+ },
32
+ "include": ["src"]
33
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ { "path": "./tsconfig.app.json" },
5
+ { "path": "./tsconfig.node.json" }
6
+ ]
7
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
+ "target": "ES2023",
5
+ "lib": ["ES2023"],
6
+ "module": "ESNext",
7
+ "types": ["node"],
8
+ "skipLibCheck": true,
9
+
10
+ /* Bundler mode */
11
+ "moduleResolution": "bundler",
12
+ "allowImportingTsExtensions": true,
13
+ "verbatimModuleSyntax": true,
14
+ "moduleDetection": "force",
15
+ "noEmit": true,
16
+
17
+ /* Linting */
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "erasableSyntaxOnly": true,
22
+ "noFallthroughCasesInSwitch": true,
23
+ "noUncheckedSideEffectImports": true
24
+ },
25
+ "include": ["vite.config.ts"]
26
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,33 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig([
4
+ {
5
+ entry: {
6
+ cli: "scripts/add-book.ts",
7
+ },
8
+ format: ["esm"],
9
+ splitting: false,
10
+ sourcemap: false,
11
+ clean: true,
12
+ dts: false,
13
+ banner: {
14
+ js: "#!/usr/bin/env node",
15
+ },
16
+ },
17
+ {
18
+ entry: {
19
+ index: "src/lib/libraryCard.tsx",
20
+ },
21
+ format: ["iife"],
22
+ minify: true,
23
+ splitting: false,
24
+ sourcemap: false,
25
+ clean: true,
26
+ dts: false,
27
+ treeshake: true,
28
+ esbuildOptions(options) {
29
+ options.jsx = "automatic";
30
+ options.jsxImportSource = "preact"; // Tells it to get h and Fragment from preact
31
+ },
32
+ },
33
+ ]);
package/vite.config.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from "vite";
2
+ import preact from "@preact/preset-vite";
3
+
4
+ // https://vite.dev/config/
5
+ export default defineConfig({
6
+ plugins: [preact()],
7
+ });
package/README.md DELETED
@@ -1,75 +0,0 @@
1
- # React + TypeScript + Vite
2
-
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
-
5
- Currently, two official plugins are available:
6
-
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
-
10
- ## React Compiler
11
-
12
- The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.
13
-
14
- Note: This will impact Vite dev & build performances.
15
-
16
- ## Expanding the ESLint configuration
17
-
18
- If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
19
-
20
- ```js
21
- export default defineConfig([
22
- globalIgnores(['dist']),
23
- {
24
- files: ['**/*.{ts,tsx}'],
25
- extends: [
26
- // Other configs...
27
-
28
- // Remove tseslint.configs.recommended and replace with this
29
- tseslint.configs.recommendedTypeChecked,
30
- // Alternatively, use this for stricter rules
31
- tseslint.configs.strictTypeChecked,
32
- // Optionally, add this for stylistic rules
33
- tseslint.configs.stylisticTypeChecked,
34
-
35
- // Other configs...
36
- ],
37
- languageOptions: {
38
- parserOptions: {
39
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
40
- tsconfigRootDir: import.meta.dirname,
41
- },
42
- // other options...
43
- },
44
- },
45
- ])
46
- ```
47
-
48
- You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
49
-
50
- ```js
51
- // eslint.config.js
52
- import reactX from 'eslint-plugin-react-x'
53
- import reactDom from 'eslint-plugin-react-dom'
54
-
55
- export default defineConfig([
56
- globalIgnores(['dist']),
57
- {
58
- files: ['**/*.{ts,tsx}'],
59
- extends: [
60
- // Other configs...
61
- // Enable lint rules for React
62
- reactX.configs['recommended-typescript'],
63
- // Enable lint rules for React DOM
64
- reactDom.configs.recommended,
65
- ],
66
- languageOptions: {
67
- parserOptions: {
68
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
69
- tsconfigRootDir: import.meta.dirname,
70
- },
71
- // other options...
72
- },
73
- },
74
- ])
75
- ```
package/dist/cli.cjs DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";var u=Object.create;var p=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var f=(o,a,t,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of y(a))!g.call(o,e)&&e!==t&&p(o,e,{get:()=>a[e],enumerable:!(n=w(a,e))||n.enumerable});return o};var i=(o,a,t)=>(t=o!=null?u(b(o)):{},f(a||!o||!o.__esModule?p(t,"default",{value:o,enumerable:!0}):t,o));var c=i(require("inquirer"),1),l=i(require("axios"),1),r=i(require("fs-extra"),1),m=i(require("path"),1),h=m.default.join(process.cwd(),"public/library"),s=m.default.join(process.cwd(),"public/library/card.json");async function k(){if(await r.default.ensureDir(h),!r.default.existsSync(s)){let e=await c.default.prompt([{type:"input",name:"borrower",message:"Enter borrower name"},{type:"input",name:"libName",message:"Enter library name",default:"Boo Library"}]),d={borrower:e.borrower,library:{name:e.libName,signature:"\u{1F43E}"},books:[]};await r.default.writeJson(s,d,{spaces:2}),console.log("\u2728 Library card created!")}let{query:o}=await c.default.prompt([{type:"input",name:"query",message:"Search for a book:"}]),{data:a}=await l.default.get(`https://openlibrary.org/search.json?q=${encodeURIComponent(o)}`);if(!a.docs?.length){console.log("No books found.");return}let{selectedBook:t}=await c.default.prompt([{type:"select",name:"selectedBook",message:"Select a book:",choices:a.docs.map(e=>({name:`${e.title} (${e.author_name?.[0]||"Unknown"})`,value:{key:e.key,name:e.title,finishedDate:new Date().toLocaleDateString("en-IN")}}))}]),n=await r.default.readJson(s);n.books.push(t),await r.default.writeJson(s,n,{spaces:2}),console.log(`Added ${t.name}`)}k();
package/dist/cli.d.cts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/cli.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import t from"inquirer";import p from"axios";import o from"fs-extra";import s from"path";var l=s.join(process.cwd(),"public/library"),a=s.join(process.cwd(),"public/library/card.json");async function d(){if(await o.ensureDir(l),!o.existsSync(a)){let e=await t.prompt([{type:"input",name:"borrower",message:"Enter borrower name"},{type:"input",name:"libName",message:"Enter library name",default:"Boo Library"}]),m={borrower:e.borrower,library:{name:e.libName,signature:"\u{1F43E}"},books:[]};await o.writeJson(a,m,{spaces:2}),console.log("\u2728 Library card created!")}let{query:c}=await t.prompt([{type:"input",name:"query",message:"Search for a book:"}]),{data:r}=await p.get(`https://openlibrary.org/search.json?q=${encodeURIComponent(c)}`);if(!r.docs?.length){console.log("No books found.");return}let{selectedBook:n}=await t.prompt([{type:"select",name:"selectedBook",message:"Select a book:",choices:r.docs.map(e=>({name:`${e.title} (${e.author_name?.[0]||"Unknown"})`,value:{key:e.key,name:e.title,finishedDate:new Date().toLocaleDateString("en-IN")}}))}]),i=await o.readJson(a);i.books.push(n),await o.writeJson(a,i,{spaces:2}),console.log(`Added ${n.name}`)}d();
package/dist/index.cjs DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";var p=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var y=(i,t)=>{for(var a in t)p(i,a,{get:t[a],enumerable:!0})},x=(i,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u(t))!h.call(i,s)&&s!==a&&p(i,s,{get:()=>t[s],enumerable:!(r=b(t,s))||r.enumerable});return i};var N=i=>x(p({},"__esModule",{value:!0}),i);var k={};y(k,{LibraryCard:()=>v});module.exports=N(k);var d=require("react");function f(i,{insertAt:t}={}){if(!i||typeof document>"u")return;let a=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&a.firstChild?a.insertBefore(r,a.firstChild):a.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}f(`.card{position:relative;max-width:384px;border:2px solid #1f2937;background-color:#fff;padding:1.5rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;box-shadow:0 1px 2px #0000000d}.inner{transform:rotate(-1deg)}.header{display:flex;justify-content:space-between;border-bottom:2px solid #1f2937;padding-bottom:.5rem;margin-bottom:1rem}.year{font-size:.75rem;text-transform:uppercase;font-weight:700}.libraryTitle{font-size:1.25rem;font-weight:900;letter-spacing:.1em;text-transform:uppercase;font-style:italic;margin:0}.fieldGroup{margin-bottom:1rem}.fieldValue{margin:0;line-height:1.2}.nameValue{font-size:1.125rem}.signatureValue{font-size:1.5rem}.label{display:block;font-size:10px;text-transform:uppercase;color:#6b7280;text-decoration:underline dotted}.bookSection{border-top:2px solid #1f2937;padding-top:.5rem}.bookList{list-style:none;padding:0;margin:0}.bookRow{position:relative;display:grid;grid-template-cols:1fr 1fr;align-items:flex-end;border-bottom:1px solid #f3f4f6;padding-bottom:.25rem;margin-bottom:.5rem}.bookName{font-size:.875rem;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:.5rem}.bookDate{font-size:10px;text-align:right;color:#9ca3af;font-style:italic}.friendSignatures{position:absolute;right:-2rem;display:flex;gap:-.5rem}.signatureLink{font-size:1.125rem;transition:transform .2s;text-decoration:none;color:inherit}.signatureLink:hover{transform:scale(1.25);z-index:10}
3
- `);var e=require("react/jsx-runtime"),v=({cardUrl:i,friends:t=[]})=>{let[a,r]=(0,d.useState)(null),[s,c]=(0,d.useState)([]);return(0,d.useEffect)(()=>{fetch(i).then(o=>o.json()).then(r),t.length>0&&Promise.all(t.map(o=>fetch(o).then(l=>l.json()).then(l=>({...l,url:o})))).then(c)},[i,t]),a?(0,e.jsx)("div",{className:"card",children:(0,e.jsxs)("div",{className:"inner",children:[(0,e.jsxs)("div",{className:"header",children:[(0,e.jsx)("span",{className:"year",children:"20"}),(0,e.jsx)("span",{className:"year",children:"26"})]}),(0,e.jsx)("div",{className:"header",children:(0,e.jsx)("h2",{className:"libraryTitle",children:a.library.name})}),(0,e.jsxs)("div",{className:"fieldGroup",children:[(0,e.jsx)("p",{className:"fieldValue nameValue",children:a.borrower}),(0,e.jsx)("label",{className:"label",children:"Borrower's Name"})]}),(0,e.jsxs)("div",{className:"fieldGroup",children:[(0,e.jsx)("p",{className:"fieldValue signatureValue",children:a.library.signature}),(0,e.jsx)("label",{className:"label",children:"Librarian's Signature"})]}),(0,e.jsx)("div",{className:"bookSection",children:(0,e.jsx)("ul",{className:"bookList",children:a.books.map((o,l)=>{let g=s.filter(n=>n.books.some(m=>m.isbn===o.isbn));return(0,e.jsxs)("li",{className:"bookRow",children:[(0,e.jsx)("span",{className:"bookName",children:o.name}),(0,e.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[(0,e.jsx)("span",{className:"bookDate",children:o.finishedDate}),(0,e.jsx)("div",{className:"friendSignatures",children:g.map((n,m)=>(0,e.jsx)("a",{href:n.url?new URL(n.url).origin:"#",className:"signatureLink",title:`${n.borrower} read this too`,children:n.library.signature},m))})]})]},l)})})})]})}):(0,e.jsx)("div",{className:"loading",children:"Loading library card..."})};0&&(module.exports={LibraryCard});
package/dist/index.d.cts DELETED
@@ -1,9 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
-
3
- interface Props {
4
- cardUrl: string;
5
- friends?: string[];
6
- }
7
- declare const LibraryCard: ({ cardUrl, friends }: Props) => react_jsx_runtime.JSX.Element;
8
-
9
- export { LibraryCard };
package/dist/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
-
3
- interface Props {
4
- cardUrl: string;
5
- friends?: string[];
6
- }
7
- declare const LibraryCard: ({ cardUrl, friends }: Props) => react_jsx_runtime.JSX.Element;
8
-
9
- export { LibraryCard };
package/dist/index.js DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import{useState as p,useEffect as b}from"react";function m(r,{insertAt:n}={}){if(!r||typeof document>"u")return;let a=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",n==="top"&&a.firstChild?a.insertBefore(t,a.firstChild):a.appendChild(t),t.styleSheet?t.styleSheet.cssText=r:t.appendChild(document.createTextNode(r))}m(`.card{position:relative;max-width:384px;border:2px solid #1f2937;background-color:#fff;padding:1.5rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;box-shadow:0 1px 2px #0000000d}.inner{transform:rotate(-1deg)}.header{display:flex;justify-content:space-between;border-bottom:2px solid #1f2937;padding-bottom:.5rem;margin-bottom:1rem}.year{font-size:.75rem;text-transform:uppercase;font-weight:700}.libraryTitle{font-size:1.25rem;font-weight:900;letter-spacing:.1em;text-transform:uppercase;font-style:italic;margin:0}.fieldGroup{margin-bottom:1rem}.fieldValue{margin:0;line-height:1.2}.nameValue{font-size:1.125rem}.signatureValue{font-size:1.5rem}.label{display:block;font-size:10px;text-transform:uppercase;color:#6b7280;text-decoration:underline dotted}.bookSection{border-top:2px solid #1f2937;padding-top:.5rem}.bookList{list-style:none;padding:0;margin:0}.bookRow{position:relative;display:grid;grid-template-cols:1fr 1fr;align-items:flex-end;border-bottom:1px solid #f3f4f6;padding-bottom:.25rem;margin-bottom:.5rem}.bookName{font-size:.875rem;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:.5rem}.bookDate{font-size:10px;text-align:right;color:#9ca3af;font-style:italic}.friendSignatures{position:absolute;right:-2rem;display:flex;gap:-.5rem}.signatureLink{font-size:1.125rem;transition:transform .2s;text-decoration:none;color:inherit}.signatureLink:hover{transform:scale(1.25);z-index:10}
3
- `);import{jsx as e,jsxs as s}from"react/jsx-runtime";var N=({cardUrl:r,friends:n=[]})=>{let[a,t]=p(null),[f,c]=p([]);return b(()=>{fetch(r).then(i=>i.json()).then(t),n.length>0&&Promise.all(n.map(i=>fetch(i).then(l=>l.json()).then(l=>({...l,url:i})))).then(c)},[r,n]),a?e("div",{className:"card",children:s("div",{className:"inner",children:[s("div",{className:"header",children:[e("span",{className:"year",children:"20"}),e("span",{className:"year",children:"26"})]}),e("div",{className:"header",children:e("h2",{className:"libraryTitle",children:a.library.name})}),s("div",{className:"fieldGroup",children:[e("p",{className:"fieldValue nameValue",children:a.borrower}),e("label",{className:"label",children:"Borrower's Name"})]}),s("div",{className:"fieldGroup",children:[e("p",{className:"fieldValue signatureValue",children:a.library.signature}),e("label",{className:"label",children:"Librarian's Signature"})]}),e("div",{className:"bookSection",children:e("ul",{className:"bookList",children:a.books.map((i,l)=>{let g=f.filter(o=>o.books.some(d=>d.isbn===i.isbn));return s("li",{className:"bookRow",children:[e("span",{className:"bookName",children:i.name}),s("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[e("span",{className:"bookDate",children:i.finishedDate}),e("div",{className:"friendSignatures",children:g.map((o,d)=>e("a",{href:o.url?new URL(o.url).origin:"#",className:"signatureLink",title:`${o.borrower} read this too`,children:o.library.signature},d))})]})]},l)})})})]})}):e("div",{className:"loading",children:"Loading library card..."})};export{N as LibraryCard};