@deskwork/studio 0.15.0 → 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.
- package/dist/components/scrapbook-item.d.ts +20 -0
- package/dist/components/scrapbook-item.d.ts.map +1 -1
- package/dist/components/scrapbook-item.js +21 -2
- package/dist/components/scrapbook-item.js.map +1 -1
- package/dist/pages/dashboard/affordances.d.ts.map +1 -1
- package/dist/pages/dashboard/affordances.js +13 -1
- package/dist/pages/dashboard/affordances.js.map +1 -1
- package/dist/pages/dashboard/affordances.ts +13 -1
- package/dist/pages/review-scrapbook-drawer.d.ts.map +1 -1
- package/dist/pages/review-scrapbook-drawer.js +10 -1
- package/dist/pages/review-scrapbook-drawer.js.map +1 -1
- package/dist/pages/review-scrapbook-drawer.ts +11 -1
- package/dist/pages/scrapbook/dispatch.d.ts +50 -0
- package/dist/pages/scrapbook/dispatch.d.ts.map +1 -0
- package/dist/pages/scrapbook/dispatch.js +104 -0
- package/dist/pages/scrapbook/dispatch.js.map +1 -0
- package/dist/pages/scrapbook/image-readers.d.ts +24 -0
- package/dist/pages/scrapbook/image-readers.d.ts.map +1 -0
- package/dist/pages/scrapbook/image-readers.js +135 -0
- package/dist/pages/scrapbook/image-readers.js.map +1 -0
- package/dist/pages/scrapbook/index.d.ts +21 -0
- package/dist/pages/scrapbook/index.d.ts.map +1 -0
- package/dist/pages/scrapbook/index.js +96 -0
- package/dist/pages/scrapbook/index.js.map +1 -0
- package/dist/pages/scrapbook/render.d.ts +68 -0
- package/dist/pages/scrapbook/render.d.ts.map +1 -0
- package/dist/pages/scrapbook/render.js +315 -0
- package/dist/pages/scrapbook/render.js.map +1 -0
- package/dist/pages/scrapbook/text-helpers.d.ts +40 -0
- package/dist/pages/scrapbook/text-helpers.d.ts.map +1 -0
- package/dist/pages/scrapbook/text-helpers.js +92 -0
- package/dist/pages/scrapbook/text-helpers.js.map +1 -0
- package/dist/pages/scrapbook/types.d.ts +26 -0
- package/dist/pages/scrapbook/types.d.ts.map +1 -0
- package/dist/pages/scrapbook/types.js +12 -0
- package/dist/pages/scrapbook/types.js.map +1 -0
- package/dist/pages/scrapbook.d.ts +8 -8
- package/dist/pages/scrapbook.d.ts.map +1 -1
- package/dist/pages/scrapbook.js +8 -600
- package/dist/pages/scrapbook.js.map +1 -1
- package/dist/pages/scrapbook.ts +11 -660
- package/dist/routes/api.d.ts.map +1 -1
- package/dist/routes/api.js +111 -2
- package/dist/routes/api.js.map +1 -1
- package/dist/routes/entry-annotation-body.d.ts +29 -0
- package/dist/routes/entry-annotation-body.d.ts.map +1 -1
- package/dist/routes/entry-annotation-body.js +80 -0
- package/dist/routes/entry-annotation-body.js.map +1 -1
- package/dist/routes/scrapbook-file.d.ts +1 -1
- package/dist/routes/scrapbook-file.js +1 -1
- package/dist/routes/scrapbook-mutation-dispatch.d.ts +29 -0
- package/dist/routes/scrapbook-mutation-dispatch.d.ts.map +1 -0
- package/dist/routes/scrapbook-mutation-dispatch.js +63 -0
- package/dist/routes/scrapbook-mutation-dispatch.js.map +1 -0
- package/dist/routes/scrapbook-mutation-envelope.d.ts +93 -0
- package/dist/routes/scrapbook-mutation-envelope.d.ts.map +1 -0
- package/dist/routes/scrapbook-mutation-envelope.js +147 -0
- package/dist/routes/scrapbook-mutation-envelope.js.map +1 -0
- package/dist/routes/scrapbook-mutations.d.ts +25 -7
- package/dist/routes/scrapbook-mutations.d.ts.map +1 -1
- package/dist/routes/scrapbook-mutations.js +67 -92
- package/dist/routes/scrapbook-mutations.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +16 -2
- package/dist/server.js.map +1 -1
- package/package.json +2 -2
- package/dist/pages/review.d.ts +0 -68
- package/dist/pages/review.d.ts.map +0 -1
- package/dist/pages/review.js +0 -561
- package/dist/pages/review.js.map +0 -1
- package/dist/pages/review.ts +0 -710
|
@@ -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, '<')
|
|
9
|
+
.replace(/>/g, '>')
|
|
10
|
+
.replace(/"/g, '"')
|
|
11
|
+
.replace(/'/g, ''');
|
|
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
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AC;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
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
-
*
|
|
10
|
-
*
|
|
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
|
-
|
|
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
|
|
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"}
|