@deskwork/studio 0.15.0 → 0.17.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.
Files changed (75) hide show
  1. package/dist/components/scrapbook-item.d.ts +20 -0
  2. package/dist/components/scrapbook-item.d.ts.map +1 -1
  3. package/dist/components/scrapbook-item.js +21 -2
  4. package/dist/components/scrapbook-item.js.map +1 -1
  5. package/dist/lib/entry-resolver.d.ts +19 -6
  6. package/dist/lib/entry-resolver.d.ts.map +1 -1
  7. package/dist/lib/entry-resolver.js +40 -33
  8. package/dist/lib/entry-resolver.js.map +1 -1
  9. package/dist/pages/dashboard/affordances.d.ts.map +1 -1
  10. package/dist/pages/dashboard/affordances.js +13 -1
  11. package/dist/pages/dashboard/affordances.js.map +1 -1
  12. package/dist/pages/dashboard/affordances.ts +13 -1
  13. package/dist/pages/review-scrapbook-drawer.d.ts.map +1 -1
  14. package/dist/pages/review-scrapbook-drawer.js +10 -1
  15. package/dist/pages/review-scrapbook-drawer.js.map +1 -1
  16. package/dist/pages/review-scrapbook-drawer.ts +11 -1
  17. package/dist/pages/scrapbook/dispatch.d.ts +50 -0
  18. package/dist/pages/scrapbook/dispatch.d.ts.map +1 -0
  19. package/dist/pages/scrapbook/dispatch.js +104 -0
  20. package/dist/pages/scrapbook/dispatch.js.map +1 -0
  21. package/dist/pages/scrapbook/image-readers.d.ts +24 -0
  22. package/dist/pages/scrapbook/image-readers.d.ts.map +1 -0
  23. package/dist/pages/scrapbook/image-readers.js +135 -0
  24. package/dist/pages/scrapbook/image-readers.js.map +1 -0
  25. package/dist/pages/scrapbook/index.d.ts +21 -0
  26. package/dist/pages/scrapbook/index.d.ts.map +1 -0
  27. package/dist/pages/scrapbook/index.js +96 -0
  28. package/dist/pages/scrapbook/index.js.map +1 -0
  29. package/dist/pages/scrapbook/render.d.ts +68 -0
  30. package/dist/pages/scrapbook/render.d.ts.map +1 -0
  31. package/dist/pages/scrapbook/render.js +315 -0
  32. package/dist/pages/scrapbook/render.js.map +1 -0
  33. package/dist/pages/scrapbook/text-helpers.d.ts +40 -0
  34. package/dist/pages/scrapbook/text-helpers.d.ts.map +1 -0
  35. package/dist/pages/scrapbook/text-helpers.js +92 -0
  36. package/dist/pages/scrapbook/text-helpers.js.map +1 -0
  37. package/dist/pages/scrapbook/types.d.ts +26 -0
  38. package/dist/pages/scrapbook/types.d.ts.map +1 -0
  39. package/dist/pages/scrapbook/types.js +12 -0
  40. package/dist/pages/scrapbook/types.js.map +1 -0
  41. package/dist/pages/scrapbook.d.ts +8 -8
  42. package/dist/pages/scrapbook.d.ts.map +1 -1
  43. package/dist/pages/scrapbook.js +8 -600
  44. package/dist/pages/scrapbook.js.map +1 -1
  45. package/dist/pages/scrapbook.ts +11 -660
  46. package/dist/routes/api.d.ts.map +1 -1
  47. package/dist/routes/api.js +111 -2
  48. package/dist/routes/api.js.map +1 -1
  49. package/dist/routes/entry-annotation-body.d.ts +29 -0
  50. package/dist/routes/entry-annotation-body.d.ts.map +1 -1
  51. package/dist/routes/entry-annotation-body.js +80 -0
  52. package/dist/routes/entry-annotation-body.js.map +1 -1
  53. package/dist/routes/scrapbook-file.d.ts +1 -1
  54. package/dist/routes/scrapbook-file.js +1 -1
  55. package/dist/routes/scrapbook-mutation-dispatch.d.ts +29 -0
  56. package/dist/routes/scrapbook-mutation-dispatch.d.ts.map +1 -0
  57. package/dist/routes/scrapbook-mutation-dispatch.js +63 -0
  58. package/dist/routes/scrapbook-mutation-dispatch.js.map +1 -0
  59. package/dist/routes/scrapbook-mutation-envelope.d.ts +93 -0
  60. package/dist/routes/scrapbook-mutation-envelope.d.ts.map +1 -0
  61. package/dist/routes/scrapbook-mutation-envelope.js +147 -0
  62. package/dist/routes/scrapbook-mutation-envelope.js.map +1 -0
  63. package/dist/routes/scrapbook-mutations.d.ts +25 -7
  64. package/dist/routes/scrapbook-mutations.d.ts.map +1 -1
  65. package/dist/routes/scrapbook-mutations.js +67 -92
  66. package/dist/routes/scrapbook-mutations.js.map +1 -1
  67. package/dist/server.d.ts.map +1 -1
  68. package/dist/server.js +16 -2
  69. package/dist/server.js.map +1 -1
  70. package/package.json +2 -2
  71. package/dist/pages/review.d.ts +0 -68
  72. package/dist/pages/review.d.ts.map +0 -1
  73. package/dist/pages/review.js +0 -561
  74. package/dist/pages/review.js.map +0 -1
  75. package/dist/pages/review.ts +0 -710
