frameboard 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1005 -246
- package/dist/client/assets/index-B1E2YE4_.css +2 -0
- package/dist/client/assets/index-jDJqKkpd.js +114 -0
- package/dist/client/index.html +2 -2
- package/package.json +14 -3
- package/dist/client/assets/index-BL6hzziB.css +0 -2
- package/dist/client/assets/index-BPHCKLmi.js +0 -114
package/dist/cli.js
CHANGED
|
@@ -7,14 +7,14 @@ import path, { basename, delimiter, dirname, extname, isAbsolute, join, relative
|
|
|
7
7
|
import fs, { copyFileSync, createReadStream, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
|
|
8
8
|
import process$1, { versions } from "node:process";
|
|
9
9
|
import { isDeepStrictEqual, promisify, stripVTControlCharacters } from "node:util";
|
|
10
|
-
import { constants, copyFile, cp, link, lstat, mkdir, open, readFile, readdir, readlink, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
10
|
+
import { constants, copyFile, cp, link, lstat, mkdir, mkdtemp, open, readFile, readdir, readlink, realpath, rename, rm, rmdir, stat, utimes, writeFile } from "node:fs/promises";
|
|
11
11
|
import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
12
12
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
13
|
-
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
14
14
|
import { STATUS_CODES, ServerResponse, createServer } from "node:http";
|
|
15
15
|
import { Http2ServerRequest, constants as constants$1 } from "node:http2";
|
|
16
16
|
import { Readable } from "node:stream";
|
|
17
|
-
import { homedir, release, type } from "node:os";
|
|
17
|
+
import { homedir, release, tmpdir, type } from "node:os";
|
|
18
18
|
// \0rolldown/runtime.js
|
|
19
19
|
var __create = Object.create;
|
|
20
20
|
var __defProp = Object.defineProperty;
|
|
@@ -3049,7 +3049,12 @@ const EXIT_CODES = {
|
|
|
3049
3049
|
"dispatch-failed": 13,
|
|
3050
3050
|
"section-not-found": 3,
|
|
3051
3051
|
"reanchors-descendant": 7,
|
|
3052
|
-
"clipboard-unsupported": 3
|
|
3052
|
+
"clipboard-unsupported": 3,
|
|
3053
|
+
"frame-map-invalid": 5,
|
|
3054
|
+
"format-refused": 10,
|
|
3055
|
+
"formatter-not-found": 9,
|
|
3056
|
+
"references-stale": 14,
|
|
3057
|
+
"page-file-load": 10
|
|
3053
3058
|
};
|
|
3054
3059
|
var FrameboardError = class extends Error {
|
|
3055
3060
|
code;
|
|
@@ -9158,7 +9163,9 @@ const projectFileSchema = looseObject({
|
|
|
9158
9163
|
version: literal(1),
|
|
9159
9164
|
pages: array$1(string$1()),
|
|
9160
9165
|
createdAt: union([datetime(), unknown()]).optional(),
|
|
9161
|
-
checks: union([projectChecksSchema, unknown()]).optional()
|
|
9166
|
+
checks: union([projectChecksSchema, unknown()]).optional(),
|
|
9167
|
+
group: union([string$1(), unknown()]).optional(),
|
|
9168
|
+
archived: union([boolean$1(), unknown()]).optional()
|
|
9162
9169
|
});
|
|
9163
9170
|
const layoutEntrySchema = looseObject({
|
|
9164
9171
|
x: int$1(),
|
|
@@ -9232,7 +9239,8 @@ async function listFrames(pageDir) {
|
|
|
9232
9239
|
/**
|
|
9233
9240
|
* The page order a reader shows: listed pages that exist in that order, then
|
|
9234
9241
|
* unlisted ones by name. A file that fails to read orders every page by name.
|
|
9235
|
-
* The creation time
|
|
9242
|
+
* The creation time, folder, and archive flag come from the same read, each
|
|
9243
|
+
* read as absent when the file holds none or holds one of another type.
|
|
9236
9244
|
*/
|
|
9237
9245
|
async function readPageOrder(projectDir) {
|
|
9238
9246
|
const folders = await listPageFolders(projectDir);
|
|
@@ -9248,6 +9256,8 @@ async function readPageOrder(projectDir) {
|
|
|
9248
9256
|
return {
|
|
9249
9257
|
pages: folders,
|
|
9250
9258
|
createdAt: null,
|
|
9259
|
+
group: null,
|
|
9260
|
+
archived: false,
|
|
9251
9261
|
error: {
|
|
9252
9262
|
path,
|
|
9253
9263
|
message: error.message
|
|
@@ -9257,9 +9267,17 @@ async function readPageOrder(projectDir) {
|
|
|
9257
9267
|
return {
|
|
9258
9268
|
pages: orderPages(file.pages, folders),
|
|
9259
9269
|
createdAt: isTime(file.createdAt) ? file.createdAt : null,
|
|
9270
|
+
group: groupOf$1(file.group),
|
|
9271
|
+
archived: file.archived === true,
|
|
9260
9272
|
error: null
|
|
9261
9273
|
};
|
|
9262
9274
|
}
|
|
9275
|
+
/** A folder name as home shows it, trimmed, null for a blank or a non-string. */
|
|
9276
|
+
function groupOf$1(value) {
|
|
9277
|
+
if (typeof value !== "string") return null;
|
|
9278
|
+
const trimmed = value.trim();
|
|
9279
|
+
return trimmed === "" ? null : trimmed;
|
|
9280
|
+
}
|
|
9263
9281
|
function isTime(value) {
|
|
9264
9282
|
return datetime().safeParse(value).success;
|
|
9265
9283
|
}
|
|
@@ -9347,7 +9365,7 @@ async function scanBoard(root, { project } = {}) {
|
|
|
9347
9365
|
}
|
|
9348
9366
|
async function scanProject(root, name) {
|
|
9349
9367
|
const path = join(root, name);
|
|
9350
|
-
const { pages: order, createdAt, error } = await readPageOrder(path);
|
|
9368
|
+
const { pages: order, createdAt, group, archived, error } = await readPageOrder(path);
|
|
9351
9369
|
const pages = await Promise.all(order.map((page, index) => scanPage(root, name, page, index)));
|
|
9352
9370
|
const times = await Promise.all([
|
|
9353
9371
|
mtimeOf$1(join(path, PROJECT_FILE)),
|
|
@@ -9359,6 +9377,8 @@ async function scanProject(root, name) {
|
|
|
9359
9377
|
path,
|
|
9360
9378
|
modifiedAt: new Date(Math.max(...times)).toISOString(),
|
|
9361
9379
|
createdAt,
|
|
9380
|
+
group,
|
|
9381
|
+
archived,
|
|
9362
9382
|
projectFileError: error,
|
|
9363
9383
|
pages
|
|
9364
9384
|
};
|
|
@@ -9497,8 +9517,9 @@ async function isDirectory(path) {
|
|
|
9497
9517
|
}
|
|
9498
9518
|
}
|
|
9499
9519
|
// package.json
|
|
9500
|
-
var version$1 = "0.
|
|
9520
|
+
var version$1 = "0.27.0";
|
|
9501
9521
|
var dependencies = { "playwright-core": "1.64.1" };
|
|
9522
|
+
var peerDependencies = { "oxfmt": "0.75.0" };
|
|
9502
9523
|
// src/shared/version.ts
|
|
9503
9524
|
const version = version$1;
|
|
9504
9525
|
// src/cli/client-dir.ts
|
|
@@ -21286,7 +21307,7 @@ const LOG_FILE = "log.json";
|
|
|
21286
21307
|
const VERSIONS_FOLDER = "versions";
|
|
21287
21308
|
const VERSION_EXTENSION = ".html";
|
|
21288
21309
|
const HASH = /^[0-9a-f]{64}$/;
|
|
21289
|
-
const changeSchema = looseObject({
|
|
21310
|
+
const changeSchema$1 = looseObject({
|
|
21290
21311
|
id: string$1(),
|
|
21291
21312
|
frame: string$1(),
|
|
21292
21313
|
at: string$1(),
|
|
@@ -21304,7 +21325,7 @@ const changeSchema = looseObject({
|
|
|
21304
21325
|
});
|
|
21305
21326
|
const logSchema = looseObject({
|
|
21306
21327
|
version: literal(1),
|
|
21307
|
-
changes: array$1(changeSchema)
|
|
21328
|
+
changes: array$1(changeSchema$1)
|
|
21308
21329
|
});
|
|
21309
21330
|
/** `.run/changes/`, which holds the change log across a restart. */
|
|
21310
21331
|
function changesFolder(root) {
|
|
@@ -21536,7 +21557,7 @@ function versionKey(ref, hash) {
|
|
|
21536
21557
|
/** The files and folders a step wrote, being every rewrite, creation, removal, and move. */
|
|
21537
21558
|
function writtenPaths(step) {
|
|
21538
21559
|
return step.changes.flatMap((change) => {
|
|
21539
|
-
if (change.kind === "element" || change.kind === "inserted" || change.kind === "relocated" || change.kind === "path") return [change.path];
|
|
21560
|
+
if (change.kind === "element" || change.kind === "inserted" || change.kind === "deleted" || change.kind === "relocated" || change.kind === "path") return [change.path];
|
|
21540
21561
|
if (change.kind === "moved") return [change.from, change.to];
|
|
21541
21562
|
return [];
|
|
21542
21563
|
});
|
|
@@ -36354,6 +36375,48 @@ function editFrameFile(path, address, change, sourceAt) {
|
|
|
36354
36375
|
};
|
|
36355
36376
|
}
|
|
36356
36377
|
/**
|
|
36378
|
+
* Edits several elements of a frame file as one write, each found again and
|
|
36379
|
+
* verified as `editFrameFile` does one, in the order sent through the bytes
|
|
36380
|
+
* the one before it left. Any refusal writes nothing, so a batch never lands
|
|
36381
|
+
* in part, and naming one element twice is refused since one undo could not
|
|
36382
|
+
* put both spans back.
|
|
36383
|
+
*/
|
|
36384
|
+
function editFrameFileAll(path, hash, edits, sourceAt) {
|
|
36385
|
+
const read = readSource(path);
|
|
36386
|
+
if (!read.ok) return read;
|
|
36387
|
+
const { source } = read;
|
|
36388
|
+
const indexes = [];
|
|
36389
|
+
for (const { index, change } of edits) {
|
|
36390
|
+
if (hash === read.hash) {
|
|
36391
|
+
indexes.push(index);
|
|
36392
|
+
continue;
|
|
36393
|
+
}
|
|
36394
|
+
const was = sourceAt?.(hash);
|
|
36395
|
+
if (!was) return stale$1(path);
|
|
36396
|
+
const found = relocate(was, index, scopeOf(change), source);
|
|
36397
|
+
if (!found) return collided(path, was, index, source);
|
|
36398
|
+
indexes.push(found.index);
|
|
36399
|
+
}
|
|
36400
|
+
if (new Set(indexes).size !== indexes.length) return refuse$2("invalid-edit", "a batch names one element twice");
|
|
36401
|
+
let html = source;
|
|
36402
|
+
const spans = [];
|
|
36403
|
+
for (const [at, { change }] of edits.entries()) {
|
|
36404
|
+
const applied = applyEdit(html, { index: indexes[at] ?? -1 }, change);
|
|
36405
|
+
if (!applied.ok) return applied;
|
|
36406
|
+
html = applied.html;
|
|
36407
|
+
spans.push(applied.span);
|
|
36408
|
+
}
|
|
36409
|
+
if (!replaceFile(path, read.hash, html)) return stale$1(path);
|
|
36410
|
+
return {
|
|
36411
|
+
ok: true,
|
|
36412
|
+
hash: contentHash(html),
|
|
36413
|
+
from: read.hash,
|
|
36414
|
+
indexes,
|
|
36415
|
+
spans,
|
|
36416
|
+
remap: identity
|
|
36417
|
+
};
|
|
36418
|
+
}
|
|
36419
|
+
/**
|
|
36357
36420
|
* Writes one new element into a frame file the way `editFrameFile` writes an
|
|
36358
36421
|
* edit, through a temporary file and a rename after reading the file again.
|
|
36359
36422
|
* A hash the file no longer has is refused as stale with no search, since the
|
|
@@ -36410,6 +36473,45 @@ function removeFrameFile(path, hash, index) {
|
|
|
36410
36473
|
};
|
|
36411
36474
|
}
|
|
36412
36475
|
/**
|
|
36476
|
+
* Takes several elements out of a frame file as one write, refused as
|
|
36477
|
+
* `removeFrameFile` refuses one. Each goes last in the file first, so the
|
|
36478
|
+
* indices ahead of it hold, and one inside another named element goes with
|
|
36479
|
+
* that one rather than on its own.
|
|
36480
|
+
*/
|
|
36481
|
+
function removeFrameFileAll(path, hash, indexes) {
|
|
36482
|
+
const read = readSource(path);
|
|
36483
|
+
if (!read.ok) return read;
|
|
36484
|
+
if (read.hash !== hash) return stale$1(path);
|
|
36485
|
+
const { elements } = parseFrame(read.source);
|
|
36486
|
+
const named = new Set(indexes.map((index) => elements[index]));
|
|
36487
|
+
const outermost = [...new Set(indexes)].filter((index) => {
|
|
36488
|
+
let node = elements[index]?.parentNode;
|
|
36489
|
+
while (node && typeof node === "object") {
|
|
36490
|
+
if (named.has(node)) return false;
|
|
36491
|
+
node = "parentNode" in node ? node.parentNode : null;
|
|
36492
|
+
}
|
|
36493
|
+
return true;
|
|
36494
|
+
});
|
|
36495
|
+
let html = read.source;
|
|
36496
|
+
const spans = [];
|
|
36497
|
+
const remaps = [];
|
|
36498
|
+
for (const index of outermost.toSorted((a, b) => b - a)) {
|
|
36499
|
+
const size = subtreeSize(html, index);
|
|
36500
|
+
const removed = removeElement(html, index);
|
|
36501
|
+
if (!removed.ok) return removed;
|
|
36502
|
+
html = removed.html;
|
|
36503
|
+
spans.push(removed.span);
|
|
36504
|
+
remaps.push(takenOut(index, size));
|
|
36505
|
+
}
|
|
36506
|
+
if (!replaceFile(path, hash, html)) return stale$1(path);
|
|
36507
|
+
return {
|
|
36508
|
+
ok: true,
|
|
36509
|
+
hash: contentHash(html),
|
|
36510
|
+
spans,
|
|
36511
|
+
remap: (index) => remaps.reduce((at, remap) => at === null ? null : remap(at), index)
|
|
36512
|
+
};
|
|
36513
|
+
}
|
|
36514
|
+
/**
|
|
36413
36515
|
* Moves one element of a frame file into another gap, written as
|
|
36414
36516
|
* `insertFrameFile` writes, and refused as stale on a hash the file no longer
|
|
36415
36517
|
* has, since both indices name nothing once the file moved.
|
|
@@ -36452,6 +36554,38 @@ function placeFrameFile(path, hash, index, spot, facts, drop = []) {
|
|
|
36452
36554
|
};
|
|
36453
36555
|
}
|
|
36454
36556
|
/**
|
|
36557
|
+
* Places several elements of a frame file as one write, refused whole as
|
|
36558
|
+
* `placeFrameFile` refuses one. They go in file order, so a parent placed too
|
|
36559
|
+
* is positioned ahead of its child, which then writes no second span on its
|
|
36560
|
+
* tag that would strand the undo. `factsOf` reads the static cascade of the
|
|
36561
|
+
* bytes the one before left, so siblings share the parent the first one made
|
|
36562
|
+
* relative rather than writing it twice.
|
|
36563
|
+
*/
|
|
36564
|
+
function placeFrameFileAll(path, hash, places, factsOf) {
|
|
36565
|
+
const read = readSource(path);
|
|
36566
|
+
if (!read.ok) return read;
|
|
36567
|
+
if (read.hash !== hash) return stale$1(path);
|
|
36568
|
+
let html = read.source;
|
|
36569
|
+
const spans = [];
|
|
36570
|
+
const sized = /* @__PURE__ */ new Map();
|
|
36571
|
+
for (const place of places.toSorted((a, b) => a.index - b.index)) {
|
|
36572
|
+
const { index, spot, drop } = place;
|
|
36573
|
+
const placed = placeElement(html, index, spot, factsOf(html), drop ?? []);
|
|
36574
|
+
if (!placed.ok) return placed;
|
|
36575
|
+
html = placed.html;
|
|
36576
|
+
spans.push(...placed.spans);
|
|
36577
|
+
sized.set(place, placed.sized);
|
|
36578
|
+
}
|
|
36579
|
+
if (!replaceFile(path, hash, html)) return stale$1(path);
|
|
36580
|
+
return {
|
|
36581
|
+
ok: true,
|
|
36582
|
+
hash: contentHash(html),
|
|
36583
|
+
spans,
|
|
36584
|
+
sized: places.map((place) => sized.get(place) ?? []),
|
|
36585
|
+
remap: identity
|
|
36586
|
+
};
|
|
36587
|
+
}
|
|
36588
|
+
/**
|
|
36455
36589
|
* Replaces a raw color with a token across the subtree `root` names, or the
|
|
36456
36590
|
* frame's body when undefined, written as `placeFrameFile` writes and refused
|
|
36457
36591
|
* as stale on a hash the file no longer has, so a retried replace lands once.
|
|
@@ -36589,6 +36723,286 @@ const listenerSchema = object$1({
|
|
|
36589
36723
|
tag: string$1(),
|
|
36590
36724
|
since: string$1()
|
|
36591
36725
|
});
|
|
36726
|
+
// src/server/board/pages.ts
|
|
36727
|
+
/** Notes and their images belong to the page they were pinned on, so a copy starts without them. */
|
|
36728
|
+
const NOT_COPIED = /* @__PURE__ */ new Set(["notes.json", ".notes"]);
|
|
36729
|
+
async function addPage(root, ref, { index, ...options }) {
|
|
36730
|
+
const page = await resolvePageRef(root, ref, {
|
|
36731
|
+
...options,
|
|
36732
|
+
allowMissing: true
|
|
36733
|
+
});
|
|
36734
|
+
if (existsSync(page.path)) throw taken(page, page.name);
|
|
36735
|
+
return recordOf(root, page, await reorder(root, page, async (order) => {
|
|
36736
|
+
await mkdir(page.path);
|
|
36737
|
+
await options.journal?.created(page.path);
|
|
36738
|
+
return insert(order, page.name, index ?? order.length);
|
|
36739
|
+
}, options.journal));
|
|
36740
|
+
}
|
|
36741
|
+
async function duplicatePage(root, ref, { name, ...options }) {
|
|
36742
|
+
const source = await resolvePageRef(root, ref, options);
|
|
36743
|
+
const projectDir = join(root, source.project);
|
|
36744
|
+
return recordOf(root, source, await reorder(root, source, async (order) => {
|
|
36745
|
+
const copy = await freeName(source, projectDir, name, false);
|
|
36746
|
+
const copyPath = join(projectDir, copy);
|
|
36747
|
+
await cp(source.path, copyPath, {
|
|
36748
|
+
recursive: true,
|
|
36749
|
+
errorOnExist: true,
|
|
36750
|
+
force: false,
|
|
36751
|
+
filter: (path) => isCopied(basename(path))
|
|
36752
|
+
});
|
|
36753
|
+
await options.journal?.created(copyPath);
|
|
36754
|
+
return {
|
|
36755
|
+
name: copy,
|
|
36756
|
+
order: insert(order, copy, order.indexOf(source.name) + 1)
|
|
36757
|
+
};
|
|
36758
|
+
}, options.journal));
|
|
36759
|
+
}
|
|
36760
|
+
async function renamePage(root, ref, newName, { journal, ...options }) {
|
|
36761
|
+
const page = await resolvePageRef(root, ref, options);
|
|
36762
|
+
const projectDir = join(root, page.project);
|
|
36763
|
+
return recordOf(root, page, await reorder(root, page, async (order) => {
|
|
36764
|
+
const renamed = await freeName(page, projectDir, newName, true);
|
|
36765
|
+
const renamedPath = join(projectDir, renamed);
|
|
36766
|
+
if (journal) await journal.moved(page.path, renamedPath);
|
|
36767
|
+
else await rename(page.path, renamedPath);
|
|
36768
|
+
return {
|
|
36769
|
+
name: renamed,
|
|
36770
|
+
order: order.map((name) => name === page.name ? renamed : name)
|
|
36771
|
+
};
|
|
36772
|
+
}, journal));
|
|
36773
|
+
}
|
|
36774
|
+
async function movePage(root, ref, { index, ...options }) {
|
|
36775
|
+
const page = await resolvePageRef(root, ref, options);
|
|
36776
|
+
return recordOf(root, page, await reorder(root, page, async (order) => insert(order.filter((name) => name !== page.name), page.name, index), options.journal));
|
|
36777
|
+
}
|
|
36778
|
+
async function deletePage(root, ref, { journal, ...options }) {
|
|
36779
|
+
const page = await resolvePageRef(root, ref, options);
|
|
36780
|
+
await reorder(root, page, async (order) => {
|
|
36781
|
+
if (journal) await journal.removed(page.path);
|
|
36782
|
+
else await rm(page.path, {
|
|
36783
|
+
recursive: true,
|
|
36784
|
+
force: true
|
|
36785
|
+
});
|
|
36786
|
+
return order.filter((name) => name !== page.name);
|
|
36787
|
+
}, journal);
|
|
36788
|
+
return { deleted: `${page.project}/${page.name}` };
|
|
36789
|
+
}
|
|
36790
|
+
/**
|
|
36791
|
+
* Runs one page change under the project file's lock, returning the page's
|
|
36792
|
+
* name after it and the order written. The file is read and
|
|
36793
|
+
* validated before `change` touches a folder, and written back holding exactly
|
|
36794
|
+
* the page folders on disk, in the order `change` returns, which the journal
|
|
36795
|
+
* is told of when it differs from the order the file held.
|
|
36796
|
+
*/
|
|
36797
|
+
async function reorder(root, page, change, journal) {
|
|
36798
|
+
const projectDir = join(root, page.project);
|
|
36799
|
+
const path = join(projectDir, PROJECT_FILE);
|
|
36800
|
+
return withLocks([path], async () => {
|
|
36801
|
+
const file = await readRecord(path, {
|
|
36802
|
+
...projectSpec,
|
|
36803
|
+
empty: emptyProject
|
|
36804
|
+
});
|
|
36805
|
+
const changed = await change(orderPages(file.pages, await listPageFolders(projectDir)));
|
|
36806
|
+
const { name, order } = Array.isArray(changed) ? {
|
|
36807
|
+
name: page.name,
|
|
36808
|
+
order: changed
|
|
36809
|
+
} : changed;
|
|
36810
|
+
const pages = orderPages(order, await listPageFolders(projectDir));
|
|
36811
|
+
await writeRecord(path, {
|
|
36812
|
+
...file,
|
|
36813
|
+
pages
|
|
36814
|
+
});
|
|
36815
|
+
if (journal && !isDeepStrictEqual(file.pages, pages)) journal.pages(projectDir, file.pages, pages);
|
|
36816
|
+
return {
|
|
36817
|
+
name,
|
|
36818
|
+
pages
|
|
36819
|
+
};
|
|
36820
|
+
});
|
|
36821
|
+
}
|
|
36822
|
+
async function recordOf(root, page, { name, pages }) {
|
|
36823
|
+
return scanPage(root, page.project, name, pages.indexOf(name));
|
|
36824
|
+
}
|
|
36825
|
+
/**
|
|
36826
|
+
* The explicit name when free and valid, else the next free copy of the
|
|
36827
|
+
* source's. A rename frees the source's own name, so a case-only rename runs.
|
|
36828
|
+
*/
|
|
36829
|
+
async function freeName(source, projectDir, name, freesSource) {
|
|
36830
|
+
const others = (await listPageFolders(projectDir)).filter((page) => !freesSource || page !== source.name);
|
|
36831
|
+
if (name === void 0) return nextFreeName(source.name, others);
|
|
36832
|
+
assertValidName("page", name);
|
|
36833
|
+
const holder = matchName(others, name);
|
|
36834
|
+
if (holder) throw taken(source, holder);
|
|
36835
|
+
return name;
|
|
36836
|
+
}
|
|
36837
|
+
function insert(order, name, index) {
|
|
36838
|
+
const at = Math.max(0, Math.min(index, order.length));
|
|
36839
|
+
return [
|
|
36840
|
+
...order.slice(0, at),
|
|
36841
|
+
name,
|
|
36842
|
+
...order.slice(at)
|
|
36843
|
+
];
|
|
36844
|
+
}
|
|
36845
|
+
/** Whether a copy of a page or project folder takes the file or folder `name`. */
|
|
36846
|
+
function isCopied(name) {
|
|
36847
|
+
return !NOT_COPIED.has(name) && !name.endsWith(".lock") && !name.endsWith(".tmp");
|
|
36848
|
+
}
|
|
36849
|
+
function taken(page, holder) {
|
|
36850
|
+
return new FrameboardError("name-taken", `Project ${page.project} already has a page ${holder}.`, {
|
|
36851
|
+
project: page.project,
|
|
36852
|
+
name: holder
|
|
36853
|
+
});
|
|
36854
|
+
}
|
|
36855
|
+
// src/server/board/projects.ts
|
|
36856
|
+
/** A new project holding one empty page. */
|
|
36857
|
+
async function addProject(root, name, now = /* @__PURE__ */ new Date(), { journal } = {}) {
|
|
36858
|
+
assertValidName("project", name);
|
|
36859
|
+
await assertFree$1(root, name);
|
|
36860
|
+
await mkdir(join(root, name, START_PAGE), { recursive: true });
|
|
36861
|
+
await writeRecord(join(root, name, PROJECT_FILE), {
|
|
36862
|
+
version: 1,
|
|
36863
|
+
pages: [START_PAGE],
|
|
36864
|
+
createdAt: now.toISOString()
|
|
36865
|
+
});
|
|
36866
|
+
await journal?.created(join(root, name));
|
|
36867
|
+
return scanProject(root, name);
|
|
36868
|
+
}
|
|
36869
|
+
async function renameProject(root, name, newName, { journal } = {}) {
|
|
36870
|
+
const project = await resolveProject(root, name);
|
|
36871
|
+
assertValidName("project", newName);
|
|
36872
|
+
await assertFree$1(root, newName, project.name);
|
|
36873
|
+
const renamed = join(root, newName);
|
|
36874
|
+
if (journal) await journal.moved(project.path, renamed);
|
|
36875
|
+
else await rename(project.path, renamed);
|
|
36876
|
+
return scanProject(root, newName);
|
|
36877
|
+
}
|
|
36878
|
+
/**
|
|
36879
|
+
* A copy of the project under the next free name, without its notes, and
|
|
36880
|
+
* stamped as made `now`.
|
|
36881
|
+
*/
|
|
36882
|
+
async function duplicateProject(root, name, now = /* @__PURE__ */ new Date(), { journal } = {}) {
|
|
36883
|
+
const source = await resolveProject(root, name);
|
|
36884
|
+
const file = await readRecord(join(source.path, PROJECT_FILE), {
|
|
36885
|
+
...projectSpec,
|
|
36886
|
+
empty: emptyProject
|
|
36887
|
+
});
|
|
36888
|
+
const copy = nextFreeName(source.name, await listProjects(root));
|
|
36889
|
+
const copyPath = join(root, copy);
|
|
36890
|
+
await cp(source.path, copyPath, {
|
|
36891
|
+
recursive: true,
|
|
36892
|
+
errorOnExist: true,
|
|
36893
|
+
force: false,
|
|
36894
|
+
filter: (path) => isCopied(basename(path))
|
|
36895
|
+
});
|
|
36896
|
+
const { archived: _archived, ...kept } = file;
|
|
36897
|
+
await writeRecord(join(copyPath, PROJECT_FILE), {
|
|
36898
|
+
...kept,
|
|
36899
|
+
createdAt: now.toISOString()
|
|
36900
|
+
});
|
|
36901
|
+
await journal?.created(copyPath);
|
|
36902
|
+
return scanProject(root, copy);
|
|
36903
|
+
}
|
|
36904
|
+
async function deleteProject(root, name, { journal } = {}) {
|
|
36905
|
+
const project = await resolveProject(root, name);
|
|
36906
|
+
if (journal) await journal.removed(project.path);
|
|
36907
|
+
else await rm(project.path, {
|
|
36908
|
+
recursive: true,
|
|
36909
|
+
force: true
|
|
36910
|
+
});
|
|
36911
|
+
return { deleted: project.name };
|
|
36912
|
+
}
|
|
36913
|
+
/**
|
|
36914
|
+
* Files every named project at once, each `project.json` read and merged
|
|
36915
|
+
* under its lock so pages, checks, and unknown keys stay as written. A file
|
|
36916
|
+
* that does not parse refuses the whole filing before any is written. The
|
|
36917
|
+
* file's and folder's times are put back, since a filing is not an edit to
|
|
36918
|
+
* the project and must not move it in home's Edited sort.
|
|
36919
|
+
*/
|
|
36920
|
+
async function fileProjects(root, names, filing, { journal } = {}) {
|
|
36921
|
+
const projects = await Promise.all(names.map((name) => resolveProject(root, name)));
|
|
36922
|
+
const paths = [...new Set(projects.map((project) => join(project.path, PROJECT_FILE)))];
|
|
36923
|
+
await keepingTimes(paths, (keep) => withLocks(paths, async () => {
|
|
36924
|
+
const files = await Promise.all(paths.map((path) => readRecord(path, {
|
|
36925
|
+
...projectSpec,
|
|
36926
|
+
empty: emptyProject
|
|
36927
|
+
})));
|
|
36928
|
+
for (const [index, path] of paths.entries()) {
|
|
36929
|
+
const file = files[index];
|
|
36930
|
+
if (!file) continue;
|
|
36931
|
+
const next = filed(file, filing);
|
|
36932
|
+
const before = filingOf(file);
|
|
36933
|
+
const after = filingOf(next);
|
|
36934
|
+
if (isSameFiling(before, after)) continue;
|
|
36935
|
+
await keep(path);
|
|
36936
|
+
await writeRecord(path, next);
|
|
36937
|
+
journal?.project(path, before, after);
|
|
36938
|
+
}
|
|
36939
|
+
}));
|
|
36940
|
+
return Promise.all(projects.map((project) => scanProject(root, project.name)));
|
|
36941
|
+
}
|
|
36942
|
+
function filed(file, filing) {
|
|
36943
|
+
const { group, archived, ...rest } = file;
|
|
36944
|
+
if ("group" in filing) {
|
|
36945
|
+
const name = filing.group?.trim();
|
|
36946
|
+
return {
|
|
36947
|
+
...rest,
|
|
36948
|
+
...name ? { group: name } : {},
|
|
36949
|
+
...archived === void 0 ? {} : { archived }
|
|
36950
|
+
};
|
|
36951
|
+
}
|
|
36952
|
+
return {
|
|
36953
|
+
...rest,
|
|
36954
|
+
...group === void 0 ? {} : { group },
|
|
36955
|
+
...filing.archived ? { archived: true } : {}
|
|
36956
|
+
};
|
|
36957
|
+
}
|
|
36958
|
+
/** The filing keys a project file holds, leaving out the ones it lacks. */
|
|
36959
|
+
function filingOf(file) {
|
|
36960
|
+
return {
|
|
36961
|
+
...file.group === void 0 ? {} : { group: file.group },
|
|
36962
|
+
...file.archived === void 0 ? {} : { archived: file.archived }
|
|
36963
|
+
};
|
|
36964
|
+
}
|
|
36965
|
+
function isSameFiling(a, b) {
|
|
36966
|
+
return a.group === b.group && a.archived === b.archived;
|
|
36967
|
+
}
|
|
36968
|
+
/**
|
|
36969
|
+
* Runs `run`, a section holding the lock of each project file it writes, and
|
|
36970
|
+
* puts back the times that file and its folder held, which the scanner reads
|
|
36971
|
+
* as the project's last edit. `run` calls `keep` under the lock before each
|
|
36972
|
+
* write, so the file's time is read after any writer that held the lock first.
|
|
36973
|
+
* The folder's time is read before the lock, since taking and dropping the
|
|
36974
|
+
* lock moves it, and goes back only where the file kept its time until `keep`,
|
|
36975
|
+
* so a writer that ran in between keeps the Edited time it earned.
|
|
36976
|
+
*/
|
|
36977
|
+
async function keepingTimes(files, run) {
|
|
36978
|
+
const before = new Map(await Promise.all(files.map(async (file) => [file, {
|
|
36979
|
+
file: await stat(file).catch(() => void 0),
|
|
36980
|
+
folder: await stat(dirname(file)).catch(() => void 0)
|
|
36981
|
+
}])));
|
|
36982
|
+
const kept = /* @__PURE__ */ new Map();
|
|
36983
|
+
const keep = async (file) => {
|
|
36984
|
+
const time = await stat(file).catch(() => void 0);
|
|
36985
|
+
if (time && !kept.has(file)) kept.set(file, time);
|
|
36986
|
+
};
|
|
36987
|
+
const put = (path, time) => utimes(path, time.atimeMs / 1e3, time.mtimeMs / 1e3).catch(() => {});
|
|
36988
|
+
try {
|
|
36989
|
+
return await run(keep);
|
|
36990
|
+
} finally {
|
|
36991
|
+
await Promise.all([...kept].map(async ([file, time]) => {
|
|
36992
|
+
await put(file, time);
|
|
36993
|
+
const { file: was, folder } = before.get(file) ?? {};
|
|
36994
|
+
if (folder && was?.mtimeMs === time.mtimeMs) await put(dirname(file), folder);
|
|
36995
|
+
}));
|
|
36996
|
+
}
|
|
36997
|
+
}
|
|
36998
|
+
/** Throws `name-taken` when another project holds `name` in any case. */
|
|
36999
|
+
async function assertFree$1(root, name, self) {
|
|
37000
|
+
const taken = matchName((await listProjects(root)).filter((project) => project !== self), name);
|
|
37001
|
+
if (taken) throw new FrameboardError("name-taken", `The board already has a project ${taken}.`, {
|
|
37002
|
+
name,
|
|
37003
|
+
taken
|
|
37004
|
+
});
|
|
37005
|
+
}
|
|
36592
37006
|
// src/server/look/token-edit.ts
|
|
36593
37007
|
const NAME = /^--[\w-]+$/;
|
|
36594
37008
|
const UNSAFE_VALUE = /[;{}\n\r]|\/\*/;
|
|
@@ -36832,7 +37246,7 @@ async function emptyTrash(root) {
|
|
|
36832
37246
|
/** The records a change writes, whose locks are held while it is checked and written. */
|
|
36833
37247
|
function lockPaths(change) {
|
|
36834
37248
|
if (change.kind === "entry" || change.kind === "section") return [change.layout];
|
|
36835
|
-
if (change.kind === "pages") return [change.file];
|
|
37249
|
+
if (change.kind === "pages" || change.kind === "project") return [change.file];
|
|
36836
37250
|
return [];
|
|
36837
37251
|
}
|
|
36838
37252
|
/**
|
|
@@ -36867,6 +37281,10 @@ async function reads(change, side) {
|
|
|
36867
37281
|
});
|
|
36868
37282
|
return isDeepStrictEqual(file.pages, change[side]);
|
|
36869
37283
|
}
|
|
37284
|
+
case "project": {
|
|
37285
|
+
const file = await readRecord(change.file, projectSpec);
|
|
37286
|
+
return isDeepStrictEqual(filingOf(file), change[side]);
|
|
37287
|
+
}
|
|
36870
37288
|
case "moved": {
|
|
36871
37289
|
const [present, absent] = side === "after" ? [change.to, change.from] : [change.from, change.to];
|
|
36872
37290
|
return await exists(present) && !await exists(absent);
|
|
@@ -36874,6 +37292,7 @@ async function reads(change, side) {
|
|
|
36874
37292
|
case "path": return change.present === side ? await exists(change.path) && await hashPath(change.path) === change.hash : !await exists(change.path) && await exists(change.slot);
|
|
36875
37293
|
case "element": return await exists(change.path) && holdsSpan(await readFile(change.path, "utf8"), change.span, side);
|
|
36876
37294
|
case "inserted": return await exists(change.path) && holdsInserted(await readFile(change.path, "utf8"), change.span, side === change.present ? "after" : "before");
|
|
37295
|
+
case "deleted": return await exists(change.path) && chainDeleted(await readFile(change.path, "utf8"), change, OTHER[side]) !== void 0;
|
|
36877
37296
|
case "token": return await exists(change.path) && holdsToken(change, side);
|
|
36878
37297
|
case "relocated": return await exists(change.path) && relocateMoved(await readFile(change.path, "utf8"), change.span, OTHER[side]) !== void 0;
|
|
36879
37298
|
}
|
|
@@ -36938,6 +37357,14 @@ async function restore(change, side) {
|
|
|
36938
37357
|
});
|
|
36939
37358
|
return;
|
|
36940
37359
|
}
|
|
37360
|
+
case "project": {
|
|
37361
|
+
const { group: _group, archived: _archived, ...rest } = await readRecord(change.file, projectSpec);
|
|
37362
|
+
await writeRecord(change.file, {
|
|
37363
|
+
...rest,
|
|
37364
|
+
...change[side]
|
|
37365
|
+
});
|
|
37366
|
+
return;
|
|
37367
|
+
}
|
|
36941
37368
|
case "moved":
|
|
36942
37369
|
if (side === "before") await rename(change.to, change.from);
|
|
36943
37370
|
else await rename(change.from, change.to);
|
|
@@ -36964,6 +37391,15 @@ async function restore(change, side) {
|
|
|
36964
37391
|
}
|
|
36965
37392
|
};
|
|
36966
37393
|
});
|
|
37394
|
+
case "deleted": return rewriteFrame(change, (source) => {
|
|
37395
|
+
const written = chainDeleted(source, change, side);
|
|
37396
|
+
return written && {
|
|
37397
|
+
html: written.html,
|
|
37398
|
+
keep: () => {
|
|
37399
|
+
change.spans = written.spans;
|
|
37400
|
+
}
|
|
37401
|
+
};
|
|
37402
|
+
});
|
|
36967
37403
|
case "relocated": return rewriteFrame(change, (source) => {
|
|
36968
37404
|
const written = relocateMoved(source, change.span, side);
|
|
36969
37405
|
return written && {
|
|
@@ -36976,6 +37412,28 @@ async function restore(change, side) {
|
|
|
36976
37412
|
case "token": return rewriteToken(change, side);
|
|
36977
37413
|
}
|
|
36978
37414
|
}
|
|
37415
|
+
/**
|
|
37416
|
+
* The frame with a delete's elements back, `before` restoring them in the
|
|
37417
|
+
* reverse of the order taken out, or out again, `after` taking them in that
|
|
37418
|
+
* order, undefined when any one's bytes or gap no longer read. Answers the
|
|
37419
|
+
* spans as the frame then stands, in the order taken out.
|
|
37420
|
+
*/
|
|
37421
|
+
function chainDeleted(source, { spans }, side) {
|
|
37422
|
+
const restoring = side === "before";
|
|
37423
|
+
const write = restoring ? restoreInserted : removeInserted;
|
|
37424
|
+
let html = source;
|
|
37425
|
+
const kept = [];
|
|
37426
|
+
for (const span of restoring ? spans.toReversed() : spans) {
|
|
37427
|
+
const written = write(html, span);
|
|
37428
|
+
if (!written) return void 0;
|
|
37429
|
+
html = written.html;
|
|
37430
|
+
kept.push(written.span);
|
|
37431
|
+
}
|
|
37432
|
+
return {
|
|
37433
|
+
html,
|
|
37434
|
+
spans: restoring ? kept.toReversed() : kept
|
|
37435
|
+
};
|
|
37436
|
+
}
|
|
36979
37437
|
/** Whether the sheet sets the token exactly as `side` holds it, false for a sheet that no longer parses. */
|
|
36980
37438
|
async function holdsToken(change, side) {
|
|
36981
37439
|
try {
|
|
@@ -37066,6 +37524,14 @@ var StepJournal = class {
|
|
|
37066
37524
|
after
|
|
37067
37525
|
});
|
|
37068
37526
|
}
|
|
37527
|
+
project(file, before, after) {
|
|
37528
|
+
this.changes.push({
|
|
37529
|
+
kind: "project",
|
|
37530
|
+
file,
|
|
37531
|
+
before,
|
|
37532
|
+
after
|
|
37533
|
+
});
|
|
37534
|
+
}
|
|
37069
37535
|
async moved(from, to) {
|
|
37070
37536
|
await rename(from, to);
|
|
37071
37537
|
this.changes.push({
|
|
@@ -37103,6 +37569,15 @@ var StepJournal = class {
|
|
|
37103
37569
|
present: "before"
|
|
37104
37570
|
});
|
|
37105
37571
|
}
|
|
37572
|
+
/** The elements one hand delete took out of a frame file, in the order taken out, which this journal does not write. */
|
|
37573
|
+
deletedElements(path, ref, spans) {
|
|
37574
|
+
this.changes.push({
|
|
37575
|
+
kind: "deleted",
|
|
37576
|
+
path,
|
|
37577
|
+
ref,
|
|
37578
|
+
spans
|
|
37579
|
+
});
|
|
37580
|
+
}
|
|
37106
37581
|
/** The element a hand move took to another gap of a frame file, which this journal does not write. */
|
|
37107
37582
|
relocated(path, ref, span) {
|
|
37108
37583
|
this.changes.push({
|
|
@@ -37267,15 +37742,17 @@ var History = class {
|
|
|
37267
37742
|
const was = to === "before" ? "after" : "before";
|
|
37268
37743
|
const hashes = {};
|
|
37269
37744
|
const locks = step.changes.flatMap(lockPaths).filter((path) => existsSync(dirname(path)));
|
|
37745
|
+
const timed = step.changes.flatMap((change) => change.kind === "project" ? [change.file] : []);
|
|
37270
37746
|
try {
|
|
37271
|
-
await withLocks(locks, async () => {
|
|
37747
|
+
await keepingTimes(timed, (keep) => withLocks(locks, async () => {
|
|
37272
37748
|
for (const change of step.changes) if (!await holds(change, was)) throw new FrameboardError("undo-overtaken", `An agent changed ${nameOf(change)} after your edit, so that step was dropped.`, { change: change.kind });
|
|
37749
|
+
for (const file of timed) await keep(file);
|
|
37273
37750
|
const ordered = to === "before" ? [...step.changes].reverse() : step.changes;
|
|
37274
37751
|
for (const change of ordered) {
|
|
37275
37752
|
const hash = await restore(change, to);
|
|
37276
37753
|
if (hash !== void 0 && "ref" in change) hashes[change.ref] = hash;
|
|
37277
37754
|
}
|
|
37278
|
-
});
|
|
37755
|
+
}));
|
|
37279
37756
|
} catch (error) {
|
|
37280
37757
|
if (!(error instanceof FrameboardError && error.code === "undo-overtaken")) from.push(step);
|
|
37281
37758
|
this.onChange(this.counts());
|
|
@@ -37299,11 +37776,12 @@ var History = class {
|
|
|
37299
37776
|
return run;
|
|
37300
37777
|
}
|
|
37301
37778
|
};
|
|
37302
|
-
/** What a refusal names as overtaken, being a frame, a section, a page,
|
|
37779
|
+
/** What a refusal names as overtaken, being a frame, a section, a page, the page order, or a filed project. */
|
|
37303
37780
|
function nameOf(change) {
|
|
37304
37781
|
if (change.kind === "entry") return change.frame;
|
|
37305
37782
|
if (change.kind === "section") return `section ${change.section}`;
|
|
37306
37783
|
if (change.kind === "pages") return "the page order";
|
|
37784
|
+
if (change.kind === "project") return basename(dirname(change.file));
|
|
37307
37785
|
if (change.kind === "token") return change.name;
|
|
37308
37786
|
const path = change.kind === "moved" ? change.to : change.path;
|
|
37309
37787
|
return basename(path, FRAME_EXTENSION);
|
|
@@ -37647,7 +38125,9 @@ const editResultSchema = object$1({
|
|
|
37647
38125
|
index: int$1().min(0),
|
|
37648
38126
|
hash,
|
|
37649
38127
|
/** The hash the edit was written over, which differs from the one sent once the edit was found again. */
|
|
37650
|
-
from: hash.optional()
|
|
38128
|
+
from: hash.optional(),
|
|
38129
|
+
/** Each element's index in the file as written, in the order a batch sent them, with `index` the last. */
|
|
38130
|
+
indexes: array$1(int$1().min(0)).optional()
|
|
37651
38131
|
});
|
|
37652
38132
|
object$1({
|
|
37653
38133
|
ref: string$1(),
|
|
@@ -37669,7 +38149,12 @@ object$1({
|
|
|
37669
38149
|
ref: string$1(),
|
|
37670
38150
|
index: int$1().min(0),
|
|
37671
38151
|
hash,
|
|
37672
|
-
sized: array$1(placedSizeSchema)
|
|
38152
|
+
sized: array$1(placedSizeSchema),
|
|
38153
|
+
/** Each element a batch placed and the sizes written on it, in the order sent, with `index` and `sized` the last's. */
|
|
38154
|
+
placed: array$1(object$1({
|
|
38155
|
+
index: int$1().min(0),
|
|
38156
|
+
sized: array$1(placedSizeSchema)
|
|
38157
|
+
})).optional()
|
|
37673
38158
|
});
|
|
37674
38159
|
object$1({
|
|
37675
38160
|
ref: string$1(),
|
|
@@ -37683,34 +38168,44 @@ const name$1 = string$1().min(1).max(256);
|
|
|
37683
38168
|
const side = int$1().min(1).max(1e4);
|
|
37684
38169
|
/** A spot in CSS pixels, bounded well past any frame. */
|
|
37685
38170
|
const offset = number().min(-1e5).max(1e5);
|
|
37686
|
-
|
|
38171
|
+
/** How many elements one batch names, well past any selection a hand makes. */
|
|
38172
|
+
const BATCH = 1024;
|
|
38173
|
+
const changeSchema = discriminatedUnion("kind", [
|
|
38174
|
+
object$1({
|
|
38175
|
+
kind: literal("style"),
|
|
38176
|
+
property: name$1,
|
|
38177
|
+
value
|
|
38178
|
+
}),
|
|
38179
|
+
object$1({
|
|
38180
|
+
kind: literal("attribute"),
|
|
38181
|
+
name: name$1,
|
|
38182
|
+
value
|
|
38183
|
+
}),
|
|
38184
|
+
object$1({
|
|
38185
|
+
kind: literal("text"),
|
|
38186
|
+
value
|
|
38187
|
+
}),
|
|
38188
|
+
object$1({
|
|
38189
|
+
kind: literal("styles"),
|
|
38190
|
+
declarations: array$1(object$1({
|
|
38191
|
+
property: name$1,
|
|
38192
|
+
value
|
|
38193
|
+
})).max(16)
|
|
38194
|
+
})
|
|
38195
|
+
]);
|
|
38196
|
+
const editSchema$1 = union([object$1({
|
|
37687
38197
|
ref: string$1().min(1).max(1024),
|
|
37688
38198
|
index: int$1().min(0),
|
|
37689
38199
|
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
37690
|
-
change:
|
|
37691
|
-
|
|
37692
|
-
|
|
37693
|
-
|
|
37694
|
-
|
|
37695
|
-
|
|
37696
|
-
|
|
37697
|
-
|
|
37698
|
-
|
|
37699
|
-
value
|
|
37700
|
-
}),
|
|
37701
|
-
object$1({
|
|
37702
|
-
kind: literal("text"),
|
|
37703
|
-
value
|
|
37704
|
-
}),
|
|
37705
|
-
object$1({
|
|
37706
|
-
kind: literal("styles"),
|
|
37707
|
-
declarations: array$1(object$1({
|
|
37708
|
-
property: name$1,
|
|
37709
|
-
value
|
|
37710
|
-
})).max(16)
|
|
37711
|
-
})
|
|
37712
|
-
])
|
|
37713
|
-
});
|
|
38200
|
+
change: changeSchema
|
|
38201
|
+
}), object$1({
|
|
38202
|
+
ref: string$1().min(1).max(1024),
|
|
38203
|
+
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
38204
|
+
edits: array$1(object$1({
|
|
38205
|
+
index: int$1().min(0),
|
|
38206
|
+
change: changeSchema
|
|
38207
|
+
})).min(1).max(BATCH)
|
|
38208
|
+
})]);
|
|
37714
38209
|
const insertSchema = object$1({
|
|
37715
38210
|
ref: string$1().min(1).max(1024),
|
|
37716
38211
|
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
@@ -37747,11 +38242,15 @@ const insertSchema = object$1({
|
|
|
37747
38242
|
orFlow: boolean$1().optional()
|
|
37748
38243
|
}).optional()
|
|
37749
38244
|
});
|
|
37750
|
-
const removeSchema = object$1({
|
|
38245
|
+
const removeSchema = union([object$1({
|
|
37751
38246
|
ref: string$1().min(1).max(1024),
|
|
37752
38247
|
index: int$1().min(0),
|
|
37753
38248
|
hash: string$1().regex(/^[0-9a-f]{64}$/)
|
|
37754
|
-
})
|
|
38249
|
+
}), object$1({
|
|
38250
|
+
ref: string$1().min(1).max(1024),
|
|
38251
|
+
indexes: array$1(int$1().min(0)).min(1).max(BATCH),
|
|
38252
|
+
hash: string$1().regex(/^[0-9a-f]{64}$/)
|
|
38253
|
+
})]);
|
|
37755
38254
|
const moveSchema$1 = object$1({
|
|
37756
38255
|
ref: string$1().min(1).max(1024),
|
|
37757
38256
|
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
@@ -37759,10 +38258,7 @@ const moveSchema$1 = object$1({
|
|
|
37759
38258
|
parent: int$1().min(0),
|
|
37760
38259
|
before: int$1().min(0).nullable()
|
|
37761
38260
|
});
|
|
37762
|
-
const
|
|
37763
|
-
ref: string$1().min(1).max(1024),
|
|
37764
|
-
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
37765
|
-
index: int$1().min(0),
|
|
38261
|
+
const spotFields = {
|
|
37766
38262
|
spot: object$1({
|
|
37767
38263
|
left: offset,
|
|
37768
38264
|
top: offset,
|
|
@@ -37771,7 +38267,20 @@ const placeSchema = object$1({
|
|
|
37771
38267
|
}).nullable(),
|
|
37772
38268
|
/** Back in flow, the sizes to drop, being ones a placement wrote that nothing changed since. */
|
|
37773
38269
|
drop: array$1(placedSizeSchema).max(2).optional()
|
|
37774
|
-
}
|
|
38270
|
+
};
|
|
38271
|
+
const placeSchema = union([object$1({
|
|
38272
|
+
ref: string$1().min(1).max(1024),
|
|
38273
|
+
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
38274
|
+
index: int$1().min(0),
|
|
38275
|
+
...spotFields
|
|
38276
|
+
}), object$1({
|
|
38277
|
+
ref: string$1().min(1).max(1024),
|
|
38278
|
+
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
38279
|
+
places: array$1(object$1({
|
|
38280
|
+
index: int$1().min(0),
|
|
38281
|
+
...spotFields
|
|
38282
|
+
})).min(1).max(BATCH)
|
|
38283
|
+
})]);
|
|
37775
38284
|
const recolorSchema = object$1({
|
|
37776
38285
|
ref: string$1().min(1).max(1024),
|
|
37777
38286
|
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
@@ -37797,6 +38306,9 @@ const recolorSchema = object$1({
|
|
|
37797
38306
|
* records the edited element's span as one step. It answers the `edit`
|
|
37798
38307
|
* record with the index written and the hash written over. Each refusal the
|
|
37799
38308
|
* writer returns answers 409 with its code, `stale-address` among them.
|
|
38309
|
+
* Given `edits` in place of `index` and `change`, it writes each as one
|
|
38310
|
+
* write and one step, refused whole on any refusal, and answers `indexes` in
|
|
38311
|
+
* the order sent, `index` being the last.
|
|
37800
38312
|
*
|
|
37801
38313
|
* The insert takes an element kind, never markup, and writes that kind's one
|
|
37802
38314
|
* tag into the gap `parent` and `before` name, painted from the project's
|
|
@@ -37817,7 +38329,9 @@ const recolorSchema = object$1({
|
|
|
37817
38329
|
* The remove takes out the element at `index`, with what it holds, from the
|
|
37818
38330
|
* bytes `hash` names, and records it as one step whose undo puts it back
|
|
37819
38331
|
* under its parent. It answers the frame and the hash written, and refuses a
|
|
37820
|
-
* moved file as `stale-address` the way the insert does.
|
|
38332
|
+
* moved file as `stale-address` the way the insert does. Given `indexes` in
|
|
38333
|
+
* place of `index`, it takes out each as one write and one step, one held
|
|
38334
|
+
* inside another named going with that one, refused whole on any refusal.
|
|
37821
38335
|
*
|
|
37822
38336
|
* The move takes one element by index and the gap it goes into, both read
|
|
37823
38337
|
* in the frame as the hash names it, and records it as one step an undo
|
|
@@ -37832,7 +38346,9 @@ const recolorSchema = object$1({
|
|
|
37832
38346
|
* both as one step, so one undo restores both. It answers the element's
|
|
37833
38347
|
* index, the hash written, and the sizes a placement wrote, refuses as the move
|
|
37834
38348
|
* does, and refuses `reanchors-descendant` where a positioned parent would
|
|
37835
|
-
* move another element anchored above it.
|
|
38349
|
+
* move another element anchored above it. Given `places` in place of
|
|
38350
|
+
* `index`, `spot`, and `drop`, it places each as one write and one step,
|
|
38351
|
+
* refused whole on any refusal, and answers `placed` in the order sent.
|
|
37836
38352
|
*
|
|
37837
38353
|
* The recolor writes the color token `to` in place of the raw color `from`
|
|
37838
38354
|
* on every element under `index`, or under the frame's body without one,
|
|
@@ -37855,6 +38371,43 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
37855
38371
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
37856
38372
|
await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
|
|
37857
38373
|
const was = contentHash(await readFile(frame.path)) !== body.hash ? await version?.(ref, body.hash) ?? null : null;
|
|
38374
|
+
if ("edits" in body) {
|
|
38375
|
+
const result = editFrameFileAll(frame.path, body.hash, body.edits, (hash) => hash === body.hash ? was : null);
|
|
38376
|
+
if (!result.ok) return c.json({
|
|
38377
|
+
ok: false,
|
|
38378
|
+
error: {
|
|
38379
|
+
code: result.reason,
|
|
38380
|
+
message: result.detail,
|
|
38381
|
+
details: {
|
|
38382
|
+
ref,
|
|
38383
|
+
..."moved" in result ? { moved: result.moved } : {}
|
|
38384
|
+
}
|
|
38385
|
+
}
|
|
38386
|
+
}, 409);
|
|
38387
|
+
const written = result.spans.filter((span) => span.before !== span.after);
|
|
38388
|
+
if (written.length > 0) {
|
|
38389
|
+
const journal = history.journal();
|
|
38390
|
+
for (const span of written) journal.element(frame.path, ref, span);
|
|
38391
|
+
history.record({
|
|
38392
|
+
id: journal.id,
|
|
38393
|
+
changes: journal.changes,
|
|
38394
|
+
page: null,
|
|
38395
|
+
frames: [ref]
|
|
38396
|
+
});
|
|
38397
|
+
}
|
|
38398
|
+
await follow(frame, result.from, result.hash, result.remap);
|
|
38399
|
+
const data = {
|
|
38400
|
+
ref,
|
|
38401
|
+
index: result.indexes.at(-1) ?? 0,
|
|
38402
|
+
indexes: [...result.indexes],
|
|
38403
|
+
hash: result.hash,
|
|
38404
|
+
from: result.from
|
|
38405
|
+
};
|
|
38406
|
+
return c.json({
|
|
38407
|
+
ok: true,
|
|
38408
|
+
data
|
|
38409
|
+
});
|
|
38410
|
+
}
|
|
37858
38411
|
const result = editFrameFile(frame.path, {
|
|
37859
38412
|
index: body.index,
|
|
37860
38413
|
hash: body.hash
|
|
@@ -37977,6 +38530,34 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
37977
38530
|
const frame = await resolveFrameRef(root, body.ref, { cwd: root });
|
|
37978
38531
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
37979
38532
|
await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
|
|
38533
|
+
if ("indexes" in body) {
|
|
38534
|
+
const result = removeFrameFileAll(frame.path, body.hash, body.indexes);
|
|
38535
|
+
if (!result.ok) return c.json({
|
|
38536
|
+
ok: false,
|
|
38537
|
+
error: {
|
|
38538
|
+
code: result.reason,
|
|
38539
|
+
message: result.detail,
|
|
38540
|
+
details: { ref }
|
|
38541
|
+
}
|
|
38542
|
+
}, 409);
|
|
38543
|
+
const journal = history.journal();
|
|
38544
|
+
journal.deletedElements(frame.path, ref, result.spans);
|
|
38545
|
+
history.record({
|
|
38546
|
+
id: journal.id,
|
|
38547
|
+
changes: journal.changes,
|
|
38548
|
+
page: null,
|
|
38549
|
+
frames: [ref]
|
|
38550
|
+
});
|
|
38551
|
+
await follow(frame, body.hash, result.hash, result.remap);
|
|
38552
|
+
const data = {
|
|
38553
|
+
ref,
|
|
38554
|
+
hash: result.hash
|
|
38555
|
+
};
|
|
38556
|
+
return c.json({
|
|
38557
|
+
ok: true,
|
|
38558
|
+
data
|
|
38559
|
+
});
|
|
38560
|
+
}
|
|
37980
38561
|
const result = removeFrameFile(frame.path, body.hash, body.index);
|
|
37981
38562
|
if (!result.ok) return c.json({
|
|
37982
38563
|
ok: false,
|
|
@@ -38052,6 +38633,48 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
38052
38633
|
const frame = await resolveFrameRef(root, body.ref, { cwd: root });
|
|
38053
38634
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
38054
38635
|
await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
|
|
38636
|
+
if ("places" in body) {
|
|
38637
|
+
const result = placeFrameFileAll(frame.path, body.hash, body.places.map(({ index, spot, drop }) => ({
|
|
38638
|
+
index,
|
|
38639
|
+
spot,
|
|
38640
|
+
drop: spot ? [] : drop ?? []
|
|
38641
|
+
})), (html) => elementPlaceFacts(frameFrom(frame, html), tokenSheets(frame.project)));
|
|
38642
|
+
if (!result.ok) return c.json({
|
|
38643
|
+
ok: false,
|
|
38644
|
+
error: {
|
|
38645
|
+
code: result.reason,
|
|
38646
|
+
message: result.detail,
|
|
38647
|
+
details: { ref }
|
|
38648
|
+
}
|
|
38649
|
+
}, 409);
|
|
38650
|
+
const written = result.spans.filter((span) => span.before !== span.after);
|
|
38651
|
+
if (written.length > 0) {
|
|
38652
|
+
const journal = history.journal();
|
|
38653
|
+
for (const span of written) journal.element(frame.path, ref, span);
|
|
38654
|
+
history.record({
|
|
38655
|
+
id: journal.id,
|
|
38656
|
+
changes: journal.changes,
|
|
38657
|
+
page: null,
|
|
38658
|
+
frames: [ref]
|
|
38659
|
+
});
|
|
38660
|
+
}
|
|
38661
|
+
await follow(frame, body.hash, result.hash, result.remap);
|
|
38662
|
+
const placed = body.places.map(({ index }, at) => ({
|
|
38663
|
+
index,
|
|
38664
|
+
sized: [...result.sized[at] ?? []]
|
|
38665
|
+
}));
|
|
38666
|
+
const data = {
|
|
38667
|
+
ref,
|
|
38668
|
+
index: placed.at(-1)?.index ?? 0,
|
|
38669
|
+
hash: result.hash,
|
|
38670
|
+
sized: placed.at(-1)?.sized ?? [],
|
|
38671
|
+
placed
|
|
38672
|
+
};
|
|
38673
|
+
return c.json({
|
|
38674
|
+
ok: true,
|
|
38675
|
+
data
|
|
38676
|
+
});
|
|
38677
|
+
}
|
|
38055
38678
|
const source = readFrame(frame);
|
|
38056
38679
|
const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame.project)) : [];
|
|
38057
38680
|
const result = placeFrameFile(frame.path, body.hash, body.index, body.spot, facts, body.spot ? [] : body.drop ?? []);
|
|
@@ -39272,135 +39895,6 @@ function parseScale$1(value) {
|
|
|
39272
39895
|
if (value === "1" || value === "2" || value === "3") return Number(value);
|
|
39273
39896
|
return null;
|
|
39274
39897
|
}
|
|
39275
|
-
// src/server/board/pages.ts
|
|
39276
|
-
/** Notes and their images belong to the page they were pinned on, so a copy starts without them. */
|
|
39277
|
-
const NOT_COPIED = /* @__PURE__ */ new Set(["notes.json", ".notes"]);
|
|
39278
|
-
async function addPage(root, ref, { index, ...options }) {
|
|
39279
|
-
const page = await resolvePageRef(root, ref, {
|
|
39280
|
-
...options,
|
|
39281
|
-
allowMissing: true
|
|
39282
|
-
});
|
|
39283
|
-
if (existsSync(page.path)) throw taken(page, page.name);
|
|
39284
|
-
return recordOf(root, page, await reorder(root, page, async (order) => {
|
|
39285
|
-
await mkdir(page.path);
|
|
39286
|
-
await options.journal?.created(page.path);
|
|
39287
|
-
return insert(order, page.name, index ?? order.length);
|
|
39288
|
-
}, options.journal));
|
|
39289
|
-
}
|
|
39290
|
-
async function duplicatePage(root, ref, { name, ...options }) {
|
|
39291
|
-
const source = await resolvePageRef(root, ref, options);
|
|
39292
|
-
const projectDir = join(root, source.project);
|
|
39293
|
-
return recordOf(root, source, await reorder(root, source, async (order) => {
|
|
39294
|
-
const copy = await freeName(source, projectDir, name, false);
|
|
39295
|
-
const copyPath = join(projectDir, copy);
|
|
39296
|
-
await cp(source.path, copyPath, {
|
|
39297
|
-
recursive: true,
|
|
39298
|
-
errorOnExist: true,
|
|
39299
|
-
force: false,
|
|
39300
|
-
filter: (path) => isCopied(basename(path))
|
|
39301
|
-
});
|
|
39302
|
-
await options.journal?.created(copyPath);
|
|
39303
|
-
return {
|
|
39304
|
-
name: copy,
|
|
39305
|
-
order: insert(order, copy, order.indexOf(source.name) + 1)
|
|
39306
|
-
};
|
|
39307
|
-
}, options.journal));
|
|
39308
|
-
}
|
|
39309
|
-
async function renamePage(root, ref, newName, { journal, ...options }) {
|
|
39310
|
-
const page = await resolvePageRef(root, ref, options);
|
|
39311
|
-
const projectDir = join(root, page.project);
|
|
39312
|
-
return recordOf(root, page, await reorder(root, page, async (order) => {
|
|
39313
|
-
const renamed = await freeName(page, projectDir, newName, true);
|
|
39314
|
-
const renamedPath = join(projectDir, renamed);
|
|
39315
|
-
if (journal) await journal.moved(page.path, renamedPath);
|
|
39316
|
-
else await rename(page.path, renamedPath);
|
|
39317
|
-
return {
|
|
39318
|
-
name: renamed,
|
|
39319
|
-
order: order.map((name) => name === page.name ? renamed : name)
|
|
39320
|
-
};
|
|
39321
|
-
}, journal));
|
|
39322
|
-
}
|
|
39323
|
-
async function movePage(root, ref, { index, ...options }) {
|
|
39324
|
-
const page = await resolvePageRef(root, ref, options);
|
|
39325
|
-
return recordOf(root, page, await reorder(root, page, async (order) => insert(order.filter((name) => name !== page.name), page.name, index), options.journal));
|
|
39326
|
-
}
|
|
39327
|
-
async function deletePage(root, ref, { journal, ...options }) {
|
|
39328
|
-
const page = await resolvePageRef(root, ref, options);
|
|
39329
|
-
await reorder(root, page, async (order) => {
|
|
39330
|
-
if (journal) await journal.removed(page.path);
|
|
39331
|
-
else await rm(page.path, {
|
|
39332
|
-
recursive: true,
|
|
39333
|
-
force: true
|
|
39334
|
-
});
|
|
39335
|
-
return order.filter((name) => name !== page.name);
|
|
39336
|
-
}, journal);
|
|
39337
|
-
return { deleted: `${page.project}/${page.name}` };
|
|
39338
|
-
}
|
|
39339
|
-
/**
|
|
39340
|
-
* Runs one page change under the project file's lock, returning the page's
|
|
39341
|
-
* name after it and the order written. The file is read and
|
|
39342
|
-
* validated before `change` touches a folder, and written back holding exactly
|
|
39343
|
-
* the page folders on disk, in the order `change` returns, which the journal
|
|
39344
|
-
* is told of when it differs from the order the file held.
|
|
39345
|
-
*/
|
|
39346
|
-
async function reorder(root, page, change, journal) {
|
|
39347
|
-
const projectDir = join(root, page.project);
|
|
39348
|
-
const path = join(projectDir, PROJECT_FILE);
|
|
39349
|
-
return withLocks([path], async () => {
|
|
39350
|
-
const file = await readRecord(path, {
|
|
39351
|
-
...projectSpec,
|
|
39352
|
-
empty: emptyProject
|
|
39353
|
-
});
|
|
39354
|
-
const changed = await change(orderPages(file.pages, await listPageFolders(projectDir)));
|
|
39355
|
-
const { name, order } = Array.isArray(changed) ? {
|
|
39356
|
-
name: page.name,
|
|
39357
|
-
order: changed
|
|
39358
|
-
} : changed;
|
|
39359
|
-
const pages = orderPages(order, await listPageFolders(projectDir));
|
|
39360
|
-
await writeRecord(path, {
|
|
39361
|
-
...file,
|
|
39362
|
-
pages
|
|
39363
|
-
});
|
|
39364
|
-
if (journal && !isDeepStrictEqual(file.pages, pages)) journal.pages(projectDir, file.pages, pages);
|
|
39365
|
-
return {
|
|
39366
|
-
name,
|
|
39367
|
-
pages
|
|
39368
|
-
};
|
|
39369
|
-
});
|
|
39370
|
-
}
|
|
39371
|
-
async function recordOf(root, page, { name, pages }) {
|
|
39372
|
-
return scanPage(root, page.project, name, pages.indexOf(name));
|
|
39373
|
-
}
|
|
39374
|
-
/**
|
|
39375
|
-
* The explicit name when free and valid, else the next free copy of the
|
|
39376
|
-
* source's. A rename frees the source's own name, so a case-only rename runs.
|
|
39377
|
-
*/
|
|
39378
|
-
async function freeName(source, projectDir, name, freesSource) {
|
|
39379
|
-
const others = (await listPageFolders(projectDir)).filter((page) => !freesSource || page !== source.name);
|
|
39380
|
-
if (name === void 0) return nextFreeName(source.name, others);
|
|
39381
|
-
assertValidName("page", name);
|
|
39382
|
-
const holder = matchName(others, name);
|
|
39383
|
-
if (holder) throw taken(source, holder);
|
|
39384
|
-
return name;
|
|
39385
|
-
}
|
|
39386
|
-
function insert(order, name, index) {
|
|
39387
|
-
const at = Math.max(0, Math.min(index, order.length));
|
|
39388
|
-
return [
|
|
39389
|
-
...order.slice(0, at),
|
|
39390
|
-
name,
|
|
39391
|
-
...order.slice(at)
|
|
39392
|
-
];
|
|
39393
|
-
}
|
|
39394
|
-
/** Whether a copy of a page or project folder takes the file or folder `name`. */
|
|
39395
|
-
function isCopied(name) {
|
|
39396
|
-
return !NOT_COPIED.has(name) && !name.endsWith(".lock") && !name.endsWith(".tmp");
|
|
39397
|
-
}
|
|
39398
|
-
function taken(page, holder) {
|
|
39399
|
-
return new FrameboardError("name-taken", `Project ${page.project} already has a page ${holder}.`, {
|
|
39400
|
-
project: page.project,
|
|
39401
|
-
name: holder
|
|
39402
|
-
});
|
|
39403
|
-
}
|
|
39404
39898
|
// src/server/board/paste.ts
|
|
39405
39899
|
/** Reads each frame's file and placement under its page's lock, in the order given. */
|
|
39406
39900
|
async function holdFrames(root, refs, options) {
|
|
@@ -39465,71 +39959,6 @@ async function pasteFrames(root, pageRef, held, options) {
|
|
|
39465
39959
|
}, journal);
|
|
39466
39960
|
return Promise.all(names.map((name) => readFrame$1(root, `${target.project}/${target.name}/${name}`, options)));
|
|
39467
39961
|
}
|
|
39468
|
-
// src/server/board/projects.ts
|
|
39469
|
-
/** A new project holding one empty page. */
|
|
39470
|
-
async function addProject(root, name, now = /* @__PURE__ */ new Date(), { journal } = {}) {
|
|
39471
|
-
assertValidName("project", name);
|
|
39472
|
-
await assertFree$1(root, name);
|
|
39473
|
-
await mkdir(join(root, name, START_PAGE), { recursive: true });
|
|
39474
|
-
await writeRecord(join(root, name, PROJECT_FILE), {
|
|
39475
|
-
version: 1,
|
|
39476
|
-
pages: [START_PAGE],
|
|
39477
|
-
createdAt: now.toISOString()
|
|
39478
|
-
});
|
|
39479
|
-
await journal?.created(join(root, name));
|
|
39480
|
-
return scanProject(root, name);
|
|
39481
|
-
}
|
|
39482
|
-
async function renameProject(root, name, newName, { journal } = {}) {
|
|
39483
|
-
const project = await resolveProject(root, name);
|
|
39484
|
-
assertValidName("project", newName);
|
|
39485
|
-
await assertFree$1(root, newName, project.name);
|
|
39486
|
-
const renamed = join(root, newName);
|
|
39487
|
-
if (journal) await journal.moved(project.path, renamed);
|
|
39488
|
-
else await rename(project.path, renamed);
|
|
39489
|
-
return scanProject(root, newName);
|
|
39490
|
-
}
|
|
39491
|
-
/**
|
|
39492
|
-
* A copy of the project under the next free name, without its notes, and
|
|
39493
|
-
* stamped as made `now`.
|
|
39494
|
-
*/
|
|
39495
|
-
async function duplicateProject(root, name, now = /* @__PURE__ */ new Date(), { journal } = {}) {
|
|
39496
|
-
const source = await resolveProject(root, name);
|
|
39497
|
-
const file = await readRecord(join(source.path, PROJECT_FILE), {
|
|
39498
|
-
...projectSpec,
|
|
39499
|
-
empty: emptyProject
|
|
39500
|
-
});
|
|
39501
|
-
const copy = nextFreeName(source.name, await listProjects(root));
|
|
39502
|
-
const copyPath = join(root, copy);
|
|
39503
|
-
await cp(source.path, copyPath, {
|
|
39504
|
-
recursive: true,
|
|
39505
|
-
errorOnExist: true,
|
|
39506
|
-
force: false,
|
|
39507
|
-
filter: (path) => isCopied(basename(path))
|
|
39508
|
-
});
|
|
39509
|
-
await writeRecord(join(copyPath, PROJECT_FILE), {
|
|
39510
|
-
...file,
|
|
39511
|
-
createdAt: now.toISOString()
|
|
39512
|
-
});
|
|
39513
|
-
await journal?.created(copyPath);
|
|
39514
|
-
return scanProject(root, copy);
|
|
39515
|
-
}
|
|
39516
|
-
async function deleteProject(root, name, { journal } = {}) {
|
|
39517
|
-
const project = await resolveProject(root, name);
|
|
39518
|
-
if (journal) await journal.removed(project.path);
|
|
39519
|
-
else await rm(project.path, {
|
|
39520
|
-
recursive: true,
|
|
39521
|
-
force: true
|
|
39522
|
-
});
|
|
39523
|
-
return { deleted: project.name };
|
|
39524
|
-
}
|
|
39525
|
-
/** Throws `name-taken` when another project holds `name` in any case. */
|
|
39526
|
-
async function assertFree$1(root, name, self) {
|
|
39527
|
-
const taken = matchName((await listProjects(root)).filter((project) => project !== self), name);
|
|
39528
|
-
if (taken) throw new FrameboardError("name-taken", `The board already has a project ${taken}.`, {
|
|
39529
|
-
name,
|
|
39530
|
-
taken
|
|
39531
|
-
});
|
|
39532
|
-
}
|
|
39533
39962
|
// src/server/board/sections.ts
|
|
39534
39963
|
/** The name a section takes when the developer gives none, `-2` and on once taken. */
|
|
39535
39964
|
const DEFAULT_NAME = "section";
|
|
@@ -39706,6 +40135,16 @@ const sectionSchema = object$1({
|
|
|
39706
40135
|
});
|
|
39707
40136
|
const projectAddSchema = object$1({ name: name.optional() });
|
|
39708
40137
|
const projectSchema = object$1({ ref });
|
|
40138
|
+
/** More projects than any board holds, so a body cannot grow without bound. */
|
|
40139
|
+
const projectRefs$1 = array$1(ref).min(1).max(1e3);
|
|
40140
|
+
const projectGroupSchema = object$1({
|
|
40141
|
+
refs: projectRefs$1,
|
|
40142
|
+
group: name.nullable()
|
|
40143
|
+
});
|
|
40144
|
+
const projectArchiveSchema = object$1({
|
|
40145
|
+
refs: projectRefs$1,
|
|
40146
|
+
archived: boolean$1()
|
|
40147
|
+
});
|
|
39709
40148
|
const projectTokensSchema = object$1({
|
|
39710
40149
|
ref,
|
|
39711
40150
|
accent: _enum$1(Object.keys(STARTER_ACCENTS)).default(DEFAULT_LOOK.accent),
|
|
@@ -40091,6 +40530,31 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
40091
40530
|
data: project
|
|
40092
40531
|
});
|
|
40093
40532
|
});
|
|
40533
|
+
/** Refuses a filing of any project another session holds, as rename does, before anything is written. */
|
|
40534
|
+
const refuseHeldProjects = async (refs) => {
|
|
40535
|
+
const projects = await Promise.all(refs.map((project) => resolveProject(root, project)));
|
|
40536
|
+
await refuseHeld(projects.map((project) => project.name));
|
|
40537
|
+
};
|
|
40538
|
+
/** Files the named projects in one folder, a null group taking them out of theirs. */
|
|
40539
|
+
app.post("/api/project/group", async (c) => {
|
|
40540
|
+
const body = await parseBody$1(c.req.raw, projectGroupSchema);
|
|
40541
|
+
await refuseHeldProjects(body.refs);
|
|
40542
|
+
const projects = await recorded((journal) => fileProjects(root, body.refs, { group: body.group }, { journal }), onHome);
|
|
40543
|
+
return c.json({
|
|
40544
|
+
ok: true,
|
|
40545
|
+
data: projects
|
|
40546
|
+
});
|
|
40547
|
+
});
|
|
40548
|
+
/** Moves the named projects into home's Archived section, or back out of it. */
|
|
40549
|
+
app.post("/api/project/archive", async (c) => {
|
|
40550
|
+
const body = await parseBody$1(c.req.raw, projectArchiveSchema);
|
|
40551
|
+
await refuseHeldProjects(body.refs);
|
|
40552
|
+
const projects = await recorded((journal) => fileProjects(root, body.refs, { archived: body.archived }, { journal }), onHome);
|
|
40553
|
+
return c.json({
|
|
40554
|
+
ok: true,
|
|
40555
|
+
data: projects
|
|
40556
|
+
});
|
|
40557
|
+
});
|
|
40094
40558
|
/** Creates the project's `tokens.css` from a preset, refusing where any sheet already reaches it. */
|
|
40095
40559
|
app.post("/api/project/tokens", async (c) => {
|
|
40096
40560
|
const body = await parseBody$1(c.req.raw, projectTokensSchema);
|
|
@@ -42624,6 +43088,10 @@ const projectRecordSchema = object$1({
|
|
|
42624
43088
|
modifiedAt: string$1(),
|
|
42625
43089
|
/** When the project was made, null for one made before the time was recorded. */
|
|
42626
43090
|
createdAt: string$1().nullable(),
|
|
43091
|
+
/** The folder home files the project under, null for one in no folder. */
|
|
43092
|
+
group: string$1().nullable(),
|
|
43093
|
+
/** Whether home holds the project out of the main list, in its Archived section. */
|
|
43094
|
+
archived: boolean$1(),
|
|
42627
43095
|
projectFileError: recordErrorSchema,
|
|
42628
43096
|
pages: array$1(pageRecordSchema)
|
|
42629
43097
|
});
|
|
@@ -42973,6 +43441,25 @@ const inspectResultSchema = object$1({
|
|
|
42973
43441
|
editable: boolean$1(),
|
|
42974
43442
|
elements: array$1(inspectedElementSchema)
|
|
42975
43443
|
});
|
|
43444
|
+
// src/shared/records/references.ts
|
|
43445
|
+
/** What `references sync` returns, each path relative to the folder and sorted. */
|
|
43446
|
+
const referencesSyncSchema = object$1({
|
|
43447
|
+
folder: string$1(),
|
|
43448
|
+
written: array$1(string$1()),
|
|
43449
|
+
removed: array$1(string$1())
|
|
43450
|
+
});
|
|
43451
|
+
/**
|
|
43452
|
+
* What `references sync --check` returns, and the details of its
|
|
43453
|
+
* `references-stale`, each path relative to the folder and sorted. `pngDiffers`
|
|
43454
|
+
* warns and never fails, since a PNG varies with the browser build.
|
|
43455
|
+
*/
|
|
43456
|
+
const referencesCheckSchema = object$1({
|
|
43457
|
+
folder: string$1(),
|
|
43458
|
+
changed: array$1(string$1()),
|
|
43459
|
+
missing: array$1(string$1()),
|
|
43460
|
+
stray: array$1(string$1()),
|
|
43461
|
+
pngDiffers: array$1(string$1())
|
|
43462
|
+
});
|
|
42976
43463
|
const tokenRowSchema = object$1({
|
|
42977
43464
|
/** The custom property, with its leading `--`. */
|
|
42978
43465
|
name: string$1(),
|
|
@@ -43026,7 +43513,9 @@ const RECORDS = {
|
|
|
43026
43513
|
assetAdd: assetAddResultSchema,
|
|
43027
43514
|
elements: elementTreeSchema,
|
|
43028
43515
|
selection: selectionResultSchema,
|
|
43029
|
-
find: findResultSchema
|
|
43516
|
+
find: findResultSchema,
|
|
43517
|
+
referencesSync: referencesSyncSchema,
|
|
43518
|
+
referencesCheck: referencesCheckSchema
|
|
43030
43519
|
};
|
|
43031
43520
|
// src/cli/docs/content-format.ts
|
|
43032
43521
|
/** The content format `docs` prints, built from the constants the verbs run on. */
|
|
@@ -47414,6 +47903,275 @@ function registerProject(program, context) {
|
|
|
47414
47903
|
};
|
|
47415
47904
|
});
|
|
47416
47905
|
}
|
|
47906
|
+
// src/server/references/assets.ts
|
|
47907
|
+
/**
|
|
47908
|
+
* The files a frame loads inside its project's `assets/`, by their path there,
|
|
47909
|
+
* sorted and each once. A load naming no file is left to the link check's
|
|
47910
|
+
* `missing-file`, so it copies nothing here. A file in the frame's page folder
|
|
47911
|
+
* refuses `page-file-load`, since the link check allows it and a reference
|
|
47912
|
+
* folder holds nothing it could resolve to, so it would land broken.
|
|
47913
|
+
*/
|
|
47914
|
+
function frameAssets(source) {
|
|
47915
|
+
const assets = assetsDirOf(source);
|
|
47916
|
+
const found = /* @__PURE__ */ new Set();
|
|
47917
|
+
for (const load of frameLoads(source)) {
|
|
47918
|
+
const target = localTarget(load.url, load.base);
|
|
47919
|
+
if (target === null) continue;
|
|
47920
|
+
if (!statSync(target, { throwIfNoEntry: false })?.isFile()) continue;
|
|
47921
|
+
if (isInside(assets, target)) found.add(relative(assets, target).split(sep).join("/"));
|
|
47922
|
+
else if (isInside(source.pageDir, target)) throw new FrameboardError("page-file-load", `${source.ref} loads ${load.url} from its page folder, which a reference folder cannot hold. Move the file into the project's assets/ and link it there. Nothing written.`, {
|
|
47923
|
+
frame: source.ref,
|
|
47924
|
+
load: load.url
|
|
47925
|
+
});
|
|
47926
|
+
}
|
|
47927
|
+
return [...found].sort();
|
|
47928
|
+
}
|
|
47929
|
+
// src/server/references/drift.ts
|
|
47930
|
+
/** Compares what a sync would write against the files the folder holds, the HTML as the source and a PNG as derived. */
|
|
47931
|
+
function classifyDrift(expected, tracked) {
|
|
47932
|
+
const changed = [];
|
|
47933
|
+
const pngDiffers = [];
|
|
47934
|
+
const missing = [];
|
|
47935
|
+
for (const [path, data] of expected) {
|
|
47936
|
+
const copy = tracked.get(path);
|
|
47937
|
+
if (copy === void 0) missing.push(path);
|
|
47938
|
+
else if (!Buffer.from(copy).equals(Buffer.from(data))) (path.endsWith(".png") ? pngDiffers : changed).push(path);
|
|
47939
|
+
}
|
|
47940
|
+
return {
|
|
47941
|
+
changed,
|
|
47942
|
+
pngDiffers,
|
|
47943
|
+
missing,
|
|
47944
|
+
stray: [...tracked.keys()].filter((path) => !expected.has(path))
|
|
47945
|
+
};
|
|
47946
|
+
}
|
|
47947
|
+
// src/server/references/format.ts
|
|
47948
|
+
/** A frame's asset link, never the tail of a longer path such as `../../assets/`. */
|
|
47949
|
+
const BOARD_ASSETS = /(?<![\w./-])\.\.\/assets\//g;
|
|
47950
|
+
const OPTIONS = {
|
|
47951
|
+
semi: false,
|
|
47952
|
+
singleQuote: true,
|
|
47953
|
+
printWidth: 80,
|
|
47954
|
+
sortPackageJson: false
|
|
47955
|
+
};
|
|
47956
|
+
/**
|
|
47957
|
+
* What the folder holds of a board frame: its asset links moved to its
|
|
47958
|
+
* project's subtree, so two projects never collide, formatted so a reference
|
|
47959
|
+
* diffs line by line while the board file stays as the agent wrote it. The
|
|
47960
|
+
* write and `--check` both build through it, so they compare the same bytes.
|
|
47961
|
+
*/
|
|
47962
|
+
async function toReference(source, reference, folder) {
|
|
47963
|
+
const result = await (await importFormat(folder))(`${reference}.html`, withProjectAssets(source), OPTIONS);
|
|
47964
|
+
const [error] = result.errors;
|
|
47965
|
+
if (error) {
|
|
47966
|
+
const [reason] = error.message.split("\n");
|
|
47967
|
+
throw new FrameboardError("format-refused", `${reference} does not parse as HTML: ${reason}. Fix its board frame and sync again. Nothing written.`, { reference });
|
|
47968
|
+
}
|
|
47969
|
+
return result.code;
|
|
47970
|
+
}
|
|
47971
|
+
/**
|
|
47972
|
+
* Rewrites the frame's text only at the spans its loads occupy, so text naming
|
|
47973
|
+
* `../assets/` that loads nothing, such as a `<code>` sample, keeps its bytes.
|
|
47974
|
+
*/
|
|
47975
|
+
function withProjectAssets(source) {
|
|
47976
|
+
const framePath = boardPath(source.root, source.path);
|
|
47977
|
+
const spans = /* @__PURE__ */ new Map();
|
|
47978
|
+
for (const { path, location } of frameLoads(source)) if (path === framePath && location) spans.set(location.startOffset, location.endOffset);
|
|
47979
|
+
let html = source.html;
|
|
47980
|
+
for (const [start, end] of [...spans].sort(([a], [b]) => b - a)) {
|
|
47981
|
+
const span = html.slice(start, end).replace(BOARD_ASSETS, `../assets/${source.project}/`);
|
|
47982
|
+
html = `${html.slice(0, start)}${span}${html.slice(end)}`;
|
|
47983
|
+
}
|
|
47984
|
+
return html;
|
|
47985
|
+
}
|
|
47986
|
+
async function importFormat(folder) {
|
|
47987
|
+
try {
|
|
47988
|
+
const { format } = await import("oxfmt");
|
|
47989
|
+
return format;
|
|
47990
|
+
} catch {
|
|
47991
|
+
try {
|
|
47992
|
+
const path = createRequire(join(folder, "frames.json")).resolve("oxfmt");
|
|
47993
|
+
const { format } = await import(
|
|
47994
|
+
/* @vite-ignore */
|
|
47995
|
+
pathToFileURL(path).href
|
|
47996
|
+
);
|
|
47997
|
+
return format;
|
|
47998
|
+
} catch (error) {
|
|
47999
|
+
const version = peerDependencies.oxfmt;
|
|
48000
|
+
const install = {
|
|
48001
|
+
npm: `npm install --save-dev oxfmt@${version}`,
|
|
48002
|
+
bun: `bun add --dev oxfmt@${version}`
|
|
48003
|
+
};
|
|
48004
|
+
throw new FrameboardError("formatter-not-found", `references sync needs oxfmt to format each reference, and it found none. Install it in the project holding ${folder} with ${install.npm}, or ${install.bun}.`, { install }, { cause: error });
|
|
48005
|
+
}
|
|
48006
|
+
}
|
|
48007
|
+
}
|
|
48008
|
+
// src/server/references/frame-map.ts
|
|
48009
|
+
const REFERENCE = /^[a-z0-9]+(-[a-z0-9]+)*\/[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
48010
|
+
const BOARD_REF = /^[^/\s]+\/[^/\s]+\/[^/\s]+$/;
|
|
48011
|
+
/**
|
|
48012
|
+
* Reads `frames.json`, mapping each reference, `<group>/<name>`, to the
|
|
48013
|
+
* board frame `<project>/<page>/<frame>` it is captured from. An entry in
|
|
48014
|
+
* any other shape refuses rather than filing into the wrong folder.
|
|
48015
|
+
*/
|
|
48016
|
+
function parseFrameMap(json) {
|
|
48017
|
+
const parsed = parseJson(json);
|
|
48018
|
+
const frames = typeof parsed === "object" && parsed !== null && "frames" in parsed ? parsed.frames : void 0;
|
|
48019
|
+
if (typeof frames !== "object" || frames === null || Array.isArray(frames)) throw new FrameboardError("frame-map-invalid", "frames.json needs a frames object.");
|
|
48020
|
+
if (Object.keys(frames).length === 0) throw new FrameboardError("frame-map-invalid", "frames.json maps no frames, so a sync would remove every reference.");
|
|
48021
|
+
const map = /* @__PURE__ */ new Map();
|
|
48022
|
+
for (const [reference, ref] of Object.entries(frames)) {
|
|
48023
|
+
if (!REFERENCE.test(reference)) throw new FrameboardError("frame-map-invalid", `frames.json entry "${reference}" needs a kebab-case <group>/<name>.`, { reference });
|
|
48024
|
+
if (typeof ref !== "string" || !BOARD_REF.test(ref)) throw new FrameboardError("frame-map-invalid", `frames.json entry "${reference}" needs a board frame as <project>/<page>/<frame>.`, { reference });
|
|
48025
|
+
map.set(reference, ref);
|
|
48026
|
+
}
|
|
48027
|
+
return map;
|
|
48028
|
+
}
|
|
48029
|
+
function parseJson(json) {
|
|
48030
|
+
try {
|
|
48031
|
+
return JSON.parse(json);
|
|
48032
|
+
} catch (error) {
|
|
48033
|
+
throw new FrameboardError("frame-map-invalid", "frames.json does not parse as JSON.", {}, { cause: error });
|
|
48034
|
+
}
|
|
48035
|
+
}
|
|
48036
|
+
/** The mapped board frames the board does not hold. */
|
|
48037
|
+
function missingFrames(map, board) {
|
|
48038
|
+
return [...map.values()].filter((ref) => !board.has(ref));
|
|
48039
|
+
}
|
|
48040
|
+
// src/server/references/sync.ts
|
|
48041
|
+
/**
|
|
48042
|
+
* Writes what the board holds into the folder and removes every other file
|
|
48043
|
+
* below its first level. It builds the whole output first, so a refusal leaves
|
|
48044
|
+
* the folder as it was.
|
|
48045
|
+
*/
|
|
48046
|
+
async function syncReferences(options) {
|
|
48047
|
+
const { folder } = options;
|
|
48048
|
+
const output = await buildOutput(options);
|
|
48049
|
+
const removed = (await heldFiles(folder)).filter((path) => !output.has(path));
|
|
48050
|
+
await Promise.all([...output].map(async ([path, data]) => {
|
|
48051
|
+
await mkdir(dirname(join(folder, path)), { recursive: true });
|
|
48052
|
+
await writeFile(join(folder, path), data);
|
|
48053
|
+
}));
|
|
48054
|
+
await Promise.all(removed.map((path) => rm(join(folder, path))));
|
|
48055
|
+
await removeEmptyFolders(folder, folder);
|
|
48056
|
+
return {
|
|
48057
|
+
folder,
|
|
48058
|
+
written: [...output.keys()].sort(),
|
|
48059
|
+
removed: removed.sort()
|
|
48060
|
+
};
|
|
48061
|
+
}
|
|
48062
|
+
/** Compares the folder against what a sync would write, writing nothing. */
|
|
48063
|
+
async function checkReferences(options) {
|
|
48064
|
+
const { folder } = options;
|
|
48065
|
+
const output = await buildOutput(options);
|
|
48066
|
+
const held = /* @__PURE__ */ new Map();
|
|
48067
|
+
await Promise.all((await heldFiles(folder)).map(async (path) => {
|
|
48068
|
+
held.set(path, await readFile(join(folder, path)));
|
|
48069
|
+
}));
|
|
48070
|
+
const drift = classifyDrift(output, held);
|
|
48071
|
+
return {
|
|
48072
|
+
folder,
|
|
48073
|
+
changed: [...drift.changed].sort(),
|
|
48074
|
+
missing: [...drift.missing].sort(),
|
|
48075
|
+
stray: [...drift.stray].sort(),
|
|
48076
|
+
pngDiffers: [...drift.pngDiffers].sort()
|
|
48077
|
+
};
|
|
48078
|
+
}
|
|
48079
|
+
async function buildOutput({ root, folder, facesDir }) {
|
|
48080
|
+
const map = parseFrameMap(await readFile(join(folder, "frames.json"), "utf8"));
|
|
48081
|
+
const frames = await mappedFrames(root, map);
|
|
48082
|
+
const output = /* @__PURE__ */ new Map();
|
|
48083
|
+
await Promise.all([...map].map(async ([reference, ref]) => {
|
|
48084
|
+
const { project, page, name } = frameOf(frames, ref);
|
|
48085
|
+
const source = readFrame({
|
|
48086
|
+
root,
|
|
48087
|
+
project,
|
|
48088
|
+
page,
|
|
48089
|
+
name
|
|
48090
|
+
});
|
|
48091
|
+
output.set(`${reference}.html`, await toReference(source, reference, folder));
|
|
48092
|
+
for (const asset of frameAssets(source)) output.set(join("assets", project, asset), await readFile(join(assetsDirOf(source), asset)));
|
|
48093
|
+
}));
|
|
48094
|
+
const captures = await mkdtemp(join(tmpdir(), "frameboard-references-"));
|
|
48095
|
+
try {
|
|
48096
|
+
const images = await withFrameHost({
|
|
48097
|
+
root,
|
|
48098
|
+
facesDir
|
|
48099
|
+
}, "references sync", (browser, baseUrl) => captureFrameImages(browser, {
|
|
48100
|
+
baseUrl,
|
|
48101
|
+
frames: [...frames.values()],
|
|
48102
|
+
themes: THEMES,
|
|
48103
|
+
out: captures
|
|
48104
|
+
}));
|
|
48105
|
+
for (const [reference, ref] of map) for (const image of images.filter((image) => image.ref === ref)) output.set(`${reference}-${image.theme}.png`, await readFile(image.path));
|
|
48106
|
+
} finally {
|
|
48107
|
+
await rm(captures, {
|
|
48108
|
+
recursive: true,
|
|
48109
|
+
force: true
|
|
48110
|
+
});
|
|
48111
|
+
}
|
|
48112
|
+
return output;
|
|
48113
|
+
}
|
|
48114
|
+
/** The board frame each mapped ref names, each once, or a refusal listing every one it lacks. */
|
|
48115
|
+
async function mappedFrames(root, map) {
|
|
48116
|
+
const { projects } = await scanBoard(root);
|
|
48117
|
+
const board = new Map(projects.flatMap((project) => project.pages).flatMap((page) => page.frames).map((frame) => [frame.ref, frame]));
|
|
48118
|
+
const missing = missingFrames(map, new Set(board.keys()));
|
|
48119
|
+
if (missing.length > 0) throw new FrameboardError("frame-not-found", `No board frame for: ${missing.join(", ")}. Nothing written.`, { missing });
|
|
48120
|
+
return new Map([...map.values()].map((ref) => [ref, frameOf(board, ref)]));
|
|
48121
|
+
}
|
|
48122
|
+
function frameOf(frames, ref) {
|
|
48123
|
+
const frame = frames.get(ref);
|
|
48124
|
+
if (!frame) throw new Error(`${ref} was not resolved.`);
|
|
48125
|
+
return frame;
|
|
48126
|
+
}
|
|
48127
|
+
/** Every file below the folder's first level, which the sync owns. A top-level file is the consumer's own. */
|
|
48128
|
+
async function heldFiles(folder) {
|
|
48129
|
+
return (await readdir(folder, {
|
|
48130
|
+
recursive: true,
|
|
48131
|
+
withFileTypes: true
|
|
48132
|
+
})).filter((entry) => entry.isFile()).map((entry) => relative(folder, join(entry.parentPath, entry.name))).filter((path) => path.includes(sep));
|
|
48133
|
+
}
|
|
48134
|
+
async function removeEmptyFolders(dir, folder) {
|
|
48135
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
48136
|
+
await Promise.all(entries.filter((entry) => entry.isDirectory()).map((entry) => removeEmptyFolders(join(dir, entry.name), folder)));
|
|
48137
|
+
if (dir !== folder && (await readdir(dir)).length === 0) await rmdir(dir);
|
|
48138
|
+
}
|
|
48139
|
+
// src/cli/commands/references.ts
|
|
48140
|
+
function registerReferences(program, context) {
|
|
48141
|
+
const { io } = context;
|
|
48142
|
+
act(addVerb(program.command("references").description("Fill a folder of design references from the board's frames"), "sync", "Write each frame <folder>/frames.json maps as its HTML, a PNG per theme, and the project assets it loads, removing every other file below the folder's first level").argument("<folder>", "the folder holding frames.json").option("--check", "write nothing, and exit 14 when the folder differs from what a sync would write"), context, async ([given = ""], options) => {
|
|
48143
|
+
const folder = resolve(io.cwd, given);
|
|
48144
|
+
if (!existsSync(join(folder, "frames.json"))) throw new FrameboardError("usage", `${folder} holds no frames.json, mapping each reference to a board frame.`);
|
|
48145
|
+
const target = {
|
|
48146
|
+
root: await boardOf(options, io),
|
|
48147
|
+
folder,
|
|
48148
|
+
facesDir: context.facesDir
|
|
48149
|
+
};
|
|
48150
|
+
if (options.check) {
|
|
48151
|
+
const result = await checkReferences(target);
|
|
48152
|
+
const lines = driftLines(result);
|
|
48153
|
+
if (result.changed.length + result.missing.length + result.stray.length > 0) throw new FrameboardError("references-stale", [`${folder} differs from what a sync would write.`, ...lines].join("\n"), { ...result });
|
|
48154
|
+
return {
|
|
48155
|
+
data: result,
|
|
48156
|
+
human: [`${folder} matches the board.`, ...lines].join("\n")
|
|
48157
|
+
};
|
|
48158
|
+
}
|
|
48159
|
+
const result = await syncReferences(target);
|
|
48160
|
+
const removed = result.removed.length > 0 ? `, removed ${result.removed.length}` : "";
|
|
48161
|
+
return {
|
|
48162
|
+
data: result,
|
|
48163
|
+
human: `Wrote ${result.written.length} files to ${folder}${removed}.`
|
|
48164
|
+
};
|
|
48165
|
+
});
|
|
48166
|
+
}
|
|
48167
|
+
function driftLines({ changed, missing, stray, pngDiffers }) {
|
|
48168
|
+
return [
|
|
48169
|
+
...changed.map((path) => `Changed: ${path}`),
|
|
48170
|
+
...missing.map((path) => `Missing: ${path}`),
|
|
48171
|
+
...stray.map((path) => `Stray: ${path}`),
|
|
48172
|
+
...pngDiffers.map((path) => `Warning: PNG bytes differ: ${path}`)
|
|
48173
|
+
];
|
|
48174
|
+
}
|
|
47417
48175
|
// src/cli/commands/selection.ts
|
|
47418
48176
|
function registerSelection(program, context) {
|
|
47419
48177
|
const { io } = context;
|
|
@@ -52444,6 +53202,7 @@ function createProgram(context) {
|
|
|
52444
53202
|
registerEditing(program, context);
|
|
52445
53203
|
registerCapture(program, faced);
|
|
52446
53204
|
registerInspect(program, faced);
|
|
53205
|
+
registerReferences(program, faced);
|
|
52447
53206
|
registerDocs(program, context);
|
|
52448
53207
|
return program;
|
|
52449
53208
|
}
|