@kousaku-maron/diffshape 0.4.0 → 0.5.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/bin/{chunk-EAWLY4IY.js → chunk-AKBOSCJ7.js} +38 -7
- package/dist/bin/dbshape.js +1 -1
- package/dist/bin/depshape.js +1 -1
- package/dist/bin/diffshape.js +1 -1
- package/dist/bin/fileshape.js +1 -1
- package/dist/bin/ui/assets/index-Drh5gF_A.js +153 -0
- package/dist/bin/ui/assets/{index-8ie1NCfx.css → index-pEETZtFR.css} +1 -1
- package/dist/bin/ui/index.html +2 -2
- package/package.json +4 -4
- package/dist/bin/ui/assets/index-CnRZHirE.js +0 -152
|
@@ -2407,6 +2407,7 @@ async function linguistGenerated(root, target, paths) {
|
|
|
2407
2407
|
}
|
|
2408
2408
|
|
|
2409
2409
|
// ../fileshape/src/api.ts
|
|
2410
|
+
var MAX_PLAIN = 2 * 1024 * 1024;
|
|
2410
2411
|
var IMAGE_TYPES = {
|
|
2411
2412
|
png: "image/png",
|
|
2412
2413
|
jpg: "image/jpeg",
|
|
@@ -2429,9 +2430,29 @@ var sideOf = (url) => {
|
|
|
2429
2430
|
if (s !== "old" && s !== "new") throw new HttpError(400, "side must be old or new");
|
|
2430
2431
|
return s;
|
|
2431
2432
|
};
|
|
2432
|
-
|
|
2433
|
+
var listings = /* @__PURE__ */ new WeakMap();
|
|
2434
|
+
function targetFiles(sources, data) {
|
|
2435
|
+
let p = listings.get(data);
|
|
2436
|
+
if (!p) {
|
|
2437
|
+
p = listFiles(sources.root, sources.target).then((paths) => new Set(paths));
|
|
2438
|
+
p.catch(() => listings.delete(data));
|
|
2439
|
+
listings.set(data, p);
|
|
2440
|
+
}
|
|
2441
|
+
return p;
|
|
2442
|
+
}
|
|
2443
|
+
async function plainPath(sources, data, path) {
|
|
2444
|
+
if (!(await targetFiles(sources, data)).has(path)) throw new HttpError(404, `not in the repository: ${path}`);
|
|
2445
|
+
return path;
|
|
2446
|
+
}
|
|
2447
|
+
var linesOf = (blob) => {
|
|
2448
|
+
const lines = blob.toString("utf8").split("\n").map((l) => l.replace(/\r$/, ""));
|
|
2449
|
+
if (lines[lines.length - 1] === "") lines.pop();
|
|
2450
|
+
return lines;
|
|
2451
|
+
};
|
|
2452
|
+
var isBinary = (blob) => blob.subarray(0, 8e3).includes(0);
|
|
2453
|
+
async function diffPath(sources, data, path, side) {
|
|
2433
2454
|
const f = data.files.find((x) => x.path === path);
|
|
2434
|
-
if (!f)
|
|
2455
|
+
if (!f) return plainPath(sources, data, path);
|
|
2435
2456
|
if (side === "old" && f.status === "added" || side === "new" && f.status === "removed") throw new HttpError(404, `${path} is not on the ${side} side`);
|
|
2436
2457
|
return side === "old" ? f.oldPath ?? f.path : f.path;
|
|
2437
2458
|
}
|
|
@@ -2439,13 +2460,23 @@ var fileApi = {
|
|
|
2439
2460
|
/** `?path=&side=` → { lines } of a file of the diff */
|
|
2440
2461
|
async content(url, { sources, data }) {
|
|
2441
2462
|
const side = sideOf(url);
|
|
2442
|
-
const path = diffPath(data, safePath(url.searchParams.get("path")), side);
|
|
2463
|
+
const path = await diffPath(sources, data, safePath(url.searchParams.get("path")), side);
|
|
2443
2464
|
const blob = await readBlob(sources.root, side === "old" ? sources.base : sources.target, path);
|
|
2444
2465
|
if (!blob) throw new HttpError(404, `not found: ${path}`);
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2466
|
+
return { lines: linesOf(blob) };
|
|
2467
|
+
},
|
|
2468
|
+
/** → { paths } of every file on the target side (the tree's "全体" view) */
|
|
2469
|
+
async files(_url, { sources, data }) {
|
|
2470
|
+
return { paths: [...await targetFiles(sources, data)].sort() };
|
|
2471
|
+
},
|
|
2472
|
+
/** `?path=` → a file that is not in the diff, as a PlainFile */
|
|
2473
|
+
async plain(url, { sources, data }) {
|
|
2474
|
+
const path = await plainPath(sources, data, safePath(url.searchParams.get("path")));
|
|
2475
|
+
const blob = await readBlob(sources.root, sources.target, path);
|
|
2476
|
+
if (!blob) throw new HttpError(404, `not found: ${path}`);
|
|
2477
|
+
if (isBinary(blob)) return { binary: true };
|
|
2478
|
+
if (blob.length > MAX_PLAIN) return { large: true };
|
|
2479
|
+
return { lines: linesOf(blob) };
|
|
2449
2480
|
},
|
|
2450
2481
|
/** `?path=&side=` → the bytes of an image in the repository */
|
|
2451
2482
|
async raw(url, { sources }) {
|
package/dist/bin/dbshape.js
CHANGED
package/dist/bin/depshape.js
CHANGED
package/dist/bin/diffshape.js
CHANGED