yamlover 0.3.10 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +186 -143
- package/bin/yamlover.js +51 -2
- package/dist/agent-docs/AGENTS.md +267 -0
- package/dist/agent-docs/CLAUDE.md +7 -0
- package/dist/builtin-taxonomy/$defs/.yamlover/meta.yamlover +25 -0
- package/dist/builtin-taxonomy/$defs/annotation +18 -0
- package/dist/builtin-taxonomy/$defs/board +15 -0
- package/dist/builtin-taxonomy/$defs/chapter +19 -0
- package/dist/builtin-taxonomy/$defs/chunk +6 -0
- package/dist/builtin-taxonomy/$defs/config +20 -0
- package/dist/builtin-taxonomy/$defs/fragment +44 -0
- package/dist/builtin-taxonomy/$defs/tag +17 -0
- package/dist/builtin-taxonomy/$defs/task +33 -0
- package/dist/builtin-taxonomy/$defs/workflow +18 -0
- package/dist/builtin-taxonomy/tags/.yamlover/body.yamlover +46 -0
- package/dist/client/assets/{decoded-M-9MjrR3.js → decoded-DVR13gJ5.js} +1 -1
- package/dist/client/assets/{djvu-M6ksPMNz.js → djvu-CZbDJKwH.js} +1 -1
- package/dist/client/assets/{docx-D4h81KWC.js → docx-BWH54ddd.js} +1 -1
- package/dist/client/assets/{heic-BoSpW_tk.js → heic-CV3oZ6BF.js} +1 -1
- package/dist/client/assets/{imagemap-CIJFPvXv.js → imagemap-DRJrF_aD.js} +1 -1
- package/dist/client/assets/index-CCUPHCB4.js +620 -0
- package/dist/client/assets/{index-DHqicFJy.css → index-D5xvCkZE.css} +1 -1
- package/dist/client/assets/{map-MATRMboW.js → map-Y_zmEjLV.js} +1 -1
- package/dist/client/assets/{paged-BQLUFBor.js → paged-DKLVDozm.js} +1 -1
- package/dist/client/assets/{panzoom-Do4jskMZ.js → panzoom-NbtFbptF.js} +1 -1
- package/dist/client/assets/{pdf-BShpl2D5.js → pdf-DM1MQkYa.js} +1 -1
- package/dist/client/assets/{psd-DIxfuhrV.js → psd-PXeZB_nC.js} +1 -1
- package/dist/client/assets/{spreadsheet-DL0NoDcm.js → spreadsheet-B-3t2XCi.js} +1 -1
- package/dist/client/assets/{tiff-C7zPNKoD.js → tiff-BQq-nYyI.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server.js +545 -339
- package/package.json +1 -1
- package/dist/client/assets/index-DZ1FuhId.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
|
|
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(
|
|
5763
|
+
exports.write = function(path11, frames, spec, encoder) {
|
|
5764
5764
|
encoder = encoder || defaultCodec;
|
|
5765
|
-
const matches =
|
|
5765
|
+
const matches = path11.match(/\.[a-zA-Z]+$/);
|
|
5766
5766
|
if (matches !== null && INVALID_SUFFIXES.includes(matches[0].toLowerCase())) {
|
|
5767
|
-
throw new Error(`GIF '${
|
|
5767
|
+
throw new Error(`GIF '${path11}' has an unexpected suffix`);
|
|
5768
5768
|
}
|
|
5769
5769
|
return encoder.encodeGif(frames, spec).then((gif2) => {
|
|
5770
|
-
return _writeBinary(
|
|
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(
|
|
5842
|
+
function _readBinary(path11) {
|
|
5843
5843
|
return new Promise((resolve3, reject) => {
|
|
5844
|
-
|
|
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(
|
|
5852
|
+
function _writeBinary(path11, buffer) {
|
|
5853
5853
|
return new Promise((resolve3, reject) => {
|
|
5854
|
-
|
|
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(
|
|
7864
|
+
load: function load(path11) {
|
|
7865
7865
|
var xhr = new XMLHttpRequest();
|
|
7866
|
-
xhr.open("GET",
|
|
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:
|
|
18729
|
-
const fullPath = [...
|
|
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,
|
|
19037
|
+
constructor(parent, value, path11, key) {
|
|
19038
19038
|
this._cachedPath = [];
|
|
19039
19039
|
this.parent = parent;
|
|
19040
19040
|
this.data = value;
|
|
19041
|
-
this._path =
|
|
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
|
|
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 =
|
|
23997
|
-
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(
|
|
24040
|
-
|
|
24041
|
-
let last =
|
|
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 <
|
|
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
|
|
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(
|
|
30581
|
-
return new FileTypeParser2(options).fromFile(
|
|
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(
|
|
30612
|
+
async fromFile(path11) {
|
|
30613
30613
|
this.options.signal?.throwIfAborted();
|
|
30614
|
-
const fileHandle = await
|
|
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:
|
|
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(
|
|
30959
|
-
const mimeType = import_lite.default.getType(
|
|
30960
|
-
await writeFile(
|
|
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
|
|
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(
|
|
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:
|
|
42496
|
+
const { existsSync: existsSync3, promises: fs11 } = await import("fs");
|
|
42497
42497
|
if (existsSync3(file)) {
|
|
42498
|
-
fileOrBuffer = await
|
|
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
|
|
48598
|
-
return { sig, path:
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
54386
|
-
paths.push(
|
|
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
|
-
|
|
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
|
|
54454
|
-
(0, psdWriter_1.writeUint16)(writer,
|
|
54455
|
-
(0, psdWriter_1.writeUint16)(writer,
|
|
54456
|
-
(0, psdWriter_1.writeUint16)(writer,
|
|
54457
|
-
(0, psdWriter_1.writeUint16)(writer,
|
|
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 =
|
|
54460
|
-
var unlinkedKnot =
|
|
54461
|
-
for (var _c = 0, _d =
|
|
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(
|
|
56180
|
+
SbpL: c3.paths.map(function(path11) {
|
|
56181
56181
|
return {
|
|
56182
56182
|
_name: "",
|
|
56183
56183
|
_classID: "Sbpl",
|
|
56184
|
-
Clsp:
|
|
56185
|
-
"Pts ":
|
|
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(
|
|
59213
|
+
function locateFile(path11) {
|
|
59214
59214
|
if (Module3["locateFile"]) {
|
|
59215
|
-
return Module3["locateFile"](
|
|
59215
|
+
return Module3["locateFile"](path11, scriptDirectory);
|
|
59216
59216
|
}
|
|
59217
|
-
return scriptDirectory +
|
|
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(
|
|
60653
|
+
function locateFile(path11) {
|
|
60654
60654
|
if (Module3["locateFile"]) {
|
|
60655
|
-
return Module3["locateFile"](
|
|
60655
|
+
return Module3["locateFile"](path11, scriptDirectory);
|
|
60656
60656
|
}
|
|
60657
|
-
return scriptDirectory +
|
|
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 = (
|
|
62175
|
-
if (!isString(
|
|
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 (!
|
|
62181
|
+
if (!path11) {
|
|
62182
62182
|
return doThrow(`path must not be empty`, TypeError);
|
|
62183
62183
|
}
|
|
62184
|
-
if (checkPath.isNotRelative(
|
|
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 = (
|
|
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(
|
|
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(
|
|
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
|
|
62273
|
+
const path11 = originalPath && checkPath.convert(originalPath);
|
|
62274
62274
|
checkPath(
|
|
62275
|
-
|
|
62275
|
+
path11,
|
|
62276
62276
|
originalPath,
|
|
62277
62277
|
this._allowRelativePaths ? RETURN_FALSE : throwError
|
|
62278
62278
|
);
|
|
62279
|
-
return this._t(
|
|
62279
|
+
return this._t(path11, cache, checkUnignored, slices);
|
|
62280
62280
|
}
|
|
62281
|
-
_t(
|
|
62282
|
-
if (
|
|
62283
|
-
return cache[
|
|
62281
|
+
_t(path11, cache, checkUnignored, slices) {
|
|
62282
|
+
if (path11 in cache) {
|
|
62283
|
+
return cache[path11];
|
|
62284
62284
|
}
|
|
62285
62285
|
if (!slices) {
|
|
62286
|
-
slices =
|
|
62286
|
+
slices = path11.split(SLASH);
|
|
62287
62287
|
}
|
|
62288
62288
|
slices.pop();
|
|
62289
62289
|
if (!slices.length) {
|
|
62290
|
-
return cache[
|
|
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[
|
|
62298
|
+
return cache[path11] = parent.ignored ? parent : this._testOne(path11, checkUnignored);
|
|
62299
62299
|
}
|
|
62300
|
-
ignores(
|
|
62301
|
-
return this._test(
|
|
62300
|
+
ignores(path11) {
|
|
62301
|
+
return this._test(path11, this._ignoreCache, false).ignored;
|
|
62302
62302
|
}
|
|
62303
62303
|
createFilter() {
|
|
62304
|
-
return (
|
|
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(
|
|
62311
|
-
return this._test(
|
|
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 = (
|
|
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,14 +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 = (
|
|
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
|
|
62333
|
-
import
|
|
62332
|
+
import path10 from "node:path";
|
|
62333
|
+
import fs10 from "node:fs";
|
|
62334
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
62334
62335
|
|
|
62335
62336
|
// ../parser/ts/src/ir.ts
|
|
62336
62337
|
function isPointer(v) {
|
|
@@ -62359,6 +62360,7 @@ function entryPlain(e3) {
|
|
|
62359
62360
|
}
|
|
62360
62361
|
|
|
62361
62362
|
// ../engine/ts/src/resolve.ts
|
|
62363
|
+
var YAMLOVER_AUTHORITY = "yamlover.inthemoon.net";
|
|
62362
62364
|
function resolveDocument(doc) {
|
|
62363
62365
|
const chains = buildChains(doc.root);
|
|
62364
62366
|
const { edges: anchorEdges, keys } = realizeAnchors(doc, chains);
|
|
@@ -62446,8 +62448,10 @@ function resolve(doc, chains, fromChain, ptr, visited, anchorKeys) {
|
|
|
62446
62448
|
switch (ptr.base.scope) {
|
|
62447
62449
|
case "link": {
|
|
62448
62450
|
chain = chains.get(root) ?? [root];
|
|
62449
|
-
|
|
62450
|
-
|
|
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];
|
|
62451
62455
|
break;
|
|
62452
62456
|
}
|
|
62453
62457
|
case "document": {
|
|
@@ -62604,7 +62608,7 @@ var Store = class {
|
|
|
62604
62608
|
try {
|
|
62605
62609
|
this.db.exec("DELETE FROM node; DELETE FROM edge; DELETE FROM dangling;");
|
|
62606
62610
|
if (files) this.db.exec("DELETE FROM file;");
|
|
62607
|
-
walkNodes(doc.root, ":", (
|
|
62611
|
+
walkNodes(doc.root, ":", (path11, node, parent, label, pos) => {
|
|
62608
62612
|
const meta = node.meta ? JSON.stringify(node.meta) : null;
|
|
62609
62613
|
const owned = node.entries?.filter((e3) => e3.edge !== "back") ?? [];
|
|
62610
62614
|
const isArray = node.array || node.kind === "mapping" && owned.length > 0 && owned.every((e3) => e3.key === null);
|
|
@@ -62612,8 +62616,8 @@ var Store = class {
|
|
|
62612
62616
|
const format = node.kind === "blob" ? node.format : formatFromMeta(node);
|
|
62613
62617
|
const hash = node.kind === "blob" ? node.contentHash : null;
|
|
62614
62618
|
const size = node.kind === "blob" ? node.size : null;
|
|
62615
|
-
insNode.run(
|
|
62616
|
-
if (parent !== null) insEdge.run(parent,
|
|
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);
|
|
62617
62621
|
});
|
|
62618
62622
|
const insDangling = this.db.prepare("INSERT INTO dangling (from_path, raw, reason) VALUES (?, ?, ?)");
|
|
62619
62623
|
for (const r2 of resolveDocument(doc)) {
|
|
@@ -62828,29 +62832,29 @@ var Store = class {
|
|
|
62828
62832
|
}));
|
|
62829
62833
|
}
|
|
62830
62834
|
/** A node's attributes (null if no such path). */
|
|
62831
|
-
node(
|
|
62832
|
-
const row = this.db.prepare("SELECT * FROM node WHERE path = ?").get(
|
|
62835
|
+
node(path11) {
|
|
62836
|
+
const row = this.db.prepare("SELECT * FROM node WHERE path = ?").get(path11);
|
|
62833
62837
|
return row ? rowToNode(row) : null;
|
|
62834
62838
|
}
|
|
62835
62839
|
/** Direct containment children of a node, in source order (by `pos`). */
|
|
62836
|
-
children(
|
|
62837
|
-
return this.db.prepare("SELECT to_path, label, pos FROM edge WHERE from_path = ? AND kind = 'contain' ORDER BY pos").all(
|
|
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 }));
|
|
62838
62842
|
}
|
|
62839
62843
|
/** ALL of a node's entries in source order — containment children AND `*`/`~` pointer
|
|
62840
62844
|
* entries (ref/back). Unlike {@link children} this keeps positional pointers (`- *file`)
|
|
62841
62845
|
* in place, so an array that mixes inline values and pointers (e.g. a chapter's `chunks`)
|
|
62842
62846
|
* projects in full. `kind` says whether `to` is an owned child (contain) or a pointer target. */
|
|
62843
|
-
entries(
|
|
62844
|
-
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(
|
|
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 }));
|
|
62845
62849
|
}
|
|
62846
62850
|
/** Whether a node has any containment children (expandable in the TOC). */
|
|
62847
|
-
hasChildren(
|
|
62848
|
-
const r2 = this.db.prepare("SELECT 1 FROM edge WHERE from_path = ? AND kind = 'contain' LIMIT 1").get(
|
|
62851
|
+
hasChildren(path11) {
|
|
62852
|
+
const r2 = this.db.prepare("SELECT 1 FROM edge WHERE from_path = ? AND kind = 'contain' LIMIT 1").get(path11);
|
|
62849
62853
|
return r2 != null;
|
|
62850
62854
|
}
|
|
62851
62855
|
/** The containment subtree rooted at `path`, up to `depth` levels (TOC). A recursive CTE
|
|
62852
62856
|
* over `contain` edges — the acyclic spine; ordered by `pos` at each level. */
|
|
62853
|
-
toc(
|
|
62857
|
+
toc(path11 = ":", depth = Infinity) {
|
|
62854
62858
|
const rows = this.db.prepare(
|
|
62855
62859
|
`WITH RECURSIVE sub(from_path, to_path, label, pos, lvl) AS (
|
|
62856
62860
|
SELECT from_path, to_path, label, pos, 1 FROM edge
|
|
@@ -62863,10 +62867,10 @@ var Store = class {
|
|
|
62863
62867
|
SELECT s.to_path AS path, s.from_path AS parent, s.label, s.pos, n.type, n.format
|
|
62864
62868
|
FROM sub s JOIN node n ON n.path = s.to_path
|
|
62865
62869
|
ORDER BY s.lvl, s.from_path, s.pos`
|
|
62866
|
-
).all(
|
|
62870
|
+
).all(path11, depth === Infinity ? Number.MAX_SAFE_INTEGER : depth);
|
|
62867
62871
|
const byPath = /* @__PURE__ */ new Map();
|
|
62868
|
-
const root = { path:
|
|
62869
|
-
byPath.set(
|
|
62872
|
+
const root = { path: path11, label: null, type: this.node(path11)?.type ?? "mapping", format: null, children: [] };
|
|
62873
|
+
byPath.set(path11, root);
|
|
62870
62874
|
for (const r2 of rows) {
|
|
62871
62875
|
const tn = {
|
|
62872
62876
|
path: r2.path,
|
|
@@ -62882,20 +62886,20 @@ var Store = class {
|
|
|
62882
62886
|
}
|
|
62883
62887
|
/** Edges in/out of a node, by kind. `derived` inverses are computed here on demand (never
|
|
62884
62888
|
* stored) per ENGINE.md — for each ref/back into/out of the node, the reverse direction. */
|
|
62885
|
-
relationships(
|
|
62886
|
-
const out = this.db.prepare("SELECT * FROM edge WHERE from_path = ? AND kind != 'contain'").all(
|
|
62887
|
-
const inc = this.db.prepare("SELECT * FROM edge WHERE to_path = ? AND kind != 'contain'").all(
|
|
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);
|
|
62888
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 }));
|
|
62889
62893
|
return { out, in: [...inc, ...derivedIn] };
|
|
62890
62894
|
}
|
|
62891
62895
|
};
|
|
62892
|
-
function walkNodes(node,
|
|
62893
|
-
visit2(
|
|
62896
|
+
function walkNodes(node, path11, visit2, parent = null, label = null, pos = null) {
|
|
62897
|
+
visit2(path11, node, parent, label, pos);
|
|
62894
62898
|
if (!node.entries) return;
|
|
62895
62899
|
node.entries.forEach((e3, i2) => {
|
|
62896
62900
|
if (isPointer(e3.value)) return;
|
|
62897
|
-
const childPath2 = (
|
|
62898
|
-
walkNodes(e3.value, childPath2, visit2,
|
|
62901
|
+
const childPath2 = (path11 === ":" ? "" : path11) + (e3.key != null ? ":" + e3.key : "[" + i2 + "]");
|
|
62902
|
+
walkNodes(e3.value, childPath2, visit2, path11, e3.key, i2);
|
|
62899
62903
|
});
|
|
62900
62904
|
}
|
|
62901
62905
|
function formatFromMeta(node) {
|
|
@@ -62933,8 +62937,8 @@ function rowToEdge(r2) {
|
|
|
62933
62937
|
}
|
|
62934
62938
|
|
|
62935
62939
|
// ../engine/ts/src/walk.ts
|
|
62936
|
-
import
|
|
62937
|
-
import
|
|
62940
|
+
import fs2 from "node:fs";
|
|
62941
|
+
import path2 from "node:path";
|
|
62938
62942
|
import { setImmediate as yieldLoop } from "node:timers/promises";
|
|
62939
62943
|
|
|
62940
62944
|
// ../engine/ts/node_modules/xxhash-wasm/esm/xxhash-wasm.js
|
|
@@ -63178,8 +63182,8 @@ function colonSegment(name) {
|
|
|
63178
63182
|
if (/[ \t]/.test(name) || /^['"]/.test(name)) return `'${name.replace(/'/g, "''")}'`;
|
|
63179
63183
|
return name.replace(/[\\:[\]*&#~?!()<>=|]/g, (c3) => "\\" + c3);
|
|
63180
63184
|
}
|
|
63181
|
-
function parsePath(
|
|
63182
|
-
const segs = splitSlash(
|
|
63185
|
+
function parsePath(path11) {
|
|
63186
|
+
const segs = splitSlash(path11);
|
|
63183
63187
|
const out = [];
|
|
63184
63188
|
for (let i2 = 0; i2 < segs.length; i2++) {
|
|
63185
63189
|
if (segs[i2] === "") continue;
|
|
@@ -63270,13 +63274,13 @@ function makeAnchor(body, fail) {
|
|
|
63270
63274
|
ordinal = true;
|
|
63271
63275
|
body = body.slice(0, -2);
|
|
63272
63276
|
}
|
|
63273
|
-
const
|
|
63277
|
+
const path11 = parsePointer(body);
|
|
63274
63278
|
if (!ordinal) {
|
|
63275
|
-
const last =
|
|
63279
|
+
const last = path11.steps[path11.steps.length - 1];
|
|
63276
63280
|
if (last === void 0) fail('an anchor path needs a key segment (or a trailing "[]" for ordinal membership)');
|
|
63277
63281
|
if (last.sel !== "key") fail('an anchor may not claim a position \u2014 use a trailing "[]" for ordinal membership');
|
|
63278
63282
|
}
|
|
63279
|
-
return { path:
|
|
63283
|
+
return { path: path11, ...ordinal ? { ordinal: true } : {} };
|
|
63280
63284
|
}
|
|
63281
63285
|
function escapeSegment(name) {
|
|
63282
63286
|
if (name === "..") return "\\.\\.";
|
|
@@ -64302,6 +64306,49 @@ function json5number(tok) {
|
|
|
64302
64306
|
return void 0;
|
|
64303
64307
|
}
|
|
64304
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
|
+
|
|
64305
64352
|
// ../engine/ts/src/walk.ts
|
|
64306
64353
|
var { h64Raw, create64 } = await e();
|
|
64307
64354
|
var hashBytes = (bytes) => "xxh64:" + h64Raw(bytes).toString(16).padStart(16, "0");
|
|
@@ -64315,6 +64362,8 @@ var YAMLOVER_INTERNAL = /* @__PURE__ */ new Set([
|
|
|
64315
64362
|
"index.db-shm",
|
|
64316
64363
|
"index.db-journal"
|
|
64317
64364
|
]);
|
|
64365
|
+
var SETTINGS_FILE = "settings.yamlover";
|
|
64366
|
+
var skipInYamloverDir = (name) => YAMLOVER_INTERNAL.has(name) && name !== SETTINGS_FILE || name.startsWith(".");
|
|
64318
64367
|
var MAX_TEXT_BYTES = 1 << 20;
|
|
64319
64368
|
var MAX_DOC_BYTES = 64 << 20;
|
|
64320
64369
|
var HASH_INLINE_MAX = 1 << 20;
|
|
@@ -64372,24 +64421,35 @@ function builtinYamloverGraft() {
|
|
|
64372
64421
|
return { node, defs: /* @__PURE__ */ new Map([["tag", tagCopy], ["fragment", fragCopy], ["annotation", annCopy]]) };
|
|
64373
64422
|
}
|
|
64374
64423
|
function* walkTreeGen(absDir, opts = {}) {
|
|
64375
|
-
const ctx = { root:
|
|
64424
|
+
const ctx = { root: path2.resolve(absDir), opts, files: /* @__PURE__ */ new Map(), count: 0 };
|
|
64376
64425
|
const root = yield* dirNode(ctx.root, ctx);
|
|
64377
64426
|
root.meta = { ...root.meta, documentRoot: true };
|
|
64378
64427
|
const defsRoot = findDefsRoot(absDir);
|
|
64379
|
-
const defsDir =
|
|
64380
|
-
const selfRoot =
|
|
64428
|
+
const defsDir = path2.join(defsRoot, "$defs");
|
|
64429
|
+
const selfRoot = fs2.existsSync(defsDir) && path2.resolve(absDir) === defsRoot;
|
|
64381
64430
|
const arrayRoot = root.array || (root.entries?.length ? root.entries.every((e3) => e3.key === null) : false);
|
|
64382
64431
|
let builtinDefs;
|
|
64383
|
-
if (!
|
|
64384
|
-
|
|
64385
|
-
|
|
64386
|
-
|
|
64387
|
-
if (
|
|
64388
|
-
|
|
64389
|
-
|
|
64390
|
-
|
|
64391
|
-
|
|
64392
|
-
|
|
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 });
|
|
64393
64453
|
}
|
|
64394
64454
|
}
|
|
64395
64455
|
applySchemas(root, defsRoot, builtinDefs);
|
|
@@ -64407,7 +64467,7 @@ function reindex(store, absDir, opts = {}) {
|
|
|
64407
64467
|
async function reindexAsyncDoc(store, absDir, opts = {}) {
|
|
64408
64468
|
const prev = store.stale ? /* @__PURE__ */ new Map() : store.manifest();
|
|
64409
64469
|
const onProgress = opts.onProgress;
|
|
64410
|
-
const total = onProgress ? await countChildren(
|
|
64470
|
+
const total = onProgress ? await countChildren(path2.resolve(absDir), opts) : void 0;
|
|
64411
64471
|
const { doc, files } = await walkTreeAsync(absDir, {
|
|
64412
64472
|
...opts,
|
|
64413
64473
|
cache: opts.cache ?? manifestCache(prev),
|
|
@@ -64419,7 +64479,7 @@ async function reindexAsyncDoc(store, absDir, opts = {}) {
|
|
|
64419
64479
|
return { diff: diffManifest(prev, files), doc, files };
|
|
64420
64480
|
}
|
|
64421
64481
|
async function reindexPathAsync(store, absDir, cachedDoc, changedRel, opts = {}) {
|
|
64422
|
-
const root =
|
|
64482
|
+
const root = path2.resolve(absDir);
|
|
64423
64483
|
const parts = changedRel.split("/");
|
|
64424
64484
|
const yi = parts.indexOf(YAMLOVER_DIR);
|
|
64425
64485
|
const dirSegs = yi >= 0 ? parts.slice(0, yi) : parts.slice(0, -1);
|
|
@@ -64435,8 +64495,8 @@ async function reindexPathAsync(store, absDir, cachedDoc, changedRel, opts = {})
|
|
|
64435
64495
|
else entries = entries[i2].value.entries;
|
|
64436
64496
|
}
|
|
64437
64497
|
if (!target) return null;
|
|
64438
|
-
const absSpliceDir =
|
|
64439
|
-
if (!
|
|
64498
|
+
const absSpliceDir = path2.join(root, ...dirSegs);
|
|
64499
|
+
if (!fs2.existsSync(absSpliceDir) || !fs2.statSync(absSpliceDir).isDirectory()) return null;
|
|
64440
64500
|
const prev = store.stale ? /* @__PURE__ */ new Map() : store.manifest();
|
|
64441
64501
|
const ctx = { root, opts: { ...opts, cache: opts.cache ?? manifestCache(prev) }, files: /* @__PURE__ */ new Map(), count: 0 };
|
|
64442
64502
|
const gen = dirNode(absSpliceDir, ctx);
|
|
@@ -64471,18 +64531,18 @@ async function countChildren(absRoot, opts) {
|
|
|
64471
64531
|
const visitYamlover = async (dir) => {
|
|
64472
64532
|
let entries;
|
|
64473
64533
|
try {
|
|
64474
|
-
entries = await
|
|
64534
|
+
entries = await fs2.promises.readdir(dir, { withFileTypes: true });
|
|
64475
64535
|
} catch {
|
|
64476
64536
|
return 0;
|
|
64477
64537
|
}
|
|
64478
64538
|
let top = 0;
|
|
64479
64539
|
for (const e3 of entries) {
|
|
64480
|
-
if (
|
|
64481
|
-
const abs =
|
|
64540
|
+
if (skipInYamloverDir(e3.name)) continue;
|
|
64541
|
+
const abs = path2.join(dir, e3.name);
|
|
64482
64542
|
if (opts.ignore?.(abs)) continue;
|
|
64483
64543
|
n2++;
|
|
64484
64544
|
top++;
|
|
64485
|
-
const isDir = e3.isDirectory() || e3.isSymbolicLink() && (await
|
|
64545
|
+
const isDir = e3.isDirectory() || e3.isSymbolicLink() && (await fs2.promises.stat(abs).catch(() => null))?.isDirectory();
|
|
64486
64546
|
if (isDir) await visit2(abs);
|
|
64487
64547
|
}
|
|
64488
64548
|
return top;
|
|
@@ -64490,20 +64550,20 @@ async function countChildren(absRoot, opts) {
|
|
|
64490
64550
|
const visit2 = async (dir) => {
|
|
64491
64551
|
let entries;
|
|
64492
64552
|
try {
|
|
64493
|
-
entries = await
|
|
64553
|
+
entries = await fs2.promises.readdir(dir, { withFileTypes: true });
|
|
64494
64554
|
} catch {
|
|
64495
64555
|
return;
|
|
64496
64556
|
}
|
|
64497
64557
|
for (const e3 of entries) {
|
|
64498
64558
|
if (e3.name.startsWith(".") && e3.name !== YAMLOVER_DIR) continue;
|
|
64499
|
-
const abs =
|
|
64559
|
+
const abs = path2.join(dir, e3.name);
|
|
64500
64560
|
if (opts.ignore?.(abs)) continue;
|
|
64501
64561
|
if (e3.name === YAMLOVER_DIR) {
|
|
64502
64562
|
if (await visitYamlover(abs) > 0) n2++;
|
|
64503
64563
|
continue;
|
|
64504
64564
|
}
|
|
64505
64565
|
n2++;
|
|
64506
|
-
const isDir = e3.isDirectory() || e3.isSymbolicLink() && (await
|
|
64566
|
+
const isDir = e3.isDirectory() || e3.isSymbolicLink() && (await fs2.promises.stat(abs).catch(() => null))?.isDirectory();
|
|
64507
64567
|
if (isDir) await visit2(abs);
|
|
64508
64568
|
}
|
|
64509
64569
|
};
|
|
@@ -64553,7 +64613,7 @@ function groupBy(list, key) {
|
|
|
64553
64613
|
return m;
|
|
64554
64614
|
}
|
|
64555
64615
|
async function hashFileAsync(abs, onChunk) {
|
|
64556
|
-
const fh = await
|
|
64616
|
+
const fh = await fs2.promises.open(abs, "r");
|
|
64557
64617
|
try {
|
|
64558
64618
|
const hasher = create64();
|
|
64559
64619
|
const buf = Buffer.alloc(HASH_CHUNK);
|
|
@@ -64571,19 +64631,19 @@ async function hashFileAsync(abs, onChunk) {
|
|
|
64571
64631
|
}
|
|
64572
64632
|
}
|
|
64573
64633
|
function record(ctx, abs, hash, size, mtimeMs) {
|
|
64574
|
-
const rel =
|
|
64634
|
+
const rel = path2.relative(ctx.root, abs).split(path2.sep).join("/");
|
|
64575
64635
|
if (rel.startsWith("..")) return;
|
|
64576
64636
|
ctx.files.set(rel, { path: rel, hash, size, mtimeMs });
|
|
64577
64637
|
}
|
|
64578
64638
|
function readTracked(ctx, abs) {
|
|
64579
|
-
const stat =
|
|
64580
|
-
const bytes =
|
|
64639
|
+
const stat = fs2.statSync(abs);
|
|
64640
|
+
const bytes = fs2.readFileSync(abs);
|
|
64581
64641
|
record(ctx, abs, hashBytes(bytes), stat.size, stat.mtimeMs);
|
|
64582
64642
|
return bytes;
|
|
64583
64643
|
}
|
|
64584
64644
|
function loadMeta(dir, ctx) {
|
|
64585
|
-
const file =
|
|
64586
|
-
if (!
|
|
64645
|
+
const file = path2.join(dir, YAMLOVER_DIR, "meta.yamlover");
|
|
64646
|
+
if (!fs2.existsSync(file)) return {};
|
|
64587
64647
|
try {
|
|
64588
64648
|
const plain = toPlain(parseYamlover(readTracked(ctx, file).toString("utf8"), file).root);
|
|
64589
64649
|
const props = plain?.properties ?? {};
|
|
@@ -64594,21 +64654,21 @@ function loadMeta(dir, ctx) {
|
|
|
64594
64654
|
}
|
|
64595
64655
|
function* dirNode(dir, ctx) {
|
|
64596
64656
|
const meta = loadMeta(dir, ctx);
|
|
64597
|
-
const names3 =
|
|
64657
|
+
const names3 = fs2.readdirSync(dir).filter((n2) => n2 === YAMLOVER_DIR || !n2.startsWith(".")).filter((n2) => !ctx.opts.ignore?.(path2.join(dir, n2))).sort();
|
|
64598
64658
|
const entries = [];
|
|
64599
64659
|
for (const name of names3) {
|
|
64600
|
-
const abs =
|
|
64660
|
+
const abs = path2.join(dir, name);
|
|
64601
64661
|
if (name === YAMLOVER_DIR) {
|
|
64602
64662
|
const hidden = yield* yamloverDirNode(abs, ctx);
|
|
64603
64663
|
if (hidden) {
|
|
64604
64664
|
entries.push({ key: name, edge: "contain", value: hidden });
|
|
64605
|
-
yield { done: ++ctx.count, path:
|
|
64665
|
+
yield { done: ++ctx.count, path: path2.relative(ctx.root, abs).split(path2.sep).join("/") };
|
|
64606
64666
|
}
|
|
64607
64667
|
continue;
|
|
64608
64668
|
}
|
|
64609
64669
|
const child = yield* childNode(abs, meta[name], ctx);
|
|
64610
64670
|
entries.push({ key: name, edge: "contain", value: child });
|
|
64611
|
-
yield { done: ++ctx.count, path:
|
|
64671
|
+
yield { done: ++ctx.count, path: path2.relative(ctx.root, abs).split(path2.sep).join("/") };
|
|
64612
64672
|
}
|
|
64613
64673
|
const node = { kind: "mapping", entries, array: false };
|
|
64614
64674
|
return applyMeta(applyBody(dir, node, ctx), meta);
|
|
@@ -64616,24 +64676,24 @@ function* dirNode(dir, ctx) {
|
|
|
64616
64676
|
function* yamloverDirNode(absYamlover, ctx) {
|
|
64617
64677
|
let names3;
|
|
64618
64678
|
try {
|
|
64619
|
-
names3 =
|
|
64679
|
+
names3 = fs2.readdirSync(absYamlover).filter((n2) => !skipInYamloverDir(n2)).filter((n2) => !ctx.opts.ignore?.(path2.join(absYamlover, n2))).sort();
|
|
64620
64680
|
} catch {
|
|
64621
64681
|
return null;
|
|
64622
64682
|
}
|
|
64623
64683
|
const entries = [];
|
|
64624
64684
|
for (const name of names3) {
|
|
64625
|
-
const abs =
|
|
64685
|
+
const abs = path2.join(absYamlover, name);
|
|
64626
64686
|
const child = yield* childNode(abs, void 0, ctx);
|
|
64627
64687
|
entries.push({ key: name, edge: "contain", value: child });
|
|
64628
|
-
yield { done: ++ctx.count, path:
|
|
64688
|
+
yield { done: ++ctx.count, path: path2.relative(ctx.root, abs).split(path2.sep).join("/") };
|
|
64629
64689
|
}
|
|
64630
64690
|
if (entries.length === 0) return null;
|
|
64631
64691
|
return { kind: "mapping", entries, array: false, meta: { hidden: true } };
|
|
64632
64692
|
}
|
|
64633
64693
|
function* childNode(abs, m, ctx) {
|
|
64634
|
-
const stat =
|
|
64694
|
+
const stat = fs2.statSync(abs);
|
|
64635
64695
|
if (stat.isDirectory()) return yield* dirNode(abs, ctx);
|
|
64636
|
-
const ext =
|
|
64696
|
+
const ext = path2.extname(abs).toLowerCase();
|
|
64637
64697
|
const fmt = m?.format ?? EXT_FORMAT[ext] ?? null;
|
|
64638
64698
|
if (m?.type === "binary") return blob(abs, fmt ?? "application/octet-stream", ctx);
|
|
64639
64699
|
if (fmt && (DOC_FORMATS[fmt] || TEXT_FORMATS.has(fmt))) {
|
|
@@ -64657,15 +64717,15 @@ function applyMeta(node, meta) {
|
|
|
64657
64717
|
return node;
|
|
64658
64718
|
}
|
|
64659
64719
|
function blob(abs, format, ctx) {
|
|
64660
|
-
const stat =
|
|
64661
|
-
const rel =
|
|
64662
|
-
const
|
|
64663
|
-
if (
|
|
64664
|
-
record(ctx, abs,
|
|
64665
|
-
return { kind: "blob", format, contentHash:
|
|
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 };
|
|
64666
64726
|
}
|
|
64667
64727
|
const inlineMax = ctx.opts.hashInlineMax ?? HASH_INLINE_MAX;
|
|
64668
|
-
const contentHash = stat.size <= inlineMax ? hashBytes(
|
|
64728
|
+
const contentHash = stat.size <= inlineMax ? hashBytes(fs2.readFileSync(abs)) : null;
|
|
64669
64729
|
record(ctx, abs, contentHash, stat.size, stat.mtimeMs);
|
|
64670
64730
|
return { kind: "blob", format, contentHash, size: stat.size };
|
|
64671
64731
|
}
|
|
@@ -64687,12 +64747,15 @@ function parsedDoc(abs, lang, ctx) {
|
|
|
64687
64747
|
return { kind: "scalar", value: text, raw: text };
|
|
64688
64748
|
}
|
|
64689
64749
|
}
|
|
64750
|
+
function isYamloverWorldPointer(v) {
|
|
64751
|
+
return isPointer(v) && v.base.scope === "link" && v.base.world === true && v.base.authority === YAMLOVER_AUTHORITY2;
|
|
64752
|
+
}
|
|
64690
64753
|
function findDefsRoot(dir) {
|
|
64691
|
-
let d =
|
|
64754
|
+
let d = path2.resolve(dir);
|
|
64692
64755
|
for (; ; ) {
|
|
64693
|
-
if (
|
|
64694
|
-
const up =
|
|
64695
|
-
if (up === d) return
|
|
64756
|
+
if (fs2.existsSync(path2.join(d, "$defs"))) return d;
|
|
64757
|
+
const up = path2.dirname(d);
|
|
64758
|
+
if (up === d) return path2.resolve(dir);
|
|
64696
64759
|
d = up;
|
|
64697
64760
|
}
|
|
64698
64761
|
}
|
|
@@ -64700,9 +64763,9 @@ function applySchemas(root, defsRoot, builtinDefs) {
|
|
|
64700
64763
|
const cache = /* @__PURE__ */ new Map();
|
|
64701
64764
|
const loadDef = (name) => {
|
|
64702
64765
|
if (!cache.has(name)) {
|
|
64703
|
-
const defFile =
|
|
64766
|
+
const defFile = path2.join(defsRoot, "$defs", name);
|
|
64704
64767
|
try {
|
|
64705
|
-
cache.set(name, parseYamlover(
|
|
64768
|
+
cache.set(name, parseYamlover(fs2.readFileSync(defFile, "utf8"), defFile).root);
|
|
64706
64769
|
} catch {
|
|
64707
64770
|
cache.set(name, builtinDefs?.get(name) ?? null);
|
|
64708
64771
|
}
|
|
@@ -64759,8 +64822,8 @@ function inlineFormat(format) {
|
|
|
64759
64822
|
return { kind: "mapping", entries: [{ key: "format", edge: "contain", value: { kind: "scalar", value: format, raw: format } }], array: false };
|
|
64760
64823
|
}
|
|
64761
64824
|
function applyBody(dir, node, ctx) {
|
|
64762
|
-
const file =
|
|
64763
|
-
if (!
|
|
64825
|
+
const file = path2.join(dir, YAMLOVER_DIR, "body.yamlover");
|
|
64826
|
+
if (!fs2.existsSync(file)) return node;
|
|
64764
64827
|
const bodyDoc = parseYamlover(readTracked(ctx, file).toString("utf8"), file);
|
|
64765
64828
|
const body = bodyDoc.root;
|
|
64766
64829
|
if (body.kind !== "mapping" && body.kind !== "scalar" || !body.entries) return node;
|
|
@@ -64812,14 +64875,14 @@ function pointerLeafKey(v) {
|
|
|
64812
64875
|
}
|
|
64813
64876
|
function looksBinary(abs) {
|
|
64814
64877
|
try {
|
|
64815
|
-
if (
|
|
64816
|
-
const fd =
|
|
64878
|
+
if (fs2.statSync(abs).size > MAX_TEXT_BYTES) return true;
|
|
64879
|
+
const fd = fs2.openSync(abs, "r");
|
|
64817
64880
|
try {
|
|
64818
64881
|
const buf = Buffer.alloc(4096);
|
|
64819
|
-
const n2 =
|
|
64882
|
+
const n2 = fs2.readSync(fd, buf, 0, buf.length, 0);
|
|
64820
64883
|
return buf.subarray(0, n2).includes(0);
|
|
64821
64884
|
} finally {
|
|
64822
|
-
|
|
64885
|
+
fs2.closeSync(fd);
|
|
64823
64886
|
}
|
|
64824
64887
|
} catch {
|
|
64825
64888
|
return true;
|
|
@@ -64889,7 +64952,7 @@ var DOC_FORMATS = {
|
|
|
64889
64952
|
};
|
|
64890
64953
|
|
|
64891
64954
|
// ../engine/ts/src/rewrite.ts
|
|
64892
|
-
import * as
|
|
64955
|
+
import * as path3 from "node:path";
|
|
64893
64956
|
|
|
64894
64957
|
// ../parser/ts/src/serialize-yamlover.ts
|
|
64895
64958
|
function pointerToken(raw) {
|
|
@@ -64940,7 +65003,7 @@ function planRewrites(doc, edges, oldStore, newStore, opts = {}) {
|
|
|
64940
65003
|
miss("anchor has no source span");
|
|
64941
65004
|
continue;
|
|
64942
65005
|
}
|
|
64943
|
-
if (opts.root !== void 0 &&
|
|
65006
|
+
if (opts.root !== void 0 && path3.relative(opts.root, span2.uri).startsWith("..")) {
|
|
64944
65007
|
miss("source file is outside the served root (grafted)");
|
|
64945
65008
|
continue;
|
|
64946
65009
|
}
|
|
@@ -64992,7 +65055,7 @@ function planRewrites(doc, edges, oldStore, newStore, opts = {}) {
|
|
|
64992
65055
|
miss("pointer has no source span");
|
|
64993
65056
|
continue;
|
|
64994
65057
|
}
|
|
64995
|
-
if (opts.root !== void 0 &&
|
|
65058
|
+
if (opts.root !== void 0 && path3.relative(opts.root, span.uri).startsWith("..")) {
|
|
64996
65059
|
miss("source file is outside the served root (grafted)");
|
|
64997
65060
|
continue;
|
|
64998
65061
|
}
|
|
@@ -65126,12 +65189,12 @@ function json5pAnchorToken(body) {
|
|
|
65126
65189
|
}
|
|
65127
65190
|
|
|
65128
65191
|
// ../engine/ts/src/mv.ts
|
|
65129
|
-
import * as
|
|
65130
|
-
import * as
|
|
65192
|
+
import * as fs3 from "node:fs";
|
|
65193
|
+
import * as path4 from "node:path";
|
|
65131
65194
|
function mv(absRoot, fromRel, toRel, opts = {}) {
|
|
65132
|
-
const root =
|
|
65133
|
-
const absFrom =
|
|
65134
|
-
const absTo =
|
|
65195
|
+
const root = path4.resolve(absRoot);
|
|
65196
|
+
const absFrom = path4.resolve(root, fromRel);
|
|
65197
|
+
const absTo = path4.resolve(root, toRel);
|
|
65135
65198
|
const relFrom = relInside(root, absFrom, "source");
|
|
65136
65199
|
const relTo = relInside(root, absTo, "target");
|
|
65137
65200
|
for (const rel of [relFrom, relTo]) {
|
|
@@ -65139,9 +65202,9 @@ function mv(absRoot, fromRel, toRel, opts = {}) {
|
|
|
65139
65202
|
if (seg.startsWith(".")) throw new Error(`mv: hidden/overlay segments are not movable ("${seg}" in "${rel}")`);
|
|
65140
65203
|
}
|
|
65141
65204
|
}
|
|
65142
|
-
if (!
|
|
65143
|
-
if (
|
|
65144
|
-
if (absTo === absFrom || absTo.startsWith(absFrom +
|
|
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)) {
|
|
65145
65208
|
throw new Error(`mv: cannot move "${relFrom}" into itself`);
|
|
65146
65209
|
}
|
|
65147
65210
|
const { doc } = walkTree(root, opts);
|
|
@@ -65149,15 +65212,15 @@ function mv(absRoot, fromRel, toRel, opts = {}) {
|
|
|
65149
65212
|
const plan = planRewrites(doc, edges, storeOf(relFrom), storeOf(relTo), { root });
|
|
65150
65213
|
const editedFiles = [];
|
|
65151
65214
|
for (const [uri, edits] of plan.edits) {
|
|
65152
|
-
|
|
65153
|
-
editedFiles.push(
|
|
65215
|
+
fs3.writeFileSync(uri, applyEdits(fs3.readFileSync(uri, "utf8"), edits));
|
|
65216
|
+
editedFiles.push(path4.relative(root, uri).split(path4.sep).join("/"));
|
|
65154
65217
|
}
|
|
65155
|
-
|
|
65156
|
-
|
|
65218
|
+
fs3.mkdirSync(path4.dirname(absTo), { recursive: true });
|
|
65219
|
+
fs3.renameSync(absFrom, absTo);
|
|
65157
65220
|
return { from: relFrom, to: relTo, rewritten: plan.rewritten, unrewritten: plan.unrewritten, editedFiles };
|
|
65158
65221
|
}
|
|
65159
65222
|
function relinkMoved(absRoot, moved, opts = {}) {
|
|
65160
|
-
const root =
|
|
65223
|
+
const root = path4.resolve(absRoot);
|
|
65161
65224
|
const { doc } = walkTree(root, opts);
|
|
65162
65225
|
const edges = resolveDocument(doc);
|
|
65163
65226
|
const rewritten = [];
|
|
@@ -65178,36 +65241,36 @@ function relinkMoved(absRoot, moved, opts = {}) {
|
|
|
65178
65241
|
}
|
|
65179
65242
|
const editedFiles = [];
|
|
65180
65243
|
for (const [uri, edits] of merged) {
|
|
65181
|
-
|
|
65182
|
-
editedFiles.push(
|
|
65244
|
+
fs3.writeFileSync(uri, applyEdits(fs3.readFileSync(uri, "utf8"), edits));
|
|
65245
|
+
editedFiles.push(path4.relative(root, uri).split(path4.sep).join("/"));
|
|
65183
65246
|
}
|
|
65184
65247
|
return { rewritten, unrewritten, editedFiles };
|
|
65185
65248
|
}
|
|
65186
65249
|
function relInside(root, abs, what) {
|
|
65187
|
-
const rel =
|
|
65188
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
65250
|
+
const rel = path4.relative(root, abs);
|
|
65251
|
+
if (rel === "" || rel.startsWith("..") || path4.isAbsolute(rel)) {
|
|
65189
65252
|
throw new Error(`mv: ${what} escapes the served root`);
|
|
65190
65253
|
}
|
|
65191
|
-
return rel.split(
|
|
65254
|
+
return rel.split(path4.sep).join("/");
|
|
65192
65255
|
}
|
|
65193
65256
|
function storeOf(rel) {
|
|
65194
65257
|
return ":" + rel.split("/").join(":");
|
|
65195
65258
|
}
|
|
65196
65259
|
|
|
65197
65260
|
// ../engine/ts/src/watch.ts
|
|
65198
|
-
import
|
|
65199
|
-
import
|
|
65261
|
+
import fs4 from "node:fs";
|
|
65262
|
+
import path5 from "node:path";
|
|
65200
65263
|
var OVERLAY_FILES = /* @__PURE__ */ new Set(["body.yamlover", "meta.yamlover", "settings.yamlover"]);
|
|
65201
65264
|
var YAMLOVER_SIDECAR_DIRS = /* @__PURE__ */ new Set(["thumbnails", "fragments"]);
|
|
65202
65265
|
function watchTree(absRoot, onBatch, opts = {}) {
|
|
65203
|
-
const root =
|
|
65266
|
+
const root = path5.resolve(absRoot);
|
|
65204
65267
|
const debounceMs = opts.debounceMs ?? 300;
|
|
65205
65268
|
const pending = /* @__PURE__ */ new Set();
|
|
65206
65269
|
let timer = null;
|
|
65207
65270
|
let running = false;
|
|
65208
65271
|
let closed = false;
|
|
65209
65272
|
const relevant = (rel) => {
|
|
65210
|
-
const segs = rel.split(
|
|
65273
|
+
const segs = rel.split(path5.sep);
|
|
65211
65274
|
for (let i2 = 0; i2 < segs.length; i2++) {
|
|
65212
65275
|
if (!segs[i2].startsWith(".")) continue;
|
|
65213
65276
|
const rest = segs.slice(i2 + 1);
|
|
@@ -65216,12 +65279,12 @@ function watchTree(absRoot, onBatch, opts = {}) {
|
|
|
65216
65279
|
if (!isOverlay && !isSidecar) return false;
|
|
65217
65280
|
break;
|
|
65218
65281
|
}
|
|
65219
|
-
return !opts.ignore?.(
|
|
65282
|
+
return !opts.ignore?.(path5.join(root, rel));
|
|
65220
65283
|
};
|
|
65221
65284
|
const fire = () => {
|
|
65222
65285
|
timer = null;
|
|
65223
65286
|
if (running || closed || pending.size === 0) return;
|
|
65224
|
-
const batch = [...pending].map((p2) => p2.split(
|
|
65287
|
+
const batch = [...pending].map((p2) => p2.split(path5.sep).join("/"));
|
|
65225
65288
|
pending.clear();
|
|
65226
65289
|
running = true;
|
|
65227
65290
|
try {
|
|
@@ -65231,7 +65294,7 @@ function watchTree(absRoot, onBatch, opts = {}) {
|
|
|
65231
65294
|
if (pending.size > 0) timer = setTimeout(fire, debounceMs);
|
|
65232
65295
|
}
|
|
65233
65296
|
};
|
|
65234
|
-
const watcher =
|
|
65297
|
+
const watcher = fs4.watch(root, { recursive: true }, (_event, filename) => {
|
|
65235
65298
|
if (closed || filename == null) return;
|
|
65236
65299
|
const rel = String(filename);
|
|
65237
65300
|
if (!relevant(rel)) return;
|
|
@@ -65247,28 +65310,83 @@ function watchTree(absRoot, onBatch, opts = {}) {
|
|
|
65247
65310
|
}
|
|
65248
65311
|
|
|
65249
65312
|
// ../engine/ts/src/settings.ts
|
|
65250
|
-
import
|
|
65251
|
-
import
|
|
65313
|
+
import fs5 from "node:fs";
|
|
65314
|
+
import path6 from "node:path";
|
|
65252
65315
|
var DEFAULT_SETTINGS = {
|
|
65253
|
-
|
|
65254
|
-
|
|
65255
|
-
|
|
65316
|
+
uri: void 0,
|
|
65317
|
+
exports: [],
|
|
65318
|
+
annotations: ":annotations",
|
|
65319
|
+
tags: ":tags",
|
|
65320
|
+
sidecars: "per-directory",
|
|
65321
|
+
annotationTag: void 0
|
|
65256
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
|
+
}
|
|
65257
65343
|
function loadSettings(absRoot) {
|
|
65258
|
-
const file =
|
|
65259
|
-
if (!
|
|
65344
|
+
const file = path6.join(absRoot, ".yamlover", "settings.yamlover");
|
|
65345
|
+
if (!fs5.existsSync(file)) return DEFAULT_SETTINGS;
|
|
65260
65346
|
let root;
|
|
65261
65347
|
try {
|
|
65262
|
-
root = parseYamlover(
|
|
65348
|
+
root = parseYamlover(fs5.readFileSync(file, "utf8"), file).root;
|
|
65263
65349
|
} catch {
|
|
65264
65350
|
return DEFAULT_SETTINGS;
|
|
65265
65351
|
}
|
|
65266
65352
|
return {
|
|
65267
|
-
|
|
65268
|
-
|
|
65269
|
-
|
|
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)
|
|
65270
65359
|
};
|
|
65271
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
|
+
}
|
|
65272
65390
|
function sidecarLocation(v, dflt) {
|
|
65273
65391
|
const s2 = v !== void 0 && !isPointer(v) && v.kind === "scalar" && typeof v.value === "string" ? v.value.trim() : "";
|
|
65274
65392
|
if (s2 === "per-directory" || s2 === "document") return "per-directory";
|
|
@@ -65290,10 +65408,14 @@ function locationSetting(v, dflt) {
|
|
|
65290
65408
|
return dflt;
|
|
65291
65409
|
}
|
|
65292
65410
|
function pointerPath(p2) {
|
|
65293
|
-
|
|
65294
|
-
if (p2.
|
|
65295
|
-
|
|
65296
|
-
|
|
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;
|
|
65297
65419
|
return ":" + segs.join(":");
|
|
65298
65420
|
}
|
|
65299
65421
|
function stringPath(v, dflt) {
|
|
@@ -65307,9 +65429,11 @@ function stringPath(v, dflt) {
|
|
|
65307
65429
|
function parseQuery(text) {
|
|
65308
65430
|
let rest = text.trim();
|
|
65309
65431
|
let base = { scope: "current" };
|
|
65432
|
+
let world = false;
|
|
65310
65433
|
if (rest.startsWith(":::")) {
|
|
65311
65434
|
rest = rest.slice(3);
|
|
65312
65435
|
base = { scope: "link", authority: "" };
|
|
65436
|
+
world = true;
|
|
65313
65437
|
} else if (rest.startsWith("::")) {
|
|
65314
65438
|
rest = rest.slice(2);
|
|
65315
65439
|
base = { scope: "link", authority: "" };
|
|
@@ -65321,7 +65445,7 @@ function parseQuery(text) {
|
|
|
65321
65445
|
if (base.scope === "link") {
|
|
65322
65446
|
const auth = raws.shift();
|
|
65323
65447
|
if (auth === void 0 || auth === "") throw new SyntaxError(`query: "::" needs an authority in "${text}"`);
|
|
65324
|
-
base = { scope: "link", authority: keyName(auth) };
|
|
65448
|
+
base = { scope: "link", authority: keyName(auth), world };
|
|
65325
65449
|
} else if (base.scope === "current" && raws[0] === "..") {
|
|
65326
65450
|
base = { scope: "parent" };
|
|
65327
65451
|
raws.shift();
|
|
@@ -65475,6 +65599,7 @@ function keyName(portion) {
|
|
|
65475
65599
|
if (steps.length !== 1 || steps[0].sel !== "key") throw new SyntaxError(`query: bad name portion "${portion}"`);
|
|
65476
65600
|
return steps[0].name;
|
|
65477
65601
|
}
|
|
65602
|
+
var YAMLOVER_AUTHORITY3 = "yamlover.inthemoon.net";
|
|
65478
65603
|
function evalQuery(s2, text, from = ":") {
|
|
65479
65604
|
const q = parseQuery(text);
|
|
65480
65605
|
let binds;
|
|
@@ -65489,11 +65614,13 @@ function evalQuery(s2, text, from = ":") {
|
|
|
65489
65614
|
binds = [docRootOf(s2, from)];
|
|
65490
65615
|
break;
|
|
65491
65616
|
case "link": {
|
|
65492
|
-
|
|
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) {
|
|
65493
65620
|
binds = [":"];
|
|
65494
65621
|
break;
|
|
65495
65622
|
}
|
|
65496
|
-
const hit = childByKey(s2, ":",
|
|
65623
|
+
const hit = childByKey(s2, ":", authority);
|
|
65497
65624
|
binds = hit === null ? [] : [hit];
|
|
65498
65625
|
break;
|
|
65499
65626
|
}
|
|
@@ -65873,17 +66000,17 @@ var psdExtractor = {
|
|
|
65873
66000
|
};
|
|
65874
66001
|
|
|
65875
66002
|
// src/server/extract/wasm.ts
|
|
65876
|
-
import
|
|
65877
|
-
import
|
|
65878
|
-
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";
|
|
65879
66006
|
import { createRequire } from "node:module";
|
|
65880
66007
|
var require2 = createRequire(import.meta.url);
|
|
65881
66008
|
async function loadWasm(npmSpecifier, prodFile) {
|
|
65882
66009
|
let bytes;
|
|
65883
66010
|
try {
|
|
65884
|
-
bytes =
|
|
66011
|
+
bytes = fs8.readFileSync(require2.resolve(npmSpecifier));
|
|
65885
66012
|
} catch {
|
|
65886
|
-
bytes =
|
|
66013
|
+
bytes = fs8.readFileSync(path8.join(path8.dirname(fileURLToPath2(import.meta.url)), "wasm", prodFile));
|
|
65887
66014
|
}
|
|
65888
66015
|
return WebAssembly.compile(new Uint8Array(bytes));
|
|
65889
66016
|
}
|
|
@@ -65951,8 +66078,8 @@ async function renderThumbnail(bytes, format, w, h) {
|
|
|
65951
66078
|
|
|
65952
66079
|
// src/server/gitignore.ts
|
|
65953
66080
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
65954
|
-
import
|
|
65955
|
-
import
|
|
66081
|
+
import fs9 from "node:fs";
|
|
66082
|
+
import path9 from "node:path";
|
|
65956
66083
|
function buildGitIgnore(dataRoot) {
|
|
65957
66084
|
const gitRoot = findGitRoot(dataRoot) ?? dataRoot;
|
|
65958
66085
|
const cache = /* @__PURE__ */ new Map();
|
|
@@ -65960,8 +66087,8 @@ function buildGitIgnore(dataRoot) {
|
|
|
65960
66087
|
if (!cache.has(dir)) {
|
|
65961
66088
|
let ig = null;
|
|
65962
66089
|
try {
|
|
65963
|
-
const gi =
|
|
65964
|
-
if (
|
|
66090
|
+
const gi = path9.join(dir, ".gitignore");
|
|
66091
|
+
if (fs9.statSync(gi).isFile()) ig = (0, import_ignore.default)().add(fs9.readFileSync(gi, "utf-8"));
|
|
65965
66092
|
} catch {
|
|
65966
66093
|
}
|
|
65967
66094
|
cache.set(dir, ig);
|
|
@@ -65969,25 +66096,25 @@ function buildGitIgnore(dataRoot) {
|
|
|
65969
66096
|
return cache.get(dir);
|
|
65970
66097
|
};
|
|
65971
66098
|
return (absPath) => {
|
|
65972
|
-
const fromRoot =
|
|
65973
|
-
if (fromRoot === ".git" || fromRoot.startsWith(".git" +
|
|
66099
|
+
const fromRoot = path9.relative(gitRoot, absPath);
|
|
66100
|
+
if (fromRoot === ".git" || fromRoot.startsWith(".git" + path9.sep)) return true;
|
|
65974
66101
|
let isDir = false;
|
|
65975
66102
|
try {
|
|
65976
|
-
isDir =
|
|
66103
|
+
isDir = fs9.statSync(absPath).isDirectory();
|
|
65977
66104
|
} catch {
|
|
65978
66105
|
}
|
|
65979
|
-
const rel =
|
|
65980
|
-
const segs = rel === "" ? [] : rel.split(
|
|
66106
|
+
const rel = path9.relative(gitRoot, path9.dirname(absPath));
|
|
66107
|
+
const segs = rel === "" ? [] : rel.split(path9.sep);
|
|
65981
66108
|
let dir = gitRoot;
|
|
65982
66109
|
const dirs = [gitRoot];
|
|
65983
66110
|
for (const s2 of segs) {
|
|
65984
|
-
dir =
|
|
66111
|
+
dir = path9.join(dir, s2);
|
|
65985
66112
|
dirs.push(dir);
|
|
65986
66113
|
}
|
|
65987
66114
|
for (const d of dirs) {
|
|
65988
66115
|
const ig = matcherFor(d);
|
|
65989
66116
|
if (!ig) continue;
|
|
65990
|
-
const relToDir =
|
|
66117
|
+
const relToDir = path9.relative(d, absPath);
|
|
65991
66118
|
if (!relToDir) continue;
|
|
65992
66119
|
if (ig.ignores(relToDir) || isDir && ig.ignores(relToDir + "/")) return true;
|
|
65993
66120
|
}
|
|
@@ -65995,15 +66122,15 @@ function buildGitIgnore(dataRoot) {
|
|
|
65995
66122
|
};
|
|
65996
66123
|
}
|
|
65997
66124
|
function findGitRoot(start) {
|
|
65998
|
-
let dir =
|
|
66125
|
+
let dir = path9.resolve(start);
|
|
65999
66126
|
try {
|
|
66000
|
-
if (!
|
|
66127
|
+
if (!fs9.statSync(dir).isDirectory()) dir = path9.dirname(dir);
|
|
66001
66128
|
} catch {
|
|
66002
66129
|
return null;
|
|
66003
66130
|
}
|
|
66004
66131
|
for (; ; ) {
|
|
66005
|
-
if (
|
|
66006
|
-
const parent =
|
|
66132
|
+
if (fs9.existsSync(path9.join(dir, ".git"))) return dir;
|
|
66133
|
+
const parent = path9.dirname(dir);
|
|
66007
66134
|
if (parent === dir) return null;
|
|
66008
66135
|
dir = parent;
|
|
66009
66136
|
}
|
|
@@ -66100,11 +66227,20 @@ var LINK_KEY = "$yamloverLink";
|
|
|
66100
66227
|
var BINARY_KEY = "$yamloverBinary";
|
|
66101
66228
|
var MIXED_KEY = "$yamloverMixed";
|
|
66102
66229
|
function createHandlers(dataRoot, opts = {}) {
|
|
66103
|
-
const rootName =
|
|
66104
|
-
const dbPath =
|
|
66105
|
-
const
|
|
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);
|
|
66106
66242
|
const ignore2 = opts.gitignore === false ? void 0 : buildGitIgnore(dataRoot);
|
|
66107
|
-
|
|
66243
|
+
fs10.mkdirSync(path10.dirname(dbPath), { recursive: true });
|
|
66108
66244
|
const store0 = new Store(dbPath);
|
|
66109
66245
|
const store = () => store0;
|
|
66110
66246
|
let cachedDoc = null;
|
|
@@ -66181,7 +66317,7 @@ function createHandlers(dataRoot, opts = {}) {
|
|
|
66181
66317
|
const next = pending[0];
|
|
66182
66318
|
const total = done + pending.length;
|
|
66183
66319
|
h.progress(done, total, next.path);
|
|
66184
|
-
const abs =
|
|
66320
|
+
const abs = path10.join(dataRoot, ...next.path.split("/"));
|
|
66185
66321
|
let hash = null;
|
|
66186
66322
|
try {
|
|
66187
66323
|
hash = await hashFileAsync(abs, (bytes) => {
|
|
@@ -66189,7 +66325,7 @@ function createHandlers(dataRoot, opts = {}) {
|
|
|
66189
66325
|
});
|
|
66190
66326
|
} catch {
|
|
66191
66327
|
}
|
|
66192
|
-
const st = hash !== null ?
|
|
66328
|
+
const st = hash !== null ? fs10.statSync(abs, { throwIfNoEntry: false }) : void 0;
|
|
66193
66329
|
const fresh = st !== void 0 && st.size === next.size && st.mtimeMs === next.mtimeMs;
|
|
66194
66330
|
const ok = hash !== null && fresh && !closed ? await enqueue(() => store0.setFileHash(next.path, hash, next.size, next.mtimeMs)) : false;
|
|
66195
66331
|
if (!ok) {
|
|
@@ -66220,7 +66356,7 @@ function createHandlers(dataRoot, opts = {}) {
|
|
|
66220
66356
|
};
|
|
66221
66357
|
const doReindexFile = async (absFile) => {
|
|
66222
66358
|
if (cachedDoc) {
|
|
66223
|
-
const rel =
|
|
66359
|
+
const rel = path10.relative(dataRoot, absFile).split(path10.sep).join("/");
|
|
66224
66360
|
try {
|
|
66225
66361
|
const res = await reindexPathAsync(store0, dataRoot, cachedDoc, rel, { ignore: ignore2 });
|
|
66226
66362
|
if (res) {
|
|
@@ -66349,7 +66485,7 @@ function createHandlers(dataRoot, opts = {}) {
|
|
|
66349
66485
|
(data) => enqueue(async () => {
|
|
66350
66486
|
const f2 = data;
|
|
66351
66487
|
if (!f2?.selector || typeof f2.selector !== "object") throw new Error("a fragment needs a selector");
|
|
66352
|
-
const made = embedFragment(dataRoot, s2, settings.sidecars
|
|
66488
|
+
const made = embedFragment(dataRoot, s2, settings.sidecars, f2);
|
|
66353
66489
|
broadcast(await doReindex());
|
|
66354
66490
|
scheduleHasher();
|
|
66355
66491
|
return made;
|
|
@@ -66372,7 +66508,7 @@ function createHandlers(dataRoot, opts = {}) {
|
|
|
66372
66508
|
(data) => enqueue(async () => {
|
|
66373
66509
|
const name = String(data?.name ?? "").trim();
|
|
66374
66510
|
if (!name) throw new Error("tag needs a non-empty name");
|
|
66375
|
-
const segs2 = [...strToSegs(settings.tags
|
|
66511
|
+
const segs2 = [...strToSegs(settings.tags), name];
|
|
66376
66512
|
const tagPath = segsToStr(segs2);
|
|
66377
66513
|
const existing = s2.node(storePath(segs2));
|
|
66378
66514
|
if (existing) {
|
|
@@ -66380,8 +66516,8 @@ function createHandlers(dataRoot, opts = {}) {
|
|
|
66380
66516
|
const color = s2.node(storePath(segs2) + ":color")?.value;
|
|
66381
66517
|
return { path: tagPath, name, color: typeof color === "string" ? color : null, created: false };
|
|
66382
66518
|
}
|
|
66383
|
-
const written = writeTag(dataRoot, settings.tags
|
|
66384
|
-
s2.addTag(storePath(strToSegs(settings.tags
|
|
66519
|
+
const written = writeTag(dataRoot, settings.tags, name);
|
|
66520
|
+
s2.addTag(storePath(strToSegs(settings.tags)), name, written.pos, written.node);
|
|
66385
66521
|
if (s2.node(storePath(segs2))?.format !== TAG_FORMAT) throw new Error(`the created tag did not index as a tag: ${tagPath}`);
|
|
66386
66522
|
announce(written.createdFile ? { added: [written.file] } : { changed: [written.file] });
|
|
66387
66523
|
return { path: tagPath, name, color: null, created: true };
|
|
@@ -66395,9 +66531,9 @@ function createHandlers(dataRoot, opts = {}) {
|
|
|
66395
66531
|
const b = data;
|
|
66396
66532
|
const cols = Array.isArray(b?.columns) ? b.columns.map((lane) => Array.isArray(lane) ? lane.map((p3) => String(p3)) : []) : [];
|
|
66397
66533
|
const { bodyFile } = hostFor(dataRoot, s2, strToSegs(b?.path || ":"));
|
|
66398
|
-
|
|
66399
|
-
const src =
|
|
66400
|
-
|
|
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));
|
|
66401
66537
|
broadcast(await doReindex());
|
|
66402
66538
|
scheduleHasher();
|
|
66403
66539
|
return { ok: true };
|
|
@@ -66434,6 +66570,65 @@ function createHandlers(dataRoot, opts = {}) {
|
|
|
66434
66570
|
).then((body) => sendJson(res, 200, body)).catch((e3) => sendJson(res, 400, { error: String(e3.message || e3) }));
|
|
66435
66571
|
return;
|
|
66436
66572
|
}
|
|
66573
|
+
if (req.method === "POST" && url.pathname === "/api/agent-docs") {
|
|
66574
|
+
readBody(req).then(
|
|
66575
|
+
(data) => enqueue(async () => {
|
|
66576
|
+
const overwrite = !!data?.overwrite;
|
|
66577
|
+
const files = [];
|
|
66578
|
+
let wrote = false;
|
|
66579
|
+
for (const doc of loadAgentDocs()) {
|
|
66580
|
+
const exists = fs10.existsSync(path10.resolve(dataRoot, doc.name));
|
|
66581
|
+
if (exists && !overwrite) {
|
|
66582
|
+
files.push({ name: doc.name, status: "exists" });
|
|
66583
|
+
continue;
|
|
66584
|
+
}
|
|
66585
|
+
writeInside(dataRoot, dataRoot, doc.name, Buffer.from(doc.content, "utf8"));
|
|
66586
|
+
files.push({ name: doc.name, status: exists ? "overwritten" : "created" });
|
|
66587
|
+
wrote = true;
|
|
66588
|
+
}
|
|
66589
|
+
if (wrote) {
|
|
66590
|
+
broadcast(await doReindex());
|
|
66591
|
+
scheduleHasher();
|
|
66592
|
+
}
|
|
66593
|
+
return { files };
|
|
66594
|
+
})
|
|
66595
|
+
).then((body) => sendJson(res, 201, body)).catch((e3) => sendJson(res, 400, { error: String(e3.message || e3) }));
|
|
66596
|
+
return;
|
|
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
|
+
}
|
|
66437
66632
|
const segs = strToSegs(url.searchParams.get("path") || ":");
|
|
66438
66633
|
const p2 = storePath(segs);
|
|
66439
66634
|
const depth = parseDepth(url.searchParams.get("depth"));
|
|
@@ -66459,37 +66654,37 @@ function createHandlers(dataRoot, opts = {}) {
|
|
|
66459
66654
|
return;
|
|
66460
66655
|
}
|
|
66461
66656
|
if (url.pathname === "/api/blob") {
|
|
66462
|
-
const file =
|
|
66463
|
-
if (!
|
|
66657
|
+
const file = path10.join(dataRoot, ...segs.map(String));
|
|
66658
|
+
if (!fs10.existsSync(file) || fs10.statSync(file).isDirectory()) return notFound(res, url);
|
|
66464
66659
|
res.statusCode = 200;
|
|
66465
66660
|
res.setHeader("Content-Type", s2.node(p2)?.format ?? formatFromExt(file) ?? "application/octet-stream");
|
|
66466
|
-
res.setHeader("Content-Length", String(
|
|
66467
|
-
const stream =
|
|
66661
|
+
res.setHeader("Content-Length", String(fs10.statSync(file).size));
|
|
66662
|
+
const stream = fs10.createReadStream(file);
|
|
66468
66663
|
stream.on("error", () => res.destroy());
|
|
66469
66664
|
stream.pipe(res);
|
|
66470
66665
|
return;
|
|
66471
66666
|
}
|
|
66472
66667
|
if (url.pathname === "/api/thumb") {
|
|
66473
66668
|
const sourceRow = s2.node(p2);
|
|
66474
|
-
const sourceAbs =
|
|
66475
|
-
if (!sourceRow || !
|
|
66669
|
+
const sourceAbs = path10.join(dataRoot, ...segs.map(String));
|
|
66670
|
+
if (!sourceRow || !fs10.existsSync(sourceAbs) || fs10.statSync(sourceAbs).isDirectory()) return notFound(res, url);
|
|
66476
66671
|
const w = clampThumbDim(url.searchParams.get("w"), 256);
|
|
66477
66672
|
const h = clampThumbDim(url.searchParams.get("h"), w);
|
|
66478
66673
|
const serve = (file) => {
|
|
66479
66674
|
res.statusCode = 200;
|
|
66480
66675
|
res.setHeader("Content-Type", "image/jpeg");
|
|
66481
|
-
res.setHeader("Content-Length", String(
|
|
66676
|
+
res.setHeader("Content-Length", String(fs10.statSync(file).size));
|
|
66482
66677
|
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
|
|
66483
|
-
const stream =
|
|
66678
|
+
const stream = fs10.createReadStream(file);
|
|
66484
66679
|
stream.on("error", () => res.destroy());
|
|
66485
66680
|
stream.pipe(res);
|
|
66486
66681
|
};
|
|
66487
|
-
const ready2 = existingThumb(dataRoot, s2, settings.sidecars
|
|
66682
|
+
const ready2 = existingThumb(dataRoot, s2, settings.sidecars, segs, sourceRow, w, h);
|
|
66488
66683
|
if (ready2) return serve(ready2);
|
|
66489
66684
|
thumbBegin();
|
|
66490
66685
|
enqueue(async () => {
|
|
66491
66686
|
thumbTask?.progress(thumbDone, thumbTotal, String(segs[segs.length - 1] ?? ""));
|
|
66492
|
-
const made = await ensureThumbnail(dataRoot, s2, settings.sidecars
|
|
66687
|
+
const made = await ensureThumbnail(dataRoot, s2, settings.sidecars, segs, sourceRow, w, h);
|
|
66493
66688
|
if (made) broadcast(await doReindex());
|
|
66494
66689
|
return made;
|
|
66495
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());
|
|
@@ -66543,26 +66738,26 @@ var JSON_EXT = { ".json": "json", ".json5": "json5", ".json5p": "json5p" };
|
|
|
66543
66738
|
function concreteOf(dataRoot, segs, row) {
|
|
66544
66739
|
const last = segs[segs.length - 1];
|
|
66545
66740
|
if (typeof last === "string") {
|
|
66546
|
-
const json = JSON_EXT[
|
|
66741
|
+
const json = JSON_EXT[path10.extname(last).toLowerCase()];
|
|
66547
66742
|
if (json) {
|
|
66548
|
-
const abs2 =
|
|
66743
|
+
const abs2 = path10.resolve(dataRoot, ...segs.map(String));
|
|
66549
66744
|
try {
|
|
66550
|
-
if (
|
|
66745
|
+
if (fs10.statSync(abs2).isFile()) return json;
|
|
66551
66746
|
} catch {
|
|
66552
66747
|
}
|
|
66553
66748
|
}
|
|
66554
66749
|
}
|
|
66555
66750
|
if (row.type !== "mapping") return null;
|
|
66556
66751
|
if (segs.some((g) => typeof g === "number")) return null;
|
|
66557
|
-
const abs =
|
|
66752
|
+
const abs = path10.resolve(dataRoot, ...segs.map(String));
|
|
66558
66753
|
let st;
|
|
66559
66754
|
try {
|
|
66560
|
-
st =
|
|
66755
|
+
st = fs10.statSync(abs);
|
|
66561
66756
|
} catch {
|
|
66562
66757
|
return null;
|
|
66563
66758
|
}
|
|
66564
66759
|
if (!st.isDirectory()) return null;
|
|
66565
|
-
return
|
|
66760
|
+
return fs10.existsSync(path10.join(abs, ".yamlover")) ? "yamlover" : "dir";
|
|
66566
66761
|
}
|
|
66567
66762
|
var relKey = (label, other) => `${label ?? ""}\0${other}`;
|
|
66568
66763
|
var isHidden = (s2, to2) => !!s2.node(to2)?.meta?.hidden;
|
|
@@ -66693,8 +66888,8 @@ function buildRelations(dataRoot, s2, segs) {
|
|
|
66693
66888
|
return out;
|
|
66694
66889
|
}
|
|
66695
66890
|
function binaryContent(dataRoot, segs, row) {
|
|
66696
|
-
const file =
|
|
66697
|
-
const bytes =
|
|
66891
|
+
const file = path10.join(dataRoot, ...segs.map(String));
|
|
66892
|
+
const bytes = fs10.existsSync(file) ? fs10.readFileSync(file) : Buffer.alloc(0);
|
|
66698
66893
|
return { [BINARY_KEY]: { format: row.format ?? null, size: row.size ?? bytes.length, base64: bytes.toString("base64") } };
|
|
66699
66894
|
}
|
|
66700
66895
|
function buildTree(dataRoot, s2, segs, label, depth) {
|
|
@@ -66823,12 +67018,12 @@ function writeBoardColumns(src, cols) {
|
|
|
66823
67018
|
return lines.join("\n") + "\n";
|
|
66824
67019
|
}
|
|
66825
67020
|
function sidecarTarget(dataRoot, mode, subdir, bodyFile) {
|
|
66826
|
-
const dirOverlay = bodyFile.endsWith(
|
|
67021
|
+
const dirOverlay = bodyFile.endsWith(path10.join(".yamlover", "body.yamlover"));
|
|
66827
67022
|
if (mode === "per-directory" && dirOverlay) {
|
|
66828
|
-
const fileDir =
|
|
66829
|
-
return { dir:
|
|
67023
|
+
const fileDir = path10.dirname(path10.dirname(bodyFile));
|
|
67024
|
+
return { dir: path10.join(fileDir, ".yamlover", subdir), scope: "document" };
|
|
66830
67025
|
}
|
|
66831
|
-
return { dir:
|
|
67026
|
+
return { dir: path10.join(dataRoot, ".yamlover", subdir), scope: "project" };
|
|
66832
67027
|
}
|
|
66833
67028
|
function sidecarPointerRaw(subdir, name, scope) {
|
|
66834
67029
|
const body = [".yamlover", subdir, name].map(colonSegment).join(":");
|
|
@@ -66840,24 +67035,24 @@ function yScalar(v) {
|
|
|
66840
67035
|
function hostFor(dataRoot, s2, segs) {
|
|
66841
67036
|
for (let i2 = segs.length; i2 >= 0; i2--) {
|
|
66842
67037
|
const sub = segs.slice(0, i2);
|
|
66843
|
-
const abs =
|
|
67038
|
+
const abs = path10.resolve(dataRoot, ...sub.map(String));
|
|
66844
67039
|
let st;
|
|
66845
67040
|
try {
|
|
66846
|
-
st =
|
|
67041
|
+
st = fs10.statSync(abs);
|
|
66847
67042
|
} catch {
|
|
66848
67043
|
continue;
|
|
66849
67044
|
}
|
|
66850
|
-
if (st.isDirectory()) return { bodyFile:
|
|
67045
|
+
if (st.isDirectory()) return { bodyFile: path10.join(abs, ".yamlover", "body.yamlover"), within: segs.slice(i2).map(String) };
|
|
66851
67046
|
if (st.isFile()) {
|
|
66852
67047
|
const node = s2.node(storePath(sub));
|
|
66853
67048
|
if (node?.meta?.documentRoot && node.type === "mapping" && !node.is_array) {
|
|
66854
67049
|
return { bodyFile: abs, within: segs.slice(i2).map(String) };
|
|
66855
67050
|
}
|
|
66856
|
-
const dir =
|
|
66857
|
-
return { bodyFile:
|
|
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) };
|
|
66858
67053
|
}
|
|
66859
67054
|
}
|
|
66860
|
-
return { bodyFile:
|
|
67055
|
+
return { bodyFile: path10.join(dataRoot, ".yamlover", "body.yamlover"), within: segs.map(String) };
|
|
66861
67056
|
}
|
|
66862
67057
|
function annotationItemLines(a2, indent) {
|
|
66863
67058
|
const pad = " ".repeat(indent);
|
|
@@ -66878,9 +67073,9 @@ function fragmentBlockLines(slug, selector, imagePtr, indent) {
|
|
|
66878
67073
|
}
|
|
66879
67074
|
function embedAnnotation(dataRoot, s2, a2) {
|
|
66880
67075
|
const { bodyFile, within } = hostFor(dataRoot, s2, strToSegs(a2.target || ":"));
|
|
66881
|
-
|
|
66882
|
-
const src =
|
|
66883
|
-
|
|
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)));
|
|
66884
67079
|
return bodyFile;
|
|
66885
67080
|
}
|
|
66886
67081
|
function embedFragment(dataRoot, s2, mode, f2) {
|
|
@@ -66892,15 +67087,15 @@ function embedFragment(dataRoot, s2, mode, f2) {
|
|
|
66892
67087
|
const bytes = Buffer.from(String(f2.imageBase64).replace(/^data:[^,]*,/, ""), "base64");
|
|
66893
67088
|
if (bytes.length > 0) {
|
|
66894
67089
|
const { dir, scope } = sidecarTarget(dataRoot, mode, CROP_SUBDIR, bodyFile);
|
|
66895
|
-
|
|
67090
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
66896
67091
|
const cropName = `${slug}.png`;
|
|
66897
67092
|
writeInside(dataRoot, dir, cropName, bytes);
|
|
66898
67093
|
imagePtr = pointerToken(sidecarPointerRaw(CROP_SUBDIR, cropName, scope));
|
|
66899
67094
|
}
|
|
66900
67095
|
}
|
|
66901
|
-
|
|
66902
|
-
const src =
|
|
66903
|
-
|
|
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)));
|
|
66904
67099
|
return { slug, fragmentPath: segsToStr([...segs, FRAG_KEY, slug]) };
|
|
66905
67100
|
}
|
|
66906
67101
|
var thumbResKey = (w, h) => `[${w}, ${h}]`;
|
|
@@ -66909,50 +67104,50 @@ function existingThumb(dataRoot, s2, mode, segs, row, w, h) {
|
|
|
66909
67104
|
if (!row.content_hash) return null;
|
|
66910
67105
|
const { bodyFile } = hostFor(dataRoot, s2, segs);
|
|
66911
67106
|
const { dir } = sidecarTarget(dataRoot, mode, THUMB_SUBDIR, bodyFile);
|
|
66912
|
-
const abs =
|
|
66913
|
-
return
|
|
67107
|
+
const abs = path10.join(dir, thumbName(row.content_hash, w, h));
|
|
67108
|
+
return fs10.existsSync(abs) ? abs : null;
|
|
66914
67109
|
}
|
|
66915
67110
|
function embedThumbnail(dataRoot, s2, mode, segs, w, h, name) {
|
|
66916
67111
|
const { bodyFile, within } = hostFor(dataRoot, s2, segs);
|
|
66917
67112
|
const { scope } = sidecarTarget(dataRoot, mode, THUMB_SUBDIR, bodyFile);
|
|
66918
|
-
|
|
66919
|
-
const src =
|
|
67113
|
+
fs10.mkdirSync(path10.dirname(bodyFile), { recursive: true });
|
|
67114
|
+
const src = fs10.existsSync(bodyFile) ? fs10.readFileSync(bodyFile, "utf8") : "";
|
|
66920
67115
|
const ptr = pointerToken(sidecarPointerRaw(THUMB_SUBDIR, name, scope));
|
|
66921
67116
|
const key = thumbResKey(w, h);
|
|
66922
|
-
|
|
67117
|
+
fs10.writeFileSync(bodyFile, upsertThumbnail(src, within, key, (indent) => [`${" ".repeat(indent)}${key}: ${ptr}`]));
|
|
66923
67118
|
}
|
|
66924
67119
|
async function ensureThumbnail(dataRoot, s2, mode, segs, row, w, h) {
|
|
66925
|
-
const sourceAbs =
|
|
67120
|
+
const sourceAbs = path10.join(dataRoot, ...segs.map(String));
|
|
66926
67121
|
const hash = row.content_hash ?? await hashFileAsync(sourceAbs);
|
|
66927
67122
|
const name = thumbName(hash, w, h);
|
|
66928
67123
|
const { bodyFile } = hostFor(dataRoot, s2, segs);
|
|
66929
67124
|
const { dir } = sidecarTarget(dataRoot, mode, THUMB_SUBDIR, bodyFile);
|
|
66930
|
-
const abs =
|
|
66931
|
-
if (
|
|
66932
|
-
const thumb = await renderThumbnail(
|
|
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);
|
|
66933
67128
|
if (!thumb) return null;
|
|
66934
|
-
|
|
67129
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
66935
67130
|
writeInside(dataRoot, dir, name, thumb.buf);
|
|
66936
67131
|
embedThumbnail(dataRoot, s2, mode, segs, w, h, name);
|
|
66937
67132
|
return abs;
|
|
66938
67133
|
}
|
|
66939
67134
|
function unembedAnnotation(dataRoot, s2, target, tag) {
|
|
66940
67135
|
const { bodyFile, within } = hostFor(dataRoot, s2, strToSegs(target || ":"));
|
|
66941
|
-
if (!
|
|
67136
|
+
if (!fs10.existsSync(bodyFile)) return bodyFile;
|
|
66942
67137
|
const needlePath = ":" + pointerRaw(tag).replace(/^:+/, "");
|
|
66943
|
-
const src =
|
|
66944
|
-
|
|
67138
|
+
const src = fs10.readFileSync(bodyFile, "utf8");
|
|
67139
|
+
fs10.writeFileSync(bodyFile, removeAnnotation(src, within, (itemText) => itemText.replace(/\s+/g, "").includes(needlePath)));
|
|
66945
67140
|
return bodyFile;
|
|
66946
67141
|
}
|
|
66947
67142
|
function writeTag(dataRoot, location, name) {
|
|
66948
67143
|
if (/[/\\\r\n:]/.test(name)) throw new Error("a tag name cannot contain '/', '\\', ':' or line breaks");
|
|
66949
|
-
const root =
|
|
66950
|
-
const dir =
|
|
66951
|
-
if (!dir.startsWith(root +
|
|
66952
|
-
const file =
|
|
66953
|
-
const createdFile = !
|
|
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);
|
|
66954
67149
|
const head = "# Named tags created from the annotation picker (settings.yamlover: tags.location).\n";
|
|
66955
|
-
const existing = createdFile ? head :
|
|
67150
|
+
const existing = createdFile ? head : fs10.readFileSync(file, "utf8");
|
|
66956
67151
|
const body = (existing === "" || existing.endsWith("\n") ? existing : existing + "\n") + `${name}: !!<*::yamlover:$defs:tag>
|
|
66957
67152
|
`;
|
|
66958
67153
|
const entries = parseYamlover(body, file).root.entries ?? [];
|
|
@@ -66961,8 +67156,8 @@ function writeTag(dataRoot, location, name) {
|
|
|
66961
67156
|
if (!entry || isPointer(entry.value) || entry.value.meta?.schema === void 0) {
|
|
66962
67157
|
throw new Error(`cannot write a tag named ${JSON.stringify(name)}`);
|
|
66963
67158
|
}
|
|
66964
|
-
|
|
66965
|
-
|
|
67159
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
67160
|
+
fs10.writeFileSync(file, body);
|
|
66966
67161
|
return { node: entry.value, pos, file: [...strToSegs(location).map(String), ".yamlover", "body.yamlover"].join("/"), createdFile };
|
|
66967
67162
|
}
|
|
66968
67163
|
function handlePaste(dataRoot, s2, input) {
|
|
@@ -66986,7 +67181,7 @@ function handlePaste(dataRoot, s2, input) {
|
|
|
66986
67181
|
if (row.format === "x-yamlover-chapter") return pasteIntoChapter(dataRoot, s2, segs, name, bytes);
|
|
66987
67182
|
const dirSegs = nearestDirSegs(dataRoot, segs);
|
|
66988
67183
|
if (!dirSegs) throw new Error("no enclosing directory to paste into");
|
|
66989
|
-
const dir =
|
|
67184
|
+
const dir = path10.resolve(dataRoot, ...dirSegs.map(String));
|
|
66990
67185
|
const final = uniqueName(dir, name);
|
|
66991
67186
|
writeInside(dataRoot, dir, final, bytes);
|
|
66992
67187
|
return { path: segsToStr([...dirSegs, final]), dir: segsToStr(dirSegs), open: dirSegs.length !== segs.length };
|
|
@@ -66994,17 +67189,17 @@ function handlePaste(dataRoot, s2, input) {
|
|
|
66994
67189
|
function nearestDirSegs(dataRoot, segs) {
|
|
66995
67190
|
for (let i2 = segs.length; i2 >= 0; i2--) {
|
|
66996
67191
|
const sub = segs.slice(0, i2);
|
|
66997
|
-
const abs =
|
|
66998
|
-
if (
|
|
67192
|
+
const abs = path10.resolve(dataRoot, ...sub.map(String));
|
|
67193
|
+
if (fs10.existsSync(abs) && fs10.statSync(abs).isDirectory()) return sub;
|
|
66999
67194
|
}
|
|
67000
67195
|
return null;
|
|
67001
67196
|
}
|
|
67002
67197
|
function chapterSource(dataRoot, s2, segs) {
|
|
67003
67198
|
const docSegs = documentRootSegs(s2, segs);
|
|
67004
|
-
const docFs =
|
|
67005
|
-
const dirBacked =
|
|
67006
|
-
const bodyFile = dirBacked ?
|
|
67007
|
-
if (!bodyFile.endsWith(".yamlover") || !
|
|
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)) {
|
|
67008
67203
|
throw new Error("unsupported chapter source (need a .yamlover body)");
|
|
67009
67204
|
}
|
|
67010
67205
|
return { docSegs, bodyFile, dirBacked };
|
|
@@ -67012,27 +67207,27 @@ function chapterSource(dataRoot, s2, segs) {
|
|
|
67012
67207
|
function pasteIntoChapter(dataRoot, s2, segs, name, bytes) {
|
|
67013
67208
|
const { docSegs, bodyFile, dirBacked } = chapterSource(dataRoot, s2, segs);
|
|
67014
67209
|
const writeDirSegs = dirBacked ? docSegs : docSegs.slice(0, -1);
|
|
67015
|
-
const writeDir =
|
|
67210
|
+
const writeDir = path10.resolve(dataRoot, ...writeDirSegs.map(String));
|
|
67016
67211
|
const final = uniqueName(writeDir, name);
|
|
67017
67212
|
writeInside(dataRoot, writeDir, final, bytes);
|
|
67018
67213
|
const fileSegs = [...writeDirSegs, final];
|
|
67019
67214
|
const pointer = dirBacked ? `*/${final}` : `*/${segsToStr(fileSegs)}`;
|
|
67020
67215
|
const within = segs.slice(docSegs.length);
|
|
67021
|
-
const src =
|
|
67022
|
-
|
|
67216
|
+
const src = fs10.readFileSync(bodyFile, "utf8");
|
|
67217
|
+
fs10.writeFileSync(bodyFile, appendToList(src, within, "chunks", (indent) => [`${" ".repeat(indent)}- ${pointer}`]));
|
|
67023
67218
|
return { path: segsToStr(fileSegs), chapter: segsToStr(segs), pointer };
|
|
67024
67219
|
}
|
|
67025
67220
|
function pasteTextIntoChapter(dataRoot, s2, segs, text) {
|
|
67026
67221
|
const { docSegs, bodyFile } = chapterSource(dataRoot, s2, segs);
|
|
67027
67222
|
const within = segs.slice(docSegs.length);
|
|
67028
|
-
const src =
|
|
67029
|
-
|
|
67223
|
+
const src = fs10.readFileSync(bodyFile, "utf8");
|
|
67224
|
+
fs10.writeFileSync(bodyFile, appendToList(src, within, "chunks", (indent) => textChunkLines(text, indent)));
|
|
67030
67225
|
return { path: segsToStr(segs), chapter: segsToStr(segs) };
|
|
67031
67226
|
}
|
|
67032
67227
|
function pasteTextAsChapterFile(dataRoot, segs, text) {
|
|
67033
67228
|
const dirSegs = nearestDirSegs(dataRoot, segs);
|
|
67034
67229
|
if (!dirSegs) throw new Error("no enclosing directory to paste into");
|
|
67035
|
-
const dir =
|
|
67230
|
+
const dir = path10.resolve(dataRoot, ...dirSegs.map(String));
|
|
67036
67231
|
const title = titleFromText(text);
|
|
67037
67232
|
const final = uniqueName(dir, chapterFileName(title));
|
|
67038
67233
|
const src = ["!!<*::yamlover:$defs:chapter>", `title: ${JSON.stringify(title)}`, "chunks:", ...textChunkLines(text, 0), ""].join("\n");
|
|
@@ -67079,7 +67274,7 @@ function richChildLines(node, indent, pointerFor) {
|
|
|
67079
67274
|
function pasteRichIntoChapter(dataRoot, s2, segs, rich) {
|
|
67080
67275
|
const { docSegs, bodyFile, dirBacked } = chapterSource(dataRoot, s2, segs);
|
|
67081
67276
|
const writeDirSegs = dirBacked ? docSegs : docSegs.slice(0, -1);
|
|
67082
|
-
const writeDir =
|
|
67277
|
+
const writeDir = path10.resolve(dataRoot, ...writeDirSegs.map(String));
|
|
67083
67278
|
const files = [];
|
|
67084
67279
|
const pointerFor = (name, bytes) => {
|
|
67085
67280
|
const final = uniqueName(writeDir, name);
|
|
@@ -67088,16 +67283,16 @@ function pasteRichIntoChapter(dataRoot, s2, segs, rich) {
|
|
|
67088
67283
|
return dirBacked ? `*/${final}` : `*/${segsToStr([...writeDirSegs, final])}`;
|
|
67089
67284
|
};
|
|
67090
67285
|
const within = segs.slice(docSegs.length);
|
|
67091
|
-
let src =
|
|
67286
|
+
let src = fs10.readFileSync(bodyFile, "utf8");
|
|
67092
67287
|
if (rich.chunks.length) src = appendToList(src, within, "chunks", (ind) => rich.chunks.flatMap((c3) => richItemLines(c3, ind, pointerFor)));
|
|
67093
67288
|
if (rich.children.length) src = appendToList(src, within, "children", (ind) => rich.children.flatMap((k) => richChildLines(k, ind, pointerFor)));
|
|
67094
|
-
|
|
67289
|
+
fs10.writeFileSync(bodyFile, src);
|
|
67095
67290
|
return { path: segsToStr(segs), chapter: segsToStr(segs), files };
|
|
67096
67291
|
}
|
|
67097
67292
|
function pasteRichAsChapter(dataRoot, segs, rich) {
|
|
67098
67293
|
const dirSegs = nearestDirSegs(dataRoot, segs);
|
|
67099
67294
|
if (!dirSegs) throw new Error("no enclosing directory to paste into");
|
|
67100
|
-
const dir =
|
|
67295
|
+
const dir = path10.resolve(dataRoot, ...dirSegs.map(String));
|
|
67101
67296
|
if (!rich.title && rich.chunks.length === 0 && rich.children.length === 1) rich = rich.children[0];
|
|
67102
67297
|
const firstText = rich.chunks.find((c3) => "text" in c3);
|
|
67103
67298
|
const title = rich.title ?? (firstText ? titleFromText(firstText.text) : rich.children[0]?.title ?? "Pasted content");
|
|
@@ -67110,16 +67305,16 @@ function pasteRichAsChapter(dataRoot, segs, rich) {
|
|
|
67110
67305
|
return { path: segsToStr([...dirSegs, final]), dir: segsToStr(dirSegs), open: dirSegs.length !== segs.length };
|
|
67111
67306
|
}
|
|
67112
67307
|
const name = uniqueName(dir, chapterFileName(title).replace(/\.yamlover$/, ""));
|
|
67113
|
-
const chDir =
|
|
67114
|
-
if (!
|
|
67115
|
-
|
|
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 });
|
|
67116
67311
|
const pointerFor = (fname, bytes) => {
|
|
67117
67312
|
const final = uniqueName(chDir, fname);
|
|
67118
67313
|
writeInside(dataRoot, chDir, final, bytes);
|
|
67119
67314
|
return `*/${final}`;
|
|
67120
67315
|
};
|
|
67121
67316
|
const src = renderChapterSource(title, rich, pointerFor);
|
|
67122
|
-
writeInside(dataRoot,
|
|
67317
|
+
writeInside(dataRoot, path10.join(chDir, ".yamlover"), "body.yamlover", Buffer.from(src, "utf8"));
|
|
67123
67318
|
return { path: segsToStr([...dirSegs, name]), dir: segsToStr(dirSegs), open: dirSegs.length !== segs.length };
|
|
67124
67319
|
}
|
|
67125
67320
|
function renderChapterSource(title, rich, pointerFor) {
|
|
@@ -67141,23 +67336,34 @@ function chapterFileName(title) {
|
|
|
67141
67336
|
return `${base || "pasted"}.yamlover`;
|
|
67142
67337
|
}
|
|
67143
67338
|
function sanitizeName(raw) {
|
|
67144
|
-
const base =
|
|
67339
|
+
const base = path10.basename(String(raw || "")).replace(/[^A-Za-z0-9._-]/g, "_").replace(/^\.+/, "");
|
|
67145
67340
|
return base || "pasted";
|
|
67146
67341
|
}
|
|
67147
67342
|
function uniqueName(dir, name) {
|
|
67148
|
-
if (!
|
|
67149
|
-
const ext =
|
|
67343
|
+
if (!fs10.existsSync(path10.join(dir, name))) return name;
|
|
67344
|
+
const ext = path10.extname(name);
|
|
67150
67345
|
const stem = name.slice(0, name.length - ext.length);
|
|
67151
67346
|
for (let i2 = 1; ; i2++) {
|
|
67152
67347
|
const cand = `${stem}-${i2}${ext}`;
|
|
67153
|
-
if (!
|
|
67348
|
+
if (!fs10.existsSync(path10.join(dir, cand))) return cand;
|
|
67154
67349
|
}
|
|
67155
67350
|
}
|
|
67156
67351
|
function writeInside(dataRoot, dir, name, bytes) {
|
|
67157
|
-
const root =
|
|
67158
|
-
const target =
|
|
67159
|
-
if (target !== root && !target.startsWith(root +
|
|
67160
|
-
|
|
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);
|
|
67356
|
+
}
|
|
67357
|
+
var AGENT_DOCS_DIR = path10.join(path10.dirname(fileURLToPath3(import.meta.url)), "agent-docs");
|
|
67358
|
+
function loadAgentDocs() {
|
|
67359
|
+
let names3;
|
|
67360
|
+
try {
|
|
67361
|
+
names3 = fs10.readdirSync(AGENT_DOCS_DIR).filter((f2) => f2.endsWith(".md")).sort();
|
|
67362
|
+
} catch {
|
|
67363
|
+
throw new Error(`agent-docs resources not found at ${AGENT_DOCS_DIR}`);
|
|
67364
|
+
}
|
|
67365
|
+
if (names3.length === 0) throw new Error(`no agent-docs resources at ${AGENT_DOCS_DIR}`);
|
|
67366
|
+
return names3.map((name) => ({ name, content: fs10.readFileSync(path10.join(AGENT_DOCS_DIR, name), "utf8") }));
|
|
67161
67367
|
}
|
|
67162
67368
|
var indentOf2 = (line) => {
|
|
67163
67369
|
let i2 = 0;
|
|
@@ -67324,7 +67530,7 @@ var EXT_CT = {
|
|
|
67324
67530
|
".epub": "application/epub+zip"
|
|
67325
67531
|
};
|
|
67326
67532
|
function formatFromExt(file) {
|
|
67327
|
-
return EXT_CT[
|
|
67533
|
+
return EXT_CT[path10.extname(file).toLowerCase()] ?? null;
|
|
67328
67534
|
}
|
|
67329
67535
|
function parseDepth(raw) {
|
|
67330
67536
|
if (raw == null || raw === "") return null;
|