frameboard 0.52.0 → 0.53.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 +409 -108
- package/dist/client/assets/index-D2X9oOwk.js +163 -0
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
- package/dist/client/assets/index-BWloGxEw.js +0 -163
package/dist/cli.js
CHANGED
|
@@ -3423,7 +3423,7 @@ function slugify(input) {
|
|
|
3423
3423
|
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3424
3424
|
}
|
|
3425
3425
|
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
3426
|
-
function isObject(data) {
|
|
3426
|
+
function isObject$1(data) {
|
|
3427
3427
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
3428
3428
|
}
|
|
3429
3429
|
const allowsEval = /* @__PURE__*/ cached(() => {
|
|
@@ -3437,12 +3437,12 @@ const allowsEval = /* @__PURE__*/ cached(() => {
|
|
|
3437
3437
|
}
|
|
3438
3438
|
});
|
|
3439
3439
|
function isPlainObject(o) {
|
|
3440
|
-
if (isObject(o) === false) return false;
|
|
3440
|
+
if (isObject$1(o) === false) return false;
|
|
3441
3441
|
const ctor = o.constructor;
|
|
3442
3442
|
if (ctor === void 0) return true;
|
|
3443
3443
|
if (typeof ctor !== "function") return true;
|
|
3444
3444
|
const prot = ctor.prototype;
|
|
3445
|
-
if (isObject(prot) === false) return false;
|
|
3445
|
+
if (isObject$1(prot) === false) return false;
|
|
3446
3446
|
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
3447
3447
|
return true;
|
|
3448
3448
|
}
|
|
@@ -5333,7 +5333,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
5333
5333
|
}
|
|
5334
5334
|
return propValues;
|
|
5335
5335
|
});
|
|
5336
|
-
const isObject
|
|
5336
|
+
const isObject = isObject$1;
|
|
5337
5337
|
const catchall = def.catchall;
|
|
5338
5338
|
let value;
|
|
5339
5339
|
const memo = globalConfig.memoizer;
|
|
@@ -5341,7 +5341,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
5341
5341
|
inst._zod.parse = (payload, ctx) => {
|
|
5342
5342
|
value ?? (value = _normalized.value);
|
|
5343
5343
|
const input = payload.value;
|
|
5344
|
-
if (!isObject
|
|
5344
|
+
if (!isObject(input)) {
|
|
5345
5345
|
payload.issues.push({
|
|
5346
5346
|
expected: "object",
|
|
5347
5347
|
code: "invalid_type",
|
|
@@ -5471,7 +5471,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
5471
5471
|
return doc.compile();
|
|
5472
5472
|
};
|
|
5473
5473
|
let fastpass;
|
|
5474
|
-
const isObject
|
|
5474
|
+
const isObject = isObject$1;
|
|
5475
5475
|
const jit = !globalConfig.jitless;
|
|
5476
5476
|
const fastEnabled = jit && allowsEval.value;
|
|
5477
5477
|
const catchall = def.catchall;
|
|
@@ -5479,7 +5479,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
5479
5479
|
inst._zod.parse = (payload, ctx) => {
|
|
5480
5480
|
value ?? (value = _normalized.value);
|
|
5481
5481
|
const input = payload.value;
|
|
5482
|
-
if (!isObject
|
|
5482
|
+
if (!isObject(input)) {
|
|
5483
5483
|
payload.issues.push({
|
|
5484
5484
|
expected: "object",
|
|
5485
5485
|
code: "invalid_type",
|
|
@@ -5590,7 +5590,7 @@ const $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnio
|
|
|
5590
5590
|
const disc = cached(() => discriminatorMap(def));
|
|
5591
5591
|
inst._zod.parse = (payload, ctx) => {
|
|
5592
5592
|
const input = payload.value;
|
|
5593
|
-
if (!isObject(input)) {
|
|
5593
|
+
if (!isObject$1(input)) {
|
|
5594
5594
|
payload.issues.push({
|
|
5595
5595
|
code: "invalid_type",
|
|
5596
5596
|
expected: "object",
|
|
@@ -25575,7 +25575,7 @@ async function isDirectory(path) {
|
|
|
25575
25575
|
}
|
|
25576
25576
|
}
|
|
25577
25577
|
// package.json
|
|
25578
|
-
var version$1 = "0.
|
|
25578
|
+
var version$1 = "0.53.0";
|
|
25579
25579
|
var dependencies = { "playwright-core": "1.65.1" };
|
|
25580
25580
|
var peerDependencies = { "oxfmt": "0.79.0" };
|
|
25581
25581
|
// src/shared/version.ts
|
|
@@ -25687,7 +25687,9 @@ const claimBoxSchema = object$1({
|
|
|
25687
25687
|
width: number(),
|
|
25688
25688
|
height: number(),
|
|
25689
25689
|
hugWidth: boolean$1().optional(),
|
|
25690
|
-
hugHeight: boolean$1().optional()
|
|
25690
|
+
hugHeight: boolean$1().optional(),
|
|
25691
|
+
/** Set on a box its frame's name sized, which lands inside the device its width names. */
|
|
25692
|
+
showDevice: boolean$1().optional()
|
|
25691
25693
|
});
|
|
25692
25694
|
/** One session's hold on a frame while its agent rewrites it. */
|
|
25693
25695
|
const claimSchema = looseObject({
|
|
@@ -25854,17 +25856,17 @@ async function releaseReservation(root, frame, now) {
|
|
|
25854
25856
|
return dropped;
|
|
25855
25857
|
}
|
|
25856
25858
|
/**
|
|
25857
|
-
* Drops a session's
|
|
25858
|
-
*
|
|
25859
|
+
* Drops a session's claims on the frames named in one write, or every claim
|
|
25860
|
+
* it holds when `frames` is undefined, returning what it dropped.
|
|
25859
25861
|
*/
|
|
25860
|
-
async function release(root, session,
|
|
25862
|
+
async function release(root, session, frames, now) {
|
|
25861
25863
|
const dropped = [];
|
|
25862
25864
|
await ensureRunFolder(root);
|
|
25863
25865
|
await updateRecord(claimsPath(root), claimsSpec, (file) => {
|
|
25864
25866
|
const kept = [];
|
|
25865
25867
|
for (const each of file.claims) {
|
|
25866
25868
|
if (!isLive(each, now)) continue;
|
|
25867
|
-
(each.session === session && (
|
|
25869
|
+
(each.session === session && (frames === void 0 || frames.includes(each.frame)) ? dropped : kept).push(each);
|
|
25868
25870
|
}
|
|
25869
25871
|
return {
|
|
25870
25872
|
...file,
|
|
@@ -25888,11 +25890,12 @@ async function addFrame(root, ref, options) {
|
|
|
25888
25890
|
const page = pageDir(frame);
|
|
25889
25891
|
const reserved = options.x === void 0 && options.y === void 0 ? await reservedBox(root, refOf$1(frame)) : void 0;
|
|
25890
25892
|
const sized = options.size !== void 0 || options.width !== void 0 || options.height !== void 0;
|
|
25893
|
+
const scroll = options.scroll ?? false;
|
|
25894
|
+
const reservedDevice = !sized && reserved?.showDevice === true;
|
|
25891
25895
|
const statedSize = reserved && !sized ? {
|
|
25892
25896
|
width: reserved.width,
|
|
25893
|
-
height: reserved.height
|
|
25897
|
+
...reservedDevice && scroll ? {} : { height: reserved.height }
|
|
25894
25898
|
} : sizeOf(options);
|
|
25895
|
-
const scroll = options.scroll ?? false;
|
|
25896
25899
|
const statedHugs = scroll ? {
|
|
25897
25900
|
hugWidth: false,
|
|
25898
25901
|
hugHeight: false
|
|
@@ -25912,7 +25915,7 @@ async function addFrame(root, ref, options) {
|
|
|
25912
25915
|
...statedHugs,
|
|
25913
25916
|
hugWidth: false
|
|
25914
25917
|
};
|
|
25915
|
-
const showDevice = options.showDevice || named !== void 0;
|
|
25918
|
+
const showDevice = options.showDevice || reservedDevice || named !== void 0;
|
|
25916
25919
|
const names = exists ? layout.names : [...layout.names, frame.name].sort();
|
|
25917
25920
|
const placed = placeFrames(layout.file.frames, names.filter((name) => layout.hasEntry(name)));
|
|
25918
25921
|
const stale = placed.get(frame.name);
|
|
@@ -45361,20 +45364,34 @@ async function boardKitNames(root) {
|
|
|
45361
45364
|
}
|
|
45362
45365
|
// src/server/kits/install.ts
|
|
45363
45366
|
/**
|
|
45364
|
-
*
|
|
45365
|
-
*
|
|
45366
|
-
* `
|
|
45367
|
+
* Copies a kit's folder into a project's `assets/kits/`, touching no token
|
|
45368
|
+
* sheet and no page. Over a kit the project holds, refuses `name-taken` or,
|
|
45369
|
+
* under `replace`, swaps in the copy under the name it is held by.
|
|
45367
45370
|
*/
|
|
45368
|
-
async function installKit(root, ref, kit, { journal } = {}) {
|
|
45371
|
+
async function installKit(root, ref, kit, { journal, replace = false } = {}) {
|
|
45369
45372
|
const project = await resolveProject(root, ref);
|
|
45370
45373
|
assertValidName("kit", kit.name);
|
|
45371
45374
|
const held = matchName(await projectKitNames(project.path), kit.name);
|
|
45372
|
-
const
|
|
45373
|
-
|
|
45375
|
+
const name = held ?? kit.name;
|
|
45376
|
+
const target = projectKitDir(project.path, name);
|
|
45377
|
+
const swaps = replace && held !== void 0;
|
|
45378
|
+
if (!swaps && (held !== void 0 || existsSync(target))) throw new FrameboardError("name-taken", held === void 0 ? `${target} exists and is not a kit folder, so no kit was added. Move it away first.` : `${project.name} already holds a kit named ${name}, so none was added. Run \`frameboard kit add\` with --replace to put this copy in its place, which keeps the kit on every frame naming it.`, {
|
|
45374
45379
|
project: project.name,
|
|
45375
|
-
kit:
|
|
45380
|
+
kit: name
|
|
45376
45381
|
});
|
|
45377
45382
|
await readKitFile(kit);
|
|
45383
|
+
const record = {
|
|
45384
|
+
project: project.name,
|
|
45385
|
+
kit: name,
|
|
45386
|
+
written: [target]
|
|
45387
|
+
};
|
|
45388
|
+
if (swaps) {
|
|
45389
|
+
await swapIn(kit.path, target);
|
|
45390
|
+
return {
|
|
45391
|
+
...record,
|
|
45392
|
+
replaced: true
|
|
45393
|
+
};
|
|
45394
|
+
}
|
|
45378
45395
|
const made = topmostMissing(target);
|
|
45379
45396
|
await mkdir(dirname(target), { recursive: true });
|
|
45380
45397
|
await cp(kit.path, target, {
|
|
@@ -45384,11 +45401,33 @@ async function installKit(root, ref, kit, { journal } = {}) {
|
|
|
45384
45401
|
filter: (path) => isKitFile(kit.path, path)
|
|
45385
45402
|
});
|
|
45386
45403
|
await journal?.created(made);
|
|
45387
|
-
return
|
|
45388
|
-
|
|
45389
|
-
|
|
45390
|
-
|
|
45391
|
-
|
|
45404
|
+
return record;
|
|
45405
|
+
}
|
|
45406
|
+
/**
|
|
45407
|
+
* Puts a copy of the kit folder in place of the one at `target`, staged whole
|
|
45408
|
+
* in a dot folder beside it, so a failed copy leaves the held kit as it was.
|
|
45409
|
+
*/
|
|
45410
|
+
async function swapIn(kitPath, target) {
|
|
45411
|
+
const stage = await mkdtemp(join(dirname(target), `.${basename(target)}.`));
|
|
45412
|
+
const copy = join(stage, "copy");
|
|
45413
|
+
const aside = join(stage, "held");
|
|
45414
|
+
try {
|
|
45415
|
+
await cp(kitPath, copy, {
|
|
45416
|
+
recursive: true,
|
|
45417
|
+
dereference: true,
|
|
45418
|
+
filter: (path) => isKitFile(kitPath, path)
|
|
45419
|
+
});
|
|
45420
|
+
await rename(target, aside);
|
|
45421
|
+
await rename(copy, target).catch(async (error) => {
|
|
45422
|
+
await rename(aside, target);
|
|
45423
|
+
throw error;
|
|
45424
|
+
});
|
|
45425
|
+
} finally {
|
|
45426
|
+
if (existsSync(target)) await rm(stage, {
|
|
45427
|
+
recursive: true,
|
|
45428
|
+
force: true
|
|
45429
|
+
});
|
|
45430
|
+
}
|
|
45392
45431
|
}
|
|
45393
45432
|
/** The highest folder on the way to `path` that does not exist yet, which an undo removes whole. */
|
|
45394
45433
|
function topmostMissing(path) {
|
|
@@ -49145,8 +49184,9 @@ async function waitForAnimations(timeoutMs) {
|
|
|
49145
49184
|
}
|
|
49146
49185
|
// src/server/capture/element-shot.ts
|
|
49147
49186
|
/**
|
|
49148
|
-
* Leaves one element showing alone on a transparent ground,
|
|
49149
|
-
*
|
|
49187
|
+
* Leaves one element showing alone on a transparent ground, so the page is
|
|
49188
|
+
* shot once and closed. The box it answers can run past the frame's right and
|
|
49189
|
+
* bottom, and is no reading of the element's place past the left or top.
|
|
49150
49190
|
*/
|
|
49151
49191
|
async function isolateElement(page, ref, index) {
|
|
49152
49192
|
const isolated = await page.evaluate(hideAllBut, index);
|
|
@@ -49158,7 +49198,9 @@ async function isolateElement(page, ref, index) {
|
|
|
49158
49198
|
ref,
|
|
49159
49199
|
index
|
|
49160
49200
|
});
|
|
49161
|
-
|
|
49201
|
+
const { box } = isolated;
|
|
49202
|
+
if (box.x >= 0 && box.y >= 0) return box;
|
|
49203
|
+
return page.evaluate(shiftIntoView);
|
|
49162
49204
|
}
|
|
49163
49205
|
function hideAllBut(index) {
|
|
49164
49206
|
let count = 0;
|
|
@@ -49192,6 +49234,52 @@ function hideAllBut(index) {
|
|
|
49192
49234
|
}
|
|
49193
49235
|
};
|
|
49194
49236
|
}
|
|
49237
|
+
function shiftIntoView() {
|
|
49238
|
+
const root = document.documentElement;
|
|
49239
|
+
const target = document.querySelector("[data-frameboard-shot]");
|
|
49240
|
+
if (!target) throw new Error("No element is isolated.");
|
|
49241
|
+
const painted = () => {
|
|
49242
|
+
const { left, top, right, bottom } = target.getBoundingClientRect();
|
|
49243
|
+
const x = Math.round(left + window.scrollX) + 0;
|
|
49244
|
+
const y = Math.round(top + window.scrollY) + 0;
|
|
49245
|
+
return {
|
|
49246
|
+
x,
|
|
49247
|
+
y,
|
|
49248
|
+
width: Math.max(1, Math.round(right + window.scrollX) - x),
|
|
49249
|
+
height: Math.max(1, Math.round(bottom + window.scrollY) - y)
|
|
49250
|
+
};
|
|
49251
|
+
};
|
|
49252
|
+
const hold = (element, styles) => {
|
|
49253
|
+
for (const [name, value] of Object.entries(styles)) element.style.setProperty(name, value, "important");
|
|
49254
|
+
};
|
|
49255
|
+
const chain = [];
|
|
49256
|
+
for (let element = target; element && element !== root; element = element.parentElement) {
|
|
49257
|
+
const { width, height } = getComputedStyle(element);
|
|
49258
|
+
chain.unshift({
|
|
49259
|
+
element,
|
|
49260
|
+
width,
|
|
49261
|
+
height
|
|
49262
|
+
});
|
|
49263
|
+
}
|
|
49264
|
+
hold(root, {
|
|
49265
|
+
transition: "none",
|
|
49266
|
+
translate: "0px"
|
|
49267
|
+
});
|
|
49268
|
+
for (const { element, ...used } of chain) for (const side of ["width", "height"]) {
|
|
49269
|
+
const size = used[side];
|
|
49270
|
+
if (getComputedStyle(element)[side] === size) continue;
|
|
49271
|
+
hold(element, {
|
|
49272
|
+
transition: "none",
|
|
49273
|
+
[side]: size,
|
|
49274
|
+
[`min-${side}`]: size,
|
|
49275
|
+
[`max-${side}`]: size
|
|
49276
|
+
});
|
|
49277
|
+
}
|
|
49278
|
+
const { x, y } = painted();
|
|
49279
|
+
const shift = (at) => `${Math.max(0, -at) / root.currentCSSZoom}px`;
|
|
49280
|
+
hold(root, { translate: `${shift(x)} ${shift(y)}` });
|
|
49281
|
+
return painted();
|
|
49282
|
+
}
|
|
49195
49283
|
// src/server/capture/fonts.ts
|
|
49196
49284
|
/**
|
|
49197
49285
|
* Families the browser maps to a face itself, so no frame has to supply one.
|
|
@@ -51438,7 +51526,11 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
51438
51526
|
if (!measure) throw new FrameboardError("browser-not-found", "Fit height needs the board server's browser, and none runs here.");
|
|
51439
51527
|
for (const target of targets) {
|
|
51440
51528
|
const frame = await readFrame(root, target.ref, { cwd });
|
|
51441
|
-
const
|
|
51529
|
+
const page = pageBox(frame.box, frame.device, frame.turn);
|
|
51530
|
+
const content = await measure({
|
|
51531
|
+
...frame,
|
|
51532
|
+
box: page
|
|
51533
|
+
});
|
|
51442
51534
|
const widths = [];
|
|
51443
51535
|
for (const { width } of frame.widths) {
|
|
51444
51536
|
const bar = linkedBar(frame, width);
|
|
@@ -51452,7 +51544,7 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
51452
51544
|
});
|
|
51453
51545
|
}
|
|
51454
51546
|
target.measured = {
|
|
51455
|
-
height: content.height,
|
|
51547
|
+
height: content.height + topInset(frame.device, frame.turn),
|
|
51456
51548
|
widths
|
|
51457
51549
|
};
|
|
51458
51550
|
}
|
|
@@ -53589,14 +53681,14 @@ function contentFormat() {
|
|
|
53589
53681
|
"hidden, locked, hugWidth, hugHeight, and scroll read as false when absent, and an axis whose hug flag is false holds the size its entry states.",
|
|
53590
53682
|
`scroll marks a frame that holds a fixed screen height and scrolls past it, such as a page with a sticky section. It fixes both axes, so either hug flag beside it reads as false, frame fit refuses it, and serve never measures it. frame add --scroll sets it, taking the height given or else the preset height of the width (${FRAME_SIZES.desktop.height} px at ${FRAME_SIZES.desktop.width}). frame resize --scroll sets it on a placed frame, dropping a hugging height to that preset height unless a height is given and keeping a fixed height as it stands, so resize a frame fixed past a screen with --height too. frame resize --no-scroll clears it, keeping the box.`,
|
|
53591
53683
|
`widths lists the extra widths one frame file also shows at, as { width, height } objects, each drawn 80 px past the last, or past its device's body, in a row beside the frame at its y, so a responsive page is one file rather than a copy per width. Each width follows the frame's own height mode: it hugs its content at that width while hugHeight is on, and otherwise holds its height, the preset height of its width when first set and on frame resize --scroll. A value of any other shape reads as none. frame add --widths 834,390 and frame resize --widths set it, refusing a repeated width, the frame's own width, or a frame hugging its width, and frame resize --no-widths clears it. capture writes <frame>@<width>.<theme>.png beside <frame>.<theme>.png, check reports a browser finding at a linked width with that width and prints it as <path>@<width>, and a frames.json value of <project>/<page>/<frame>@<width> syncs that width's images.`,
|
|
53592
|
-
`showDevice true has the board draw the frame inside the device its width names: a phone from 320 to 479 px wide, a tablet from 480 to 1023, and a laptop from 1024 up, with none under 320. The phone's body stands ${BEZELS.phone.border} px past the box on every side, with side buttons 4 px past that, and the tablet's ${BEZELS.tablet.border}, with a power button and two volume buttons 6 px past that, and the laptop's lid ${BEZELS.laptop.border} px past its top and sides, with a chin and a wider base below. A resize redraws the body with no write, and list reports the device the width names as device, absent when off or under 320. It never changes the frame file, its size, or its box. frame add, frame duplicate, and a paste place a frame beside another with its own body, a laptop's base included, 80 px past the other's body. A frame given --x keeps that x, a frame landing in a reserved box keeps that box
|
|
53684
|
+
`showDevice true has the board draw the frame inside the device its width names: a phone from 320 to 479 px wide, a tablet from 480 to 1023, and a laptop from 1024 up, with none under 320. The phone's body stands ${BEZELS.phone.border} px past the box on every side, with side buttons 4 px past that, and the tablet's ${BEZELS.tablet.border}, with a power button and two volume buttons 6 px past that, and the laptop's lid ${BEZELS.laptop.border} px past its top and sides, with a chin and a wider base below. A resize redraws the body with no write, and list reports the device the width names as device, absent when off or under 320. It never changes the frame file, its size, or its box. frame add, frame duplicate, and a paste place a frame beside another with its own body, a laptop's base included, 80 px past the other's body. A frame given --x keeps that x, a frame landing in a reserved box keeps that box, which left room for a device only where its name gave one, and a placed frame stays where it stands when its device turns on. Each linked width draws inside the device its own width names, bare under 320 and whenever the frame's device is off, and capture --composite draws the body of every frame and linked width showing one. Any other value of showDevice reads as off and is kept on write. A device string from before showDevice reads as on, and the entry's next write replaces it with showDevice. frame add --device on and frame device <frame-ref> <on|off> set it, taking phone and tablet as on and none as off.`,
|
|
53593
53685
|
`While a phone shows, the board draws a status bar over the top ${STATUS_BAR.height} px of the frame's box, in the page's own fill and text color, and the page starts under it: a frame ${FRAME_SIZES.phone.width} by ${FRAME_SIZES.phone.height} shows a page ${FRAME_SIZES.phone.width} by ${FRAME_SIZES.phone.height - STATUS_BAR.height}. The box in layout.json keeps the screen's size, and the frame file gains no padding. A hugging height measures the page and stores it plus the bar, frame fit does the same, and capture, check, inspect, and present each read the page under the bar. An export draws the bar only with its device included, and lays the page out at the whole box without it. A linked width that names a phone starts its page under a bar the same way, and a hugging one stores its page plus the bar. With the device off, or on any other device, the page is the whole box.`,
|
|
53594
|
-
"showOverflow true has the board paint each element past the frame's edge as a still picture at its place, the first twenty in document order
|
|
53686
|
+
"showOverflow true has the board paint each element past the frame's edge as a still picture at its place, the first twenty in document order, and absent clips. A shadow or text past the element's own box is cut, and a frame that scrolls or shows its device clips either way. It changes what the board draws in Edit alone: capture, export, and present still cut at the box, and check still reports clipped. list --json gives it while true, any other value reads as clipped and is kept on write, and the developer sets it with the inspector's Clip content switch.",
|
|
53595
53687
|
`island wide has a phone draw its wide island, the one a call or a timer shows, and absent draws the compact one. It is kept while the device is off and reads as compact on any other device. Any other value reads as compact and is kept on write. frame device <frame-ref> --island wide sets it, --island compact clears it, and both refuse a frame whose width names no phone or that names the foldable.`,
|
|
53596
53688
|
`turn left or right turns a phone, a tablet, or a foldable a quarter, with the island on the left side for left and the right for right, and absent stands it upright. A phone's or a tablet's first turn keeps the box's upright width and height in upright, and the upright width still picks the device, so a turned phone reads as a phone however wide its box. A fixed or scroll box swaps its sides, and a hugging one takes the reference height of its upright width, ${FRAME_SIZES.phone.height} px for a phone, and hugs its height at that width. A turned phone draws no status bar and insets its page ${STATUS_BAR.height} px from each short side instead, with both strips in the page's own fill so the island stands over no content, and its buttons stand on its long edges: an ${FRAME_SIZES.phone.height} by ${FRAME_SIZES.phone.width} turned box shows a page ${FRAME_SIZES.phone.height - 2 * STATUS_BAR.height} by ${FRAME_SIZES.phone.width}, and a hugging one hugs at that page width. list reports turn while the frame is turned, shown or not, and never upright. Turning upright restores the kept size, even after a hand resize of the turned box. A turned foldable keeps no upright, since its pose gives its screen: its box is that screen with the sides swapped, ${POSE_SIZES.closed.height} by ${POSE_SIZES.closed.width} closed and ${POSE_SIZES.open.height} by ${POSE_SIZES.open.width} half or open, its island sits where the quarter turn puts it, its fold runs across the screen, and its page insets ${sideInset("foldable", "left")} px from each side edge in the page's own fill as a turned phone's does, so a turned closed box shows a page ${POSE_SIZES.closed.height - 2 * sideInset("foldable", "left")} by ${POSE_SIZES.closed.width}. A fold keeps the turn and takes the new pose's swapped screen, upright restores the pose's screen, and --no-foldable stands it upright at that screen. frame device <frame-ref> --turn <upright|left|right> sets it, writing the layout entry alone, and a quarter turn refuses a laptop, a frame showing no device, and a frame holding extra widths, each with usage. A turned frame refuses new extra widths, and naming a turned phone or tablet the foldable stands it upright first. A phone's or a tablet's turn with no readable upright, or a value no reader knows, reads as upright.`,
|
|
53597
53689
|
`foldable true has the frame name the foldable device over the one its width picks, and pose folds it: closed is the cover screen at ${POSE_SIZES.closed.width} by ${POSE_SIZES.closed.height}, and half and open are the inner screen at ${POSE_SIZES.open.width} by ${POSE_SIZES.open.height}, half shading the fold. Naming a foldable or setting a pose sets the box's width and height to that screen and turns both hug flags off, and writes the layout entry alone, never the frame file, so one file shows every pose and its content reflows as on the device. The body stands ${BEZELS.foldable.border} px past the box on every side. A newly named foldable starts in the pose nearest its width, closed up to 678 px wide and open past it. list reports device as foldable while it shows, and pose on every frame naming one, shown or not. With showDevice off the box keeps its pose's size and no body draws. A foldable draws no linked width and refuses a new one, and widths its entry held from before stay in the file undrawn, draw again once --no-foldable un-names it, and clear on frame resize --no-widths. Any other value of foldable reads as width-picked, a pose no reader knows reads as closed, and both are kept on write. An older Frameboard rewriting the entry may drop both keys, leaving a width-picked frame at the pose's size. frame device <frame-ref> --foldable names it and shows it, --pose <closed|half|open> folds it, and --no-foldable hands the pick back to the width at the size it stands.`,
|
|
53598
53690
|
`An axis that hugs takes its size from the frame's content: a running serve measures it after each write to the frame file and when frame add places a file already written, its width at most ${FRAME_SIZES.desktop.width} px, and writes width and height alone, never a flag. Content sized off the viewport keeps the box it has.`,
|
|
53599
|
-
"frame add with no size hugs both axes, --size or --width fixes the width and hugs the height, and --height fixes the height alone, its box standing in until serve measures. With no --size, --width, or --height, no reserved box, and no entry left in layout.json by a missing file, frame add takes a name ending in -<px>, such as overview-390, as --width 390 with showDevice on, where <px> is the width of a size in frameSizes, and any other ending hugs both axes. frame resize and a hand resize fix each axis they set, and frame fit sets the height and turns hugHeight on.",
|
|
53691
|
+
"frame add with no size hugs both axes, --size or --width fixes the width and hugs the height, and --height fixes the height alone, its box standing in until serve measures. With no --size, --width, or --height, no reserved box, and no entry left in layout.json by a missing file, frame add takes a name ending in -<px>, such as overview-390, as --width 390 with showDevice on, where <px> is the width of a size in frameSizes, and any other ending hugs both axes. editing --new with no size flag reads the name the same way, and frame add into that reserved box keeps its width and device. frame resize and a hand resize fix each axis they set, and frame fit sets the height and turns hugHeight on.",
|
|
53600
53692
|
"Frames sort by order, then name, and a write that changes order renumbers the page from 0.",
|
|
53601
53693
|
`A frame file with no entry is unplaced: it reads at desktop size, y 0, 80 px past the right edge of every frame placed before it in name order. frame add places it 80 px past the placed frames alone, so the first unplaced file keeps that box and any later one moves left.`,
|
|
53602
53694
|
"An entry with no frame file beside it is ignored on read and kept on write.",
|
|
@@ -53619,7 +53711,7 @@ function contentFormat() {
|
|
|
53619
53711
|
],
|
|
53620
53712
|
kits: [
|
|
53621
53713
|
`A kit is a folder of plain files: ${KIT_FILE} naming it, ${TOKEN_FILE} with a light and a dark block, ${KIT_SHEET} of component styles, ${KIT_NOTE} saying what to reach for, and a kit page of sample frames. The tool ships ${SHIPPED_KITS.join(", ")}, and a board keeps the kits saved from its projects in ${KITS_FOLDER}/.`,
|
|
53622
|
-
`kit add copies the kit's folder into the project's ${ASSETS_FOLDER}/${PROJECT_KITS}/<kit>/ and writes no token sheet and no page, so a project holds several kits beside its own look. It refuses name-taken where the project already holds a kit by that name
|
|
53714
|
+
`kit add copies the kit's folder into the project's ${ASSETS_FOLDER}/${PROJECT_KITS}/<kit>/ and writes no token sheet and no page, so a project holds several kits beside its own look. It refuses name-taken where the project already holds a kit by that name. kit add --replace puts the copy in place of that kit instead, dropping the old files and any edit made to them, answering replaced true, and every frame naming it keeps its kit. Where the project holds none, it adds the kit. kit remove deletes that folder and clears the kit from every frame naming it, refusing kit-not-found for a kit the project lacks. kit save refuses name-taken for a name a shipped or saved kit holds, and tokens-not-found for a project no sheet reaches.`,
|
|
53623
53715
|
`A frame draws with a kit only where its ${LAYOUT_FILE} entry names one under kit. frame kit <frame-ref> <kit> sets it and frame kit <frame-ref> ${NO_KIT_WORD} clears it, each writing ${LAYOUT_FILE} alone, and it refuses kit-not-found for a kit the project lacks. The frame file never names the kit, so rewriting the frame keeps it. list --json answers kit on each frame naming one and kits on each project, with every kit's name, title, and frameCount.`,
|
|
53624
53716
|
`The server imports ${ASSETS_FOLDER}/${PROJECT_KITS}/<kit>/${TOKEN_FILE} then ${KIT_SHEET} into a frame naming that kit, after the project sheet, and check reads the same sheets. A plain frame beside it loads neither, and a frame naming a kit whose folder is gone loads none and keeps the name. Read ${ASSETS_FOLDER}/${PROJECT_KITS}/<kit>/${KIT_NOTE} and the sample frames under its kit/ folder before drawing a frame that names it.`,
|
|
53625
53717
|
`A project holding ${ASSETS_FOLDER}/kit/${KIT_FILE} took its kit before a frame could name one, and every frame in it still loads ${ASSETS_FOLDER}/kit/${KIT_SHEET} after the project sheet. An ${ASSETS_FOLDER}/kit/ holding no ${KIT_FILE} is loaded into no frame, so a frame using it links it itself.`
|
|
@@ -53852,7 +53944,7 @@ function tagFor(agent, session, cwd) {
|
|
|
53852
53944
|
const ANY_INTEGER$1 = parseInteger(Number.MIN_SAFE_INTEGER);
|
|
53853
53945
|
function registerEditing(program, context) {
|
|
53854
53946
|
const { io } = context;
|
|
53855
|
-
act(addVerb(program, "editing", "Claim a frame before rewriting it, so the board shows it and another session is told it is taken. With --new, reserve frames not written yet, so the board shows where each will land. Bare, list the live claims", { project: true }).argument("[frame-refs...]", "the frame to claim or release
|
|
53947
|
+
act(addVerb(program, "editing", "Claim a frame before rewriting it, so the board shows it and another session is told it is taken. With --new, reserve frames not written yet, so the board shows where each will land, a -<px> name with no size flag giving its width and device. Bare, list the live claims", { project: true }).argument("[frame-refs...]", "the frame to claim, or every frame to release with --release or reserve with --new").option("--release", "drop this session's claim on each frame named, or every claim it holds").option("--new", "reserve each frame named, none of which may exist yet, as one set that renews together").addOption(new Option("--size <preset>", "with --new, a size preset or device for every frame").choices(FRAME_SIZE_NAMES)).option("--width <n>", "with --new, width in px", parseInteger(1)).option("--height <n>", "with --new, height in px", parseInteger(1)).option("--x <n>", "with --new, board x of the first frame in px", ANY_INTEGER$1).option("--y <n>", "with --new, board y of the row in px", ANY_INTEGER$1).option("--session <id>", `the session holding the claim, defaulting to ${SESSION_ENV}`).option("--agent <name>", "the agent the board names, by its first letter", DEFAULT_AGENT), context, async (refs, options) => {
|
|
53856
53948
|
const root = await boardOf(options, io);
|
|
53857
53949
|
const now = /* @__PURE__ */ new Date();
|
|
53858
53950
|
if (options.new) {
|
|
@@ -53867,19 +53959,23 @@ function registerEditing(program, context) {
|
|
|
53867
53959
|
human: `Reserved ${claims.map((each) => each.frame).join(", ")}. Claim any of them again within five minutes to keep the set.`
|
|
53868
53960
|
};
|
|
53869
53961
|
}
|
|
53870
|
-
if (refs.length > 1) throw new FrameboardError("usage", `editing claims one frame at a time. Pass --new to reserve ${refs.length} frames not written yet.`, { refs });
|
|
53871
|
-
const [ref] = refs;
|
|
53872
53962
|
if (options.release) {
|
|
53873
53963
|
const session = sessionOf(options.session);
|
|
53874
|
-
const
|
|
53964
|
+
const frames = await targetsOf(root, refs, options, io.cwd);
|
|
53965
|
+
await assertClaimable(root, refs, frames, now);
|
|
53966
|
+
const released = await release(root, session, refs.length > 0 ? frames.map(refOf) : void 0, now);
|
|
53875
53967
|
return {
|
|
53876
53968
|
data: { released },
|
|
53877
53969
|
human: released.length === 0 ? `${session} held no claim to release` : `Released ${released.map((each) => each.frame).join(", ")}`
|
|
53878
53970
|
};
|
|
53879
53971
|
}
|
|
53972
|
+
if (refs.length > 1) throw new FrameboardError("usage", `editing claims one frame at a time. Pass --new to reserve ${refs.length} frames not written yet, or --release to drop ${refs.length} claims.`, { refs });
|
|
53973
|
+
const [ref] = refs;
|
|
53880
53974
|
if (ref) {
|
|
53881
53975
|
const session = sessionOf(options.session);
|
|
53882
|
-
const
|
|
53976
|
+
const target = await targetOf(root, ref, options, io.cwd);
|
|
53977
|
+
await assertClaimable(root, refs, [target], now);
|
|
53978
|
+
const frame = refOf(target);
|
|
53883
53979
|
const held = await claim(root, {
|
|
53884
53980
|
frame,
|
|
53885
53981
|
session,
|
|
@@ -53898,26 +53994,31 @@ function registerEditing(program, context) {
|
|
|
53898
53994
|
};
|
|
53899
53995
|
});
|
|
53900
53996
|
}
|
|
53901
|
-
|
|
53902
|
-
|
|
53997
|
+
/** The frame a ref names, whether or not its file is written. */
|
|
53998
|
+
function targetOf(root, ref, options, cwd) {
|
|
53999
|
+
return resolveFrameRef(root, ref, {
|
|
53903
54000
|
project: options.project,
|
|
53904
|
-
cwd
|
|
53905
|
-
|
|
54001
|
+
cwd,
|
|
54002
|
+
allowMissing: true
|
|
54003
|
+
});
|
|
54004
|
+
}
|
|
54005
|
+
function targetsOf(root, refs, options, cwd) {
|
|
54006
|
+
return Promise.all(refs.map((ref) => targetOf(root, ref, options, cwd)));
|
|
53906
54007
|
}
|
|
53907
54008
|
/**
|
|
53908
|
-
*
|
|
53909
|
-
*
|
|
53910
|
-
* draw it. Any other missing frame refuses `frame-not-found` as before.
|
|
54009
|
+
* Refuses the whole call as `frame-not-found`, naming every frame with no
|
|
54010
|
+
* file and no live reservation, which an agent claims as it turns to draw it.
|
|
53911
54011
|
*/
|
|
53912
|
-
async function
|
|
53913
|
-
const
|
|
53914
|
-
|
|
53915
|
-
|
|
53916
|
-
|
|
53917
|
-
const
|
|
53918
|
-
if (
|
|
53919
|
-
if (
|
|
53920
|
-
|
|
54012
|
+
async function assertClaimable(root, refs, frames, now) {
|
|
54013
|
+
const unwritten = frames.filter((frame) => !existsSync(frame.path));
|
|
54014
|
+
const live = unwritten.length > 0 ? await readClaims(root, now) : [];
|
|
54015
|
+
const reserved = new Set(live.filter((each) => each.box).map((each) => each.frame));
|
|
54016
|
+
const missing = unwritten.filter((frame) => !reserved.has(refOf(frame)));
|
|
54017
|
+
const [first] = missing;
|
|
54018
|
+
if (!first) return;
|
|
54019
|
+
if (refs.length === 1) throw new FrameboardError("frame-not-found", `No frame ${first.name} in ${first.project}/${first.page}.`, { ref: refs[0] });
|
|
54020
|
+
const named = missing.map(refOf);
|
|
54021
|
+
throw new FrameboardError("frame-not-found", `No frame or reservation ${named.join(", ")}, so nothing was released.`, { refs: named });
|
|
53921
54022
|
}
|
|
53922
54023
|
/** `<project>/<page>/<frame>`, the one form a claim names a frame by. */
|
|
53923
54024
|
function refOf(frame) {
|
|
@@ -53929,45 +54030,73 @@ function refOf(frame) {
|
|
|
53929
54030
|
*/
|
|
53930
54031
|
async function reservationsOf(root, refs, options, cwd, now) {
|
|
53931
54032
|
if (refs.length === 0) throw new FrameboardError("usage", "Name at least one frame to reserve with --new.");
|
|
53932
|
-
const frames = await
|
|
53933
|
-
...resolving(options, cwd),
|
|
53934
|
-
allowMissing: true
|
|
53935
|
-
})));
|
|
54033
|
+
const frames = await targetsOf(root, refs, options, cwd);
|
|
53936
54034
|
const existing = frames.filter((frame) => existsSync(frame.path));
|
|
53937
54035
|
if (existing.length > 0) throw new FrameboardError("name-taken", `${existing.map(refOf).join(", ")} already exists, so claim it with editing <ref> rather than reserving it.`, { refs: existing.map(refOf) });
|
|
53938
54036
|
const named = frames.map(refOf);
|
|
53939
54037
|
const repeated = named.find((ref, index) => named.indexOf(ref) !== index);
|
|
53940
54038
|
if (repeated) throw new FrameboardError("usage", `${repeated} is named twice.`, { ref: repeated });
|
|
53941
|
-
const size = {
|
|
53942
|
-
...FRAME_SIZES[DEFAULT_FRAME_SIZE],
|
|
53943
|
-
...sizeOf(options)
|
|
53944
|
-
};
|
|
53945
|
-
const hugs = hugsOf(options);
|
|
53946
54039
|
const live = await readClaims(root, now);
|
|
53947
|
-
const
|
|
54040
|
+
const edges = /* @__PURE__ */ new Map();
|
|
53948
54041
|
const reservations = [];
|
|
53949
54042
|
for (const frame of frames) {
|
|
53950
54043
|
const page = `${frame.project}/${frame.page}`;
|
|
53951
|
-
const
|
|
53952
|
-
|
|
54044
|
+
const size = await reservedSize(frame, options);
|
|
54045
|
+
const device = deviceOf(size);
|
|
54046
|
+
const edge = edges.get(page);
|
|
54047
|
+
const box = {
|
|
54048
|
+
x: edge === void 0 ? options.x ?? Math.max(xPast(await rightOf(root, frame, live), size.width, device), 0) : xPast(edge, size.width, device),
|
|
54049
|
+
y: options.y ?? 0,
|
|
54050
|
+
...size
|
|
54051
|
+
};
|
|
54052
|
+
const body = bezelBox(box, device, "upright");
|
|
54053
|
+
edges.set(page, body.x + body.width);
|
|
53953
54054
|
reservations.push({
|
|
53954
54055
|
frame: refOf(frame),
|
|
53955
|
-
box
|
|
53956
|
-
x,
|
|
53957
|
-
y: options.y ?? 0,
|
|
53958
|
-
...size,
|
|
53959
|
-
...hugs
|
|
53960
|
-
}
|
|
54056
|
+
box
|
|
53961
54057
|
});
|
|
53962
54058
|
}
|
|
53963
54059
|
return reservations;
|
|
53964
54060
|
}
|
|
53965
|
-
/**
|
|
54061
|
+
/**
|
|
54062
|
+
* The size a frame reserves, as `frame add` would size it: a flag's, else the
|
|
54063
|
+
* width its name states in that width's device, else the default hugging.
|
|
54064
|
+
*/
|
|
54065
|
+
async function reservedSize(frame, options) {
|
|
54066
|
+
const size = {
|
|
54067
|
+
...FRAME_SIZES[DEFAULT_FRAME_SIZE],
|
|
54068
|
+
...sizeOf(options),
|
|
54069
|
+
...hugsOf(options)
|
|
54070
|
+
};
|
|
54071
|
+
const width = options.size !== void 0 || options.width !== void 0 || options.height !== void 0 ? void 0 : namedWidth(frame.name);
|
|
54072
|
+
if (width === void 0 || await hasEntry(frame)) return size;
|
|
54073
|
+
return {
|
|
54074
|
+
...size,
|
|
54075
|
+
width,
|
|
54076
|
+
hugWidth: false,
|
|
54077
|
+
showDevice: true
|
|
54078
|
+
};
|
|
54079
|
+
}
|
|
54080
|
+
/** Whether the page's layout holds an entry for a frame, none where it does not parse. */
|
|
54081
|
+
async function hasEntry(frame) {
|
|
54082
|
+
try {
|
|
54083
|
+
const layout = await readRecord(join(dirname(frame.path), LAYOUT_FILE), layoutSpec);
|
|
54084
|
+
return Object.hasOwn(layout.frames, frame.name);
|
|
54085
|
+
} catch (error) {
|
|
54086
|
+
if (error instanceof FrameboardError) return false;
|
|
54087
|
+
throw error;
|
|
54088
|
+
}
|
|
54089
|
+
}
|
|
54090
|
+
/** The device a reserved box will land in, none for one no name sized. */
|
|
54091
|
+
function deviceOf({ showDevice, width }) {
|
|
54092
|
+
return showDevice ? deviceForWidth(width) : null;
|
|
54093
|
+
}
|
|
54094
|
+
/** The right edge of a page's frames' drawn rows and reserved bodies. */
|
|
53966
54095
|
async function rightOf(root, frame, live) {
|
|
53967
54096
|
const page = await scanPage(root, frame.project, frame.page, 0);
|
|
53968
54097
|
const prefix = `${frame.project}/${frame.page}/`;
|
|
53969
|
-
const boxes = [...page.frames.map((each) => drawnExtent(each.box, each.widths, each)), ...live.flatMap((each) => each.box && each.frame.startsWith(prefix) ? [each.box] : [])];
|
|
53970
|
-
return Math.max(...boxes.map((box) => box.x + box.width
|
|
54098
|
+
const boxes = [...page.frames.map((each) => drawnExtent(each.box, each.widths, each)), ...live.flatMap((each) => each.box && each.frame.startsWith(prefix) ? [bezelBox(each.box, deviceOf(each.box), "upright")] : [])];
|
|
54099
|
+
return Math.max(...boxes.map((box) => box.x + box.width));
|
|
53971
54100
|
}
|
|
53972
54101
|
function describe$4(claims, now) {
|
|
53973
54102
|
if (claims.length === 0) return "No frame is claimed";
|
|
@@ -58465,17 +58594,17 @@ function registerKit(program, context) {
|
|
|
58465
58594
|
human: kits.map((each) => `${each.name}\t${each.description}`).join("\n")
|
|
58466
58595
|
};
|
|
58467
58596
|
});
|
|
58468
|
-
act(addVerb(kit, "add", "Add a kit to a project as a copy under assets/kits/<kit>/, leaving its token sheets alone, so frame kit can set it on a frame. Refuses name-taken where the project already holds a kit by that name").argument("<project>", "the project").argument("[kit]", "a kit `kit list` names").option("--from <folder>", "add the kit in this folder instead").
|
|
58597
|
+
act(addVerb(kit, "add", "Add a kit to a project as a copy under assets/kits/<kit>/, leaving its token sheets alone, so frame kit can set it on a frame. Refuses name-taken where the project already holds a kit by that name, unless --replace puts this copy in its place").argument("<project>", "the project").argument("[kit]", "a kit `kit list` names").option("--from <folder>", "add the kit in this folder instead").option("--replace", "put this copy in place of a kit the project already holds by that name, dropping its old files and leaving every frame’s kit as it is"), context, async ([project = "", name], options) => {
|
|
58469
58598
|
if (name === void 0 === (options.from === void 0)) throw new FrameboardError("usage", "Name a kit or pass --from <folder>, not both.");
|
|
58470
58599
|
const root = await boardOf(options, io);
|
|
58471
58600
|
const folder = options.from === void 0 ? null : resolve$1(io.cwd, options.from);
|
|
58472
58601
|
const record = await installKit(root, project, folder === null ? findKit(root, name ?? "") : {
|
|
58473
58602
|
name: basename(folder),
|
|
58474
58603
|
path: folder
|
|
58475
|
-
});
|
|
58604
|
+
}, { replace: options.replace });
|
|
58476
58605
|
return {
|
|
58477
58606
|
data: record,
|
|
58478
|
-
human: `Added ${record.kit} to ${record.project}`
|
|
58607
|
+
human: record.replaced ? `Replaced ${record.kit} in ${record.project}` : `Added ${record.kit} to ${record.project}`
|
|
58479
58608
|
};
|
|
58480
58609
|
});
|
|
58481
58610
|
act(addVerb(kit, "remove", "Take a kit out of a project, deleting its folder under assets/kits/ and clearing it from every frame naming it, so each draws with the project’s sheets alone. Refuses kit-not-found for a kit the project holds none under").argument("<project>", "the project").argument("<kit>", "a kit the project holds"), context, async ([project = "", name = ""], options) => {
|
|
@@ -59972,7 +60101,7 @@ async function landReserved(root, now) {
|
|
|
59972
60101
|
for (const { claim, page, name } of due) {
|
|
59973
60102
|
const layout = layoutAt(layouts, page);
|
|
59974
60103
|
if (layout.hasEntry(name) || !layout.names.includes(name)) continue;
|
|
59975
|
-
const { x, y, width, height, hugWidth, hugHeight } = claim.box;
|
|
60104
|
+
const { x, y, width, height, hugWidth, hugHeight, showDevice } = claim.box;
|
|
59976
60105
|
layout.set(name, {
|
|
59977
60106
|
box: {
|
|
59978
60107
|
x,
|
|
@@ -59987,6 +60116,7 @@ async function landReserved(root, now) {
|
|
|
59987
60116
|
hugHeight: hugHeight ?? false,
|
|
59988
60117
|
scroll: false,
|
|
59989
60118
|
widths: [],
|
|
60119
|
+
...showDevice ? { showDevice: true } : {},
|
|
59990
60120
|
placed: true
|
|
59991
60121
|
});
|
|
59992
60122
|
layout.renumber();
|
|
@@ -60097,6 +60227,159 @@ async function startFrameOrigin(options) {
|
|
|
60097
60227
|
})
|
|
60098
60228
|
};
|
|
60099
60229
|
}
|
|
60230
|
+
// src/shared/board-sync/patch.ts
|
|
60231
|
+
/** The patch that makes `next` of `held`. */
|
|
60232
|
+
function patchBetween(held, next) {
|
|
60233
|
+
return {
|
|
60234
|
+
...next,
|
|
60235
|
+
projects: listMoved(held.projects, next.projects, projectPatch)
|
|
60236
|
+
};
|
|
60237
|
+
}
|
|
60238
|
+
function projectPatch(held, next) {
|
|
60239
|
+
return {
|
|
60240
|
+
...next,
|
|
60241
|
+
pages: listMoved(held?.pages ?? [], next.pages, pagePatch)
|
|
60242
|
+
};
|
|
60243
|
+
}
|
|
60244
|
+
function pagePatch(held, next) {
|
|
60245
|
+
return {
|
|
60246
|
+
...next,
|
|
60247
|
+
frames: listMoved(held?.frames ?? [], next.frames, (_, frame) => frame)
|
|
60248
|
+
};
|
|
60249
|
+
}
|
|
60250
|
+
function listMoved(held, next, patch) {
|
|
60251
|
+
const byName = namedOf(held);
|
|
60252
|
+
return next.map((record) => {
|
|
60253
|
+
const match = byName.get(record.name);
|
|
60254
|
+
return match !== void 0 && isEqual(match, record) ? record.name : patch(match, record);
|
|
60255
|
+
});
|
|
60256
|
+
}
|
|
60257
|
+
function namedOf(records) {
|
|
60258
|
+
return new Map(records.map((record) => [record.name, record]));
|
|
60259
|
+
}
|
|
60260
|
+
/** Whether two JSON values match on every key, named in their types or not. */
|
|
60261
|
+
function isEqual(a, b) {
|
|
60262
|
+
if (a === b) return true;
|
|
60263
|
+
if (!isObject(a) || !isObject(b)) return false;
|
|
60264
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
60265
|
+
const keys = Object.keys(a);
|
|
60266
|
+
return keys.length === Object.keys(b).length && keys.every((key) => Object.hasOwn(b, key) && isEqual(a[key], b[key]));
|
|
60267
|
+
}
|
|
60268
|
+
function isObject(value) {
|
|
60269
|
+
return typeof value === "object" && value !== null;
|
|
60270
|
+
}
|
|
60271
|
+
// src/shared/board-sync/rename.ts
|
|
60272
|
+
/**
|
|
60273
|
+
* Whether `board` still waits on a rename, holding `before` and not yet
|
|
60274
|
+
* `after`. Both ends ask it, so a tab and the server's copy of what the tabs
|
|
60275
|
+
* hold take the same renames.
|
|
60276
|
+
*/
|
|
60277
|
+
function takesRename(board, before, after) {
|
|
60278
|
+
return holdsRef(board, before) && !holdsRef(board, after);
|
|
60279
|
+
}
|
|
60280
|
+
function holdsRef(board, ref) {
|
|
60281
|
+
return board.projects.some((project) => project.name === ref || project.pages.some((page) => page.ref === ref || page.frames.some((frame) => frame.ref === ref)));
|
|
60282
|
+
}
|
|
60283
|
+
/**
|
|
60284
|
+
* The board with one project, page, or frame renamed, its path and
|
|
60285
|
+
* everything under it following.
|
|
60286
|
+
*/
|
|
60287
|
+
function renameOnBoard(board, before, after) {
|
|
60288
|
+
const [project = "", page, frame] = before.split("/");
|
|
60289
|
+
const name = after.split("/").at(-1) ?? after;
|
|
60290
|
+
const repath = (from, to) => (path) => path === from || path.startsWith(`${from}/`) ? `${to}${path.slice(from.length)}` : path;
|
|
60291
|
+
return {
|
|
60292
|
+
...board,
|
|
60293
|
+
projects: board.projects.map((held) => {
|
|
60294
|
+
if (held.name !== project) return held;
|
|
60295
|
+
if (frame !== void 0) return {
|
|
60296
|
+
...held,
|
|
60297
|
+
pages: held.pages.map((each) => each.name !== page ? each : {
|
|
60298
|
+
...each,
|
|
60299
|
+
frames: each.frames.map((one) => one.ref !== before ? one : {
|
|
60300
|
+
...one,
|
|
60301
|
+
ref: after,
|
|
60302
|
+
name,
|
|
60303
|
+
path: siblingPath(one.path, `${name}.html`)
|
|
60304
|
+
})
|
|
60305
|
+
})
|
|
60306
|
+
};
|
|
60307
|
+
if (page === void 0) {
|
|
60308
|
+
const path = repath(held.path, siblingPath(held.path, name));
|
|
60309
|
+
return {
|
|
60310
|
+
...held,
|
|
60311
|
+
name,
|
|
60312
|
+
path: path(held.path),
|
|
60313
|
+
pages: held.pages.map((each) => ({
|
|
60314
|
+
...each,
|
|
60315
|
+
ref: `${name}/${each.name}`,
|
|
60316
|
+
project: name,
|
|
60317
|
+
path: path(each.path),
|
|
60318
|
+
frames: each.frames.map((frame) => ({
|
|
60319
|
+
...frame,
|
|
60320
|
+
ref: `${name}/${each.name}/${frame.name}`,
|
|
60321
|
+
project: name,
|
|
60322
|
+
path: path(frame.path)
|
|
60323
|
+
}))
|
|
60324
|
+
}))
|
|
60325
|
+
};
|
|
60326
|
+
}
|
|
60327
|
+
return {
|
|
60328
|
+
...held,
|
|
60329
|
+
pages: held.pages.map((each) => {
|
|
60330
|
+
if (each.name !== page) return each;
|
|
60331
|
+
const path = repath(each.path, siblingPath(each.path, name));
|
|
60332
|
+
return {
|
|
60333
|
+
...each,
|
|
60334
|
+
ref: after,
|
|
60335
|
+
name,
|
|
60336
|
+
path: path(each.path),
|
|
60337
|
+
frames: each.frames.map((frame) => ({
|
|
60338
|
+
...frame,
|
|
60339
|
+
ref: `${after}/${frame.name}`,
|
|
60340
|
+
page: name,
|
|
60341
|
+
path: path(frame.path)
|
|
60342
|
+
}))
|
|
60343
|
+
};
|
|
60344
|
+
})
|
|
60345
|
+
};
|
|
60346
|
+
})
|
|
60347
|
+
};
|
|
60348
|
+
}
|
|
60349
|
+
/** The folder path beside `path` named `name`. */
|
|
60350
|
+
function siblingPath(path, name) {
|
|
60351
|
+
return `${path.slice(0, path.lastIndexOf("/") + 1)}${name}`;
|
|
60352
|
+
}
|
|
60353
|
+
// src/server/live/feed.ts
|
|
60354
|
+
/**
|
|
60355
|
+
* Holds the board the tabs hold, which every patch starts from. Each verb
|
|
60356
|
+
* moves it and sends in one synchronous step, so no other crosses between.
|
|
60357
|
+
*/
|
|
60358
|
+
function createBoardFeed(hub) {
|
|
60359
|
+
let held = {
|
|
60360
|
+
root: "",
|
|
60361
|
+
projects: []
|
|
60362
|
+
};
|
|
60363
|
+
return {
|
|
60364
|
+
push: (board) => {
|
|
60365
|
+
hub.broadcastBoard(board, patchBetween(held, board));
|
|
60366
|
+
held = board;
|
|
60367
|
+
},
|
|
60368
|
+
rename: (before, after) => {
|
|
60369
|
+
hub.broadcast({
|
|
60370
|
+
type: "renamed",
|
|
60371
|
+
before,
|
|
60372
|
+
after
|
|
60373
|
+
});
|
|
60374
|
+
if (takesRename(held, before, after)) held = renameOnBoard(held, before, after);
|
|
60375
|
+
},
|
|
60376
|
+
join: (board, deliver) => {
|
|
60377
|
+
if (!isEqual(held, board)) hub.broadcastPatch(patchBetween(held, board));
|
|
60378
|
+
held = board;
|
|
60379
|
+
deliver(board);
|
|
60380
|
+
}
|
|
60381
|
+
};
|
|
60382
|
+
}
|
|
60100
60383
|
// node_modules/readdirp/index.js
|
|
60101
60384
|
const EntryTypes = {
|
|
60102
60385
|
FILE_TYPE: "files",
|
|
@@ -63623,6 +63906,15 @@ function createHub({ tabs, port, access, snapshot, findings, notes, delivery, hi
|
|
|
63623
63906
|
const boards = /* @__PURE__ */ new Map();
|
|
63624
63907
|
const inboxes = /* @__PURE__ */ new Map();
|
|
63625
63908
|
const tabIds = /* @__PURE__ */ new Map();
|
|
63909
|
+
const patching = /* @__PURE__ */ new Set();
|
|
63910
|
+
const joined = /* @__PURE__ */ new Set();
|
|
63911
|
+
const deliver = (socket, board) => {
|
|
63912
|
+
send(socket, {
|
|
63913
|
+
type: "board",
|
|
63914
|
+
data: board
|
|
63915
|
+
});
|
|
63916
|
+
if (patching.has(socket)) joined.add(socket);
|
|
63917
|
+
};
|
|
63626
63918
|
server.on("connection", (socket, request) => {
|
|
63627
63919
|
socket.on("message", (data) => {
|
|
63628
63920
|
const message = parse(String(data));
|
|
@@ -63631,7 +63923,11 @@ function createHub({ tabs, port, access, snapshot, findings, notes, delivery, hi
|
|
|
63631
63923
|
if (message?.type === "ack") delivery?.ack(inbox, message.id).catch(() => {});
|
|
63632
63924
|
return;
|
|
63633
63925
|
}
|
|
63634
|
-
if (boards.has(socket)
|
|
63926
|
+
if (boards.has(socket)) {
|
|
63927
|
+
if (message?.type === "resync" && joined.delete(socket)) snapshot((board) => deliver(socket, board)).catch(() => {});
|
|
63928
|
+
return;
|
|
63929
|
+
}
|
|
63930
|
+
if (message?.type !== "hello") return;
|
|
63635
63931
|
if (message.role === "inbox") {
|
|
63636
63932
|
if (!isWriter({ authorization: request.headers.authorization }, access) || !delivery || !message.session) {
|
|
63637
63933
|
socket.close(1008, "An inbox needs the address token as a bearer.");
|
|
@@ -63652,16 +63948,13 @@ function createHub({ tabs, port, access, snapshot, findings, notes, delivery, hi
|
|
|
63652
63948
|
}, access);
|
|
63653
63949
|
boards.set(socket, writer);
|
|
63654
63950
|
if (typeof message.tab === "string") tabIds.set(socket, message.tab);
|
|
63951
|
+
if (message.patches === true) patching.add(socket);
|
|
63655
63952
|
tabs.open(writer);
|
|
63656
63953
|
if (framePort) send(socket, {
|
|
63657
63954
|
type: "frames",
|
|
63658
63955
|
port: framePort()
|
|
63659
63956
|
});
|
|
63660
|
-
snapshot().then(async (
|
|
63661
|
-
send(socket, {
|
|
63662
|
-
type: "board",
|
|
63663
|
-
data: board
|
|
63664
|
-
});
|
|
63957
|
+
snapshot((board) => deliver(socket, board)).then(async () => {
|
|
63665
63958
|
send(socket, {
|
|
63666
63959
|
type: "access",
|
|
63667
63960
|
write: writer,
|
|
@@ -63704,6 +63997,8 @@ function createHub({ tabs, port, access, snapshot, findings, notes, delivery, hi
|
|
|
63704
63997
|
const writer = boards.get(socket);
|
|
63705
63998
|
if (writer !== void 0) {
|
|
63706
63999
|
boards.delete(socket);
|
|
64000
|
+
patching.delete(socket);
|
|
64001
|
+
joined.delete(socket);
|
|
63707
64002
|
tabs.close(writer);
|
|
63708
64003
|
}
|
|
63709
64004
|
const tab = tabIds.get(socket);
|
|
@@ -63724,6 +64019,19 @@ function createHub({ tabs, port, access, snapshot, findings, notes, delivery, hi
|
|
|
63724
64019
|
broadcast: (message) => {
|
|
63725
64020
|
for (const socket of boards.keys()) send(socket, message);
|
|
63726
64021
|
},
|
|
64022
|
+
broadcastBoard: (board, patch) => {
|
|
64023
|
+
for (const socket of boards.keys()) if (joined.has(socket)) send(socket, {
|
|
64024
|
+
type: "patch",
|
|
64025
|
+
data: patch
|
|
64026
|
+
});
|
|
64027
|
+
else deliver(socket, board);
|
|
64028
|
+
},
|
|
64029
|
+
broadcastPatch: (patch) => {
|
|
64030
|
+
for (const socket of joined) send(socket, {
|
|
64031
|
+
type: "patch",
|
|
64032
|
+
data: patch
|
|
64033
|
+
});
|
|
64034
|
+
},
|
|
63727
64035
|
close: () => {
|
|
63728
64036
|
for (const socket of server.clients) socket.terminate();
|
|
63729
64037
|
return new Promise((resolve) => server.close(() => resolve()));
|
|
@@ -64806,11 +65114,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
64806
65114
|
}];
|
|
64807
65115
|
}
|
|
64808
65116
|
const from = side === "after" ? "before" : "after";
|
|
64809
|
-
|
|
64810
|
-
type: "renamed",
|
|
64811
|
-
before: step.renamed[from],
|
|
64812
|
-
after: step.renamed[side]
|
|
64813
|
-
});
|
|
65117
|
+
feed.rename(step.renamed[from], step.renamed[side]);
|
|
64814
65118
|
}
|
|
64815
65119
|
inTurn(() => tracker.own(step));
|
|
64816
65120
|
});
|
|
@@ -64826,9 +65130,10 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
64826
65130
|
port: boundPort,
|
|
64827
65131
|
framePort: () => frameOrigin.port,
|
|
64828
65132
|
access,
|
|
64829
|
-
snapshot: () => inTurn(async () => {
|
|
64830
|
-
|
|
64831
|
-
|
|
65133
|
+
snapshot: (deliver) => inTurn(async () => {
|
|
65134
|
+
const board = await scanBoard(root);
|
|
65135
|
+
shown.board = board;
|
|
65136
|
+
feed.join(board, deliver);
|
|
64832
65137
|
}),
|
|
64833
65138
|
findings: () => inTurn(async () => findings.all()),
|
|
64834
65139
|
notes: () => inTurn(() => boardView(root)),
|
|
@@ -64840,6 +65145,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
64840
65145
|
dispatch: dispatcher !== void 0,
|
|
64841
65146
|
editButton
|
|
64842
65147
|
});
|
|
65148
|
+
const feed = createBoardFeed(hub);
|
|
64843
65149
|
const claims = createClaimsPush(root, {
|
|
64844
65150
|
broadcast: (list) => hub.broadcast({
|
|
64845
65151
|
type: "claims",
|
|
@@ -65049,10 +65355,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
65049
65355
|
latest = await scanBoard(root);
|
|
65050
65356
|
scanned.unmeasured = placedRefs(scanned.board ?? board, latest, void 0, scanned.unmeasured);
|
|
65051
65357
|
scanned.board = latest;
|
|
65052
|
-
|
|
65053
|
-
type: "board",
|
|
65054
|
-
data: latest
|
|
65055
|
-
});
|
|
65358
|
+
feed.push(latest);
|
|
65056
65359
|
shown.board = latest;
|
|
65057
65360
|
const changed = await recheck(latest, stale);
|
|
65058
65361
|
if (Object.keys(changed).length > 0) hub.broadcast({
|
|
@@ -65073,6 +65376,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
65073
65376
|
if (rest.length === 0) return;
|
|
65074
65377
|
inTurn(() => pushBatch(root, tokens ?? null, rest, {
|
|
65075
65378
|
hub,
|
|
65379
|
+
feed,
|
|
65076
65380
|
recheck,
|
|
65077
65381
|
rendered,
|
|
65078
65382
|
delivery,
|
|
@@ -65135,7 +65439,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
65135
65439
|
* One rescan per batch, pushing the board, then reloads, then findings, then
|
|
65136
65440
|
* notes, an agent's changes waiting out the grace before the board hears.
|
|
65137
65441
|
*/
|
|
65138
|
-
async function pushBatch(root, tokens, paths, { hub, recheck, rendered, delivery, tracker, claims, thumbnails, hug, settleLater, moved, shown, scanned }) {
|
|
65442
|
+
async function pushBatch(root, tokens, paths, { hub, feed, recheck, rendered, delivery, tracker, claims, thumbnails, hug, settleLater, moved, shown, scanned }) {
|
|
65139
65443
|
let board;
|
|
65140
65444
|
let own;
|
|
65141
65445
|
let placed;
|
|
@@ -65165,10 +65469,7 @@ async function pushBatch(root, tokens, paths, { hub, recheck, rendered, delivery
|
|
|
65165
65469
|
} catch {
|
|
65166
65470
|
return;
|
|
65167
65471
|
}
|
|
65168
|
-
|
|
65169
|
-
type: "board",
|
|
65170
|
-
data: board
|
|
65171
|
-
});
|
|
65472
|
+
feed.push(board);
|
|
65172
65473
|
const last = shown.board;
|
|
65173
65474
|
shown.board = board;
|
|
65174
65475
|
const refs = [.../* @__PURE__ */ new Set([...reloadRefs(root, paths, board, tokens), ...rekitted])];
|
|
@@ -65193,7 +65494,7 @@ async function pushBatch(root, tokens, paths, { hub, recheck, rendered, delivery
|
|
|
65193
65494
|
}
|
|
65194
65495
|
const held = await tracker.update(board, paths, await claims.read());
|
|
65195
65496
|
if (held.length > 0) settleLater(held);
|
|
65196
|
-
const due = recheckRefs(root, paths, board, tokens);
|
|
65497
|
+
const due = [.../* @__PURE__ */ new Set([...recheckRefs(root, paths, board, tokens), ...rekitted])];
|
|
65197
65498
|
const changed = await recheck(board, due);
|
|
65198
65499
|
if (Object.keys(changed).length > 0) hub.broadcast({
|
|
65199
65500
|
type: "findings",
|