cluebook-inspector 0.0.0-stage → 1.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 +21 -0
- package/README.md +15 -2
- package/demo/index.html +54 -0
- package/index.mjs +105 -0
- package/package.json +18 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ClueBook
|
|
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
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# cluebook-inspector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Free, zero-dependency MIT utility for:
|
|
4
|
+
1. Validating single American-style crossword grids (4-connectivity, full checking, zero 1- or 2-letter stubs, duplicate-word detection).
|
|
5
|
+
2. Calculating Lulu 6×9 US Trade interior bleed (`450 × 666 pt`) and paperback vs. casewrap hardcover spine & cover wrap dimensions.
|
|
6
|
+
|
|
7
|
+
> Want to turn 5–15 friends' inside jokes into a real 100-page printed keepsake crossword book? Try **[ClueBook](https://getcluebook.com?utm_source=npm&utm_medium=oss&utm_campaign=cluebook-inspector)** ($39 paperback / $59 hardcover, US Mail included).
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { validateCrosswordGrid, calculateLulu6x9Spec } from "cluebook-inspector";
|
|
13
|
+
|
|
14
|
+
const spec = calculateLulu6x9Spec({ pageCount: 100, binding: "paperback" });
|
|
15
|
+
console.log(spec.interiorPt, spec.coverWrapPt);
|
|
16
|
+
```
|
package/demo/index.html
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
6
|
+
<title>ClueBook Inspector — Free Lulu 6×9 Bleed & Crossword Grid Validator (MIT)</title>
|
|
7
|
+
<style>
|
|
8
|
+
body{font-family:system-ui,sans-serif;background:#faf9f5;color:#141413;margin:0;line-height:1.55}
|
|
9
|
+
.banner{background:#181715;color:#faf9f5;padding:12px 18px;text-align:center;font-size:14px}
|
|
10
|
+
.banner a{color:#e8a55a;font-weight:700;text-decoration:underline}
|
|
11
|
+
main{max-width:760px;margin:0 auto;padding:28px 18px}
|
|
12
|
+
h1{font-family:Georgia,serif}
|
|
13
|
+
.card{background:#fff;border:1px solid #e6dfd8;border-radius:14px;padding:20px;margin-top:16px}
|
|
14
|
+
input,select{padding:8px 10px;border:1px solid #d8cfc2;border-radius:8px;font-size:14px}
|
|
15
|
+
pre{background:#f5f0e8;padding:14px;border-radius:10px;overflow:auto;font-size:13px}
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<div class="banner">
|
|
20
|
+
Need a full 100-page printed keepsake crossword book co-created by 5–15 friends?
|
|
21
|
+
<a href="https://getcluebook.com?utm_source=github&utm_medium=oss&utm_campaign=cluebook-inspector">Build Your ClueBook ($39 Paperback / $59 Hardcover) →</a>
|
|
22
|
+
</div>
|
|
23
|
+
<main>
|
|
24
|
+
<h1>ClueBook Inspector (MIT Open Source)</h1>
|
|
25
|
+
<p>Free single-unit Lulu 6×9 US Trade bleed & spine dimension calculator for 60# uncoated B&W books.</p>
|
|
26
|
+
<div class="card">
|
|
27
|
+
<label>Pages: <input id="pages" type="number" min="32" max="800" value="100" /></label>
|
|
28
|
+
<label style="margin-left:12px">Binding:
|
|
29
|
+
<select id="binding">
|
|
30
|
+
<option value="paperback">Paperback (0600X0900BWSTDPB060UW444MXX)</option>
|
|
31
|
+
<option value="hardcover">Casewrap Hardcover (0600X0900BWSTDCW060UW444MXX)</option>
|
|
32
|
+
</select>
|
|
33
|
+
</label>
|
|
34
|
+
<pre id="out"></pre>
|
|
35
|
+
</div>
|
|
36
|
+
</main>
|
|
37
|
+
<script type="module">
|
|
38
|
+
import { calculateLulu6x9Spec } from "../index.mjs";
|
|
39
|
+
const pagesEl = document.getElementById("pages");
|
|
40
|
+
const bindEl = document.getElementById("binding");
|
|
41
|
+
const outEl = document.getElementById("out");
|
|
42
|
+
const render = () => {
|
|
43
|
+
outEl.textContent = JSON.stringify(
|
|
44
|
+
calculateLulu6x9Spec({ pageCount: Number(pagesEl.value), binding: bindEl.value }),
|
|
45
|
+
null,
|
|
46
|
+
2
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
pagesEl.addEventListener("input", render);
|
|
50
|
+
bindEl.addEventListener("change", render);
|
|
51
|
+
render();
|
|
52
|
+
</script>
|
|
53
|
+
</body>
|
|
54
|
+
</html>
|
package/index.mjs
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cluebook-inspector (MIT) — Free single-unit American crossword grid validator
|
|
3
|
+
* & Lulu 6x9 bleed/spine print dimension calculator.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export function validateCrosswordGrid(rows) {
|
|
7
|
+
if (!Array.isArray(rows) || rows.length < 5 || rows.length > 21) {
|
|
8
|
+
return { ok: false, reason: "invalid_grid_size", wordCount: 0 };
|
|
9
|
+
}
|
|
10
|
+
const n = rows.length;
|
|
11
|
+
if (rows.some((r) => typeof r !== "string" || r.length !== n)) {
|
|
12
|
+
return { ok: false, reason: "non_square_grid", wordCount: 0 };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const whites = new Set();
|
|
16
|
+
for (let r = 0; r < n; r++) {
|
|
17
|
+
for (let c = 0; c < n; c++) {
|
|
18
|
+
const ch = rows[r][c];
|
|
19
|
+
if (ch === "#") continue;
|
|
20
|
+
if (ch < "A" || ch > "Z") {
|
|
21
|
+
return { ok: false, reason: `invalid_char_${ch}`, wordCount: 0 };
|
|
22
|
+
}
|
|
23
|
+
whites.add(r * n + c);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (whites.size === 0) return { ok: false, reason: "no_white_cells", wordCount: 0 };
|
|
27
|
+
|
|
28
|
+
const first = whites.values().next().value;
|
|
29
|
+
const q = [first];
|
|
30
|
+
const seen = new Set([first]);
|
|
31
|
+
while (q.length > 0) {
|
|
32
|
+
const cur = q.shift();
|
|
33
|
+
const r = Math.floor(cur / n);
|
|
34
|
+
const c = cur % n;
|
|
35
|
+
for (const [nr, nc] of [[r + 1, c], [r - 1, c], [r, c + 1], [r, c - 1]]) {
|
|
36
|
+
if (nr >= 0 && nr < n && nc >= 0 && nc < n) {
|
|
37
|
+
const k = nr * n + nc;
|
|
38
|
+
if (whites.has(k) && !seen.has(k)) {
|
|
39
|
+
seen.add(k);
|
|
40
|
+
q.push(k);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (seen.size !== whites.size) {
|
|
46
|
+
return { ok: false, reason: "disconnected_white_cells", wordCount: 0 };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const words = new Set();
|
|
50
|
+
const checkRun = (w) => {
|
|
51
|
+
if (w.length < 3) return `short_word_${w.length}`;
|
|
52
|
+
if (words.has(w)) return `duplicate_word_${w}`;
|
|
53
|
+
words.add(w);
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
for (let r = 0; r < n; r++) {
|
|
58
|
+
let c = 0;
|
|
59
|
+
while (c < n) {
|
|
60
|
+
if (rows[r][c] === "#") { c++; continue; }
|
|
61
|
+
let w = "";
|
|
62
|
+
while (c < n && rows[r][c] !== "#") w += rows[r][c++];
|
|
63
|
+
const err = checkRun(w);
|
|
64
|
+
if (err) return { ok: false, reason: err, wordCount: words.size };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for (let c = 0; c < n; c++) {
|
|
68
|
+
let r = 0;
|
|
69
|
+
while (r < n) {
|
|
70
|
+
if (rows[r][c] === "#") { r++; continue; }
|
|
71
|
+
let w = "";
|
|
72
|
+
while (r < n && rows[r][c] !== "#") w += rows[r++][c];
|
|
73
|
+
const err = checkRun(w);
|
|
74
|
+
if (err) return { ok: false, reason: err, wordCount: words.size };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return { ok: true, reason: "ok", wordCount: words.size, whiteCellCount: whites.size };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function calculateLulu6x9Spec({ pageCount = 100, binding = "paperback" } = {}) {
|
|
82
|
+
const pages = Math.max(32, Math.min(800, Math.round(Number(pageCount) || 100)));
|
|
83
|
+
const isHardcover = binding === "hardcover";
|
|
84
|
+
const spineIn = isHardcover
|
|
85
|
+
? Math.max(0.375, pages / 444 + 0.2123)
|
|
86
|
+
: pages / 444 + 0.06;
|
|
87
|
+
const coverWidthIn = isHardcover
|
|
88
|
+
? 6.0 * 2 + spineIn + 0.75 * 2 + 0.25
|
|
89
|
+
: 6.0 * 2 + spineIn + 0.125 * 2;
|
|
90
|
+
const coverHeightIn = isHardcover ? 9.0 + 0.75 * 2 + 0.25 : 9.0 + 0.125 * 2;
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
binding: isHardcover ? "hardcover" : "paperback",
|
|
94
|
+
podPackageId: isHardcover
|
|
95
|
+
? "0600X0900BWSTDCW060UW444MXX"
|
|
96
|
+
: "0600X0900BWSTDPB060UW444MXX",
|
|
97
|
+
pageCount: pages,
|
|
98
|
+
interiorPt: { width: 450, height: 666, bleed: 9 },
|
|
99
|
+
coverWrapPt: {
|
|
100
|
+
width: Math.round(coverWidthIn * 72 * 100) / 100,
|
|
101
|
+
height: Math.round(coverHeightIn * 72 * 100) / 100,
|
|
102
|
+
spine: Math.round(spineIn * 72 * 100) / 100,
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cluebook-inspector",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Free MIT American-style 13x13 crossword grid validator & Lulu 6x9 bleed/spine dimension calculator by ClueBook.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.mjs"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"crossword",
|
|
12
|
+
"validator",
|
|
13
|
+
"lulu-print",
|
|
14
|
+
"bleed-calculator",
|
|
15
|
+
"spine-width",
|
|
16
|
+
"book-printing"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"homepage": "https://getcluebook.com"
|
|
20
|
+
}
|