yamlover 0.3.11 → 0.3.13

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 (31) hide show
  1. package/README.md +186 -143
  2. package/bin/yamlover.js +51 -2
  3. package/dist/builtin-taxonomy/$defs/.yamlover/meta.yamlover +25 -0
  4. package/dist/builtin-taxonomy/$defs/annotation +18 -0
  5. package/dist/builtin-taxonomy/$defs/board +15 -0
  6. package/dist/builtin-taxonomy/$defs/chapter +19 -0
  7. package/dist/builtin-taxonomy/$defs/chunk +6 -0
  8. package/dist/builtin-taxonomy/$defs/config +20 -0
  9. package/dist/builtin-taxonomy/$defs/fragment +44 -0
  10. package/dist/builtin-taxonomy/$defs/tag +17 -0
  11. package/dist/builtin-taxonomy/$defs/task +33 -0
  12. package/dist/builtin-taxonomy/$defs/workflow +18 -0
  13. package/dist/builtin-taxonomy/tags/.yamlover/body.yamlover +46 -0
  14. package/dist/client/assets/{decoded-4gqlad5X.js → decoded-7CsibQKd.js} +1 -1
  15. package/dist/client/assets/{djvu-Dex1F0s7.js → djvu-BXFlPnkK.js} +1 -1
  16. package/dist/client/assets/{docx-DJzgnQG5.js → docx-B_9I-KwO.js} +1 -1
  17. package/dist/client/assets/{heic-DqYoM-Wf.js → heic-Ce7tu8UK.js} +1 -1
  18. package/dist/client/assets/{imagemap-DaET_nLG.js → imagemap-DlsYOgu-.js} +1 -1
  19. package/dist/client/assets/index-D7TqaRqy.js +620 -0
  20. package/dist/client/assets/{index-CkbHoSh8.css → index-DEBdytA6.css} +1 -1
  21. package/dist/client/assets/{map-BmG6sq1M.js → map-CKyCg437.js} +1 -1
  22. package/dist/client/assets/{paged-Bxb-d5c7.js → paged-CBui7Gsu.js} +1 -1
  23. package/dist/client/assets/{panzoom-BoL5vDfI.js → panzoom-BDtxTlLr.js} +1 -1
  24. package/dist/client/assets/{pdf-BpkDRVTL.js → pdf-DEAMWCiJ.js} +1 -1
  25. package/dist/client/assets/{psd-DC6nmZST.js → psd-BUfV7J7j.js} +1 -1
  26. package/dist/client/assets/{spreadsheet-DIfzBeGR.js → spreadsheet-DM8lRCkI.js} +1 -1
  27. package/dist/client/assets/{tiff-CBO4Dy15.js → tiff-DvGVB25t.js} +1 -1
  28. package/dist/client/index.html +2 -2
  29. package/dist/server.js +513 -344
  30. package/package.json +1 -1
  31. package/dist/client/assets/index-IlC0sRFA.js +0 -620
