@deskwork/studio 0.14.1 → 0.16.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 (86) 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/pages/dashboard/affordances.d.ts.map +1 -1
  6. package/dist/pages/dashboard/affordances.js +13 -1
  7. package/dist/pages/dashboard/affordances.js.map +1 -1
  8. package/dist/pages/dashboard/affordances.ts +13 -1
  9. package/dist/pages/dashboard/press-queue.d.ts +16 -0
  10. package/dist/pages/dashboard/press-queue.d.ts.map +1 -0
  11. package/dist/pages/dashboard/press-queue.js +91 -0
  12. package/dist/pages/dashboard/press-queue.js.map +1 -0
  13. package/dist/pages/dashboard/press-queue.ts +112 -0
  14. package/dist/pages/dashboard.d.ts.map +1 -1
  15. package/dist/pages/dashboard.js +2 -0
  16. package/dist/pages/dashboard.js.map +1 -1
  17. package/dist/pages/dashboard.ts +2 -0
  18. package/dist/pages/entry-review/decision-strip.d.ts.map +1 -1
  19. package/dist/pages/entry-review/decision-strip.js +10 -2
  20. package/dist/pages/entry-review/decision-strip.js.map +1 -1
  21. package/dist/pages/entry-review/index.d.ts.map +1 -1
  22. package/dist/pages/entry-review/index.js +7 -4
  23. package/dist/pages/entry-review/index.js.map +1 -1
  24. package/dist/pages/help.js +11 -11
  25. package/dist/pages/help.js.map +1 -1
  26. package/dist/pages/help.ts +11 -11
  27. package/dist/pages/review-scrapbook-drawer.d.ts.map +1 -1
  28. package/dist/pages/review-scrapbook-drawer.js +10 -1
  29. package/dist/pages/review-scrapbook-drawer.js.map +1 -1
  30. package/dist/pages/review-scrapbook-drawer.ts +11 -1
  31. package/dist/pages/scrapbook/dispatch.d.ts +50 -0
  32. package/dist/pages/scrapbook/dispatch.d.ts.map +1 -0
  33. package/dist/pages/scrapbook/dispatch.js +104 -0
  34. package/dist/pages/scrapbook/dispatch.js.map +1 -0
  35. package/dist/pages/scrapbook/image-readers.d.ts +24 -0
  36. package/dist/pages/scrapbook/image-readers.d.ts.map +1 -0
  37. package/dist/pages/scrapbook/image-readers.js +135 -0
  38. package/dist/pages/scrapbook/image-readers.js.map +1 -0
  39. package/dist/pages/scrapbook/index.d.ts +21 -0
  40. package/dist/pages/scrapbook/index.d.ts.map +1 -0
  41. package/dist/pages/scrapbook/index.js +96 -0
  42. package/dist/pages/scrapbook/index.js.map +1 -0
  43. package/dist/pages/scrapbook/render.d.ts +68 -0
  44. package/dist/pages/scrapbook/render.d.ts.map +1 -0
  45. package/dist/pages/scrapbook/render.js +315 -0
  46. package/dist/pages/scrapbook/render.js.map +1 -0
  47. package/dist/pages/scrapbook/text-helpers.d.ts +40 -0
  48. package/dist/pages/scrapbook/text-helpers.d.ts.map +1 -0
  49. package/dist/pages/scrapbook/text-helpers.js +92 -0
  50. package/dist/pages/scrapbook/text-helpers.js.map +1 -0
  51. package/dist/pages/scrapbook/types.d.ts +26 -0
  52. package/dist/pages/scrapbook/types.d.ts.map +1 -0
  53. package/dist/pages/scrapbook/types.js +12 -0
  54. package/dist/pages/scrapbook/types.js.map +1 -0
  55. package/dist/pages/scrapbook.d.ts +8 -8
  56. package/dist/pages/scrapbook.d.ts.map +1 -1
  57. package/dist/pages/scrapbook.js +8 -600
  58. package/dist/pages/scrapbook.js.map +1 -1
  59. package/dist/pages/scrapbook.ts +11 -660
  60. package/dist/routes/api.d.ts.map +1 -1
  61. package/dist/routes/api.js +102 -140
  62. package/dist/routes/api.js.map +1 -1
  63. package/dist/routes/entry-annotation-body.d.ts +29 -0
  64. package/dist/routes/entry-annotation-body.d.ts.map +1 -1
  65. package/dist/routes/entry-annotation-body.js +80 -0
  66. package/dist/routes/entry-annotation-body.js.map +1 -1
  67. package/dist/routes/scrapbook-file.d.ts +17 -9
  68. package/dist/routes/scrapbook-file.d.ts.map +1 -1
  69. package/dist/routes/scrapbook-file.js +48 -15
  70. package/dist/routes/scrapbook-file.js.map +1 -1
  71. package/dist/routes/scrapbook-mutation-dispatch.d.ts +29 -0
  72. package/dist/routes/scrapbook-mutation-dispatch.d.ts.map +1 -0
  73. package/dist/routes/scrapbook-mutation-dispatch.js +63 -0
  74. package/dist/routes/scrapbook-mutation-dispatch.js.map +1 -0
  75. package/dist/routes/scrapbook-mutation-envelope.d.ts +93 -0
  76. package/dist/routes/scrapbook-mutation-envelope.d.ts.map +1 -0
  77. package/dist/routes/scrapbook-mutation-envelope.js +147 -0
  78. package/dist/routes/scrapbook-mutation-envelope.js.map +1 -0
  79. package/dist/routes/scrapbook-mutations.d.ts +25 -7
  80. package/dist/routes/scrapbook-mutations.d.ts.map +1 -1
  81. package/dist/routes/scrapbook-mutations.js +67 -92
  82. package/dist/routes/scrapbook-mutations.js.map +1 -1
  83. package/dist/server.d.ts.map +1 -1
  84. package/dist/server.js +16 -2
  85. package/dist/server.js.map +1 -1
  86. package/package.json +2 -2
@@ -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, '&')
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,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7E,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACzC,IAAI,IAAI,KAAK,IAAI;QAAE,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AC,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"}