@bendyline/docblocks 2.6.2 → 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.
Files changed (62) hide show
  1. package/THIRD_PARTY_NOTICES.txt +33 -33
  2. package/dist/capabilities-CdQAc745.d.ts +1233 -0
  3. package/dist/catalog-BQK05tne.d.ts +122 -0
  4. package/dist/chunk-245W57QP.js +31 -0
  5. package/dist/{chunk-2WDJ27EH.js → chunk-46AGYHDY.js} +8 -0
  6. package/dist/{chunk-4437YWLE.js → chunk-6UPO2GE6.js} +4 -2
  7. package/dist/{chunk-UMWCTEXW.js → chunk-7SN7YQL4.js} +211 -40
  8. package/dist/{chunk-OQCPBOQA.js → chunk-DAPFSEKY.js} +35 -0
  9. package/dist/{chunk-M62ZGJ5I.js → chunk-HABG2JM3.js} +0 -17
  10. package/dist/{chunk-YM7O3PWO.js → chunk-HKOOHM67.js} +20 -12
  11. package/dist/chunk-IDYE73TU.js +77 -0
  12. package/dist/{chunk-KLQKU74Q.js → chunk-IGB2VSRE.js} +124 -330
  13. package/dist/{chunk-5MJC4KOE.js → chunk-L6PRMR7T.js} +53 -101
  14. package/dist/chunk-LPIJ6HKL.js +19 -0
  15. package/dist/{chunk-SJBB5OD7.js → chunk-QS5WTLUZ.js} +10 -8
  16. package/dist/chunk-R2JX5N3F.js +382 -0
  17. package/dist/{chunk-ZO7G53QP.js → chunk-UDEWLHQI.js} +4 -2
  18. package/dist/chunk-UK7R3RC7.js +514 -0
  19. package/dist/chunk-XTNWCNSK.js +464 -0
  20. package/dist/chunk-YHSFRPBS.js +42 -0
  21. package/dist/chunk-YNUQG4GF.js +1173 -0
  22. package/dist/document/index.d.ts +31 -1
  23. package/dist/document/index.js +7 -6
  24. package/dist/filesystem/electron.d.ts +8 -35
  25. package/dist/filesystem/electron.js +7 -4
  26. package/dist/filesystem/host.d.ts +28 -0
  27. package/dist/filesystem/host.js +103 -0
  28. package/dist/filesystem/index.d.ts +52 -6
  29. package/dist/filesystem/index.js +36 -15
  30. package/dist/filesystem/indexeddb.d.ts +8 -1
  31. package/dist/filesystem/indexeddb.js +7 -6
  32. package/dist/filesystem/memory.d.ts +2 -1
  33. package/dist/filesystem/memory.js +3 -2
  34. package/dist/filesystem/native.d.ts +2 -1
  35. package/dist/filesystem/native.js +3 -2
  36. package/dist/filesystem-v2-C8AdSXUN.d.ts +74 -0
  37. package/dist/host/index.d.ts +127 -5
  38. package/dist/host/index.js +98 -4
  39. package/dist/host/mobile.d.ts +389 -0
  40. package/dist/host/mobile.js +315 -0
  41. package/dist/host-provider-v2-CyLTRKJF.d.ts +51 -0
  42. package/dist/index.d.ts +8 -5
  43. package/dist/index.js +151 -34
  44. package/dist/mcp/index.d.ts +2 -2
  45. package/dist/mcp/zod.d.ts +23 -1
  46. package/dist/mcp/zod.js +1 -0
  47. package/dist/settings-HrrCikVX.d.ts +170 -0
  48. package/dist/types-BvDnr3YU.d.ts +88 -0
  49. package/dist/{types-Oy9U5FST.d.ts → types-d0yvHUJz.d.ts} +6 -0
  50. package/dist/{types-Bb3yccTH.d.ts → v2-BVnZZyd4.d.ts} +1 -86
  51. package/dist/vscode/index.d.ts +43 -1
  52. package/dist/vscode/index.js +67 -1
  53. package/dist/workspace/index.d.ts +10 -6
  54. package/dist/workspace/index.js +4 -2
  55. package/dist/workspace-index/index.d.ts +240 -0
  56. package/dist/workspace-index/index.js +1287 -0
  57. package/dist/workspace-settings/index.d.ts +301 -0
  58. package/dist/workspace-settings/index.js +820 -0
  59. package/package.json +22 -2
  60. package/dist/chunk-KFWPPIJH.js +0 -45
  61. package/dist/chunk-QI6YKTQV.js +0 -110
  62. package/dist/types-DhLZZNEn.d.ts +0 -577