package/dist/server.js CHANGED
@@ -5645,7 +5645,7 @@ var require_gifframe = __commonJS({
5645
5645
  var require_gifutil = __commonJS({
5646
5646
  "node_modules/gifwrap/src/gifutil.js"(exports) {
5647
5647
  "use strict";
5648
- var fs10 = __require("fs");
5648
+ var fs11 = __require("fs");
5649
5649
  var ImageQ = require_image_q();
5650
5650
  var BitmapImage2 = require_bitmapimage();
5651
5651
  var { GifFrame: GifFrame2 } = require_gifframe();
@@ -5760,14 +5760,14 @@ var require_gifutil = __commonJS({
5760
5760
  jimpImage.bitmap.data = bitmapImageToShare.bitmap.data;
5761
5761
  return jimpImage;
5762
5762
  };
5763
- exports.write = function(path10, frames, spec, encoder) {
5763
+ exports.write = function(path11, frames, spec, encoder) {
5764
5764
  encoder = encoder || defaultCodec;
5765
- const matches = path10.match(/\.[a-zA-Z]+$/);
5765
+ const matches = path11.match(/\.[a-zA-Z]+$/);
5766
5766
  if (matches !== null && INVALID_SUFFIXES.includes(matches[0].toLowerCase())) {
5767
- throw new Error(`GIF '${path10}' has an unexpected suffix`);
5767
+ throw new Error(`GIF '${path11}' has an unexpected suffix`);
5768
5768
  }
5769
5769
  return encoder.encodeGif(frames, spec).then((gif2) => {
5770
- return _writeBinary(path10, gif2.buffer).then(() => {
5770
+ return _writeBinary(path11, gif2.buffer).then(() => {
5771
5771
  return gif2;
5772
5772
  });
5773
5773
  });
@@ -5839,9 +5839,9 @@ var require_gifutil = __commonJS({
5839
5839
  }
5840
5840
  }
5841
5841
  }
5842
- function _readBinary(path10) {
5842
+ function _readBinary(path11) {
5843
5843
  return new Promise((resolve3, reject) => {
5844
- fs10.readFile(path10, (err, buffer) => {
5844
+ fs11.readFile(path11, (err, buffer) => {
5845
5845
  if (err) {
5846
5846
  return reject(err);
5847
5847
  }
@@ -5849,9 +5849,9 @@ var require_gifutil = __commonJS({
5849
5849
  });
5850
5850
  });
5851
5851
  }
5852
- function _writeBinary(path10, buffer) {
5852
+ function _writeBinary(path11, buffer) {
5853
5853
  return new Promise((resolve3, reject) => {
5854
- fs10.writeFile(path10, buffer, (err) => {
5854
+ fs11.writeFile(path11, buffer, (err) => {
5855
5855
  if (err) {
5856
5856
  return reject(err);
5857
5857
  }
@@ -7861,9 +7861,9 @@ var require_decoder = __commonJS({
7861
7861
  return a2 < 0 ? 0 : a2 > 255 ? 255 : a2;
7862
7862
  }
7863
7863
  constructor.prototype = {
7864
- load: function load(path10) {
7864
+ load: function load(path11) {
7865
7865
  var xhr = new XMLHttpRequest();
7866
- xhr.open("GET", path10, true);
7866
+ xhr.open("GET", path11, true);
7867
7867
  xhr.responseType = "arraybuffer";
7868
7868
  xhr.onload = function() {
7869
7869
  var data = new Uint8Array(xhr.response || xhr.mozResponseArrayBuffer);
@@ -18725,8 +18725,8 @@ var init_parseUtil = __esm({
18725
18725
  init_errors();
18726
18726
  init_en();
18727
18727
  makeIssue = (params) => {
18728
- const { data, path: path10, errorMaps, issueData } = params;
18729
- const fullPath = [...path10, ...issueData.path || []];
18728
+ const { data, path: path11, errorMaps, issueData } = params;
18729
+ const fullPath = [...path11, ...issueData.path || []];
18730
18730
  const fullIssue = {
18731
18731
  ...issueData,
18732
18732
  path: fullPath
@@ -19034,11 +19034,11 @@ var init_types2 = __esm({
19034
19034
  init_parseUtil();
19035
19035
  init_util();
19036
19036
  ParseInputLazyPath = class {
19037
- constructor(parent, value, path10, key) {
19037
+ constructor(parent, value, path11, key) {
19038
19038
  this._cachedPath = [];
19039
19039
  this.parent = parent;
19040
19040
  this.data = value;
19041
- this._path = path10;
19041
+ this._path = path11;
19042
19042
  this._key = key;
19043
19043
  }
19044
19044
  get path() {
@@ -23988,13 +23988,13 @@ var require_await_to_js_umd = __commonJS({
23988
23988
  });
23989
23989
 
23990
23990
  // node_modules/@jimp/file-ops/dist/esm/index.js
23991
- import { promises as fs5 } from "fs";
23991
+ import { promises as fs6 } from "fs";
23992
23992
  import { existsSync as existsSync2 } from "fs";
23993
23993
  var readFile, writeFile;
23994
23994
  var init_esm13 = __esm({
23995
23995
  "node_modules/@jimp/file-ops/dist/esm/index.js"() {
23996
- readFile = fs5.readFile;
23997
- writeFile = fs5.writeFile;
23996
+ readFile = fs6.readFile;
23997
+ writeFile = fs6.writeFile;
23998
23998
  }
23999
23999
  });
24000
24000
 
@@ -24036,11 +24036,11 @@ var require_Mime = __commonJS({
24036
24036
  }
24037
24037
  }
24038
24038
  };
24039
- Mime.prototype.getType = function(path10) {
24040
- path10 = String(path10);
24041
- let last = path10.replace(/^.*[/\\]/, "").toLowerCase();
24039
+ Mime.prototype.getType = function(path11) {
24040
+ path11 = String(path11);
24041
+ let last = path11.replace(/^.*[/\\]/, "").toLowerCase();
24042
24042
  let ext = last.replace(/^.*\./, "").toLowerCase();
24043
- let hasPath = last.length < path10.length;
24043
+ let hasPath = last.length < path11.length;
24044
24044
  let hasDot = ext.length < last.length - 1;
24045
24045
  return (hasDot || !hasPath) && this._types[ext] || null;
24046
24046
  };
@@ -30569,7 +30569,7 @@ __export(file_type_exports, {
30569
30569
  });
30570
30570
  import { ReadableStream as WebReadableStream } from "node:stream/web";
30571
30571
  import { pipeline, PassThrough, Readable } from "node:stream";
30572
- import fs6 from "node:fs/promises";
30572
+ import fs7 from "node:fs/promises";
30573
30573
  import { constants as fileSystemConstants } from "node:fs";
30574
30574
  function isTokenizerStreamBoundsError(error) {
30575
30575
  if (!(error instanceof RangeError) || error.message !== "offset is out of bounds" || typeof error.stack !== "string") {
@@ -30577,8 +30577,8 @@ function isTokenizerStreamBoundsError(error) {
30577
30577
  }
30578
30578
  return /strtok3[/\\]lib[/\\]stream[/\\]/.test(error.stack);
30579
30579
  }
30580
- async function fileTypeFromFile(path10, options) {
30581
- return new FileTypeParser2(options).fromFile(path10, options);
30580
+ async function fileTypeFromFile(path11, options) {
30581
+ return new FileTypeParser2(options).fromFile(path11, options);
30582
30582
  }
30583
30583
  async function fileTypeFromStream(stream, options) {
30584
30584
  return new FileTypeParser2(options).fromStream(stream);
@@ -30609,9 +30609,9 @@ var init_file_type = __esm({
30609
30609
  }
30610
30610
  }
30611
30611
  }
30612
- async fromFile(path10) {
30612
+ async fromFile(path11) {
30613
30613
  this.options.signal?.throwIfAborted();
30614
- const fileHandle = await fs6.open(path10, fileSystemConstants.O_RDONLY | fileSystemConstants.O_NONBLOCK);
30614
+ const fileHandle = await fs7.open(path11, fileSystemConstants.O_RDONLY | fileSystemConstants.O_NONBLOCK);
30615
30615
  const fileStat = await fileHandle.stat();
30616
30616
  if (!fileStat.isFile()) {
30617
30617
  await fileHandle.close();
@@ -30620,7 +30620,7 @@ var init_file_type = __esm({
30620
30620
  const tokenizer = new FileTokenizer(fileHandle, {
30621
30621
  ...this.getTokenizerOptions(),
30622
30622
  fileInfo: {
30623
- path: path10,
30623
+ path: path11,
30624
30624
  size: fileStat.size
30625
30625
  }
30626
30626
  });
@@ -30955,9 +30955,9 @@ function createJimp({ plugins: pluginsArg, formats: formatsArg } = {}) {
30955
30955
  * await image.write("test/output.png");
30956
30956
  * ```
30957
30957
  */
30958
- async write(path10, options) {
30959
- const mimeType = import_lite.default.getType(path10);
30960
- await writeFile(path10, await this.getBuffer(mimeType, options));
30958
+ async write(path11, options) {
30959
+ const mimeType = import_lite.default.getType(path11);
30960
+ await writeFile(path11, await this.getBuffer(mimeType, options));
30961
30961
  }
30962
30962
  /**
30963
30963
  * Clone the image into a new Jimp instance.
@@ -42379,7 +42379,7 @@ var init_simpleXmlToJson_min = __esm({
42379
42379
  });
42380
42380
 
42381
42381
  // node_modules/@jimp/plugin-print/dist/esm/load-bitmap-font.js
42382
- import path6 from "path";
42382
+ import path7 from "path";
42383
42383
  function isBinary(buf) {
42384
42384
  if (typeof buf === "string") {
42385
42385
  return buf.substring(0, 3) === "BMF";
@@ -42470,7 +42470,7 @@ async function processBitmapFont(file, font) {
42470
42470
  ...font,
42471
42471
  chars,
42472
42472
  kernings,
42473
- pages: await Promise.all(font.pages.map(async (page) => CharacterJimp.read(path6.join(path6.dirname(file), page))))
42473
+ pages: await Promise.all(font.pages.map(async (page) => CharacterJimp.read(path7.join(path7.dirname(file), page))))
42474
42474
  };
42475
42475
  }
42476
42476
  var import_parse_bmfont_ascii, import_parse_bmfont_xml, import_parse_bmfont_binary, convertXML, isWebWorker, CharacterJimp, HEADER;
@@ -42493,9 +42493,9 @@ var init_load_bitmap_font = __esm({
42493
42493
  async function loadFont(file) {
42494
42494
  let fileOrBuffer = file;
42495
42495
  if (typeof window === "undefined" && !isWebWorker) {
42496
- const { existsSync: existsSync3, promises: fs10 } = await import("fs");
42496
+ const { existsSync: existsSync3, promises: fs11 } = await import("fs");
42497
42497
  if (existsSync3(file)) {
42498
- fileOrBuffer = await fs10.readFile(file);
42498
+ fileOrBuffer = await fs11.readFile(file);
42499
42499
  }
42500
42500
  }
42501
42501
  const data = await loadBitmapFontData(fileOrBuffer);
@@ -48594,8 +48594,8 @@ var require_descriptor = __commonJS({
48594
48594
  var sig = (0, psdReader_1.readSignature)(reader);
48595
48595
  (0, psdReader_1.readInt32LE)(reader);
48596
48596
  var charsCount = (0, psdReader_1.readInt32LE)(reader);
48597
- var path10 = (0, psdReader_1.readUnicodeStringWithLengthLE)(reader, charsCount);
48598
- return { sig, path: path10 };
48597
+ var path11 = (0, psdReader_1.readUnicodeStringWithLengthLE)(reader, charsCount);
48598
+ return { sig, path: path11 };
48599
48599
  }
48600
48600
  default:
48601
48601
  throw new Error("Invalid TySh descriptor OSType: ".concat(type2, " at ").concat(reader.offset.toString(16)));
@@ -54366,7 +54366,7 @@ var require_additionalInfo = __commonJS({
54366
54366
  function readVectorMask(reader, vectorMask, width, height, size) {
54367
54367
  var end = reader.offset + size;
54368
54368
  var paths = vectorMask.paths;
54369
- var path10 = void 0;
54369
+ var path11 = void 0;
54370
54370
  while (end - reader.offset >= 26) {
54371
54371
  var selector = (0, psdReader_1.readUint16)(reader);
54372
54372
  switch (selector) {
@@ -54376,21 +54376,21 @@ var require_additionalInfo = __commonJS({
54376
54376
  var boolOp = (0, psdReader_1.readInt16)(reader);
54377
54377
  var flags = (0, psdReader_1.readUint16)(reader);
54378
54378
  (0, psdReader_1.skipBytes)(reader, 18);
54379
- path10 = {
54379
+ path11 = {
54380
54380
  open: selector === 3,
54381
54381
  knots: [],
54382
54382
  fillRule: flags === 2 ? "non-zero" : "even-odd"
54383
54383
  };
54384
54384
  if (boolOp !== -1)
54385
- path10.operation = exports.booleanOperations[boolOp];
54386
- paths.push(path10);
54385
+ path11.operation = exports.booleanOperations[boolOp];
54386
+ paths.push(path11);
54387
54387
  break;
54388
54388
  }
54389
54389
  case 1:
54390
54390
  case 2:
54391
54391
  case 4:
54392
54392
  case 5:
54393
- path10.knots.push({ linked: selector === 1 || selector === 4, points: readBezierKnot(reader, width, height) });
54393
+ path11.knots.push({ linked: selector === 1 || selector === 4, points: readBezierKnot(reader, width, height) });
54394
54394
  break;
54395
54395
  case 6:
54396
54396
  (0, psdReader_1.skipBytes)(reader, 24);
@@ -54450,15 +54450,15 @@ var require_additionalInfo = __commonJS({
54450
54450
  (0, psdWriter_1.writeUint16)(writer, vectorMask.fillStartsWithAllPixels ? 1 : 0);
54451
54451
  (0, psdWriter_1.writeZeros)(writer, 22);
54452
54452
  for (var _i = 0, _b = vectorMask.paths; _i < _b.length; _i++) {
54453
- var path10 = _b[_i];
54454
- (0, psdWriter_1.writeUint16)(writer, path10.open ? 3 : 0);
54455
- (0, psdWriter_1.writeUint16)(writer, path10.knots.length);
54456
- (0, psdWriter_1.writeUint16)(writer, path10.operation ? exports.booleanOperations.indexOf(path10.operation) : -1);
54457
- (0, psdWriter_1.writeUint16)(writer, path10.fillRule === "non-zero" ? 2 : 1);
54453
+ var path11 = _b[_i];
54454
+ (0, psdWriter_1.writeUint16)(writer, path11.open ? 3 : 0);
54455
+ (0, psdWriter_1.writeUint16)(writer, path11.knots.length);
54456
+ (0, psdWriter_1.writeUint16)(writer, path11.operation ? exports.booleanOperations.indexOf(path11.operation) : -1);
54457
+ (0, psdWriter_1.writeUint16)(writer, path11.fillRule === "non-zero" ? 2 : 1);
54458
54458
  (0, psdWriter_1.writeZeros)(writer, 18);
54459
- var linkedKnot = path10.open ? 4 : 1;
54460
- var unlinkedKnot = path10.open ? 5 : 2;
54461
- for (var _c = 0, _d = path10.knots; _c < _d.length; _c++) {
54459
+ var linkedKnot = path11.open ? 4 : 1;
54460
+ var unlinkedKnot = path11.open ? 5 : 2;
54461
+ for (var _c = 0, _d = path11.knots; _c < _d.length; _c++) {
54462
54462
  var _e = _d[_c], linked = _e.linked, points = _e.points;
54463
54463
  (0, psdWriter_1.writeUint16)(writer, linked ? linkedKnot : unlinkedKnot);
54464
54464
  writeBezierKnot(writer, points, width, height);
@@ -56177,12 +56177,12 @@ var require_additionalInfo = __commonJS({
56177
56177
  _name: "",
56178
56178
  _classID: "PaCm",
56179
56179
  shapeOperation: "shapeOperation.".concat(c3.shapeOperation),
56180
- SbpL: c3.paths.map(function(path10) {
56180
+ SbpL: c3.paths.map(function(path11) {
56181
56181
  return {
56182
56182
  _name: "",
56183
56183
  _classID: "Sbpl",
56184
- Clsp: path10.closed,
56185
- "Pts ": path10.points.map(function(pt) {
56184
+ Clsp: path11.closed,
56185
+ "Pts ": path11.points.map(function(pt) {
56186
56186
  return {
56187
56187
  _name: "",
56188
56188
  _classID: "Pthp",
@@ -59210,11 +59210,11 @@ var init_webp_dec = __esm({
59210
59210
  var ENVIRONMENT_IS_WORKER = typeof importScripts == "function";
59211
59211
  var ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
59212
59212
  var scriptDirectory = "";
59213
- function locateFile(path10) {
59213
+ function locateFile(path11) {
59214
59214
  if (Module3["locateFile"]) {
59215
- return Module3["locateFile"](path10, scriptDirectory);
59215
+ return Module3["locateFile"](path11, scriptDirectory);
59216
59216
  }
59217
- return scriptDirectory + path10;
59217
+ return scriptDirectory + path11;
59218
59218
  }
59219
59219
  var read_, readAsync, readBinary2, setWindowTitle;
59220
59220
  if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
@@ -60650,11 +60650,11 @@ var init_avif_dec = __esm({
60650
60650
  var ENVIRONMENT_IS_WORKER = typeof importScripts == "function";
60651
60651
  var ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
60652
60652
  var scriptDirectory = "";
60653
- function locateFile(path10) {
60653
+ function locateFile(path11) {
60654
60654
  if (Module3["locateFile"]) {
60655
- return Module3["locateFile"](path10, scriptDirectory);
60655
+ return Module3["locateFile"](path11, scriptDirectory);
60656
60656
  }
60657
- return scriptDirectory + path10;
60657
+ return scriptDirectory + path11;
60658
60658
  }
60659
60659
  var read_, readAsync, readBinary2;
60660
60660
  if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
@@ -62171,17 +62171,17 @@ var require_ignore = __commonJS({
62171
62171
  var throwError = (message, Ctor) => {
62172
62172
  throw new Ctor(message);
62173
62173
  };
62174
- var checkPath = (path10, originalPath, doThrow) => {
62175
- if (!isString(path10)) {
62174
+ var checkPath = (path11, originalPath, doThrow) => {
62175
+ if (!isString(path11)) {
62176
62176
  return doThrow(
62177
62177
  `path must be a string, but got \`${originalPath}\``,
62178
62178
  TypeError
62179
62179
  );
62180
62180
  }
62181
- if (!path10) {
62181
+ if (!path11) {
62182
62182
  return doThrow(`path must not be empty`, TypeError);
62183
62183
  }
62184
- if (checkPath.isNotRelative(path10)) {
62184
+ if (checkPath.isNotRelative(path11)) {
62185
62185
  const r2 = "`path.relative()`d";
62186
62186
  return doThrow(
62187
62187
  `path should be a ${r2} string, but got "${originalPath}"`,
@@ -62190,7 +62190,7 @@ var require_ignore = __commonJS({
62190
62190
  }
62191
62191
  return true;
62192
62192
  };
62193
- var isNotRelative = (path10) => REGEX_TEST_INVALID_PATH.test(path10);
62193
+ var isNotRelative = (path11) => REGEX_TEST_INVALID_PATH.test(path11);
62194
62194
  checkPath.isNotRelative = isNotRelative;
62195
62195
  checkPath.convert = (p2) => p2;
62196
62196
  var Ignore = class {
@@ -62249,7 +62249,7 @@ var require_ignore = __commonJS({
62249
62249
  // setting `checkUnignored` to `false` could reduce additional
62250
62250
  // path matching.
62251
62251
  // @returns {TestResult} true if a file is ignored
62252
- _testOne(path10, checkUnignored) {
62252
+ _testOne(path11, checkUnignored) {
62253
62253
  let ignored = false;
62254
62254
  let unignored = false;
62255
62255
  this._rules.forEach((rule) => {
@@ -62257,7 +62257,7 @@ var require_ignore = __commonJS({
62257
62257
  if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
62258
62258
  return;
62259
62259
  }
62260
- const matched = rule.regex.test(path10);
62260
+ const matched = rule.regex.test(path11);
62261
62261
  if (matched) {
62262
62262
  ignored = !negative;
62263
62263
  unignored = negative;
@@ -62270,24 +62270,24 @@ var require_ignore = __commonJS({
62270
62270
  }
62271
62271
  // @returns {TestResult}
62272
62272
  _test(originalPath, cache, checkUnignored, slices) {
62273
- const path10 = originalPath && checkPath.convert(originalPath);
62273
+ const path11 = originalPath && checkPath.convert(originalPath);
62274
62274
  checkPath(
62275
- path10,
62275
+ path11,
62276
62276
  originalPath,
62277
62277
  this._allowRelativePaths ? RETURN_FALSE : throwError
62278
62278
  );
62279
- return this._t(path10, cache, checkUnignored, slices);
62279
+ return this._t(path11, cache, checkUnignored, slices);
62280
62280
  }
62281
- _t(path10, cache, checkUnignored, slices) {
62282
- if (path10 in cache) {
62283
- return cache[path10];
62281
+ _t(path11, cache, checkUnignored, slices) {
62282
+ if (path11 in cache) {
62283
+ return cache[path11];
62284
62284
  }
62285
62285
  if (!slices) {
62286
- slices = path10.split(SLASH);
62286
+ slices = path11.split(SLASH);
62287
62287
  }
62288
62288
  slices.pop();
62289
62289
  if (!slices.length) {
62290
- return cache[path10] = this._testOne(path10, checkUnignored);
62290
+ return cache[path11] = this._testOne(path11, checkUnignored);
62291
62291
  }
62292
62292
  const parent = this._t(
62293
62293
  slices.join(SLASH) + SLASH,
@@ -62295,24 +62295,24 @@ var require_ignore = __commonJS({
62295
62295
  checkUnignored,
62296
62296
  slices
62297
62297
  );
62298
- return cache[path10] = parent.ignored ? parent : this._testOne(path10, checkUnignored);
62298
+ return cache[path11] = parent.ignored ? parent : this._testOne(path11, checkUnignored);
62299
62299
  }
62300
- ignores(path10) {
62301
- return this._test(path10, this._ignoreCache, false).ignored;
62300
+ ignores(path11) {
62301
+ return this._test(path11, this._ignoreCache, false).ignored;
62302
62302
  }
62303
62303
  createFilter() {
62304
- return (path10) => !this.ignores(path10);
62304
+ return (path11) => !this.ignores(path11);
62305
62305
  }
62306
62306
  filter(paths) {
62307
62307
  return makeArray(paths).filter(this.createFilter());
62308
62308
  }
62309
62309
  // @returns {TestResult}
62310
- test(path10) {
62311
- return this._test(path10, this._testCache, true);
62310
+ test(path11) {
62311
+ return this._test(path11, this._testCache, true);
62312
62312
  }
62313
62313
  };
62314
62314
  var factory = (options) => new Ignore(options);
62315
- var isPathValid = (path10) => checkPath(path10 && checkPath.convert(path10), path10, RETURN_FALSE);
62315
+ var isPathValid = (path11) => checkPath(path11 && checkPath.convert(path11), path11, RETURN_FALSE);
62316
62316
  factory.isPathValid = isPathValid;
62317
62317
  factory.default = factory;
62318
62318
  module.exports = factory;
@@ -62323,15 +62323,15 @@ var require_ignore = __commonJS({
62323
62323
  const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
62324
62324
  checkPath.convert = makePosix;
62325
62325
  const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
62326
- checkPath.isNotRelative = (path10) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path10) || isNotRelative(path10);
62326
+ checkPath.isNotRelative = (path11) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path11) || isNotRelative(path11);
62327
62327
  }
62328
62328
  }
62329
62329
  });
62330
62330
 
62331
62331
  // src/server/engine-api.ts
62332
- import path9 from "node:path";
62333
- import fs9 from "node:fs";
62334
- import { fileURLToPath as fileURLToPath2 } from "node:url";
62332
+ import path10 from "node:path";
62333
+ import fs10 from "node:fs";
62334
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
62335
62335
 
62336
62336
  // ../parser/ts/src/ir.ts
62337
62337
  function isPointer(v) {
@@ -62360,6 +62360,7 @@ function entryPlain(e3) {
62360
62360
  }
62361
62361
 
62362
62362
  // ../engine/ts/src/resolve.ts
62363
+ var YAMLOVER_AUTHORITY = "yamlover.inthemoon.net";
62363
62364
  function resolveDocument(doc) {
62364
62365
  const chains = buildChains(doc.root);
62365
62366
  const { edges: anchorEdges, keys } = realizeAnchors(doc, chains);
@@ -62447,8 +62448,10 @@ function resolve(doc, chains, fromChain, ptr, visited, anchorKeys) {
62447
62448
  switch (ptr.base.scope) {
62448
62449
  case "link": {
62449
62450
  chain = chains.get(root) ?? [root];
62450
- const selfImport = ptr.base.authority === "yamlover" && !root.entries?.some((e3) => e3.key === "yamlover");
62451
- steps = selfImport ? ptr.steps : [{ sel: "key", name: ptr.base.authority }, ...ptr.steps];
62451
+ let authority = ptr.base.authority;
62452
+ if (isWorld && authority === YAMLOVER_AUTHORITY) authority = "yamlover";
62453
+ const selfImport = authority === "yamlover" && !root.entries?.some((e3) => e3.key === "yamlover");
62454
+ steps = selfImport ? ptr.steps : [{ sel: "key", name: authority }, ...ptr.steps];
62452
62455
  break;
62453
62456
  }
62454
62457
  case "document": {
@@ -62605,7 +62608,7 @@ var Store = class {
62605
62608
  try {
62606
62609
  this.db.exec("DELETE FROM node; DELETE FROM edge; DELETE FROM dangling;");
62607
62610
  if (files) this.db.exec("DELETE FROM file;");
62608
- walkNodes(doc.root, ":", (path10, node, parent, label, pos) => {
62611
+ walkNodes(doc.root, ":", (path11, node, parent, label, pos) => {
62609
62612
  const meta = node.meta ? JSON.stringify(node.meta) : null;
62610
62613
  const owned = node.entries?.filter((e3) => e3.edge !== "back") ?? [];
62611
62614
  const isArray = node.array || node.kind === "mapping" && owned.length > 0 && owned.every((e3) => e3.key === null);
@@ -62613,8 +62616,8 @@ var Store = class {
62613
62616
  const format = node.kind === "blob" ? node.format : formatFromMeta(node);
62614
62617
  const hash = node.kind === "blob" ? node.contentHash : null;
62615
62618
  const size = node.kind === "blob" ? node.size : null;
62616
- insNode.run(path10, node.kind, format, value, hash, size, isArray ? 1 : 0, meta);
62617
- if (parent !== null) insEdge.run(parent, path10, label, "contain", pos);
62619
+ insNode.run(path11, node.kind, format, value, hash, size, isArray ? 1 : 0, meta);
62620
+ if (parent !== null) insEdge.run(parent, path11, label, "contain", pos);
62618
62621
  });
62619
62622
  const insDangling = this.db.prepare("INSERT INTO dangling (from_path, raw, reason) VALUES (?, ?, ?)");
62620
62623
  for (const r2 of resolveDocument(doc)) {
@@ -62829,29 +62832,29 @@ var Store = class {
62829
62832
  }));
62830
62833
  }
62831
62834
  /** A node's attributes (null if no such path). */
62832
- node(path10) {
62833
- const row = this.db.prepare("SELECT * FROM node WHERE path = ?").get(path10);
62835
+ node(path11) {
62836
+ const row = this.db.prepare("SELECT * FROM node WHERE path = ?").get(path11);
62834
62837
  return row ? rowToNode(row) : null;
62835
62838
  }
62836
62839
  /** Direct containment children of a node, in source order (by `pos`). */
62837
- children(path10) {
62838
- return this.db.prepare("SELECT to_path, label, pos FROM edge WHERE from_path = ? AND kind = 'contain' ORDER BY pos").all(path10).map((r2) => ({ to: r2.to_path, label: r2.label ?? null, pos: r2.pos ?? null }));
62840
+ children(path11) {
62841
+ return this.db.prepare("SELECT to_path, label, pos FROM edge WHERE from_path = ? AND kind = 'contain' ORDER BY pos").all(path11).map((r2) => ({ to: r2.to_path, label: r2.label ?? null, pos: r2.pos ?? null }));
62839
62842
  }
62840
62843
  /** ALL of a node's entries in source order — containment children AND `*`/`~` pointer
62841
62844
  * entries (ref/back). Unlike {@link children} this keeps positional pointers (`- *file`)
62842
62845
  * in place, so an array that mixes inline values and pointers (e.g. a chapter's `chunks`)
62843
62846
  * projects in full. `kind` says whether `to` is an owned child (contain) or a pointer target. */
62844
- entries(path10) {
62845
- return this.db.prepare("SELECT to_path, label, pos, kind FROM edge WHERE from_path = ? AND kind IN ('contain','ref','back') ORDER BY pos").all(path10).map((r2) => ({ to: r2.to_path, label: r2.label ?? null, pos: r2.pos ?? null, kind: r2.kind }));
62847
+ entries(path11) {
62848
+ return this.db.prepare("SELECT to_path, label, pos, kind FROM edge WHERE from_path = ? AND kind IN ('contain','ref','back') ORDER BY pos").all(path11).map((r2) => ({ to: r2.to_path, label: r2.label ?? null, pos: r2.pos ?? null, kind: r2.kind }));
62846
62849
  }
62847
62850
  /** Whether a node has any containment children (expandable in the TOC). */
62848
- hasChildren(path10) {
62849
- const r2 = this.db.prepare("SELECT 1 FROM edge WHERE from_path = ? AND kind = 'contain' LIMIT 1").get(path10);
62851
+ hasChildren(path11) {
62852
+ const r2 = this.db.prepare("SELECT 1 FROM edge WHERE from_path = ? AND kind = 'contain' LIMIT 1").get(path11);
62850
62853
  return r2 != null;
62851
62854
  }
62852
62855
  /** The containment subtree rooted at `path`, up to `depth` levels (TOC). A recursive CTE
62853
62856
  * over `contain` edges — the acyclic spine; ordered by `pos` at each level. */
62854
- toc(path10 = ":", depth = Infinity) {
62857
+ toc(path11 = ":", depth = Infinity) {
62855
62858
  const rows = this.db.prepare(
62856
62859
  `WITH RECURSIVE sub(from_path, to_path, label, pos, lvl) AS (
62857
62860
  SELECT from_path, to_path, label, pos, 1 FROM edge
@@ -62864,10 +62867,10 @@ var Store = class {
62864
62867
  SELECT s.to_path AS path, s.from_path AS parent, s.label, s.pos, n.type, n.format
62865
62868
  FROM sub s JOIN node n ON n.path = s.to_path
62866
62869
  ORDER BY s.lvl, s.from_path, s.pos`
62867
- ).all(path10, depth === Infinity ? Number.MAX_SAFE_INTEGER : depth);
62870
+ ).all(path11, depth === Infinity ? Number.MAX_SAFE_INTEGER : depth);
62868
62871
  const byPath = /* @__PURE__ */ new Map();
62869
- const root = { path: path10, label: null, type: this.node(path10)?.type ?? "mapping", format: null, children: [] };
62870
- byPath.set(path10, root);
62872
+ const root = { path: path11, label: null, type: this.node(path11)?.type ?? "mapping", format: null, children: [] };
62873
+ byPath.set(path11, root);
62871
62874
  for (const r2 of rows) {
62872
62875
  const tn = {
62873
62876
  path: r2.path,
@@ -62883,20 +62886,20 @@ var Store = class {
62883
62886
  }
62884
62887
  /** Edges in/out of a node, by kind. `derived` inverses are computed here on demand (never
62885
62888
  * stored) per ENGINE.md — for each ref/back into/out of the node, the reverse direction. */
62886
- relationships(path10) {
62887
- const out = this.db.prepare("SELECT * FROM edge WHERE from_path = ? AND kind != 'contain'").all(path10).map(rowToEdge);
62888
- const inc = this.db.prepare("SELECT * FROM edge WHERE to_path = ? AND kind != 'contain'").all(path10).map(rowToEdge);
62889
+ relationships(path11) {
62890
+ const out = this.db.prepare("SELECT * FROM edge WHERE from_path = ? AND kind != 'contain'").all(path11).map(rowToEdge);
62891
+ const inc = this.db.prepare("SELECT * FROM edge WHERE to_path = ? AND kind != 'contain'").all(path11).map(rowToEdge);
62889
62892
  const derivedIn = inc.filter((e3) => e3.kind === "ref" || e3.kind === "back").map((e3) => ({ from: e3.to, to: e3.from, label: e3.label, kind: "derived", pos: null }));
62890
62893
  return { out, in: [...inc, ...derivedIn] };
62891
62894
  }
62892
62895
  };
62893
- function walkNodes(node, path10, visit2, parent = null, label = null, pos = null) {
62894
- visit2(path10, node, parent, label, pos);
62896
+ function walkNodes(node, path11, visit2, parent = null, label = null, pos = null) {
62897
+ visit2(path11, node, parent, label, pos);
62895
62898
  if (!node.entries) return;
62896
62899
  node.entries.forEach((e3, i2) => {
62897
62900
  if (isPointer(e3.value)) return;
62898
- const childPath2 = (path10 === ":" ? "" : path10) + (e3.key != null ? ":" + e3.key : "[" + i2 + "]");
62899
- walkNodes(e3.value, childPath2, visit2, path10, e3.key, i2);
62901
+ const childPath2 = (path11 === ":" ? "" : path11) + (e3.key != null ? ":" + e3.key : "[" + i2 + "]");
62902
+ walkNodes(e3.value, childPath2, visit2, path11, e3.key, i2);
62900
62903
  });
62901
62904
  }
62902
62905
  function formatFromMeta(node) {
@@ -62934,8 +62937,8 @@ function rowToEdge(r2) {
62934
62937
  }
62935
62938
 
62936
62939
  // ../engine/ts/src/walk.ts
62937
- import fs from "node:fs";
62938
- import path from "node:path";
62940
+ import fs2 from "node:fs";
62941
+ import path2 from "node:path";
62939
62942
  import { setImmediate as yieldLoop } from "node:timers/promises";
62940
62943
 
62941
62944
  // ../engine/ts/node_modules/xxhash-wasm/esm/xxhash-wasm.js
@@ -63179,8 +63182,8 @@ function colonSegment(name) {
63179
63182
  if (/[ \t]/.test(name) || /^['"]/.test(name)) return `'${name.replace(/'/g, "''")}'`;
63180
63183
  return name.replace(/[\\:[\]*&#~?!()<>=|]/g, (c3) => "\\" + c3);
63181
63184
  }
63182
- function parsePath(path10) {
63183
- const segs = splitSlash(path10);
63185
+ function parsePath(path11) {
63186
+ const segs = splitSlash(path11);
63184
63187
  const out = [];
63185
63188
  for (let i2 = 0; i2 < segs.length; i2++) {
63186
63189
  if (segs[i2] === "") continue;
@@ -63271,13 +63274,13 @@ function makeAnchor(body, fail) {
63271
63274
  ordinal = true;
63272
63275
  body = body.slice(0, -2);
63273
63276
  }
63274
- const path10 = parsePointer(body);
63277
+ const path11 = parsePointer(body);
63275
63278
  if (!ordinal) {
63276
- const last = path10.steps[path10.steps.length - 1];
63279
+ const last = path11.steps[path11.steps.length - 1];
63277
63280
  if (last === void 0) fail('an anchor path needs a key segment (or a trailing "[]" for ordinal membership)');
63278
63281
  if (last.sel !== "key") fail('an anchor may not claim a position \u2014 use a trailing "[]" for ordinal membership');
63279
63282
  }
63280
- return { path: path10, ...ordinal ? { ordinal: true } : {} };
63283
+ return { path: path11, ...ordinal ? { ordinal: true } : {} };
63281
63284
  }
63282
63285
  function escapeSegment(name) {
63283
63286
  if (name === "..") return "\\.\\.";
@@ -64303,6 +64306,49 @@ function json5number(tok) {
64303
64306
  return void 0;
64304
64307
  }
64305
64308
 
64309
+ // ../engine/ts/src/mounts.ts
64310
+ import fs from "node:fs";
64311
+ import path from "node:path";
64312
+ import { fileURLToPath } from "node:url";
64313
+ var YAMLOVER_AUTHORITY2 = "yamlover.inthemoon.net";
64314
+ var moduleDir = path.dirname(fileURLToPath(import.meta.url));
64315
+ function taxonomyDir() {
64316
+ const candidates = [
64317
+ path.join(moduleDir, "builtin-taxonomy"),
64318
+ // published package: dist/builtin-taxonomy
64319
+ path.resolve(moduleDir, "../../../../")
64320
+ // dev/source run: the repo root
64321
+ ];
64322
+ for (const c3 of candidates) if (fs.existsSync(path.join(c3, "$defs"))) return c3;
64323
+ return null;
64324
+ }
64325
+ var cached;
64326
+ function loadBundledTaxonomy() {
64327
+ if (cached !== void 0) return cached;
64328
+ const dir = taxonomyDir();
64329
+ if (!dir) return cached = null;
64330
+ const defsRoot = walkTree(path.join(dir, "$defs"), { noGraft: true }).doc.root;
64331
+ const entries = [{ key: "$defs", edge: "contain", value: defsRoot }];
64332
+ const tagsDir = path.join(dir, "tags");
64333
+ if (fs.existsSync(tagsDir)) {
64334
+ entries.push({ key: "tags", edge: "contain", value: walkTree(tagsDir, { noGraft: true }).doc.root });
64335
+ }
64336
+ const defs = defsMap(defsRoot);
64337
+ return cached = { node: { kind: "mapping", array: false, entries }, defs };
64338
+ }
64339
+ function graftTaxonomy() {
64340
+ const base = loadBundledTaxonomy();
64341
+ if (!base) return null;
64342
+ const node = structuredClone(base.node);
64343
+ const defsNode = node.entries?.find((e3) => e3.key === "$defs")?.value;
64344
+ return { node, defs: defsNode ? defsMap(defsNode) : /* @__PURE__ */ new Map() };
64345
+ }
64346
+ function defsMap(defsNode) {
64347
+ const m = /* @__PURE__ */ new Map();
64348
+ for (const e3 of defsNode.entries ?? []) if (e3.key && !isPointer(e3.value)) m.set(e3.key, e3.value);
64349
+ return m;
64350
+ }
64351
+
64306
64352
  // ../engine/ts/src/walk.ts
64307
64353
  var { h64Raw, create64 } = await e();
64308
64354
  var hashBytes = (bytes) => "xxh64:" + h64Raw(bytes).toString(16).padStart(16, "0");
@@ -64316,6 +64362,8 @@ var YAMLOVER_INTERNAL = /* @__PURE__ */ new Set([
64316
64362
  "index.db-shm",
64317
64363
  "index.db-journal"
64318
64364
  ]);
64365
+ var SETTINGS_FILE = "settings.yamlover";
64366
+ var skipInYamloverDir = (name) => YAMLOVER_INTERNAL.has(name) && name !== SETTINGS_FILE || name.startsWith(".");
64319
64367
  var MAX_TEXT_BYTES = 1 << 20;
64320
64368
  var MAX_DOC_BYTES = 64 << 20;
64321
64369
  var HASH_INLINE_MAX = 1 << 20;
@@ -64373,24 +64421,35 @@ function builtinYamloverGraft() {
64373
64421
  return { node, defs: /* @__PURE__ */ new Map([["tag", tagCopy], ["fragment", fragCopy], ["annotation", annCopy]]) };
64374
64422
  }
64375
64423
  function* walkTreeGen(absDir, opts = {}) {
64376
- const ctx = { root: path.resolve(absDir), opts, files: /* @__PURE__ */ new Map(), count: 0 };
64424
+ const ctx = { root: path2.resolve(absDir), opts, files: /* @__PURE__ */ new Map(), count: 0 };
64377
64425
  const root = yield* dirNode(ctx.root, ctx);
64378
64426
  root.meta = { ...root.meta, documentRoot: true };
64379
64427
  const defsRoot = findDefsRoot(absDir);
64380
- const defsDir = path.join(defsRoot, "$defs");
64381
- const selfRoot = path.resolve(absDir) === defsRoot;
64428
+ const defsDir = path2.join(defsRoot, "$defs");
64429
+ const selfRoot = fs2.existsSync(defsDir) && path2.resolve(absDir) === defsRoot;
64382
64430
  const arrayRoot = root.array || (root.entries?.length ? root.entries.every((e3) => e3.key === null) : false);
64383
64431
  let builtinDefs;
64384
- if (!arrayRoot && root.entries && !root.entries.some((e3) => e3.key === "yamlover")) {
64385
- if (fs.existsSync(defsDir) && !selfRoot) {
64386
- const shared = [{ key: "$defs", edge: "contain", value: yield* dirNode(defsDir, ctx) }];
64387
- const tagsDir = path.join(defsRoot, "tags");
64388
- if (fs.existsSync(tagsDir)) shared.push({ key: "tags", edge: "contain", value: yield* dirNode(tagsDir, ctx) });
64389
- root.entries.push({ key: "yamlover", edge: "contain", value: { kind: "mapping", entries: shared, array: false } });
64390
- } else if (!fs.existsSync(defsDir)) {
64391
- const built = builtinYamloverGraft();
64392
- root.entries.push({ key: "yamlover", edge: "contain", value: built.node });
64393
- builtinDefs = built.defs;
64432
+ if (!opts.noGraft && !arrayRoot && root.entries) {
64433
+ const yEntry = root.entries.find((e3) => e3.key === "yamlover");
64434
+ const yIsSelfImport = !yEntry || isPointer(yEntry.value) && isYamloverWorldPointer(yEntry.value);
64435
+ if (selfRoot) {
64436
+ if (yEntry && yIsSelfImport) root.entries = root.entries.filter((e3) => e3 !== yEntry);
64437
+ } else if (yIsSelfImport) {
64438
+ let node;
64439
+ if (fs2.existsSync(defsDir)) {
64440
+ const shared = [{ key: "$defs", edge: "contain", value: yield* dirNode(defsDir, ctx) }];
64441
+ const tagsDir = path2.join(defsRoot, "tags");
64442
+ if (fs2.existsSync(tagsDir)) shared.push({ key: "tags", edge: "contain", value: yield* dirNode(tagsDir, ctx) });
64443
+ node = { kind: "mapping", entries: shared, array: false };
64444
+ } else {
64445
+ const built = graftTaxonomy() ?? builtinYamloverGraft();
64446
+ node = built.node;
64447
+ builtinDefs = built.defs;
64448
+ }
64449
+ if (yEntry) {
64450
+ yEntry.value = node;
64451
+ yEntry.edge = "contain";
64452
+ } else root.entries.push({ key: "yamlover", edge: "contain", value: node });
64394
64453
  }
64395
64454
  }
64396
64455
  applySchemas(root, defsRoot, builtinDefs);
@@ -64408,7 +64467,7 @@ function reindex(store, absDir, opts = {}) {
64408
64467
  async function reindexAsyncDoc(store, absDir, opts = {}) {
64409
64468
  const prev = store.stale ? /* @__PURE__ */ new Map() : store.manifest();
64410
64469
  const onProgress = opts.onProgress;
64411
- const total = onProgress ? await countChildren(path.resolve(absDir), opts) : void 0;
64470
+ const total = onProgress ? await countChildren(path2.resolve(absDir), opts) : void 0;
64412
64471
  const { doc, files } = await walkTreeAsync(absDir, {
64413
64472
  ...opts,
64414
64473
  cache: opts.cache ?? manifestCache(prev),
@@ -64420,7 +64479,7 @@ async function reindexAsyncDoc(store, absDir, opts = {}) {
64420
64479
  return { diff: diffManifest(prev, files), doc, files };
64421
64480
  }
64422
64481
  async function reindexPathAsync(store, absDir, cachedDoc, changedRel, opts = {}) {
64423
- const root = path.resolve(absDir);
64482
+ const root = path2.resolve(absDir);
64424
64483
  const parts = changedRel.split("/");
64425
64484
  const yi = parts.indexOf(YAMLOVER_DIR);
64426
64485
  const dirSegs = yi >= 0 ? parts.slice(0, yi) : parts.slice(0, -1);
@@ -64436,8 +64495,8 @@ async function reindexPathAsync(store, absDir, cachedDoc, changedRel, opts = {})
64436
64495
  else entries = entries[i2].value.entries;
64437
64496
  }
64438
64497
  if (!target) return null;
64439
- const absSpliceDir = path.join(root, ...dirSegs);
64440
- if (!fs.existsSync(absSpliceDir) || !fs.statSync(absSpliceDir).isDirectory()) return null;
64498
+ const absSpliceDir = path2.join(root, ...dirSegs);
64499
+ if (!fs2.existsSync(absSpliceDir) || !fs2.statSync(absSpliceDir).isDirectory()) return null;
64441
64500
  const prev = store.stale ? /* @__PURE__ */ new Map() : store.manifest();
64442
64501
  const ctx = { root, opts: { ...opts, cache: opts.cache ?? manifestCache(prev) }, files: /* @__PURE__ */ new Map(), count: 0 };
64443
64502
  const gen = dirNode(absSpliceDir, ctx);
@@ -64472,18 +64531,18 @@ async function countChildren(absRoot, opts) {
64472
64531
  const visitYamlover = async (dir) => {
64473
64532
  let entries;
64474
64533
  try {
64475
- entries = await fs.promises.readdir(dir, { withFileTypes: true });
64534
+ entries = await fs2.promises.readdir(dir, { withFileTypes: true });
64476
64535
  } catch {
64477
64536
  return 0;
64478
64537
  }
64479
64538
  let top = 0;
64480
64539
  for (const e3 of entries) {
64481
- if (YAMLOVER_INTERNAL.has(e3.name) || e3.name.startsWith(".")) continue;
64482
- const abs = path.join(dir, e3.name);
64540
+ if (skipInYamloverDir(e3.name)) continue;
64541
+ const abs = path2.join(dir, e3.name);
64483
64542
  if (opts.ignore?.(abs)) continue;
64484
64543
  n2++;
64485
64544
  top++;
64486
- const isDir = e3.isDirectory() || e3.isSymbolicLink() && (await fs.promises.stat(abs).catch(() => null))?.isDirectory();
64545
+ const isDir = e3.isDirectory() || e3.isSymbolicLink() && (await fs2.promises.stat(abs).catch(() => null))?.isDirectory();
64487
64546
  if (isDir) await visit2(abs);
64488
64547
  }
64489
64548
  return top;
@@ -64491,20 +64550,20 @@ async function countChildren(absRoot, opts) {
64491
64550
  const visit2 = async (dir) => {
64492
64551
  let entries;
64493
64552
  try {
64494
- entries = await fs.promises.readdir(dir, { withFileTypes: true });
64553
+ entries = await fs2.promises.readdir(dir, { withFileTypes: true });
64495
64554
  } catch {
64496
64555
  return;
64497
64556
  }
64498
64557
  for (const e3 of entries) {
64499
64558
  if (e3.name.startsWith(".") && e3.name !== YAMLOVER_DIR) continue;
64500
- const abs = path.join(dir, e3.name);
64559
+ const abs = path2.join(dir, e3.name);
64501
64560
  if (opts.ignore?.(abs)) continue;
64502
64561
  if (e3.name === YAMLOVER_DIR) {
64503
64562
  if (await visitYamlover(abs) > 0) n2++;
64504
64563
  continue;
64505
64564
  }
64506
64565
  n2++;
64507
- const isDir = e3.isDirectory() || e3.isSymbolicLink() && (await fs.promises.stat(abs).catch(() => null))?.isDirectory();
64566
+ const isDir = e3.isDirectory() || e3.isSymbolicLink() && (await fs2.promises.stat(abs).catch(() => null))?.isDirectory();
64508
64567
  if (isDir) await visit2(abs);
64509
64568
  }
64510
64569
  };
@@ -64554,7 +64613,7 @@ function groupBy(list, key) {
64554
64613
  return m;
64555
64614
  }
64556
64615
  async function hashFileAsync(abs, onChunk) {
64557
- const fh = await fs.promises.open(abs, "r");
64616
+ const fh = await fs2.promises.open(abs, "r");
64558
64617
  try {
64559
64618
  const hasher = create64();
64560
64619
  const buf = Buffer.alloc(HASH_CHUNK);
@@ -64572,19 +64631,19 @@ async function hashFileAsync(abs, onChunk) {
64572
64631
  }
64573
64632
  }
64574
64633
  function record(ctx, abs, hash, size, mtimeMs) {
64575
- const rel = path.relative(ctx.root, abs).split(path.sep).join("/");
64634
+ const rel = path2.relative(ctx.root, abs).split(path2.sep).join("/");
64576
64635
  if (rel.startsWith("..")) return;
64577
64636
  ctx.files.set(rel, { path: rel, hash, size, mtimeMs });
64578
64637
  }
64579
64638
  function readTracked(ctx, abs) {
64580
- const stat = fs.statSync(abs);
64581
- const bytes = fs.readFileSync(abs);
64639
+ const stat = fs2.statSync(abs);
64640
+ const bytes = fs2.readFileSync(abs);
64582
64641
  record(ctx, abs, hashBytes(bytes), stat.size, stat.mtimeMs);
64583
64642
  return bytes;
64584
64643
  }
64585
64644
  function loadMeta(dir, ctx) {
64586
- const file = path.join(dir, YAMLOVER_DIR, "meta.yamlover");
64587
- if (!fs.existsSync(file)) return {};
64645
+ const file = path2.join(dir, YAMLOVER_DIR, "meta.yamlover");
64646
+ if (!fs2.existsSync(file)) return {};
64588
64647
  try {
64589
64648
  const plain = toPlain(parseYamlover(readTracked(ctx, file).toString("utf8"), file).root);
64590
64649
  const props = plain?.properties ?? {};
@@ -64595,21 +64654,21 @@ function loadMeta(dir, ctx) {
64595
64654
  }
64596
64655
  function* dirNode(dir, ctx) {
64597
64656
  const meta = loadMeta(dir, ctx);
64598
- const names3 = fs.readdirSync(dir).filter((n2) => n2 === YAMLOVER_DIR || !n2.startsWith(".")).filter((n2) => !ctx.opts.ignore?.(path.join(dir, n2))).sort();
64657
+ const names3 = fs2.readdirSync(dir).filter((n2) => n2 === YAMLOVER_DIR || !n2.startsWith(".")).filter((n2) => !ctx.opts.ignore?.(path2.join(dir, n2))).sort();
64599
64658
  const entries = [];
64600
64659
  for (const name of names3) {
64601
- const abs = path.join(dir, name);
64660
+ const abs = path2.join(dir, name);
64602
64661
  if (name === YAMLOVER_DIR) {
64603
64662
  const hidden = yield* yamloverDirNode(abs, ctx);
64604
64663
  if (hidden) {
64605
64664
  entries.push({ key: name, edge: "contain", value: hidden });
64606
- yield { done: ++ctx.count, path: path.relative(ctx.root, abs).split(path.sep).join("/") };
64665
+ yield { done: ++ctx.count, path: path2.relative(ctx.root, abs).split(path2.sep).join("/") };
64607
64666
  }
64608
64667
  continue;
64609
64668
  }
64610
64669
  const child = yield* childNode(abs, meta[name], ctx);
64611
64670
  entries.push({ key: name, edge: "contain", value: child });
64612
- yield { done: ++ctx.count, path: path.relative(ctx.root, abs).split(path.sep).join("/") };
64671
+ yield { done: ++ctx.count, path: path2.relative(ctx.root, abs).split(path2.sep).join("/") };
64613
64672
  }
64614
64673
  const node = { kind: "mapping", entries, array: false };
64615
64674
  return applyMeta(applyBody(dir, node, ctx), meta);
@@ -64617,24 +64676,24 @@ function* dirNode(dir, ctx) {
64617
64676
  function* yamloverDirNode(absYamlover, ctx) {
64618
64677
  let names3;
64619
64678
  try {
64620
- names3 = fs.readdirSync(absYamlover).filter((n2) => !YAMLOVER_INTERNAL.has(n2) && !n2.startsWith(".")).filter((n2) => !ctx.opts.ignore?.(path.join(absYamlover, n2))).sort();
64679
+ names3 = fs2.readdirSync(absYamlover).filter((n2) => !skipInYamloverDir(n2)).filter((n2) => !ctx.opts.ignore?.(path2.join(absYamlover, n2))).sort();
64621
64680
  } catch {
64622
64681
  return null;
64623
64682
  }
64624
64683
  const entries = [];
64625
64684
  for (const name of names3) {
64626
- const abs = path.join(absYamlover, name);
64685
+ const abs = path2.join(absYamlover, name);
64627
64686
  const child = yield* childNode(abs, void 0, ctx);
64628
64687
  entries.push({ key: name, edge: "contain", value: child });
64629
- yield { done: ++ctx.count, path: path.relative(ctx.root, abs).split(path.sep).join("/") };
64688
+ yield { done: ++ctx.count, path: path2.relative(ctx.root, abs).split(path2.sep).join("/") };
64630
64689
  }
64631
64690
  if (entries.length === 0) return null;
64632
64691
  return { kind: "mapping", entries, array: false, meta: { hidden: true } };
64633
64692
  }
64634
64693
  function* childNode(abs, m, ctx) {
64635
- const stat = fs.statSync(abs);
64694
+ const stat = fs2.statSync(abs);
64636
64695
  if (stat.isDirectory()) return yield* dirNode(abs, ctx);
64637
- const ext = path.extname(abs).toLowerCase();
64696
+ const ext = path2.extname(abs).toLowerCase();
64638
64697
  const fmt = m?.format ?? EXT_FORMAT[ext] ?? null;
64639
64698
  if (m?.type === "binary") return blob(abs, fmt ?? "application/octet-stream", ctx);
64640
64699
  if (fmt && (DOC_FORMATS[fmt] || TEXT_FORMATS.has(fmt))) {
@@ -64658,15 +64717,15 @@ function applyMeta(node, meta) {
64658
64717
  return node;
64659
64718
  }
64660
64719
  function blob(abs, format, ctx) {
64661
- const stat = fs.statSync(abs);
64662
- const rel = path.relative(ctx.root, abs).split(path.sep).join("/");
64663
- const cached = ctx.opts.cache?.(rel, stat.size, stat.mtimeMs) ?? null;
64664
- if (cached) {
64665
- record(ctx, abs, cached, stat.size, stat.mtimeMs);
64666
- return { kind: "blob", format, contentHash: cached, size: stat.size };
64720
+ const stat = fs2.statSync(abs);
64721
+ const rel = path2.relative(ctx.root, abs).split(path2.sep).join("/");
64722
+ const cached2 = ctx.opts.cache?.(rel, stat.size, stat.mtimeMs) ?? null;
64723
+ if (cached2) {
64724
+ record(ctx, abs, cached2, stat.size, stat.mtimeMs);
64725
+ return { kind: "blob", format, contentHash: cached2, size: stat.size };
64667
64726
  }
64668
64727
  const inlineMax = ctx.opts.hashInlineMax ?? HASH_INLINE_MAX;
64669
- const contentHash = stat.size <= inlineMax ? hashBytes(fs.readFileSync(abs)) : null;
64728
+ const contentHash = stat.size <= inlineMax ? hashBytes(fs2.readFileSync(abs)) : null;
64670
64729
  record(ctx, abs, contentHash, stat.size, stat.mtimeMs);
64671
64730
  return { kind: "blob", format, contentHash, size: stat.size };
64672
64731
  }
@@ -64688,12 +64747,15 @@ function parsedDoc(abs, lang, ctx) {
64688
64747
  return { kind: "scalar", value: text, raw: text };
64689
64748
  }
64690
64749
  }
64750
+ function isYamloverWorldPointer(v) {
64751
+ return isPointer(v) && v.base.scope === "link" && v.base.world === true && v.base.authority === YAMLOVER_AUTHORITY2;
64752
+ }
64691
64753
  function findDefsRoot(dir) {
64692
- let d = path.resolve(dir);
64754
+ let d = path2.resolve(dir);
64693
64755
  for (; ; ) {
64694
- if (fs.existsSync(path.join(d, "$defs"))) return d;
64695
- const up = path.dirname(d);
64696
- if (up === d) return path.resolve(dir);
64756
+ if (fs2.existsSync(path2.join(d, "$defs"))) return d;
64757
+ const up = path2.dirname(d);
64758
+ if (up === d) return path2.resolve(dir);
64697
64759
  d = up;
64698
64760
  }
64699
64761
  }
@@ -64701,9 +64763,9 @@ function applySchemas(root, defsRoot, builtinDefs) {
64701
64763
  const cache = /* @__PURE__ */ new Map();
64702
64764
  const loadDef = (name) => {
64703
64765
  if (!cache.has(name)) {
64704
- const defFile = path.join(defsRoot, "$defs", name);
64766
+ const defFile = path2.join(defsRoot, "$defs", name);
64705
64767
  try {
64706
- cache.set(name, parseYamlover(fs.readFileSync(defFile, "utf8"), defFile).root);
64768
+ cache.set(name, parseYamlover(fs2.readFileSync(defFile, "utf8"), defFile).root);
64707
64769
  } catch {
64708
64770
  cache.set(name, builtinDefs?.get(name) ?? null);
64709
64771
  }
@@ -64760,8 +64822,8 @@ function inlineFormat(format) {
64760
64822
  return { kind: "mapping", entries: [{ key: "format", edge: "contain", value: { kind: "scalar", value: format, raw: format } }], array: false };
64761
64823
  }
64762
64824
  function applyBody(dir, node, ctx) {
64763
- const file = path.join(dir, YAMLOVER_DIR, "body.yamlover");
64764
- if (!fs.existsSync(file)) return node;
64825
+ const file = path2.join(dir, YAMLOVER_DIR, "body.yamlover");
64826
+ if (!fs2.existsSync(file)) return node;
64765
64827
  const bodyDoc = parseYamlover(readTracked(ctx, file).toString("utf8"), file);
64766
64828
  const body = bodyDoc.root;
64767
64829
  if (body.kind !== "mapping" && body.kind !== "scalar" || !body.entries) return node;
@@ -64813,14 +64875,14 @@ function pointerLeafKey(v) {
64813
64875
  }
64814
64876
  function looksBinary(abs) {
64815
64877
  try {
64816
- if (fs.statSync(abs).size > MAX_TEXT_BYTES) return true;
64817
- const fd = fs.openSync(abs, "r");
64878
+ if (fs2.statSync(abs).size > MAX_TEXT_BYTES) return true;
64879
+ const fd = fs2.openSync(abs, "r");
64818
64880
  try {
64819
64881
  const buf = Buffer.alloc(4096);
64820
- const n2 = fs.readSync(fd, buf, 0, buf.length, 0);
64882
+ const n2 = fs2.readSync(fd, buf, 0, buf.length, 0);
64821
64883
  return buf.subarray(0, n2).includes(0);
64822
64884
  } finally {
64823
- fs.closeSync(fd);
64885
+ fs2.closeSync(fd);
64824
64886
  }
64825
64887
  } catch {
64826
64888
  return true;
@@ -64890,7 +64952,7 @@ var DOC_FORMATS = {
64890
64952
  };
64891
64953
 
64892
64954
  // ../engine/ts/src/rewrite.ts
64893
- import * as path2 from "node:path";
64955
+ import * as path3 from "node:path";
64894
64956
 
64895
64957
  // ../parser/ts/src/serialize-yamlover.ts
64896
64958
  function pointerToken(raw) {
@@ -64941,7 +65003,7 @@ function planRewrites(doc, edges, oldStore, newStore, opts = {}) {
64941
65003
  miss("anchor has no source span");
64942
65004
  continue;
64943
65005
  }
64944
- if (opts.root !== void 0 && path2.relative(opts.root, span2.uri).startsWith("..")) {
65006
+ if (opts.root !== void 0 && path3.relative(opts.root, span2.uri).startsWith("..")) {
64945
65007
  miss("source file is outside the served root (grafted)");
64946
65008
  continue;
64947
65009
  }
@@ -64993,7 +65055,7 @@ function planRewrites(doc, edges, oldStore, newStore, opts = {}) {
64993
65055
  miss("pointer has no source span");
64994
65056
  continue;
64995
65057
  }
64996
- if (opts.root !== void 0 && path2.relative(opts.root, span.uri).startsWith("..")) {
65058
+ if (opts.root !== void 0 && path3.relative(opts.root, span.uri).startsWith("..")) {
64997
65059
  miss("source file is outside the served root (grafted)");
64998
65060
  continue;
64999
65061
  }
@@ -65127,12 +65189,12 @@ function json5pAnchorToken(body) {
65127
65189
  }
65128
65190
 
65129
65191
  // ../engine/ts/src/mv.ts
65130
- import * as fs2 from "node:fs";
65131
- import * as path3 from "node:path";
65192
+ import * as fs3 from "node:fs";
65193
+ import * as path4 from "node:path";
65132
65194
  function mv(absRoot, fromRel, toRel, opts = {}) {
65133
- const root = path3.resolve(absRoot);
65134
- const absFrom = path3.resolve(root, fromRel);
65135
- const absTo = path3.resolve(root, toRel);
65195
+ const root = path4.resolve(absRoot);
65196
+ const absFrom = path4.resolve(root, fromRel);
65197
+ const absTo = path4.resolve(root, toRel);
65136
65198
  const relFrom = relInside(root, absFrom, "source");
65137
65199
  const relTo = relInside(root, absTo, "target");
65138
65200
  for (const rel of [relFrom, relTo]) {
@@ -65140,9 +65202,9 @@ function mv(absRoot, fromRel, toRel, opts = {}) {
65140
65202
  if (seg.startsWith(".")) throw new Error(`mv: hidden/overlay segments are not movable ("${seg}" in "${rel}")`);
65141
65203
  }
65142
65204
  }
65143
- if (!fs2.existsSync(absFrom)) throw new Error(`mv: source does not exist: ${relFrom}`);
65144
- if (fs2.existsSync(absTo)) throw new Error(`mv: target already exists: ${relTo}`);
65145
- if (absTo === absFrom || absTo.startsWith(absFrom + path3.sep)) {
65205
+ if (!fs3.existsSync(absFrom)) throw new Error(`mv: source does not exist: ${relFrom}`);
65206
+ if (fs3.existsSync(absTo)) throw new Error(`mv: target already exists: ${relTo}`);
65207
+ if (absTo === absFrom || absTo.startsWith(absFrom + path4.sep)) {
65146
65208
  throw new Error(`mv: cannot move "${relFrom}" into itself`);
65147
65209
  }
65148
65210
  const { doc } = walkTree(root, opts);
@@ -65150,15 +65212,15 @@ function mv(absRoot, fromRel, toRel, opts = {}) {
65150
65212
  const plan = planRewrites(doc, edges, storeOf(relFrom), storeOf(relTo), { root });
65151
65213
  const editedFiles = [];
65152
65214
  for (const [uri, edits] of plan.edits) {
65153
- fs2.writeFileSync(uri, applyEdits(fs2.readFileSync(uri, "utf8"), edits));
65154
- editedFiles.push(path3.relative(root, uri).split(path3.sep).join("/"));
65215
+ fs3.writeFileSync(uri, applyEdits(fs3.readFileSync(uri, "utf8"), edits));
65216
+ editedFiles.push(path4.relative(root, uri).split(path4.sep).join("/"));
65155
65217
  }
65156
- fs2.mkdirSync(path3.dirname(absTo), { recursive: true });
65157
- fs2.renameSync(absFrom, absTo);
65218
+ fs3.mkdirSync(path4.dirname(absTo), { recursive: true });
65219
+ fs3.renameSync(absFrom, absTo);
65158
65220
  return { from: relFrom, to: relTo, rewritten: plan.rewritten, unrewritten: plan.unrewritten, editedFiles };
65159
65221
  }
65160
65222
  function relinkMoved(absRoot, moved, opts = {}) {
65161
- const root = path3.resolve(absRoot);
65223
+ const root = path4.resolve(absRoot);
65162
65224
  const { doc } = walkTree(root, opts);
65163
65225
  const edges = resolveDocument(doc);
65164
65226
  const rewritten = [];
@@ -65179,36 +65241,36 @@ function relinkMoved(absRoot, moved, opts = {}) {
65179
65241
  }
65180
65242
  const editedFiles = [];
65181
65243
  for (const [uri, edits] of merged) {
65182
- fs2.writeFileSync(uri, applyEdits(fs2.readFileSync(uri, "utf8"), edits));
65183
- editedFiles.push(path3.relative(root, uri).split(path3.sep).join("/"));
65244
+ fs3.writeFileSync(uri, applyEdits(fs3.readFileSync(uri, "utf8"), edits));
65245
+ editedFiles.push(path4.relative(root, uri).split(path4.sep).join("/"));
65184
65246
  }
65185
65247
  return { rewritten, unrewritten, editedFiles };
65186
65248
  }
65187
65249
  function relInside(root, abs, what) {
65188
- const rel = path3.relative(root, abs);
65189
- if (rel === "" || rel.startsWith("..") || path3.isAbsolute(rel)) {
65250
+ const rel = path4.relative(root, abs);
65251
+ if (rel === "" || rel.startsWith("..") || path4.isAbsolute(rel)) {
65190
65252
  throw new Error(`mv: ${what} escapes the served root`);
65191
65253
  }
65192
- return rel.split(path3.sep).join("/");
65254
+ return rel.split(path4.sep).join("/");
65193
65255
  }
65194
65256
  function storeOf(rel) {
65195
65257
  return ":" + rel.split("/").join(":");
65196
65258
  }
65197
65259
 
65198
65260
  // ../engine/ts/src/watch.ts
65199
- import fs3 from "node:fs";
65200
- import path4 from "node:path";
65261
+ import fs4 from "node:fs";
65262
+ import path5 from "node:path";
65201
65263
  var OVERLAY_FILES = /* @__PURE__ */ new Set(["body.yamlover", "meta.yamlover", "settings.yamlover"]);
65202
65264
  var YAMLOVER_SIDECAR_DIRS = /* @__PURE__ */ new Set(["thumbnails", "fragments"]);
65203
65265
  function watchTree(absRoot, onBatch, opts = {}) {
65204
- const root = path4.resolve(absRoot);
65266
+ const root = path5.resolve(absRoot);
65205
65267
  const debounceMs = opts.debounceMs ?? 300;
65206
65268
  const pending = /* @__PURE__ */ new Set();
65207
65269
  let timer = null;
65208
65270
  let running = false;
65209
65271
  let closed = false;
65210
65272
  const relevant = (rel) => {
65211
- const segs = rel.split(path4.sep);
65273
+ const segs = rel.split(path5.sep);
65212
65274
  for (let i2 = 0; i2 < segs.length; i2++) {
65213
65275
  if (!segs[i2].startsWith(".")) continue;
65214
65276
  const rest = segs.slice(i2 + 1);
@@ -65217,12 +65279,12 @@ function watchTree(absRoot, onBatch, opts = {}) {
65217
65279
  if (!isOverlay && !isSidecar) return false;
65218
65280
  break;
65219
65281
  }
65220
- return !opts.ignore?.(path4.join(root, rel));
65282
+ return !opts.ignore?.(path5.join(root, rel));
65221
65283
  };
65222
65284
  const fire = () => {
65223
65285
  timer = null;
65224
65286
  if (running || closed || pending.size === 0) return;
65225
- const batch = [...pending].map((p2) => p2.split(path4.sep).join("/"));
65287
+ const batch = [...pending].map((p2) => p2.split(path5.sep).join("/"));
65226
65288
  pending.clear();
65227
65289
  running = true;
65228
65290
  try {
@@ -65232,7 +65294,7 @@ function watchTree(absRoot, onBatch, opts = {}) {
65232
65294
  if (pending.size > 0) timer = setTimeout(fire, debounceMs);
65233
65295
  }
65234
65296
  };
65235
- const watcher = fs3.watch(root, { recursive: true }, (_event, filename) => {
65297
+ const watcher = fs4.watch(root, { recursive: true }, (_event, filename) => {
65236
65298
  if (closed || filename == null) return;
65237
65299
  const rel = String(filename);
65238
65300
  if (!relevant(rel)) return;
@@ -65248,28 +65310,83 @@ function watchTree(absRoot, onBatch, opts = {}) {
65248
65310
  }
65249
65311
 
65250
65312
  // ../engine/ts/src/settings.ts
65251
- import fs4 from "node:fs";
65252
- import path5 from "node:path";
65313
+ import fs5 from "node:fs";
65314
+ import path6 from "node:path";
65253
65315
  var DEFAULT_SETTINGS = {
65254
- annotations: { location: ":annotations" },
65255
- tags: { location: ":tags" },
65256
- sidecars: { location: "per-directory" }
65316
+ uri: void 0,
65317
+ exports: [],
65318
+ annotations: ":annotations",
65319
+ tags: ":tags",
65320
+ sidecars: "per-directory",
65321
+ annotationTag: void 0
65257
65322
  };
65323
+ var DEFAULT_SETTINGS_SOURCE = `# .yamlover/settings.yamlover \u2014 project settings for this root (created with defaults).
65324
+ # Settings are DEFAULTS, never constraints: they only say where the server CREATES things when you
65325
+ # do not; reading is location-independent (a node is recognized by its schema, wherever it sits).
65326
+ # Locations are PROJECT-SCOPE pointers: \`*::x\` = project root, \`*:x\` = document root, \`*x\` =
65327
+ # parent/current scope (SEPARATOR.md \xA72). A missing field falls back to these same values. Edit me
65328
+ # here or via the gear button's settings editor.
65329
+ !!<*yamlover:$defs:config>
65330
+
65331
+ annotations: *:: annotations # create new annotations in :annotations
65332
+ tags: *:: tags # create new tags in :tags
65333
+ sidecars: per-directory # where derived thumbnail/crop blobs go (enum, not a path)
65334
+ `;
65335
+ function ensureSettingsFile(absRoot) {
65336
+ const file = path6.join(absRoot, ".yamlover", "settings.yamlover");
65337
+ if (!fs5.existsSync(file)) {
65338
+ fs5.mkdirSync(path6.dirname(file), { recursive: true });
65339
+ fs5.writeFileSync(file, DEFAULT_SETTINGS_SOURCE);
65340
+ }
65341
+ return file;
65342
+ }
65258
65343
  function loadSettings(absRoot) {
65259
- const file = path5.join(absRoot, ".yamlover", "settings.yamlover");
65260
- if (!fs4.existsSync(file)) return DEFAULT_SETTINGS;
65344
+ const file = path6.join(absRoot, ".yamlover", "settings.yamlover");
65345
+ if (!fs5.existsSync(file)) return DEFAULT_SETTINGS;
65261
65346
  let root;
65262
65347
  try {
65263
- root = parseYamlover(fs4.readFileSync(file, "utf8"), file).root;
65348
+ root = parseYamlover(fs5.readFileSync(file, "utf8"), file).root;
65264
65349
  } catch {
65265
65350
  return DEFAULT_SETTINGS;
65266
65351
  }
65267
65352
  return {
65268
- annotations: { location: locationSetting(valueAt(root, "annotations", "location"), DEFAULT_SETTINGS.annotations.location) },
65269
- tags: { location: locationSetting(valueAt(root, "tags", "location"), DEFAULT_SETTINGS.tags.location) },
65270
- sidecars: { location: sidecarLocation(valueAt(root, "sidecars", "location"), DEFAULT_SETTINGS.sidecars.location) }
65353
+ uri: uriSetting(valueAt(root, "uri")),
65354
+ exports: exportsSetting(valueAt(root, "exports")),
65355
+ annotations: locationSetting(valueAt(root, "annotations"), DEFAULT_SETTINGS.annotations),
65356
+ tags: locationSetting(valueAt(root, "tags"), DEFAULT_SETTINGS.tags),
65357
+ sidecars: sidecarLocation(valueAt(root, "sidecars"), DEFAULT_SETTINGS.sidecars),
65358
+ annotationTag: locationSetting(valueAt(root, "annotation-tag"), void 0)
65271
65359
  };
65272
65360
  }
65361
+ function uriSetting(v) {
65362
+ if (v === void 0) return void 0;
65363
+ if (isPointer(v)) return v.base.scope === "link" ? v.base.authority : void 0;
65364
+ if (v.kind === "scalar" && typeof v.value === "string") {
65365
+ const a2 = v.value.replace(/^[:\s]+/, "").trim();
65366
+ return a2 === "" ? void 0 : a2;
65367
+ }
65368
+ return void 0;
65369
+ }
65370
+ function exportsSetting(v) {
65371
+ if (v === void 0 || isPointer(v) || !v.entries) return [];
65372
+ const out = [];
65373
+ for (const e3 of v.entries) {
65374
+ if (isPointer(e3.value)) out.push("*" + e3.value.raw);
65375
+ else if (e3.value.kind === "scalar" && typeof e3.value.value === "string" && e3.value.value.trim() !== "") out.push(e3.value.value.trim());
65376
+ }
65377
+ return out;
65378
+ }
65379
+ function writeSettingKey(absRoot, key, valueText) {
65380
+ const file = path6.join(absRoot, ".yamlover", "settings.yamlover");
65381
+ const src = fs5.existsSync(file) ? fs5.readFileSync(file, "utf8") : "";
65382
+ const line = `${key}: ${valueText}`;
65383
+ const re = new RegExp("^" + key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + ":.*$", "m");
65384
+ let out = re.test(src) ? src.replace(re, line) : (src === "" || src.endsWith("\n") ? src : src + "\n") + line;
65385
+ if (!out.endsWith("\n")) out += "\n";
65386
+ fs5.mkdirSync(path6.dirname(file), { recursive: true });
65387
+ fs5.writeFileSync(file, out);
65388
+ return file;
65389
+ }
65273
65390
  function sidecarLocation(v, dflt) {
65274
65391
  const s2 = v !== void 0 && !isPointer(v) && v.kind === "scalar" && typeof v.value === "string" ? v.value.trim() : "";
65275
65392
  if (s2 === "per-directory" || s2 === "document") return "per-directory";
@@ -65291,10 +65408,14 @@ function locationSetting(v, dflt) {
65291
65408
  return dflt;
65292
65409
  }
65293
65410
  function pointerPath(p2) {
65294
- if (p2.base.scope !== "current" && p2.base.scope !== "document") return null;
65295
- if (p2.steps.length === 0 || !p2.steps.every((s2) => s2.sel === "key")) return null;
65296
- const segs = p2.steps.map((s2) => s2.name);
65297
- if (segs.some((seg) => seg === ".." || seg === "")) return null;
65411
+ const segs = [];
65412
+ if (p2.base.scope === "link") segs.push(p2.base.authority);
65413
+ else if (p2.base.scope !== "current" && p2.base.scope !== "document") return null;
65414
+ for (const s2 of p2.steps) {
65415
+ if (s2.sel !== "key") return null;
65416
+ segs.push(s2.name);
65417
+ }
65418
+ if (segs.length === 0 || segs.some((seg) => seg === ".." || seg === "")) return null;
65298
65419
  return ":" + segs.join(":");
65299
65420
  }
65300
65421
  function stringPath(v, dflt) {
@@ -65308,9 +65429,11 @@ function stringPath(v, dflt) {
65308
65429
  function parseQuery(text) {
65309
65430
  let rest = text.trim();
65310
65431
  let base = { scope: "current" };
65432
+ let world = false;
65311
65433
  if (rest.startsWith(":::")) {
65312
65434
  rest = rest.slice(3);
65313
65435
  base = { scope: "link", authority: "" };
65436
+ world = true;
65314
65437
  } else if (rest.startsWith("::")) {
65315
65438
  rest = rest.slice(2);
65316
65439
  base = { scope: "link", authority: "" };
@@ -65322,7 +65445,7 @@ function parseQuery(text) {
65322
65445
  if (base.scope === "link") {
65323
65446
  const auth = raws.shift();
65324
65447
  if (auth === void 0 || auth === "") throw new SyntaxError(`query: "::" needs an authority in "${text}"`);
65325
- base = { scope: "link", authority: keyName(auth) };
65448
+ base = { scope: "link", authority: keyName(auth), world };
65326
65449
  } else if (base.scope === "current" && raws[0] === "..") {
65327
65450
  base = { scope: "parent" };
65328
65451
  raws.shift();
@@ -65476,6 +65599,7 @@ function keyName(portion) {
65476
65599
  if (steps.length !== 1 || steps[0].sel !== "key") throw new SyntaxError(`query: bad name portion "${portion}"`);
65477
65600
  return steps[0].name;
65478
65601
  }
65602
+ var YAMLOVER_AUTHORITY3 = "yamlover.inthemoon.net";
65479
65603
  function evalQuery(s2, text, from = ":") {
65480
65604
  const q = parseQuery(text);
65481
65605
  let binds;
@@ -65490,11 +65614,13 @@ function evalQuery(s2, text, from = ":") {
65490
65614
  binds = [docRootOf(s2, from)];
65491
65615
  break;
65492
65616
  case "link": {
65493
- if (q.base.authority === "yamlover" && childByKey(s2, ":", "yamlover") === null) {
65617
+ let authority = q.base.authority;
65618
+ if (q.base.world === true && authority === YAMLOVER_AUTHORITY3) authority = "yamlover";
65619
+ if (authority === "yamlover" && childByKey(s2, ":", "yamlover") === null) {
65494
65620
  binds = [":"];
65495
65621
  break;
65496
65622
  }
65497
- const hit = childByKey(s2, ":", q.base.authority);
65623
+ const hit = childByKey(s2, ":", authority);
65498
65624
  binds = hit === null ? [] : [hit];
65499
65625
  break;
65500
65626
  }
@@ -65874,17 +66000,17 @@ var psdExtractor = {
65874
66000
  };
65875
66001
 
65876
66002
  // src/server/extract/wasm.ts
65877
- import fs7 from "node:fs";
65878
- import path7 from "node:path";
65879
- import { fileURLToPath } from "node:url";
66003
+ import fs8 from "node:fs";
66004
+ import path8 from "node:path";
66005
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
65880
66006
  import { createRequire } from "node:module";
65881
66007
  var require2 = createRequire(import.meta.url);
65882
66008
  async function loadWasm(npmSpecifier, prodFile) {
65883
66009
  let bytes;
65884
66010
  try {
65885
- bytes = fs7.readFileSync(require2.resolve(npmSpecifier));
66011
+ bytes = fs8.readFileSync(require2.resolve(npmSpecifier));
65886
66012
  } catch {
65887
- bytes = fs7.readFileSync(path7.join(path7.dirname(fileURLToPath(import.meta.url)), "wasm", prodFile));
66013
+ bytes = fs8.readFileSync(path8.join(path8.dirname(fileURLToPath2(import.meta.url)), "wasm", prodFile));
65888
66014
  }
65889
66015
  return WebAssembly.compile(new Uint8Array(bytes));
65890
66016
  }
@@ -65952,8 +66078,8 @@ async function renderThumbnail(bytes, format, w, h) {
65952
66078
 
65953
66079
  // src/server/gitignore.ts
65954
66080
  var import_ignore = __toESM(require_ignore(), 1);
65955
- import fs8 from "node:fs";
65956
- import path8 from "node:path";
66081
+ import fs9 from "node:fs";
66082
+ import path9 from "node:path";
65957
66083
  function buildGitIgnore(dataRoot) {
65958
66084
  const gitRoot = findGitRoot(dataRoot) ?? dataRoot;
65959
66085
  const cache = /* @__PURE__ */ new Map();
@@ -65961,8 +66087,8 @@ function buildGitIgnore(dataRoot) {
65961
66087
  if (!cache.has(dir)) {
65962
66088
  let ig = null;
65963
66089
  try {
65964
- const gi = path8.join(dir, ".gitignore");
65965
- if (fs8.statSync(gi).isFile()) ig = (0, import_ignore.default)().add(fs8.readFileSync(gi, "utf-8"));
66090
+ const gi = path9.join(dir, ".gitignore");
66091
+ if (fs9.statSync(gi).isFile()) ig = (0, import_ignore.default)().add(fs9.readFileSync(gi, "utf-8"));
65966
66092
  } catch {
65967
66093
  }
65968
66094
  cache.set(dir, ig);
@@ -65970,25 +66096,25 @@ function buildGitIgnore(dataRoot) {
65970
66096
  return cache.get(dir);
65971
66097
  };
65972
66098
  return (absPath) => {
65973
- const fromRoot = path8.relative(gitRoot, absPath);
65974
- if (fromRoot === ".git" || fromRoot.startsWith(".git" + path8.sep)) return true;
66099
+ const fromRoot = path9.relative(gitRoot, absPath);
66100
+ if (fromRoot === ".git" || fromRoot.startsWith(".git" + path9.sep)) return true;
65975
66101
  let isDir = false;
65976
66102
  try {
65977
- isDir = fs8.statSync(absPath).isDirectory();
66103
+ isDir = fs9.statSync(absPath).isDirectory();
65978
66104
  } catch {
65979
66105
  }
65980
- const rel = path8.relative(gitRoot, path8.dirname(absPath));
65981
- const segs = rel === "" ? [] : rel.split(path8.sep);
66106
+ const rel = path9.relative(gitRoot, path9.dirname(absPath));
66107
+ const segs = rel === "" ? [] : rel.split(path9.sep);
65982
66108
  let dir = gitRoot;
65983
66109
  const dirs = [gitRoot];
65984
66110
  for (const s2 of segs) {
65985
- dir = path8.join(dir, s2);
66111
+ dir = path9.join(dir, s2);
65986
66112
  dirs.push(dir);
65987
66113
  }
65988
66114
  for (const d of dirs) {
65989
66115
  const ig = matcherFor(d);
65990
66116
  if (!ig) continue;
65991
- const relToDir = path8.relative(d, absPath);
66117
+ const relToDir = path9.relative(d, absPath);
65992
66118
  if (!relToDir) continue;
65993
66119
  if (ig.ignores(relToDir) || isDir && ig.ignores(relToDir + "/")) return true;
65994
66120
  }
@@ -65996,15 +66122,15 @@ function buildGitIgnore(dataRoot) {
65996
66122
  };
65997
66123
  }
65998
66124
  function findGitRoot(start) {
65999
- let dir = path8.resolve(start);
66125
+ let dir = path9.resolve(start);
66000
66126
  try {
66001
- if (!fs8.statSync(dir).isDirectory()) dir = path8.dirname(dir);
66127
+ if (!fs9.statSync(dir).isDirectory()) dir = path9.dirname(dir);
66002
66128
  } catch {
66003
66129
  return null;
66004
66130
  }
66005
66131
  for (; ; ) {
66006
- if (fs8.existsSync(path8.join(dir, ".git"))) return dir;
66007
- const parent = path8.dirname(dir);
66132
+ if (fs9.existsSync(path9.join(dir, ".git"))) return dir;
66133
+ const parent = path9.dirname(dir);
66008
66134
  if (parent === dir) return null;
66009
66135
  dir = parent;
66010
66136
  }
@@ -66101,11 +66227,20 @@ var LINK_KEY = "$yamloverLink";
66101
66227
  var BINARY_KEY = "$yamloverBinary";
66102
66228
  var MIXED_KEY = "$yamloverMixed";
66103
66229
  function createHandlers(dataRoot, opts = {}) {
66104
- const rootName = path9.basename(path9.resolve(dataRoot)) || "/";
66105
- const dbPath = path9.join(dataRoot, ".yamlover", "index.db");
66106
- const settings = loadSettings(dataRoot);
66230
+ const rootName = path10.basename(path10.resolve(dataRoot)) || "/";
66231
+ const dbPath = path10.join(dataRoot, ".yamlover", "index.db");
66232
+ const settingsFile = path10.join(dataRoot, ".yamlover", "settings.yamlover");
66233
+ if (opts.ensureSettings) {
66234
+ try {
66235
+ ensureSettingsFile(dataRoot);
66236
+ } catch (e3) {
66237
+ (opts.log ?? (() => {
66238
+ }))(`could not create settings.yamlover: ${e3.message}`);
66239
+ }
66240
+ }
66241
+ let settings = loadSettings(dataRoot);
66107
66242
  const ignore2 = opts.gitignore === false ? void 0 : buildGitIgnore(dataRoot);
66108
- fs9.mkdirSync(path9.dirname(dbPath), { recursive: true });
66243
+ fs10.mkdirSync(path10.dirname(dbPath), { recursive: true });
66109
66244
  const store0 = new Store(dbPath);
66110
66245
  const store = () => store0;
66111
66246
  let cachedDoc = null;
@@ -66182,7 +66317,7 @@ function createHandlers(dataRoot, opts = {}) {
66182
66317
  const next = pending[0];
66183
66318
  const total = done + pending.length;
66184
66319
  h.progress(done, total, next.path);
66185
- const abs = path9.join(dataRoot, ...next.path.split("/"));
66320
+ const abs = path10.join(dataRoot, ...next.path.split("/"));
66186
66321
  let hash = null;
66187
66322
  try {
66188
66323
  hash = await hashFileAsync(abs, (bytes) => {
@@ -66190,7 +66325,7 @@ function createHandlers(dataRoot, opts = {}) {
66190
66325
  });
66191
66326
  } catch {
66192
66327
  }
66193
- const st = hash !== null ? fs9.statSync(abs, { throwIfNoEntry: false }) : void 0;
66328
+ const st = hash !== null ? fs10.statSync(abs, { throwIfNoEntry: false }) : void 0;
66194
66329
  const fresh = st !== void 0 && st.size === next.size && st.mtimeMs === next.mtimeMs;
66195
66330
  const ok = hash !== null && fresh && !closed ? await enqueue(() => store0.setFileHash(next.path, hash, next.size, next.mtimeMs)) : false;
66196
66331
  if (!ok) {
@@ -66221,7 +66356,7 @@ function createHandlers(dataRoot, opts = {}) {
66221
66356
  };
66222
66357
  const doReindexFile = async (absFile) => {
66223
66358
  if (cachedDoc) {
66224
- const rel = path9.relative(dataRoot, absFile).split(path9.sep).join("/");
66359
+ const rel = path10.relative(dataRoot, absFile).split(path10.sep).join("/");
66225
66360
  try {
66226
66361
  const res = await reindexPathAsync(store0, dataRoot, cachedDoc, rel, { ignore: ignore2 });
66227
66362
  if (res) {
@@ -66350,7 +66485,7 @@ function createHandlers(dataRoot, opts = {}) {
66350
66485
  (data) => enqueue(async () => {
66351
66486
  const f2 = data;
66352
66487
  if (!f2?.selector || typeof f2.selector !== "object") throw new Error("a fragment needs a selector");
66353
- const made = embedFragment(dataRoot, s2, settings.sidecars.location, f2);
66488
+ const made = embedFragment(dataRoot, s2, settings.sidecars, f2);
66354
66489
  broadcast(await doReindex());
66355
66490
  scheduleHasher();
66356
66491
  return made;
@@ -66373,7 +66508,7 @@ function createHandlers(dataRoot, opts = {}) {
66373
66508
  (data) => enqueue(async () => {
66374
66509
  const name = String(data?.name ?? "").trim();
66375
66510
  if (!name) throw new Error("tag needs a non-empty name");
66376
- const segs2 = [...strToSegs(settings.tags.location), name];
66511
+ const segs2 = [...strToSegs(settings.tags), name];
66377
66512
  const tagPath = segsToStr(segs2);
66378
66513
  const existing = s2.node(storePath(segs2));
66379
66514
  if (existing) {
@@ -66381,8 +66516,8 @@ function createHandlers(dataRoot, opts = {}) {
66381
66516
  const color = s2.node(storePath(segs2) + ":color")?.value;
66382
66517
  return { path: tagPath, name, color: typeof color === "string" ? color : null, created: false };
66383
66518
  }
66384
- const written = writeTag(dataRoot, settings.tags.location, name);
66385
- s2.addTag(storePath(strToSegs(settings.tags.location)), name, written.pos, written.node);
66519
+ const written = writeTag(dataRoot, settings.tags, name);
66520
+ s2.addTag(storePath(strToSegs(settings.tags)), name, written.pos, written.node);
66386
66521
  if (s2.node(storePath(segs2))?.format !== TAG_FORMAT) throw new Error(`the created tag did not index as a tag: ${tagPath}`);
66387
66522
  announce(written.createdFile ? { added: [written.file] } : { changed: [written.file] });
66388
66523
  return { path: tagPath, name, color: null, created: true };
@@ -66396,9 +66531,9 @@ function createHandlers(dataRoot, opts = {}) {
66396
66531
  const b = data;
66397
66532
  const cols = Array.isArray(b?.columns) ? b.columns.map((lane) => Array.isArray(lane) ? lane.map((p3) => String(p3)) : []) : [];
66398
66533
  const { bodyFile } = hostFor(dataRoot, s2, strToSegs(b?.path || ":"));
66399
- fs9.mkdirSync(path9.dirname(bodyFile), { recursive: true });
66400
- const src = fs9.existsSync(bodyFile) ? fs9.readFileSync(bodyFile, "utf8") : "";
66401
- fs9.writeFileSync(bodyFile, writeBoardColumns(src, cols));
66534
+ fs10.mkdirSync(path10.dirname(bodyFile), { recursive: true });
66535
+ const src = fs10.existsSync(bodyFile) ? fs10.readFileSync(bodyFile, "utf8") : "";
66536
+ fs10.writeFileSync(bodyFile, writeBoardColumns(src, cols));
66402
66537
  broadcast(await doReindex());
66403
66538
  scheduleHasher();
66404
66539
  return { ok: true };
@@ -66442,7 +66577,7 @@ function createHandlers(dataRoot, opts = {}) {
66442
66577
  const files = [];
66443
66578
  let wrote = false;
66444
66579
  for (const doc of loadAgentDocs()) {
66445
- const exists = fs9.existsSync(path9.resolve(dataRoot, doc.name));
66580
+ const exists = fs10.existsSync(path10.resolve(dataRoot, doc.name));
66446
66581
  if (exists && !overwrite) {
66447
66582
  files.push({ name: doc.name, status: "exists" });
66448
66583
  continue;
@@ -66460,6 +66595,40 @@ function createHandlers(dataRoot, opts = {}) {
66460
66595
  ).then((body) => sendJson(res, 201, body)).catch((e3) => sendJson(res, 400, { error: String(e3.message || e3) }));
66461
66596
  return;
66462
66597
  }
66598
+ if (req.method !== "POST" && url.pathname === "/api/config") {
66599
+ const source = fs10.existsSync(settingsFile) ? fs10.readFileSync(settingsFile, "utf8") : "";
66600
+ sendJson(res, 200, { source, settings, path: ":.yamlover:settings.yamlover" });
66601
+ return;
66602
+ }
66603
+ if (req.method === "POST" && url.pathname === "/api/config") {
66604
+ readBody(req).then(
66605
+ (data) => enqueue(async () => {
66606
+ const source = String(data?.source ?? "");
66607
+ parseYamlover(source, settingsFile);
66608
+ fs10.mkdirSync(path10.dirname(settingsFile), { recursive: true });
66609
+ fs10.writeFileSync(settingsFile, source);
66610
+ settings = loadSettings(dataRoot);
66611
+ broadcast(await doReindexFile(settingsFile));
66612
+ return { ok: true, settings };
66613
+ })
66614
+ ).then((body) => sendJson(res, 200, body)).catch((e3) => sendJson(res, 400, { error: String(e3.message || e3) }));
66615
+ return;
66616
+ }
66617
+ if (req.method === "POST" && url.pathname === "/api/last-tag") {
66618
+ readBody(req).then(
66619
+ (data) => enqueue(async () => {
66620
+ const tag = String(data?.tag ?? "").trim();
66621
+ if (!tag) throw new Error("last-tag needs a `tag` path");
66622
+ const segs2 = strToSegs(tag);
66623
+ if (segs2.length === 0 || segs2.some((g) => typeof g === "number")) throw new Error(`not a tag node path: ${tag}`);
66624
+ writeSettingKey(dataRoot, "annotation-tag", "*:: " + segs2.map((s3) => colonSegment(String(s3))).join(": "));
66625
+ settings = loadSettings(dataRoot);
66626
+ announce({ changed: [relFileOf(":.yamlover:settings.yamlover")] });
66627
+ return { ok: true, annotationTag: settings.annotationTag };
66628
+ })
66629
+ ).then((body) => sendJson(res, 200, body)).catch((e3) => sendJson(res, 400, { error: String(e3.message || e3) }));
66630
+ return;
66631
+ }
66463
66632
  const segs = strToSegs(url.searchParams.get("path") || ":");
66464
66633
  const p2 = storePath(segs);
66465
66634
  const depth = parseDepth(url.searchParams.get("depth"));
@@ -66485,37 +66654,37 @@ function createHandlers(dataRoot, opts = {}) {
66485
66654
  return;
66486
66655
  }
66487
66656
  if (url.pathname === "/api/blob") {
66488
- const file = path9.join(dataRoot, ...segs.map(String));
66489
- if (!fs9.existsSync(file) || fs9.statSync(file).isDirectory()) return notFound(res, url);
66657
+ const file = path10.join(dataRoot, ...segs.map(String));
66658
+ if (!fs10.existsSync(file) || fs10.statSync(file).isDirectory()) return notFound(res, url);
66490
66659
  res.statusCode = 200;
66491
66660
  res.setHeader("Content-Type", s2.node(p2)?.format ?? formatFromExt(file) ?? "application/octet-stream");
66492
- res.setHeader("Content-Length", String(fs9.statSync(file).size));
66493
- const stream = fs9.createReadStream(file);
66661
+ res.setHeader("Content-Length", String(fs10.statSync(file).size));
66662
+ const stream = fs10.createReadStream(file);
66494
66663
  stream.on("error", () => res.destroy());
66495
66664
  stream.pipe(res);
66496
66665
  return;
66497
66666
  }
66498
66667
  if (url.pathname === "/api/thumb") {
66499
66668
  const sourceRow = s2.node(p2);
66500
- const sourceAbs = path9.join(dataRoot, ...segs.map(String));
66501
- if (!sourceRow || !fs9.existsSync(sourceAbs) || fs9.statSync(sourceAbs).isDirectory()) return notFound(res, url);
66669
+ const sourceAbs = path10.join(dataRoot, ...segs.map(String));
66670
+ if (!sourceRow || !fs10.existsSync(sourceAbs) || fs10.statSync(sourceAbs).isDirectory()) return notFound(res, url);
66502
66671
  const w = clampThumbDim(url.searchParams.get("w"), 256);
66503
66672
  const h = clampThumbDim(url.searchParams.get("h"), w);
66504
66673
  const serve = (file) => {
66505
66674
  res.statusCode = 200;
66506
66675
  res.setHeader("Content-Type", "image/jpeg");
66507
- res.setHeader("Content-Length", String(fs9.statSync(file).size));
66676
+ res.setHeader("Content-Length", String(fs10.statSync(file).size));
66508
66677
  res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
66509
- const stream = fs9.createReadStream(file);
66678
+ const stream = fs10.createReadStream(file);
66510
66679
  stream.on("error", () => res.destroy());
66511
66680
  stream.pipe(res);
66512
66681
  };
66513
- const ready2 = existingThumb(dataRoot, s2, settings.sidecars.location, segs, sourceRow, w, h);
66682
+ const ready2 = existingThumb(dataRoot, s2, settings.sidecars, segs, sourceRow, w, h);
66514
66683
  if (ready2) return serve(ready2);
66515
66684
  thumbBegin();
66516
66685
  enqueue(async () => {
66517
66686
  thumbTask?.progress(thumbDone, thumbTotal, String(segs[segs.length - 1] ?? ""));
66518
- const made = await ensureThumbnail(dataRoot, s2, settings.sidecars.location, segs, sourceRow, w, h);
66687
+ const made = await ensureThumbnail(dataRoot, s2, settings.sidecars, segs, sourceRow, w, h);
66519
66688
  if (made) broadcast(await doReindex());
66520
66689
  return made;
66521
66690
  }).then((made) => made ? serve(made) : sendJson(res, 415, { error: `no thumbnail for format: ${sourceRow.format ?? "unknown"}` })).catch((e3) => sendJson(res, 500, { error: String(e3.message || e3) })).finally(() => thumbEnd());
@@ -66569,26 +66738,26 @@ var JSON_EXT = { ".json": "json", ".json5": "json5", ".json5p": "json5p" };
66569
66738
  function concreteOf(dataRoot, segs, row) {
66570
66739
  const last = segs[segs.length - 1];
66571
66740
  if (typeof last === "string") {
66572
- const json = JSON_EXT[path9.extname(last).toLowerCase()];
66741
+ const json = JSON_EXT[path10.extname(last).toLowerCase()];
66573
66742
  if (json) {
66574
- const abs2 = path9.resolve(dataRoot, ...segs.map(String));
66743
+ const abs2 = path10.resolve(dataRoot, ...segs.map(String));
66575
66744
  try {
66576
- if (fs9.statSync(abs2).isFile()) return json;
66745
+ if (fs10.statSync(abs2).isFile()) return json;
66577
66746
  } catch {
66578
66747
  }
66579
66748
  }
66580
66749
  }
66581
66750
  if (row.type !== "mapping") return null;
66582
66751
  if (segs.some((g) => typeof g === "number")) return null;
66583
- const abs = path9.resolve(dataRoot, ...segs.map(String));
66752
+ const abs = path10.resolve(dataRoot, ...segs.map(String));
66584
66753
  let st;
66585
66754
  try {
66586
- st = fs9.statSync(abs);
66755
+ st = fs10.statSync(abs);
66587
66756
  } catch {
66588
66757
  return null;
66589
66758
  }
66590
66759
  if (!st.isDirectory()) return null;
66591
- return fs9.existsSync(path9.join(abs, ".yamlover")) ? "yamlover" : "dir";
66760
+ return fs10.existsSync(path10.join(abs, ".yamlover")) ? "yamlover" : "dir";
66592
66761
  }
66593
66762
  var relKey = (label, other) => `${label ?? ""}\0${other}`;
66594
66763
  var isHidden = (s2, to2) => !!s2.node(to2)?.meta?.hidden;
@@ -66719,8 +66888,8 @@ function buildRelations(dataRoot, s2, segs) {
66719
66888
  return out;
66720
66889
  }
66721
66890
  function binaryContent(dataRoot, segs, row) {
66722
- const file = path9.join(dataRoot, ...segs.map(String));
66723
- const bytes = fs9.existsSync(file) ? fs9.readFileSync(file) : Buffer.alloc(0);
66891
+ const file = path10.join(dataRoot, ...segs.map(String));
66892
+ const bytes = fs10.existsSync(file) ? fs10.readFileSync(file) : Buffer.alloc(0);
66724
66893
  return { [BINARY_KEY]: { format: row.format ?? null, size: row.size ?? bytes.length, base64: bytes.toString("base64") } };
66725
66894
  }
66726
66895
  function buildTree(dataRoot, s2, segs, label, depth) {
@@ -66849,12 +67018,12 @@ function writeBoardColumns(src, cols) {
66849
67018
  return lines.join("\n") + "\n";
66850
67019
  }
66851
67020
  function sidecarTarget(dataRoot, mode, subdir, bodyFile) {
66852
- const dirOverlay = bodyFile.endsWith(path9.join(".yamlover", "body.yamlover"));
67021
+ const dirOverlay = bodyFile.endsWith(path10.join(".yamlover", "body.yamlover"));
66853
67022
  if (mode === "per-directory" && dirOverlay) {
66854
- const fileDir = path9.dirname(path9.dirname(bodyFile));
66855
- return { dir: path9.join(fileDir, ".yamlover", subdir), scope: "document" };
67023
+ const fileDir = path10.dirname(path10.dirname(bodyFile));
67024
+ return { dir: path10.join(fileDir, ".yamlover", subdir), scope: "document" };
66856
67025
  }
66857
- return { dir: path9.join(dataRoot, ".yamlover", subdir), scope: "project" };
67026
+ return { dir: path10.join(dataRoot, ".yamlover", subdir), scope: "project" };
66858
67027
  }
66859
67028
  function sidecarPointerRaw(subdir, name, scope) {
66860
67029
  const body = [".yamlover", subdir, name].map(colonSegment).join(":");
@@ -66866,24 +67035,24 @@ function yScalar(v) {
66866
67035
  function hostFor(dataRoot, s2, segs) {
66867
67036
  for (let i2 = segs.length; i2 >= 0; i2--) {
66868
67037
  const sub = segs.slice(0, i2);
66869
- const abs = path9.resolve(dataRoot, ...sub.map(String));
67038
+ const abs = path10.resolve(dataRoot, ...sub.map(String));
66870
67039
  let st;
66871
67040
  try {
66872
- st = fs9.statSync(abs);
67041
+ st = fs10.statSync(abs);
66873
67042
  } catch {
66874
67043
  continue;
66875
67044
  }
66876
- if (st.isDirectory()) return { bodyFile: path9.join(abs, ".yamlover", "body.yamlover"), within: segs.slice(i2).map(String) };
67045
+ if (st.isDirectory()) return { bodyFile: path10.join(abs, ".yamlover", "body.yamlover"), within: segs.slice(i2).map(String) };
66877
67046
  if (st.isFile()) {
66878
67047
  const node = s2.node(storePath(sub));
66879
67048
  if (node?.meta?.documentRoot && node.type === "mapping" && !node.is_array) {
66880
67049
  return { bodyFile: abs, within: segs.slice(i2).map(String) };
66881
67050
  }
66882
- const dir = path9.resolve(dataRoot, ...sub.slice(0, -1).map(String));
66883
- return { bodyFile: path9.join(dir, ".yamlover", "body.yamlover"), within: segs.slice(i2 - 1).map(String) };
67051
+ const dir = path10.resolve(dataRoot, ...sub.slice(0, -1).map(String));
67052
+ return { bodyFile: path10.join(dir, ".yamlover", "body.yamlover"), within: segs.slice(i2 - 1).map(String) };
66884
67053
  }
66885
67054
  }
66886
- return { bodyFile: path9.join(dataRoot, ".yamlover", "body.yamlover"), within: segs.map(String) };
67055
+ return { bodyFile: path10.join(dataRoot, ".yamlover", "body.yamlover"), within: segs.map(String) };
66887
67056
  }
66888
67057
  function annotationItemLines(a2, indent) {
66889
67058
  const pad = " ".repeat(indent);
@@ -66904,9 +67073,9 @@ function fragmentBlockLines(slug, selector, imagePtr, indent) {
66904
67073
  }
66905
67074
  function embedAnnotation(dataRoot, s2, a2) {
66906
67075
  const { bodyFile, within } = hostFor(dataRoot, s2, strToSegs(a2.target || ":"));
66907
- fs9.mkdirSync(path9.dirname(bodyFile), { recursive: true });
66908
- const src = fs9.existsSync(bodyFile) ? fs9.readFileSync(bodyFile, "utf8") : "";
66909
- fs9.writeFileSync(bodyFile, appendAnnotation(src, within, (indent) => annotationItemLines(a2, indent)));
67076
+ fs10.mkdirSync(path10.dirname(bodyFile), { recursive: true });
67077
+ const src = fs10.existsSync(bodyFile) ? fs10.readFileSync(bodyFile, "utf8") : "";
67078
+ fs10.writeFileSync(bodyFile, appendAnnotation(src, within, (indent) => annotationItemLines(a2, indent)));
66910
67079
  return bodyFile;
66911
67080
  }
66912
67081
  function embedFragment(dataRoot, s2, mode, f2) {
@@ -66918,15 +67087,15 @@ function embedFragment(dataRoot, s2, mode, f2) {
66918
67087
  const bytes = Buffer.from(String(f2.imageBase64).replace(/^data:[^,]*,/, ""), "base64");
66919
67088
  if (bytes.length > 0) {
66920
67089
  const { dir, scope } = sidecarTarget(dataRoot, mode, CROP_SUBDIR, bodyFile);
66921
- fs9.mkdirSync(dir, { recursive: true });
67090
+ fs10.mkdirSync(dir, { recursive: true });
66922
67091
  const cropName = `${slug}.png`;
66923
67092
  writeInside(dataRoot, dir, cropName, bytes);
66924
67093
  imagePtr = pointerToken(sidecarPointerRaw(CROP_SUBDIR, cropName, scope));
66925
67094
  }
66926
67095
  }
66927
- fs9.mkdirSync(path9.dirname(bodyFile), { recursive: true });
66928
- const src = fs9.existsSync(bodyFile) ? fs9.readFileSync(bodyFile, "utf8") : "";
66929
- fs9.writeFileSync(bodyFile, upsertFragment(src, within, slug, (indent) => fragmentBlockLines(slug, f2.selector, imagePtr, indent)));
67096
+ fs10.mkdirSync(path10.dirname(bodyFile), { recursive: true });
67097
+ const src = fs10.existsSync(bodyFile) ? fs10.readFileSync(bodyFile, "utf8") : "";
67098
+ fs10.writeFileSync(bodyFile, upsertFragment(src, within, slug, (indent) => fragmentBlockLines(slug, f2.selector, imagePtr, indent)));
66930
67099
  return { slug, fragmentPath: segsToStr([...segs, FRAG_KEY, slug]) };
66931
67100
  }
66932
67101
  var thumbResKey = (w, h) => `[${w}, ${h}]`;
@@ -66935,50 +67104,50 @@ function existingThumb(dataRoot, s2, mode, segs, row, w, h) {
66935
67104
  if (!row.content_hash) return null;
66936
67105
  const { bodyFile } = hostFor(dataRoot, s2, segs);
66937
67106
  const { dir } = sidecarTarget(dataRoot, mode, THUMB_SUBDIR, bodyFile);
66938
- const abs = path9.join(dir, thumbName(row.content_hash, w, h));
66939
- return fs9.existsSync(abs) ? abs : null;
67107
+ const abs = path10.join(dir, thumbName(row.content_hash, w, h));
67108
+ return fs10.existsSync(abs) ? abs : null;
66940
67109
  }
66941
67110
  function embedThumbnail(dataRoot, s2, mode, segs, w, h, name) {
66942
67111
  const { bodyFile, within } = hostFor(dataRoot, s2, segs);
66943
67112
  const { scope } = sidecarTarget(dataRoot, mode, THUMB_SUBDIR, bodyFile);
66944
- fs9.mkdirSync(path9.dirname(bodyFile), { recursive: true });
66945
- const src = fs9.existsSync(bodyFile) ? fs9.readFileSync(bodyFile, "utf8") : "";
67113
+ fs10.mkdirSync(path10.dirname(bodyFile), { recursive: true });
67114
+ const src = fs10.existsSync(bodyFile) ? fs10.readFileSync(bodyFile, "utf8") : "";
66946
67115
  const ptr = pointerToken(sidecarPointerRaw(THUMB_SUBDIR, name, scope));
66947
67116
  const key = thumbResKey(w, h);
66948
- fs9.writeFileSync(bodyFile, upsertThumbnail(src, within, key, (indent) => [`${" ".repeat(indent)}${key}: ${ptr}`]));
67117
+ fs10.writeFileSync(bodyFile, upsertThumbnail(src, within, key, (indent) => [`${" ".repeat(indent)}${key}: ${ptr}`]));
66949
67118
  }
66950
67119
  async function ensureThumbnail(dataRoot, s2, mode, segs, row, w, h) {
66951
- const sourceAbs = path9.join(dataRoot, ...segs.map(String));
67120
+ const sourceAbs = path10.join(dataRoot, ...segs.map(String));
66952
67121
  const hash = row.content_hash ?? await hashFileAsync(sourceAbs);
66953
67122
  const name = thumbName(hash, w, h);
66954
67123
  const { bodyFile } = hostFor(dataRoot, s2, segs);
66955
67124
  const { dir } = sidecarTarget(dataRoot, mode, THUMB_SUBDIR, bodyFile);
66956
- const abs = path9.join(dir, name);
66957
- if (fs9.existsSync(abs)) return abs;
66958
- const thumb = await renderThumbnail(fs9.readFileSync(sourceAbs), row.format ?? formatFromExt(sourceAbs), w, h);
67125
+ const abs = path10.join(dir, name);
67126
+ if (fs10.existsSync(abs)) return abs;
67127
+ const thumb = await renderThumbnail(fs10.readFileSync(sourceAbs), row.format ?? formatFromExt(sourceAbs), w, h);
66959
67128
  if (!thumb) return null;
66960
- fs9.mkdirSync(dir, { recursive: true });
67129
+ fs10.mkdirSync(dir, { recursive: true });
66961
67130
  writeInside(dataRoot, dir, name, thumb.buf);
66962
67131
  embedThumbnail(dataRoot, s2, mode, segs, w, h, name);
66963
67132
  return abs;
66964
67133
  }
66965
67134
  function unembedAnnotation(dataRoot, s2, target, tag) {
66966
67135
  const { bodyFile, within } = hostFor(dataRoot, s2, strToSegs(target || ":"));
66967
- if (!fs9.existsSync(bodyFile)) return bodyFile;
67136
+ if (!fs10.existsSync(bodyFile)) return bodyFile;
66968
67137
  const needlePath = ":" + pointerRaw(tag).replace(/^:+/, "");
66969
- const src = fs9.readFileSync(bodyFile, "utf8");
66970
- fs9.writeFileSync(bodyFile, removeAnnotation(src, within, (itemText) => itemText.replace(/\s+/g, "").includes(needlePath)));
67138
+ const src = fs10.readFileSync(bodyFile, "utf8");
67139
+ fs10.writeFileSync(bodyFile, removeAnnotation(src, within, (itemText) => itemText.replace(/\s+/g, "").includes(needlePath)));
66971
67140
  return bodyFile;
66972
67141
  }
66973
67142
  function writeTag(dataRoot, location, name) {
66974
67143
  if (/[/\\\r\n:]/.test(name)) throw new Error("a tag name cannot contain '/', '\\', ':' or line breaks");
66975
- const root = path9.resolve(dataRoot);
66976
- const dir = path9.resolve(dataRoot, ...strToSegs(location).map(String), ".yamlover");
66977
- if (!dir.startsWith(root + path9.sep)) throw new Error("tags location escapes the data root");
66978
- const file = path9.join(dir, "body.yamlover");
66979
- const createdFile = !fs9.existsSync(file);
67144
+ const root = path10.resolve(dataRoot);
67145
+ const dir = path10.resolve(dataRoot, ...strToSegs(location).map(String), ".yamlover");
67146
+ if (!dir.startsWith(root + path10.sep)) throw new Error("tags location escapes the data root");
67147
+ const file = path10.join(dir, "body.yamlover");
67148
+ const createdFile = !fs10.existsSync(file);
66980
67149
  const head = "# Named tags created from the annotation picker (settings.yamlover: tags.location).\n";
66981
- const existing = createdFile ? head : fs9.readFileSync(file, "utf8");
67150
+ const existing = createdFile ? head : fs10.readFileSync(file, "utf8");
66982
67151
  const body = (existing === "" || existing.endsWith("\n") ? existing : existing + "\n") + `${name}: !!<*::yamlover:$defs:tag>
66983
67152
  `;
66984
67153
  const entries = parseYamlover(body, file).root.entries ?? [];
@@ -66987,8 +67156,8 @@ function writeTag(dataRoot, location, name) {
66987
67156
  if (!entry || isPointer(entry.value) || entry.value.meta?.schema === void 0) {
66988
67157
  throw new Error(`cannot write a tag named ${JSON.stringify(name)}`);
66989
67158
  }
66990
- fs9.mkdirSync(dir, { recursive: true });
66991
- fs9.writeFileSync(file, body);
67159
+ fs10.mkdirSync(dir, { recursive: true });
67160
+ fs10.writeFileSync(file, body);
66992
67161
  return { node: entry.value, pos, file: [...strToSegs(location).map(String), ".yamlover", "body.yamlover"].join("/"), createdFile };
66993
67162
  }
66994
67163
  function handlePaste(dataRoot, s2, input) {
@@ -67012,7 +67181,7 @@ function handlePaste(dataRoot, s2, input) {
67012
67181
  if (row.format === "x-yamlover-chapter") return pasteIntoChapter(dataRoot, s2, segs, name, bytes);
67013
67182
  const dirSegs = nearestDirSegs(dataRoot, segs);
67014
67183
  if (!dirSegs) throw new Error("no enclosing directory to paste into");
67015
- const dir = path9.resolve(dataRoot, ...dirSegs.map(String));
67184
+ const dir = path10.resolve(dataRoot, ...dirSegs.map(String));
67016
67185
  const final = uniqueName(dir, name);
67017
67186
  writeInside(dataRoot, dir, final, bytes);
67018
67187
  return { path: segsToStr([...dirSegs, final]), dir: segsToStr(dirSegs), open: dirSegs.length !== segs.length };
@@ -67020,17 +67189,17 @@ function handlePaste(dataRoot, s2, input) {
67020
67189
  function nearestDirSegs(dataRoot, segs) {
67021
67190
  for (let i2 = segs.length; i2 >= 0; i2--) {
67022
67191
  const sub = segs.slice(0, i2);
67023
- const abs = path9.resolve(dataRoot, ...sub.map(String));
67024
- if (fs9.existsSync(abs) && fs9.statSync(abs).isDirectory()) return sub;
67192
+ const abs = path10.resolve(dataRoot, ...sub.map(String));
67193
+ if (fs10.existsSync(abs) && fs10.statSync(abs).isDirectory()) return sub;
67025
67194
  }
67026
67195
  return null;
67027
67196
  }
67028
67197
  function chapterSource(dataRoot, s2, segs) {
67029
67198
  const docSegs = documentRootSegs(s2, segs);
67030
- const docFs = path9.resolve(dataRoot, ...docSegs.map(String));
67031
- const dirBacked = fs9.existsSync(docFs) && fs9.statSync(docFs).isDirectory();
67032
- const bodyFile = dirBacked ? path9.join(docFs, ".yamlover", "body.yamlover") : docFs;
67033
- if (!bodyFile.endsWith(".yamlover") || !fs9.existsSync(bodyFile)) {
67199
+ const docFs = path10.resolve(dataRoot, ...docSegs.map(String));
67200
+ const dirBacked = fs10.existsSync(docFs) && fs10.statSync(docFs).isDirectory();
67201
+ const bodyFile = dirBacked ? path10.join(docFs, ".yamlover", "body.yamlover") : docFs;
67202
+ if (!bodyFile.endsWith(".yamlover") || !fs10.existsSync(bodyFile)) {
67034
67203
  throw new Error("unsupported chapter source (need a .yamlover body)");
67035
67204
  }
67036
67205
  return { docSegs, bodyFile, dirBacked };
@@ -67038,27 +67207,27 @@ function chapterSource(dataRoot, s2, segs) {
67038
67207
  function pasteIntoChapter(dataRoot, s2, segs, name, bytes) {
67039
67208
  const { docSegs, bodyFile, dirBacked } = chapterSource(dataRoot, s2, segs);
67040
67209
  const writeDirSegs = dirBacked ? docSegs : docSegs.slice(0, -1);
67041
- const writeDir = path9.resolve(dataRoot, ...writeDirSegs.map(String));
67210
+ const writeDir = path10.resolve(dataRoot, ...writeDirSegs.map(String));
67042
67211
  const final = uniqueName(writeDir, name);
67043
67212
  writeInside(dataRoot, writeDir, final, bytes);
67044
67213
  const fileSegs = [...writeDirSegs, final];
67045
67214
  const pointer = dirBacked ? `*/${final}` : `*/${segsToStr(fileSegs)}`;
67046
67215
  const within = segs.slice(docSegs.length);
67047
- const src = fs9.readFileSync(bodyFile, "utf8");
67048
- fs9.writeFileSync(bodyFile, appendToList(src, within, "chunks", (indent) => [`${" ".repeat(indent)}- ${pointer}`]));
67216
+ const src = fs10.readFileSync(bodyFile, "utf8");
67217
+ fs10.writeFileSync(bodyFile, appendToList(src, within, "chunks", (indent) => [`${" ".repeat(indent)}- ${pointer}`]));
67049
67218
  return { path: segsToStr(fileSegs), chapter: segsToStr(segs), pointer };
67050
67219
  }
67051
67220
  function pasteTextIntoChapter(dataRoot, s2, segs, text) {
67052
67221
  const { docSegs, bodyFile } = chapterSource(dataRoot, s2, segs);
67053
67222
  const within = segs.slice(docSegs.length);
67054
- const src = fs9.readFileSync(bodyFile, "utf8");
67055
- fs9.writeFileSync(bodyFile, appendToList(src, within, "chunks", (indent) => textChunkLines(text, indent)));
67223
+ const src = fs10.readFileSync(bodyFile, "utf8");
67224
+ fs10.writeFileSync(bodyFile, appendToList(src, within, "chunks", (indent) => textChunkLines(text, indent)));
67056
67225
  return { path: segsToStr(segs), chapter: segsToStr(segs) };
67057
67226
  }
67058
67227
  function pasteTextAsChapterFile(dataRoot, segs, text) {
67059
67228
  const dirSegs = nearestDirSegs(dataRoot, segs);
67060
67229
  if (!dirSegs) throw new Error("no enclosing directory to paste into");
67061
- const dir = path9.resolve(dataRoot, ...dirSegs.map(String));
67230
+ const dir = path10.resolve(dataRoot, ...dirSegs.map(String));
67062
67231
  const title = titleFromText(text);
67063
67232
  const final = uniqueName(dir, chapterFileName(title));
67064
67233
  const src = ["!!<*::yamlover:$defs:chapter>", `title: ${JSON.stringify(title)}`, "chunks:", ...textChunkLines(text, 0), ""].join("\n");
@@ -67105,7 +67274,7 @@ function richChildLines(node, indent, pointerFor) {
67105
67274
  function pasteRichIntoChapter(dataRoot, s2, segs, rich) {
67106
67275
  const { docSegs, bodyFile, dirBacked } = chapterSource(dataRoot, s2, segs);
67107
67276
  const writeDirSegs = dirBacked ? docSegs : docSegs.slice(0, -1);
67108
- const writeDir = path9.resolve(dataRoot, ...writeDirSegs.map(String));
67277
+ const writeDir = path10.resolve(dataRoot, ...writeDirSegs.map(String));
67109
67278
  const files = [];
67110
67279
  const pointerFor = (name, bytes) => {
67111
67280
  const final = uniqueName(writeDir, name);
@@ -67114,16 +67283,16 @@ function pasteRichIntoChapter(dataRoot, s2, segs, rich) {
67114
67283
  return dirBacked ? `*/${final}` : `*/${segsToStr([...writeDirSegs, final])}`;
67115
67284
  };
67116
67285
  const within = segs.slice(docSegs.length);
67117
- let src = fs9.readFileSync(bodyFile, "utf8");
67286
+ let src = fs10.readFileSync(bodyFile, "utf8");
67118
67287
  if (rich.chunks.length) src = appendToList(src, within, "chunks", (ind) => rich.chunks.flatMap((c3) => richItemLines(c3, ind, pointerFor)));
67119
67288
  if (rich.children.length) src = appendToList(src, within, "children", (ind) => rich.children.flatMap((k) => richChildLines(k, ind, pointerFor)));
67120
- fs9.writeFileSync(bodyFile, src);
67289
+ fs10.writeFileSync(bodyFile, src);
67121
67290
  return { path: segsToStr(segs), chapter: segsToStr(segs), files };
67122
67291
  }
67123
67292
  function pasteRichAsChapter(dataRoot, segs, rich) {
67124
67293
  const dirSegs = nearestDirSegs(dataRoot, segs);
67125
67294
  if (!dirSegs) throw new Error("no enclosing directory to paste into");
67126
- const dir = path9.resolve(dataRoot, ...dirSegs.map(String));
67295
+ const dir = path10.resolve(dataRoot, ...dirSegs.map(String));
67127
67296
  if (!rich.title && rich.chunks.length === 0 && rich.children.length === 1) rich = rich.children[0];
67128
67297
  const firstText = rich.chunks.find((c3) => "text" in c3);
67129
67298
  const title = rich.title ?? (firstText ? titleFromText(firstText.text) : rich.children[0]?.title ?? "Pasted content");
@@ -67136,16 +67305,16 @@ function pasteRichAsChapter(dataRoot, segs, rich) {
67136
67305
  return { path: segsToStr([...dirSegs, final]), dir: segsToStr(dirSegs), open: dirSegs.length !== segs.length };
67137
67306
  }
67138
67307
  const name = uniqueName(dir, chapterFileName(title).replace(/\.yamlover$/, ""));
67139
- const chDir = path9.join(dir, name);
67140
- if (!path9.resolve(chDir).startsWith(path9.resolve(dataRoot) + path9.sep)) throw new Error("target escapes the data root");
67141
- fs9.mkdirSync(path9.join(chDir, ".yamlover"), { recursive: true });
67308
+ const chDir = path10.join(dir, name);
67309
+ if (!path10.resolve(chDir).startsWith(path10.resolve(dataRoot) + path10.sep)) throw new Error("target escapes the data root");
67310
+ fs10.mkdirSync(path10.join(chDir, ".yamlover"), { recursive: true });
67142
67311
  const pointerFor = (fname, bytes) => {
67143
67312
  const final = uniqueName(chDir, fname);
67144
67313
  writeInside(dataRoot, chDir, final, bytes);
67145
67314
  return `*/${final}`;
67146
67315
  };
67147
67316
  const src = renderChapterSource(title, rich, pointerFor);
67148
- writeInside(dataRoot, path9.join(chDir, ".yamlover"), "body.yamlover", Buffer.from(src, "utf8"));
67317
+ writeInside(dataRoot, path10.join(chDir, ".yamlover"), "body.yamlover", Buffer.from(src, "utf8"));
67149
67318
  return { path: segsToStr([...dirSegs, name]), dir: segsToStr(dirSegs), open: dirSegs.length !== segs.length };
67150
67319
  }
67151
67320
  function renderChapterSource(title, rich, pointerFor) {
@@ -67167,34 +67336,34 @@ function chapterFileName(title) {
67167
67336
  return `${base || "pasted"}.yamlover`;
67168
67337
  }
67169
67338
  function sanitizeName(raw) {
67170
- const base = path9.basename(String(raw || "")).replace(/[^A-Za-z0-9._-]/g, "_").replace(/^\.+/, "");
67339
+ const base = path10.basename(String(raw || "")).replace(/[^A-Za-z0-9._-]/g, "_").replace(/^\.+/, "");
67171
67340
  return base || "pasted";
67172
67341
  }
67173
67342
  function uniqueName(dir, name) {
67174
- if (!fs9.existsSync(path9.join(dir, name))) return name;
67175
- const ext = path9.extname(name);
67343
+ if (!fs10.existsSync(path10.join(dir, name))) return name;
67344
+ const ext = path10.extname(name);
67176
67345
  const stem = name.slice(0, name.length - ext.length);
67177
67346
  for (let i2 = 1; ; i2++) {
67178
67347
  const cand = `${stem}-${i2}${ext}`;
67179
- if (!fs9.existsSync(path9.join(dir, cand))) return cand;
67348
+ if (!fs10.existsSync(path10.join(dir, cand))) return cand;
67180
67349
  }
67181
67350
  }
67182
67351
  function writeInside(dataRoot, dir, name, bytes) {
67183
- const root = path9.resolve(dataRoot);
67184
- const target = path9.resolve(dir, name);
67185
- if (target !== root && !target.startsWith(root + path9.sep)) throw new Error("target escapes the data root");
67186
- fs9.writeFileSync(target, bytes);
67352
+ const root = path10.resolve(dataRoot);
67353
+ const target = path10.resolve(dir, name);
67354
+ if (target !== root && !target.startsWith(root + path10.sep)) throw new Error("target escapes the data root");
67355
+ fs10.writeFileSync(target, bytes);
67187
67356
  }
67188
- var AGENT_DOCS_DIR = path9.join(path9.dirname(fileURLToPath2(import.meta.url)), "agent-docs");
67357
+ var AGENT_DOCS_DIR = path10.join(path10.dirname(fileURLToPath3(import.meta.url)), "agent-docs");
67189
67358
  function loadAgentDocs() {
67190
67359
  let names3;
67191
67360
  try {
67192
- names3 = fs9.readdirSync(AGENT_DOCS_DIR).filter((f2) => f2.endsWith(".md")).sort();
67361
+ names3 = fs10.readdirSync(AGENT_DOCS_DIR).filter((f2) => f2.endsWith(".md")).sort();
67193
67362
  } catch {
67194
67363
  throw new Error(`agent-docs resources not found at ${AGENT_DOCS_DIR}`);
67195
67364
  }
67196
67365
  if (names3.length === 0) throw new Error(`no agent-docs resources at ${AGENT_DOCS_DIR}`);
67197
- return names3.map((name) => ({ name, content: fs9.readFileSync(path9.join(AGENT_DOCS_DIR, name), "utf8") }));
67366
+ return names3.map((name) => ({ name, content: fs10.readFileSync(path10.join(AGENT_DOCS_DIR, name), "utf8") }));
67198
67367
  }
67199
67368
  var indentOf2 = (line) => {
67200
67369
  let i2 = 0;
@@ -67361,7 +67530,7 @@ var EXT_CT = {
67361
67530
  ".epub": "application/epub+zip"
67362
67531
  };
67363
67532
  function formatFromExt(file) {
67364
- return EXT_CT[path9.extname(file).toLowerCase()] ?? null;
67533
+ return EXT_CT[path10.extname(file).toLowerCase()] ?? null;
67365
67534
  }
67366
67535
  function parseDepth(raw) {
67367
67536
  if (raw == null || raw === "") return null;