seekstone 0.17.1 → 0.17.2
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/index.js +30 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1010,19 +1010,27 @@ function truncate(s, max) {
|
|
|
1010
1010
|
}
|
|
1011
1011
|
|
|
1012
1012
|
// src/index/resolve.ts
|
|
1013
|
-
function
|
|
1013
|
+
function buildResolveMaps(notes2) {
|
|
1014
|
+
const byBasename = /* @__PURE__ */ new Map();
|
|
1015
|
+
const byPathNoExt = /* @__PURE__ */ new Map();
|
|
1016
|
+
for (const path2 of notes2.keys()) {
|
|
1017
|
+
const pathNoExt = path2.replace(/\.md$/i, "").toLowerCase();
|
|
1018
|
+
const base = pathNoExt.split("/").pop() ?? pathNoExt;
|
|
1019
|
+
const prevBase = byBasename.get(base);
|
|
1020
|
+
if (prevBase === void 0 || path2 < prevBase) byBasename.set(base, path2);
|
|
1021
|
+
const prevPath = byPathNoExt.get(pathNoExt);
|
|
1022
|
+
if (prevPath === void 0 || path2 < prevPath) byPathNoExt.set(pathNoExt, path2);
|
|
1023
|
+
}
|
|
1024
|
+
return { byBasename, byPathNoExt };
|
|
1025
|
+
}
|
|
1026
|
+
function resolveLink(target, notes2, maps) {
|
|
1014
1027
|
if (notes2.has(target)) return target;
|
|
1015
1028
|
const withMd = `${target}.md`;
|
|
1016
1029
|
if (notes2.has(withMd)) return withMd;
|
|
1030
|
+
const m = maps ?? buildResolveMaps(notes2);
|
|
1017
1031
|
const targetLower = target.toLowerCase();
|
|
1018
|
-
const targetBase =
|
|
1019
|
-
|
|
1020
|
-
const pathNoExt = path2.replace(/\.md$/i, "");
|
|
1021
|
-
if (pathNoExt.toLowerCase() === targetLower) return path2;
|
|
1022
|
-
const pathBase = (pathNoExt.split("/").pop() ?? pathNoExt).toLowerCase();
|
|
1023
|
-
if (pathBase === targetBase) return path2;
|
|
1024
|
-
}
|
|
1025
|
-
return void 0;
|
|
1032
|
+
const targetBase = targetLower.split("/").pop() ?? targetLower;
|
|
1033
|
+
return m.byBasename.get(targetBase) ?? m.byPathNoExt.get(targetLower);
|
|
1026
1034
|
}
|
|
1027
1035
|
|
|
1028
1036
|
// src/tools/search.ts
|
|
@@ -1475,8 +1483,11 @@ import { z as z5 } from "zod";
|
|
|
1475
1483
|
function removeNoteBacklinks(ctx2, relPath) {
|
|
1476
1484
|
const oldDoc = ctx2.notes.get(relPath);
|
|
1477
1485
|
if (oldDoc === void 0) return;
|
|
1478
|
-
|
|
1479
|
-
|
|
1486
|
+
const links = extractLinksWithLines(oldDoc.raw);
|
|
1487
|
+
if (links.length === 0) return;
|
|
1488
|
+
const maps = buildResolveMaps(ctx2.notes);
|
|
1489
|
+
for (const link of links) {
|
|
1490
|
+
const resolved = resolveLink(link.target, ctx2.notes, maps);
|
|
1480
1491
|
if (resolved === void 0) continue;
|
|
1481
1492
|
const arr = ctx2.backlinks.get(resolved);
|
|
1482
1493
|
if (arr === void 0) continue;
|
|
@@ -1486,8 +1497,11 @@ function removeNoteBacklinks(ctx2, relPath) {
|
|
|
1486
1497
|
}
|
|
1487
1498
|
function addNoteBacklinks(ctx2, relPath, raw) {
|
|
1488
1499
|
const seen = /* @__PURE__ */ new Set();
|
|
1489
|
-
|
|
1490
|
-
|
|
1500
|
+
const links = extractLinksWithLines(raw);
|
|
1501
|
+
if (links.length === 0) return;
|
|
1502
|
+
const maps = buildResolveMaps(ctx2.notes);
|
|
1503
|
+
for (const link of links) {
|
|
1504
|
+
const resolved = resolveLink(link.target, ctx2.notes, maps);
|
|
1491
1505
|
if (resolved === void 0) continue;
|
|
1492
1506
|
const dedupeKey = `${relPath}\0${resolved}`;
|
|
1493
1507
|
if (seen.has(dedupeKey)) continue;
|
|
@@ -3452,10 +3466,11 @@ async function buildIndex(vaultRoot2) {
|
|
|
3452
3466
|
}
|
|
3453
3467
|
function buildBacklinks(notes2) {
|
|
3454
3468
|
const result = /* @__PURE__ */ new Map();
|
|
3469
|
+
const resolveMaps = buildResolveMaps(notes2);
|
|
3455
3470
|
for (const [srcPath, doc] of notes2) {
|
|
3456
3471
|
const seen = /* @__PURE__ */ new Set();
|
|
3457
3472
|
for (const link of extractLinksWithLines(doc.raw)) {
|
|
3458
|
-
const resolved = resolveLink(link.target, notes2);
|
|
3473
|
+
const resolved = resolveLink(link.target, notes2, resolveMaps);
|
|
3459
3474
|
if (resolved === void 0) continue;
|
|
3460
3475
|
const dedupeKey = `${srcPath}\0${resolved}`;
|
|
3461
3476
|
if (seen.has(dedupeKey)) continue;
|
|
@@ -5354,7 +5369,7 @@ function startWatcher(ctx2, log2, opts) {
|
|
|
5354
5369
|
}
|
|
5355
5370
|
|
|
5356
5371
|
// src/index.ts
|
|
5357
|
-
var VERSION = true ? "0.17.
|
|
5372
|
+
var VERSION = true ? "0.17.2" : "0.0.0-dev";
|
|
5358
5373
|
var intent = parseCliIntent(process.argv.slice(2));
|
|
5359
5374
|
if (intent === "version") {
|
|
5360
5375
|
process.stdout.write(`${VERSION}
|