@bendyline/docblocks 2.6.1 → 2.7.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/THIRD_PARTY_NOTICES.txt +33 -33
- package/dist/capabilities-CdQAc745.d.ts +1233 -0
- package/dist/catalog-BQK05tne.d.ts +122 -0
- package/dist/chunk-245W57QP.js +31 -0
- package/dist/{chunk-2WDJ27EH.js → chunk-46AGYHDY.js} +8 -0
- package/dist/{chunk-4437YWLE.js → chunk-6UPO2GE6.js} +4 -2
- package/dist/{chunk-UMWCTEXW.js → chunk-7SN7YQL4.js} +211 -40
- package/dist/{chunk-OQCPBOQA.js → chunk-DAPFSEKY.js} +35 -0
- package/dist/{chunk-M62ZGJ5I.js → chunk-HABG2JM3.js} +0 -17
- package/dist/{chunk-YM7O3PWO.js → chunk-HKOOHM67.js} +20 -12
- package/dist/chunk-IDYE73TU.js +77 -0
- package/dist/{chunk-KLQKU74Q.js → chunk-IGB2VSRE.js} +124 -330
- package/dist/{chunk-BVY7GGNV.js → chunk-L6PRMR7T.js} +137 -95
- package/dist/chunk-LPIJ6HKL.js +19 -0
- package/dist/{chunk-SJBB5OD7.js → chunk-QS5WTLUZ.js} +10 -8
- package/dist/chunk-R2JX5N3F.js +382 -0
- package/dist/{chunk-ZO7G53QP.js → chunk-UDEWLHQI.js} +4 -2
- package/dist/chunk-UK7R3RC7.js +514 -0
- package/dist/chunk-XTNWCNSK.js +464 -0
- package/dist/chunk-YHSFRPBS.js +42 -0
- package/dist/chunk-YNUQG4GF.js +1173 -0
- package/dist/document/index.d.ts +31 -1
- package/dist/document/index.js +7 -6
- package/dist/filesystem/electron.d.ts +8 -34
- package/dist/filesystem/electron.js +7 -4
- package/dist/filesystem/host.d.ts +28 -0
- package/dist/filesystem/host.js +103 -0
- package/dist/filesystem/index.d.ts +52 -6
- package/dist/filesystem/index.js +36 -15
- package/dist/filesystem/indexeddb.d.ts +8 -1
- package/dist/filesystem/indexeddb.js +7 -6
- package/dist/filesystem/memory.d.ts +2 -1
- package/dist/filesystem/memory.js +3 -2
- package/dist/filesystem/native.d.ts +2 -1
- package/dist/filesystem/native.js +3 -2
- package/dist/filesystem-v2-C8AdSXUN.d.ts +74 -0
- package/dist/host/index.d.ts +127 -5
- package/dist/host/index.js +100 -4
- package/dist/host/mobile.d.ts +389 -0
- package/dist/host/mobile.js +315 -0
- package/dist/host-provider-v2-CyLTRKJF.d.ts +51 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +153 -34
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/zod.d.ts +23 -1
- package/dist/mcp/zod.js +1 -0
- package/dist/settings-HrrCikVX.d.ts +170 -0
- package/dist/types-BvDnr3YU.d.ts +88 -0
- package/dist/{types-Oy9U5FST.d.ts → types-d0yvHUJz.d.ts} +6 -0
- package/dist/{types-Bb3yccTH.d.ts → v2-BVnZZyd4.d.ts} +1 -86
- package/dist/vscode/index.d.ts +43 -1
- package/dist/vscode/index.js +67 -1
- package/dist/workspace/index.d.ts +10 -6
- package/dist/workspace/index.js +4 -2
- package/dist/workspace-index/index.d.ts +240 -0
- package/dist/workspace-index/index.js +1287 -0
- package/dist/workspace-settings/index.d.ts +301 -0
- package/dist/workspace-settings/index.js +820 -0
- package/package.json +22 -2
- package/dist/chunk-6XHOOBYF.js +0 -36
- package/dist/chunk-QI6YKTQV.js +0 -110
- package/dist/types-DBYraXxE.d.ts +0 -557
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
// src/workspace-settings/catalog.ts
|
|
2
|
+
var CATALOG_GENERATOR = "docblocks-workspace-catalog";
|
|
3
|
+
var CATALOG_FORMAT_VERSION = 1;
|
|
4
|
+
var CATALOG_LIMITS = {
|
|
5
|
+
maxOutlineEntries: 100,
|
|
6
|
+
maxOutlineTitleCharacters: 256,
|
|
7
|
+
maxExcerptCharacters: 280,
|
|
8
|
+
maxDescriptionCharacters: 1024,
|
|
9
|
+
maxMetadataCharacters: 256,
|
|
10
|
+
maxTags: 32
|
|
11
|
+
};
|
|
12
|
+
var markdownModule = null;
|
|
13
|
+
function loadMarkdown() {
|
|
14
|
+
markdownModule ?? (markdownModule = import("@bendyline/squisq/markdown"));
|
|
15
|
+
return markdownModule;
|
|
16
|
+
}
|
|
17
|
+
function normalizeLineEndings(text) {
|
|
18
|
+
return text.replace(/\r\n?/g, "\n");
|
|
19
|
+
}
|
|
20
|
+
var WORD_PATTERN = /[\p{L}\p{N}]+(?:['’_-][\p{L}\p{N}]+)*/gu;
|
|
21
|
+
function countWords(text) {
|
|
22
|
+
return text.match(WORD_PATTERN)?.length ?? 0;
|
|
23
|
+
}
|
|
24
|
+
function collapseWhitespace(text) {
|
|
25
|
+
return text.replace(/\s+/g, " ").trim();
|
|
26
|
+
}
|
|
27
|
+
function truncate(text, maximum) {
|
|
28
|
+
if (text.length <= maximum) return text;
|
|
29
|
+
const slice = text.slice(0, maximum - 1);
|
|
30
|
+
const space = slice.lastIndexOf(" ");
|
|
31
|
+
return `${(space > maximum / 2 ? slice.slice(0, space) : slice).trimEnd()}\u2026`;
|
|
32
|
+
}
|
|
33
|
+
function metadataText(value, maximum) {
|
|
34
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
35
|
+
if (value instanceof Date && Number.isFinite(value.getTime())) {
|
|
36
|
+
return value.toISOString().slice(0, 10);
|
|
37
|
+
}
|
|
38
|
+
if (typeof value !== "string") return void 0;
|
|
39
|
+
const text = collapseWhitespace(value);
|
|
40
|
+
return text ? truncate(text, maximum) : void 0;
|
|
41
|
+
}
|
|
42
|
+
function firstMetadataText(frontmatter, keys, maximum) {
|
|
43
|
+
for (const key of keys) {
|
|
44
|
+
const value = metadataText(frontmatter?.[key], maximum);
|
|
45
|
+
if (value) return value;
|
|
46
|
+
}
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
function metadataTags(frontmatter) {
|
|
50
|
+
const raw = frontmatter?.tags ?? frontmatter?.keywords;
|
|
51
|
+
const values = Array.isArray(raw) ? raw : typeof raw === "string" ? (
|
|
52
|
+
// Squisq's frontmatter reader keeps YAML flow lists (`[a, b]`) as text.
|
|
53
|
+
raw.replace(/^\s*\[|\]\s*$/g, "").split(",").map((tag) => tag.trim().replace(/^(["'])(.*)\1$/, "$2"))
|
|
54
|
+
) : [];
|
|
55
|
+
const tags = [];
|
|
56
|
+
for (const value of values) {
|
|
57
|
+
const tag = metadataText(value, CATALOG_LIMITS.maxMetadataCharacters);
|
|
58
|
+
if (tag && !tags.includes(tag)) tags.push(tag);
|
|
59
|
+
if (tags.length >= CATALOG_LIMITS.maxTags) break;
|
|
60
|
+
}
|
|
61
|
+
return tags.length > 0 ? tags : void 0;
|
|
62
|
+
}
|
|
63
|
+
function stemOf(path) {
|
|
64
|
+
const name = path.slice(path.lastIndexOf("/") + 1);
|
|
65
|
+
const dot = name.lastIndexOf(".");
|
|
66
|
+
return dot > 0 ? name.slice(0, dot) : name;
|
|
67
|
+
}
|
|
68
|
+
async function catalogEntryFromDocument(source, document, hints = {}) {
|
|
69
|
+
const { extractPlainText, inferDocumentTitle, readFrontmatterThemeId } = await loadMarkdown();
|
|
70
|
+
const frontmatter = document.frontmatter;
|
|
71
|
+
const title = metadataText(inferDocumentTitle(document), CATALOG_LIMITS.maxMetadataCharacters) ?? metadataText(hints.fallbackTitle, CATALOG_LIMITS.maxMetadataCharacters) ?? stemOf(source.path);
|
|
72
|
+
const outline = [];
|
|
73
|
+
let words = 0;
|
|
74
|
+
let excerpt;
|
|
75
|
+
for (const block of document.children) {
|
|
76
|
+
const text = extractPlainText(block);
|
|
77
|
+
words += countWords(text);
|
|
78
|
+
if (block.type === "heading") {
|
|
79
|
+
const headingTitle = collapseWhitespace(text);
|
|
80
|
+
if (headingTitle && outline.length < CATALOG_LIMITS.maxOutlineEntries) {
|
|
81
|
+
outline.push({
|
|
82
|
+
level: block.depth,
|
|
83
|
+
title: truncate(headingTitle, CATALOG_LIMITS.maxOutlineTitleCharacters)
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
} else if (block.type === "paragraph" && excerpt === void 0) {
|
|
87
|
+
const paragraph = collapseWhitespace(text);
|
|
88
|
+
if (paragraph && paragraph !== title && paragraph !== hints.fallbackTitle) {
|
|
89
|
+
excerpt = truncate(paragraph, CATALOG_LIMITS.maxExcerptCharacters);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const description = firstMetadataText(
|
|
94
|
+
frontmatter,
|
|
95
|
+
["description", "summary", "excerpt"],
|
|
96
|
+
CATALOG_LIMITS.maxDescriptionCharacters
|
|
97
|
+
) ?? metadataText(hints.description, CATALOG_LIMITS.maxDescriptionCharacters);
|
|
98
|
+
const author = firstMetadataText(frontmatter, ["author"], CATALOG_LIMITS.maxMetadataCharacters);
|
|
99
|
+
const date = firstMetadataText(
|
|
100
|
+
frontmatter,
|
|
101
|
+
["date", "updated", "published"],
|
|
102
|
+
CATALOG_LIMITS.maxMetadataCharacters
|
|
103
|
+
);
|
|
104
|
+
const theme = readFrontmatterThemeId(frontmatter);
|
|
105
|
+
return {
|
|
106
|
+
path: source.path,
|
|
107
|
+
...source.source !== void 0 && source.source !== source.path ? { source: source.source } : {},
|
|
108
|
+
format: source.format,
|
|
109
|
+
title,
|
|
110
|
+
...description ? { description } : {},
|
|
111
|
+
...author ? { author } : {},
|
|
112
|
+
...date ? { date } : {},
|
|
113
|
+
...metadataTags(frontmatter) ? { tags: metadataTags(frontmatter) } : {},
|
|
114
|
+
...theme ? { theme } : {},
|
|
115
|
+
outline,
|
|
116
|
+
wordCount: words,
|
|
117
|
+
...excerpt ? { excerpt } : {}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
async function catalogEntryFromMarkdown(source, markdown, options = {}) {
|
|
121
|
+
const { parseMarkdown } = await loadMarkdown();
|
|
122
|
+
const normalized = normalizeLineEndings(markdown);
|
|
123
|
+
const entry = await catalogEntryFromDocument(source, parseMarkdown(normalized));
|
|
124
|
+
return options.includeMarkdown ? { ...entry, markdown: normalized } : entry;
|
|
125
|
+
}
|
|
126
|
+
function catalogEntryForUnreadable(source) {
|
|
127
|
+
return {
|
|
128
|
+
path: source.path,
|
|
129
|
+
format: source.format,
|
|
130
|
+
title: stemOf(source.path),
|
|
131
|
+
outline: [],
|
|
132
|
+
wordCount: 0
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function compareCodeUnits(left, right) {
|
|
136
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
137
|
+
}
|
|
138
|
+
function sortCatalogEntries(entries, order) {
|
|
139
|
+
const byPath = (left, right) => compareCodeUnits(left.path, right.path);
|
|
140
|
+
const byTitle = (left, right) => compareCodeUnits(left.title.toLowerCase(), right.title.toLowerCase()) || compareCodeUnits(left.title, right.title) || byPath(left, right);
|
|
141
|
+
return [...entries].sort((left, right) => {
|
|
142
|
+
if (order === "path") return byPath(left, right);
|
|
143
|
+
if (order === "date") {
|
|
144
|
+
if (left.date && right.date) {
|
|
145
|
+
return compareCodeUnits(right.date, left.date) || byTitle(left, right);
|
|
146
|
+
}
|
|
147
|
+
if (left.date) return -1;
|
|
148
|
+
if (right.date) return 1;
|
|
149
|
+
}
|
|
150
|
+
return byTitle(left, right);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function createWorkspaceCatalog(title, entries, order) {
|
|
154
|
+
return {
|
|
155
|
+
generator: CATALOG_GENERATOR,
|
|
156
|
+
version: CATALOG_FORMAT_VERSION,
|
|
157
|
+
title,
|
|
158
|
+
documents: sortCatalogEntries(entries, order)
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function orderedEntry(entry) {
|
|
162
|
+
const ordered = {};
|
|
163
|
+
const keys = [
|
|
164
|
+
"path",
|
|
165
|
+
"source",
|
|
166
|
+
"format",
|
|
167
|
+
"title",
|
|
168
|
+
"description",
|
|
169
|
+
"author",
|
|
170
|
+
"date",
|
|
171
|
+
"tags",
|
|
172
|
+
"theme",
|
|
173
|
+
"outline",
|
|
174
|
+
"wordCount",
|
|
175
|
+
"excerpt",
|
|
176
|
+
"markdown"
|
|
177
|
+
];
|
|
178
|
+
for (const key of keys) {
|
|
179
|
+
const value = entry[key];
|
|
180
|
+
if (value === void 0) continue;
|
|
181
|
+
ordered[key] = key === "outline" ? value.map((item) => ({
|
|
182
|
+
level: item.level,
|
|
183
|
+
title: item.title
|
|
184
|
+
})) : value;
|
|
185
|
+
}
|
|
186
|
+
return ordered;
|
|
187
|
+
}
|
|
188
|
+
function serializeCatalogJson(catalog) {
|
|
189
|
+
return `${JSON.stringify(
|
|
190
|
+
{
|
|
191
|
+
generator: catalog.generator,
|
|
192
|
+
version: catalog.version,
|
|
193
|
+
title: catalog.title,
|
|
194
|
+
documents: catalog.documents.map(orderedEntry)
|
|
195
|
+
},
|
|
196
|
+
null,
|
|
197
|
+
2
|
|
198
|
+
)}
|
|
199
|
+
`;
|
|
200
|
+
}
|
|
201
|
+
var CATALOG_JSON_MARKER = /^\uFEFF?\{\s*"generator"\s*:\s*"docblocks-workspace-catalog"/;
|
|
202
|
+
function isGeneratedCatalogJson(text) {
|
|
203
|
+
return CATALOG_JSON_MARKER.test(text.slice(0, 256));
|
|
204
|
+
}
|
|
205
|
+
var CATALOG_HTML_MARKER = /<!-- docblocks-workspace-catalog v1 inputs=sha256:([0-9a-f]{64}) -->/;
|
|
206
|
+
var CATALOG_HTML_MARKER_SCAN_CHARACTERS = 2048;
|
|
207
|
+
function stampCatalogHtml(html, inputsDigest) {
|
|
208
|
+
if (!/^[0-9a-f]{64}$/.test(inputsDigest)) throw new Error("Catalog digest must be SHA-256 hex.");
|
|
209
|
+
const marker = `<!-- ${CATALOG_GENERATOR} v1 inputs=sha256:${inputsDigest} -->
|
|
210
|
+
`;
|
|
211
|
+
const doctype = /^<!DOCTYPE html>\r?\n/i.exec(html);
|
|
212
|
+
return doctype ? `${doctype[0]}${marker}${html.slice(doctype[0].length)}` : `${marker}${html}`;
|
|
213
|
+
}
|
|
214
|
+
function readCatalogHtmlDigest(text) {
|
|
215
|
+
return CATALOG_HTML_MARKER.exec(text.slice(0, CATALOG_HTML_MARKER_SCAN_CHARACTERS))?.[1] ?? null;
|
|
216
|
+
}
|
|
217
|
+
function isGeneratedCatalogHtml(text) {
|
|
218
|
+
return readCatalogHtmlDigest(text) !== null;
|
|
219
|
+
}
|
|
220
|
+
function relativeCatalogLink(fromDirectory, toPath) {
|
|
221
|
+
const from = fromDirectory.split("/").filter(Boolean);
|
|
222
|
+
const to = toPath.split("/").filter(Boolean);
|
|
223
|
+
let shared = 0;
|
|
224
|
+
while (shared < from.length && shared < to.length - 1 && from[shared] === to[shared]) shared += 1;
|
|
225
|
+
const up = from.slice(shared).map(() => "..");
|
|
226
|
+
return [...up, ...to.slice(shared).map((segment) => encodeURIComponent(segment))].join("/");
|
|
227
|
+
}
|
|
228
|
+
function textNode(value) {
|
|
229
|
+
return { type: "text", value };
|
|
230
|
+
}
|
|
231
|
+
function folderOf(path) {
|
|
232
|
+
const slash = path.lastIndexOf("/");
|
|
233
|
+
return slash < 0 ? "" : path.slice(0, slash);
|
|
234
|
+
}
|
|
235
|
+
function buildCatalogMarkdownDocument(catalog, outputPath) {
|
|
236
|
+
const outputDirectory = folderOf(outputPath);
|
|
237
|
+
const children = [
|
|
238
|
+
{ type: "heading", depth: 1, children: [textNode(catalog.title)] }
|
|
239
|
+
];
|
|
240
|
+
if (catalog.documents.length === 0) {
|
|
241
|
+
children.push({ type: "paragraph", children: [textNode("No documents yet.")] });
|
|
242
|
+
return { type: "document", children };
|
|
243
|
+
}
|
|
244
|
+
const groups = /* @__PURE__ */ new Map();
|
|
245
|
+
for (const entry of catalog.documents) {
|
|
246
|
+
const folder = folderOf(entry.path);
|
|
247
|
+
const group = groups.get(folder);
|
|
248
|
+
if (group) group.push(entry);
|
|
249
|
+
else groups.set(folder, [entry]);
|
|
250
|
+
}
|
|
251
|
+
const folders = [...groups.keys()].sort(compareCodeUnits);
|
|
252
|
+
const showFolders = folders.length > 1 || folders[0] !== "";
|
|
253
|
+
for (const folder of folders) {
|
|
254
|
+
if (showFolders && folder) {
|
|
255
|
+
children.push({ type: "heading", depth: 2, children: [textNode(folder)] });
|
|
256
|
+
}
|
|
257
|
+
const items = groups.get(folder).map((entry) => {
|
|
258
|
+
const inline = [
|
|
259
|
+
{
|
|
260
|
+
type: "link",
|
|
261
|
+
url: relativeCatalogLink(outputDirectory, entry.path),
|
|
262
|
+
title: null,
|
|
263
|
+
children: [textNode(entry.title)]
|
|
264
|
+
}
|
|
265
|
+
];
|
|
266
|
+
if (entry.date) inline.push(textNode(` \xB7 ${entry.date}`));
|
|
267
|
+
const description = entry.description ?? entry.excerpt;
|
|
268
|
+
if (description) inline.push(textNode(` \u2014 ${description}`));
|
|
269
|
+
return {
|
|
270
|
+
type: "listItem",
|
|
271
|
+
spread: false,
|
|
272
|
+
children: [{ type: "paragraph", children: inline }]
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
children.push({ type: "list", ordered: false, spread: false, children: items });
|
|
276
|
+
}
|
|
277
|
+
return { type: "document", children };
|
|
278
|
+
}
|
|
279
|
+
async function sha256Hex(text) {
|
|
280
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
|
|
281
|
+
return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// src/workspace-settings/outside-in-layout.ts
|
|
285
|
+
var OUTSIDE_IN_FORMAT_IDS = ["html", "docx", "pdf", "pptx", "xlsx", "csv"];
|
|
286
|
+
var FORMAT_IDS = new Set(OUTSIDE_IN_FORMAT_IDS);
|
|
287
|
+
function normalizePath(path) {
|
|
288
|
+
const leading = path.replace(/\\/g, "/").startsWith("/") ? "/" : "";
|
|
289
|
+
const parts = path.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
290
|
+
if (parts.some((part) => part === "." || part === "..")) {
|
|
291
|
+
throw new Error(`Outside-in paths must be canonical workspace paths: ${path}`);
|
|
292
|
+
}
|
|
293
|
+
return leading + parts.join("/");
|
|
294
|
+
}
|
|
295
|
+
function join(parent, child) {
|
|
296
|
+
if (!parent || parent === "/") return parent === "/" ? `/${child}` : child;
|
|
297
|
+
return `${parent}/${child}`;
|
|
298
|
+
}
|
|
299
|
+
function slug(stem) {
|
|
300
|
+
return stem.normalize("NFKD").replace(/\p{Mark}+/gu, "").toLocaleLowerCase("en-US").replace(/[^\p{Letter}\p{Number}]+/gu, "-").replace(/^-+|-+$/g, "") || "document";
|
|
301
|
+
}
|
|
302
|
+
function resolveOutsideInLayout(path) {
|
|
303
|
+
const targetPath = normalizePath(path);
|
|
304
|
+
const slash = targetPath.lastIndexOf("/");
|
|
305
|
+
const parentDirectory = slash < 0 ? "" : slash === 0 ? "/" : targetPath.slice(0, slash);
|
|
306
|
+
const filename = slash < 0 ? targetPath : targetPath.slice(slash + 1);
|
|
307
|
+
const dot = filename.lastIndexOf(".");
|
|
308
|
+
if (dot <= 0) return null;
|
|
309
|
+
const rawFormat = filename.slice(dot + 1).toLowerCase();
|
|
310
|
+
const format = rawFormat === "htm" ? "html" : rawFormat;
|
|
311
|
+
if (!FORMAT_IDS.has(format)) return null;
|
|
312
|
+
const stem = filename.slice(0, dot);
|
|
313
|
+
const companionName = `${stem}_files`;
|
|
314
|
+
const companionDirectory = join(parentDirectory, companionName);
|
|
315
|
+
const markdownFilename = `${slug(stem)}.md`;
|
|
316
|
+
const backupDirectory = join(companionDirectory, ".original");
|
|
317
|
+
const backupFilename = `original.${format}`;
|
|
318
|
+
return {
|
|
319
|
+
targetPath,
|
|
320
|
+
format,
|
|
321
|
+
parentDirectory,
|
|
322
|
+
stem,
|
|
323
|
+
companionName,
|
|
324
|
+
companionDirectory,
|
|
325
|
+
markdownFilename,
|
|
326
|
+
markdownPath: join(companionDirectory, markdownFilename),
|
|
327
|
+
relativeTargetPath: `../${filename}`,
|
|
328
|
+
backupDirectory,
|
|
329
|
+
backupFilename,
|
|
330
|
+
backupPath: join(backupDirectory, backupFilename)
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function relocateOutsideInLayout(layout, targetPath) {
|
|
334
|
+
const next = resolveOutsideInLayout(targetPath);
|
|
335
|
+
if (!next || next.format !== layout.format)
|
|
336
|
+
throw new Error("Keep the outside-in document format when moving it.");
|
|
337
|
+
const root = `${normalizePath(layout.companionDirectory).replace(/\/$/, "")}/`;
|
|
338
|
+
const source = normalizePath(layout.markdownPath);
|
|
339
|
+
if (!source.startsWith(root))
|
|
340
|
+
throw new Error("The Markdown source is outside its companion directory.");
|
|
341
|
+
const markdownPath = join(next.companionDirectory, source.slice(root.length));
|
|
342
|
+
return { ...next, markdownPath, markdownFilename: layout.markdownFilename };
|
|
343
|
+
}
|
|
344
|
+
function chooseOutsideInMarkdownPath(layout, paths) {
|
|
345
|
+
const canonical = normalizePath(layout.markdownPath);
|
|
346
|
+
const normalized = paths.map(normalizePath);
|
|
347
|
+
const exact = normalized.find((path) => path === canonical);
|
|
348
|
+
if (exact) return exact;
|
|
349
|
+
const folded = normalized.find(
|
|
350
|
+
(path) => path.toLocaleLowerCase("en-US") === canonical.toLocaleLowerCase("en-US")
|
|
351
|
+
);
|
|
352
|
+
if (folded) return folded;
|
|
353
|
+
const prefix = `${normalizePath(layout.companionDirectory).replace(/\/$/, "")}/`;
|
|
354
|
+
const markdown = normalized.filter(
|
|
355
|
+
(path) => path.startsWith(prefix) && !path.slice(prefix.length).includes("/") && path.toLocaleLowerCase("en-US").endsWith(".md")
|
|
356
|
+
);
|
|
357
|
+
return markdown.length === 1 ? markdown[0] : null;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export {
|
|
361
|
+
CATALOG_GENERATOR,
|
|
362
|
+
CATALOG_FORMAT_VERSION,
|
|
363
|
+
CATALOG_LIMITS,
|
|
364
|
+
normalizeLineEndings,
|
|
365
|
+
catalogEntryFromDocument,
|
|
366
|
+
catalogEntryFromMarkdown,
|
|
367
|
+
catalogEntryForUnreadable,
|
|
368
|
+
sortCatalogEntries,
|
|
369
|
+
createWorkspaceCatalog,
|
|
370
|
+
serializeCatalogJson,
|
|
371
|
+
isGeneratedCatalogJson,
|
|
372
|
+
stampCatalogHtml,
|
|
373
|
+
readCatalogHtmlDigest,
|
|
374
|
+
isGeneratedCatalogHtml,
|
|
375
|
+
relativeCatalogLink,
|
|
376
|
+
buildCatalogMarkdownDocument,
|
|
377
|
+
sha256Hex,
|
|
378
|
+
OUTSIDE_IN_FORMAT_IDS,
|
|
379
|
+
resolveOutsideInLayout,
|
|
380
|
+
relocateOutsideInLayout,
|
|
381
|
+
chooseOutsideInMarkdownPath
|
|
382
|
+
};
|
|
@@ -4,9 +4,11 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
compareSnapshotsByName,
|
|
6
6
|
compareText,
|
|
7
|
-
copyBytes
|
|
7
|
+
copyBytes
|
|
8
|
+
} from "./chunk-HABG2JM3.js";
|
|
9
|
+
import {
|
|
8
10
|
parseFileSystemVersion
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-LPIJ6HKL.js";
|
|
10
12
|
import {
|
|
11
13
|
decodeUtf8Text
|
|
12
14
|
} from "./chunk-M5ZNQGR5.js";
|