@takazudo/zudo-doc-history-server 0.2.6 → 0.2.8
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.
|
@@ -163,7 +163,7 @@ function parseBatchContents(rawBuf, pairs) {
|
|
|
163
163
|
const headerParts = header.split(" ");
|
|
164
164
|
const sizeStr = headerParts[headerParts.length - 1];
|
|
165
165
|
const size = parseInt(sizeStr ?? "0", 10);
|
|
166
|
-
if (isNaN(size))
|
|
166
|
+
if (isNaN(size) || size < 0 || pos + size > rawBuf.length) break;
|
|
167
167
|
const content = rawBuf.toString("utf-8", pos, pos + size);
|
|
168
168
|
pos += size + 1;
|
|
169
169
|
result.set(hash, content);
|
|
@@ -228,15 +228,15 @@ async function getDocHistoryAsync(filePath, slug, maxEntries = 50) {
|
|
|
228
228
|
path: hashToPath.get(rec.hash) ?? relPath
|
|
229
229
|
}));
|
|
230
230
|
const contentMap = await batchFetchContentsAsync(pairs);
|
|
231
|
-
const entries =
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
231
|
+
const entries = [];
|
|
232
|
+
for (const rec of metaRecords) {
|
|
233
|
+
if (contentMap.has(rec.hash)) {
|
|
234
|
+
entries.push({ ...rec, content: contentMap.get(rec.hash) });
|
|
235
|
+
} else {
|
|
236
236
|
const content = await getFileAtCommitAsync(rec.hash, filePath);
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
237
|
+
entries.push({ ...rec, content });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
240
|
return { slug, filePath: relPath, entries };
|
|
241
241
|
}
|
|
242
242
|
async function getFileAtCommitAsync(hash, filePath) {
|
package/dist/cli.js
CHANGED
package/dist/git-history.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
collectContentFiles,
|
|
8
8
|
getDocHistoryAsync
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OGIEQWJI.js";
|
|
10
10
|
|
|
11
11
|
// src/server.ts
|
|
12
12
|
import { createServer } from "http";
|
|
@@ -50,12 +50,13 @@ function startServer(options2) {
|
|
|
50
50
|
const dirEntries = getContentDirEntries(contentDir, locales);
|
|
51
51
|
let fileIndex = buildFileIndex(dirEntries);
|
|
52
52
|
console.log(`Indexed ${fileIndex.size} documents`);
|
|
53
|
-
setInterval(() => {
|
|
53
|
+
const refreshTimer = setInterval(() => {
|
|
54
54
|
try {
|
|
55
55
|
fileIndex = buildFileIndex(dirEntries);
|
|
56
56
|
} catch {
|
|
57
57
|
}
|
|
58
58
|
}, FILE_INDEX_REFRESH_MS);
|
|
59
|
+
refreshTimer.unref();
|
|
59
60
|
const server = createServer((req, res) => {
|
|
60
61
|
const url = req.url ?? "";
|
|
61
62
|
const origin = req.headers.origin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takazudo/zudo-doc-history-server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Standalone doc git-history service for zudo-doc — HTTP server + CLI batch generator. Decouples expensive `git log --follow` calls from the main build pipeline.",
|
|
6
6
|
"license": "MIT",
|