@@ -0,0 +1,514 @@
1
+ import {
2
+ parseWorkspacePath
3
+ } from "./chunk-AYWKIZLD.js";
4
+
5
+ // src/workspace-settings/settings.ts
6
+ var WORKSPACE_SETTINGS_DIRECTORY = ".docblocks";
7
+ var WORKSPACE_SETTINGS_PATH = ".docblocks/workspace.json";
8
+ var WORKSPACE_SETTINGS_VERSION = 1;
9
+ var DEFAULT_CATALOG_TITLE = "Documents";
10
+ var DEFAULT_CATALOG_HTML_PATH = "index.html";
11
+ var DEFAULT_CATALOG_JSON_PATH = "catalog.json";
12
+ var WORKSPACE_SETTINGS_LIMITS = {
13
+ maxFileBytes: 64 * 1024,
14
+ maxTitleCharacters: 256,
15
+ maxPathCharacters: 1024,
16
+ maxSchemaCharacters: 2048,
17
+ maxExcludes: 64,
18
+ minKeep: 1,
19
+ maxKeep: 1e3
20
+ };
21
+ var WORKSPACE_THEME_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,63}$/;
22
+ var CATALOG_SORT_ORDERS = ["title", "path", "date"];
23
+ var CATALOG_JSON_CONTENT_MODES = ["metadata", "markdown"];
24
+ var EMPTY_WORKSPACE_SETTINGS = Object.freeze({
25
+ version: WORKSPACE_SETTINGS_VERSION
26
+ });
27
+ var WorkspaceSettingsShapeError = class extends Error {
28
+ };
29
+ function fail(message) {
30
+ throw new WorkspaceSettingsShapeError(message);
31
+ }
32
+ function isRecord(value) {
33
+ return typeof value === "object" && value !== null && !Array.isArray(value);
34
+ }
35
+ function exactRecord(value, label, allowed) {
36
+ if (!isRecord(value)) fail(`${label} must be an object.`);
37
+ const unknownKey = Object.keys(value).find((key) => !allowed.includes(key));
38
+ if (unknownKey !== void 0) fail(`${label} has an unknown field "${unknownKey}".`);
39
+ return value;
40
+ }
41
+ function optionalBoolean(value, label) {
42
+ if (value === void 0) return void 0;
43
+ if (typeof value !== "boolean") fail(`${label} must be true or false.`);
44
+ return value;
45
+ }
46
+ function optionalTheme(value, label) {
47
+ if (value === void 0) return void 0;
48
+ if (typeof value !== "string" || !WORKSPACE_THEME_ID_PATTERN.test(value)) {
49
+ fail(`${label} must be a theme id such as "warm-earth".`);
50
+ }
51
+ return value;
52
+ }
53
+ function optionalTitle(value, label) {
54
+ if (value === void 0) return void 0;
55
+ if (typeof value !== "string" || !value.trim() || value.length > WORKSPACE_SETTINGS_LIMITS.maxTitleCharacters || hasControlCharacter(value)) {
56
+ fail(
57
+ `${label} must be non-empty text of at most ${WORKSPACE_SETTINGS_LIMITS.maxTitleCharacters} characters.`
58
+ );
59
+ }
60
+ return value;
61
+ }
62
+ function optionalEnum(value, label, allowed) {
63
+ if (value === void 0) return void 0;
64
+ if (typeof value !== "string" || !allowed.includes(value)) {
65
+ fail(`${label} must be one of ${allowed.map((option) => `"${option}"`).join(", ")}.`);
66
+ }
67
+ return value;
68
+ }
69
+ function hasControlCharacter(value) {
70
+ return [...value].some((character) => {
71
+ const codePoint = character.codePointAt(0) ?? 0;
72
+ return codePoint <= 31 || codePoint === 127;
73
+ });
74
+ }
75
+ function boundedPath(value, label) {
76
+ if (typeof value !== "string" || !value || value.length > WORKSPACE_SETTINGS_LIMITS.maxPathCharacters) {
77
+ fail(`${label} must be a workspace-relative path.`);
78
+ }
79
+ let path;
80
+ try {
81
+ path = parseWorkspacePath(value);
82
+ } catch {
83
+ fail(`${label} must be a workspace-relative path without "." or ".." segments.`);
84
+ }
85
+ if (!path) fail(`${label} must not be the workspace root.`);
86
+ return path;
87
+ }
88
+ var OUTPUT_EXTENSIONS = {
89
+ html: [".html", ".htm"],
90
+ json: [".json"]
91
+ };
92
+ function validateCatalogOutputPath(value, kind) {
93
+ const label = `catalog.${kind}.path`;
94
+ const path = boundedPath(value, label);
95
+ const lower = path.toLowerCase();
96
+ if (!OUTPUT_EXTENSIONS[kind].some((extension) => lower.endsWith(extension))) {
97
+ fail(`${label} must end with ${OUTPUT_EXTENSIONS[kind].join(" or ")}.`);
98
+ }
99
+ const segments = path.split("/");
100
+ for (const segment of segments) {
101
+ if (segment.startsWith(".")) fail(`${label} must not be inside a hidden folder.`);
102
+ }
103
+ for (const directory of segments.slice(0, -1)) {
104
+ if (directory.toLowerCase().endsWith("_files")) {
105
+ fail(`${label} must not be inside a document's _files folder.`);
106
+ }
107
+ if (directory === "_squisq") fail(`${label} must not be inside the _squisq folder.`);
108
+ if (directory === "node_modules") fail(`${label} must not be inside node_modules.`);
109
+ }
110
+ return path;
111
+ }
112
+ function checkCatalogOutputPath(value, kind) {
113
+ try {
114
+ return { ok: true, path: validateCatalogOutputPath(value, kind) };
115
+ } catch (error) {
116
+ return { ok: false, message: shapeMessage(error) };
117
+ }
118
+ }
119
+ function parseExclude(value) {
120
+ if (value === void 0) return void 0;
121
+ if (!Array.isArray(value)) fail("catalog.exclude must be a list of folder or file paths.");
122
+ if (value.length > WORKSPACE_SETTINGS_LIMITS.maxExcludes) {
123
+ fail(`catalog.exclude may list at most ${WORKSPACE_SETTINGS_LIMITS.maxExcludes} paths.`);
124
+ }
125
+ const seen = /* @__PURE__ */ new Set();
126
+ const result = [];
127
+ value.forEach((entry, index) => {
128
+ const path = boundedPath(entry, `catalog.exclude[${index}]`);
129
+ if (!seen.has(path)) {
130
+ seen.add(path);
131
+ result.push(path);
132
+ }
133
+ });
134
+ return result;
135
+ }
136
+ function parseKeep(value) {
137
+ if (value === void 0) return void 0;
138
+ if (typeof value !== "number" || !Number.isInteger(value) || value < WORKSPACE_SETTINGS_LIMITS.minKeep || value > WORKSPACE_SETTINGS_LIMITS.maxKeep) {
139
+ fail(
140
+ `versionHistory.keep must be a whole number from ${WORKSPACE_SETTINGS_LIMITS.minKeep} to ${WORKSPACE_SETTINGS_LIMITS.maxKeep}.`
141
+ );
142
+ }
143
+ return value;
144
+ }
145
+ function compact(value) {
146
+ const entries = Object.entries(value).filter(([, field]) => field !== void 0);
147
+ return entries.length > 0 ? Object.fromEntries(entries) : void 0;
148
+ }
149
+ function parseWorkspaceSettings(value) {
150
+ const root = isRecord(value) ? value : fail("Workspace settings must be a JSON object.");
151
+ const version = root.version;
152
+ if (typeof version === "number" && Number.isInteger(version) && version > 1) {
153
+ throw new UnsupportedWorkspaceSettingsVersionError(version);
154
+ }
155
+ exactRecord(root, "Workspace settings", [
156
+ "$schema",
157
+ "version",
158
+ "documents",
159
+ "versionHistory",
160
+ "catalog"
161
+ ]);
162
+ if (version !== WORKSPACE_SETTINGS_VERSION) fail('Workspace settings must have "version": 1.');
163
+ let $schema;
164
+ if (root.$schema !== void 0) {
165
+ if (typeof root.$schema !== "string" || root.$schema.length > WORKSPACE_SETTINGS_LIMITS.maxSchemaCharacters) {
166
+ fail("$schema must be a bounded string.");
167
+ }
168
+ $schema = root.$schema;
169
+ }
170
+ let documents;
171
+ if (root.documents !== void 0) {
172
+ const record = exactRecord(root.documents, "documents", ["defaultTheme"]);
173
+ documents = compact({
174
+ defaultTheme: optionalTheme(record.defaultTheme, "documents.defaultTheme")
175
+ });
176
+ }
177
+ let versionHistory;
178
+ if (root.versionHistory !== void 0) {
179
+ const record = exactRecord(root.versionHistory, "versionHistory", ["enabled", "keep"]);
180
+ versionHistory = compact({
181
+ enabled: optionalBoolean(record.enabled, "versionHistory.enabled"),
182
+ keep: parseKeep(record.keep)
183
+ });
184
+ }
185
+ let catalog;
186
+ if (root.catalog !== void 0) {
187
+ const record = exactRecord(root.catalog, "catalog", [
188
+ "title",
189
+ "sort",
190
+ "exclude",
191
+ "html",
192
+ "json"
193
+ ]);
194
+ let html;
195
+ if (record.html !== void 0) {
196
+ const htmlRecord = exactRecord(record.html, "catalog.html", ["enabled", "path", "theme"]);
197
+ html = compact({
198
+ enabled: optionalBoolean(htmlRecord.enabled, "catalog.html.enabled"),
199
+ path: htmlRecord.path === void 0 ? void 0 : validateCatalogOutputPath(htmlRecord.path, "html"),
200
+ theme: optionalTheme(htmlRecord.theme, "catalog.html.theme")
201
+ });
202
+ }
203
+ let json;
204
+ if (record.json !== void 0) {
205
+ const jsonRecord = exactRecord(record.json, "catalog.json", ["enabled", "path", "content"]);
206
+ json = compact({
207
+ enabled: optionalBoolean(jsonRecord.enabled, "catalog.json.enabled"),
208
+ path: jsonRecord.path === void 0 ? void 0 : validateCatalogOutputPath(jsonRecord.path, "json"),
209
+ content: optionalEnum(
210
+ jsonRecord.content,
211
+ "catalog.json.content",
212
+ CATALOG_JSON_CONTENT_MODES
213
+ )
214
+ });
215
+ }
216
+ catalog = compact({
217
+ title: optionalTitle(record.title, "catalog.title"),
218
+ sort: optionalEnum(record.sort, "catalog.sort", CATALOG_SORT_ORDERS),
219
+ exclude: parseExclude(record.exclude),
220
+ html,
221
+ json
222
+ });
223
+ const htmlPath = (html?.path ?? DEFAULT_CATALOG_HTML_PATH).toLowerCase();
224
+ const jsonPath = (json?.path ?? DEFAULT_CATALOG_JSON_PATH).toLowerCase();
225
+ if (htmlPath === jsonPath) fail("catalog.html.path and catalog.json.path must differ.");
226
+ }
227
+ return {
228
+ ...$schema !== void 0 ? { $schema } : {},
229
+ version: WORKSPACE_SETTINGS_VERSION,
230
+ ...documents ? { documents } : {},
231
+ ...versionHistory ? { versionHistory } : {},
232
+ ...catalog ? { catalog } : {}
233
+ };
234
+ }
235
+ var UnsupportedWorkspaceSettingsVersionError = class extends Error {
236
+ constructor(version) {
237
+ super(
238
+ `These workspace settings were written by a newer version of DocBlocks (settings version ${version}). Update DocBlocks to use or change them.`
239
+ );
240
+ this.version = version;
241
+ this.name = "UnsupportedWorkspaceSettingsVersionError";
242
+ }
243
+ };
244
+ function shapeMessage(error) {
245
+ if (error instanceof WorkspaceSettingsShapeError) return error.message;
246
+ if (error instanceof Error) return error.message;
247
+ return "Workspace settings are invalid.";
248
+ }
249
+ function parseWorkspaceSettingsText(text) {
250
+ const source = text.charCodeAt(0) === 65279 ? text.slice(1) : text;
251
+ if (new TextEncoder().encode(source).byteLength > WORKSPACE_SETTINGS_LIMITS.maxFileBytes) {
252
+ return {
253
+ status: "invalid",
254
+ message: `${WORKSPACE_SETTINGS_PATH} is larger than ${WORKSPACE_SETTINGS_LIMITS.maxFileBytes / 1024} KiB.`
255
+ };
256
+ }
257
+ let value;
258
+ try {
259
+ value = JSON.parse(source);
260
+ } catch (error) {
261
+ return {
262
+ status: "invalid",
263
+ message: `${WORKSPACE_SETTINGS_PATH} is not valid JSON${error instanceof Error ? `: ${error.message}` : "."}`
264
+ };
265
+ }
266
+ try {
267
+ return { status: "ok", settings: parseWorkspaceSettings(value) };
268
+ } catch (error) {
269
+ if (error instanceof UnsupportedWorkspaceSettingsVersionError) {
270
+ return { status: "unsupported-version", message: error.message };
271
+ }
272
+ return { status: "invalid", message: shapeMessage(error) };
273
+ }
274
+ }
275
+ function serializeWorkspaceSettings(settings) {
276
+ const normalized = parseWorkspaceSettings(settings);
277
+ const ordered = {};
278
+ if (normalized.$schema !== void 0) ordered.$schema = normalized.$schema;
279
+ ordered.version = normalized.version;
280
+ if (normalized.documents) {
281
+ ordered.documents = pick(normalized.documents, ["defaultTheme"]);
282
+ }
283
+ if (normalized.versionHistory) {
284
+ ordered.versionHistory = pick(normalized.versionHistory, ["enabled", "keep"]);
285
+ }
286
+ if (normalized.catalog) {
287
+ const catalog = normalized.catalog;
288
+ ordered.catalog = {
289
+ ...pick(catalog, ["title", "sort", "exclude"]),
290
+ ...catalog.html ? { html: pick(catalog.html, ["enabled", "path", "theme"]) } : {},
291
+ ...catalog.json ? { json: pick(catalog.json, ["enabled", "path", "content"]) } : {}
292
+ };
293
+ }
294
+ return `${JSON.stringify(ordered, null, 2)}
295
+ `;
296
+ }
297
+ function pick(value, keys) {
298
+ const result = {};
299
+ for (const key of keys) {
300
+ if (value[key] !== void 0) result[key] = value[key];
301
+ }
302
+ return result;
303
+ }
304
+ function patchFields(base, patch) {
305
+ if (!patch) return base;
306
+ const next = { ...base ?? {} };
307
+ for (const [key, value] of Object.entries(patch)) {
308
+ if (value === void 0) continue;
309
+ if (value === null) delete next[key];
310
+ else next[key] = value;
311
+ }
312
+ return compact(next);
313
+ }
314
+ function applyWorkspaceSettingsPatch(base, patch) {
315
+ const current = base ?? EMPTY_WORKSPACE_SETTINGS;
316
+ const catalogPatch = patch.catalog;
317
+ let catalog = current.catalog;
318
+ if (catalogPatch) {
319
+ const { html: htmlPatch, json: jsonPatch, ...topPatch } = catalogPatch;
320
+ const top = patchFields(
321
+ current.catalog ? pick(current.catalog, ["title", "sort", "exclude"]) : void 0,
322
+ topPatch
323
+ );
324
+ catalog = compact({
325
+ ...top ?? {},
326
+ html: patchFields(current.catalog?.html, htmlPatch),
327
+ json: patchFields(current.catalog?.json, jsonPatch)
328
+ });
329
+ }
330
+ return parseWorkspaceSettings({
331
+ ...current.$schema !== void 0 ? { $schema: current.$schema } : {},
332
+ version: WORKSPACE_SETTINGS_VERSION,
333
+ ...optionalSection("documents", patchFields(current.documents, patch.documents)),
334
+ ...optionalSection("versionHistory", patchFields(current.versionHistory, patch.versionHistory)),
335
+ ...optionalSection("catalog", catalog)
336
+ });
337
+ }
338
+ function optionalSection(key, value) {
339
+ return value ? { [key]: value } : {};
340
+ }
341
+ function diffWorkspaceSettings(before, after) {
342
+ const base = before ?? EMPTY_WORKSPACE_SETTINGS;
343
+ const documents = diffFields(base.documents, after.documents, ["defaultTheme"]);
344
+ const versionHistory = diffFields(base.versionHistory, after.versionHistory, ["enabled", "keep"]);
345
+ const top = diffFields(
346
+ base.catalog,
347
+ after.catalog,
348
+ ["title", "sort", "exclude"]
349
+ );
350
+ const html = diffFields(base.catalog?.html, after.catalog?.html, ["enabled", "path", "theme"]);
351
+ const json = diffFields(base.catalog?.json, after.catalog?.json, ["enabled", "path", "content"]);
352
+ const catalog = top || html || json ? { ...top ?? {}, ...html ? { html } : {}, ...json ? { json } : {} } : void 0;
353
+ return {
354
+ ...documents ? { documents } : {},
355
+ ...versionHistory ? { versionHistory } : {},
356
+ ...catalog ? { catalog } : {}
357
+ };
358
+ }
359
+ function diffFields(before, after, keys) {
360
+ const patch = {};
361
+ for (const key of keys) {
362
+ const previous = before?.[key];
363
+ const next = after?.[key];
364
+ if (JSON.stringify(previous) === JSON.stringify(next)) continue;
365
+ patch[key] = next === void 0 ? null : next;
366
+ }
367
+ return Object.keys(patch).length > 0 ? patch : void 0;
368
+ }
369
+ function isEmptyWorkspaceSettingsPatch(patch) {
370
+ return !patch.documents && !patch.versionHistory && !patch.catalog;
371
+ }
372
+ function parseWorkspaceSettingsPatch(value) {
373
+ const root = exactRecord(value, "Workspace settings patch", [
374
+ "documents",
375
+ "versionHistory",
376
+ "catalog"
377
+ ]);
378
+ const nullable = (field, parse) => field === null ? null : parse(field);
379
+ const result = {};
380
+ if (root.documents !== void 0) {
381
+ const record = exactRecord(root.documents, "documents", ["defaultTheme"]);
382
+ result.documents = compact({
383
+ defaultTheme: nullable(
384
+ record.defaultTheme,
385
+ (input) => optionalTheme(input, "documents.defaultTheme")
386
+ )
387
+ }) ?? {};
388
+ }
389
+ if (root.versionHistory !== void 0) {
390
+ const record = exactRecord(root.versionHistory, "versionHistory", ["enabled", "keep"]);
391
+ result.versionHistory = compact({
392
+ enabled: nullable(
393
+ record.enabled,
394
+ (input) => optionalBoolean(input, "versionHistory.enabled")
395
+ ),
396
+ keep: nullable(record.keep, parseKeep)
397
+ }) ?? {};
398
+ }
399
+ if (root.catalog !== void 0) {
400
+ const record = exactRecord(root.catalog, "catalog", [
401
+ "title",
402
+ "sort",
403
+ "exclude",
404
+ "html",
405
+ "json"
406
+ ]);
407
+ const catalog = {
408
+ ...compact({
409
+ title: nullable(record.title, (input) => optionalTitle(input, "catalog.title")),
410
+ sort: nullable(
411
+ record.sort,
412
+ (input) => optionalEnum(input, "catalog.sort", CATALOG_SORT_ORDERS)
413
+ ),
414
+ exclude: nullable(record.exclude, parseExclude)
415
+ }) ?? {}
416
+ };
417
+ if (record.html !== void 0) {
418
+ const html = exactRecord(record.html, "catalog.html", ["enabled", "path", "theme"]);
419
+ catalog.html = compact({
420
+ enabled: nullable(
421
+ html.enabled,
422
+ (input) => optionalBoolean(input, "catalog.html.enabled")
423
+ ),
424
+ path: nullable(html.path, (input) => validateCatalogOutputPath(input, "html")),
425
+ theme: nullable(html.theme, (input) => optionalTheme(input, "catalog.html.theme"))
426
+ }) ?? {};
427
+ }
428
+ if (record.json !== void 0) {
429
+ const json = exactRecord(record.json, "catalog.json", ["enabled", "path", "content"]);
430
+ catalog.json = compact({
431
+ enabled: nullable(
432
+ json.enabled,
433
+ (input) => optionalBoolean(input, "catalog.json.enabled")
434
+ ),
435
+ path: nullable(json.path, (input) => validateCatalogOutputPath(input, "json")),
436
+ content: nullable(
437
+ json.content,
438
+ (input) => optionalEnum(input, "catalog.json.content", CATALOG_JSON_CONTENT_MODES)
439
+ )
440
+ }) ?? {};
441
+ }
442
+ result.catalog = catalog;
443
+ }
444
+ return result;
445
+ }
446
+ function tryApplyWorkspaceSettingsPatch(base, patch) {
447
+ try {
448
+ return { ok: true, settings: applyWorkspaceSettingsPatch(base, patch) };
449
+ } catch (error) {
450
+ return { ok: false, message: shapeMessage(error) };
451
+ }
452
+ }
453
+ function isDefaultWorkspaceSettings(settings) {
454
+ return settings?.documents?.defaultTheme === void 0 && settings?.versionHistory?.enabled === void 0 && settings?.versionHistory?.keep === void 0 && settings?.catalog?.html?.enabled !== true && settings?.catalog?.json?.enabled !== true;
455
+ }
456
+ function resolveWorkspaceDefaultThemeId(settings) {
457
+ return settings?.documents?.defaultTheme;
458
+ }
459
+ function resolveFallbackThemeId(frontmatterThemeId, settings) {
460
+ if (frontmatterThemeId) return void 0;
461
+ return resolveWorkspaceDefaultThemeId(settings);
462
+ }
463
+ function resolveWorkspaceVersioningEnabled(settings) {
464
+ return settings?.versionHistory?.enabled;
465
+ }
466
+ function resolveCatalogOutputs(settings) {
467
+ const catalog = settings?.catalog;
468
+ const htmlEnabled = catalog?.html?.enabled === true;
469
+ const jsonEnabled = catalog?.json?.enabled === true;
470
+ if (!htmlEnabled && !jsonEnabled) return null;
471
+ return {
472
+ title: catalog?.title ?? DEFAULT_CATALOG_TITLE,
473
+ sort: catalog?.sort ?? "title",
474
+ exclude: catalog?.exclude ?? [],
475
+ html: htmlEnabled ? {
476
+ path: validateCatalogOutputPath(catalog?.html?.path ?? DEFAULT_CATALOG_HTML_PATH, "html"),
477
+ themeId: catalog?.html?.theme ?? settings?.documents?.defaultTheme
478
+ } : null,
479
+ json: jsonEnabled ? {
480
+ path: validateCatalogOutputPath(catalog?.json?.path ?? DEFAULT_CATALOG_JSON_PATH, "json"),
481
+ content: catalog?.json?.content ?? "metadata"
482
+ } : null
483
+ };
484
+ }
485
+
486
+ export {
487
+ WORKSPACE_SETTINGS_DIRECTORY,
488
+ WORKSPACE_SETTINGS_PATH,
489
+ WORKSPACE_SETTINGS_VERSION,
490
+ DEFAULT_CATALOG_TITLE,
491
+ DEFAULT_CATALOG_HTML_PATH,
492
+ DEFAULT_CATALOG_JSON_PATH,
493
+ WORKSPACE_SETTINGS_LIMITS,
494
+ WORKSPACE_THEME_ID_PATTERN,
495
+ CATALOG_SORT_ORDERS,
496
+ CATALOG_JSON_CONTENT_MODES,
497
+ EMPTY_WORKSPACE_SETTINGS,
498
+ validateCatalogOutputPath,
499
+ checkCatalogOutputPath,
500
+ parseWorkspaceSettings,
501
+ UnsupportedWorkspaceSettingsVersionError,
502
+ parseWorkspaceSettingsText,
503
+ serializeWorkspaceSettings,
504
+ applyWorkspaceSettingsPatch,
505
+ diffWorkspaceSettings,
506
+ isEmptyWorkspaceSettingsPatch,
507
+ parseWorkspaceSettingsPatch,
508
+ tryApplyWorkspaceSettingsPatch,
509
+ isDefaultWorkspaceSettings,
510
+ resolveWorkspaceDefaultThemeId,
511
+ resolveFallbackThemeId,
512
+ resolveWorkspaceVersioningEnabled,
513
+ resolveCatalogOutputs
514
+ };