@@ -0,0 +1,315 @@
1
+ /**
2
+ * Scrapbook page render helpers — RawHtml emitters for cards, previews,
3
+ * the aside, the new-note composer, the drop zone, the secret section,
4
+ * and the breadcrumb / search / filter chrome.
5
+ *
6
+ * Reads filesystem only via `computeKindMeta` and `renderPreview`; both
7
+ * resolve through the pre-resolved `RenderCtx.scrapbookDir` (set by the
8
+ * dispatch step) so render stays free of path-resolution logic.
9
+ */
10
+ import { readFileSync } from 'node:fs';
11
+ import { formatRelativeTime, formatSize, scrapbookFilePathAtDir, } from '@deskwork/core/scrapbook';
12
+ import { html, unsafe } from "../html.js";
13
+ import { countJsonKeys, countLines, escapeHtml, previewExcerpt, } from "./text-helpers.js";
14
+ import { readImageDimensions } from "./image-readers.js";
15
+ const KIND_LABEL = {
16
+ md: 'MD',
17
+ img: 'IMG',
18
+ json: 'JSON',
19
+ js: 'JS',
20
+ txt: 'TXT',
21
+ other: '·',
22
+ };
23
+ export function countByKind(items) {
24
+ const counts = {
25
+ all: items.length,
26
+ md: 0,
27
+ img: 0,
28
+ json: 0,
29
+ js: 0,
30
+ txt: 0,
31
+ other: 0,
32
+ };
33
+ for (const i of items)
34
+ counts[i.kind]++;
35
+ return counts;
36
+ }
37
+ /**
38
+ * Compute the per-kind extra meta string shown after the kind chip + size:
39
+ * md / txt → "{N} lines"
40
+ * json → "{N} keys" (root must be a plain object; otherwise empty)
41
+ * img → "{W} × {H}" (PNG only; other formats → empty)
42
+ * other → empty
43
+ *
44
+ * ENOENT (race-window with delete) returns empty so the card still
45
+ * renders; other errors propagate to the page renderer.
46
+ */
47
+ export function computeKindMeta(rctx, item, opts = {}) {
48
+ if (item.kind !== 'md' && item.kind !== 'txt' && item.kind !== 'json' && item.kind !== 'img') {
49
+ return '';
50
+ }
51
+ let buf;
52
+ try {
53
+ const fullPath = scrapbookFilePathAtDir(rctx.scrapbookDir, item.name, opts.secret ? { secret: true } : {});
54
+ buf = readFileSync(fullPath);
55
+ }
56
+ catch (e) {
57
+ if (e instanceof Error && 'code' in e && e.code === 'ENOENT')
58
+ return '';
59
+ throw e;
60
+ }
61
+ if (item.kind === 'md' || item.kind === 'txt')
62
+ return `${countLines(buf)} lines`;
63
+ if (item.kind === 'json') {
64
+ const keys = countJsonKeys(buf);
65
+ return keys !== null ? `${keys} keys` : '';
66
+ }
67
+ // img
68
+ const dims = readImageDimensions(buf);
69
+ return dims ? `${dims.width} × ${dims.height}` : '';
70
+ }
71
+ /**
72
+ * Build the file-fetch URL for the read-only binary endpoint. Prefers
73
+ * entry-aware addressing when `rctx.entryId` is set (#205); falls back
74
+ * to slug-template addressing (`path=`) otherwise.
75
+ */
76
+ function buildFileFetchUrl(rctx, filename, secret) {
77
+ const params = new URLSearchParams({ site: rctx.site, name: filename });
78
+ if (rctx.entryId !== undefined && rctx.entryId.length > 0) {
79
+ params.set('entryId', rctx.entryId);
80
+ }
81
+ else {
82
+ params.set('path', rctx.path);
83
+ }
84
+ if (secret)
85
+ params.set('secret', '1');
86
+ return `/api/dev/scrapbook-file?${params.toString()}`;
87
+ }
88
+ /**
89
+ * Server-side preview for the closed-state card. Img → bg-frame URL;
90
+ * md → italic Newsreader excerpt with frontmatter stripped; json → mono
91
+ * pre with parse-then-stringify pretty-print; txt → mono pre raw excerpt.
92
+ * Other / empty / binary-as-text → no preview block.
93
+ */
94
+ export function renderPreview(rctx, item, opts = {}) {
95
+ const { secret = false } = opts;
96
+ if (item.kind === 'img') {
97
+ const url = buildFileFetchUrl(rctx, item.name, secret);
98
+ return unsafe(html `
99
+ <div class="scrap-preview scrap-preview--img" aria-hidden="true">
100
+ <div class="scrap-preview--img-frame" style="background-image: url(&quot;${url}&quot;);"></div>
101
+ </div>`);
102
+ }
103
+ if (item.kind !== 'md' && item.kind !== 'txt' && item.kind !== 'json') {
104
+ return unsafe('');
105
+ }
106
+ try {
107
+ const fullPath = scrapbookFilePathAtDir(rctx.scrapbookDir, item.name, secret ? { secret: true } : {});
108
+ const buf = readFileSync(fullPath);
109
+ const excerpt = previewExcerpt(buf, item.kind);
110
+ if (excerpt === null)
111
+ return unsafe('');
112
+ const safe = escapeHtml(excerpt);
113
+ if (item.kind === 'json' || item.kind === 'txt') {
114
+ return unsafe(html `
115
+ <pre class="scrap-preview scrap-preview--mono" aria-hidden="true">${unsafe(safe)}</pre>`);
116
+ }
117
+ return unsafe(html `
118
+ <div class="scrap-preview scrap-preview-md" aria-hidden="true"><p>${unsafe(safe)}</p></div>`);
119
+ }
120
+ catch (e) {
121
+ // ENOENT = file disappeared between listScrapbook and this read (race
122
+ // window with delete); rendering an empty preview is the right call.
123
+ // Anything else (EACCES, EISDIR, encoding bugs) propagates so the
124
+ // operator sees a real error instead of a silently-broken page.
125
+ if (e instanceof Error && 'code' in e && e.code === 'ENOENT') {
126
+ return unsafe('');
127
+ }
128
+ throw e;
129
+ }
130
+ }
131
+ export function renderFilterChips(counts) {
132
+ const chip = (kind, label, isAll = false) => unsafe(html `
133
+ <button class="scrap-filter" type="button" data-filter="${kind}"
134
+ aria-pressed="${isAll ? 'true' : 'false'}">${label} · ${counts[kind]}</button>`);
135
+ return unsafe(html `
136
+ <div class="scrap-filters" role="toolbar" aria-label="filter by kind">
137
+ ${chip('all', 'all', true)}
138
+ ${chip('md', 'md')}
139
+ ${chip('img', 'img')}
140
+ ${chip('json', 'json')}
141
+ ${chip('txt', 'txt')}
142
+ ${chip('other', 'other')}
143
+ </div>`);
144
+ }
145
+ export function renderSearch() {
146
+ return unsafe(html `
147
+ <div class="scrap-search">
148
+ <input type="search" placeholder="filter by name or content" aria-label="filter scrapbook" data-scrap-search />
149
+ <span class="scrap-search-kbd">/</span>
150
+ </div>`);
151
+ }
152
+ export function renderBreadcrumb(site, path) {
153
+ const segments = path.split('/').filter(Boolean);
154
+ const last = segments[segments.length - 1] ?? path;
155
+ return unsafe(html `
156
+ <nav class="scrap-breadcrumb" aria-label="hierarchy">
157
+ <a href="/dev/content/${site}">${site}</a><span class="sep">›</span>
158
+ <b>${last}</b>
159
+ </nav>`);
160
+ }
161
+ export function renderAside(site, path, items, totalSize, lastModified, secretCount, reviewLink) {
162
+ const lastModifiedLabel = lastModified ? formatRelativeTime(lastModified) : '—';
163
+ const publicCount = items.length;
164
+ const sizeLabel = formatSize(totalSize);
165
+ const folderLabel = path.split('/').filter(Boolean).pop() ?? path;
166
+ const fullPath = `${site}/${path}/scrapbook/`;
167
+ // #168 Phase 34 ship-pass — when this scrapbook belongs to a tracked
168
+ // calendar entry, expose a "← back to review" link so the operator
169
+ // who arrived from the entry-review surface (or via the dashboard's
170
+ // scrapbook chip) has an obvious path back. Pre-fix the only nav
171
+ // affordance was the breadcrumb's site link, which lands on the
172
+ // content tree, not the entry-review.
173
+ const backLink = reviewLink !== null
174
+ ? unsafe(html `<p class="scrap-aside-back"><a href="${reviewLink}">← back to review</a></p><hr />`)
175
+ : unsafe('');
176
+ return unsafe(html `
177
+ <aside class="scrap-aside">
178
+ ${backLink}
179
+ <p class="scrap-aside-kicker"><em>§</em> The folder</p>
180
+ <h1 class="scrap-aside-title">${folderLabel}</h1>
181
+ <p class="scrap-aside-meta">${site}</p>
182
+ <hr />
183
+ <p class="scrap-aside-totals">
184
+ <strong>${publicCount}</strong> public ·
185
+ <strong>${secretCount}</strong> secret ·
186
+ <em>${sizeLabel}</em>
187
+ </p>
188
+ <p class="scrap-aside-meta">last modified ${lastModifiedLabel}</p>
189
+ <hr />
190
+ <ol class="scrap-aside-list" data-scrap-aside-list>
191
+ ${items.map((item, i) => {
192
+ const seq = String(i + 1).padStart(2, '0');
193
+ return unsafe(html `<li><span class="num">${seq}</span><a href="#item-${i + 1}" data-scrap-aside-link>${item.name}</a></li>`);
194
+ })}
195
+ </ol>
196
+ <hr />
197
+ <div class="scrap-aside-actions">
198
+ <button class="scrap-aside-btn scrap-aside-btn--primary" type="button" data-action="new-note">+ new note</button>
199
+ <button class="scrap-aside-btn" type="button" data-action="upload">+ upload file</button>
200
+ </div>
201
+ <hr />
202
+ <p class="scrap-aside-path">${fullPath}</p>
203
+ </aside>`);
204
+ }
205
+ export function renderCard(rctx, item, index, opts = {}) {
206
+ const { secret = false } = opts;
207
+ const seq = String(index + 1).padStart(2, '0');
208
+ const kindLabel = KIND_LABEL[item.kind];
209
+ const kindClass = item.kind === 'other' ? '' : `scrap-kind--${item.kind}`;
210
+ const time = item.mtime
211
+ ? html `<time class="scrap-time" datetime="${item.mtime}">${formatRelativeTime(item.mtime)}</time>`
212
+ : '';
213
+ const preview = renderPreview(rctx, item, { secret });
214
+ const kindMeta = computeKindMeta(rctx, item, { secret });
215
+ const kindMetaHtml = kindMeta
216
+ ? unsafe(html `<span>·</span><span>${kindMeta}</span>`)
217
+ : unsafe('');
218
+ const editBtn = item.kind === 'img'
219
+ ? unsafe('')
220
+ : unsafe(html `<button class="scrap-tool" type="button" data-action="edit">edit</button>`);
221
+ // Secret cards get id="secret-item-N" to disambiguate from public ids in
222
+ // restoreFromHash + aside cross-link lookups (F4 contract); the
223
+ // mark-secret action toggle reads "mark public" since clicking it moves
224
+ // the card OUT of the secret section.
225
+ const id = secret ? `secret-item-${index + 1}` : `item-${index + 1}`;
226
+ const markSecretLabel = secret ? 'mark public' : 'mark secret';
227
+ const dataSecretAttr = secret ? ' data-secret="true"' : '';
228
+ // #164 Phase 34b — small ⚿ glyph next to .scrap-name on secret
229
+ // cards. Provides visual continuity for the secret marker once a
230
+ // card is expanded (where it grows outside the grouped section's
231
+ // visual scope).
232
+ const secretGlyph = secret
233
+ ? unsafe(html `<span class="scrap-name-secret-mark" aria-label="secret" title="secret — never published">⚿</span>`)
234
+ : unsafe('');
235
+ return unsafe(html `
236
+ <li class="scrap-card" data-kind="${item.kind}" data-state="closed" id="${id}"${unsafe(dataSecretAttr)}>
237
+ <div class="scrap-card-head">
238
+ <span class="scrap-seq">N° ${seq}</span>
239
+ ${secretGlyph}
240
+ <span class="scrap-name" data-action="open">${item.name}</span>
241
+ ${unsafe(time)}
242
+ </div>
243
+ <div class="scrap-card-meta">
244
+ <span class="scrap-kind ${kindClass}">${kindLabel}</span>
245
+ <span class="scrap-size">${formatSize(item.size)}</span>
246
+ ${kindMetaHtml}
247
+ </div>
248
+ ${preview}
249
+ <div class="scrap-card-foot">
250
+ <button class="scrap-tool scrap-tool--primary" type="button" data-action="open">open</button>
251
+ ${editBtn}
252
+ <button class="scrap-tool" type="button" data-action="rename">rename</button>
253
+ <button class="scrap-tool" type="button" data-action="mark-secret">${markSecretLabel}</button>
254
+ <span class="spacer"></span>
255
+ <button class="scrap-tool scrap-tool--delete" type="button" data-action="delete">delete</button>
256
+ </div>
257
+ </li>`);
258
+ }
259
+ /**
260
+ * Inline new-note composer (Phase 34b — #166).
261
+ *
262
+ * Mirrors the pre-F1 inline composer (`44094ee^:scrapbook.ts:274-294`),
263
+ * adapted to the F1 `.scrap-*` design vocabulary. Hidden by default;
264
+ * the aside's `+ new note` button reveals it via the client wire-up.
265
+ *
266
+ * Per `.claude/rules/affordance-placement.md`: component-attached to
267
+ * the page (not a generic toolbar), placed where the resulting note
268
+ * will appear in sorted position. Direct manipulation: in-page form,
269
+ * filename + body + secret toggle visible inline, Cmd/Ctrl+S saves,
270
+ * Esc cancels. Replaces the F1 `window.prompt()` regression (#166).
271
+ */
272
+ export function renderComposer() {
273
+ return unsafe(html `
274
+ <form class="scrap-composer" data-scrap-composer hidden>
275
+ <header class="scrap-composer-head">
276
+ <span class="scrap-composer-glyph" aria-hidden="true">✎</span>
277
+ <span class="scrap-composer-kicker">NEW NOTE</span>
278
+ <input type="text" class="scrap-composer-filename" data-composer-filename
279
+ placeholder="note-name.md" aria-label="new note filename" />
280
+ <label class="scrap-composer-secret" title="save under scrapbook/secret/ — never published">
281
+ <input type="checkbox" data-composer-secret />
282
+ <span>secret</span>
283
+ </label>
284
+ <button class="scrap-tool" type="button" data-action="composer-cancel">cancel</button>
285
+ <button class="scrap-tool scrap-tool--primary" type="submit" data-action="composer-save">save →</button>
286
+ </header>
287
+ <textarea class="scrap-composer-body" data-composer-body
288
+ placeholder="Write the note in markdown. Cmd/Ctrl+S saves, Esc cancels."
289
+ aria-label="new note body" rows="8"></textarea>
290
+ </form>`);
291
+ }
292
+ export function renderDropZone() {
293
+ return unsafe(html `
294
+ <div class="scrap-drop" role="button" tabindex="0" data-action="upload"
295
+ aria-label="Drop a file here, or press Enter to pick one">
296
+ ── drop a file here, or pick one ──
297
+ </div>`);
298
+ }
299
+ export function renderSecretSection(rctx, secretItems) {
300
+ if (secretItems.length === 0)
301
+ return unsafe('');
302
+ const cards = secretItems.map((item, i) => renderCard(rctx, item, i, { secret: true }));
303
+ return unsafe(html `
304
+ <section class="scrap-secret" aria-label="secret items">
305
+ <header class="scrap-secret-head">
306
+ <span class="scrap-secret-mark" aria-hidden="true">⚿</span>
307
+ <h2 class="scrap-secret-title">Secret</h2>
308
+ <span class="scrap-secret-badge">private — never published</span>
309
+ </header>
310
+ <ol class="scrap-cards">
311
+ ${cards}
312
+ </ol>
313
+ </section>`);
314
+ }
315
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/pages/scrapbook/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,sBAAsB,GAGvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAgB,MAAM,YAAY,CAAC;AACxD,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACV,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,E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AAO,MAAM,CAAC,IAAI,CAAA;;;;WAIT,CAAC,CAAC;AACb,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,IAAe,EACf,WAAqC;IAErC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC,IAAI,CAAA;;;;;;;;UAQV,KAAK;;eAEA,CAAC,CAAC;AACjB,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Scrapbook text-content helpers — pure Buffer/string utilities for
3
+ * rendering closed-state previews and per-kind meta strings.
4
+ */
5
+ export declare function escapeHtml(s: string): string;
6
+ /**
7
+ * Strip a YAML frontmatter block from the top of an md file. Only strips
8
+ * the leading `---\n...\n---\n` block; body-level `---` separators (Setext
9
+ * H2 underline, thematic break) are preserved because the function only
10
+ * looks at the first 4 chars for the opener.
11
+ */
12
+ export declare function stripFrontmatter(text: string): string;
13
+ /**
14
+ * Build the closed-state preview excerpt for md/json/txt. Returns null
15
+ * when there's nothing useful to render — empty file, frontmatter-only
16
+ * file, or binary masquerading as text — so the caller can omit the
17
+ * preview block entirely (matches "other" kind treatment, avoids the
18
+ * 6rem min-height void).
19
+ *
20
+ * For json: pretty-print via JSON.parse + JSON.stringify(_, null, 2) so
21
+ * minified single-line files still render multi-line. Falls back to raw
22
+ * content on parse error (bad JSON is still readable as text).
23
+ *
24
+ * Binary detection: NUL byte presence after UTF-8 decode. Real text
25
+ * almost never has NUL; binary files have it within the first KB.
26
+ */
27
+ export declare function previewExcerpt(buf: Buffer, kind: 'md' | 'json' | 'txt'): string | null;
28
+ /**
29
+ * Count lines in a text file: number of `\n` bytes plus 1 if the last
30
+ * byte isn't `\n` (so a 3-line file whether or not it has a trailing
31
+ * newline reports 3).
32
+ */
33
+ export declare function countLines(buf: Buffer): number;
34
+ /**
35
+ * Count top-level keys in a JSON object. Returns null if the file is not
36
+ * valid JSON or its root is not a plain object (arrays, primitives →
37
+ * null; caller renders no extra meta).
38
+ */
39
+ export declare function countJsonKeys(buf: Buffer): number | null;
40
+ //# sourceMappingURL=text-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-helpers.d.ts","sourceRoot":"","sources":["../../../src/pages/scrapbook/text-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAO5C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKrD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI,CAetF;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK9C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUxD"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Scrapbook text-content helpers — pure Buffer/string utilities for
3
+ * rendering closed-state previews and per-kind meta strings.
4
+ */
5
+ export function escapeHtml(s) {
6
+ return s
7
+ .replace(/&/g, '&amp;')
8
+ .replace(/</g, '&lt;')
9
+ .replace(/>/g, '&gt;')
10
+ .replace(/"/g, '&quot;')
11
+ .replace(/'/g, '&#39;');
12
+ }
13
+ /**
14
+ * Strip a YAML frontmatter block from the top of an md file. Only strips
15
+ * the leading `---\n...\n---\n` block; body-level `---` separators (Setext
16
+ * H2 underline, thematic break) are preserved because the function only
17
+ * looks at the first 4 chars for the opener.
18
+ */
19
+ export function stripFrontmatter(text) {
20
+ if (!text.startsWith('---\n'))
21
+ return text;
22
+ const closeIdx = text.indexOf('\n---\n', 4);
23
+ if (closeIdx < 0)
24
+ return text;
25
+ return text.slice(closeIdx + 5).replace(/^\n+/, '');
26
+ }
27
+ /**
28
+ * Build the closed-state preview excerpt for md/json/txt. Returns null
29
+ * when there's nothing useful to render — empty file, frontmatter-only
30
+ * file, or binary masquerading as text — so the caller can omit the
31
+ * preview block entirely (matches "other" kind treatment, avoids the
32
+ * 6rem min-height void).
33
+ *
34
+ * For json: pretty-print via JSON.parse + JSON.stringify(_, null, 2) so
35
+ * minified single-line files still render multi-line. Falls back to raw
36
+ * content on parse error (bad JSON is still readable as text).
37
+ *
38
+ * Binary detection: NUL byte presence after UTF-8 decode. Real text
39
+ * almost never has NUL; binary files have it within the first KB.
40
+ */
41
+ export function previewExcerpt(buf, kind) {
42
+ let text = buf.subarray(0, Math.min(buf.byteLength, 2400)).toString('utf-8');
43
+ if (text.indexOf('\0') >= 0)
44
+ return null;
45
+ if (kind === 'md')
46
+ text = stripFrontmatter(text);
47
+ if (kind === 'json') {
48
+ try {
49
+ const fullText = buf.toString('utf-8');
50
+ text = JSON.stringify(JSON.parse(fullText), null, 2);
51
+ }
52
+ catch {
53
+ // Invalid JSON — fall through to the raw-text excerpt below.
54
+ }
55
+ }
56
+ const excerpt = text.split('\n').slice(0, 8).join('\n').slice(0, 600);
57
+ if (excerpt.trim() === '')
58
+ return null;
59
+ return excerpt;
60
+ }
61
+ /**
62
+ * Count lines in a text file: number of `\n` bytes plus 1 if the last
63
+ * byte isn't `\n` (so a 3-line file whether or not it has a trailing
64
+ * newline reports 3).
65
+ */
66
+ export function countLines(buf) {
67
+ let count = 0;
68
+ for (const b of buf)
69
+ if (b === 0x0a)
70
+ count++;
71
+ if (buf.length > 0 && buf[buf.length - 1] !== 0x0a)
72
+ count++;
73
+ return count;
74
+ }
75
+ /**
76
+ * Count top-level keys in a JSON object. Returns null if the file is not
77
+ * valid JSON or its root is not a plain object (arrays, primitives →
78
+ * null; caller renders no extra meta).
79
+ */
80
+ export function countJsonKeys(buf) {
81
+ try {
82
+ const obj = JSON.parse(buf.toString('utf-8'));
83
+ if (obj !== null && typeof obj === 'object' && !Array.isArray(obj)) {
84
+ return Object.keys(obj).length;
85
+ }
86
+ return null;
87
+ }
88
+ catch {
89
+ return null;
90
+ }
91
+ }
92
+ //# sourceMappingURL=text-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-helpers.js","sourceRoot":"","sources":["../../../src/pages/scrapbook/text-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,OAAO,CAAC;SACL,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAC5C,IAAI,QAAQ,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,IAA2B;IACrE,IAAI,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,I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AM,UAAU,aAAa,CAAC,GAAW;IACvC,IAAI,CAAC;QACH,MAAM,GAAG,GAAY,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QACvD,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACnE,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;QACjC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Scrapbook page render context — shared between dispatch + render
3
+ * helpers in the scrapbook page split.
4
+ *
5
+ * #205 — the entryId is the load-bearing addition. When present, it
6
+ * threads into the file-fetch URL via `entryId=` so the read-only
7
+ * binary endpoint resolves through `scrapbookDirForEntry` (matching
8
+ * the entry-aware mutation API). When absent, slug-template addressing
9
+ * (`path=`) is the back-compat fallback.
10
+ */
11
+ import type { StudioContext } from '../../routes/api.ts';
12
+ /**
13
+ * Per-render context for the scrapbook page. Carries a pre-resolved
14
+ * absolute scrapbook directory (used for filesystem reads in
15
+ * `computeKindMeta` / `renderPreview`) plus the addressing identifiers
16
+ * used in URL emission (`site`, `path`, optional `entryId`).
17
+ */
18
+ export interface RenderCtx {
19
+ studio: StudioContext;
20
+ site: string;
21
+ path: string;
22
+ entryId?: string;
23
+ /** Absolute path of the scrapbook directory on disk. */
24
+ scrapbookDir: string;
25
+ }
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/pages/scrapbook/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Scrapbook page render context — shared between dispatch + render
3
+ * helpers in the scrapbook page split.
4
+ *
5
+ * #205 — the entryId is the load-bearing addition. When present, it
6
+ * threads into the file-fetch URL via `entryId=` so the read-only
7
+ * binary endpoint resolves through `scrapbookDirForEntry` (matching
8
+ * the entry-aware mutation API). When absent, slug-template addressing
9
+ * (`path=`) is the back-compat fallback.
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/pages/scrapbook/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * Scrapbook viewer — `/dev/scrapbook/:site/<path>`.
3
3
  *
4
- * Issue #161 redesign: aside-left folder card with numbered item list,
5
- * vertical card grid with per-kind colored ribbons + always-visible foot
6
- * toolbar + per-kind preview rendering, drop zone, secret section,
7
- * single-expanded card invariant, aside cross-linking.
4
+ * The implementation lives in the `scrapbook/` directory (one module
5
+ * per concern, each under the 500-line cap). This file re-exports the
6
+ * public render function + error type so the existing `server.ts`
7
+ * import keeps working.
8
8
  *
9
- * Mockup: docs/superpowers/frontend-design/2026-05-02-review-redesign/scrapbook-redesign.html
10
- * Spec: docs/superpowers/specs/2026-05-02-scrapbook-redesign-impl-spec.md
9
+ * Mirrors the post-#191 envelope/dispatch split for mutations
10
+ * (`routes/scrapbook-mutation-{envelope,dispatch}.ts`): the slim entry
11
+ * is the public surface; the directory holds the concerns.
11
12
  */
12
- import type { StudioContext } from '../routes/api.ts';
13
- export declare function renderScrapbookPage(ctx: StudioContext, site: string, path: string): string;
13
+ export { renderScrapbookPage, ScrapbookPageError, } from './scrapbook/index.ts';
14
14
  //# sourceMappingURL=scrapbook.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scrapbook.d.ts","sourceRoot":"","sources":["../../src/pages/scrapbook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAcH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAskBtD,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,MAAM,CAuDR"}
1
+ {"version":3,"file":"scrapbook.d.ts","sourceRoot":"","sources":["../../src/pages/scrapbook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC"}