frameboard 0.26.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 +339 -40
- 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 +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.27.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
|
});
|
|
@@ -36375,6 +36375,48 @@ function editFrameFile(path, address, change, sourceAt) {
|
|
|
36375
36375
|
};
|
|
36376
36376
|
}
|
|
36377
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
|
+
/**
|
|
36378
36420
|
* Writes one new element into a frame file the way `editFrameFile` writes an
|
|
36379
36421
|
* edit, through a temporary file and a rename after reading the file again.
|
|
36380
36422
|
* A hash the file no longer has is refused as stale with no search, since the
|
|
@@ -36431,6 +36473,45 @@ function removeFrameFile(path, hash, index) {
|
|
|
36431
36473
|
};
|
|
36432
36474
|
}
|
|
36433
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
|
+
/**
|
|
36434
36515
|
* Moves one element of a frame file into another gap, written as
|
|
36435
36516
|
* `insertFrameFile` writes, and refused as stale on a hash the file no longer
|
|
36436
36517
|
* has, since both indices name nothing once the file moved.
|
|
@@ -36473,6 +36554,38 @@ function placeFrameFile(path, hash, index, spot, facts, drop = []) {
|
|
|
36473
36554
|
};
|
|
36474
36555
|
}
|
|
36475
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
|
+
/**
|
|
36476
36589
|
* Replaces a raw color with a token across the subtree `root` names, or the
|
|
36477
36590
|
* frame's body when undefined, written as `placeFrameFile` writes and refused
|
|
36478
36591
|
* as stale on a hash the file no longer has, so a retried replace lands once.
|
|
@@ -37179,6 +37292,7 @@ async function reads(change, side) {
|
|
|
37179
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);
|
|
37180
37293
|
case "element": return await exists(change.path) && holdsSpan(await readFile(change.path, "utf8"), change.span, side);
|
|
37181
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;
|
|
37182
37296
|
case "token": return await exists(change.path) && holdsToken(change, side);
|
|
37183
37297
|
case "relocated": return await exists(change.path) && relocateMoved(await readFile(change.path, "utf8"), change.span, OTHER[side]) !== void 0;
|
|
37184
37298
|
}
|
|
@@ -37277,6 +37391,15 @@ async function restore(change, side) {
|
|
|
37277
37391
|
}
|
|
37278
37392
|
};
|
|
37279
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
|
+
});
|
|
37280
37403
|
case "relocated": return rewriteFrame(change, (source) => {
|
|
37281
37404
|
const written = relocateMoved(source, change.span, side);
|
|
37282
37405
|
return written && {
|
|
@@ -37289,6 +37412,28 @@ async function restore(change, side) {
|
|
|
37289
37412
|
case "token": return rewriteToken(change, side);
|
|
37290
37413
|
}
|
|
37291
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
|
+
}
|
|
37292
37437
|
/** Whether the sheet sets the token exactly as `side` holds it, false for a sheet that no longer parses. */
|
|
37293
37438
|
async function holdsToken(change, side) {
|
|
37294
37439
|
try {
|
|
@@ -37424,6 +37569,15 @@ var StepJournal = class {
|
|
|
37424
37569
|
present: "before"
|
|
37425
37570
|
});
|
|
37426
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
|
+
}
|
|
37427
37581
|
/** The element a hand move took to another gap of a frame file, which this journal does not write. */
|
|
37428
37582
|
relocated(path, ref, span) {
|
|
37429
37583
|
this.changes.push({
|
|
@@ -37971,7 +38125,9 @@ const editResultSchema = object$1({
|
|
|
37971
38125
|
index: int$1().min(0),
|
|
37972
38126
|
hash,
|
|
37973
38127
|
/** The hash the edit was written over, which differs from the one sent once the edit was found again. */
|
|
37974
|
-
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()
|
|
37975
38131
|
});
|
|
37976
38132
|
object$1({
|
|
37977
38133
|
ref: string$1(),
|
|
@@ -37993,7 +38149,12 @@ object$1({
|
|
|
37993
38149
|
ref: string$1(),
|
|
37994
38150
|
index: int$1().min(0),
|
|
37995
38151
|
hash,
|
|
37996
|
-
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()
|
|
37997
38158
|
});
|
|
37998
38159
|
object$1({
|
|
37999
38160
|
ref: string$1(),
|
|
@@ -38007,34 +38168,44 @@ const name$1 = string$1().min(1).max(256);
|
|
|
38007
38168
|
const side = int$1().min(1).max(1e4);
|
|
38008
38169
|
/** A spot in CSS pixels, bounded well past any frame. */
|
|
38009
38170
|
const offset = number().min(-1e5).max(1e5);
|
|
38010
|
-
|
|
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({
|
|
38011
38197
|
ref: string$1().min(1).max(1024),
|
|
38012
38198
|
index: int$1().min(0),
|
|
38013
38199
|
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
|
-
});
|
|
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
|
+
})]);
|
|
38038
38209
|
const insertSchema = object$1({
|
|
38039
38210
|
ref: string$1().min(1).max(1024),
|
|
38040
38211
|
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
@@ -38071,11 +38242,15 @@ const insertSchema = object$1({
|
|
|
38071
38242
|
orFlow: boolean$1().optional()
|
|
38072
38243
|
}).optional()
|
|
38073
38244
|
});
|
|
38074
|
-
const removeSchema = object$1({
|
|
38245
|
+
const removeSchema = union([object$1({
|
|
38075
38246
|
ref: string$1().min(1).max(1024),
|
|
38076
38247
|
index: int$1().min(0),
|
|
38077
38248
|
hash: string$1().regex(/^[0-9a-f]{64}$/)
|
|
38078
|
-
})
|
|
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
|
+
})]);
|
|
38079
38254
|
const moveSchema$1 = object$1({
|
|
38080
38255
|
ref: string$1().min(1).max(1024),
|
|
38081
38256
|
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
@@ -38083,10 +38258,7 @@ const moveSchema$1 = object$1({
|
|
|
38083
38258
|
parent: int$1().min(0),
|
|
38084
38259
|
before: int$1().min(0).nullable()
|
|
38085
38260
|
});
|
|
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),
|
|
38261
|
+
const spotFields = {
|
|
38090
38262
|
spot: object$1({
|
|
38091
38263
|
left: offset,
|
|
38092
38264
|
top: offset,
|
|
@@ -38095,7 +38267,20 @@ const placeSchema = object$1({
|
|
|
38095
38267
|
}).nullable(),
|
|
38096
38268
|
/** Back in flow, the sizes to drop, being ones a placement wrote that nothing changed since. */
|
|
38097
38269
|
drop: array$1(placedSizeSchema).max(2).optional()
|
|
38098
|
-
}
|
|
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
|
+
})]);
|
|
38099
38284
|
const recolorSchema = object$1({
|
|
38100
38285
|
ref: string$1().min(1).max(1024),
|
|
38101
38286
|
hash: string$1().regex(/^[0-9a-f]{64}$/),
|
|
@@ -38121,6 +38306,9 @@ const recolorSchema = object$1({
|
|
|
38121
38306
|
* records the edited element's span as one step. It answers the `edit`
|
|
38122
38307
|
* record with the index written and the hash written over. Each refusal the
|
|
38123
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.
|
|
38124
38312
|
*
|
|
38125
38313
|
* The insert takes an element kind, never markup, and writes that kind's one
|
|
38126
38314
|
* tag into the gap `parent` and `before` name, painted from the project's
|
|
@@ -38141,7 +38329,9 @@ const recolorSchema = object$1({
|
|
|
38141
38329
|
* The remove takes out the element at `index`, with what it holds, from the
|
|
38142
38330
|
* bytes `hash` names, and records it as one step whose undo puts it back
|
|
38143
38331
|
* 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.
|
|
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.
|
|
38145
38335
|
*
|
|
38146
38336
|
* The move takes one element by index and the gap it goes into, both read
|
|
38147
38337
|
* in the frame as the hash names it, and records it as one step an undo
|
|
@@ -38156,7 +38346,9 @@ const recolorSchema = object$1({
|
|
|
38156
38346
|
* both as one step, so one undo restores both. It answers the element's
|
|
38157
38347
|
* index, the hash written, and the sizes a placement wrote, refuses as the move
|
|
38158
38348
|
* does, and refuses `reanchors-descendant` where a positioned parent would
|
|
38159
|
-
* 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.
|
|
38160
38352
|
*
|
|
38161
38353
|
* The recolor writes the color token `to` in place of the raw color `from`
|
|
38162
38354
|
* on every element under `index`, or under the frame's body without one,
|
|
@@ -38179,6 +38371,43 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
38179
38371
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
38180
38372
|
await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
|
|
38181
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
|
+
}
|
|
38182
38411
|
const result = editFrameFile(frame.path, {
|
|
38183
38412
|
index: body.index,
|
|
38184
38413
|
hash: body.hash
|
|
@@ -38301,6 +38530,34 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
38301
38530
|
const frame = await resolveFrameRef(root, body.ref, { cwd: root });
|
|
38302
38531
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
38303
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
|
+
}
|
|
38304
38561
|
const result = removeFrameFile(frame.path, body.hash, body.index);
|
|
38305
38562
|
if (!result.ok) return c.json({
|
|
38306
38563
|
ok: false,
|
|
@@ -38376,6 +38633,48 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
38376
38633
|
const frame = await resolveFrameRef(root, body.ref, { cwd: root });
|
|
38377
38634
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
38378
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
|
+
}
|
|
38379
38678
|
const source = readFrame(frame);
|
|
38380
38679
|
const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame.project)) : [];
|
|
38381
38680
|
const result = placeFrameFile(frame.path, body.hash, body.index, body.spot, facts, body.spot ? [] : body.drop ?? []);
|