wrapt-cli 0.1.3 → 0.1.5
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/README.md +5 -3
- package/dist/analyze.js +9 -4
- package/dist/cli.js +65 -29
- package/dist/format.js +2 -1
- package/dist/publish.js +2 -2
- package/dist/render/index.js +18 -6
- package/dist/share/page.js +12 -6
- package/dist/site.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,9 @@ Put your own first name in place of Ada. When it's done, a QR code appears in yo
|
|
|
24
24
|
Scan it with your phone on the same Wi-Fi to open your cards, save them and copy a ready-made
|
|
25
25
|
caption for each platform.
|
|
26
26
|
|
|
27
|
-
Your cards are saved in
|
|
27
|
+
Your cards are saved in a `wrapt-<year>` folder inside the folder you ran the command from,
|
|
28
|
+
with a ZIP of each set. Your private stats stay separately in `~/.wrapt/<year>/`. To open the
|
|
29
|
+
cards folder:
|
|
28
30
|
|
|
29
31
|
```bash
|
|
30
32
|
npx wrapt-cli open
|
|
@@ -46,8 +48,8 @@ Step-by-step guide: **https://wrapt.cc**
|
|
|
46
48
|
| Format | Size | For |
|
|
47
49
|
|---|---|---|
|
|
48
50
|
| 8 story cards | 1080 × 1920 | Instagram Stories |
|
|
49
|
-
| 8 carousel cards | 1080 × 1350 | Instagram carousel post |
|
|
50
|
-
| 8-page PDF | 1080 × 1350 | LinkedIn document post |
|
|
51
|
+
| 8 carousel cards | 1080 × 1350 | Instagram carousel, or a LinkedIn image post (easiest) |
|
|
52
|
+
| 8-page PDF | 1080 × 1350 | LinkedIn document post (swipeable in the feed) |
|
|
51
53
|
| 1 summary card | 1200 × 675 | X |
|
|
52
54
|
|
|
53
55
|
The eight cards: your name and year, your biggest number (tokens, hours or prompts), when you
|
package/dist/analyze.js
CHANGED
|
@@ -27,9 +27,14 @@ export async function analyze(opts) {
|
|
|
27
27
|
const outDir = opts.outDir ?? path.join(wraptHome(), String(opts.year));
|
|
28
28
|
fs.mkdirSync(outDir, { recursive: true, mode: 0o700 });
|
|
29
29
|
const statsPath = path.join(outDir, "stats.json");
|
|
30
|
-
const samplesPath = path.join(outDir, "samples.json");
|
|
31
30
|
fs.writeFileSync(statsPath, JSON.stringify(stats, null, 2) + "\n", { mode: 0o600 });
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const samplesPath = path.join(outDir, "samples.json");
|
|
32
|
+
if (opts.samples) {
|
|
33
|
+
// samples.json holds prompt excerpts: private, local only, never rendered. Only the /wrapt skill needs it.
|
|
34
|
+
fs.writeFileSync(samplesPath, JSON.stringify({ year: opts.year, samples }, null, 2) + "\n", { mode: 0o600 });
|
|
35
|
+
return { stats, samples, statsPath, samplesPath };
|
|
36
|
+
}
|
|
37
|
+
// Don't leave excerpts from an earlier --samples run lying around.
|
|
38
|
+
fs.rmSync(samplesPath, { force: true });
|
|
39
|
+
return { stats, samples, statsPath };
|
|
35
40
|
}
|
package/dist/cli.js
CHANGED
|
@@ -15,12 +15,17 @@ import { buildSite, pushSite, resolveTarget } from "./publish.js";
|
|
|
15
15
|
import { THEMES } from "./render/theme.js";
|
|
16
16
|
import { StatsSchema } from "./stats/schema.js";
|
|
17
17
|
import { summary } from "./format.js";
|
|
18
|
+
/** A path as the user would type it: ./wrapt-2026 under the current folder, ~/… under home. */
|
|
19
|
+
function shown(p) {
|
|
20
|
+
const rel = path.relative(process.cwd(), p);
|
|
21
|
+
return rel && !rel.startsWith("..") && !path.isAbsolute(rel) ? `./${rel}` : tildify(p);
|
|
22
|
+
}
|
|
18
23
|
const HELP = `wrapt — your year with Claude Code, wrapped. 100% local.
|
|
19
24
|
|
|
20
25
|
Run it with npx: npx wrapt-cli <command> (or install it: npm i -g wrapt-cli, then wrapt <command>)
|
|
21
26
|
|
|
22
27
|
Usage
|
|
23
|
-
wrapt analyze [--year 2026] [--source all|claude|copilot] [--json] [--
|
|
28
|
+
wrapt analyze [--year 2026] [--source all|claude|copilot] [--json] [--samples] [--projects-dir <dir>]
|
|
24
29
|
wrapt render [--year 2026] [--name "Ada"] [--show-projects] [--theme bold|mono|pastel] [--out <dir>]
|
|
25
30
|
wrapt schema [--validate <narrative.json>]
|
|
26
31
|
wrapt share [--year 2026] [--minutes 15] [--port <n>]
|
|
@@ -29,12 +34,13 @@ Usage
|
|
|
29
34
|
wrapt publish --repo <owner/name> [--branch gh-pages] [--url <base>] [--dry-run] [--yes] [--remove]
|
|
30
35
|
|
|
31
36
|
Commands
|
|
32
|
-
analyze Read Claude Code (and GitHub Copilot) history and
|
|
33
|
-
render
|
|
37
|
+
analyze Read Claude Code (and GitHub Copilot) history and save your stats privately in ~/.wrapt/<year>/
|
|
38
|
+
render Make the cards in ./wrapt-<year>/ in the current folder: story and carousel PNGs, a ZIP of
|
|
39
|
+
each, linkedin.pdf and x-card.png
|
|
34
40
|
schema Print the JSON Schema for narrative.json, or --validate a file against it
|
|
35
41
|
share Serve the cards on your Wi-Fi and show a QR code to open them on your phone. No upload.
|
|
36
42
|
airdrop Mac only: AirDrop the cards to your iPhone, where they go straight into Photos.
|
|
37
|
-
open Open
|
|
43
|
+
open Open ./wrapt-<year>/ with your cards and ZIPs (Finder, File Explorer or your file manager).
|
|
38
44
|
publish Opt-in: put the cards on GitHub Pages (a gh-pages branch in YOUR repo) with link previews.
|
|
39
45
|
Uploads only the rendered images, PDF and page. --remove takes the year down again.
|
|
40
46
|
|
|
@@ -44,7 +50,10 @@ Options
|
|
|
44
50
|
copilot-vscode, copilot-cli, or a comma list
|
|
45
51
|
--json Print stats.json to stdout instead of the summary
|
|
46
52
|
--projects-dir Claude Code projects dir (default: ~/.claude/projects)
|
|
47
|
-
--out
|
|
53
|
+
--out Where the cards go, and where share/airdrop/open/publish look for them
|
|
54
|
+
(default: ./wrapt-<year> in the folder you run wrapt from)
|
|
55
|
+
--data Where your private stats live (default: ~/.wrapt/<year>). Never shared.
|
|
56
|
+
--samples analyze: also save samples.json, prompt excerpts for the /wrapt skill. Off by default.
|
|
48
57
|
--name Name for the cover (default: "Your 2026 with Claude")
|
|
49
58
|
--show-projects Put your real project names on the cards (default: "Project A/B/C")
|
|
50
59
|
--theme Colour theme: ${Object.keys(THEMES).join(", ")} (default: bold)
|
|
@@ -60,6 +69,8 @@ async function main(argv) {
|
|
|
60
69
|
"projects-dir": { type: "string" },
|
|
61
70
|
source: { type: "string" },
|
|
62
71
|
out: { type: "string" },
|
|
72
|
+
data: { type: "string" },
|
|
73
|
+
samples: { type: "boolean", default: false },
|
|
63
74
|
name: { type: "string" },
|
|
64
75
|
"show-projects": { type: "boolean", default: false },
|
|
65
76
|
// Older flag: project names are hidden by default now, so this is a no-op kept for scripts.
|
|
@@ -86,11 +97,27 @@ async function main(argv) {
|
|
|
86
97
|
const year = values.year ? Number(values.year) : new Date().getFullYear();
|
|
87
98
|
if (!Number.isInteger(year) || year < 2000 || year > 3000)
|
|
88
99
|
throw new Error(`Invalid --year: ${values.year}`);
|
|
89
|
-
/** The full command to run next, keeping --year/--out so it finds the same cards. */
|
|
90
|
-
const next = (sub) => `npx wrapt-cli ${sub}${values.year ? ` --year ${year}` : ""}${values.out ? ` --out "${values.out}"` : ""}`;
|
|
100
|
+
/** The full command to run next, keeping --year/--out/--data so it finds the same cards. */
|
|
101
|
+
const next = (sub) => `npx wrapt-cli ${sub}${values.year ? ` --year ${year}` : ""}${values.out ? ` --out "${values.out}"` : ""}${values.data ? ` --data "${values.data}"` : ""}`;
|
|
102
|
+
// Two folders, kept apart so the private one never gets shared by accident:
|
|
103
|
+
// cardsDir: the cards, in the folder the command runs from (./wrapt-<year>) unless --out says otherwise
|
|
104
|
+
// dataDir: stats.json, samples.json, narrative.json, report.md, render.json, in ~/.wrapt/<year>
|
|
105
|
+
const cardsDir = path.resolve(values.out ?? `wrapt-${year}`);
|
|
106
|
+
const homeDataDir = path.join(wraptHome(), String(year));
|
|
107
|
+
// A folder given with --out that already holds stats.json (scripts, tests) is used for both.
|
|
108
|
+
const dataDir = values.data ?? (values.out && fs.existsSync(path.join(cardsDir, "stats.json")) ? cardsDir : homeDataDir);
|
|
109
|
+
/** Where existing cards are: ./wrapt-<year>, or ~/.wrapt/<year> for cards made before wrapt 0.1.4. */
|
|
110
|
+
const findCards = () => {
|
|
111
|
+
if (values.out || fs.existsSync(path.join(cardsDir, "story")))
|
|
112
|
+
return cardsDir;
|
|
113
|
+
if (fs.existsSync(path.join(homeDataDir, "story")))
|
|
114
|
+
return homeDataDir;
|
|
115
|
+
throw new Error(`No cards in ${shown(cardsDir)}. Run \`${next("render")}\` here first, or cd to the folder where you ran it.`);
|
|
116
|
+
};
|
|
91
117
|
switch (cmd) {
|
|
92
118
|
case "analyze": {
|
|
93
|
-
|
|
119
|
+
// --out is accepted here for older scripts, where it meant the stats folder.
|
|
120
|
+
const res = await analyze({ year, projectsDir: values["projects-dir"], outDir: values.data ?? values.out, source: values.source, samples: values.samples });
|
|
94
121
|
if (values.json)
|
|
95
122
|
process.stdout.write(JSON.stringify(res.stats, null, 2) + "\n");
|
|
96
123
|
else
|
|
@@ -101,13 +128,13 @@ async function main(argv) {
|
|
|
101
128
|
return;
|
|
102
129
|
}
|
|
103
130
|
case "render": {
|
|
104
|
-
const dir =
|
|
105
|
-
const statsPath = path.join(
|
|
131
|
+
const dir = cardsDir;
|
|
132
|
+
const statsPath = path.join(dataDir, "stats.json");
|
|
106
133
|
if (!fs.existsSync(statsPath))
|
|
107
|
-
throw new Error(`No ${
|
|
134
|
+
throw new Error(`No stats for ${year} yet. Run \`${next("analyze")}\` first.`);
|
|
108
135
|
const stats = StatsSchema.parse(JSON.parse(fs.readFileSync(statsPath, "utf8")));
|
|
109
136
|
let narrative;
|
|
110
|
-
const narrativePath = path.join(
|
|
137
|
+
const narrativePath = path.join(dataDir, "narrative.json");
|
|
111
138
|
if (fs.existsSync(narrativePath)) {
|
|
112
139
|
const parsed = NarrativeSchema.safeParse(JSON.parse(fs.readFileSync(narrativePath, "utf8")));
|
|
113
140
|
if (parsed.success)
|
|
@@ -116,7 +143,7 @@ async function main(argv) {
|
|
|
116
143
|
process.stderr.write(`Ignoring invalid narrative.json:\n${parsed.error.message}\n`);
|
|
117
144
|
}
|
|
118
145
|
const t0 = Date.now();
|
|
119
|
-
const res = await renderAll({ stats, narrative, name: values.name, hideProjects: values["hide-projects"] || !values["show-projects"], theme: values.theme, outDir: dir });
|
|
146
|
+
const res = await renderAll({ stats, narrative, name: values.name, hideProjects: values["hide-projects"] || !values["show-projects"], theme: values.theme, outDir: dir, infoDir: dataDir });
|
|
120
147
|
// Every card of a set in one file, for downloading or sending in one go.
|
|
121
148
|
const zipNames = [];
|
|
122
149
|
for (const [set, buf] of Object.entries(cardZips(dir, year, collectAssets(dir)))) {
|
|
@@ -130,11 +157,11 @@ async function main(argv) {
|
|
|
130
157
|
"",
|
|
131
158
|
` ✓ Your cards are ready (${((Date.now() - t0) / 1000).toFixed(1)}s)${narrative ? "" : ". Card 4 shows your week, and the archetype comes from your rhythm."}`,
|
|
132
159
|
"",
|
|
133
|
-
` Saved in ${
|
|
160
|
+
` Saved in ${shown(dir)}`,
|
|
134
161
|
row("story/", `${n} Instagram Story cards (1080 × 1920)`),
|
|
135
|
-
row("carousel/", `${res.carousel.length}
|
|
162
|
+
row("carousel/", `${res.carousel.length} cards (1080 × 1350) for an Instagram carousel or a LinkedIn image post`),
|
|
136
163
|
...zipNames.map((z) => row(z, `all the ${z.includes("story") ? "story" : "carousel"} cards in one file`)),
|
|
137
|
-
row(path.basename(res.pdf), "LinkedIn document
|
|
164
|
+
row(path.basename(res.pdf), "the same cards as a swipeable LinkedIn document (optional)"),
|
|
138
165
|
row(path.basename(res.xCard), "X post"),
|
|
139
166
|
"",
|
|
140
167
|
" Next",
|
|
@@ -143,12 +170,13 @@ async function main(argv) {
|
|
|
143
170
|
...(process.platform === "darwin" ? [row("Mac + iPhone:", next("airdrop"))] : []),
|
|
144
171
|
"",
|
|
145
172
|
` When you post, link ${SITE_URL} so people can make their own.`,
|
|
173
|
+
...(dataDir !== dir ? [` Your private stats stay in ${shown(dataDir)} and are never shared.`] : []),
|
|
146
174
|
"",
|
|
147
175
|
].join("\n") + "\n");
|
|
148
176
|
return;
|
|
149
177
|
}
|
|
150
178
|
case "share": {
|
|
151
|
-
const dir =
|
|
179
|
+
const dir = findCards();
|
|
152
180
|
const minutes = values.minutes ? Number(values.minutes) : 15;
|
|
153
181
|
if (!(minutes > 0 && minutes <= 120))
|
|
154
182
|
throw new Error("--minutes must be between 1 and 120");
|
|
@@ -190,7 +218,6 @@ async function main(argv) {
|
|
|
190
218
|
return;
|
|
191
219
|
}
|
|
192
220
|
case "publish": {
|
|
193
|
-
const dir = values.out ?? path.join(wraptHome(), String(year));
|
|
194
221
|
const branch = values.branch ?? "gh-pages";
|
|
195
222
|
if (!values.repo && !values["dry-run"])
|
|
196
223
|
throw new Error("Pass --repo <owner/name> (an existing GitHub repo you can push to), or --dry-run.");
|
|
@@ -214,13 +241,15 @@ async function main(argv) {
|
|
|
214
241
|
process.stdout.write(changed ? ` Removed ${target.pageUrl}\n` : ` Nothing to remove for ${year}.\n`);
|
|
215
242
|
return;
|
|
216
243
|
}
|
|
217
|
-
const
|
|
244
|
+
const dir = findCards();
|
|
245
|
+
const statsPath = path.join(dataDir, "stats.json");
|
|
218
246
|
if (!fs.existsSync(statsPath))
|
|
219
|
-
throw new Error(`No ${
|
|
247
|
+
throw new Error(`No stats for ${year} yet. Run \`${next("analyze")}\` and \`${next("render")}\` first.`);
|
|
220
248
|
const stats = StatsSchema.parse(JSON.parse(fs.readFileSync(statsPath, "utf8")));
|
|
221
249
|
const renderInfo = (() => {
|
|
222
250
|
try {
|
|
223
|
-
|
|
251
|
+
const info = [dataDir, dir].map((d) => path.join(d, "render.json")).find((f) => fs.existsSync(f)) ?? "";
|
|
252
|
+
return JSON.parse(fs.readFileSync(info, "utf8"));
|
|
224
253
|
}
|
|
225
254
|
catch {
|
|
226
255
|
return {};
|
|
@@ -239,13 +268,20 @@ async function main(argv) {
|
|
|
239
268
|
}
|
|
240
269
|
process.stdout.write(L.join("\n") + "\n");
|
|
241
270
|
if (values["dry-run"]) {
|
|
242
|
-
process.stdout.write(`\n Dry run: nothing uploaded. Open ${path.join(siteDir, "index.html")} to preview.\n`);
|
|
271
|
+
process.stdout.write(`\n Dry run: nothing uploaded. Open ${path.join(siteDir, "index.html")} to preview (a temporary copy).\n`);
|
|
243
272
|
return;
|
|
244
273
|
}
|
|
274
|
+
const cleanup = () => fs.rmSync(siteDir, { recursive: true, force: true });
|
|
245
275
|
process.stdout.write(`\n This makes the cards PUBLIC at ${target.pageUrl}\n (pushed to ${target.remote}, branch ${branch}). You can undo it with --remove.\n`);
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
276
|
+
let changed;
|
|
277
|
+
try {
|
|
278
|
+
if (!(await confirm(" Publish? [y/N] ")))
|
|
279
|
+
return void process.stdout.write(" Cancelled. Nothing was uploaded.\n");
|
|
280
|
+
changed = pushSite({ remote: target.remote, branch, year, siteDir, message: `wrapt: publish ${year} cards` });
|
|
281
|
+
}
|
|
282
|
+
finally {
|
|
283
|
+
cleanup();
|
|
284
|
+
}
|
|
249
285
|
process.stdout.write([
|
|
250
286
|
"",
|
|
251
287
|
changed ? ` ✓ Published → ${target.pageUrl}` : ` Already up to date → ${target.pageUrl}`,
|
|
@@ -256,13 +292,13 @@ async function main(argv) {
|
|
|
256
292
|
return;
|
|
257
293
|
}
|
|
258
294
|
case "airdrop": {
|
|
259
|
-
const dir = values.out ?? path.join(wraptHome(), String(year));
|
|
260
295
|
const set = values.set ?? "story";
|
|
261
296
|
if (!["story", "carousel", "all"].includes(set))
|
|
262
297
|
throw new Error("--set must be story, carousel or all");
|
|
263
298
|
if (process.platform !== "darwin") {
|
|
264
299
|
throw new Error("AirDrop needs a Mac. Use `wrapt share` instead: it shows a QR code to open the cards on your phone.");
|
|
265
300
|
}
|
|
301
|
+
const dir = findCards();
|
|
266
302
|
const assets = collectAssets(dir);
|
|
267
303
|
const rels = set === "story" ? assets.story : set === "carousel" ? assets.carousel : [...assets.story, ...assets.carousel, ...(assets.xCard ? [assets.xCard] : [])];
|
|
268
304
|
if (!rels.length)
|
|
@@ -288,16 +324,16 @@ async function main(argv) {
|
|
|
288
324
|
return;
|
|
289
325
|
}
|
|
290
326
|
case "open": {
|
|
291
|
-
const dir = values.out ?? path.join(wraptHome(), String(year));
|
|
292
327
|
const set = values.set;
|
|
293
328
|
if (set && !["story", "carousel"].includes(set))
|
|
294
329
|
throw new Error("--set must be story or carousel");
|
|
330
|
+
const dir = findCards();
|
|
295
331
|
const target = set ? path.join(dir, set) : dir;
|
|
296
332
|
if (!fs.existsSync(target))
|
|
297
|
-
throw new Error(`No cards in ${
|
|
333
|
+
throw new Error(`No ${set} cards in ${shown(dir)}. Run \`${next("render")}\` first.`);
|
|
298
334
|
const opened = await openFolder(target);
|
|
299
335
|
process.stdout.write(opened
|
|
300
|
-
? ` Opened ${
|
|
336
|
+
? ` Opened ${shown(target)}\n`
|
|
301
337
|
: ` Couldn't open a file browser here. Your cards are in:\n ${target}\n`);
|
|
302
338
|
return;
|
|
303
339
|
}
|
package/dist/format.js
CHANGED
|
@@ -79,7 +79,8 @@ export function summary(s, paths) {
|
|
|
79
79
|
const excluded = Object.values(p.excludedUser).reduce((a, b) => a + b, 0);
|
|
80
80
|
L.push(dim(` parsed ${p.files} files · ${p.lines} lines · ${p.malformed} malformed · ${p.duplicates} duplicates · ${skipped} non-chat lines · ${excluded} non-prompt user lines`));
|
|
81
81
|
L.push(dim(` → ${paths.stats}`));
|
|
82
|
-
|
|
82
|
+
if (paths.samples)
|
|
83
|
+
L.push(dim(` → ${paths.samples} (private, stays on this machine)`));
|
|
83
84
|
L.push("");
|
|
84
85
|
return L.join("\n");
|
|
85
86
|
}
|
package/dist/publish.js
CHANGED
|
@@ -42,8 +42,8 @@ export function buildSite(o) {
|
|
|
42
42
|
const assets = collectAssets(o.dir);
|
|
43
43
|
if (!assets.story.length || !assets.xCard)
|
|
44
44
|
throw new Error(`No rendered cards in ${o.dir}. Run \`wrapt render\` first.`);
|
|
45
|
-
|
|
46
|
-
fs.
|
|
45
|
+
// Built in a temporary folder, never next to the cards, so no copy is left behind after publishing.
|
|
46
|
+
const siteDir = fs.mkdtempSync(path.join(os.tmpdir(), "wrapt-site-"));
|
|
47
47
|
const files = [];
|
|
48
48
|
const copy = (rel, from = path.join(o.dir, rel)) => {
|
|
49
49
|
fs.mkdirSync(path.dirname(path.join(siteDir, rel)), { recursive: true });
|
package/dist/render/index.js
CHANGED
|
@@ -54,19 +54,31 @@ export async function renderAll(opts) {
|
|
|
54
54
|
fs.writeFileSync(out.xCard, await toPng(Outro(ctxFor(SIZES.x, CARDS.length - 1)), SIZES.x));
|
|
55
55
|
fs.writeFileSync(out.pdf, await carouselPdf(carouselPngs, opts.stats.year, brandFor(opts.stats).long));
|
|
56
56
|
// Remember how the cards were made, so `wrapt publish` can warn before project names go public.
|
|
57
|
-
fs.writeFileSync(path.join(opts.outDir, "render.json"), JSON.stringify({ name: opts.name ?? null, hideProjects: opts.hideProjects ?? true, theme: opts.theme ?? "bold", renderedAt: new Date().toISOString() }, null, 2) + "\n");
|
|
57
|
+
fs.writeFileSync(path.join(opts.infoDir ?? opts.outDir, "render.json"), JSON.stringify({ name: opts.name ?? null, hideProjects: opts.hideProjects ?? true, theme: opts.theme ?? "bold", renderedAt: new Date().toISOString() }, null, 2) + "\n", { mode: 0o600 });
|
|
58
|
+
fs.chmodSync(path.join(opts.infoDir ?? opts.outDir, "render.json"), 0o600); // also when the file already existed
|
|
58
59
|
return out;
|
|
59
60
|
}
|
|
60
|
-
/**
|
|
61
|
+
/** Points per pixel: a 1080 × 1350 px card becomes an 810 × 1012.5 pt page (11.25 × 14.06 in at 96 dpi), the size design tools export for LinkedIn. */
|
|
62
|
+
export const PDF_SCALE = 0.75;
|
|
63
|
+
/**
|
|
64
|
+
* One carousel card per page. LinkedIn shows a PDF document post as a swipeable carousel.
|
|
65
|
+
* Kept deliberately plain so LinkedIn's document processing accepts it: a classic cross-reference
|
|
66
|
+
* table instead of compressed object streams, ordinary page sizes, and full-resolution images.
|
|
67
|
+
*/
|
|
61
68
|
export async function carouselPdf(pngs, year, tool = "Claude Code") {
|
|
62
69
|
const doc = await PDFDocument.create();
|
|
63
|
-
|
|
70
|
+
const title = `My ${year} with ${tool}`;
|
|
71
|
+
doc.setTitle(title);
|
|
72
|
+
doc.setSubject(`${title}, made with wrapt`);
|
|
64
73
|
doc.setCreator("wrapt");
|
|
65
74
|
doc.setProducer("wrapt");
|
|
75
|
+
doc.setLanguage("en");
|
|
66
76
|
for (const png of pngs) {
|
|
67
77
|
const img = await doc.embedPng(png);
|
|
68
|
-
const
|
|
69
|
-
|
|
78
|
+
const w = img.width * PDF_SCALE;
|
|
79
|
+
const h = img.height * PDF_SCALE;
|
|
80
|
+
const page = doc.addPage([w, h]);
|
|
81
|
+
page.drawImage(img, { x: 0, y: 0, width: w, height: h });
|
|
70
82
|
}
|
|
71
|
-
return doc.save();
|
|
83
|
+
return doc.save({ useObjectStreams: false });
|
|
72
84
|
}
|
package/dist/share/page.js
CHANGED
|
@@ -96,8 +96,8 @@ export function sharePage(a, o) {
|
|
|
96
96
|
|
|
97
97
|
${a.carousel.length
|
|
98
98
|
? `<div class="wrap">
|
|
99
|
-
<h2>
|
|
100
|
-
<p>4:5 cards
|
|
99
|
+
<h2>Instagram carousel & LinkedIn</h2>
|
|
100
|
+
<p>4:5 cards. Post all ${a.carousel.length} as an Instagram carousel, or as a LinkedIn image post.</p>
|
|
101
101
|
<div class="actions"><button class="btn secondary" id="save-carousel" data-set="carousel">Save all ${a.carousel.length} carousel cards</button></div>
|
|
102
102
|
<div class="hint" id="hint-carousel"></div>
|
|
103
103
|
<div class="grid">${a.carousel.map((r, i) => card(r, i, "carousel")).join("")}
|
|
@@ -107,8 +107,11 @@ ${a.carousel.length
|
|
|
107
107
|
|
|
108
108
|
<div class="wrap">
|
|
109
109
|
${a.pdf
|
|
110
|
-
? `<h2>LinkedIn
|
|
111
|
-
<p>
|
|
110
|
+
? `<h2>LinkedIn</h2>
|
|
111
|
+
<p><b>Easiest:</b> post the ${a.carousel.length} carousel cards as an image post. LinkedIn shows them as a grid that opens into a swipeable viewer.</p>
|
|
112
|
+
${a.carousel.length ? `<div class="actions"><button class="btn secondary" id="save-linkedin" data-set="carousel" data-hint="linkedin">Save all ${a.carousel.length} for LinkedIn</button></div>
|
|
113
|
+
<div class="hint" id="hint-linkedin"></div>` : ""}
|
|
114
|
+
<p><b>Swipeable in the feed:</b> post the same cards as one PDF document. It takes a few more steps on LinkedIn.</p>
|
|
112
115
|
<div class="actions"><a class="btn secondary" href="${esc(dl(a.pdf))}" download>Download linkedin.pdf</a></div>`
|
|
113
116
|
: ""}
|
|
114
117
|
${a.xCard
|
|
@@ -122,7 +125,8 @@ ${a.carousel.length
|
|
|
122
125
|
<ol>
|
|
123
126
|
<li><b>Instagram Story.</b> Post the 8 story cards in order as one story. On the last card, add a <b>link sticker</b> with ${esc(SITE_URL)} so people can tap through and make their own. Afterwards, add them to a Highlight called “${o.year}” so they stay on your profile.</li>
|
|
124
127
|
<li><b>Instagram carousel.</b> New post → select multiple → choose carousel cards 01–08 in order. The 4:5 size fills the feed. Put ${esc(SITE)} in your bio, since links in captions can't be tapped.</li>
|
|
125
|
-
<li><b>LinkedIn.</b> Start a post →
|
|
128
|
+
<li><b>LinkedIn, easiest.</b> Start a post → add photos → pick the ${a.carousel.length} carousel cards in order → add the caption below → Post.</li>
|
|
129
|
+
<li><b>LinkedIn, swipeable.</b> Start a post → “Add a document” → upload linkedin.pdf → give it a title → Post. It shows as a carousel people swipe in the feed.</li>
|
|
126
130
|
<li><b>X.</b> Attach x-card.png to a post.</li>
|
|
127
131
|
</ol>
|
|
128
132
|
|
|
@@ -154,7 +158,7 @@ ${a.carousel.length
|
|
|
154
158
|
var ua = navigator.userAgent;
|
|
155
159
|
var iOS = /iPhone|iPad|iPod/.test(ua) || (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
|
|
156
160
|
|
|
157
|
-
function
|
|
161
|
+
function showHint(name, html) {
|
|
158
162
|
var el = document.getElementById("hint-" + name);
|
|
159
163
|
if (el) { el.innerHTML = html; el.classList.add("show"); }
|
|
160
164
|
}
|
|
@@ -194,6 +198,8 @@ ${a.carousel.length
|
|
|
194
198
|
btn.addEventListener("click", async function () {
|
|
195
199
|
var name = btn.getAttribute("data-set");
|
|
196
200
|
var urls = sets[name];
|
|
201
|
+
var where = btn.getAttribute("data-hint") || name;
|
|
202
|
+
var hint = function (_, html) { showHint(where, html); };
|
|
197
203
|
btn.disabled = true;
|
|
198
204
|
try {
|
|
199
205
|
// On a phone over HTTPS, the share sheet saves every card straight to Photos in one go.
|
package/dist/site.js
CHANGED
|
@@ -43,7 +43,7 @@ export function captions(year, tool = "Claude Code") {
|
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
platform: "LinkedIn",
|
|
46
|
-
tip: "Paste this as the post text above linkedin.pdf.",
|
|
46
|
+
tip: "Paste this as the post text above your 8 carousel images, or above linkedin.pdf.",
|
|
47
47
|
text: `My ${year} with ${tool}, in eight cards. wrapt reads your ${tool} history on your own computer ` +
|
|
48
48
|
`and turns it into a year in review. Nothing is uploaded.\n\nMake yours: ${SITE_URL}`,
|
|
49
49
|
},
|