frameboard 0.36.0 → 0.38.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/README.md +2 -2
- package/dist/cli.js +1246 -817
- package/dist/client/assets/index-CR_GX4fJ.css +2 -0
- package/dist/client/assets/index-DRPBBMyu.js +179 -0
- package/dist/client/index.html +2 -2
- package/dist/hook.js +18611 -18531
- package/package.json +4 -4
- package/dist/client/assets/index-C9FWP23N.css +0 -2
- package/dist/client/assets/index-DiLmy0gj.js +0 -179
package/dist/cli.js
CHANGED
|
@@ -3,18 +3,18 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import childProcess, { execFile, spawn } from "node:child_process";
|
|
4
4
|
import { EventEmitter, once } from "node:events";
|
|
5
5
|
import * as sp from "node:path";
|
|
6
|
-
import path, { basename, delimiter, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
7
|
-
import fs, { copyFileSync, createReadStream, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
|
|
6
|
+
import path, { basename, delimiter, dirname, extname, isAbsolute, join, relative, resolve as resolve$1, sep } from "node:path";
|
|
7
|
+
import fs$1, { copyFileSync, createReadStream, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, watch as watch$1, writeFileSync } from "node:fs";
|
|
8
8
|
import process$1, { versions } from "node:process";
|
|
9
9
|
import { isDeepStrictEqual, promisify, stripVTControlCharacters } from "node:util";
|
|
10
|
-
import { constants, copyFile, cp, link, lstat, mkdir, mkdtemp, open, readFile, readdir, readlink, realpath, rename, rm, rmdir, stat, utimes, writeFile } from "node:fs/promises";
|
|
10
|
+
import { constants, copyFile, cp, link, lstat, mkdir, mkdtemp, open as open$1, readFile, readdir, readlink, realpath, rename, rm, rmdir, stat, utimes, writeFile } from "node:fs/promises";
|
|
11
11
|
import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
12
12
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
13
13
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
14
14
|
import { STATUS_CODES, ServerResponse, createServer } from "node:http";
|
|
15
15
|
import { Http2ServerRequest, constants as constants$1 } from "node:http2";
|
|
16
16
|
import { Readable } from "node:stream";
|
|
17
|
-
import { homedir, networkInterfaces, release, tmpdir, type } from "node:os";
|
|
17
|
+
import { homedir, networkInterfaces, release as release$2, tmpdir, type } from "node:os";
|
|
18
18
|
// \0rolldown/runtime.js
|
|
19
19
|
var __create = Object.create;
|
|
20
20
|
var __defProp = Object.defineProperty;
|
|
@@ -1917,7 +1917,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1917
1917
|
* @param {string} subcommandName
|
|
1918
1918
|
*/
|
|
1919
1919
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
1920
|
-
if (fs.existsSync(executableFile)) return;
|
|
1920
|
+
if (fs$1.existsSync(executableFile)) return;
|
|
1921
1921
|
const executableMissing = `'${executableFile}' does not exist
|
|
1922
1922
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
1923
1923
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
@@ -1940,9 +1940,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1940
1940
|
];
|
|
1941
1941
|
function findFile(baseDir, baseName) {
|
|
1942
1942
|
const localBin = path.resolve(baseDir, baseName);
|
|
1943
|
-
if (fs.existsSync(localBin)) return localBin;
|
|
1943
|
+
if (fs$1.existsSync(localBin)) return localBin;
|
|
1944
1944
|
if (sourceExt.includes(path.extname(baseName))) return void 0;
|
|
1945
|
-
const foundExt = sourceExt.find((ext) => fs.existsSync(`${localBin}${ext}`));
|
|
1945
|
+
const foundExt = sourceExt.find((ext) => fs$1.existsSync(`${localBin}${ext}`));
|
|
1946
1946
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
1947
1947
|
}
|
|
1948
1948
|
this._checkForMissingMandatoryOptions();
|
|
@@ -1952,7 +1952,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1952
1952
|
if (this._scriptPath) {
|
|
1953
1953
|
let resolvedScriptPath;
|
|
1954
1954
|
try {
|
|
1955
|
-
resolvedScriptPath = fs.realpathSync(this._scriptPath);
|
|
1955
|
+
resolvedScriptPath = fs$1.realpathSync(this._scriptPath);
|
|
1956
1956
|
} catch {
|
|
1957
1957
|
resolvedScriptPath = this._scriptPath;
|
|
1958
1958
|
}
|
|
@@ -3165,7 +3165,7 @@ async function withLocks(paths, run, options = {}) {
|
|
|
3165
3165
|
}
|
|
3166
3166
|
return await run();
|
|
3167
3167
|
} finally {
|
|
3168
|
-
await Promise.all(held.map(({ lock, nonce }) => release$
|
|
3168
|
+
await Promise.all(held.map(({ lock, nonce }) => release$1(lock, nonce)));
|
|
3169
3169
|
}
|
|
3170
3170
|
}
|
|
3171
3171
|
/** Takes the lock and returns the nonce written into it, which release checks. */
|
|
@@ -3174,7 +3174,7 @@ async function acquire(lock, timeoutMs) {
|
|
|
3174
3174
|
const nonce = randomBytes(8).toString("hex");
|
|
3175
3175
|
for (;;) {
|
|
3176
3176
|
try {
|
|
3177
|
-
const handle = await open(lock, "wx");
|
|
3177
|
+
const handle = await open$1(lock, "wx");
|
|
3178
3178
|
await handle.writeFile(JSON.stringify({
|
|
3179
3179
|
pid: process.pid,
|
|
3180
3180
|
nonce
|
|
@@ -3219,7 +3219,7 @@ async function breakLock(lock, judged) {
|
|
|
3219
3219
|
const guard = `${lock.slice(0, -5)}.break${LOCK_SUFFIX}`;
|
|
3220
3220
|
const nonce = randomBytes(8).toString("hex");
|
|
3221
3221
|
try {
|
|
3222
|
-
const handle = await open(guard, "wx");
|
|
3222
|
+
const handle = await open$1(guard, "wx");
|
|
3223
3223
|
await handle.writeFile(nonce);
|
|
3224
3224
|
await handle.close();
|
|
3225
3225
|
} catch (error) {
|
|
@@ -3275,7 +3275,7 @@ async function readOrNull$1(path) {
|
|
|
3275
3275
|
}
|
|
3276
3276
|
}
|
|
3277
3277
|
/** Removes the lock only while it still holds this writer's nonce. */
|
|
3278
|
-
async function release$
|
|
3278
|
+
async function release$1(lock, nonce) {
|
|
3279
3279
|
try {
|
|
3280
3280
|
if ((await readFile(lock, "utf8")).includes(`"nonce":"${nonce}"`)) await rm(lock, { force: true });
|
|
3281
3281
|
} catch (error) {
|
|
@@ -6269,7 +6269,7 @@ function bucketFor(state, inst) {
|
|
|
6269
6269
|
return bucket;
|
|
6270
6270
|
}
|
|
6271
6271
|
let handoff;
|
|
6272
|
-
const open
|
|
6272
|
+
const open = [];
|
|
6273
6273
|
const memo = {
|
|
6274
6274
|
alloc(_inst, payload, empty) {
|
|
6275
6275
|
const bucket = handoff;
|
|
@@ -6280,7 +6280,7 @@ const memo = {
|
|
|
6280
6280
|
issues: null
|
|
6281
6281
|
};
|
|
6282
6282
|
bucket.set(payload.value, entry);
|
|
6283
|
-
open
|
|
6283
|
+
open.push(entry);
|
|
6284
6284
|
return empty;
|
|
6285
6285
|
},
|
|
6286
6286
|
guard(inst) {
|
|
@@ -6346,10 +6346,10 @@ const memo = {
|
|
|
6346
6346
|
return payload;
|
|
6347
6347
|
}
|
|
6348
6348
|
handoff = bucket;
|
|
6349
|
-
const depth = open
|
|
6349
|
+
const depth = open.length;
|
|
6350
6350
|
const result = base(payload, ctx);
|
|
6351
6351
|
handoff = void 0;
|
|
6352
|
-
const entry = open
|
|
6352
|
+
const entry = open.length > depth ? open.pop() : void 0;
|
|
6353
6353
|
if (result instanceof Promise) return result.then((r) => {
|
|
6354
6354
|
if (entry) entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
|
|
6355
6355
|
return r;
|
|
@@ -9084,32 +9084,68 @@ function datetime(params) {
|
|
|
9084
9084
|
return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
|
|
9085
9085
|
}
|
|
9086
9086
|
// src/shared/frame-device.ts
|
|
9087
|
-
/** The devices the board can draw around a frame. */
|
|
9088
|
-
const DEVICES = [
|
|
9087
|
+
/** The devices the board can draw around a frame, the frame's width picking one. */
|
|
9088
|
+
const DEVICES = [
|
|
9089
|
+
"phone",
|
|
9090
|
+
"tablet",
|
|
9091
|
+
"laptop"
|
|
9092
|
+
];
|
|
9093
|
+
/** The laptop lid's chin below the screen, past the border its sides hold. */
|
|
9094
|
+
const LAPTOP_CHIN = 28;
|
|
9095
|
+
/** The laptop's base below the chin, reaching past the lid on each side by its share of the lid's width. */
|
|
9096
|
+
const LAPTOP_BASE = {
|
|
9097
|
+
height: 14,
|
|
9098
|
+
reach: .06,
|
|
9099
|
+
radius: 10
|
|
9100
|
+
};
|
|
9089
9101
|
/**
|
|
9090
9102
|
* The phone's border is a current Pro's body less its display, 71.9 mm
|
|
9091
9103
|
* across holding 1206 pixels at 460 ppi, which is 16 points a side. The
|
|
9092
9104
|
* tablet's is a 13-inch Pro's, 215.5 mm across holding 2064 pixels at 264
|
|
9093
9105
|
* ppi, which is 44. The tablet's screen radius is a guess no source backs.
|
|
9106
|
+
* The laptop's lid, chin, and base are scaled off the picked mock rather
|
|
9107
|
+
* than any maker's, and its screen rounds its top corners alone.
|
|
9094
9108
|
*/
|
|
9095
9109
|
const BEZELS = {
|
|
9096
9110
|
phone: {
|
|
9097
9111
|
border: 16,
|
|
9112
|
+
bottom: 16,
|
|
9098
9113
|
screenRadius: 62,
|
|
9099
9114
|
bodyRadius: 78
|
|
9100
9115
|
},
|
|
9101
9116
|
tablet: {
|
|
9102
9117
|
border: 44,
|
|
9118
|
+
bottom: 44,
|
|
9103
9119
|
screenRadius: 18,
|
|
9104
9120
|
bodyRadius: 62
|
|
9121
|
+
},
|
|
9122
|
+
laptop: {
|
|
9123
|
+
border: 20,
|
|
9124
|
+
bottom: LAPTOP_CHIN + LAPTOP_BASE.height,
|
|
9125
|
+
screenRadius: 10,
|
|
9126
|
+
bodyRadius: 30
|
|
9105
9127
|
}
|
|
9106
9128
|
};
|
|
9107
9129
|
/**
|
|
9130
|
+
* The narrowest width each device draws around, widest first, so a frame
|
|
9131
|
+
* takes the first one it reaches. Under the phone's width no device fits.
|
|
9132
|
+
*/
|
|
9133
|
+
const DEVICE_WIDTHS = [
|
|
9134
|
+
["laptop", 1024],
|
|
9135
|
+
["tablet", 480],
|
|
9136
|
+
["phone", 320]
|
|
9137
|
+
];
|
|
9138
|
+
/** The device a frame this wide draws inside, null under 320 where none fits. */
|
|
9139
|
+
function deviceForWidth(width) {
|
|
9140
|
+
return DEVICE_WIDTHS.find(([, least]) => width >= least)?.[0] ?? null;
|
|
9141
|
+
}
|
|
9142
|
+
/**
|
|
9108
9143
|
* The body's colors, fixed in both themes, since the board draws hardware
|
|
9109
9144
|
* rather than chrome: the body, the hairline around it, and the island.
|
|
9110
9145
|
*/
|
|
9111
9146
|
const BEZEL_COLORS = {
|
|
9112
9147
|
body: "#17181b",
|
|
9148
|
+
base: "#2c2e33",
|
|
9113
9149
|
edge: "#45484f",
|
|
9114
9150
|
island: "#050506",
|
|
9115
9151
|
homeBar: "rgba(128, 128, 128, 0.6)"
|
|
@@ -9129,6 +9165,33 @@ const HOME_BAR = {
|
|
|
9129
9165
|
bottom: 8
|
|
9130
9166
|
};
|
|
9131
9167
|
/**
|
|
9168
|
+
* The laptop's chin and base, each a box from the frame's top left, which
|
|
9169
|
+
* the board and the PNG draw as positioned boxes, since one spread around
|
|
9170
|
+
* the screen cannot draw a body wider below than above.
|
|
9171
|
+
*/
|
|
9172
|
+
function laptopParts({ width, height }) {
|
|
9173
|
+
const { border } = BEZELS.laptop;
|
|
9174
|
+
const lid = width + 2 * border;
|
|
9175
|
+
const reach = baseReach(width);
|
|
9176
|
+
return {
|
|
9177
|
+
chin: {
|
|
9178
|
+
x: -border,
|
|
9179
|
+
y: height,
|
|
9180
|
+
width: lid,
|
|
9181
|
+
height: LAPTOP_CHIN
|
|
9182
|
+
},
|
|
9183
|
+
base: {
|
|
9184
|
+
x: -border - reach,
|
|
9185
|
+
y: height + LAPTOP_CHIN,
|
|
9186
|
+
width: lid + 2 * reach,
|
|
9187
|
+
height: LAPTOP_BASE.height
|
|
9188
|
+
}
|
|
9189
|
+
};
|
|
9190
|
+
}
|
|
9191
|
+
function baseReach(width) {
|
|
9192
|
+
return Math.round((width + 2 * BEZELS.laptop.border) * LAPTOP_BASE.reach);
|
|
9193
|
+
}
|
|
9194
|
+
/**
|
|
9132
9195
|
* The CSS `box-shadow` drawing a device's body: a spread the border wide
|
|
9133
9196
|
* around a box rounded to the screen radius, which also covers the frame's
|
|
9134
9197
|
* corners past that radius, so the body's outer radius is the screen's plus
|
|
@@ -9147,21 +9210,19 @@ function bezelShadow(device, { board = true } = {}) {
|
|
|
9147
9210
|
].join(", ");
|
|
9148
9211
|
}
|
|
9149
9212
|
/**
|
|
9150
|
-
*
|
|
9151
|
-
*
|
|
9213
|
+
* The box a device's body covers around a frame's box, the box itself with
|
|
9214
|
+
* none. A laptop's base reaches past its lid, so its sides grow by more
|
|
9215
|
+
* than its top.
|
|
9152
9216
|
*/
|
|
9153
|
-
function deviceOf(value) {
|
|
9154
|
-
return DEVICES.find((device) => device === value) ?? null;
|
|
9155
|
-
}
|
|
9156
|
-
/** The box a device's body covers around a frame's box, the box itself with none. */
|
|
9157
9217
|
function bezelBox(box, device) {
|
|
9158
9218
|
if (!device) return { ...box };
|
|
9159
|
-
const { border } = BEZELS[device];
|
|
9219
|
+
const { border, bottom } = BEZELS[device];
|
|
9220
|
+
const side = device === "laptop" ? border + baseReach(box.width) : border;
|
|
9160
9221
|
return {
|
|
9161
|
-
x: box.x -
|
|
9222
|
+
x: box.x - side,
|
|
9162
9223
|
y: box.y - border,
|
|
9163
|
-
width: box.width + 2 *
|
|
9164
|
-
height: box.height +
|
|
9224
|
+
width: box.width + 2 * side,
|
|
9225
|
+
height: box.height + border + bottom
|
|
9165
9226
|
};
|
|
9166
9227
|
}
|
|
9167
9228
|
// src/shared/frame-sizes.ts
|
|
@@ -9374,10 +9435,14 @@ function isSize(value) {
|
|
|
9374
9435
|
/**
|
|
9375
9436
|
* Where each linked width draws: in a row at the frame's `y`, the first
|
|
9376
9437
|
* `FRAME_GAP` past the frame's right edge and each next one past the last.
|
|
9438
|
+
* A laptop's base reaches past its lid below the screen, where a linked width
|
|
9439
|
+
* taller than the frame would meet it, so the row moves out by that reach.
|
|
9377
9440
|
*/
|
|
9378
|
-
function linkedBoxes(box, widths) {
|
|
9441
|
+
function linkedBoxes(box, widths, device) {
|
|
9379
9442
|
const boxes = [];
|
|
9380
|
-
|
|
9443
|
+
const body = bezelBox(box, device);
|
|
9444
|
+
const lid = device ? BEZELS[device].border : 0;
|
|
9445
|
+
let x = body.x + body.width - lid;
|
|
9381
9446
|
for (const { width, height } of widths) {
|
|
9382
9447
|
x += 80;
|
|
9383
9448
|
boxes.push({
|
|
@@ -9395,7 +9460,7 @@ function linkedBoxes(box, widths) {
|
|
|
9395
9460
|
* width it draws, the frame's own with neither. Linked widths draw no device.
|
|
9396
9461
|
*/
|
|
9397
9462
|
function drawnExtent(box, widths, device) {
|
|
9398
|
-
const boxes = [bezelBox(box, device), ...linkedBoxes(box, widths)];
|
|
9463
|
+
const boxes = [bezelBox(box, device), ...linkedBoxes(box, widths, device)];
|
|
9399
9464
|
const left = Math.min(...boxes.map(({ x }) => x));
|
|
9400
9465
|
const top = Math.min(...boxes.map(({ y }) => y));
|
|
9401
9466
|
const right = Math.max(...boxes.map(({ x, width }) => x + width));
|
|
@@ -9565,7 +9630,8 @@ const projectFileSchema = looseObject({
|
|
|
9565
9630
|
createdAt: union([datetime(), unknown()]).optional(),
|
|
9566
9631
|
checks: union([projectChecksSchema, unknown()]).optional(),
|
|
9567
9632
|
group: union([string$1(), unknown()]).optional(),
|
|
9568
|
-
archived: union([boolean$1(), unknown()]).optional()
|
|
9633
|
+
archived: union([boolean$1(), unknown()]).optional(),
|
|
9634
|
+
title: union([string$1(), unknown()]).optional()
|
|
9569
9635
|
});
|
|
9570
9636
|
const layoutEntrySchema = looseObject({
|
|
9571
9637
|
x: int$1(),
|
|
@@ -9582,6 +9648,7 @@ const layoutEntrySchema = looseObject({
|
|
|
9582
9648
|
width: int$1().min(1),
|
|
9583
9649
|
height: int$1().min(1)
|
|
9584
9650
|
})), unknown()]).optional(),
|
|
9651
|
+
showDevice: unknown().optional(),
|
|
9585
9652
|
device: unknown().optional(),
|
|
9586
9653
|
transition: unknown().optional()
|
|
9587
9654
|
});
|
|
@@ -12677,7 +12744,7 @@ var require_source_map_consumer = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
12677
12744
|
continue;
|
|
12678
12745
|
}
|
|
12679
12746
|
}
|
|
12680
|
-
mapping.lastGeneratedColumn =
|
|
12747
|
+
mapping.lastGeneratedColumn = 1e400;
|
|
12681
12748
|
}
|
|
12682
12749
|
};
|
|
12683
12750
|
/**
|
|
@@ -23915,7 +23982,7 @@ function localTarget(url, base) {
|
|
|
23915
23982
|
try {
|
|
23916
23983
|
decoded = decodeURIComponent(bare);
|
|
23917
23984
|
} catch {}
|
|
23918
|
-
return resolve(base, decoded);
|
|
23985
|
+
return resolve$1(base, decoded);
|
|
23919
23986
|
}
|
|
23920
23987
|
/** A scheme such as `https:` or `data:`, or a protocol-relative `//`. */
|
|
23921
23988
|
function hasScheme(url) {
|
|
@@ -23975,6 +24042,38 @@ function attributeLocation(element, name) {
|
|
|
23975
24042
|
function sheetBase(sheet) {
|
|
23976
24043
|
return dirname(sheet.path);
|
|
23977
24044
|
}
|
|
24045
|
+
/**
|
|
24046
|
+
* A script's inline text, or its `src` file's when the file sits in the
|
|
24047
|
+
* board. A remote, outside, or unreadable `src` reads as null, since the
|
|
24048
|
+
* write hook never reports a read as failed.
|
|
24049
|
+
*/
|
|
24050
|
+
function scriptSource(element, source) {
|
|
24051
|
+
const src = element.attribs.src;
|
|
24052
|
+
if (src === void 0) return {
|
|
24053
|
+
text: textOf$1(element),
|
|
24054
|
+
path: source.path,
|
|
24055
|
+
offset: element.children[0]?.startIndex ?? 0
|
|
24056
|
+
};
|
|
24057
|
+
const file = localTarget(src, source.pageDir);
|
|
24058
|
+
if (!file || !isInside(source.root, file)) return null;
|
|
24059
|
+
try {
|
|
24060
|
+
return {
|
|
24061
|
+
text: readFileSync(file, "utf8"),
|
|
24062
|
+
path: file,
|
|
24063
|
+
offset: 0
|
|
24064
|
+
};
|
|
24065
|
+
} catch {
|
|
24066
|
+
return null;
|
|
24067
|
+
}
|
|
24068
|
+
}
|
|
24069
|
+
/** A script's code as `scriptSource` reads it, empty where that reads none. */
|
|
24070
|
+
function scriptText(element, source) {
|
|
24071
|
+
return scriptSource(element, source)?.text ?? "";
|
|
24072
|
+
}
|
|
24073
|
+
/** An element's own text, joined from its text children. */
|
|
24074
|
+
function textOf$1(element) {
|
|
24075
|
+
return element.children.map((node) => "data" in node ? node.data : "").join("");
|
|
24076
|
+
}
|
|
23978
24077
|
// src/server/checks/rule.ts
|
|
23979
24078
|
/**
|
|
23980
24079
|
* Builds findings for the rules `docs` declares, each at the level its doc
|
|
@@ -24019,7 +24118,7 @@ const TRANSITION_FILE_RULES = [{
|
|
|
24019
24118
|
severity: "error",
|
|
24020
24119
|
description: `A stylesheet under ${ASSETS_FOLDER}/${TRANSITIONS_FOLDER}/ is named in lowercase kebab case and holds @keyframes enter, optionally @keyframes leave, and nothing else, with no url(), quoted string, or escape. The board refuses a file breaking it whole, whether or not the rule is on`
|
|
24021
24120
|
}];
|
|
24022
|
-
const finding$
|
|
24121
|
+
const finding$13 = findingFor(TRANSITION_FILE_RULES);
|
|
24023
24122
|
/** A keyframe step: `from`, `to`, or a percentage, alone or in a comma list. */
|
|
24024
24123
|
const STEP = /^(?:from|to|\d+(?:\.\d+)?%)(?:\s*,\s*(?:from|to|\d+(?:\.\d+)?%))*$/i;
|
|
24025
24124
|
/**
|
|
@@ -24164,7 +24263,7 @@ function transitionPath(project, name) {
|
|
|
24164
24263
|
function checkTransitionSheet({ project, name }, css) {
|
|
24165
24264
|
const reading = readTransitionSheet(name, css);
|
|
24166
24265
|
if (reading.ok) return [];
|
|
24167
|
-
return reading.problems.map(({ message, location }) => finding$
|
|
24266
|
+
return reading.problems.map(({ message, location }) => finding$13("transition-file", {
|
|
24168
24267
|
frame: null,
|
|
24169
24268
|
path: transitionPath(project, name),
|
|
24170
24269
|
message,
|
|
@@ -24269,7 +24368,7 @@ async function listFrames(pageDir) {
|
|
|
24269
24368
|
/**
|
|
24270
24369
|
* The page order a reader shows: listed pages that exist in that order, then
|
|
24271
24370
|
* unlisted ones by name. A file that fails to read orders every page by name.
|
|
24272
|
-
* The creation time, folder, archive flag, and turned-off rules come from the
|
|
24371
|
+
* The creation time, title, folder, archive flag, and turned-off rules come from the
|
|
24273
24372
|
* same read, each read as absent when the file holds none or holds one of
|
|
24274
24373
|
* another type.
|
|
24275
24374
|
*/
|
|
@@ -24287,6 +24386,7 @@ async function readPageOrder(projectDir) {
|
|
|
24287
24386
|
return {
|
|
24288
24387
|
pages: folders,
|
|
24289
24388
|
createdAt: null,
|
|
24389
|
+
title: null,
|
|
24290
24390
|
group: null,
|
|
24291
24391
|
archived: false,
|
|
24292
24392
|
checksOff: [],
|
|
@@ -24299,6 +24399,7 @@ async function readPageOrder(projectDir) {
|
|
|
24299
24399
|
return {
|
|
24300
24400
|
pages: orderPages(file.pages, folders),
|
|
24301
24401
|
createdAt: isTime(file.createdAt) ? file.createdAt : null,
|
|
24402
|
+
title: titleOf(file.title),
|
|
24302
24403
|
group: groupOf$1(file.group),
|
|
24303
24404
|
archived: file.archived === true,
|
|
24304
24405
|
checksOff: checksOffOf(file.checks),
|
|
@@ -24317,6 +24418,13 @@ function checksOffOf(checks) {
|
|
|
24317
24418
|
}
|
|
24318
24419
|
/** A folder name as home shows it, trimmed, null for a blank or a non-string. */
|
|
24319
24420
|
function groupOf$1(value) {
|
|
24421
|
+
return trimmedOf(value);
|
|
24422
|
+
}
|
|
24423
|
+
/** A project's title as readers show it, trimmed, null for a blank or a non-string. */
|
|
24424
|
+
function titleOf(value) {
|
|
24425
|
+
return trimmedOf(value);
|
|
24426
|
+
}
|
|
24427
|
+
function trimmedOf(value) {
|
|
24320
24428
|
if (typeof value !== "string") return null;
|
|
24321
24429
|
const trimmed = value.trim();
|
|
24322
24430
|
return trimmed === "" ? null : trimmed;
|
|
@@ -24352,15 +24460,17 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
|
|
|
24352
24460
|
continue;
|
|
24353
24461
|
}
|
|
24354
24462
|
const scroll = entry.scroll ?? false;
|
|
24355
|
-
const
|
|
24463
|
+
const box = {
|
|
24464
|
+
x: entry.x,
|
|
24465
|
+
y: entry.y,
|
|
24466
|
+
width: entry.width,
|
|
24467
|
+
height: entry.height
|
|
24468
|
+
};
|
|
24469
|
+
const shown = showsDevice(entry);
|
|
24470
|
+
const device = shown ? deviceForWidth(box.width) : null;
|
|
24356
24471
|
const transition = readTransition(entry.transition);
|
|
24357
24472
|
placements.set(name, {
|
|
24358
|
-
box
|
|
24359
|
-
x: entry.x,
|
|
24360
|
-
y: entry.y,
|
|
24361
|
-
width: entry.width,
|
|
24362
|
-
height: entry.height
|
|
24363
|
-
},
|
|
24473
|
+
box,
|
|
24364
24474
|
order: entry.order,
|
|
24365
24475
|
hidden: entry.hidden ?? false,
|
|
24366
24476
|
locked: entry.locked ?? false,
|
|
@@ -24368,6 +24478,7 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
|
|
|
24368
24478
|
hugHeight: !scroll && (entry.hugHeight ?? false),
|
|
24369
24479
|
scroll,
|
|
24370
24480
|
widths: widthsOf(entry.widths),
|
|
24481
|
+
...shown ? { showDevice: true } : {},
|
|
24371
24482
|
...device ? { device } : {},
|
|
24372
24483
|
...transition ? { transition } : {},
|
|
24373
24484
|
placed: true
|
|
@@ -24381,6 +24492,10 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
|
|
|
24381
24492
|
}
|
|
24382
24493
|
return placements;
|
|
24383
24494
|
}
|
|
24495
|
+
/** Whether an entry shows its device, through its own key or the device name written before it. */
|
|
24496
|
+
function showsDevice(entry) {
|
|
24497
|
+
return entry?.showDevice === true || typeof entry?.device === "string";
|
|
24498
|
+
}
|
|
24384
24499
|
/**
|
|
24385
24500
|
* Where a frame with no layout entry sits: desktop size at `y` 0, 80 past the
|
|
24386
24501
|
* right edge of every frame already placed and the linked widths it draws, on top of all of them. The board
|
|
@@ -24422,7 +24537,7 @@ async function scanBoard(root, { project } = {}) {
|
|
|
24422
24537
|
}
|
|
24423
24538
|
async function scanProject(root, name) {
|
|
24424
24539
|
const path = join(root, name);
|
|
24425
|
-
const { pages: order, createdAt, group, archived, checksOff, error } = await readPageOrder(path);
|
|
24540
|
+
const { pages: order, createdAt, title, group, archived, checksOff, error } = await readPageOrder(path);
|
|
24426
24541
|
const transitions = await listTransitionNames(path);
|
|
24427
24542
|
const pages = await Promise.all(order.map((page, index) => scanPage(root, name, page, index, transitions)));
|
|
24428
24543
|
const times = await Promise.all([
|
|
@@ -24432,6 +24547,7 @@ async function scanProject(root, name) {
|
|
|
24432
24547
|
]);
|
|
24433
24548
|
return {
|
|
24434
24549
|
name,
|
|
24550
|
+
title,
|
|
24435
24551
|
path,
|
|
24436
24552
|
modifiedAt: new Date(Math.max(...times)).toISOString(),
|
|
24437
24553
|
createdAt,
|
|
@@ -24544,7 +24660,7 @@ function byName(a, b) {
|
|
|
24544
24660
|
*/
|
|
24545
24661
|
async function resolveBoard({ root, cwd }) {
|
|
24546
24662
|
if (root !== void 0) {
|
|
24547
|
-
const path = resolve(cwd, root);
|
|
24663
|
+
const path = resolve$1(cwd, root);
|
|
24548
24664
|
if (!await isDirectory(path)) throw new FrameboardError("board-not-found", `No board folder at ${path}.`, { root: path });
|
|
24549
24665
|
return realpath(path);
|
|
24550
24666
|
}
|
|
@@ -24553,7 +24669,7 @@ async function resolveBoard({ root, cwd }) {
|
|
|
24553
24669
|
return realpath(found);
|
|
24554
24670
|
}
|
|
24555
24671
|
function findBoard(cwd) {
|
|
24556
|
-
for (let dir = resolve(cwd);; dir = dirname(dir)) {
|
|
24672
|
+
for (let dir = resolve$1(cwd);; dir = dirname(dir)) {
|
|
24557
24673
|
if (existsSync(join(dir, "board.json"))) return dir;
|
|
24558
24674
|
if (existsSync(join(dir, ".frameboard", "board.json"))) return join(dir, DEFAULT_BOARD_FOLDER);
|
|
24559
24675
|
if (existsSync(join(dir, ".git")) || dirname(dir) === dir) return null;
|
|
@@ -24566,7 +24682,7 @@ function findBoard(cwd) {
|
|
|
24566
24682
|
* alone.
|
|
24567
24683
|
*/
|
|
24568
24684
|
async function startBoard({ root, cwd }, now = /* @__PURE__ */ new Date()) {
|
|
24569
|
-
const target = root === void 0 ? findBoard(cwd) ?? join(cwd, ".frameboard") : resolve(cwd, root);
|
|
24685
|
+
const target = root === void 0 ? findBoard(cwd) ?? join(cwd, ".frameboard") : resolve$1(cwd, root);
|
|
24570
24686
|
await mkdir(target, { recursive: true });
|
|
24571
24687
|
if (!existsSync(join(target, "board.json"))) await writeRecord(join(target, BOARD_FILE), { version: 1 });
|
|
24572
24688
|
let created = false;
|
|
@@ -24594,9 +24710,9 @@ async function isDirectory(path) {
|
|
|
24594
24710
|
}
|
|
24595
24711
|
}
|
|
24596
24712
|
// package.json
|
|
24597
|
-
var version$1 = "0.
|
|
24713
|
+
var version$1 = "0.38.0";
|
|
24598
24714
|
var dependencies = { "playwright-core": "1.65.0" };
|
|
24599
|
-
var peerDependencies = { "oxfmt": "0.
|
|
24715
|
+
var peerDependencies = { "oxfmt": "0.78.0" };
|
|
24600
24716
|
// src/shared/version.ts
|
|
24601
24717
|
const version = version$1;
|
|
24602
24718
|
// src/cli/client-dir.ts
|
|
@@ -24723,6 +24839,32 @@ function nextFreeName(base, taken) {
|
|
|
24723
24839
|
if (!lowered.has(candidate.toLowerCase())) return candidate;
|
|
24724
24840
|
}
|
|
24725
24841
|
}
|
|
24842
|
+
/**
|
|
24843
|
+
* The folder a project in `current` lands in once titled `title`: the name
|
|
24844
|
+
* made from the title, the next free one when another of `taken` holds it,
|
|
24845
|
+
* and `current` itself when the title names no folder or names the one it
|
|
24846
|
+
* is in. A taken name near the length limit is cut back until a free one
|
|
24847
|
+
* fits, its suffix included, so the folder always stays a valid name.
|
|
24848
|
+
*/
|
|
24849
|
+
function titledFolder(current, title, taken) {
|
|
24850
|
+
const folder = folderName(title);
|
|
24851
|
+
if (folder === "" || namesCollide(folder, current)) return current;
|
|
24852
|
+
const others = [...taken].filter((name) => name !== current);
|
|
24853
|
+
for (let cut = folder.length; cut > 0; cut--) {
|
|
24854
|
+
const base = folder.slice(0, cut).replace(/-+$/, "");
|
|
24855
|
+
const free = nextFreeName(base, others);
|
|
24856
|
+
if (base !== "" && free.length <= 64) return free;
|
|
24857
|
+
}
|
|
24858
|
+
return current;
|
|
24859
|
+
}
|
|
24860
|
+
/**
|
|
24861
|
+
* A typed title as the folder it names, lower case with each run of
|
|
24862
|
+
* characters a name may not hold turned into one dash, so `Acme mobile`
|
|
24863
|
+
* becomes `acme-mobile`. Empty when the title holds nothing a name may.
|
|
24864
|
+
*/
|
|
24865
|
+
function folderName(typed) {
|
|
24866
|
+
return typed.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "").slice(0, 64).replace(/-+$/, "");
|
|
24867
|
+
}
|
|
24726
24868
|
// src/shared/records/claims.ts
|
|
24727
24869
|
/**
|
|
24728
24870
|
* Where a reserved frame will land, and which axes take their size from the
|
|
@@ -24906,7 +25048,7 @@ async function releaseReservation(root, frame, now) {
|
|
|
24906
25048
|
* Drops a session's claim on one frame, or every claim it holds when no
|
|
24907
25049
|
* frame is named, returning what it dropped.
|
|
24908
25050
|
*/
|
|
24909
|
-
async function release
|
|
25051
|
+
async function release(root, session, frame, now) {
|
|
24910
25052
|
const dropped = [];
|
|
24911
25053
|
await ensureRunFolder(root);
|
|
24912
25054
|
await updateRecord(claimsPath(root), claimsSpec, (file) => {
|
|
@@ -25031,7 +25173,7 @@ function agreeingProject(ref, fromRef, { project }) {
|
|
|
25031
25173
|
return fromRef ?? project;
|
|
25032
25174
|
}
|
|
25033
25175
|
async function framePathParts(root, ref, cwd) {
|
|
25034
|
-
const path = resolve(cwd, ref);
|
|
25176
|
+
const path = resolve$1(cwd, ref);
|
|
25035
25177
|
let folder = dirname(path);
|
|
25036
25178
|
try {
|
|
25037
25179
|
folder = await realpath(folder);
|
|
@@ -25110,7 +25252,7 @@ async function addFrame(root, ref, options) {
|
|
|
25110
25252
|
...hugs,
|
|
25111
25253
|
scroll,
|
|
25112
25254
|
widths,
|
|
25113
|
-
...options.
|
|
25255
|
+
...options.showDevice ? { showDevice: true } : {}
|
|
25114
25256
|
});
|
|
25115
25257
|
layout.renumber();
|
|
25116
25258
|
}, journal);
|
|
@@ -25553,16 +25695,16 @@ async function setFrameFlag(root, ref, flag, { on, ...options }) {
|
|
|
25553
25695
|
}));
|
|
25554
25696
|
}
|
|
25555
25697
|
/**
|
|
25556
|
-
*
|
|
25557
|
-
* The frame's file and box are left as they stand,
|
|
25558
|
-
* whatever size the frame is.
|
|
25698
|
+
* Shows or hides the device the board draws around a frame, which the
|
|
25699
|
+
* frame's width picks. The frame's file and box are left as they stand,
|
|
25700
|
+
* since the body wraps whatever size the frame is.
|
|
25559
25701
|
*/
|
|
25560
|
-
async function setFrameDevice(root, ref,
|
|
25702
|
+
async function setFrameDevice(root, ref, show, options) {
|
|
25561
25703
|
return updatePlacement(root, ref, options, (placement) => {
|
|
25562
|
-
const {
|
|
25563
|
-
return
|
|
25704
|
+
const { showDevice: _held, device: _device, ...rest } = placement;
|
|
25705
|
+
return show ? {
|
|
25564
25706
|
...rest,
|
|
25565
|
-
|
|
25707
|
+
showDevice: true
|
|
25566
25708
|
} : rest;
|
|
25567
25709
|
});
|
|
25568
25710
|
}
|
|
@@ -25673,17 +25815,14 @@ var PageLayout = class {
|
|
|
25673
25815
|
/**
|
|
25674
25816
|
* Writes the seven fixed keys on the entry it creates or changes, after any
|
|
25675
25817
|
* key the entry already held, so unknown keys survive in place. A hug flag
|
|
25676
|
-
* is written
|
|
25677
|
-
*
|
|
25678
|
-
*
|
|
25679
|
-
*
|
|
25680
|
-
*
|
|
25681
|
-
*
|
|
25682
|
-
|
|
25683
|
-
|
|
25684
|
-
* the same way as `device`.
|
|
25685
|
-
*/
|
|
25686
|
-
set(name, { box, order, hidden, locked, scroll, widths, device, transition, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
|
|
25818
|
+
* is written once it is on or when the entry holds it, so an entry from
|
|
25819
|
+
* before the flags gains no key, and a scroll entry writes both hug flags
|
|
25820
|
+
* false, since it fixes both axes. `scroll` follows the same rule. `widths`,
|
|
25821
|
+
* `showDevice`, and `transition` are written while the frame holds one and
|
|
25822
|
+
* removed once cleared, leaving a held value no reader understands as is.
|
|
25823
|
+
* A `device` name from before `showDevice` is replaced by it on any write.
|
|
25824
|
+
*/
|
|
25825
|
+
set(name, { box, order, hidden, locked, scroll, widths, showDevice, transition, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
|
|
25687
25826
|
const hugWidth = hugsWidth && !scroll;
|
|
25688
25827
|
const hugHeight = hugsHeight && !scroll;
|
|
25689
25828
|
const held = this.file.frames[name];
|
|
@@ -25703,11 +25842,12 @@ var PageLayout = class {
|
|
|
25703
25842
|
width,
|
|
25704
25843
|
height
|
|
25705
25844
|
})) } : {},
|
|
25706
|
-
...
|
|
25845
|
+
...showDevice ? { showDevice } : {},
|
|
25707
25846
|
...transition ? { transition: { ...transition } } : {}
|
|
25708
25847
|
};
|
|
25709
25848
|
if (widths.length === 0 && widthsOf(held?.widths).length > 0) delete entry.widths;
|
|
25710
|
-
if (!
|
|
25849
|
+
if (!showDevice && held?.showDevice === true) delete entry.showDevice;
|
|
25850
|
+
if (typeof held?.device === "string") delete entry.device;
|
|
25711
25851
|
if (!transition && storedTransitionOf(held?.transition)) delete entry.transition;
|
|
25712
25852
|
this.file.frames[name] = entry;
|
|
25713
25853
|
this.changed = true;
|
|
@@ -26377,6 +26517,7 @@ Object.defineProperty(requestPrototype, "signal", { get() {
|
|
|
26377
26517
|
"cache",
|
|
26378
26518
|
"credentials",
|
|
26379
26519
|
"destination",
|
|
26520
|
+
"duplex",
|
|
26380
26521
|
"integrity",
|
|
26381
26522
|
"mode",
|
|
26382
26523
|
"redirect",
|
|
@@ -26596,6 +26737,11 @@ function writeFromReadableStreamDefaultReader(reader, writable, currentReadPromi
|
|
|
26596
26737
|
const cancel = (error) => {
|
|
26597
26738
|
reader.cancel(error).catch(() => {});
|
|
26598
26739
|
};
|
|
26740
|
+
const stream = writable.stream;
|
|
26741
|
+
if (writable.destroyed || stream?.closed || stream?.destroyed) {
|
|
26742
|
+
cancel();
|
|
26743
|
+
return reader.closed;
|
|
26744
|
+
}
|
|
26599
26745
|
writable.on("close", cancel);
|
|
26600
26746
|
writable.on("error", cancel);
|
|
26601
26747
|
(currentReadPromise ?? reader.read()).then(flow, handleStreamError);
|
|
@@ -26613,7 +26759,7 @@ function writeFromReadableStreamDefaultReader(reader, writable, currentReadPromi
|
|
|
26613
26759
|
try {
|
|
26614
26760
|
if (done) writable.end();
|
|
26615
26761
|
else if (!writable.write(value)) writable.once("drain", onDrain);
|
|
26616
|
-
else
|
|
26762
|
+
else reader.read().then(flow, handleStreamError);
|
|
26617
26763
|
} catch (e) {
|
|
26618
26764
|
handleStreamError(e);
|
|
26619
26765
|
}
|
|
@@ -26621,7 +26767,10 @@ function writeFromReadableStreamDefaultReader(reader, writable, currentReadPromi
|
|
|
26621
26767
|
}
|
|
26622
26768
|
function writeFromReadableStream(stream, writable) {
|
|
26623
26769
|
if (stream.locked) throw new TypeError("ReadableStream is locked.");
|
|
26624
|
-
else if (writable.destroyed)
|
|
26770
|
+
else if (writable.destroyed) {
|
|
26771
|
+
stream.cancel().catch(() => {});
|
|
26772
|
+
return;
|
|
26773
|
+
}
|
|
26625
26774
|
return writeFromReadableStreamDefaultReader(stream.getReader(), writable);
|
|
26626
26775
|
}
|
|
26627
26776
|
const buildOutgoingHttpHeaders = (headers, defaultContentType) => {
|
|
@@ -26812,10 +26961,7 @@ const responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
26812
26961
|
let maxReadCount = 2;
|
|
26813
26962
|
for (let i = 0; i < maxReadCount; i++) {
|
|
26814
26963
|
currentReadPromise ||= reader.read();
|
|
26815
|
-
const chunk = await readWithoutBlocking(currentReadPromise)
|
|
26816
|
-
console.error(e);
|
|
26817
|
-
done = true;
|
|
26818
|
-
});
|
|
26964
|
+
const chunk = await readWithoutBlocking(currentReadPromise);
|
|
26819
26965
|
if (!chunk) {
|
|
26820
26966
|
if (i === 1) {
|
|
26821
26967
|
await new Promise((resolve) => setTimeout(resolve));
|
|
@@ -27280,16 +27426,7 @@ const tryDecode$1 = (str, decoder) => {
|
|
|
27280
27426
|
});
|
|
27281
27427
|
}
|
|
27282
27428
|
};
|
|
27283
|
-
|
|
27284
|
-
* Try to apply decodeURI() to given string.
|
|
27285
|
-
* If it fails, skip invalid percent encoding or invalid UTF-8 sequences, and apply decodeURI() to the rest as much as possible.
|
|
27286
|
-
* @param str The string to decode.
|
|
27287
|
-
* @returns The decoded string that sometimes contains undecodable percent encoding.
|
|
27288
|
-
* @example
|
|
27289
|
-
* tryDecodeURI('Hello%20World') // 'Hello World'
|
|
27290
|
-
* tryDecodeURI('Hello%20World/%A4%A2') // 'Hello World/%A4%A2'
|
|
27291
|
-
*/
|
|
27292
|
-
const tryDecodeURI$1 = (str) => tryDecode$1(str, decodeURI);
|
|
27429
|
+
const decodeURIWithPreservedPercent = (value) => decodeURI(value.includes("%25") ? value.replace(/%25/g, "%2525") : value);
|
|
27293
27430
|
const getPath = (request) => {
|
|
27294
27431
|
const url = request.url;
|
|
27295
27432
|
const start = url.indexOf("/", url.indexOf(":") + 4);
|
|
@@ -27301,7 +27438,13 @@ const getPath = (request) => {
|
|
|
27301
27438
|
const hashIndex = url.indexOf("#", i);
|
|
27302
27439
|
const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
27303
27440
|
const path = url.slice(start, end);
|
|
27304
|
-
|
|
27441
|
+
const decoded = tryDecode$1(path, decodeURIWithPreservedPercent);
|
|
27442
|
+
if (/%(?![0-9A-Fa-f]{2})/.test(path)) {
|
|
27443
|
+
const rewritten = new URL("http://localhost");
|
|
27444
|
+
rewritten.pathname = decoded.replace(/[\\\t\n\r]/g, encodeURIComponent);
|
|
27445
|
+
if (tryDecode$1(rewritten.pathname, decodeURIWithPreservedPercent) !== decoded) return tryDecode$1(path.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"), decodeURIWithPreservedPercent);
|
|
27446
|
+
}
|
|
27447
|
+
return decoded;
|
|
27305
27448
|
} else if (charCode === 63 || charCode === 35) break;
|
|
27306
27449
|
}
|
|
27307
27450
|
return url.slice(start, i);
|
|
@@ -27310,15 +27453,6 @@ const getPathNoStrict = (request) => {
|
|
|
27310
27453
|
const result = getPath(request);
|
|
27311
27454
|
return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
|
|
27312
27455
|
};
|
|
27313
|
-
const stripPathPrefix = (rawPath, decodedPath, prefixLength) => {
|
|
27314
|
-
if (rawPath.at(-1) === "/" && decodedPath.at(-1) !== "/") rawPath = rawPath.slice(0, -1);
|
|
27315
|
-
let index = 0;
|
|
27316
|
-
for (let i = decodedPath.indexOf("/"); i !== -1 && i < prefixLength; i = decodedPath.indexOf("/", i + 1)) {
|
|
27317
|
-
index = rawPath.indexOf("/", index + 1);
|
|
27318
|
-
if (index === -1) return "/";
|
|
27319
|
-
}
|
|
27320
|
-
return rawPath.slice(index) || "/";
|
|
27321
|
-
};
|
|
27322
27456
|
/**
|
|
27323
27457
|
* Merge paths.
|
|
27324
27458
|
* @param {string[]} ...paths - The paths to merge.
|
|
@@ -28138,6 +28272,57 @@ const compose = (middleware, onError, onNotFound) => {
|
|
|
28138
28272
|
}
|
|
28139
28273
|
};
|
|
28140
28274
|
};
|
|
28275
|
+
// node_modules/hono/dist/helper/route/index.js
|
|
28276
|
+
/**
|
|
28277
|
+
* Get matched routes in the handler
|
|
28278
|
+
*
|
|
28279
|
+
* @param {Context} c - The context object
|
|
28280
|
+
* @returns An array of matched routes
|
|
28281
|
+
*
|
|
28282
|
+
* @example
|
|
28283
|
+
* ```ts
|
|
28284
|
+
* import { matchedRoutes } from 'hono/route'
|
|
28285
|
+
*
|
|
28286
|
+
* app.use('*', async function logger(c, next) {
|
|
28287
|
+
* await next()
|
|
28288
|
+
* matchedRoutes(c).forEach(({ handler, method, path }, i) => {
|
|
28289
|
+
* const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')
|
|
28290
|
+
* console.log(
|
|
28291
|
+
* method,
|
|
28292
|
+
* ' ',
|
|
28293
|
+
* path,
|
|
28294
|
+
* ' '.repeat(Math.max(10 - path.length, 0)),
|
|
28295
|
+
* name,
|
|
28296
|
+
* i === c.req.routeIndex ? '<- respond from here' : ''
|
|
28297
|
+
* )
|
|
28298
|
+
* })
|
|
28299
|
+
* })
|
|
28300
|
+
* ```
|
|
28301
|
+
*/
|
|
28302
|
+
const matchedRoutes = (c) => c.req[GET_MATCH_RESULT][0].map(([[, route]]) => route);
|
|
28303
|
+
/**
|
|
28304
|
+
* Get the route path registered within the handler
|
|
28305
|
+
*
|
|
28306
|
+
* @param {Context} c - The context object
|
|
28307
|
+
* @param {number} index - The index of the route from which to retrieve the path, similar to Array.prototype.at(), where a negative number is the index counted from the end of the matching route. Defaults to the current route index.
|
|
28308
|
+
* @returns The route path registered within the handler
|
|
28309
|
+
*
|
|
28310
|
+
* @example
|
|
28311
|
+
* ```ts
|
|
28312
|
+
* import { routePath } from 'hono/route'
|
|
28313
|
+
*
|
|
28314
|
+
* app.use('*', (c, next) => {
|
|
28315
|
+
* console.log(routePath(c)) // '*'
|
|
28316
|
+
* console.log(routePath(c, -1)) // '/posts/:id'
|
|
28317
|
+
* return next()
|
|
28318
|
+
* })
|
|
28319
|
+
*
|
|
28320
|
+
* app.get('/posts/:id', (c) => {
|
|
28321
|
+
* return c.text(routePath(c)) // '/posts/:id'
|
|
28322
|
+
* })
|
|
28323
|
+
* ```
|
|
28324
|
+
*/
|
|
28325
|
+
const routePath = (c, index) => matchedRoutes(c).at(index ?? c.req.routeIndex)?.path ?? "";
|
|
28141
28326
|
// node_modules/hono/dist/router.js
|
|
28142
28327
|
/**
|
|
28143
28328
|
* Array of supported HTTP methods.
|
|
@@ -28165,6 +28350,11 @@ var UnsupportedPathError = class extends Error {};
|
|
|
28165
28350
|
*/
|
|
28166
28351
|
const COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
28167
28352
|
// node_modules/hono/dist/utils/mount.js
|
|
28353
|
+
const countTrailingSlashes = (path) => {
|
|
28354
|
+
let index = path.length;
|
|
28355
|
+
while (index > 0 && path.charCodeAt(index - 1) === 47) index--;
|
|
28356
|
+
return path.length - index;
|
|
28357
|
+
};
|
|
28168
28358
|
const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
28169
28359
|
if (!/[:*]/.test(pathPrefix)) return pathPrefix.length;
|
|
28170
28360
|
const path = c.req.path;
|
|
@@ -28172,6 +28362,7 @@ const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
|
28172
28362
|
const paramNames = /* @__PURE__ */ new Set();
|
|
28173
28363
|
let length = 0;
|
|
28174
28364
|
for (const part of splitRoutingPath(pathPrefix)) {
|
|
28365
|
+
if (part[0] === ":" && part.endsWith("}?")) throw new Error(`mount(): Optional regular expression parameters are not supported in "${routePath}".`);
|
|
28175
28366
|
const pattern = getPattern(part);
|
|
28176
28367
|
if (pattern && pattern !== "*") {
|
|
28177
28368
|
const name = pattern[1];
|
|
@@ -28190,8 +28381,17 @@ const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
|
28190
28381
|
};
|
|
28191
28382
|
const createMountedRequest = (c, pathPrefix, routePath) => {
|
|
28192
28383
|
if (/[^/]\*$/.test(routePath)) throw new Error(`mount(): Wildcard must follow "/" in "${routePath}".`);
|
|
28193
|
-
const
|
|
28194
|
-
|
|
28384
|
+
const prefixLength = getPathPrefixLength(c, pathPrefix, routePath);
|
|
28385
|
+
const path = c.req.path.slice(prefixLength) || "/";
|
|
28386
|
+
if (prefixLength > c.req.path.length || path[0] !== "/" || /\/(?:\.|%2e){1,2}(?:\/|$)/i.test(path)) throw new HTTPException(400, { message: "Invalid mounted path" });
|
|
28387
|
+
const rawUrl = c.req.raw.url;
|
|
28388
|
+
if (/^[^/?#]*\/\/[^/?#\\]*[?#\\]/.test(rawUrl)) throw new HTTPException(400, { message: "Invalid mounted path" });
|
|
28389
|
+
const rawPathEnd = rawUrl.search(/[?#]/);
|
|
28390
|
+
const rawTrailingSlashes = countTrailingSlashes(rawPathEnd === -1 ? rawUrl : rawUrl.slice(0, rawPathEnd));
|
|
28391
|
+
if (rawTrailingSlashes > 1 && countTrailingSlashes(c.req.path) === rawTrailingSlashes - 1) throw new HTTPException(400, { message: "Invalid mounted path" });
|
|
28392
|
+
const url = new URL(rawUrl);
|
|
28393
|
+
url.pathname = path.replace(/[\\\t\n\r]/g, encodeURIComponent);
|
|
28394
|
+
if (path.includes("%")) {}
|
|
28195
28395
|
return new Request(url, c.req.raw);
|
|
28196
28396
|
};
|
|
28197
28397
|
// node_modules/hono/dist/hono-base.js
|
|
@@ -28374,6 +28574,8 @@ var Hono$1 = class Hono {
|
|
|
28374
28574
|
* @param {Function} applicationHandler - other Request Handler
|
|
28375
28575
|
* @param {MountOptions} [options] - options of `.mount()`
|
|
28376
28576
|
* @returns {Hono} mounted Hono instance
|
|
28577
|
+
* @throws {Error} If automatic request rewriting encounters duplicate path parameter names or an optional regular expression parameter.
|
|
28578
|
+
* @throws {HTTPException} With status 400 if automatic request rewriting cannot safely preserve the routed path.
|
|
28377
28579
|
*
|
|
28378
28580
|
* @example
|
|
28379
28581
|
* ```ts
|
|
@@ -28418,8 +28620,10 @@ var Hono$1 = class Hono {
|
|
|
28418
28620
|
} catch {}
|
|
28419
28621
|
return [c.env, executionContext];
|
|
28420
28622
|
};
|
|
28421
|
-
const
|
|
28422
|
-
|
|
28623
|
+
const defaultReplaceRequest = (c) => {
|
|
28624
|
+
const mountedRoutePath = routePath(c);
|
|
28625
|
+
return createMountedRequest(c, mountedRoutePath.replace(/\/?\*$/, ""), mountedRoutePath);
|
|
28626
|
+
};
|
|
28423
28627
|
const handler = async (c, next) => {
|
|
28424
28628
|
const res = await applicationHandler(replaceRequest ? replaceRequest(c.req.raw) : defaultReplaceRequest(c), ...getOptions(c));
|
|
28425
28629
|
if (res) return res;
|
|
@@ -29204,8 +29408,8 @@ const serveStatic = (options = { root: "" }) => {
|
|
|
29204
29408
|
let filename;
|
|
29205
29409
|
if (optionPath) filename = optionPath;
|
|
29206
29410
|
else try {
|
|
29207
|
-
if (!options.allowPercentInPath && c.req.path.includes("%")) throw new Error();
|
|
29208
29411
|
filename = tryDecodeURI(c.req.path);
|
|
29412
|
+
if (c.req.path.includes("%") && (!options.allowPercentInPath || filename !== c.req.path.replace(/%25/g, "%"))) throw new Error();
|
|
29209
29413
|
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}|\\/.test(filename)) throw new Error();
|
|
29210
29414
|
} catch {
|
|
29211
29415
|
await options.onNotFound?.(c.req.path, c);
|
|
@@ -29947,7 +30151,7 @@ const THEME_RULES = [{
|
|
|
29947
30151
|
severity: "error",
|
|
29948
30152
|
description: "A frame setting literal colors defines the other theme too, through a [data-theme] selector, a prefers-color-scheme query, or light-dark()"
|
|
29949
30153
|
}];
|
|
29950
|
-
const finding$
|
|
30154
|
+
const finding$12 = findingFor(THEME_RULES);
|
|
29951
30155
|
const COLOR_PROPERTIES$2 = /^(color|background(-color|-image)?|border(-(top|right|bottom|left|block|inline)(-(start|end))?)?(-color)?|outline(-color)?|fill|stroke|box-shadow|text-shadow|caret-color|accent-color|text-decoration(-color)?|column-rule(-color)?)$/i;
|
|
29952
30156
|
const COLOR_FUNCTION = /\b(rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\(/i;
|
|
29953
30157
|
const HEX_COLOR = /#[0-9a-f]{3,8}\b/i;
|
|
@@ -29957,7 +30161,7 @@ function checkTheme(source) {
|
|
|
29957
30161
|
const { firstColor, bothThemes } = readThemeColors(source);
|
|
29958
30162
|
if (!firstColor || bothThemes) return [];
|
|
29959
30163
|
const { path, location } = firstColor;
|
|
29960
|
-
return [finding$
|
|
30164
|
+
return [finding$12("theme", {
|
|
29961
30165
|
frame: source.ref,
|
|
29962
30166
|
path,
|
|
29963
30167
|
message: "The frame sets its own colors for one theme alone. Define the other through [data-theme] or prefers-color-scheme, or take the colors from token variables.",
|
|
@@ -30424,23 +30628,22 @@ const bodyLimit = (options) => {
|
|
|
30424
30628
|
const hasTransferEncoding = c.req.raw.headers.has("transfer-encoding");
|
|
30425
30629
|
if (c.req.raw.headers.has("content-length") && !hasTransferEncoding) return parseInt(c.req.raw.headers.get("content-length") || "0", 10) > maxSize ? onError(c) : next();
|
|
30426
30630
|
let size = 0;
|
|
30427
|
-
|
|
30631
|
+
let buffer = /* @__PURE__ */ new Uint8Array(0);
|
|
30428
30632
|
const rawReader = c.req.raw.body.getReader();
|
|
30429
30633
|
for (;;) {
|
|
30430
30634
|
const { done, value } = await rawReader.read();
|
|
30431
30635
|
if (done) break;
|
|
30636
|
+
const offset = size;
|
|
30432
30637
|
size += value.length;
|
|
30433
30638
|
if (size > maxSize) return onError(c);
|
|
30434
|
-
|
|
30639
|
+
if (size > buffer.length) {
|
|
30640
|
+
const grown = new Uint8Array(Math.min(maxSize, Math.max(size, buffer.length * 2)));
|
|
30641
|
+
grown.set(buffer.subarray(0, offset));
|
|
30642
|
+
buffer = grown;
|
|
30643
|
+
}
|
|
30644
|
+
buffer.set(value, offset);
|
|
30435
30645
|
}
|
|
30436
|
-
|
|
30437
|
-
body: new ReadableStream({ start(controller) {
|
|
30438
|
-
for (const chunk of chunks) controller.enqueue(chunk);
|
|
30439
|
-
controller.close();
|
|
30440
|
-
} }),
|
|
30441
|
-
duplex: "half"
|
|
30442
|
-
};
|
|
30443
|
-
c.req.raw = new Request(c.req.raw, requestInit);
|
|
30646
|
+
c.req.raw = new Request(c.req.raw, { body: buffer.subarray(0, size) });
|
|
30444
30647
|
return next();
|
|
30445
30648
|
};
|
|
30446
30649
|
};
|
|
@@ -30946,7 +31149,7 @@ function processHost() {
|
|
|
30946
31149
|
const run = promisify(execFile);
|
|
30947
31150
|
return {
|
|
30948
31151
|
platform: process.platform,
|
|
30949
|
-
release: release(),
|
|
31152
|
+
release: release$2(),
|
|
30950
31153
|
env: process.env,
|
|
30951
31154
|
run: async (command, args) => (await run(command, args)).stdout,
|
|
30952
31155
|
onPath: (command) => (process.env.PATH ?? "").split(delimiter).some((dir) => dir !== "" && existsSync(join(dir, command)))
|
|
@@ -31270,424 +31473,6 @@ function swapSpan(source, span, side) {
|
|
|
31270
31473
|
span: moved
|
|
31271
31474
|
};
|
|
31272
31475
|
}
|
|
31273
|
-
// src/server/edit/style.ts
|
|
31274
|
-
/**
|
|
31275
|
-
* The longhands a shorthand write drops, so a later longhand in the attribute
|
|
31276
|
-
* does not keep overriding the value just set. A longhand write leaves its
|
|
31277
|
-
* shorthand alone, since the longhand comes later and already wins.
|
|
31278
|
-
*/
|
|
31279
|
-
const BORDER_SIDES = [
|
|
31280
|
-
"top",
|
|
31281
|
-
"right",
|
|
31282
|
-
"bottom",
|
|
31283
|
-
"left"
|
|
31284
|
-
];
|
|
31285
|
-
const BORDER_PARTS = [
|
|
31286
|
-
"color",
|
|
31287
|
-
"style",
|
|
31288
|
-
"width"
|
|
31289
|
-
];
|
|
31290
|
-
const SHORTHAND_LONGHANDS = {
|
|
31291
|
-
background: [
|
|
31292
|
-
"background-attachment",
|
|
31293
|
-
"background-clip",
|
|
31294
|
-
"background-color",
|
|
31295
|
-
"background-image",
|
|
31296
|
-
"background-origin",
|
|
31297
|
-
"background-position",
|
|
31298
|
-
"background-repeat",
|
|
31299
|
-
"background-size"
|
|
31300
|
-
],
|
|
31301
|
-
border: [...BORDER_PARTS.map((part) => `border-${part}`), ...BORDER_SIDES.flatMap((side) => [`border-${side}`, ...BORDER_PARTS.map((part) => `border-${side}-${part}`)])],
|
|
31302
|
-
"border-radius": [
|
|
31303
|
-
"border-top-left-radius",
|
|
31304
|
-
"border-top-right-radius",
|
|
31305
|
-
"border-bottom-right-radius",
|
|
31306
|
-
"border-bottom-left-radius"
|
|
31307
|
-
],
|
|
31308
|
-
padding: [
|
|
31309
|
-
"padding-top",
|
|
31310
|
-
"padding-right",
|
|
31311
|
-
"padding-bottom",
|
|
31312
|
-
"padding-left"
|
|
31313
|
-
]
|
|
31314
|
-
};
|
|
31315
|
-
const CHARACTER_REFERENCE = /&(?:#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/iy;
|
|
31316
|
-
const DOUBLE_QUOTE_REFERENCES = /* @__PURE__ */ new Set([
|
|
31317
|
-
""",
|
|
31318
|
-
""",
|
|
31319
|
-
"""
|
|
31320
|
-
]);
|
|
31321
|
-
const SINGLE_QUOTE_REFERENCES = /* @__PURE__ */ new Set([
|
|
31322
|
-
"'",
|
|
31323
|
-
"'",
|
|
31324
|
-
"'"
|
|
31325
|
-
]);
|
|
31326
|
-
/** The end of the character reference starting at an offset, or undefined. */
|
|
31327
|
-
function referenceEnd(style, at) {
|
|
31328
|
-
if (style[at] !== "&") return void 0;
|
|
31329
|
-
CHARACTER_REFERENCE.lastIndex = at;
|
|
31330
|
-
return CHARACTER_REFERENCE.test(style) ? CHARACTER_REFERENCE.lastIndex : void 0;
|
|
31331
|
-
}
|
|
31332
|
-
/**
|
|
31333
|
-
* Splits a raw, still-encoded style value at each semicolon outside
|
|
31334
|
-
* parentheses, quotes, and comments, keeping every segment's own spacing so
|
|
31335
|
-
* an untouched one is written back as it was. A character reference's own
|
|
31336
|
-
* semicolon never splits, a quote written as one is still a quote to CSS once
|
|
31337
|
-
* decoded, and a backslash escapes the character after it, so `'a\'` leaves
|
|
31338
|
-
* the quote open.
|
|
31339
|
-
*/
|
|
31340
|
-
function declarations(style) {
|
|
31341
|
-
const segments = [];
|
|
31342
|
-
let depth = 0;
|
|
31343
|
-
let quote;
|
|
31344
|
-
let isComment = false;
|
|
31345
|
-
let start = 0;
|
|
31346
|
-
for (let at = 0; at < style.length; at += 1) {
|
|
31347
|
-
const char = style[at];
|
|
31348
|
-
if (isComment) {
|
|
31349
|
-
if (style.startsWith("*/", at)) {
|
|
31350
|
-
isComment = false;
|
|
31351
|
-
at += 1;
|
|
31352
|
-
}
|
|
31353
|
-
continue;
|
|
31354
|
-
}
|
|
31355
|
-
if (char === "\\") {
|
|
31356
|
-
at = (referenceEnd(style, at + 1) ?? at + 2) - 1;
|
|
31357
|
-
continue;
|
|
31358
|
-
}
|
|
31359
|
-
const end = referenceEnd(style, at);
|
|
31360
|
-
if (end !== void 0) {
|
|
31361
|
-
const reference = style.slice(at, end).toLowerCase();
|
|
31362
|
-
at = end - 1;
|
|
31363
|
-
const referenced = DOUBLE_QUOTE_REFERENCES.has(reference) ? "\"" : SINGLE_QUOTE_REFERENCES.has(reference) ? "'" : void 0;
|
|
31364
|
-
if (referenced && quote === referenced) quote = void 0;
|
|
31365
|
-
else if (referenced && !quote) quote = referenced;
|
|
31366
|
-
} else if (quote) {
|
|
31367
|
-
if (char === quote) quote = void 0;
|
|
31368
|
-
} else if (style.startsWith("/*", at)) {
|
|
31369
|
-
isComment = true;
|
|
31370
|
-
at += 1;
|
|
31371
|
-
} else if (char === "\"" || char === "'") quote = char;
|
|
31372
|
-
else if (char === "(") depth += 1;
|
|
31373
|
-
else if (char === ")") depth = Math.max(0, depth - 1);
|
|
31374
|
-
else if (char === ";" && depth === 0) {
|
|
31375
|
-
segments.push(style.slice(start, at));
|
|
31376
|
-
start = at + 1;
|
|
31377
|
-
}
|
|
31378
|
-
}
|
|
31379
|
-
segments.push(style.slice(start));
|
|
31380
|
-
return {
|
|
31381
|
-
segments,
|
|
31382
|
-
isOpen: quote !== void 0 || isComment
|
|
31383
|
-
};
|
|
31384
|
-
}
|
|
31385
|
-
/** The property a declaration names, read past any comment ahead of it. */
|
|
31386
|
-
function propertyOf(segment) {
|
|
31387
|
-
return segment.replace(/\/\*[\s\S]*?\*\//g, "").split(":", 1)[0]?.trim().toLowerCase() ?? "";
|
|
31388
|
-
}
|
|
31389
|
-
/** The values a style declares for one property, in order, read from a decoded style. */
|
|
31390
|
-
function declaredValues(style, property) {
|
|
31391
|
-
return declarations(style).segments.filter((segment) => propertyOf(segment) === property).map((segment) => segment.slice(segment.indexOf(":") + 1).trim());
|
|
31392
|
-
}
|
|
31393
|
-
/**
|
|
31394
|
-
* Sets one declaration in a raw style value, or drops it on an empty value.
|
|
31395
|
-
* The first declaration of the property is replaced in place and any later one
|
|
31396
|
-
* dropped, so nothing further in the attribute overrides the edit, and a
|
|
31397
|
-
* shorthand also drops its longhands. The value arrives already escaped for
|
|
31398
|
-
* the attribute. An empty style means none is left. A style ending inside an
|
|
31399
|
-
* open quote or comment refuses, since an appended declaration would land in it.
|
|
31400
|
-
*/
|
|
31401
|
-
function setDeclaration(style, property, value) {
|
|
31402
|
-
const parsed = declarations(style);
|
|
31403
|
-
if (parsed.isOpen) return { ok: false };
|
|
31404
|
-
const longhands = SHORTHAND_LONGHANDS[property] ?? [];
|
|
31405
|
-
const segments = parsed.segments.filter((segment) => !longhands.includes(propertyOf(segment)));
|
|
31406
|
-
const declaration = `${property}: ${value.trim()}`;
|
|
31407
|
-
if (value.trim() === "") {
|
|
31408
|
-
const kept = segments.filter((segment) => propertyOf(segment) !== property);
|
|
31409
|
-
if (kept.every((segment) => segment.trim() === "")) return {
|
|
31410
|
-
ok: true,
|
|
31411
|
-
style: ""
|
|
31412
|
-
};
|
|
31413
|
-
return {
|
|
31414
|
-
ok: true,
|
|
31415
|
-
style: kept.join(";").replace(/^[\s;]+/, "")
|
|
31416
|
-
};
|
|
31417
|
-
}
|
|
31418
|
-
if (!segments.some((segment) => propertyOf(segment) === property)) {
|
|
31419
|
-
const kept = segments.filter((segment) => segment.trim() !== "").join(";").replace(/^\s+/, "");
|
|
31420
|
-
return {
|
|
31421
|
-
ok: true,
|
|
31422
|
-
style: kept === "" ? declaration : `${kept}; ${declaration}`
|
|
31423
|
-
};
|
|
31424
|
-
}
|
|
31425
|
-
let isReplaced = false;
|
|
31426
|
-
return {
|
|
31427
|
-
ok: true,
|
|
31428
|
-
style: segments.flatMap((segment) => {
|
|
31429
|
-
if (propertyOf(segment) !== property) return [segment];
|
|
31430
|
-
if (isReplaced) return [];
|
|
31431
|
-
isReplaced = true;
|
|
31432
|
-
return [`${/^\s*/.exec(segment)?.[0] ?? ""}${declaration}`];
|
|
31433
|
-
}).join(";")
|
|
31434
|
-
};
|
|
31435
|
-
}
|
|
31436
|
-
/**
|
|
31437
|
-
* Rewrites each declaration's value in a raw style through `rewrite`, which
|
|
31438
|
-
* takes the property and the value with its spacing and answers the value to
|
|
31439
|
-
* keep, so every byte it leaves alone is written back as it was. A
|
|
31440
|
-
* declaration carrying a comment is kept as written, since its `:` may sit
|
|
31441
|
-
* inside the comment. Null for a style ending inside an open quote or comment.
|
|
31442
|
-
*/
|
|
31443
|
-
function rewriteValues(style, rewrite) {
|
|
31444
|
-
const parsed = declarations(style);
|
|
31445
|
-
if (parsed.isOpen) return null;
|
|
31446
|
-
return parsed.segments.map((segment) => {
|
|
31447
|
-
const colon = segment.indexOf(":");
|
|
31448
|
-
if (colon < 0 || segment.includes("/*")) return segment;
|
|
31449
|
-
return segment.slice(0, colon + 1) + rewrite(propertyOf(segment), segment.slice(colon + 1));
|
|
31450
|
-
}).join(";");
|
|
31451
|
-
}
|
|
31452
|
-
// src/server/edit/text.ts
|
|
31453
|
-
/** Elements whose content the tokenizer reads as raw text, not as a text node to splice. */
|
|
31454
|
-
const RAW_TEXT = /* @__PURE__ */ new Set([
|
|
31455
|
-
"script",
|
|
31456
|
-
"style",
|
|
31457
|
-
"template",
|
|
31458
|
-
"textarea",
|
|
31459
|
-
"title"
|
|
31460
|
-
]);
|
|
31461
|
-
/** Elements whose text the tree builder moves elsewhere, so a write never lands inside them. */
|
|
31462
|
-
const RELOCATING = /* @__PURE__ */ new Set([
|
|
31463
|
-
"html",
|
|
31464
|
-
"head",
|
|
31465
|
-
"table",
|
|
31466
|
-
"thead",
|
|
31467
|
-
"tbody",
|
|
31468
|
-
"tfoot",
|
|
31469
|
-
"tr",
|
|
31470
|
-
"colgroup",
|
|
31471
|
-
"select",
|
|
31472
|
-
"frameset"
|
|
31473
|
-
]);
|
|
31474
|
-
/** The parser drops one leading newline inside these. */
|
|
31475
|
-
const LEADING_NEWLINE_DROPPED = /* @__PURE__ */ new Set(["pre", "listing"]);
|
|
31476
|
-
function escapeText$1(value) {
|
|
31477
|
-
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
31478
|
-
}
|
|
31479
|
-
/**
|
|
31480
|
-
* Replaces the text of an element holding text alone. The source between its
|
|
31481
|
-
* tags must be exactly its one text node, or nothing, since misnested markup
|
|
31482
|
-
* such as `<b>1<p>2</b>` leaves the element's end tag past markup the tree
|
|
31483
|
-
* builder gave to another element.
|
|
31484
|
-
*/
|
|
31485
|
-
function setText(source, element, value) {
|
|
31486
|
-
const tag = element.tagName;
|
|
31487
|
-
const location = element.sourceCodeLocation;
|
|
31488
|
-
if (RAW_TEXT.has(tag)) return {
|
|
31489
|
-
ok: false,
|
|
31490
|
-
detail: `<${tag}> holds raw content, not text`
|
|
31491
|
-
};
|
|
31492
|
-
if (RELOCATING.has(tag)) return {
|
|
31493
|
-
ok: false,
|
|
31494
|
-
detail: `the parser moves text written inside <${tag}>`
|
|
31495
|
-
};
|
|
31496
|
-
if (!location?.startTag || !location.endTag) return {
|
|
31497
|
-
ok: false,
|
|
31498
|
-
detail: `<${tag}> has no end tag to bound its text`
|
|
31499
|
-
};
|
|
31500
|
-
const from = location.startTag.endOffset;
|
|
31501
|
-
const to = location.endTag.startOffset;
|
|
31502
|
-
const [only, ...rest] = element.childNodes;
|
|
31503
|
-
if (!(only === void 0 ? from === to : rest.length === 0 && only.nodeName === "#text" && only.sourceCodeLocation?.startOffset === from && only.sourceCodeLocation.endOffset === to)) return {
|
|
31504
|
-
ok: false,
|
|
31505
|
-
detail: `<${tag}> holds more than one text node`
|
|
31506
|
-
};
|
|
31507
|
-
const written = LEADING_NEWLINE_DROPPED.has(tag) && value.startsWith("\n") ? `\n${value}` : value;
|
|
31508
|
-
return {
|
|
31509
|
-
ok: true,
|
|
31510
|
-
html: source.slice(0, from) + escapeText$1(written) + source.slice(to)
|
|
31511
|
-
};
|
|
31512
|
-
}
|
|
31513
|
-
// src/server/edit/apply.ts
|
|
31514
|
-
const MAX_VALUE_LENGTH = 200;
|
|
31515
|
-
/** Anything that would end the declaration and start another. */
|
|
31516
|
-
const DECLARATION_BREAK = /[;{}<>\n\r]/;
|
|
31517
|
-
const PROPERTY_NAME = /^(?:--[\w-]+|-?[a-z][a-z0-9-]*)$/i;
|
|
31518
|
-
/** What the tokenizer reads as one attribute name. */
|
|
31519
|
-
const ATTRIBUTE_NAME = /^[^\s"'<>/=]+$/;
|
|
31520
|
-
function refuse$2(reason, detail) {
|
|
31521
|
-
return {
|
|
31522
|
-
ok: false,
|
|
31523
|
-
reason,
|
|
31524
|
-
detail
|
|
31525
|
-
};
|
|
31526
|
-
}
|
|
31527
|
-
function checkValue(value) {
|
|
31528
|
-
return value.length > MAX_VALUE_LENGTH ? refuse$2("invalid-edit", `the value runs past ${MAX_VALUE_LENGTH} characters`) : void 0;
|
|
31529
|
-
}
|
|
31530
|
-
function checkDeclaration({ property, value }) {
|
|
31531
|
-
const invalid = checkValue(value);
|
|
31532
|
-
if (invalid) return invalid;
|
|
31533
|
-
if (!PROPERTY_NAME.test(property)) return refuse$2("invalid-edit", `${property} is not a CSS property name`);
|
|
31534
|
-
if (DECLARATION_BREAK.test(value)) return refuse$2("invalid-edit", `${property} takes one value, with no ; { } < > or line break`);
|
|
31535
|
-
}
|
|
31536
|
-
function checkChange(change) {
|
|
31537
|
-
if (change.kind === "style") return checkDeclaration(change);
|
|
31538
|
-
if (change.kind === "styles") {
|
|
31539
|
-
const { declarations } = change;
|
|
31540
|
-
if (declarations.length === 0) return refuse$2("invalid-edit", "a styles edit names no declaration");
|
|
31541
|
-
if (new Set(declarations.map(({ property }) => property)).size !== declarations.length) return refuse$2("invalid-edit", "a styles edit names one property twice, so one value would be lost");
|
|
31542
|
-
for (const declaration of declarations) {
|
|
31543
|
-
const invalid = checkDeclaration(declaration);
|
|
31544
|
-
if (invalid) return invalid;
|
|
31545
|
-
}
|
|
31546
|
-
return;
|
|
31547
|
-
}
|
|
31548
|
-
if ("value" in change) {
|
|
31549
|
-
const invalid = checkValue(change.value);
|
|
31550
|
-
if (invalid) return invalid;
|
|
31551
|
-
}
|
|
31552
|
-
if (change.kind === "attribute") {
|
|
31553
|
-
if (!ATTRIBUTE_NAME.test(change.name)) return refuse$2("invalid-edit", `${change.name} is not an attribute name`);
|
|
31554
|
-
if (change.name.toLowerCase() === "style") return refuse$2("invalid-edit", "style is edited one declaration at a time, as a style edit");
|
|
31555
|
-
}
|
|
31556
|
-
}
|
|
31557
|
-
function resolve$1(tree, index) {
|
|
31558
|
-
if (tree.unstated) return refuse$2("address-mismatch", `the browser builds a <${tree.unstated.tagName}> the file does not state, so indices after it disagree`);
|
|
31559
|
-
const element = Number.isInteger(index) ? tree.elements[index] : void 0;
|
|
31560
|
-
if (!element) return refuse$2("invalid-address", `the frame holds elements 0 to ${tree.elements.length - 1}, so ${index} names none`);
|
|
31561
|
-
if (!element.sourceCodeLocation?.startTag) return refuse$2("address-mismatch", `<${element.tagName}> at ${index} is implied, not stated in the file`);
|
|
31562
|
-
return element;
|
|
31563
|
-
}
|
|
31564
|
-
/** Which bytes of the element a change reads and writes, as `SpanScope` splits them. */
|
|
31565
|
-
function scopeOf(change) {
|
|
31566
|
-
return change.kind === "text" ? "element" : "start-tag";
|
|
31567
|
-
}
|
|
31568
|
-
/** The attribute name an edit writes, or undefined for a text edit. */
|
|
31569
|
-
function editedAttribute(change) {
|
|
31570
|
-
if (change.kind === "style" || change.kind === "styles") return "style";
|
|
31571
|
-
if (change.kind === "attribute") return change.name;
|
|
31572
|
-
}
|
|
31573
|
-
function write(source, element, change) {
|
|
31574
|
-
if (change.kind === "text") {
|
|
31575
|
-
const written = setText(source, element, change.value);
|
|
31576
|
-
return written.ok ? written : refuse$2("not-text-only", written.detail);
|
|
31577
|
-
}
|
|
31578
|
-
if (change.kind === "attribute") {
|
|
31579
|
-
if ("remove" in change) return {
|
|
31580
|
-
ok: true,
|
|
31581
|
-
html: removeAttribute(source, element, change.name)
|
|
31582
|
-
};
|
|
31583
|
-
return {
|
|
31584
|
-
ok: true,
|
|
31585
|
-
html: setRawAttribute(source, element, change.name, escapeAttribute$1(change.value))
|
|
31586
|
-
};
|
|
31587
|
-
}
|
|
31588
|
-
const declarations = change.kind === "styles" ? change.declarations : [change];
|
|
31589
|
-
let style = rawAttribute(source, element, "style") ?? "";
|
|
31590
|
-
for (const { property, value } of declarations) {
|
|
31591
|
-
const next = setDeclaration(style, property, escapeAttribute$1(value));
|
|
31592
|
-
if (!next.ok) return refuse$2("open-quote", `the style on <${element.tagName}> ends inside an open quote or comment`);
|
|
31593
|
-
style = next.style;
|
|
31594
|
-
}
|
|
31595
|
-
return {
|
|
31596
|
-
ok: true,
|
|
31597
|
-
html: style === "" ? removeAttribute(source, element, "style") : setRawAttribute(source, element, "style", style)
|
|
31598
|
-
};
|
|
31599
|
-
}
|
|
31600
|
-
/**
|
|
31601
|
-
* Whether an attribute is the one the file states under a lowercased name.
|
|
31602
|
-
* In SVG and MathML, parse5 adjusts names after tokenizing, turning `viewbox`
|
|
31603
|
-
* into `viewBox` and `xlink:href` into `href` under an `xlink` prefix.
|
|
31604
|
-
*/
|
|
31605
|
-
function isNamed(attribute, name) {
|
|
31606
|
-
return (attribute.prefix ? `${attribute.prefix}:${attribute.name}` : attribute.name).toLowerCase() === name;
|
|
31607
|
-
}
|
|
31608
|
-
/**
|
|
31609
|
-
* Whether the output's tree is the input's with only the target changed. The
|
|
31610
|
-
* target's edited attribute, or its text, is copied across from the output,
|
|
31611
|
-
* so the comparison covers every other node, and the caller's own check
|
|
31612
|
-
* covers the value itself.
|
|
31613
|
-
*/
|
|
31614
|
-
function changesOnlyTarget(before, after, index, change) {
|
|
31615
|
-
if (after.elements.length !== before.elements.length) return false;
|
|
31616
|
-
const was = before.elements[index];
|
|
31617
|
-
const now = after.elements[index];
|
|
31618
|
-
if (!was || !now || was.tagName !== now.tagName) return false;
|
|
31619
|
-
const name = editedAttribute(change);
|
|
31620
|
-
if (name === void 0) was.childNodes = now.childNodes;
|
|
31621
|
-
else {
|
|
31622
|
-
const written = now.attrs.find((attribute) => isNamed(attribute, name));
|
|
31623
|
-
const others = was.attrs.filter((attribute) => !isNamed(attribute, name));
|
|
31624
|
-
was.attrs = written ? [...others, written] : others;
|
|
31625
|
-
now.attrs = written ? [...now.attrs.filter((attribute) => attribute !== written), written] : now.attrs;
|
|
31626
|
-
}
|
|
31627
|
-
return serialize$1(before.document) === serialize$1(after.document);
|
|
31628
|
-
}
|
|
31629
|
-
function textOf$1(element) {
|
|
31630
|
-
return element.childNodes.map((node) => "value" in node && node.nodeName === "#text" ? node.value : "").join("");
|
|
31631
|
-
}
|
|
31632
|
-
/** Whether the target holds the value the change asked for. */
|
|
31633
|
-
function holdsValue(element, change) {
|
|
31634
|
-
if (change.kind === "text") return textOf$1(element) === change.value;
|
|
31635
|
-
if (change.kind === "attribute") {
|
|
31636
|
-
const stated = element.attrs.find((attribute) => isNamed(attribute, change.name));
|
|
31637
|
-
return "remove" in change ? stated === void 0 : stated?.value === change.value;
|
|
31638
|
-
}
|
|
31639
|
-
const style = element.attrs.find((attribute) => attribute.name === "style")?.value ?? "";
|
|
31640
|
-
return (change.kind === "styles" ? change.declarations : [change]).every(({ property, value }) => {
|
|
31641
|
-
const declared = declaredValues(style, property);
|
|
31642
|
-
const wanted = value.trim();
|
|
31643
|
-
return wanted === "" ? declared.length === 0 : declared.length === 1 && declared[0] === wanted;
|
|
31644
|
-
});
|
|
31645
|
-
}
|
|
31646
|
-
/**
|
|
31647
|
-
* Applies one change to the element the address names and leaves every other
|
|
31648
|
-
* byte of the source as it was, a `styles` change writing each declaration in
|
|
31649
|
-
* turn into the one style attribute. The output is parsed again and refused as
|
|
31650
|
-
* `verify-failed` unless its tree is the input's with that one change, so an
|
|
31651
|
-
* input the guards never met is refused rather than written corrupted.
|
|
31652
|
-
*/
|
|
31653
|
-
function applyEdit(source, address, change) {
|
|
31654
|
-
const normalized = change.kind === "style" ? {
|
|
31655
|
-
...change,
|
|
31656
|
-
property: change.property.toLowerCase()
|
|
31657
|
-
} : change.kind === "styles" ? {
|
|
31658
|
-
...change,
|
|
31659
|
-
declarations: change.declarations.map((declaration) => ({
|
|
31660
|
-
...declaration,
|
|
31661
|
-
property: declaration.property.toLowerCase()
|
|
31662
|
-
}))
|
|
31663
|
-
} : change.kind === "attribute" ? {
|
|
31664
|
-
...change,
|
|
31665
|
-
name: change.name.toLowerCase()
|
|
31666
|
-
} : change;
|
|
31667
|
-
const invalid = checkChange(normalized);
|
|
31668
|
-
if (invalid) return invalid;
|
|
31669
|
-
const before = parseFrame(source);
|
|
31670
|
-
const element = resolve$1(before, address.index);
|
|
31671
|
-
if ("ok" in element) return element;
|
|
31672
|
-
const written = write(source, element, normalized);
|
|
31673
|
-
if (!written.ok) return written;
|
|
31674
|
-
const after = parseFrame(written.html);
|
|
31675
|
-
const target = after.elements[address.index];
|
|
31676
|
-
if (!target || !holdsValue(target, normalized) || !changesOnlyTarget(before, after, address.index, normalized)) return refuse$2("verify-failed", `the edit to <${element.tagName}> would change more than that element, so nothing was written`);
|
|
31677
|
-
const scope = scopeOf(normalized);
|
|
31678
|
-
const span = {
|
|
31679
|
-
scope,
|
|
31680
|
-
index: address.index,
|
|
31681
|
-
count: before.elements.length,
|
|
31682
|
-
before: spanText(source, element, scope),
|
|
31683
|
-
after: spanText(written.html, target, scope)
|
|
31684
|
-
};
|
|
31685
|
-
return {
|
|
31686
|
-
ok: true,
|
|
31687
|
-
html: written.html,
|
|
31688
|
-
span
|
|
31689
|
-
};
|
|
31690
|
-
}
|
|
31691
31476
|
// node_modules/@bramus/specificity/dist/index.js
|
|
31692
31477
|
var Jn = Object.create;
|
|
31693
31478
|
var te = Object.defineProperty;
|
|
@@ -33805,7 +33590,7 @@ var cs = 35;
|
|
|
33805
33590
|
var ls = 38;
|
|
33806
33591
|
var us = 42;
|
|
33807
33592
|
var hs = 43;
|
|
33808
|
-
var fs
|
|
33593
|
+
var fs = 47;
|
|
33809
33594
|
var Hn = 46;
|
|
33810
33595
|
var ps = 62;
|
|
33811
33596
|
var ms = 124;
|
|
@@ -33832,7 +33617,7 @@ function xs() {
|
|
|
33832
33617
|
case hs:
|
|
33833
33618
|
case ps:
|
|
33834
33619
|
case ds:
|
|
33835
|
-
case fs
|
|
33620
|
+
case fs: return this.Combinator();
|
|
33836
33621
|
case Hn: return this.ClassSelector();
|
|
33837
33622
|
case us:
|
|
33838
33623
|
case ms: return this.TypeSelector();
|
|
@@ -34920,7 +34705,7 @@ const textEscapeRegex = /[&<>\u{A0}]/gu;
|
|
|
34920
34705
|
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
|
34921
34706
|
* @param data String to escape.
|
|
34922
34707
|
*/
|
|
34923
|
-
function escapeText(data) {
|
|
34708
|
+
function escapeText$1(data) {
|
|
34924
34709
|
return escapeWithRegex(textEscapeRegex, data);
|
|
34925
34710
|
}
|
|
34926
34711
|
// node_modules/dom-serializer/dist/foreign-names.js
|
|
@@ -34984,7 +34769,7 @@ function renderNode(node, options, xmlMode) {
|
|
|
34984
34769
|
case Text$1: {
|
|
34985
34770
|
const element = node;
|
|
34986
34771
|
const data = element.data || "";
|
|
34987
|
-
if ((options.encodeEntities ?? options.decodeEntities) !== false && !(!xmlMode && element.parent && unencodedElements.has(element.parent.name))) return xmlMode || options.encodeEntities !== "utf8" ? encodeXML(data) : escapeText(data);
|
|
34772
|
+
if ((options.encodeEntities ?? options.decodeEntities) !== false && !(!xmlMode && element.parent && unencodedElements.has(element.parent.name))) return xmlMode || options.encodeEntities !== "utf8" ? encodeXML(data) : escapeText$1(data);
|
|
34988
34773
|
return data;
|
|
34989
34774
|
}
|
|
34990
34775
|
}
|
|
@@ -36884,6 +36669,77 @@ function splitTopLevel(text, separator) {
|
|
|
36884
36669
|
parts.push(text.slice(start));
|
|
36885
36670
|
return parts;
|
|
36886
36671
|
}
|
|
36672
|
+
/** Words of a `border` or `background` shorthand that are never its color. */
|
|
36673
|
+
const NOT_COLOR = /* @__PURE__ */ new Set([
|
|
36674
|
+
"none",
|
|
36675
|
+
"hidden",
|
|
36676
|
+
"dotted",
|
|
36677
|
+
"dashed",
|
|
36678
|
+
"solid",
|
|
36679
|
+
"double",
|
|
36680
|
+
"groove",
|
|
36681
|
+
"ridge",
|
|
36682
|
+
"inset",
|
|
36683
|
+
"outset",
|
|
36684
|
+
"thin",
|
|
36685
|
+
"medium",
|
|
36686
|
+
"thick",
|
|
36687
|
+
"repeat",
|
|
36688
|
+
"no-repeat",
|
|
36689
|
+
"repeat-x",
|
|
36690
|
+
"repeat-y",
|
|
36691
|
+
"space",
|
|
36692
|
+
"round",
|
|
36693
|
+
"fixed",
|
|
36694
|
+
"scroll",
|
|
36695
|
+
"local",
|
|
36696
|
+
"center",
|
|
36697
|
+
"top",
|
|
36698
|
+
"bottom",
|
|
36699
|
+
"left",
|
|
36700
|
+
"right",
|
|
36701
|
+
"cover",
|
|
36702
|
+
"contain",
|
|
36703
|
+
"auto",
|
|
36704
|
+
"border-box",
|
|
36705
|
+
"padding-box",
|
|
36706
|
+
"content-box"
|
|
36707
|
+
]);
|
|
36708
|
+
/**
|
|
36709
|
+
* The part of a `border` or `background` shorthand that sets `property`:
|
|
36710
|
+
* the last part that reads as a color for a color, since a color comes last
|
|
36711
|
+
* in a border, and the first length for a width. Null when none does. An
|
|
36712
|
+
* `!important` ends the parts, so a raw attribute value reads as the parsed
|
|
36713
|
+
* one does, and `start` lets a writer replace the part in place.
|
|
36714
|
+
*/
|
|
36715
|
+
function shorthandPart(value, property) {
|
|
36716
|
+
const parts = [];
|
|
36717
|
+
let start = 0;
|
|
36718
|
+
for (const text of splitTopLevel(value, " ")) {
|
|
36719
|
+
const bang = text.search(/!\s*important$/i);
|
|
36720
|
+
if (bang === 0 || text.startsWith("!")) break;
|
|
36721
|
+
if (bang > 0) {
|
|
36722
|
+
parts.push({
|
|
36723
|
+
text: text.slice(0, bang),
|
|
36724
|
+
start
|
|
36725
|
+
});
|
|
36726
|
+
break;
|
|
36727
|
+
}
|
|
36728
|
+
if (text !== "") parts.push({
|
|
36729
|
+
text,
|
|
36730
|
+
start
|
|
36731
|
+
});
|
|
36732
|
+
start += text.length + 1;
|
|
36733
|
+
}
|
|
36734
|
+
if (property === "border-width") return parts.find(({ text }) => /^(?:[\d.]|thin|medium|thick)/i.test(text)) ?? null;
|
|
36735
|
+
return parts.findLast(({ text }) => isColorish(text)) ?? null;
|
|
36736
|
+
}
|
|
36737
|
+
function isColorish(part) {
|
|
36738
|
+
const lower = part.toLowerCase();
|
|
36739
|
+
if (NOT_COLOR.has(lower)) return false;
|
|
36740
|
+
if (/^[\d.+-]/.test(lower) || lower.includes("/")) return false;
|
|
36741
|
+
return !/^(?:url|[a-z-]*gradient|image-set)\(/.test(lower);
|
|
36742
|
+
}
|
|
36887
36743
|
/** The first family of a `font-family` list, unquoted. */
|
|
36888
36744
|
function firstOf(families) {
|
|
36889
36745
|
return (splitTopLevel(families, ",")[0] ?? "").trim().replace(/^(['"])(.*)\1$/, "$2").trim();
|
|
@@ -36915,6 +36771,486 @@ function shorthandFamily(value) {
|
|
|
36915
36771
|
const family = tokens.slice(familyAt).join(" ");
|
|
36916
36772
|
return family === "" ? null : family;
|
|
36917
36773
|
}
|
|
36774
|
+
// src/server/edit/style.ts
|
|
36775
|
+
/**
|
|
36776
|
+
* The longhands a shorthand write drops, so a later longhand in the attribute
|
|
36777
|
+
* does not keep overriding the value just set. A longhand write leaves its
|
|
36778
|
+
* shorthand alone, since the longhand comes later and already wins, except
|
|
36779
|
+
* where `PART_SHORTHANDS` rewrites the shorthand's own part instead.
|
|
36780
|
+
*/
|
|
36781
|
+
const BORDER_SIDES = [
|
|
36782
|
+
"top",
|
|
36783
|
+
"right",
|
|
36784
|
+
"bottom",
|
|
36785
|
+
"left"
|
|
36786
|
+
];
|
|
36787
|
+
const BORDER_PARTS = [
|
|
36788
|
+
"color",
|
|
36789
|
+
"style",
|
|
36790
|
+
"width"
|
|
36791
|
+
];
|
|
36792
|
+
const SHORTHAND_LONGHANDS = {
|
|
36793
|
+
background: [
|
|
36794
|
+
"background-attachment",
|
|
36795
|
+
"background-clip",
|
|
36796
|
+
"background-color",
|
|
36797
|
+
"background-image",
|
|
36798
|
+
"background-origin",
|
|
36799
|
+
"background-position",
|
|
36800
|
+
"background-repeat",
|
|
36801
|
+
"background-size"
|
|
36802
|
+
],
|
|
36803
|
+
border: [...BORDER_PARTS.map((part) => `border-${part}`), ...BORDER_SIDES.flatMap((side) => [`border-${side}`, ...BORDER_PARTS.map((part) => `border-${side}-${part}`)])],
|
|
36804
|
+
"border-radius": [
|
|
36805
|
+
"border-top-left-radius",
|
|
36806
|
+
"border-top-right-radius",
|
|
36807
|
+
"border-bottom-right-radius",
|
|
36808
|
+
"border-bottom-left-radius"
|
|
36809
|
+
],
|
|
36810
|
+
padding: [
|
|
36811
|
+
"padding-top",
|
|
36812
|
+
"padding-right",
|
|
36813
|
+
"padding-bottom",
|
|
36814
|
+
"padding-left"
|
|
36815
|
+
]
|
|
36816
|
+
};
|
|
36817
|
+
/** The paint longhands whose part of a shorthand the inspector reads, and that shorthand. */
|
|
36818
|
+
const PART_SHORTHANDS = {
|
|
36819
|
+
"background-color": "background",
|
|
36820
|
+
"border-color": "border",
|
|
36821
|
+
"border-width": "border"
|
|
36822
|
+
};
|
|
36823
|
+
const CHARACTER_REFERENCE = /&(?:#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/iy;
|
|
36824
|
+
const DOUBLE_QUOTE_REFERENCES = /* @__PURE__ */ new Set([
|
|
36825
|
+
""",
|
|
36826
|
+
""",
|
|
36827
|
+
"""
|
|
36828
|
+
]);
|
|
36829
|
+
const SINGLE_QUOTE_REFERENCES = /* @__PURE__ */ new Set([
|
|
36830
|
+
"'",
|
|
36831
|
+
"'",
|
|
36832
|
+
"'"
|
|
36833
|
+
]);
|
|
36834
|
+
/** The end of the character reference starting at an offset, or undefined. */
|
|
36835
|
+
function referenceEnd(style, at) {
|
|
36836
|
+
if (style[at] !== "&") return void 0;
|
|
36837
|
+
CHARACTER_REFERENCE.lastIndex = at;
|
|
36838
|
+
return CHARACTER_REFERENCE.test(style) ? CHARACTER_REFERENCE.lastIndex : void 0;
|
|
36839
|
+
}
|
|
36840
|
+
/**
|
|
36841
|
+
* Splits a raw, still-encoded style value at each semicolon outside
|
|
36842
|
+
* parentheses, quotes, and comments, keeping every segment's own spacing so
|
|
36843
|
+
* an untouched one is written back as it was. A character reference's own
|
|
36844
|
+
* semicolon never splits, a quote written as one is still a quote to CSS once
|
|
36845
|
+
* decoded, and a backslash escapes the character after it, so `'a\'` leaves
|
|
36846
|
+
* the quote open.
|
|
36847
|
+
*/
|
|
36848
|
+
function declarations(style) {
|
|
36849
|
+
const segments = [];
|
|
36850
|
+
let depth = 0;
|
|
36851
|
+
let quote;
|
|
36852
|
+
let isComment = false;
|
|
36853
|
+
let start = 0;
|
|
36854
|
+
for (let at = 0; at < style.length; at += 1) {
|
|
36855
|
+
const char = style[at];
|
|
36856
|
+
if (isComment) {
|
|
36857
|
+
if (style.startsWith("*/", at)) {
|
|
36858
|
+
isComment = false;
|
|
36859
|
+
at += 1;
|
|
36860
|
+
}
|
|
36861
|
+
continue;
|
|
36862
|
+
}
|
|
36863
|
+
if (char === "\\") {
|
|
36864
|
+
at = (referenceEnd(style, at + 1) ?? at + 2) - 1;
|
|
36865
|
+
continue;
|
|
36866
|
+
}
|
|
36867
|
+
const end = referenceEnd(style, at);
|
|
36868
|
+
if (end !== void 0) {
|
|
36869
|
+
const reference = style.slice(at, end).toLowerCase();
|
|
36870
|
+
at = end - 1;
|
|
36871
|
+
const referenced = DOUBLE_QUOTE_REFERENCES.has(reference) ? "\"" : SINGLE_QUOTE_REFERENCES.has(reference) ? "'" : void 0;
|
|
36872
|
+
if (referenced && quote === referenced) quote = void 0;
|
|
36873
|
+
else if (referenced && !quote) quote = referenced;
|
|
36874
|
+
} else if (quote) {
|
|
36875
|
+
if (char === quote) quote = void 0;
|
|
36876
|
+
} else if (style.startsWith("/*", at)) {
|
|
36877
|
+
isComment = true;
|
|
36878
|
+
at += 1;
|
|
36879
|
+
} else if (char === "\"" || char === "'") quote = char;
|
|
36880
|
+
else if (char === "(") depth += 1;
|
|
36881
|
+
else if (char === ")") depth = Math.max(0, depth - 1);
|
|
36882
|
+
else if (char === ";" && depth === 0) {
|
|
36883
|
+
segments.push(style.slice(start, at));
|
|
36884
|
+
start = at + 1;
|
|
36885
|
+
}
|
|
36886
|
+
}
|
|
36887
|
+
segments.push(style.slice(start));
|
|
36888
|
+
return {
|
|
36889
|
+
segments,
|
|
36890
|
+
isOpen: quote !== void 0 || isComment
|
|
36891
|
+
};
|
|
36892
|
+
}
|
|
36893
|
+
/** The property a declaration names, read past any comment ahead of it. */
|
|
36894
|
+
function propertyOf(segment) {
|
|
36895
|
+
return segment.replace(/\/\*[\s\S]*?\*\//g, "").split(":", 1)[0]?.trim().toLowerCase() ?? "";
|
|
36896
|
+
}
|
|
36897
|
+
/** The values a style declares for one property, in order, read from a decoded style. */
|
|
36898
|
+
function declaredValues(style, property) {
|
|
36899
|
+
return declarations(style).segments.filter((segment) => propertyOf(segment) === property).map((segment) => segment.slice(segment.indexOf(":") + 1).trim());
|
|
36900
|
+
}
|
|
36901
|
+
/**
|
|
36902
|
+
* The part of a decoded style's last shorthand that a paint longhand reads
|
|
36903
|
+
* from, which `setDeclaration` writes in place of the longhand. Undefined for
|
|
36904
|
+
* a property with no such shorthand, or a shorthand holding no such part.
|
|
36905
|
+
*/
|
|
36906
|
+
function shorthandValue(style, property) {
|
|
36907
|
+
const shorthand = PART_SHORTHANDS[property];
|
|
36908
|
+
if (!shorthand) return void 0;
|
|
36909
|
+
const value = declaredValues(style, shorthand).at(-1);
|
|
36910
|
+
return value === void 0 ? void 0 : shorthandPart(value, property)?.text;
|
|
36911
|
+
}
|
|
36912
|
+
/**
|
|
36913
|
+
* Sets one declaration in a raw style value, or drops it on an empty value.
|
|
36914
|
+
* The first declaration of the property is replaced in place and any later one
|
|
36915
|
+
* dropped, so nothing further in the attribute overrides the edit, and a
|
|
36916
|
+
* shorthand also drops its longhands. A paint longhand over a shorthand
|
|
36917
|
+
* holding its part rewrites that part instead. The value arrives already escaped for
|
|
36918
|
+
* the attribute. An empty style means none is left. A style ending inside an
|
|
36919
|
+
* open quote or comment refuses, since an appended declaration would land in it.
|
|
36920
|
+
*/
|
|
36921
|
+
function setDeclaration(style, property, value) {
|
|
36922
|
+
const parsed = declarations(style);
|
|
36923
|
+
if (parsed.isOpen) return { ok: false };
|
|
36924
|
+
const longhands = SHORTHAND_LONGHANDS[property] ?? [];
|
|
36925
|
+
const segments = parsed.segments.filter((segment) => !longhands.includes(propertyOf(segment)));
|
|
36926
|
+
const declaration = `${property}: ${value.trim()}`;
|
|
36927
|
+
if (value.trim() === "") {
|
|
36928
|
+
const kept = segments.filter((segment) => propertyOf(segment) !== property);
|
|
36929
|
+
if (kept.every((segment) => segment.trim() === "")) return {
|
|
36930
|
+
ok: true,
|
|
36931
|
+
style: ""
|
|
36932
|
+
};
|
|
36933
|
+
return {
|
|
36934
|
+
ok: true,
|
|
36935
|
+
style: kept.join(";").replace(/^[\s;]+/, "")
|
|
36936
|
+
};
|
|
36937
|
+
}
|
|
36938
|
+
const rewritten = withShorthandPart(segments, property, value.trim());
|
|
36939
|
+
if (rewritten !== null) return {
|
|
36940
|
+
ok: true,
|
|
36941
|
+
style: rewritten
|
|
36942
|
+
};
|
|
36943
|
+
if (!segments.some((segment) => propertyOf(segment) === property)) {
|
|
36944
|
+
const kept = segments.filter((segment) => segment.trim() !== "").join(";").replace(/^\s+/, "");
|
|
36945
|
+
return {
|
|
36946
|
+
ok: true,
|
|
36947
|
+
style: kept === "" ? declaration : `${kept}; ${declaration}`
|
|
36948
|
+
};
|
|
36949
|
+
}
|
|
36950
|
+
let isReplaced = false;
|
|
36951
|
+
return {
|
|
36952
|
+
ok: true,
|
|
36953
|
+
style: segments.flatMap((segment) => {
|
|
36954
|
+
if (propertyOf(segment) !== property) return [segment];
|
|
36955
|
+
if (isReplaced) return [];
|
|
36956
|
+
isReplaced = true;
|
|
36957
|
+
return [`${/^\s*/.exec(segment)?.[0] ?? ""}${declaration}`];
|
|
36958
|
+
}).join(";")
|
|
36959
|
+
};
|
|
36960
|
+
}
|
|
36961
|
+
/**
|
|
36962
|
+
* The segments with `value` in place of the part of the last shorthand that
|
|
36963
|
+
* sets `property`, so a paint edit over `border: 1px solid var(--primary)`
|
|
36964
|
+
* leaves no token behind it as dead text. A declaration of the property ahead
|
|
36965
|
+
* of the shorthand is already overridden by it, so it drops. Null when the
|
|
36966
|
+
* property has no such shorthand, a later declaration sets the part on any
|
|
36967
|
+
* side and would keep winning there, its value holds no such part, or a
|
|
36968
|
+
* comment sits in it.
|
|
36969
|
+
*/
|
|
36970
|
+
function withShorthandPart(segments, property, value) {
|
|
36971
|
+
const shorthand = PART_SHORTHANDS[property];
|
|
36972
|
+
if (!shorthand) return null;
|
|
36973
|
+
const at = segments.findLastIndex((segment) => propertyOf(segment) === shorthand);
|
|
36974
|
+
const segment = segments[at];
|
|
36975
|
+
if (segment === void 0 || segment.includes("/*")) return null;
|
|
36976
|
+
if (segments.slice(at + 1).some((later) => setsPart(propertyOf(later), property))) return null;
|
|
36977
|
+
const colon = segment.indexOf(":");
|
|
36978
|
+
const part = shorthandPart(segment.slice(colon + 1), property);
|
|
36979
|
+
if (!part) return null;
|
|
36980
|
+
const from = colon + 1 + part.start;
|
|
36981
|
+
const rewritten = segment.slice(0, from) + value + segment.slice(from + part.text.length);
|
|
36982
|
+
return segments.flatMap((each, index) => {
|
|
36983
|
+
if (index === at) return [rewritten];
|
|
36984
|
+
return index < at && propertyOf(each) === property ? [] : [each];
|
|
36985
|
+
}).join(";").replace(/^\s+/, "");
|
|
36986
|
+
}
|
|
36987
|
+
const BORDER_SIDE = /^border-(?:top|right|bottom|left|block|inline)(?:-(?:start|end))?(?:-(color|width|style))?$/;
|
|
36988
|
+
/**
|
|
36989
|
+
* Whether a declaration of `declared` sets the part `property` names on any
|
|
36990
|
+
* side, as `border-top` or `border-top-width` does for `border-width`.
|
|
36991
|
+
*/
|
|
36992
|
+
function setsPart(declared, property) {
|
|
36993
|
+
if (declared === property) return true;
|
|
36994
|
+
const side = BORDER_SIDE.exec(declared);
|
|
36995
|
+
if (!side || !property.startsWith("border-")) return false;
|
|
36996
|
+
return side[1] === void 0 || `border-${side[1]}` === property;
|
|
36997
|
+
}
|
|
36998
|
+
/**
|
|
36999
|
+
* Rewrites each declaration's value in a raw style through `rewrite`, which
|
|
37000
|
+
* takes the property and the value with its spacing and answers the value to
|
|
37001
|
+
* keep, so every byte it leaves alone is written back as it was. A
|
|
37002
|
+
* declaration carrying a comment is kept as written, since its `:` may sit
|
|
37003
|
+
* inside the comment. Null for a style ending inside an open quote or comment.
|
|
37004
|
+
*/
|
|
37005
|
+
function rewriteValues(style, rewrite) {
|
|
37006
|
+
const parsed = declarations(style);
|
|
37007
|
+
if (parsed.isOpen) return null;
|
|
37008
|
+
return parsed.segments.map((segment) => {
|
|
37009
|
+
const colon = segment.indexOf(":");
|
|
37010
|
+
if (colon < 0 || segment.includes("/*")) return segment;
|
|
37011
|
+
return segment.slice(0, colon + 1) + rewrite(propertyOf(segment), segment.slice(colon + 1));
|
|
37012
|
+
}).join(";");
|
|
37013
|
+
}
|
|
37014
|
+
// src/server/edit/text.ts
|
|
37015
|
+
/** Elements whose content the tokenizer reads as raw text, not as a text node to splice. */
|
|
37016
|
+
const RAW_TEXT = /* @__PURE__ */ new Set([
|
|
37017
|
+
"script",
|
|
37018
|
+
"style",
|
|
37019
|
+
"template",
|
|
37020
|
+
"textarea",
|
|
37021
|
+
"title"
|
|
37022
|
+
]);
|
|
37023
|
+
/** Elements whose text the tree builder moves elsewhere, so a write never lands inside them. */
|
|
37024
|
+
const RELOCATING = /* @__PURE__ */ new Set([
|
|
37025
|
+
"html",
|
|
37026
|
+
"head",
|
|
37027
|
+
"table",
|
|
37028
|
+
"thead",
|
|
37029
|
+
"tbody",
|
|
37030
|
+
"tfoot",
|
|
37031
|
+
"tr",
|
|
37032
|
+
"colgroup",
|
|
37033
|
+
"select",
|
|
37034
|
+
"frameset"
|
|
37035
|
+
]);
|
|
37036
|
+
/** The parser drops one leading newline inside these. */
|
|
37037
|
+
const LEADING_NEWLINE_DROPPED = /* @__PURE__ */ new Set(["pre", "listing"]);
|
|
37038
|
+
function escapeText(value) {
|
|
37039
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
37040
|
+
}
|
|
37041
|
+
/**
|
|
37042
|
+
* Replaces the text of an element holding text alone. The source between its
|
|
37043
|
+
* tags must be exactly its one text node, or nothing, since misnested markup
|
|
37044
|
+
* such as `<b>1<p>2</b>` leaves the element's end tag past markup the tree
|
|
37045
|
+
* builder gave to another element.
|
|
37046
|
+
*/
|
|
37047
|
+
function setText(source, element, value) {
|
|
37048
|
+
const tag = element.tagName;
|
|
37049
|
+
const location = element.sourceCodeLocation;
|
|
37050
|
+
if (RAW_TEXT.has(tag)) return {
|
|
37051
|
+
ok: false,
|
|
37052
|
+
detail: `<${tag}> holds raw content, not text`
|
|
37053
|
+
};
|
|
37054
|
+
if (RELOCATING.has(tag)) return {
|
|
37055
|
+
ok: false,
|
|
37056
|
+
detail: `the parser moves text written inside <${tag}>`
|
|
37057
|
+
};
|
|
37058
|
+
if (!location?.startTag || !location.endTag) return {
|
|
37059
|
+
ok: false,
|
|
37060
|
+
detail: `<${tag}> has no end tag to bound its text`
|
|
37061
|
+
};
|
|
37062
|
+
const from = location.startTag.endOffset;
|
|
37063
|
+
const to = location.endTag.startOffset;
|
|
37064
|
+
const [only, ...rest] = element.childNodes;
|
|
37065
|
+
if (!(only === void 0 ? from === to : rest.length === 0 && only.nodeName === "#text" && only.sourceCodeLocation?.startOffset === from && only.sourceCodeLocation.endOffset === to)) return {
|
|
37066
|
+
ok: false,
|
|
37067
|
+
detail: `<${tag}> holds more than one text node`
|
|
37068
|
+
};
|
|
37069
|
+
const written = LEADING_NEWLINE_DROPPED.has(tag) && value.startsWith("\n") ? `\n${value}` : value;
|
|
37070
|
+
return {
|
|
37071
|
+
ok: true,
|
|
37072
|
+
html: source.slice(0, from) + escapeText(written) + source.slice(to)
|
|
37073
|
+
};
|
|
37074
|
+
}
|
|
37075
|
+
// src/server/edit/apply.ts
|
|
37076
|
+
const MAX_VALUE_LENGTH = 200;
|
|
37077
|
+
/** Anything that would end the declaration and start another. */
|
|
37078
|
+
const DECLARATION_BREAK = /[;{}<>\n\r]/;
|
|
37079
|
+
const PROPERTY_NAME = /^(?:--[\w-]+|-?[a-z][a-z0-9-]*)$/i;
|
|
37080
|
+
/** What the tokenizer reads as one attribute name. */
|
|
37081
|
+
const ATTRIBUTE_NAME = /^[^\s"'<>/=]+$/;
|
|
37082
|
+
function refuse$2(reason, detail) {
|
|
37083
|
+
return {
|
|
37084
|
+
ok: false,
|
|
37085
|
+
reason,
|
|
37086
|
+
detail
|
|
37087
|
+
};
|
|
37088
|
+
}
|
|
37089
|
+
function checkValue(value) {
|
|
37090
|
+
return value.length > MAX_VALUE_LENGTH ? refuse$2("invalid-edit", `the value runs past ${MAX_VALUE_LENGTH} characters`) : void 0;
|
|
37091
|
+
}
|
|
37092
|
+
function checkDeclaration({ property, value }) {
|
|
37093
|
+
const invalid = checkValue(value);
|
|
37094
|
+
if (invalid) return invalid;
|
|
37095
|
+
if (!PROPERTY_NAME.test(property)) return refuse$2("invalid-edit", `${property} is not a CSS property name`);
|
|
37096
|
+
if (DECLARATION_BREAK.test(value)) return refuse$2("invalid-edit", `${property} takes one value, with no ; { } < > or line break`);
|
|
37097
|
+
}
|
|
37098
|
+
function checkChange(change) {
|
|
37099
|
+
if (change.kind === "style") return checkDeclaration(change);
|
|
37100
|
+
if (change.kind === "styles") {
|
|
37101
|
+
const { declarations } = change;
|
|
37102
|
+
if (declarations.length === 0) return refuse$2("invalid-edit", "a styles edit names no declaration");
|
|
37103
|
+
if (new Set(declarations.map(({ property }) => property)).size !== declarations.length) return refuse$2("invalid-edit", "a styles edit names one property twice, so one value would be lost");
|
|
37104
|
+
for (const declaration of declarations) {
|
|
37105
|
+
const invalid = checkDeclaration(declaration);
|
|
37106
|
+
if (invalid) return invalid;
|
|
37107
|
+
}
|
|
37108
|
+
return;
|
|
37109
|
+
}
|
|
37110
|
+
if ("value" in change) {
|
|
37111
|
+
const invalid = checkValue(change.value);
|
|
37112
|
+
if (invalid) return invalid;
|
|
37113
|
+
}
|
|
37114
|
+
if (change.kind === "attribute") {
|
|
37115
|
+
if (!ATTRIBUTE_NAME.test(change.name)) return refuse$2("invalid-edit", `${change.name} is not an attribute name`);
|
|
37116
|
+
if (change.name.toLowerCase() === "style") return refuse$2("invalid-edit", "style is edited one declaration at a time, as a style edit");
|
|
37117
|
+
}
|
|
37118
|
+
}
|
|
37119
|
+
function resolve(tree, index) {
|
|
37120
|
+
if (tree.unstated) return refuse$2("address-mismatch", `the browser builds a <${tree.unstated.tagName}> the file does not state, so indices after it disagree`);
|
|
37121
|
+
const element = Number.isInteger(index) ? tree.elements[index] : void 0;
|
|
37122
|
+
if (!element) return refuse$2("invalid-address", `the frame holds elements 0 to ${tree.elements.length - 1}, so ${index} names none`);
|
|
37123
|
+
if (!element.sourceCodeLocation?.startTag) return refuse$2("address-mismatch", `<${element.tagName}> at ${index} is implied, not stated in the file`);
|
|
37124
|
+
return element;
|
|
37125
|
+
}
|
|
37126
|
+
/** Which bytes of the element a change reads and writes, as `SpanScope` splits them. */
|
|
37127
|
+
function scopeOf(change) {
|
|
37128
|
+
return change.kind === "text" ? "element" : "start-tag";
|
|
37129
|
+
}
|
|
37130
|
+
/** The attribute name an edit writes, or undefined for a text edit. */
|
|
37131
|
+
function editedAttribute(change) {
|
|
37132
|
+
if (change.kind === "style" || change.kind === "styles") return "style";
|
|
37133
|
+
if (change.kind === "attribute") return change.name;
|
|
37134
|
+
}
|
|
37135
|
+
function write(source, element, change) {
|
|
37136
|
+
if (change.kind === "text") {
|
|
37137
|
+
const written = setText(source, element, change.value);
|
|
37138
|
+
return written.ok ? written : refuse$2("not-text-only", written.detail);
|
|
37139
|
+
}
|
|
37140
|
+
if (change.kind === "attribute") {
|
|
37141
|
+
if ("remove" in change) return {
|
|
37142
|
+
ok: true,
|
|
37143
|
+
html: removeAttribute(source, element, change.name)
|
|
37144
|
+
};
|
|
37145
|
+
return {
|
|
37146
|
+
ok: true,
|
|
37147
|
+
html: setRawAttribute(source, element, change.name, escapeAttribute$1(change.value))
|
|
37148
|
+
};
|
|
37149
|
+
}
|
|
37150
|
+
const declarations = change.kind === "styles" ? change.declarations : [change];
|
|
37151
|
+
let style = rawAttribute(source, element, "style") ?? "";
|
|
37152
|
+
for (const { property, value } of declarations) {
|
|
37153
|
+
const next = setDeclaration(style, property, escapeAttribute$1(value));
|
|
37154
|
+
if (!next.ok) return refuse$2("open-quote", `the style on <${element.tagName}> ends inside an open quote or comment`);
|
|
37155
|
+
style = next.style;
|
|
37156
|
+
}
|
|
37157
|
+
return {
|
|
37158
|
+
ok: true,
|
|
37159
|
+
html: style === "" ? removeAttribute(source, element, "style") : setRawAttribute(source, element, "style", style)
|
|
37160
|
+
};
|
|
37161
|
+
}
|
|
37162
|
+
/**
|
|
37163
|
+
* Whether an attribute is the one the file states under a lowercased name.
|
|
37164
|
+
* In SVG and MathML, parse5 adjusts names after tokenizing, turning `viewbox`
|
|
37165
|
+
* into `viewBox` and `xlink:href` into `href` under an `xlink` prefix.
|
|
37166
|
+
*/
|
|
37167
|
+
function isNamed(attribute, name) {
|
|
37168
|
+
return (attribute.prefix ? `${attribute.prefix}:${attribute.name}` : attribute.name).toLowerCase() === name;
|
|
37169
|
+
}
|
|
37170
|
+
/**
|
|
37171
|
+
* Whether the output's tree is the input's with only the target changed. The
|
|
37172
|
+
* target's edited attribute, or its text, is copied across from the output,
|
|
37173
|
+
* so the comparison covers every other node, and the caller's own check
|
|
37174
|
+
* covers the value itself.
|
|
37175
|
+
*/
|
|
37176
|
+
function changesOnlyTarget(before, after, index, change) {
|
|
37177
|
+
if (after.elements.length !== before.elements.length) return false;
|
|
37178
|
+
const was = before.elements[index];
|
|
37179
|
+
const now = after.elements[index];
|
|
37180
|
+
if (!was || !now || was.tagName !== now.tagName) return false;
|
|
37181
|
+
const name = editedAttribute(change);
|
|
37182
|
+
if (name === void 0) was.childNodes = now.childNodes;
|
|
37183
|
+
else {
|
|
37184
|
+
const written = now.attrs.find((attribute) => isNamed(attribute, name));
|
|
37185
|
+
const others = was.attrs.filter((attribute) => !isNamed(attribute, name));
|
|
37186
|
+
was.attrs = written ? [...others, written] : others;
|
|
37187
|
+
now.attrs = written ? [...now.attrs.filter((attribute) => attribute !== written), written] : now.attrs;
|
|
37188
|
+
}
|
|
37189
|
+
return serialize$1(before.document) === serialize$1(after.document);
|
|
37190
|
+
}
|
|
37191
|
+
function textOf(element) {
|
|
37192
|
+
return element.childNodes.map((node) => "value" in node && node.nodeName === "#text" ? node.value : "").join("");
|
|
37193
|
+
}
|
|
37194
|
+
/** Whether the target holds the value the change asked for. */
|
|
37195
|
+
function holdsValue(element, change) {
|
|
37196
|
+
if (change.kind === "text") return textOf(element) === change.value;
|
|
37197
|
+
if (change.kind === "attribute") {
|
|
37198
|
+
const stated = element.attrs.find((attribute) => isNamed(attribute, change.name));
|
|
37199
|
+
return "remove" in change ? stated === void 0 : stated?.value === change.value;
|
|
37200
|
+
}
|
|
37201
|
+
const style = element.attrs.find((attribute) => attribute.name === "style")?.value ?? "";
|
|
37202
|
+
return (change.kind === "styles" ? change.declarations : [change]).every(({ property, value }) => {
|
|
37203
|
+
const declared = declaredValues(style, property);
|
|
37204
|
+
const wanted = value.trim();
|
|
37205
|
+
if (wanted === "") return declared.length === 0;
|
|
37206
|
+
return declared.length === 0 ? shorthandValue(style, property) === wanted : declared.length === 1 && declared[0] === wanted;
|
|
37207
|
+
});
|
|
37208
|
+
}
|
|
37209
|
+
/**
|
|
37210
|
+
* Applies one change to the element the address names and leaves every other
|
|
37211
|
+
* byte of the source as it was, a `styles` change writing each declaration in
|
|
37212
|
+
* turn into the one style attribute. The output is parsed again and refused as
|
|
37213
|
+
* `verify-failed` unless its tree is the input's with that one change, so an
|
|
37214
|
+
* input the guards never met is refused rather than written corrupted.
|
|
37215
|
+
*/
|
|
37216
|
+
function applyEdit(source, address, change) {
|
|
37217
|
+
const normalized = change.kind === "style" ? {
|
|
37218
|
+
...change,
|
|
37219
|
+
property: change.property.toLowerCase()
|
|
37220
|
+
} : change.kind === "styles" ? {
|
|
37221
|
+
...change,
|
|
37222
|
+
declarations: change.declarations.map((declaration) => ({
|
|
37223
|
+
...declaration,
|
|
37224
|
+
property: declaration.property.toLowerCase()
|
|
37225
|
+
}))
|
|
37226
|
+
} : change.kind === "attribute" ? {
|
|
37227
|
+
...change,
|
|
37228
|
+
name: change.name.toLowerCase()
|
|
37229
|
+
} : change;
|
|
37230
|
+
const invalid = checkChange(normalized);
|
|
37231
|
+
if (invalid) return invalid;
|
|
37232
|
+
const before = parseFrame(source);
|
|
37233
|
+
const element = resolve(before, address.index);
|
|
37234
|
+
if ("ok" in element) return element;
|
|
37235
|
+
const written = write(source, element, normalized);
|
|
37236
|
+
if (!written.ok) return written;
|
|
37237
|
+
const after = parseFrame(written.html);
|
|
37238
|
+
const target = after.elements[address.index];
|
|
37239
|
+
if (!target || !holdsValue(target, normalized) || !changesOnlyTarget(before, after, address.index, normalized)) return refuse$2("verify-failed", `the edit to <${element.tagName}> would change more than that element, so nothing was written`);
|
|
37240
|
+
const scope = scopeOf(normalized);
|
|
37241
|
+
const span = {
|
|
37242
|
+
scope,
|
|
37243
|
+
index: address.index,
|
|
37244
|
+
count: before.elements.length,
|
|
37245
|
+
before: spanText(source, element, scope),
|
|
37246
|
+
after: spanText(written.html, target, scope)
|
|
37247
|
+
};
|
|
37248
|
+
return {
|
|
37249
|
+
ok: true,
|
|
37250
|
+
html: written.html,
|
|
37251
|
+
span
|
|
37252
|
+
};
|
|
37253
|
+
}
|
|
36918
37254
|
// src/server/edit/elements.ts
|
|
36919
37255
|
/** How long a text-only element's text may run as its name. */
|
|
36920
37256
|
const NAME_LENGTH = 40;
|
|
@@ -37792,42 +38128,6 @@ const NEVER_USES = /* @__PURE__ */ new Set([
|
|
|
37792
38128
|
"optgroup",
|
|
37793
38129
|
"option"
|
|
37794
38130
|
]);
|
|
37795
|
-
/** Words of a `border` or `background` shorthand that are never its color. */
|
|
37796
|
-
const NOT_COLOR = /* @__PURE__ */ new Set([
|
|
37797
|
-
"none",
|
|
37798
|
-
"hidden",
|
|
37799
|
-
"dotted",
|
|
37800
|
-
"dashed",
|
|
37801
|
-
"solid",
|
|
37802
|
-
"double",
|
|
37803
|
-
"groove",
|
|
37804
|
-
"ridge",
|
|
37805
|
-
"inset",
|
|
37806
|
-
"outset",
|
|
37807
|
-
"thin",
|
|
37808
|
-
"medium",
|
|
37809
|
-
"thick",
|
|
37810
|
-
"repeat",
|
|
37811
|
-
"no-repeat",
|
|
37812
|
-
"repeat-x",
|
|
37813
|
-
"repeat-y",
|
|
37814
|
-
"space",
|
|
37815
|
-
"round",
|
|
37816
|
-
"fixed",
|
|
37817
|
-
"scroll",
|
|
37818
|
-
"local",
|
|
37819
|
-
"center",
|
|
37820
|
-
"top",
|
|
37821
|
-
"bottom",
|
|
37822
|
-
"left",
|
|
37823
|
-
"right",
|
|
37824
|
-
"cover",
|
|
37825
|
-
"contain",
|
|
37826
|
-
"auto",
|
|
37827
|
-
"border-box",
|
|
37828
|
-
"padding-box",
|
|
37829
|
-
"content-box"
|
|
37830
|
-
]);
|
|
37831
38131
|
const VAR = /^var\(\s*(--[\w-]+)\s*(?:,.*)?\)$/is;
|
|
37832
38132
|
const MIX = /^color-mix\(\s*in\s+srgb\s*,\s*var\(\s*(--[\w-]+)\s*(?:,[^)]*)?\)\s+([\d.]+)%\s*,\s*transparent\s*\)$/is;
|
|
37833
38133
|
const HEX_ALPHA = /^#([0-9a-f]{6})([0-9a-f]{2})$/i;
|
|
@@ -37858,7 +38158,7 @@ function frameStyles(source, tokens, index) {
|
|
|
37858
38158
|
const read = (element, property) => {
|
|
37859
38159
|
const found = cascade.specified(element, property);
|
|
37860
38160
|
if (!found) return null;
|
|
37861
|
-
const part = found.shorthand ? shorthandPart(found.value, property) : found.value;
|
|
38161
|
+
const part = found.shorthand ? shorthandPart(found.value, property)?.text ?? null : found.value;
|
|
37862
38162
|
return part === null ? null : named(part, found.element);
|
|
37863
38163
|
};
|
|
37864
38164
|
const family = (element) => {
|
|
@@ -37985,22 +38285,6 @@ function declaredNames(sheets) {
|
|
|
37985
38285
|
}
|
|
37986
38286
|
return names;
|
|
37987
38287
|
}
|
|
37988
|
-
/**
|
|
37989
|
-
* The part of a `border` or `background` shorthand that sets `property`:
|
|
37990
|
-
* the last part that reads as a color for a color, since a color comes last
|
|
37991
|
-
* in a border, and the first length for a width. Null when none does.
|
|
37992
|
-
*/
|
|
37993
|
-
function shorthandPart(value, property) {
|
|
37994
|
-
const parts = splitTopLevel(value.trim(), " ").filter((part) => part !== "");
|
|
37995
|
-
if (property === "border-width") return parts.find((part) => /^(?:[\d.]|thin|medium|thick)/i.test(part)) ?? null;
|
|
37996
|
-
return parts.findLast(isColorish) ?? null;
|
|
37997
|
-
}
|
|
37998
|
-
function isColorish(part) {
|
|
37999
|
-
const lower = part.toLowerCase();
|
|
38000
|
-
if (NOT_COLOR.has(lower)) return false;
|
|
38001
|
-
if (/^[\d.+-]/.test(lower) || lower.includes("/")) return false;
|
|
38002
|
-
return !/^(?:url|[a-z-]*gradient|image-set)\(/.test(lower);
|
|
38003
|
-
}
|
|
38004
38288
|
function within$1(element, root) {
|
|
38005
38289
|
for (let current = element; current;) {
|
|
38006
38290
|
if (current === root) return true;
|
|
@@ -38154,6 +38438,13 @@ function children(element) {
|
|
|
38154
38438
|
function subtree(element) {
|
|
38155
38439
|
return children(element).reduce((count, child) => count + subtree(child), 1);
|
|
38156
38440
|
}
|
|
38441
|
+
/** The first of `Container`, `Container 2`, and on that no element of `elements` is named. */
|
|
38442
|
+
function containerName(elements) {
|
|
38443
|
+
const taken = new Set(elements.flatMap((element) => element.attrs.flatMap((attr) => attr.name === "data-name" ? [attr.value.trim()] : [])));
|
|
38444
|
+
let name = "Container";
|
|
38445
|
+
for (let n = 2; taken.has(name); n += 1) name = `Container ${n}`;
|
|
38446
|
+
return name;
|
|
38447
|
+
}
|
|
38157
38448
|
function isFree(facts) {
|
|
38158
38449
|
const position = facts?.position?.trim().toLowerCase();
|
|
38159
38450
|
return position === "absolute" || position === "fixed";
|
|
@@ -38196,7 +38487,7 @@ function wrapElements(source, indexes, flow, spot, facts) {
|
|
|
38196
38487
|
if (!start || ranges.some((range) => !range)) return refuse$2("verify-failed", "a member lost its place in the file, so nothing was written");
|
|
38197
38488
|
const indent = /\n[ \t]*$/.exec(html.slice(0, start[0]))?.[0] ?? "";
|
|
38198
38489
|
const inner = indent === "" ? "" : `${indent} `;
|
|
38199
|
-
const
|
|
38490
|
+
const declarations = [
|
|
38200
38491
|
"display: flex",
|
|
38201
38492
|
`flex-direction: ${flow.direction}`,
|
|
38202
38493
|
`gap: ${px(flow.gap)}`,
|
|
@@ -38205,7 +38496,8 @@ function wrapElements(source, indexes, flow, spot, facts) {
|
|
|
38205
38496
|
`left: ${px(spot.left)}`,
|
|
38206
38497
|
`top: ${px(spot.top)}`
|
|
38207
38498
|
] : []
|
|
38208
|
-
]
|
|
38499
|
+
];
|
|
38500
|
+
const container = `<div data-name="${containerName(tree.elements)}" style="${declarations.join("; ")}">${ranges.map((range) => `${inner}${html.slice(range?.[0], range?.[1])}`).join("")}${indent}</div>`;
|
|
38209
38501
|
let wrapped = html;
|
|
38210
38502
|
for (const range of ranges.slice(1).toReversed()) {
|
|
38211
38503
|
if (!range) continue;
|
|
@@ -38373,13 +38665,10 @@ function namedOnceEach(indexes, edits) {
|
|
|
38373
38665
|
* edit, through a temporary file and a rename after reading the file again.
|
|
38374
38666
|
* A hash the file no longer has is refused as stale with no search, since the
|
|
38375
38667
|
* gap's indices name nothing once the file moved, which also lands a retried
|
|
38376
|
-
* insert at most once.
|
|
38377
|
-
*
|
|
38378
|
-
*
|
|
38379
|
-
*
|
|
38380
|
-
* tag a static parent took, so undoing both changes as one step takes the
|
|
38381
|
-
* element out after the parent's tag goes back, and a redo finds the gap
|
|
38382
|
-
* under the parent as it first stood.
|
|
38668
|
+
* insert at most once. Given `place`, the element is placed out of the flow
|
|
38669
|
+
* in the same write. Its span carries the placed bytes and `parent` the start
|
|
38670
|
+
* tag a static parent took, so one undo takes the element out after the
|
|
38671
|
+
* parent's tag goes back, and a redo finds the gap as it first stood.
|
|
38383
38672
|
*/
|
|
38384
38673
|
function insertFrameFile(path, hash, placement, markup, place) {
|
|
38385
38674
|
const read = readSource(path);
|
|
@@ -38863,6 +39152,45 @@ async function renameProject(root, name, newName, { journal } = {}) {
|
|
|
38863
39152
|
return scanProject(root, newName);
|
|
38864
39153
|
}
|
|
38865
39154
|
/**
|
|
39155
|
+
* Sets the name a person reads for the project, which may hold any
|
|
39156
|
+
* characters, and moves the folder to the name made from it, the next free
|
|
39157
|
+
* one when another project holds it. A title naming no folder, such as one in
|
|
39158
|
+
* a script a name cannot hold, or one naming the folder it is in, keeps the
|
|
39159
|
+
* folder. A blank title takes the key out, so readers show the folder again.
|
|
39160
|
+
* The title goes in first under the old folder and the move follows, which
|
|
39161
|
+
* the board's undo reverses in turn. The times are put back as a filing's
|
|
39162
|
+
* are, since a title draws nothing.
|
|
39163
|
+
*/
|
|
39164
|
+
async function retitleProject(root, name, title, { journal } = {}) {
|
|
39165
|
+
const project = await resolveProject(root, name);
|
|
39166
|
+
const path = join(project.path, PROJECT_FILE);
|
|
39167
|
+
const trimmed = title.trim();
|
|
39168
|
+
if (trimmed.length > 256) throw new FrameboardError("invalid-name", `A project title holds at most 256 characters.`, { title: trimmed });
|
|
39169
|
+
await keepingTimes([path], (keep) => withLocks([path], async () => {
|
|
39170
|
+
const file = await readRecord(path, {
|
|
39171
|
+
...projectSpec,
|
|
39172
|
+
empty: emptyProject
|
|
39173
|
+
});
|
|
39174
|
+
const { title: _title, ...rest } = file;
|
|
39175
|
+
const next = trimmed === "" ? rest : {
|
|
39176
|
+
...rest,
|
|
39177
|
+
title: trimmed
|
|
39178
|
+
};
|
|
39179
|
+
const before = filingOf(file);
|
|
39180
|
+
const after = filingOf(next);
|
|
39181
|
+
if (isSameFiling(before, after)) return;
|
|
39182
|
+
await keep(path);
|
|
39183
|
+
await writeRecord(path, next);
|
|
39184
|
+
journal?.project(path, before, after);
|
|
39185
|
+
}));
|
|
39186
|
+
const moved = titledFolder(project.name, trimmed, await listProjects(root));
|
|
39187
|
+
if (moved === project.name) return scanProject(root, project.name);
|
|
39188
|
+
const target = join(root, moved);
|
|
39189
|
+
if (journal) await journal.moved(project.path, target);
|
|
39190
|
+
else await rename(project.path, target);
|
|
39191
|
+
return scanProject(root, moved);
|
|
39192
|
+
}
|
|
39193
|
+
/**
|
|
38866
39194
|
* A copy of the project under the next free name, without its notes, and
|
|
38867
39195
|
* stamped as made `now`.
|
|
38868
39196
|
*/
|
|
@@ -38948,11 +39276,12 @@ function filingOf(file) {
|
|
|
38948
39276
|
return {
|
|
38949
39277
|
...file.group === void 0 ? {} : { group: file.group },
|
|
38950
39278
|
...file.archived === void 0 ? {} : { archived: file.archived },
|
|
39279
|
+
...file.title === void 0 ? {} : { title: file.title },
|
|
38951
39280
|
...off === void 0 ? {} : { off }
|
|
38952
39281
|
};
|
|
38953
39282
|
}
|
|
38954
39283
|
function isSameFiling(a, b) {
|
|
38955
|
-
return a.group === b.group && a.archived === b.archived && isDeepStrictEqual(a.off, b.off);
|
|
39284
|
+
return a.group === b.group && a.archived === b.archived && a.title === b.title && isDeepStrictEqual(a.off, b.off);
|
|
38956
39285
|
}
|
|
38957
39286
|
/**
|
|
38958
39287
|
* Turns one check rule off for the project, or back on, by adding or removing
|
|
@@ -39017,13 +39346,14 @@ function isRecord$3(value) {
|
|
|
39017
39346
|
/**
|
|
39018
39347
|
* Runs `run`, a section holding the lock of each project file it writes, and
|
|
39019
39348
|
* puts back the times that file and its folder held, which the scanner reads
|
|
39020
|
-
* as the project's last edit. `
|
|
39349
|
+
* as the project's last edit. `land` names where a file stands once `run`
|
|
39350
|
+
* is done, for a run that moves its folder, and the times go back there. `run` calls `keep` under the lock before each
|
|
39021
39351
|
* write, so the file's time is read after any writer that held the lock first.
|
|
39022
39352
|
* The folder's time is read before the lock, since taking and dropping the
|
|
39023
39353
|
* lock moves it, and goes back only where the file kept its time until `keep`,
|
|
39024
39354
|
* so a writer that ran in between keeps the Edited time it earned.
|
|
39025
39355
|
*/
|
|
39026
|
-
async function keepingTimes(files, run) {
|
|
39356
|
+
async function keepingTimes(files, run, land = (file) => file) {
|
|
39027
39357
|
const before = new Map(await Promise.all(files.map(async (file) => [file, {
|
|
39028
39358
|
file: await stat(file).catch(() => void 0),
|
|
39029
39359
|
folder: await stat(dirname(file)).catch(() => void 0)
|
|
@@ -39038,9 +39368,10 @@ async function keepingTimes(files, run) {
|
|
|
39038
39368
|
return await run(keep);
|
|
39039
39369
|
} finally {
|
|
39040
39370
|
await Promise.all([...kept].map(async ([file, time]) => {
|
|
39041
|
-
|
|
39371
|
+
const at = land(file);
|
|
39372
|
+
await put(at, time);
|
|
39042
39373
|
const { file: was, folder } = before.get(file) ?? {};
|
|
39043
|
-
if (folder && was?.mtimeMs === time.mtimeMs) await put(dirname(
|
|
39374
|
+
if (folder && was?.mtimeMs === time.mtimeMs) await put(dirname(at), folder);
|
|
39044
39375
|
}));
|
|
39045
39376
|
}
|
|
39046
39377
|
}
|
|
@@ -39420,7 +39751,7 @@ async function restore(change, side) {
|
|
|
39420
39751
|
return;
|
|
39421
39752
|
}
|
|
39422
39753
|
case "project": {
|
|
39423
|
-
const { group: _group, archived: _archived, ...rest } = await readRecord(change.file, projectSpec);
|
|
39754
|
+
const { group: _group, archived: _archived, title: _title, ...rest } = await readRecord(change.file, projectSpec);
|
|
39424
39755
|
const { off, ...filing } = change[side];
|
|
39425
39756
|
await writeRecord(change.file, withOff({
|
|
39426
39757
|
...rest,
|
|
@@ -39812,19 +40143,26 @@ var History = class {
|
|
|
39812
40143
|
const step = from.pop();
|
|
39813
40144
|
if (!step) throw empty();
|
|
39814
40145
|
const was = to === "before" ? "after" : "before";
|
|
40146
|
+
const standing = step.changes.map((change, index) => standingAt(change, step.changes.slice(index + 1), was));
|
|
39815
40147
|
const hashes = {};
|
|
39816
|
-
const
|
|
39817
|
-
const
|
|
40148
|
+
const moves = step.changes.flatMap((change) => change.kind === "moved" ? [change.from, change.to] : []);
|
|
40149
|
+
const locks = standing.flatMap(lockPaths).filter((path) => existsSync(dirname(path))).filter((path) => !moves.some((folder) => path.startsWith(folder + sep)));
|
|
40150
|
+
const landing = new Map(standing.flatMap((change, index) => change.kind === "project" ? [[change.file, standingAt(step.changes[index] ?? change, step.changes.slice(index + 1), to)]] : []));
|
|
40151
|
+
const timed = [...landing.keys()];
|
|
40152
|
+
const landed = (file) => {
|
|
40153
|
+
const change = landing.get(file);
|
|
40154
|
+
return change?.kind === "project" ? change.file : file;
|
|
40155
|
+
};
|
|
39818
40156
|
try {
|
|
39819
40157
|
await keepingTimes(timed, (keep) => withLocks(locks, async () => {
|
|
39820
|
-
for (const change of
|
|
40158
|
+
for (const change of standing) if (!await holds(change, was)) throw new FrameboardError("undo-overtaken", `An agent changed ${nameOf(change)} after your edit, so that step was dropped.`, { change: change.kind });
|
|
39821
40159
|
for (const file of timed) await keep(file);
|
|
39822
40160
|
const ordered = to === "before" ? [...step.changes].reverse() : step.changes;
|
|
39823
40161
|
for (const change of ordered) {
|
|
39824
40162
|
const hash = await restore(change, to);
|
|
39825
40163
|
if (hash !== void 0 && "ref" in change) hashes[change.ref] = hash;
|
|
39826
40164
|
}
|
|
39827
|
-
}));
|
|
40165
|
+
}), landed);
|
|
39828
40166
|
} catch (error) {
|
|
39829
40167
|
if (!(error instanceof FrameboardError && error.code === "undo-overtaken")) from.push(step);
|
|
39830
40168
|
this.onChange(this.counts());
|
|
@@ -39848,6 +40186,24 @@ var History = class {
|
|
|
39848
40186
|
return run;
|
|
39849
40187
|
}
|
|
39850
40188
|
};
|
|
40189
|
+
/**
|
|
40190
|
+
* The change as the board stands at `side`, reading a project file where the
|
|
40191
|
+
* moves `later` in its step left it on the after side, since a retitle writes
|
|
40192
|
+
* the file under the old folder and then moves the folder. Restoring keeps the
|
|
40193
|
+
* recorded path, since the moves are undone first and redone last.
|
|
40194
|
+
*/
|
|
40195
|
+
function standingAt(change, later, side) {
|
|
40196
|
+
if (side === "before" || change.kind !== "project") return change;
|
|
40197
|
+
let file = change.file;
|
|
40198
|
+
for (const each of later) {
|
|
40199
|
+
if (each.kind !== "moved") continue;
|
|
40200
|
+
if (file.startsWith(each.from + sep)) file = each.to + file.slice(each.from.length);
|
|
40201
|
+
}
|
|
40202
|
+
return file === change.file ? change : {
|
|
40203
|
+
...change,
|
|
40204
|
+
file
|
|
40205
|
+
};
|
|
40206
|
+
}
|
|
39851
40207
|
/** What a refusal names as overtaken, being a frame, a section, a page, the slide transition, the page order, or a filed project. */
|
|
39852
40208
|
function nameOf(change) {
|
|
39853
40209
|
if (change.kind === "entry") return change.frame;
|
|
@@ -40423,69 +40779,13 @@ const recolorSchema = object$1({
|
|
|
40423
40779
|
* A hand edit of one element, a placed element, and a deleted one, each behind
|
|
40424
40780
|
* `requireWriter` and refused on a frame another session holds.
|
|
40425
40781
|
*
|
|
40426
|
-
*
|
|
40427
|
-
* `
|
|
40428
|
-
*
|
|
40429
|
-
*
|
|
40430
|
-
*
|
|
40431
|
-
*
|
|
40432
|
-
*
|
|
40433
|
-
* writer returns answers 409 with its code, `stale-address` among them.
|
|
40434
|
-
* Given `edits` in place of `index` and `change`, it writes each as one
|
|
40435
|
-
* write and one step, refused whole on any refusal, and answers `indexes` in
|
|
40436
|
-
* the order sent, `index` being the last.
|
|
40437
|
-
*
|
|
40438
|
-
* The insert takes an element kind, never markup, and writes that kind's one
|
|
40439
|
-
* tag into the gap `parent` and `before` name, painted from the project's
|
|
40440
|
-
* tokens through `sheets`, and records it as one step. It answers the frame,
|
|
40441
|
-
* the new element's index, and the hash written. A hash the file no longer
|
|
40442
|
-
* has answers 409 `stale-address` with nothing written, since the gap's
|
|
40443
|
-
* indices name nothing past an agent's write, and a retried insert lands once.
|
|
40444
|
-
* A rectangle or an ellipse takes an optional width and height a drag drew.
|
|
40445
|
-
* Given `at`, the element lands out of the flow there in the same write and
|
|
40446
|
-
* step, placed as the place below places one, a text's margin set to zero,
|
|
40447
|
-
* and refused as the place refuses, save that `orFlow` joins the flow instead
|
|
40448
|
-
* of refusing `reanchors-descendant`. Without `at`, the element joins the flow.
|
|
40449
|
-
* An asset names a file under the project's `assets/` and the size it
|
|
40450
|
-
* shows at, and the server picks its tag from the file's kind. A file
|
|
40451
|
-
* outside that folder or not there answers 409 `asset-missing`, and one that
|
|
40452
|
-
* is no image, GIF, SVG, video, or audio `asset-not-placeable`, each writing
|
|
40453
|
-
* nothing.
|
|
40454
|
-
*
|
|
40455
|
-
* The remove takes out the element at `index`, with what it holds, from the
|
|
40456
|
-
* bytes `hash` names, and records it as one step whose undo puts it back
|
|
40457
|
-
* under its parent. It answers the frame and the hash written, and refuses a
|
|
40458
|
-
* moved file as `stale-address` the way the insert does. Given `indexes` in
|
|
40459
|
-
* place of `index`, it takes out each as one write and one step, one held
|
|
40460
|
-
* inside another named going with that one, refused whole on any refusal.
|
|
40461
|
-
*
|
|
40462
|
-
* The move takes one element by index and the gap it goes into, both read
|
|
40463
|
-
* in the frame as the hash names it, and records it as one step an undo
|
|
40464
|
-
* puts back byte for byte. It answers the element's new index and the hash
|
|
40465
|
-
* written, and refuses as the insert does, with `invalid-container` for a
|
|
40466
|
-
* gap inside the element itself.
|
|
40467
|
-
*
|
|
40468
|
-
* The place takes one element by index and a spot in CSS pixels against its
|
|
40469
|
-
* containing block, or null to put it back in the flow, read in the frame as
|
|
40470
|
-
* the hash names it, with `drop` naming the sizes back in flow takes off. It
|
|
40471
|
-
* writes the element's start tag, and its static parent's first, and records
|
|
40472
|
-
* both as one step, so one undo restores both. It answers the element's
|
|
40473
|
-
* index, the hash written, and the sizes a placement wrote, refuses as the move
|
|
40474
|
-
* does, and refuses `reanchors-descendant` where a positioned parent would
|
|
40475
|
-
* move another element anchored above it. Given `places` in place of
|
|
40476
|
-
* `index`, `spot`, and `drop`, it places each as one write and one step,
|
|
40477
|
-
* refused whole on any refusal, and answers `placed` in the order sent.
|
|
40478
|
-
*
|
|
40479
|
-
* The recolor writes the color token `to` in place of the raw color `from`
|
|
40480
|
-
* on every element under `index`, or under the frame's body without one,
|
|
40481
|
-
* that states it inline, rule-set values left as they are, and records every
|
|
40482
|
-
* rewritten start tag as one step. It answers the hash written and how many
|
|
40483
|
-
* elements it rewrote, zero writing and recording nothing. A `to` the
|
|
40484
|
-
* project's color tokens do not hold answers 409 `unknown-token`, and a
|
|
40485
|
-
* moved file `stale-address`, each writing nothing.
|
|
40486
|
-
*
|
|
40487
|
-
* Each landed write carries the notes pinned on the frame's elements to the
|
|
40488
|
-
* bytes it wrote, through the writer's remap, so a pin stays on its element.
|
|
40782
|
+
* Every write names the frame by the `hash` the board rendered and goes through
|
|
40783
|
+
* `editFrameFile`, which finds the element again in a frame an agent wrote
|
|
40784
|
+
* since and records the span as one undoable step. A refusal answers 409 with
|
|
40785
|
+
* its code, such as `stale-address`, and writes nothing. A batch field
|
|
40786
|
+
* (`edits`, `indexes`, `places`) writes each item as one step and is refused
|
|
40787
|
+
* whole on any refusal. An insert takes an element kind, never markup, and a
|
|
40788
|
+
* recolor rewrites inline colors only. Each write remaps pinned notes.
|
|
40489
40789
|
*/
|
|
40490
40790
|
function editRoutes(root, access, history, version, sheets) {
|
|
40491
40791
|
const app = new Hono();
|
|
@@ -41424,24 +41724,15 @@ const CONTENT_TYPES$1 = {
|
|
|
41424
41724
|
".m4a": "audio/mp4"
|
|
41425
41725
|
};
|
|
41426
41726
|
/**
|
|
41427
|
-
* Serves `/frames/<project>/<page>/<file
|
|
41428
|
-
* from the board, so a frame's relative
|
|
41429
|
-
*
|
|
41430
|
-
*
|
|
41431
|
-
*
|
|
41432
|
-
*
|
|
41433
|
-
*
|
|
41434
|
-
*
|
|
41435
|
-
*
|
|
41436
|
-
* A frame served from a page gets the faces and the token sheets spliced
|
|
41437
|
-
* first into its `head`, in the response alone, and is never cached. Every
|
|
41438
|
-
* other file is served byte for byte under a validator the browser checks on
|
|
41439
|
-
* each use, so an edit shows on the next load and an unchanged file answers
|
|
41440
|
-
* 304 with no body. A frame path carrying `?at=<hash>` serves the
|
|
41441
|
-
* version `version` holds under that hash in its place, with the same head,
|
|
41442
|
-
* and any other path carrying it answers 404. `base` prefixes the sheet URLs
|
|
41443
|
-
* the head imports, for a listener serving these routes under a path of its
|
|
41444
|
-
* own, since the head names them from the server's root.
|
|
41727
|
+
* Serves `/frames/<project>/<page>/<file>`, `/frames/<project>/assets/<path>`,
|
|
41728
|
+
* and `/frames/<project>/tokens.css` from the board, so a frame's relative
|
|
41729
|
+
* links resolve with no rewriting. It is a handler of its own rather than
|
|
41730
|
+
* static serving, since it must refuse board records, dot-named paths, and any
|
|
41731
|
+
* path whose realpath leaves its project. Every refusal answers 404, so
|
|
41732
|
+
* nothing tells a caller what exists. A frame gets the faces and token sheets
|
|
41733
|
+
* spliced into its `head`, in the response alone and never cached. Any other
|
|
41734
|
+
* file is served byte for byte under a validator, and `?at=<hash>` serves the
|
|
41735
|
+
* version `version` holds. `base` prefixes the head's sheet URLs.
|
|
41445
41736
|
*/
|
|
41446
41737
|
function frameRoutes(root, look, version, base = "") {
|
|
41447
41738
|
const app = new Hono();
|
|
@@ -41712,7 +42003,7 @@ const START_WINDOW_MS = 2e3;
|
|
|
41712
42003
|
*/
|
|
41713
42004
|
function createDispatcher({ command, cwd, root, env, windowMs = START_WINDOW_MS }) {
|
|
41714
42005
|
return async ({ session, id, line }) => {
|
|
41715
|
-
const log = await open(join(await ensureRunFolder(root), DISPATCH_LOG), "a");
|
|
42006
|
+
const log = await open$1(join(await ensureRunFolder(root), DISPATCH_LOG), "a");
|
|
41716
42007
|
try {
|
|
41717
42008
|
await started(spawn("sh", ["-c", command], {
|
|
41718
42009
|
cwd,
|
|
@@ -41876,22 +42167,12 @@ const sendSchema = object$1({
|
|
|
41876
42167
|
/**
|
|
41877
42168
|
* The board's note writes, each behind `requireWriter`: pin a note, reply in
|
|
41878
42169
|
* its thread, send it to a listening session, and mark it done. Each answers
|
|
41879
|
-
* the CLI's `{ ok, data }` envelope
|
|
41880
|
-
*
|
|
41881
|
-
*
|
|
41882
|
-
*
|
|
41883
|
-
*
|
|
41884
|
-
*
|
|
41885
|
-
* root delivered to it, so the started session's inbox never prints it a
|
|
41886
|
-
* second time. A failed start takes back the message the request added, and
|
|
41887
|
-
* no `dispatch` refuses before anything is written.
|
|
41888
|
-
*
|
|
41889
|
-
* A note's images go up first, as multipart `files` with the `page` ref, to
|
|
41890
|
-
* `/api/notes/images`, which saves them to the page's `.notes/` and answers
|
|
41891
|
-
* their page-relative paths for pin and reply to carry. A write naming an
|
|
41892
|
-
* image its page does not hold is refused. `/api/note-images/...` reads one
|
|
41893
|
-
* back with no writer check, as the frames route reads a page's files, since
|
|
41894
|
-
* an `<img>` sends no `Origin`.
|
|
42170
|
+
* the CLI's `{ ok, data }` envelope, and a refusal its `{ ok, error }`. Pin,
|
|
42171
|
+
* reply, and send take `dispatch: true` in place of `to`, which starts a
|
|
42172
|
+
* session through `dispatch` and marks the thread's root delivered to it, and
|
|
42173
|
+
* a failed start takes back the message the request added. Images go up first
|
|
42174
|
+
* to `/api/notes/images`, and `/api/note-images/...` reads one back with no
|
|
42175
|
+
* writer check, since an `<img>` sends no `Origin`.
|
|
41895
42176
|
*/
|
|
41896
42177
|
function notesRoutes(root, access, delivery, dispatch, imageLimit = ASSET_BODY_LIMIT) {
|
|
41897
42178
|
const app = new Hono();
|
|
@@ -42085,20 +42366,14 @@ const STATUS = {
|
|
|
42085
42366
|
const DEFAULT_SCALE = 2;
|
|
42086
42367
|
/**
|
|
42087
42368
|
* `GET /api/frames/png?ref=<frame-ref>&theme=<light|dark>&scale=<1|2|3>`, a
|
|
42088
|
-
* frame rendered at `scale` times its layout size, twice when
|
|
42089
|
-
*
|
|
42090
|
-
*
|
|
42091
|
-
* `
|
|
42092
|
-
* `
|
|
42093
|
-
*
|
|
42094
|
-
*
|
|
42095
|
-
*
|
|
42096
|
-
* hash is no longer `hash`, and 422 `invalid-address` for an index naming
|
|
42097
|
-
* no element or one with no layout box. The three additions exclude each
|
|
42098
|
-
* other, and `element` without `hash` is no address, each refusing as
|
|
42099
|
-
* `usage`. It takes no token, since the image shows only
|
|
42100
|
-
* what the frame route already serves, and a refusal answers the CLI's
|
|
42101
|
-
* `{ ok, error }` envelope.
|
|
42369
|
+
* frame rendered at `scale` times its layout size, twice when none is given.
|
|
42370
|
+
* Three additions each change what is drawn and exclude each other, each
|
|
42371
|
+
* refusing as `usage`: `filmstrip=<n>` renders `n` moments of the timeline in
|
|
42372
|
+
* one row, `device=1` draws a frame's device inside its body, and
|
|
42373
|
+
* `element=<index>&hash=<hash>` renders that one element alone on a
|
|
42374
|
+
* transparent ground, refusing a moved file as 409 `stale-address`. It takes
|
|
42375
|
+
* no token, since the image shows only what the frame route already serves,
|
|
42376
|
+
* and a refusal answers the CLI's `{ ok, error }` envelope.
|
|
42102
42377
|
*/
|
|
42103
42378
|
function pngRoutes(root, render, renderFilmstrip) {
|
|
42104
42379
|
const app = new Hono();
|
|
@@ -42414,6 +42689,74 @@ async function sectionRecord(root, page, name) {
|
|
|
42414
42689
|
if (!section) throw new Error(`Section ${name} vanished from ${page.name}.`);
|
|
42415
42690
|
return section;
|
|
42416
42691
|
}
|
|
42692
|
+
// src/server/checks/board-routes.ts
|
|
42693
|
+
const BOARD_ROUTE_RULES = [{
|
|
42694
|
+
id: "board-route",
|
|
42695
|
+
tier: "exact",
|
|
42696
|
+
severity: "error",
|
|
42697
|
+
description: "A frame's scripts and event handlers name no path under /api/, which on the board's origin reaches the board's own server"
|
|
42698
|
+
}];
|
|
42699
|
+
const finding$11 = findingFor(BOARD_ROUTE_RULES);
|
|
42700
|
+
/**
|
|
42701
|
+
* A quoted string or template literal opening on `/api/`, bare or after a
|
|
42702
|
+
* scheme and host, so a URL in code matches and prose in a comment does not.
|
|
42703
|
+
* A path the script builds at runtime, such as `'/ap' + 'i/'`, passes, since
|
|
42704
|
+
* the rule catches a mistake rather than a deliberate call.
|
|
42705
|
+
*/
|
|
42706
|
+
const BOARD_ROUTE = /(['"`])((?:(?:[a-z][a-z0-9+.-]*:)?\/\/[^/'"`\s]*)?\/api\/[^'"`\n]*)\1/gi;
|
|
42707
|
+
/**
|
|
42708
|
+
* `board-route`, one finding per string naming a board route in a frame's
|
|
42709
|
+
* scripts, inline or local, and in its `on*` event handler attributes.
|
|
42710
|
+
*/
|
|
42711
|
+
function checkBoardRoutes(source) {
|
|
42712
|
+
return frameCode(source).flatMap((code) => [...code.text.matchAll(BOARD_ROUTE)].map((match) => {
|
|
42713
|
+
const start = code.offset === null ? null : code.offset + match.index;
|
|
42714
|
+
return finding$11("board-route", {
|
|
42715
|
+
frame: source.ref,
|
|
42716
|
+
path: boardPath(source.root, code.path),
|
|
42717
|
+
message: `${code.via} names ${match[2]}, a route of the board's own server, which a frame on the board's origin reaches. Mock an app's calls with data kept in the script, or list board-route in the project's checks.off if its frames mean to call /api/.`,
|
|
42718
|
+
location: start === null ? code.at : locate$1(code.file, start, start + match[0].length)
|
|
42719
|
+
});
|
|
42720
|
+
}));
|
|
42721
|
+
}
|
|
42722
|
+
/**
|
|
42723
|
+
* Whether a browser runs the script, as it does for no `type`, `module`, or a
|
|
42724
|
+
* JavaScript type. A JSON, import map, or template block is data, which the
|
|
42725
|
+
* rule's own message names as the way to mock an app's calls.
|
|
42726
|
+
*/
|
|
42727
|
+
function runs(element) {
|
|
42728
|
+
const type = (element.attribs.type ?? "").trim().toLowerCase();
|
|
42729
|
+
return type === "" || type === "module" || /^(?:application|text)\/(?:x-)?(?:java|ecma)script$/.test(type);
|
|
42730
|
+
}
|
|
42731
|
+
function frameCode(source) {
|
|
42732
|
+
const code = [];
|
|
42733
|
+
for (const element of source.elements) {
|
|
42734
|
+
if (element.name === "script" && runs(element)) {
|
|
42735
|
+
const script = scriptSource(element, source);
|
|
42736
|
+
if (script) {
|
|
42737
|
+
const inline = element.attribs.src === void 0;
|
|
42738
|
+
code.push({
|
|
42739
|
+
...script,
|
|
42740
|
+
file: inline ? source.html : script.text,
|
|
42741
|
+
at: null,
|
|
42742
|
+
via: inline ? "A <script>" : `The script ${element.attribs.src}`
|
|
42743
|
+
});
|
|
42744
|
+
}
|
|
42745
|
+
}
|
|
42746
|
+
for (const [name, value] of Object.entries(element.attribs)) {
|
|
42747
|
+
if (!name.startsWith("on")) continue;
|
|
42748
|
+
code.push({
|
|
42749
|
+
text: value,
|
|
42750
|
+
path: source.path,
|
|
42751
|
+
offset: null,
|
|
42752
|
+
file: source.html,
|
|
42753
|
+
at: attributeLocation(element, name),
|
|
42754
|
+
via: `The ${name} handler on <${element.name}>`
|
|
42755
|
+
});
|
|
42756
|
+
}
|
|
42757
|
+
}
|
|
42758
|
+
return code;
|
|
42759
|
+
}
|
|
42417
42760
|
// src/server/checks/browser/contrast.ts
|
|
42418
42761
|
const CONTRAST_RULES = [{
|
|
42419
42762
|
id: "min-contrast",
|
|
@@ -43005,16 +43348,10 @@ async function platformFamilies(page, domIndexes) {
|
|
|
43005
43348
|
* Waits, within `timeoutMs`, until every `<img>` in the frame has loaded and
|
|
43006
43349
|
* decoded, so an image marked `decoding="async"` never shoots as an empty
|
|
43007
43350
|
* box. A lazy image is made eager in the loaded page first, never in the
|
|
43008
|
-
* file
|
|
43009
|
-
*
|
|
43010
|
-
*
|
|
43011
|
-
*
|
|
43012
|
-
* the board shows it.
|
|
43013
|
-
*
|
|
43014
|
-
* `stalled` reads a page whose load event never fired, refusing only for an
|
|
43015
|
-
* image that failed or whose request is still open. A loaded image still
|
|
43016
|
-
* decoding cannot have held the load, so something else, such as a
|
|
43017
|
-
* stylesheet or an iframe, did.
|
|
43351
|
+
* file. Under `require` an image that errored or is still loading at the
|
|
43352
|
+
* deadline refuses `image-missing`, and under `wait` the frame opens as the
|
|
43353
|
+
* board shows it. `stalled` reads a page whose load event never fired, and
|
|
43354
|
+
* refuses only for an image that failed or whose request is still open.
|
|
43018
43355
|
*/
|
|
43019
43356
|
async function settleImages(page, ref, mode, timeoutMs, { stalled = false } = {}) {
|
|
43020
43357
|
const unsettled = await page.evaluate(waitForImages, Math.max(0, timeoutMs));
|
|
@@ -43450,12 +43787,13 @@ async function shootElement(page, ref, index, scale) {
|
|
|
43450
43787
|
* page the size of the body, so the PNG holds the body and nothing past it.
|
|
43451
43788
|
*/
|
|
43452
43789
|
async function drawBezel(browser, shot, box, device, scale) {
|
|
43453
|
-
const {
|
|
43790
|
+
const { screenRadius } = BEZELS[device];
|
|
43454
43791
|
const outer = bezelBox({
|
|
43455
43792
|
x: 0,
|
|
43456
43793
|
y: 0,
|
|
43457
43794
|
...box
|
|
43458
43795
|
}, device);
|
|
43796
|
+
const laptop = device === "laptop";
|
|
43459
43797
|
const context = await browser.newContext({
|
|
43460
43798
|
viewport: {
|
|
43461
43799
|
width: outer.width,
|
|
@@ -43465,8 +43803,9 @@ async function drawBezel(browser, shot, box, device, scale) {
|
|
|
43465
43803
|
});
|
|
43466
43804
|
try {
|
|
43467
43805
|
const page = await context.newPage();
|
|
43468
|
-
const marks = device === "phone" ? `<span style="${pill(PHONE_ISLAND.width, PHONE_ISLAND.height, BEZEL_COLORS.island)}top:${PHONE_ISLAND.top}px"></span><span style="${pill(HOME_BAR.width, HOME_BAR.height, BEZEL_COLORS.homeBar)}bottom:${HOME_BAR.bottom}px"></span>` : "";
|
|
43469
|
-
|
|
43806
|
+
const marks = device === "phone" ? `<span style="${pill(PHONE_ISLAND.width, PHONE_ISLAND.height, BEZEL_COLORS.island)}top:${PHONE_ISLAND.top}px"></span><span style="${pill(HOME_BAR.width, HOME_BAR.height, BEZEL_COLORS.homeBar)}bottom:${HOME_BAR.bottom}px"></span>` : laptop ? laptopMarks(box) : "";
|
|
43807
|
+
const radius = laptop ? `${screenRadius}px ${screenRadius}px 0 0` : `${screenRadius}px`;
|
|
43808
|
+
await page.setContent(`<!doctype html><html><body style="margin:0;background:transparent"><div style="position:absolute;left:${-outer.x}px;top:${-outer.y}px;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="display:block;width:100%;height:100%"><div style="position:absolute;inset:0;border-radius:${radius};box-shadow:${bezelShadow(device, { board: false })}">${marks}</div></div></body></html>`, { waitUntil: "load" });
|
|
43470
43809
|
return await page.screenshot({
|
|
43471
43810
|
omitBackground: true,
|
|
43472
43811
|
caret: "hide"
|
|
@@ -43475,6 +43814,15 @@ async function drawBezel(browser, shot, box, device, scale) {
|
|
|
43475
43814
|
await context.close();
|
|
43476
43815
|
}
|
|
43477
43816
|
}
|
|
43817
|
+
/**
|
|
43818
|
+
* The laptop's chin and base as the board draws them, past the screen's
|
|
43819
|
+
* bottom, with the body's edge as its last pixel rather than past it.
|
|
43820
|
+
*/
|
|
43821
|
+
function laptopMarks(box) {
|
|
43822
|
+
const { chin, base } = laptopParts(box);
|
|
43823
|
+
const edge = `1px solid ${BEZEL_COLORS.edge}`;
|
|
43824
|
+
return `<span style="position:absolute;box-sizing:border-box;left:${chin.x}px;top:${chin.y}px;width:${chin.width}px;height:${chin.height}px;background:${BEZEL_COLORS.body};border-left:${edge};border-right:${edge}"></span><span style="position:absolute;box-sizing:border-box;left:${base.x}px;top:${base.y}px;width:${base.width}px;height:${base.height}px;background:${BEZEL_COLORS.base};border:${edge};border-radius:0 0 ${LAPTOP_BASE.radius}px ${LAPTOP_BASE.radius}px"></span>`;
|
|
43825
|
+
}
|
|
43478
43826
|
function pill(width, height, color) {
|
|
43479
43827
|
return `position:absolute;left:50%;transform:translateX(-50%);width:${width}px;height:${height}px;border-radius:${height / 2}px;background:${color};`;
|
|
43480
43828
|
}
|
|
@@ -43486,15 +43834,10 @@ const HUG_MAX_WIDTH = FRAME_SIZES.desktop.width;
|
|
|
43486
43834
|
* both read it, in one page resized between readings. A hugging width takes
|
|
43487
43835
|
* the content's `fit-content` width up to `HUG_MAX_WIDTH`, and the height is
|
|
43488
43836
|
* read at that width with a 1 px tall viewport and again at the reference
|
|
43489
|
-
* height
|
|
43490
|
-
*
|
|
43491
|
-
*
|
|
43492
|
-
*
|
|
43493
|
-
* page then loads at the width and height it would answer, and content
|
|
43494
|
-
* drawing another height there, as a block sized once off the window height,
|
|
43495
|
-
* refuses the same way. Finite
|
|
43496
|
-
* animations finish before the first reading, so an entrance is read at its
|
|
43497
|
-
* settled size.
|
|
43837
|
+
* height, never the box's own, so content sized off the window height reads
|
|
43838
|
+
* one height however tall the frame already is. Readings that differ, or a
|
|
43839
|
+
* fresh page drawing another height, mean the content sizes itself off the
|
|
43840
|
+
* viewport and refuse `fit-unbounded`. Finite animations finish first.
|
|
43498
43841
|
*/
|
|
43499
43842
|
async function measureContent(browser, { baseUrl, ref, box, hugWidth, fonts }) {
|
|
43500
43843
|
const reference = referenceHeight(box.width);
|
|
@@ -43680,7 +44023,7 @@ function readContentSize() {
|
|
|
43680
44023
|
};
|
|
43681
44024
|
const hangOf = (lineHeight, height) => lineHeight < height ? (height - lineHeight) / 2 : 0;
|
|
43682
44025
|
const textBottom = (element) => {
|
|
43683
|
-
let bottom = -
|
|
44026
|
+
let bottom = -1e400;
|
|
43684
44027
|
if (crops(element)) return bottom;
|
|
43685
44028
|
const lineHeight = parseFloat(getComputedStyle(element).lineHeight);
|
|
43686
44029
|
for (const child of element.childNodes) {
|
|
@@ -43865,8 +44208,8 @@ function readLayout() {
|
|
|
43865
44208
|
};
|
|
43866
44209
|
const hangOf = (lineHeight, height) => lineHeight < height ? (height - lineHeight) / 2 : 0;
|
|
43867
44210
|
const textReach = (element) => {
|
|
43868
|
-
let bottom = -
|
|
43869
|
-
let right = -
|
|
44211
|
+
let bottom = -1e400;
|
|
44212
|
+
let right = -1e400;
|
|
43870
44213
|
if (crops(element)) return {
|
|
43871
44214
|
bottom,
|
|
43872
44215
|
right
|
|
@@ -43915,7 +44258,7 @@ function readLayout() {
|
|
|
43915
44258
|
if (node === root || node === document.body || !document.body.contains(node)) continue;
|
|
43916
44259
|
const rect = node.getBoundingClientRect();
|
|
43917
44260
|
const text = textReach(node);
|
|
43918
|
-
if (rect.width === 0 && rect.height === 0 && text.right === -
|
|
44261
|
+
if (rect.width === 0 && rect.height === 0 && text.right === -1e400) continue;
|
|
43919
44262
|
const tag = node.tagName.toLowerCase();
|
|
43920
44263
|
boxes.push({
|
|
43921
44264
|
index: own,
|
|
@@ -44121,25 +44464,6 @@ function bareVars(value) {
|
|
|
44121
44464
|
function scriptWrites(text) {
|
|
44122
44465
|
return SCRIPT_WRITES.flatMap((pattern) => [...text.matchAll(pattern)].map((match) => match.at(-1) ?? ""));
|
|
44123
44466
|
}
|
|
44124
|
-
/**
|
|
44125
|
-
* A script's inline text, or its `src` file's when the file sits in the
|
|
44126
|
-
* board. A remote, outside, or unreadable `src` reads as empty, since the
|
|
44127
|
-
* write hook never reports a read as failed.
|
|
44128
|
-
*/
|
|
44129
|
-
function scriptText(element, source) {
|
|
44130
|
-
const src = element.attribs.src;
|
|
44131
|
-
if (src === void 0) return textOf(element);
|
|
44132
|
-
const file = localTarget(src, source.pageDir);
|
|
44133
|
-
if (!file || !isInside(source.root, file)) return "";
|
|
44134
|
-
try {
|
|
44135
|
-
return readFileSync(file, "utf8");
|
|
44136
|
-
} catch {
|
|
44137
|
-
return "";
|
|
44138
|
-
}
|
|
44139
|
-
}
|
|
44140
|
-
function textOf(element) {
|
|
44141
|
-
return element.children.map((node) => "data" in node ? node.data : "").join("");
|
|
44142
|
-
}
|
|
44143
44467
|
function parseOrNull(css) {
|
|
44144
44468
|
try {
|
|
44145
44469
|
return postcss_default.parse(css);
|
|
@@ -44677,6 +45001,7 @@ function checkFrameIn(target, { config, tokens }) {
|
|
|
44677
45001
|
...checkMalformedTags(source),
|
|
44678
45002
|
...checkNesting(source),
|
|
44679
45003
|
...checkLinks(source),
|
|
45004
|
+
...checkBoardRoutes(source),
|
|
44680
45005
|
...checkFonts(source, cascade, config),
|
|
44681
45006
|
...checkTheme(source),
|
|
44682
45007
|
...checkUnknownTokens(source, tokens),
|
|
@@ -44936,6 +45261,7 @@ function overlaps(a, b) {
|
|
|
44936
45261
|
const RULES = [
|
|
44937
45262
|
...STRUCTURE_RULES,
|
|
44938
45263
|
...LINK_RULES,
|
|
45264
|
+
...BOARD_ROUTE_RULES,
|
|
44939
45265
|
...FONT_RULES,
|
|
44940
45266
|
...THEME_RULES,
|
|
44941
45267
|
...CUSTOM_PROPERTY_RULES,
|
|
@@ -45040,6 +45366,11 @@ const renameSchema = object$1({
|
|
|
45040
45366
|
ref,
|
|
45041
45367
|
name
|
|
45042
45368
|
});
|
|
45369
|
+
/** Any characters, since the folder takes a valid name made from it, and the verb refuses a title past its limit. */
|
|
45370
|
+
const retitleSchema = object$1({
|
|
45371
|
+
ref,
|
|
45372
|
+
title: string$1().max(1024)
|
|
45373
|
+
});
|
|
45043
45374
|
const moveSchema = object$1({
|
|
45044
45375
|
ref,
|
|
45045
45376
|
index
|
|
@@ -45090,7 +45421,7 @@ const pasteSchema = object$1({
|
|
|
45090
45421
|
});
|
|
45091
45422
|
const frameDeviceSchema = object$1({
|
|
45092
45423
|
refs,
|
|
45093
|
-
|
|
45424
|
+
show: boolean$1()
|
|
45094
45425
|
});
|
|
45095
45426
|
/** More widths than any device list offers, so a body cannot grow without bound. */
|
|
45096
45427
|
const widthList = array$1(int$1().min(1)).max(64);
|
|
@@ -45461,10 +45792,10 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
45461
45792
|
data: frames
|
|
45462
45793
|
});
|
|
45463
45794
|
});
|
|
45464
|
-
/**
|
|
45795
|
+
/** Shows or hides the device each frame's width names, in one step, leaving every frame file alone. */
|
|
45465
45796
|
app.post("/api/frame/device", async (c) => {
|
|
45466
45797
|
const body = await parseBody$1(c.req.raw, frameDeviceSchema);
|
|
45467
|
-
const frames = await eachFrame(body.refs, (frame, journal) => setFrameDevice(root, frame, body.
|
|
45798
|
+
const frames = await eachFrame(body.refs, (frame, journal) => setFrameDevice(root, frame, body.show, {
|
|
45468
45799
|
cwd,
|
|
45469
45800
|
journal
|
|
45470
45801
|
}), (records) => records.map((record) => record.ref));
|
|
@@ -45690,6 +46021,22 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
45690
46021
|
data: project
|
|
45691
46022
|
});
|
|
45692
46023
|
});
|
|
46024
|
+
app.post("/api/project/title", async (c) => {
|
|
46025
|
+
const body = await parseBody$1(c.req.raw, retitleSchema);
|
|
46026
|
+
const source = await resolveProject(root, body.ref);
|
|
46027
|
+
await refuseHeld([source.name]);
|
|
46028
|
+
const project = await recorded((journal) => retitleProject(root, body.ref, body.title, { journal }), async (retitled) => ({
|
|
46029
|
+
...await onHome(),
|
|
46030
|
+
...retitled.name === source.name ? {} : { renamed: {
|
|
46031
|
+
before: source.name,
|
|
46032
|
+
after: retitled.name
|
|
46033
|
+
} }
|
|
46034
|
+
}));
|
|
46035
|
+
return c.json({
|
|
46036
|
+
ok: true,
|
|
46037
|
+
data: project
|
|
46038
|
+
});
|
|
46039
|
+
});
|
|
45693
46040
|
app.post("/api/project/duplicate", async (c) => {
|
|
45694
46041
|
const body = await parseBody$1(c.req.raw, projectSchema);
|
|
45695
46042
|
const project = await recorded((journal) => duplicateProject(root, body.ref, /* @__PURE__ */ new Date(), { journal }), onHome);
|
|
@@ -45846,21 +46193,14 @@ const editSchema = union([object$1({
|
|
|
45846
46193
|
reset: literal(true)
|
|
45847
46194
|
})]);
|
|
45848
46195
|
/**
|
|
45849
|
-
* The Theme tab's token write, behind `requireWriter`. `POST
|
|
45850
|
-
*
|
|
45851
|
-
*
|
|
45852
|
-
*
|
|
45853
|
-
*
|
|
45854
|
-
*
|
|
45855
|
-
*
|
|
45856
|
-
*
|
|
45857
|
-
* `stale-tokens` with nothing written, which also lands a retried edit once.
|
|
45858
|
-
* A name the sheets do not list, a value that is not one declaration, a
|
|
45859
|
-
* reset with no board value, and a sheet that does not parse answer 409
|
|
45860
|
-
* `invalid-edit`, as does a board edit that is a reset, names a token the
|
|
45861
|
-
* board sheet does not set, or meets a `--tokens` sheet outside the board
|
|
45862
|
-
* folder, which belongs to whatever handed it over. A landed edit records
|
|
45863
|
-
* one step and answers the token's values after it with the hash written.
|
|
46196
|
+
* The Theme tab's token write, behind `requireWriter`. `POST /api/tokens/edit`
|
|
46197
|
+
* sets one token the project's sheets list on one theme or both in the sheet
|
|
46198
|
+
* `sheet` names. `project`, the default, writes the project's `tokens.css`,
|
|
46199
|
+
* and a reset there takes its override back to the board's value. `board`
|
|
46200
|
+
* writes the board's sheet for a token it already sets. A stale `hash` answers
|
|
46201
|
+
* 409 `stale-tokens` and an invalid edit 409 `invalid-edit`, each writing
|
|
46202
|
+
* nothing. A landed edit records one step and answers the token's values and
|
|
46203
|
+
* the hash written.
|
|
45864
46204
|
*/
|
|
45865
46205
|
function tokenRoutes(root, access, history, look) {
|
|
45866
46206
|
const app = new Hono();
|
|
@@ -46246,7 +46586,7 @@ async function captureComposite(browser, { baseUrl, page, frames, themes, out, s
|
|
|
46246
46586
|
for (const theme of themes) {
|
|
46247
46587
|
const tiles = [];
|
|
46248
46588
|
const videos = /* @__PURE__ */ new Map();
|
|
46249
|
-
for (const frame of frames) for (const box of [frame.box, ...linkedBoxes(frame.box, frame.widths)]) {
|
|
46589
|
+
for (const frame of frames) for (const box of [frame.box, ...linkedBoxes(frame.box, frame.widths, frame.device)]) {
|
|
46250
46590
|
const { bytes, videos: unloaded } = await renderFrame(browser, baseUrl, frame, box, theme, scale);
|
|
46251
46591
|
for (const video of inFrame(frame.ref, unloaded)) videos.set(`${video.ref} ${video.index}`, video);
|
|
46252
46592
|
tiles.push(`<img src="data:image/png;base64,${bytes.toString("base64")}" style="position:absolute;left:${box.x + bounds.dx}px;top:${box.y + bounds.dy}px;width:${box.width}px;height:${box.height}px">`);
|
|
@@ -46498,7 +46838,7 @@ function registerCapture(program, context) {
|
|
|
46498
46838
|
cwd: io.cwd
|
|
46499
46839
|
};
|
|
46500
46840
|
const themes = options.theme === "both" ? THEMES : [options.theme];
|
|
46501
|
-
const outOf = async () => options.out ? resolve(io.cwd, options.out) : join(await ensureRunFolder(root), "captures");
|
|
46841
|
+
const outOf = async () => options.out ? resolve$1(io.cwd, options.out) : join(await ensureRunFolder(root), "captures");
|
|
46502
46842
|
if (options.page !== void 0) {
|
|
46503
46843
|
const page = await pageOf(root, options.page, refOptions);
|
|
46504
46844
|
const frames = page.frames.filter((frame) => !frame.hidden);
|
|
@@ -46840,7 +47180,9 @@ const frameRecordSchema = object$1({
|
|
|
46840
47180
|
width: number(),
|
|
46841
47181
|
height: number()
|
|
46842
47182
|
})),
|
|
46843
|
-
/**
|
|
47183
|
+
/** Whether the board draws the frame inside a device, absent when it does not. */
|
|
47184
|
+
showDevice: boolean$1().optional(),
|
|
47185
|
+
/** The device the frame's width names while it shows one, absent when off or under 320 wide. */
|
|
46844
47186
|
device: _enum$1(DEVICES).optional(),
|
|
46845
47187
|
/** The transition the frame arrives with in present mode, over its page's, absent when it holds none. */
|
|
46846
47188
|
transition: transitionRecordSchema.optional(),
|
|
@@ -46873,7 +47215,10 @@ const pageRecordSchema = object$1({
|
|
|
46873
47215
|
sections: array$1(sectionRecordSchema)
|
|
46874
47216
|
});
|
|
46875
47217
|
const projectRecordSchema = object$1({
|
|
47218
|
+
/** The folder, which every ref, URL, and CLI argument names the project by. */
|
|
46876
47219
|
name: string$1(),
|
|
47220
|
+
/** The name a person reads, null when `project.json` holds none, where readers show `name`. */
|
|
47221
|
+
title: string$1().nullable(),
|
|
46877
47222
|
path: string$1(),
|
|
46878
47223
|
modifiedAt: string$1(),
|
|
46879
47224
|
/** When the project was made, null for one made before the time was recorded. */
|
|
@@ -47398,7 +47743,7 @@ function contentFormat() {
|
|
|
47398
47743
|
"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.",
|
|
47399
47744
|
`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.`,
|
|
47400
47745
|
`widths lists the extra widths one frame file also shows at, as { width, height } objects, each drawn 80 px past the last 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.`,
|
|
47401
|
-
`
|
|
47746
|
+
`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 and the tablet's ${BEZELS.tablet.border}, 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 or its size, and a frame placed beside one lands 80 px past the body. Linked widths draw no device. 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.`,
|
|
47402
47747
|
`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.`,
|
|
47403
47748
|
"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. frame resize and a hand resize fix each axis they set, and frame fit sets the height and turns hugHeight on.",
|
|
47404
47749
|
"Frames sort by order, then name, and a write that changes order renumbers the page from 0.",
|
|
@@ -47635,7 +47980,7 @@ function registerEditing(program, context) {
|
|
|
47635
47980
|
const [ref] = refs;
|
|
47636
47981
|
if (options.release) {
|
|
47637
47982
|
const session = sessionOf(options.session);
|
|
47638
|
-
const released = await release
|
|
47983
|
+
const released = await release(root, session, ref ? await claimable(root, ref, resolving(options, io.cwd), now) : void 0, now);
|
|
47639
47984
|
return {
|
|
47640
47985
|
data: { released },
|
|
47641
47986
|
human: released.length === 0 ? `${session} held no claim to release` : `Released ${released.map((each) => each.frame).join(", ")}`
|
|
@@ -47775,7 +48120,29 @@ function transitionFrom(name, { ms, direction }) {
|
|
|
47775
48120
|
// src/cli/commands/frame.ts
|
|
47776
48121
|
const FRAME_REF = "a frame ref, <page>/<frame> or <project>/<page>/<frame>, or a path to its .html file";
|
|
47777
48122
|
const ANY_INTEGER = parseInteger(Number.MIN_SAFE_INTEGER);
|
|
47778
|
-
const DEVICE_HELP = "the
|
|
48123
|
+
const DEVICE_HELP = "on to draw the frame inside the phone, tablet, or laptop its width names, leaving the frame file and its size as they are, with phone and tablet taken as on";
|
|
48124
|
+
/**
|
|
48125
|
+
* What `frame device` takes, on or off, with the device names it took before
|
|
48126
|
+
* the width picked the body kept as aliases, so no agent's call breaks.
|
|
48127
|
+
*/
|
|
48128
|
+
const DEVICE_SWITCH = {
|
|
48129
|
+
on: true,
|
|
48130
|
+
off: false,
|
|
48131
|
+
phone: true,
|
|
48132
|
+
tablet: true,
|
|
48133
|
+
none: false
|
|
48134
|
+
};
|
|
48135
|
+
const DEVICE_ON = [
|
|
48136
|
+
"on",
|
|
48137
|
+
"phone",
|
|
48138
|
+
"tablet"
|
|
48139
|
+
];
|
|
48140
|
+
/** What `frame device` did, naming the device the frame's width gave it. */
|
|
48141
|
+
function deviceHeadline({ ref, box, showDevice, device }) {
|
|
48142
|
+
if (!showDevice) return `Hid the device on ${ref}`;
|
|
48143
|
+
if (!device) return `Showed the device on ${ref}, though no device fits its ${box.width} px width`;
|
|
48144
|
+
return `Showed the ${device} on ${ref}`;
|
|
48145
|
+
}
|
|
47779
48146
|
const WIDTHS_HELP = "the extra widths the frame also shows at, a comma list such as 834,390, each drawn beside it and hugging or holding its height as the frame does";
|
|
47780
48147
|
const POSITIVE = parseInteger(1);
|
|
47781
48148
|
/** A comma list of positive integers, each checked as `--width` checks one. */
|
|
@@ -47798,8 +48165,9 @@ function registerFrame(program, context) {
|
|
|
47798
48165
|
data: record,
|
|
47799
48166
|
human: `${what} ${record.ref}`
|
|
47800
48167
|
});
|
|
47801
|
-
act(withPosition(withSize(verb("add", "Place a frame past every frame, as written when its file exists and with a skeleton file only when none does, so write the file first to show no empty box. Each axis no size names hugs its content, so a preset or --width fixes the width and the height hugs.").option("--scroll", SCROLL_HELP).option("--widths <list>", WIDTHS_HELP, parseWidths).addOption(new Option("--device <
|
|
48168
|
+
act(withPosition(withSize(verb("add", "Place a frame past every frame, as written when its file exists and with a skeleton file only when none does, so write the file first to show no empty box. Each axis no size names hugs its content, so a preset or --width fixes the width and the height hugs.").option("--scroll", SCROLL_HELP).option("--widths <list>", WIDTHS_HELP, parseWidths).addOption(new Option("--device <on>", DEVICE_HELP).choices(DEVICE_ON)))), context, async ([ref = ""], { device, ...options }) => done(await addFrame(await boardOf(options, io), ref, {
|
|
47802
48169
|
...options,
|
|
48170
|
+
...device ? { showDevice: true } : {},
|
|
47803
48171
|
cwd: io.cwd
|
|
47804
48172
|
}), "Added"));
|
|
47805
48173
|
act(verb("duplicate", "Copy a frame file byte for byte, on top").option("--to <page-ref>", "the page to copy into, defaulting to its own").option("--name <new>", "name of the copy, defaulting to the next free -2, -3"), context, async ([ref = ""], options) => done(await duplicateFrame(await boardOf(options, io), ref, {
|
|
@@ -47855,12 +48223,16 @@ function registerFrame(program, context) {
|
|
|
47855
48223
|
human: `Deleted frame ${result.deleted}`
|
|
47856
48224
|
};
|
|
47857
48225
|
});
|
|
47858
|
-
act(verb("device", "
|
|
47859
|
-
const
|
|
48226
|
+
act(verb("device", "Show or hide the device the board draws around a frame, the phone, tablet, or laptop its width names, leaving the frame file and its size as they are").addArgument(new Argument("<on|off>", "on to show the device, off to hide it, with phone and tablet taken as on and none as off").choices(Object.keys(DEVICE_SWITCH))), context, async ([ref = "", value = ""], options) => {
|
|
48227
|
+
const show = Object.hasOwn(DEVICE_SWITCH, value) ? DEVICE_SWITCH[value] : false;
|
|
48228
|
+
const record = await setFrameDevice(await boardOf(options, io), ref, show, {
|
|
47860
48229
|
...options,
|
|
47861
48230
|
cwd: io.cwd
|
|
47862
48231
|
});
|
|
47863
|
-
return
|
|
48232
|
+
return {
|
|
48233
|
+
data: record,
|
|
48234
|
+
human: deviceHeadline(record)
|
|
48235
|
+
};
|
|
47864
48236
|
});
|
|
47865
48237
|
act(withTransitionFlags(verb("transition", "Set the transition present mode draws as this slide arrives, over its page’s, or clear it with page so it takes the page’s, writing only layout.json").addArgument(new Argument("<transition>", transitionHelp(`${SAME_AS_PAGE_WORD} to take the page’s`)))), context, async ([ref = "", name = ""], options) => {
|
|
47866
48238
|
const record = await setFrameTransition(await boardOf(options, io), ref, transitionOrPage(name, options), {
|
|
@@ -48025,7 +48397,7 @@ var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
48025
48397
|
this.pending--;
|
|
48026
48398
|
this[kRun]();
|
|
48027
48399
|
};
|
|
48028
|
-
this.concurrency = concurrency ||
|
|
48400
|
+
this.concurrency = concurrency || 1e400;
|
|
48029
48401
|
this.jobs = [];
|
|
48030
48402
|
this.pending = 0;
|
|
48031
48403
|
}
|
|
@@ -48885,6 +49257,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
48885
49257
|
data = this.consume(this._payloadLength);
|
|
48886
49258
|
if (this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0) unmask(data, this._mask);
|
|
48887
49259
|
}
|
|
49260
|
+
this._mask = void 0;
|
|
48888
49261
|
if (this._opcode > 7) {
|
|
48889
49262
|
this.controlMessage(data, cb);
|
|
48890
49263
|
return;
|
|
@@ -49926,6 +50299,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
49926
50299
|
const https = __require("https");
|
|
49927
50300
|
const http = __require("http");
|
|
49928
50301
|
const net = __require("net");
|
|
50302
|
+
const querystring = __require("querystring");
|
|
49929
50303
|
const tls = __require("tls");
|
|
49930
50304
|
const { randomBytes, createHash } = __require("crypto");
|
|
49931
50305
|
const { Duplex, Readable } = __require("stream");
|
|
@@ -50484,8 +50858,10 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
50484
50858
|
} catch {
|
|
50485
50859
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
50486
50860
|
}
|
|
50487
|
-
if (parsedUrl.protocol === "http:"
|
|
50488
|
-
|
|
50861
|
+
if (parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:") {
|
|
50862
|
+
parsedUrl = new URL(parsedUrl);
|
|
50863
|
+
parsedUrl.protocol = parsedUrl.protocol === "http:" ? "ws:" : "wss:";
|
|
50864
|
+
}
|
|
50489
50865
|
websocket._url = parsedUrl.href;
|
|
50490
50866
|
const isSecure = parsedUrl.protocol === "wss:";
|
|
50491
50867
|
const isIpcUrl = parsedUrl.protocol === "ws+unix:";
|
|
@@ -50538,7 +50914,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
50538
50914
|
if (opts.protocolVersion < 13) opts.headers["Sec-WebSocket-Origin"] = opts.origin;
|
|
50539
50915
|
else opts.headers.Origin = opts.origin;
|
|
50540
50916
|
}
|
|
50541
|
-
if (parsedUrl.username || parsedUrl.password) opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
|
|
50917
|
+
if (parsedUrl.username || parsedUrl.password) opts.auth = `${querystring.unescape(parsedUrl.username)}:${querystring.unescape(parsedUrl.password)}`;
|
|
50542
50918
|
if (isIpcUrl) {
|
|
50543
50919
|
const i = opts.path.indexOf(":");
|
|
50544
50920
|
if (i === -1) {
|
|
@@ -50754,8 +51130,12 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
50754
51130
|
function receiverOnConclude(code, reason) {
|
|
50755
51131
|
const websocket = this[kWebSocket];
|
|
50756
51132
|
websocket._closeFrameReceived = true;
|
|
50757
|
-
websocket._closeMessage = reason;
|
|
50758
51133
|
websocket._closeCode = code;
|
|
51134
|
+
if (reason.length === 0) websocket._closeMessage = EMPTY_BUFFER;
|
|
51135
|
+
else {
|
|
51136
|
+
websocket._closeMessage = Buffer.allocUnsafeSlow(reason.length);
|
|
51137
|
+
websocket._closeMessage.set(reason);
|
|
51138
|
+
}
|
|
50759
51139
|
if (websocket._socket[kWebSocket] === void 0) return;
|
|
50760
51140
|
websocket._socket.removeListener("data", socketOnData);
|
|
50761
51141
|
process.nextTick(resume, websocket._socket);
|
|
@@ -52343,6 +52723,13 @@ function registerProject(program, context) {
|
|
|
52343
52723
|
human: `Renamed project ${name} to ${record.name}`
|
|
52344
52724
|
};
|
|
52345
52725
|
});
|
|
52726
|
+
act(addVerb(project, "title", "Set the name a person reads for a project, which may hold any characters, and move its folder to the name made from it").argument("<name>", "the project folder").argument("<title>", "its title, a blank one taking the title out"), context, async ([name = "", title = ""], options) => {
|
|
52727
|
+
const record = await retitleProject(await boardOf(options, io), name, title);
|
|
52728
|
+
return {
|
|
52729
|
+
data: record,
|
|
52730
|
+
human: record.title === null ? `Took the title off project ${record.name}` : record.name === name ? `Titled project ${name} '${record.title}'` : `Titled project ${name} '${record.title}' and moved it to ${record.name}`
|
|
52731
|
+
};
|
|
52732
|
+
});
|
|
52346
52733
|
act(addVerb(project, "delete", "Delete a project and everything in it").argument("<name>", "the project"), context, async ([name = ""], options) => {
|
|
52347
52734
|
const result = await deleteProject(await boardOf(options, io), name);
|
|
52348
52735
|
return {
|
|
@@ -52676,7 +53063,7 @@ async function removeEmptyFolders(dir, folder) {
|
|
|
52676
53063
|
function registerReferences(program, context) {
|
|
52677
53064
|
const { io } = context;
|
|
52678
53065
|
act(addVerb(program.command("references").description("Fill a folder of design references from the board's frames"), "sync", "Write each frame <folder>/frames.json maps as its HTML, a PNG per theme, and the project assets it loads, removing every other file below the folder's first level").argument("<folder>", "the folder holding frames.json").option("--check", "write nothing, and exit 14 when the folder differs from what a sync would write"), context, async ([given = ""], options) => {
|
|
52679
|
-
const folder = resolve(io.cwd, given);
|
|
53066
|
+
const folder = resolve$1(io.cwd, given);
|
|
52680
53067
|
if (!existsSync(join(folder, "frames.json"))) throw new FrameboardError("usage", `${folder} holds no frames.json, mapping each reference to a board frame.`);
|
|
52681
53068
|
const target = {
|
|
52682
53069
|
root: await boardOf(options, io),
|
|
@@ -53254,7 +53641,7 @@ var ReaddirpStream = class extends Readable {
|
|
|
53254
53641
|
this._wantsDir = DIR_TYPES.has(type);
|
|
53255
53642
|
this._wantsFile = FILE_TYPES.has(type);
|
|
53256
53643
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
53257
|
-
this._root = resolve(root);
|
|
53644
|
+
this._root = resolve$1(root);
|
|
53258
53645
|
this._relStart = this._root.endsWith(sep) ? this._root.length : this._root.length + 1;
|
|
53259
53646
|
this._isDirent = !opts.alwaysStat;
|
|
53260
53647
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
@@ -53653,13 +54040,13 @@ function projectNativeRelativePath(nativeRoot, relativePath) {
|
|
|
53653
54040
|
}
|
|
53654
54041
|
const FsWatchInstances = /* @__PURE__ */ new Map();
|
|
53655
54042
|
function systemNativeWatchFactory(path, options, listener) {
|
|
53656
|
-
return watch(path, options, listener);
|
|
54043
|
+
return watch$1(path, options, listener);
|
|
53657
54044
|
}
|
|
53658
54045
|
let nativeWatchFactory = systemNativeWatchFactory;
|
|
53659
54046
|
const RecursiveWatchInstances = /* @__PURE__ */ new Map();
|
|
53660
54047
|
let recursiveWatchUnsupported = false;
|
|
53661
54048
|
function systemRecursiveWatchFactory(path, options, listener) {
|
|
53662
|
-
return watch(path, options, listener);
|
|
54049
|
+
return watch$1(path, options, listener);
|
|
53663
54050
|
}
|
|
53664
54051
|
let recursiveWatchFactory = systemRecursiveWatchFactory;
|
|
53665
54052
|
function failRecursiveResource(resource, error) {
|
|
@@ -53774,7 +54161,7 @@ function closeFailedNativeResource(cont, error) {
|
|
|
53774
54161
|
}
|
|
53775
54162
|
async function handleNativeError(path, cont, error) {
|
|
53776
54163
|
if (isWindows && error.code === "EPERM") try {
|
|
53777
|
-
await (await open(path, "r")).close();
|
|
54164
|
+
await (await open$1(path, "r")).close();
|
|
53778
54165
|
broadcastNativeError(cont, error);
|
|
53779
54166
|
} catch {
|
|
53780
54167
|
publishNativeTrigger(cont, "rename", null, false);
|
|
@@ -56301,7 +56688,7 @@ var FSWatcher = class extends EventEmitter {
|
|
|
56301
56688
|
* const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
|
|
56302
56689
|
* watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
|
|
56303
56690
|
*/
|
|
56304
|
-
function watch
|
|
56691
|
+
function watch(paths, options = {}) {
|
|
56305
56692
|
const watcher = new FSWatcher(options);
|
|
56306
56693
|
watcher.add(paths);
|
|
56307
56694
|
return watcher;
|
|
@@ -56336,10 +56723,10 @@ async function watchBoard(root, files = []) {
|
|
|
56336
56723
|
});
|
|
56337
56724
|
const runFolder = join(root, RUN_FOLDER);
|
|
56338
56725
|
const outside = files.filter((file) => relative(root, file).startsWith(".."));
|
|
56339
|
-
const watchers = [watch
|
|
56726
|
+
const watchers = [watch(root, {
|
|
56340
56727
|
ignoreInitial: true,
|
|
56341
56728
|
ignored: (path) => isIgnored(root, path)
|
|
56342
|
-
}), ...outside.length > 0 ? [watch
|
|
56729
|
+
}), ...outside.length > 0 ? [watch([...outside], { ignoreInitial: true })] : []];
|
|
56343
56730
|
let warm = false;
|
|
56344
56731
|
await Promise.all(watchers.map((watcher) => {
|
|
56345
56732
|
watcher.on("all", (_event, path) => {
|
|
@@ -56413,6 +56800,26 @@ function isIgnored(root, path) {
|
|
|
56413
56800
|
* Only frames in `board` are named, in board order.
|
|
56414
56801
|
*/
|
|
56415
56802
|
function reloadRefs(root, paths, board, tokens = null) {
|
|
56803
|
+
const { refs, everyFrame } = reloadCauses(root, paths, tokens);
|
|
56804
|
+
const named = [];
|
|
56805
|
+
for (const project of board.projects) for (const page of project.pages) for (const frame of page.frames) if (everyFrame || refs.has(frame.ref) || refs.has(`${page.ref}/*`) || refs.has(`${project.name}/*`)) named.push(frame.ref);
|
|
56806
|
+
return named;
|
|
56807
|
+
}
|
|
56808
|
+
/**
|
|
56809
|
+
* The frames `reloadRefs` names through their own file alone, with no token
|
|
56810
|
+
* sheet, asset, or other page-folder file in the batch reaching them, in
|
|
56811
|
+
* board order. Only these reload into bytes a hash of that one file names.
|
|
56812
|
+
*/
|
|
56813
|
+
function ownReloadRefs(root, paths, board, tokens = null) {
|
|
56814
|
+
const { refs, everyFrame } = reloadCauses(root, paths, tokens);
|
|
56815
|
+
if (everyFrame) return [];
|
|
56816
|
+
return board.projects.flatMap((project) => refs.has(`${project.name}/*`) ? [] : project.pages.flatMap((page) => refs.has(`${page.ref}/*`) ? [] : page.frames.filter((frame) => refs.has(frame.ref)).map((frame) => frame.ref)));
|
|
56817
|
+
}
|
|
56818
|
+
/**
|
|
56819
|
+
* What a batch's paths reach: frame refs, `<page>/*` and `<project>/*`
|
|
56820
|
+
* wildcards, and whether a board-wide sheet reaches every frame.
|
|
56821
|
+
*/
|
|
56822
|
+
function reloadCauses(root, paths, tokens) {
|
|
56416
56823
|
const refs = /* @__PURE__ */ new Set();
|
|
56417
56824
|
let everyFrame = false;
|
|
56418
56825
|
for (const path of paths) {
|
|
@@ -56434,9 +56841,10 @@ function reloadRefs(root, paths, board, tokens = null) {
|
|
|
56434
56841
|
refs.add(frame === null ? `${project}/${folder}/*` : `${project}/${folder}/${frame}`);
|
|
56435
56842
|
}
|
|
56436
56843
|
}
|
|
56437
|
-
|
|
56438
|
-
|
|
56439
|
-
|
|
56844
|
+
return {
|
|
56845
|
+
refs,
|
|
56846
|
+
everyFrame
|
|
56847
|
+
};
|
|
56440
56848
|
}
|
|
56441
56849
|
/**
|
|
56442
56850
|
* `refs` less each frame that only moved with a folder the board renamed,
|
|
@@ -57720,10 +58128,14 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
|
|
|
57720
58128
|
hug.later(board, [.../* @__PURE__ */ new Set([...refs, ...relisted])].filter((ref) => !own.includes(ref) && !placed.includes(ref)));
|
|
57721
58129
|
if (refs.length > 0) {
|
|
57722
58130
|
const reloads = unmovedRefs(refs, board, moved(), last);
|
|
57723
|
-
if (reloads.length > 0)
|
|
57724
|
-
|
|
57725
|
-
|
|
57726
|
-
|
|
58131
|
+
if (reloads.length > 0) {
|
|
58132
|
+
const hashes = await ownFileHashes(board, ownReloadRefs(root, paths, board, tokens).filter((ref) => reloads.includes(ref)));
|
|
58133
|
+
hub.broadcast({
|
|
58134
|
+
type: "reload",
|
|
58135
|
+
refs: reloads,
|
|
58136
|
+
...Object.keys(hashes).length > 0 ? { hashes } : {}
|
|
58137
|
+
});
|
|
58138
|
+
}
|
|
57727
58139
|
thumbnails.invalidate(refs);
|
|
57728
58140
|
const stale = Object.fromEntries(refs.map((ref) => [ref, null]));
|
|
57729
58141
|
for (const theme of THEMES) hub.broadcast({
|
|
@@ -57743,6 +58155,23 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
|
|
|
57743
58155
|
await pushNotes(root, paths, hub, delivery);
|
|
57744
58156
|
}
|
|
57745
58157
|
/**
|
|
58158
|
+
* The content hash of each named frame's file as it stands now, which is
|
|
58159
|
+
* what its reload will render. A file that cannot be read is left out, so
|
|
58160
|
+
* its frame reloads.
|
|
58161
|
+
*/
|
|
58162
|
+
async function ownFileHashes(board, refs) {
|
|
58163
|
+
const named = new Set(refs);
|
|
58164
|
+
const frames = board.projects.flatMap((project) => project.pages).flatMap((page) => page.frames).filter((frame) => named.has(frame.ref));
|
|
58165
|
+
const read = await Promise.all(frames.map(async (frame) => {
|
|
58166
|
+
try {
|
|
58167
|
+
return [[frame.ref, contentHash(await readFile(frame.path))]];
|
|
58168
|
+
} catch {
|
|
58169
|
+
return [];
|
|
58170
|
+
}
|
|
58171
|
+
}));
|
|
58172
|
+
return Object.fromEntries(read.flat());
|
|
58173
|
+
}
|
|
58174
|
+
/**
|
|
57746
58175
|
* Runs `outranked` over each settled agent write against the bytes it
|
|
57747
58176
|
* replaced, holding the result in place of the frame's previous write's, and
|
|
57748
58177
|
* returns the merged lists to send. A write raising nothing keeps a held
|
|
@@ -57834,7 +58263,7 @@ const RECONNECT_WAIT_MS = 1e3;
|
|
|
57834
58263
|
function registerServe(program, context) {
|
|
57835
58264
|
const { io } = context;
|
|
57836
58265
|
act(addVerb(program, "serve", `Serve the board in a local browser. A note sent to a new session runs the shell command in ${DISPATCH_ENV}, read once at start, with the note in FRAMEBOARD_NOTE, FRAMEBOARD_NOTE_ID, FRAMEBOARD_SESSION, and FRAMEBOARD_ROOT`).option("-p, --port <port>", "port to listen on, falling back to a free one when the default is taken", parsePort, DEFAULT_PORT).option("--no-open", "leave the browser alone").option("--tokens <path>", "a token sheet another tool manages, standing in for the board's tokens.css").addOption(new Option("--open-route", "answer /api/access/open with a fresh edit link per request").default(false).hideHelp()), context, async (_args, options, self) => {
|
|
57837
|
-
const tokens = options.tokens === void 0 ? void 0 : resolve(io.cwd, options.tokens);
|
|
58266
|
+
const tokens = options.tokens === void 0 ? void 0 : resolve$1(io.cwd, options.tokens);
|
|
57838
58267
|
if (tokens !== void 0 && !isFile(tokens)) throw new FrameboardError("tokens-not-found", `No token sheet at ${tokens}.`, { tokens });
|
|
57839
58268
|
const existing = await resolveBoard({
|
|
57840
58269
|
root: options.root,
|