frameboard 0.26.0 → 0.28.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 +386 -48
- package/dist/client/assets/index-BkEyIB6D.css +2 -0
- package/dist/client/assets/index-Cy3MOstR.js +114 -0
- package/dist/client/index.html +2 -2
- package/package.json +5 -2
- package/dist/client/assets/index-DevfxYLc.js +0 -114
- package/dist/client/assets/index-DqicY-g0.css +0 -2
package/dist/cli.js
CHANGED
|
@@ -9517,7 +9517,7 @@ async function isDirectory(path) {
|
|
|
9517
9517
|
}
|
|
9518
9518
|
}
|
|
9519
9519
|
// package.json
|
|
9520
|
-
var version$1 = "0.
|
|
9520
|
+
var version$1 = "0.28.0";
|
|
9521
9521
|
var dependencies = { "playwright-core": "1.64.1" };
|
|
9522
9522
|
var peerDependencies = { "oxfmt": "0.75.0" };
|
|
9523
9523
|
// src/shared/version.ts
|
|
@@ -21307,7 +21307,7 @@ const LOG_FILE = "log.json";
|
|
|
21307
21307
|
const VERSIONS_FOLDER = "versions";
|
|
21308
21308
|
const VERSION_EXTENSION = ".html";
|
|
21309
21309
|
const HASH = /^[0-9a-f]{64}$/;
|
|
21310
|
-
const changeSchema = looseObject({
|
|
21310
|
+
const changeSchema$1 = looseObject({
|
|
21311
21311
|
id: string$1(),
|
|
21312
21312
|
frame: string$1(),
|
|
21313
21313
|
at: string$1(),
|
|
@@ -21325,7 +21325,7 @@ const changeSchema = looseObject({
|
|
|
21325
21325
|
});
|
|
21326
21326
|
const logSchema = looseObject({
|
|
21327
21327
|
version: literal(1),
|
|
21328
|
-
changes: array$1(changeSchema)
|
|
21328
|
+
changes: array$1(changeSchema$1)
|
|
21329
21329
|
});
|
|
21330
21330
|
/** `.run/changes/`, which holds the change log across a restart. */
|
|
21331
21331
|
function changesFolder(root) {
|
|
@@ -21557,7 +21557,7 @@ function versionKey(ref, hash) {
|
|
|
21557
21557
|
/** The files and folders a step wrote, being every rewrite, creation, removal, and move. */
|
|
21558
21558
|
function writtenPaths(step) {
|
|
21559
21559
|
return step.changes.flatMap((change) => {
|
|
21560
|
-
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];
|
|
21561
21561
|
if (change.kind === "moved") return [change.from, change.to];
|
|
21562
21562
|
return [];
|
|
21563
21563
|
});
|
|
@@ -35986,6 +35986,31 @@ const NO_COLOR = /* @__PURE__ */ new Set([
|
|
|
35986
35986
|
"currentcolor",
|
|
35987
35987
|
"none"
|
|
35988
35988
|
]);
|
|
35989
|
+
/**
|
|
35990
|
+
* Elements a color's `uses` never names: `body`, which the board selects as the
|
|
35991
|
+
* frame, and those that draw no box of their own, whatever color they inherit.
|
|
35992
|
+
*/
|
|
35993
|
+
const NEVER_USES = /* @__PURE__ */ new Set([
|
|
35994
|
+
"html",
|
|
35995
|
+
"head",
|
|
35996
|
+
"body",
|
|
35997
|
+
"title",
|
|
35998
|
+
"meta",
|
|
35999
|
+
"link",
|
|
36000
|
+
"base",
|
|
36001
|
+
"style",
|
|
36002
|
+
"script",
|
|
36003
|
+
"noscript",
|
|
36004
|
+
"template",
|
|
36005
|
+
"br",
|
|
36006
|
+
"wbr",
|
|
36007
|
+
"source",
|
|
36008
|
+
"track",
|
|
36009
|
+
"area",
|
|
36010
|
+
"datalist",
|
|
36011
|
+
"optgroup",
|
|
36012
|
+
"option"
|
|
36013
|
+
]);
|
|
35989
36014
|
/** Words of a `border` or `background` shorthand that are never its color. */
|
|
35990
36015
|
const NOT_COLOR = /* @__PURE__ */ new Set([
|
|
35991
36016
|
"none",
|
|
@@ -36070,14 +36095,21 @@ function frameStyles(source, tokens, index) {
|
|
|
36070
36095
|
flow: flowOf(buildCascade(source, tokens, { properties: FLOW_PROPERTIES }), target)
|
|
36071
36096
|
} : null;
|
|
36072
36097
|
const root = target ?? source.elements.find((candidate) => candidate.name === "body");
|
|
36073
|
-
const subtree = root ? source.elements.filter((candidate) => within$1(candidate, root)) : source.elements;
|
|
36074
36098
|
const colors = /* @__PURE__ */ new Map();
|
|
36075
|
-
|
|
36076
|
-
|
|
36077
|
-
|
|
36078
|
-
|
|
36079
|
-
|
|
36080
|
-
|
|
36099
|
+
source.elements.forEach((candidate, at) => {
|
|
36100
|
+
if (root && !within$1(candidate, root)) return;
|
|
36101
|
+
for (const property of COLOR_PROPERTIES$1) {
|
|
36102
|
+
const value = read(candidate, property);
|
|
36103
|
+
if (!value || NO_COLOR.has(value.value.trim().toLowerCase())) continue;
|
|
36104
|
+
const key = colorKey(value);
|
|
36105
|
+
const color = colors.get(key) ?? {
|
|
36106
|
+
...value,
|
|
36107
|
+
uses: []
|
|
36108
|
+
};
|
|
36109
|
+
colors.set(key, color);
|
|
36110
|
+
if (!NEVER_USES.has(candidate.name) && color.uses.at(-1) !== at) color.uses.push(at);
|
|
36111
|
+
}
|
|
36112
|
+
});
|
|
36081
36113
|
return {
|
|
36082
36114
|
element,
|
|
36083
36115
|
colors: [...colors.values()]
|
|
@@ -36375,6 +36407,48 @@ function editFrameFile(path, address, change, sourceAt) {
|
|
|
36375
36407
|
};
|
|
36376
36408
|
}
|
|
36377
36409
|
/**
|
|
36410
|
+
* Edits several elements of a frame file as one write, each found again and
|
|
36411
|
+
* verified as `editFrameFile` does one, in the order sent through the bytes
|
|
36412
|
+
* the one before it left. Any refusal writes nothing, so a batch never lands
|
|
36413
|
+
* in part, and naming one element twice is refused since one undo could not
|
|
36414
|
+
* put both spans back.
|
|
36415
|
+
*/
|
|
36416
|
+
function editFrameFileAll(path, hash, edits, sourceAt) {
|
|
36417
|
+
const read = readSource(path);
|
|
36418
|
+
if (!read.ok) return read;
|
|
36419
|
+
const { source } = read;
|
|
36420
|
+
const indexes = [];
|
|
36421
|
+
for (const { index, change } of edits) {
|
|
36422
|
+
if (hash === read.hash) {
|
|
36423
|
+
indexes.push(index);
|
|
36424
|
+
continue;
|
|
36425
|
+
}
|
|
36426
|
+
const was = sourceAt?.(hash);
|
|
36427
|
+
if (!was) return stale$1(path);
|
|
36428
|
+
const found = relocate(was, index, scopeOf(change), source);
|
|
36429
|
+
if (!found) return collided(path, was, index, source);
|
|
36430
|
+
indexes.push(found.index);
|
|
36431
|
+
}
|
|
36432
|
+
if (new Set(indexes).size !== indexes.length) return refuse$2("invalid-edit", "a batch names one element twice");
|
|
36433
|
+
let html = source;
|
|
36434
|
+
const spans = [];
|
|
36435
|
+
for (const [at, { change }] of edits.entries()) {
|
|
36436
|
+
const applied = applyEdit(html, { index: indexes[at] ?? -1 }, change);
|
|
36437
|
+
if (!applied.ok) return applied;
|
|
36438
|
+
html = applied.html;
|
|
36439
|
+
spans.push(applied.span);
|
|
36440
|
+
}
|
|
36441
|
+
if (!replaceFile(path, read.hash, html)) return stale$1(path);
|
|
36442
|
+
return {
|
|
36443
|
+
ok: true,
|
|
36444
|
+
hash: contentHash(html),
|
|
36445
|
+
from: read.hash,
|
|
36446
|
+
indexes,
|
|
36447
|
+
spans,
|
|
36448
|
+
remap: identity
|
|
36449
|
+
};
|
|
36450
|
+
}
|
|
36451
|
+
/**
|
|
36378
36452
|
* Writes one new element into a frame file the way `editFrameFile` writes an
|
|
36379
36453
|
* edit, through a temporary file and a rename after reading the file again.
|
|
36380
36454
|
* A hash the file no longer has is refused as stale with no search, since the
|
|
@@ -36431,6 +36505,45 @@ function removeFrameFile(path, hash, index) {
|
|
|
36431
36505
|
};
|
|
36432
36506
|
}
|
|
36433
36507
|
/**
|
|
36508
|
+
* Takes several elements out of a frame file as one write, refused as
|
|
36509
|
+
* `removeFrameFile` refuses one. Each goes last in the file first, so the
|
|
36510
|
+
* indices ahead of it hold, and one inside another named element goes with
|
|
36511
|
+
* that one rather than on its own.
|
|
36512
|
+
*/
|
|
36513
|
+
function removeFrameFileAll(path, hash, indexes) {
|
|
36514
|
+
const read = readSource(path);
|
|
36515
|
+
if (!read.ok) return read;
|
|
36516
|
+
if (read.hash !== hash) return stale$1(path);
|
|
36517
|
+
const { elements } = parseFrame(read.source);
|
|
36518
|
+
const named = new Set(indexes.map((index) => elements[index]));
|
|
36519
|
+
const outermost = [...new Set(indexes)].filter((index) => {
|
|
36520
|
+
let node = elements[index]?.parentNode;
|
|
36521
|
+
while (node && typeof node === "object") {
|
|
36522
|
+
if (named.has(node)) return false;
|
|
36523
|
+
node = "parentNode" in node ? node.parentNode : null;
|
|
36524
|
+
}
|
|
36525
|
+
return true;
|
|
36526
|
+
});
|
|
36527
|
+
let html = read.source;
|
|
36528
|
+
const spans = [];
|
|
36529
|
+
const remaps = [];
|
|
36530
|
+
for (const index of outermost.toSorted((a, b) => b - a)) {
|
|
36531
|
+
const size = subtreeSize(html, index);
|
|
36532
|
+
const removed = removeElement(html, index);
|
|
36533
|
+
if (!removed.ok) return removed;
|
|
36534
|
+
html = removed.html;
|
|
36535
|
+
spans.push(removed.span);
|
|
36536
|
+
remaps.push(takenOut(index, size));
|
|
36537
|
+
}
|
|
36538
|
+
if (!replaceFile(path, hash, html)) return stale$1(path);
|
|
36539
|
+
return {
|
|
36540
|
+
ok: true,
|
|
36541
|
+
hash: contentHash(html),
|
|
36542
|
+
spans,
|
|
36543
|
+
remap: (index) => remaps.reduce((at, remap) => at === null ? null : remap(at), index)
|
|
36544
|
+
};
|
|
36545
|
+
}
|
|
36546
|
+
/**
|
|
36434
36547
|
* Moves one element of a frame file into another gap, written as
|
|
36435
36548
|
* `insertFrameFile` writes, and refused as stale on a hash the file no longer
|
|
36436
36549
|
* has, since both indices name nothing once the file moved.
|
|
@@ -36473,6 +36586,38 @@ function placeFrameFile(path, hash, index, spot, facts, drop = []) {
|
|
|
36473
36586
|
};
|
|
36474
36587
|
}
|
|
36475
36588
|
/**
|
|
36589
|
+
* Places several elements of a frame file as one write, refused whole as
|
|
36590
|
+
* `placeFrameFile` refuses one. They go in file order, so a parent placed too
|
|
36591
|
+
* is positioned ahead of its child, which then writes no second span on its
|
|
36592
|
+
* tag that would strand the undo. `factsOf` reads the static cascade of the
|
|
36593
|
+
* bytes the one before left, so siblings share the parent the first one made
|
|
36594
|
+
* relative rather than writing it twice.
|
|
36595
|
+
*/
|
|
36596
|
+
function placeFrameFileAll(path, hash, places, factsOf) {
|
|
36597
|
+
const read = readSource(path);
|
|
36598
|
+
if (!read.ok) return read;
|
|
36599
|
+
if (read.hash !== hash) return stale$1(path);
|
|
36600
|
+
let html = read.source;
|
|
36601
|
+
const spans = [];
|
|
36602
|
+
const sized = /* @__PURE__ */ new Map();
|
|
36603
|
+
for (const place of places.toSorted((a, b) => a.index - b.index)) {
|
|
36604
|
+
const { index, spot, drop } = place;
|
|
36605
|
+
const placed = placeElement(html, index, spot, factsOf(html), drop ?? []);
|
|
36606
|
+
if (!placed.ok) return placed;
|
|
36607
|
+
html = placed.html;
|
|
36608
|
+
spans.push(...placed.spans);
|
|
36609
|
+
sized.set(place, placed.sized);
|
|
36610
|
+
}
|
|
36611
|
+
if (!replaceFile(path, hash, html)) return stale$1(path);
|
|
36612
|
+
return {
|
|
36613
|
+
ok: true,
|
|
36614
|
+
hash: contentHash(html),
|
|
36615
|
+
spans,
|
|
36616
|
+
sized: places.map((place) => sized.get(place) ?? []),
|
|
36617
|
+
remap: identity
|
|
36618
|
+
};
|
|
36619
|
+
}
|
|
36620
|
+
/**
|
|
36476
36621
|
* Replaces a raw color with a token across the subtree `root` names, or the
|
|
36477
36622
|
* frame's body when undefined, written as `placeFrameFile` writes and refused
|
|
36478
36623
|
* as stale on a hash the file no longer has, so a retried replace lands once.
|
|
@@ -37179,6 +37324,7 @@ async function reads(change, side) {
|
|
|
37179
37324
|
case "path": return change.present === side ? await exists(change.path) && await hashPath(change.path) === change.hash : !await exists(change.path) && await exists(change.slot);
|
|
37180
37325
|
case "element": return await exists(change.path) && holdsSpan(await readFile(change.path, "utf8"), change.span, side);
|
|
37181
37326
|
case "inserted": return await exists(change.path) && holdsInserted(await readFile(change.path, "utf8"), change.span, side === change.present ? "after" : "before");
|
|
37327
|
+
case "deleted": return await exists(change.path) && chainDeleted(await readFile(change.path, "utf8"), change, OTHER[side]) !== void 0;
|
|
37182
37328
|
case "token": return await exists(change.path) && holdsToken(change, side);
|
|
37183
37329
|
case "relocated": return await exists(change.path) && relocateMoved(await readFile(change.path, "utf8"), change.span, OTHER[side]) !== void 0;
|
|
37184
37330
|
}
|
|
@@ -37277,6 +37423,15 @@ async function restore(change, side) {
|
|
|
37277
37423
|
}
|
|
37278
37424
|
};
|
|
37279
37425
|
});
|
|
37426
|
+
case "deleted": return rewriteFrame(change, (source) => {
|
|
37427
|
+
const written = chainDeleted(source, change, side);
|
|
37428
|
+
return written && {
|
|
37429
|
+
html: written.html,
|
|
37430
|
+
keep: () => {
|
|
37431
|
+
change.spans = written.spans;
|
|
37432
|
+
}
|
|
37433
|
+
};
|
|
37434
|
+
});
|
|
37280
37435
|
case "relocated": return rewriteFrame(change, (source) => {
|
|
37281
37436
|
const written = relocateMoved(source, change.span, side);
|
|
37282
37437
|
return written && {
|
|
@@ -37289,6 +37444,28 @@ async function restore(change, side) {
|
|
|
37289
37444
|
case "token": return rewriteToken(change, side);
|
|
37290
37445
|
}
|
|
37291
37446
|
}
|
|
37447
|
+
/**
|
|
37448
|
+
* The frame with a delete's elements back, `before` restoring them in the
|
|
37449
|
+
* reverse of the order taken out, or out again, `after` taking them in that
|
|
37450
|
+
* order, undefined when any one's bytes or gap no longer read. Answers the
|
|
37451
|
+
* spans as the frame then stands, in the order taken out.
|
|
37452
|
+
*/
|
|
37453
|
+
function chainDeleted(source, { spans }, side) {
|
|
37454
|
+
const restoring = side === "before";
|
|
37455
|
+
const write = restoring ? restoreInserted : removeInserted;
|
|
37456
|
+
let html = source;
|
|
37457
|
+
const kept = [];
|
|
37458
|
+
for (const span of restoring ? spans.toReversed() : spans) {
|
|
37459
|
+
const written = write(html, span);
|
|
37460
|
+
if (!written) return void 0;
|
|
37461
|
+
html = written.html;
|
|
37462
|
+
kept.push(written.span);
|
|
37463
|
+
}
|
|
37464
|
+
return {
|
|
37465
|
+
html,
|
|
37466
|
+
spans: restoring ? kept.toReversed() : kept
|
|
37467
|
+
};
|
|
37468
|
+
}
|
|
37292
37469
|
/** Whether the sheet sets the token exactly as `side` holds it, false for a sheet that no longer parses. */
|
|
37293
37470
|
async function holdsToken(change, side) {
|
|
37294
37471
|
try {
|
|
@@ -37424,6 +37601,15 @@ var StepJournal = class {
|
|
|
37424
37601
|
present: "before"
|
|
37425
37602
|
});
|
|
37426
37603
|
}
|
|
37604
|
+
/** The elements one hand delete took out of a frame file, in the order taken out, which this journal does not write. */
|
|
37605
|
+
deletedElements(path, ref, spans) {
|
|
37606
|
+
this.changes.push({
|
|
37607
|
+
kind: "deleted",
|
|
37608
|
+
path,
|
|
37609
|
+
ref,
|
|
37610
|
+
spans
|
|
37611
|
+
});
|
|
37612
|
+
}
|
|
37427
37613
|
/** The element a hand move took to another gap of a frame file, which this journal does not write. */
|
|
37428
37614
|
relocated(path, ref, span) {
|
|
37429
37615
|
this.changes.push({
|
|
@@ -37971,7 +38157,9 @@ const editResultSchema = object$1({
|
|
|
37971
38157
|
index: int$1().min(0),
|
|
37972
38158
|
hash,
|
|
37973
38159
|
/** The hash the edit was written over, which differs from the one sent once the edit was found again. */
|
|
37974
|
-
from: hash.optional()
|
|
38160
|
+
from: hash.optional(),
|
|
38161
|
+
/** Each element's index in the file as written, in the order a batch sent them, with `index` the last. */
|
|
38162
|
+
indexes: array$1(int$1().min(0)).optional()
|
|
37975
38163
|
});
|
|
37976
38164
|
object$1({
|
|
37977
38165
|
ref: string$1(),
|
|
@@ -37993,7 +38181,12 @@ object$1({
|
|
|
37993
38181
|
ref: string$1(),
|
|
37994
38182
|
index: int$1().min(0),
|
|
37995
38183
|
hash,
|
|
37996
|
-
sized: array$1(placedSizeSchema)
|
|
38184
|
+
sized: array$1(placedSizeSchema),
|
|
38185
|
+
/** Each element a batch placed and the sizes written on it, in the order sent, with `index` and `sized` the last's. */
|
|
38186
|
+
placed: array$1(object$1({
|
|
38187
|
+
index: int$1().min(0),
|
|
38188
|
+
sized: array$1(placedSizeSchema)
|
|
38189
|
+
})).optional()
|
|
37997
38190
|
});
|
|
37998
38191
|
object$1({
|
|
37999
38192
|
ref: string$1(),
|
|
@@ -38007,34 +38200,44 @@ const name$1 = string$1().min(1).max(256);
|
|
|
38007
38200
|
const side = int$1().min(1).max(1e4);
|
|
38008
38201
|
/** A spot in CSS pixels, bounded well past any frame. */
|
|
38009
38202
|
const offset = number().min(-1e5).max(1e5);
|
|
38010
|
-
|
|
38203
|
+
/** How many elements one batch names, well past any selection a hand makes. */
|
|
38204
|
+
const BATCH = 1024;
|
|
38205
|
+
const changeSchema = discriminatedUnion("kind", [
|
|
38206
|
+
object$1({
|
|
38207
|
+
kind: literal("style"),
|
|
38208
|
+
property: name$1,
|
|
38209
|
+
value
|
|
38210
|
+
}),
|
|
38211
|
+
object$1({
|
|
38212
|
+
kind: literal("attribute"),
|
|
38213
|
+
name: name$1,
|
|
38214
|
+
value
|
|
38215
|
+
}),
|
|
38216
|
+
object$1({
|
|
38217
|
+
kind: literal("text"),
|
|
38218
|
+
value
|
|
38219
|
+
}),
|
|
38220
|
+
object$1({
|
|
38221
|
+
kind: literal("styles"),
|
|
38222
|
+
declarations: array$1(object$1({
|
|
38223
|
+
property: name$1,
|
|
38224
|
+
value
|
|
38225
|
+
})).max(16)
|
|
38226
|
+
})
|
|
38227
|
+
]);
|
|
38228
|
+
const editSchema$1 = union([object$1({
|
|
38011
38229
|
ref: string$1().min(1).max(1024),
|
|
38012
38230
|
index: int$1().min(0),
|
|
38013
38231
|
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
38014
|
-
change:
|
|
38015
|
-
|
|
38016
|
-
|
|
38017
|
-
|
|
38018
|
-
|
|
38019
|
-
|
|
38020
|
-
|
|
38021
|
-
|
|
38022
|
-
|
|
38023
|
-
value
|
|
38024
|
-
}),
|
|
38025
|
-
object$1({
|
|
38026
|
-
kind: literal("text"),
|
|
38027
|
-
value
|
|
38028
|
-
}),
|
|
38029
|
-
object$1({
|
|
38030
|
-
kind: literal("styles"),
|
|
38031
|
-
declarations: array$1(object$1({
|
|
38032
|
-
property: name$1,
|
|
38033
|
-
value
|
|
38034
|
-
})).max(16)
|
|
38035
|
-
})
|
|
38036
|
-
])
|
|
38037
|
-
});
|
|
38232
|
+
change: changeSchema
|
|
38233
|
+
}), object$1({
|
|
38234
|
+
ref: string$1().min(1).max(1024),
|
|
38235
|
+
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
38236
|
+
edits: array$1(object$1({
|
|
38237
|
+
index: int$1().min(0),
|
|
38238
|
+
change: changeSchema
|
|
38239
|
+
})).min(1).max(BATCH)
|
|
38240
|
+
})]);
|
|
38038
38241
|
const insertSchema = object$1({
|
|
38039
38242
|
ref: string$1().min(1).max(1024),
|
|
38040
38243
|
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
@@ -38071,11 +38274,15 @@ const insertSchema = object$1({
|
|
|
38071
38274
|
orFlow: boolean$1().optional()
|
|
38072
38275
|
}).optional()
|
|
38073
38276
|
});
|
|
38074
|
-
const removeSchema = object$1({
|
|
38277
|
+
const removeSchema = union([object$1({
|
|
38075
38278
|
ref: string$1().min(1).max(1024),
|
|
38076
38279
|
index: int$1().min(0),
|
|
38077
38280
|
hash: string$1().regex(/^[0-9a-f]{64}$/)
|
|
38078
|
-
})
|
|
38281
|
+
}), object$1({
|
|
38282
|
+
ref: string$1().min(1).max(1024),
|
|
38283
|
+
indexes: array$1(int$1().min(0)).min(1).max(BATCH),
|
|
38284
|
+
hash: string$1().regex(/^[0-9a-f]{64}$/)
|
|
38285
|
+
})]);
|
|
38079
38286
|
const moveSchema$1 = object$1({
|
|
38080
38287
|
ref: string$1().min(1).max(1024),
|
|
38081
38288
|
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
@@ -38083,10 +38290,7 @@ const moveSchema$1 = object$1({
|
|
|
38083
38290
|
parent: int$1().min(0),
|
|
38084
38291
|
before: int$1().min(0).nullable()
|
|
38085
38292
|
});
|
|
38086
|
-
const
|
|
38087
|
-
ref: string$1().min(1).max(1024),
|
|
38088
|
-
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
38089
|
-
index: int$1().min(0),
|
|
38293
|
+
const spotFields = {
|
|
38090
38294
|
spot: object$1({
|
|
38091
38295
|
left: offset,
|
|
38092
38296
|
top: offset,
|
|
@@ -38095,7 +38299,20 @@ const placeSchema = object$1({
|
|
|
38095
38299
|
}).nullable(),
|
|
38096
38300
|
/** Back in flow, the sizes to drop, being ones a placement wrote that nothing changed since. */
|
|
38097
38301
|
drop: array$1(placedSizeSchema).max(2).optional()
|
|
38098
|
-
}
|
|
38302
|
+
};
|
|
38303
|
+
const placeSchema = union([object$1({
|
|
38304
|
+
ref: string$1().min(1).max(1024),
|
|
38305
|
+
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
38306
|
+
index: int$1().min(0),
|
|
38307
|
+
...spotFields
|
|
38308
|
+
}), object$1({
|
|
38309
|
+
ref: string$1().min(1).max(1024),
|
|
38310
|
+
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
38311
|
+
places: array$1(object$1({
|
|
38312
|
+
index: int$1().min(0),
|
|
38313
|
+
...spotFields
|
|
38314
|
+
})).min(1).max(BATCH)
|
|
38315
|
+
})]);
|
|
38099
38316
|
const recolorSchema = object$1({
|
|
38100
38317
|
ref: string$1().min(1).max(1024),
|
|
38101
38318
|
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
@@ -38121,6 +38338,9 @@ const recolorSchema = object$1({
|
|
|
38121
38338
|
* records the edited element's span as one step. It answers the `edit`
|
|
38122
38339
|
* record with the index written and the hash written over. Each refusal the
|
|
38123
38340
|
* writer returns answers 409 with its code, `stale-address` among them.
|
|
38341
|
+
* Given `edits` in place of `index` and `change`, it writes each as one
|
|
38342
|
+
* write and one step, refused whole on any refusal, and answers `indexes` in
|
|
38343
|
+
* the order sent, `index` being the last.
|
|
38124
38344
|
*
|
|
38125
38345
|
* The insert takes an element kind, never markup, and writes that kind's one
|
|
38126
38346
|
* tag into the gap `parent` and `before` name, painted from the project's
|
|
@@ -38141,7 +38361,9 @@ const recolorSchema = object$1({
|
|
|
38141
38361
|
* The remove takes out the element at `index`, with what it holds, from the
|
|
38142
38362
|
* bytes `hash` names, and records it as one step whose undo puts it back
|
|
38143
38363
|
* under its parent. It answers the frame and the hash written, and refuses a
|
|
38144
|
-
* moved file as `stale-address` the way the insert does.
|
|
38364
|
+
* moved file as `stale-address` the way the insert does. Given `indexes` in
|
|
38365
|
+
* place of `index`, it takes out each as one write and one step, one held
|
|
38366
|
+
* inside another named going with that one, refused whole on any refusal.
|
|
38145
38367
|
*
|
|
38146
38368
|
* The move takes one element by index and the gap it goes into, both read
|
|
38147
38369
|
* in the frame as the hash names it, and records it as one step an undo
|
|
@@ -38156,7 +38378,9 @@ const recolorSchema = object$1({
|
|
|
38156
38378
|
* both as one step, so one undo restores both. It answers the element's
|
|
38157
38379
|
* index, the hash written, and the sizes a placement wrote, refuses as the move
|
|
38158
38380
|
* does, and refuses `reanchors-descendant` where a positioned parent would
|
|
38159
|
-
* move another element anchored above it.
|
|
38381
|
+
* move another element anchored above it. Given `places` in place of
|
|
38382
|
+
* `index`, `spot`, and `drop`, it places each as one write and one step,
|
|
38383
|
+
* refused whole on any refusal, and answers `placed` in the order sent.
|
|
38160
38384
|
*
|
|
38161
38385
|
* The recolor writes the color token `to` in place of the raw color `from`
|
|
38162
38386
|
* on every element under `index`, or under the frame's body without one,
|
|
@@ -38179,6 +38403,43 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
38179
38403
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
38180
38404
|
await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
|
|
38181
38405
|
const was = contentHash(await readFile(frame.path)) !== body.hash ? await version?.(ref, body.hash) ?? null : null;
|
|
38406
|
+
if ("edits" in body) {
|
|
38407
|
+
const result = editFrameFileAll(frame.path, body.hash, body.edits, (hash) => hash === body.hash ? was : null);
|
|
38408
|
+
if (!result.ok) return c.json({
|
|
38409
|
+
ok: false,
|
|
38410
|
+
error: {
|
|
38411
|
+
code: result.reason,
|
|
38412
|
+
message: result.detail,
|
|
38413
|
+
details: {
|
|
38414
|
+
ref,
|
|
38415
|
+
..."moved" in result ? { moved: result.moved } : {}
|
|
38416
|
+
}
|
|
38417
|
+
}
|
|
38418
|
+
}, 409);
|
|
38419
|
+
const written = result.spans.filter((span) => span.before !== span.after);
|
|
38420
|
+
if (written.length > 0) {
|
|
38421
|
+
const journal = history.journal();
|
|
38422
|
+
for (const span of written) journal.element(frame.path, ref, span);
|
|
38423
|
+
history.record({
|
|
38424
|
+
id: journal.id,
|
|
38425
|
+
changes: journal.changes,
|
|
38426
|
+
page: null,
|
|
38427
|
+
frames: [ref]
|
|
38428
|
+
});
|
|
38429
|
+
}
|
|
38430
|
+
await follow(frame, result.from, result.hash, result.remap);
|
|
38431
|
+
const data = {
|
|
38432
|
+
ref,
|
|
38433
|
+
index: result.indexes.at(-1) ?? 0,
|
|
38434
|
+
indexes: [...result.indexes],
|
|
38435
|
+
hash: result.hash,
|
|
38436
|
+
from: result.from
|
|
38437
|
+
};
|
|
38438
|
+
return c.json({
|
|
38439
|
+
ok: true,
|
|
38440
|
+
data
|
|
38441
|
+
});
|
|
38442
|
+
}
|
|
38182
38443
|
const result = editFrameFile(frame.path, {
|
|
38183
38444
|
index: body.index,
|
|
38184
38445
|
hash: body.hash
|
|
@@ -38301,6 +38562,34 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
38301
38562
|
const frame = await resolveFrameRef(root, body.ref, { cwd: root });
|
|
38302
38563
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
38303
38564
|
await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
|
|
38565
|
+
if ("indexes" in body) {
|
|
38566
|
+
const result = removeFrameFileAll(frame.path, body.hash, body.indexes);
|
|
38567
|
+
if (!result.ok) return c.json({
|
|
38568
|
+
ok: false,
|
|
38569
|
+
error: {
|
|
38570
|
+
code: result.reason,
|
|
38571
|
+
message: result.detail,
|
|
38572
|
+
details: { ref }
|
|
38573
|
+
}
|
|
38574
|
+
}, 409);
|
|
38575
|
+
const journal = history.journal();
|
|
38576
|
+
journal.deletedElements(frame.path, ref, result.spans);
|
|
38577
|
+
history.record({
|
|
38578
|
+
id: journal.id,
|
|
38579
|
+
changes: journal.changes,
|
|
38580
|
+
page: null,
|
|
38581
|
+
frames: [ref]
|
|
38582
|
+
});
|
|
38583
|
+
await follow(frame, body.hash, result.hash, result.remap);
|
|
38584
|
+
const data = {
|
|
38585
|
+
ref,
|
|
38586
|
+
hash: result.hash
|
|
38587
|
+
};
|
|
38588
|
+
return c.json({
|
|
38589
|
+
ok: true,
|
|
38590
|
+
data
|
|
38591
|
+
});
|
|
38592
|
+
}
|
|
38304
38593
|
const result = removeFrameFile(frame.path, body.hash, body.index);
|
|
38305
38594
|
if (!result.ok) return c.json({
|
|
38306
38595
|
ok: false,
|
|
@@ -38376,6 +38665,48 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
38376
38665
|
const frame = await resolveFrameRef(root, body.ref, { cwd: root });
|
|
38377
38666
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
38378
38667
|
await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
|
|
38668
|
+
if ("places" in body) {
|
|
38669
|
+
const result = placeFrameFileAll(frame.path, body.hash, body.places.map(({ index, spot, drop }) => ({
|
|
38670
|
+
index,
|
|
38671
|
+
spot,
|
|
38672
|
+
drop: spot ? [] : drop ?? []
|
|
38673
|
+
})), (html) => elementPlaceFacts(frameFrom(frame, html), tokenSheets(frame.project)));
|
|
38674
|
+
if (!result.ok) return c.json({
|
|
38675
|
+
ok: false,
|
|
38676
|
+
error: {
|
|
38677
|
+
code: result.reason,
|
|
38678
|
+
message: result.detail,
|
|
38679
|
+
details: { ref }
|
|
38680
|
+
}
|
|
38681
|
+
}, 409);
|
|
38682
|
+
const written = result.spans.filter((span) => span.before !== span.after);
|
|
38683
|
+
if (written.length > 0) {
|
|
38684
|
+
const journal = history.journal();
|
|
38685
|
+
for (const span of written) journal.element(frame.path, ref, span);
|
|
38686
|
+
history.record({
|
|
38687
|
+
id: journal.id,
|
|
38688
|
+
changes: journal.changes,
|
|
38689
|
+
page: null,
|
|
38690
|
+
frames: [ref]
|
|
38691
|
+
});
|
|
38692
|
+
}
|
|
38693
|
+
await follow(frame, body.hash, result.hash, result.remap);
|
|
38694
|
+
const placed = body.places.map(({ index }, at) => ({
|
|
38695
|
+
index,
|
|
38696
|
+
sized: [...result.sized[at] ?? []]
|
|
38697
|
+
}));
|
|
38698
|
+
const data = {
|
|
38699
|
+
ref,
|
|
38700
|
+
index: placed.at(-1)?.index ?? 0,
|
|
38701
|
+
hash: result.hash,
|
|
38702
|
+
sized: placed.at(-1)?.sized ?? [],
|
|
38703
|
+
placed
|
|
38704
|
+
};
|
|
38705
|
+
return c.json({
|
|
38706
|
+
ok: true,
|
|
38707
|
+
data
|
|
38708
|
+
});
|
|
38709
|
+
}
|
|
38379
38710
|
const source = readFrame(frame);
|
|
38380
38711
|
const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame.project)) : [];
|
|
38381
38712
|
const result = placeFrameFile(frame.path, body.hash, body.index, body.spot, facts, body.spot ? [] : body.drop ?? []);
|
|
@@ -43073,11 +43404,18 @@ const elementStylesSchema = object$1({
|
|
|
43073
43404
|
/** Absent from a server older than the Layout section, which a reader treats as no rule and no size modes. */
|
|
43074
43405
|
flow: elementFlowSchema.optional()
|
|
43075
43406
|
});
|
|
43407
|
+
/**
|
|
43408
|
+
* One color a frame or a subtree uses. `uses` holds the edit-address index of
|
|
43409
|
+
* each element whose color, background, or border is this one, inherited or
|
|
43410
|
+
* not, ascending and valid for the read's `hash`. It never names `body`, which
|
|
43411
|
+
* the board selects as the frame, or an element that draws no box, such as `br`.
|
|
43412
|
+
*/
|
|
43413
|
+
const usedColorSchema = styleValueSchema.extend({ uses: array$1(int$1().min(0)).optional() });
|
|
43076
43414
|
object$1({
|
|
43077
43415
|
ref: string$1(),
|
|
43078
43416
|
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
43079
43417
|
element: elementStylesSchema.nullable(),
|
|
43080
|
-
colors: array$1(
|
|
43418
|
+
colors: array$1(usedColorSchema)
|
|
43081
43419
|
});
|
|
43082
43420
|
// src/shared/records/find.ts
|
|
43083
43421
|
/** One match: a frame by its name, an element by its name, or an element's own text. */
|