@gmickel/gno 1.29.5 → 1.30.1
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 +15 -5
- package/browser-extension/artifacts/{gno-browser-clipper-v1.29.5.zip → gno-browser-clipper-v1.30.1.zip} +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v1.30.1.zip.sha256 +1 -0
- package/browser-extension/dist/manifest.json +1 -1
- package/package.json +4 -1
- package/src/core/network-boundary-inventory.ts +51 -0
- package/src/ingestion/index.ts +1 -1
- package/src/ingestion/walker.ts +45 -23
- package/src/serve/AGENTS.md +5 -1
- package/src/serve/CLAUDE.md +5 -1
- package/src/serve/fn112-routes.ts +232 -0
- package/src/serve/pdfjs-assets.ts +391 -0
- package/src/serve/public/components/pdf/PdfPageView.tsx +427 -0
- package/src/serve/public/components/pdf/PdfToolbar.tsx +384 -0
- package/src/serve/public/components/pdf/PdfViewer.tsx +539 -0
- package/src/serve/public/components/pdf/pdf-viewer-deps.tsx +94 -0
- package/src/serve/public/globals.built.css +1 -1
- package/src/serve/public/globals.css +113 -0
- package/src/serve/public/hooks/use-pdf-document.ts +227 -0
- package/src/serve/public/hooks/use-pdf-pages.ts +1197 -0
- package/src/serve/public/lib/doc-asset-url.ts +57 -0
- package/src/serve/public/lib/math-sum-precise.ts +34 -0
- package/src/serve/public/lib/pdf.ts +772 -0
- package/src/serve/public/pages/DocView.tsx +295 -39
- package/src/serve/public/pages/doc-pdf-viewer.tsx +7 -0
- package/src/serve/routes/api.ts +154 -14
- package/src/serve/server.ts +190 -37
- package/src/serve/spa-bundle-source.ts +99 -0
- package/src/serve/watch-service.ts +219 -23
- package/browser-extension/artifacts/gno-browser-clipper-v1.29.5.zip.sha256 +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Doc-asset URL helpers for the native PDF viewer (fn-112 task .5).
|
|
3
|
+
*
|
|
4
|
+
* Production `/api/doc-asset` resolves relative `path` against
|
|
5
|
+
* `dirname(resolvedDoc.fullPath)` where the document is resolved by `uri`
|
|
6
|
+
* (`recordSourcePath ?? relPath` under the collection root).
|
|
7
|
+
*
|
|
8
|
+
* Therefore the client must pass the **basename** of the API `relPath`
|
|
9
|
+
* (which already incorporates recordSourcePath), not the full relative path —
|
|
10
|
+
* joining a multi-segment relPath onto dirname would double the directories.
|
|
11
|
+
*
|
|
12
|
+
* Same-basename siblings in other directories remain distinct because `uri`
|
|
13
|
+
* anchors the directory; only basename + uri is needed.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** Last path segment of a document relPath (POSIX or Windows separators). */
|
|
17
|
+
export function assetPathFromRelPath(relPath: string): string {
|
|
18
|
+
const normalized = relPath.replaceAll("\\", "/").replace(/\/+$/u, "");
|
|
19
|
+
if (!normalized) {
|
|
20
|
+
return relPath;
|
|
21
|
+
}
|
|
22
|
+
const segments = normalized.split("/").filter(Boolean);
|
|
23
|
+
return segments.at(-1) ?? normalized;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Build encoded `/api/doc-asset?uri=…&path=…` for the indexed document file.
|
|
28
|
+
* Same URL is used for PdfViewer assetUrl and downloadUrl.
|
|
29
|
+
*/
|
|
30
|
+
export function buildDocAssetUrl(uri: string, relPath: string): string {
|
|
31
|
+
const path = assetPathFromRelPath(relPath);
|
|
32
|
+
return `/api/doc-asset?uri=${encodeURIComponent(uri)}&path=${encodeURIComponent(path)}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Spec predicate for extracted-text availability (DocView → PdfViewer).
|
|
37
|
+
* Evaluated per render; never derived from mime/ext.
|
|
38
|
+
*/
|
|
39
|
+
export function isExtractedTextAvailable(doc: {
|
|
40
|
+
contentAvailable: boolean;
|
|
41
|
+
content: string | null | undefined;
|
|
42
|
+
}): boolean {
|
|
43
|
+
return (
|
|
44
|
+
doc.contentAvailable === true &&
|
|
45
|
+
typeof doc.content === "string" &&
|
|
46
|
+
doc.content.trim().length > 0
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function isPdfDocument(source: {
|
|
51
|
+
mime?: string | null;
|
|
52
|
+
ext?: string | null;
|
|
53
|
+
}): boolean {
|
|
54
|
+
const mime = (source.mime ?? "").toLowerCase();
|
|
55
|
+
const ext = (source.ext ?? "").toLowerCase();
|
|
56
|
+
return mime === "application/pdf" || ext === ".pdf";
|
|
57
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
type MathWithSumPrecise = Math & {
|
|
2
|
+
sumPrecise?: (values: Iterable<number>) => number;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Compatibility for pdfjs-dist on browsers that predate Math.sumPrecise.
|
|
7
|
+
* Neumaier compensation keeps mixed-magnitude page metrics stable enough for
|
|
8
|
+
* the PDF.js call sites while native implementations remain preferred.
|
|
9
|
+
*/
|
|
10
|
+
export function installMathSumPrecise(): void {
|
|
11
|
+
const math = Math as MathWithSumPrecise;
|
|
12
|
+
if (typeof math.sumPrecise === "function") {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(math, "sumPrecise", {
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value(values: Iterable<number>): number {
|
|
19
|
+
let sum = 0;
|
|
20
|
+
let compensation = 0;
|
|
21
|
+
for (const value of values) {
|
|
22
|
+
const next = sum + value;
|
|
23
|
+
compensation +=
|
|
24
|
+
Math.abs(sum) >= Math.abs(value)
|
|
25
|
+
? sum - next + value
|
|
26
|
+
: value - next + sum;
|
|
27
|
+
sum = next;
|
|
28
|
+
}
|
|
29
|
+
return sum + compensation;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
installMathSumPrecise();
|