frameboard 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +780 -726
- package/dist/client/assets/index-5vtY9zMD.css +2 -0
- package/dist/client/assets/index-C3AvCtOi.js +179 -0
- package/dist/client/index.html +2 -2
- package/dist/hook.js +1 -1
- 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;
|
|
@@ -12677,7 +12677,7 @@ var require_source_map_consumer = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
12677
12677
|
continue;
|
|
12678
12678
|
}
|
|
12679
12679
|
}
|
|
12680
|
-
mapping.lastGeneratedColumn =
|
|
12680
|
+
mapping.lastGeneratedColumn = 1e400;
|
|
12681
12681
|
}
|
|
12682
12682
|
};
|
|
12683
12683
|
/**
|
|
@@ -23915,7 +23915,7 @@ function localTarget(url, base) {
|
|
|
23915
23915
|
try {
|
|
23916
23916
|
decoded = decodeURIComponent(bare);
|
|
23917
23917
|
} catch {}
|
|
23918
|
-
return resolve(base, decoded);
|
|
23918
|
+
return resolve$1(base, decoded);
|
|
23919
23919
|
}
|
|
23920
23920
|
/** A scheme such as `https:` or `data:`, or a protocol-relative `//`. */
|
|
23921
23921
|
function hasScheme(url) {
|
|
@@ -24544,7 +24544,7 @@ function byName(a, b) {
|
|
|
24544
24544
|
*/
|
|
24545
24545
|
async function resolveBoard({ root, cwd }) {
|
|
24546
24546
|
if (root !== void 0) {
|
|
24547
|
-
const path = resolve(cwd, root);
|
|
24547
|
+
const path = resolve$1(cwd, root);
|
|
24548
24548
|
if (!await isDirectory(path)) throw new FrameboardError("board-not-found", `No board folder at ${path}.`, { root: path });
|
|
24549
24549
|
return realpath(path);
|
|
24550
24550
|
}
|
|
@@ -24553,7 +24553,7 @@ async function resolveBoard({ root, cwd }) {
|
|
|
24553
24553
|
return realpath(found);
|
|
24554
24554
|
}
|
|
24555
24555
|
function findBoard(cwd) {
|
|
24556
|
-
for (let dir = resolve(cwd);; dir = dirname(dir)) {
|
|
24556
|
+
for (let dir = resolve$1(cwd);; dir = dirname(dir)) {
|
|
24557
24557
|
if (existsSync(join(dir, "board.json"))) return dir;
|
|
24558
24558
|
if (existsSync(join(dir, ".frameboard", "board.json"))) return join(dir, DEFAULT_BOARD_FOLDER);
|
|
24559
24559
|
if (existsSync(join(dir, ".git")) || dirname(dir) === dir) return null;
|
|
@@ -24566,7 +24566,7 @@ function findBoard(cwd) {
|
|
|
24566
24566
|
* alone.
|
|
24567
24567
|
*/
|
|
24568
24568
|
async function startBoard({ root, cwd }, now = /* @__PURE__ */ new Date()) {
|
|
24569
|
-
const target = root === void 0 ? findBoard(cwd) ?? join(cwd, ".frameboard") : resolve(cwd, root);
|
|
24569
|
+
const target = root === void 0 ? findBoard(cwd) ?? join(cwd, ".frameboard") : resolve$1(cwd, root);
|
|
24570
24570
|
await mkdir(target, { recursive: true });
|
|
24571
24571
|
if (!existsSync(join(target, "board.json"))) await writeRecord(join(target, BOARD_FILE), { version: 1 });
|
|
24572
24572
|
let created = false;
|
|
@@ -24594,9 +24594,9 @@ async function isDirectory(path) {
|
|
|
24594
24594
|
}
|
|
24595
24595
|
}
|
|
24596
24596
|
// package.json
|
|
24597
|
-
var version$1 = "0.
|
|
24597
|
+
var version$1 = "0.37.0";
|
|
24598
24598
|
var dependencies = { "playwright-core": "1.65.0" };
|
|
24599
|
-
var peerDependencies = { "oxfmt": "0.
|
|
24599
|
+
var peerDependencies = { "oxfmt": "0.78.0" };
|
|
24600
24600
|
// src/shared/version.ts
|
|
24601
24601
|
const version = version$1;
|
|
24602
24602
|
// src/cli/client-dir.ts
|
|
@@ -24906,7 +24906,7 @@ async function releaseReservation(root, frame, now) {
|
|
|
24906
24906
|
* Drops a session's claim on one frame, or every claim it holds when no
|
|
24907
24907
|
* frame is named, returning what it dropped.
|
|
24908
24908
|
*/
|
|
24909
|
-
async function release
|
|
24909
|
+
async function release(root, session, frame, now) {
|
|
24910
24910
|
const dropped = [];
|
|
24911
24911
|
await ensureRunFolder(root);
|
|
24912
24912
|
await updateRecord(claimsPath(root), claimsSpec, (file) => {
|
|
@@ -25031,7 +25031,7 @@ function agreeingProject(ref, fromRef, { project }) {
|
|
|
25031
25031
|
return fromRef ?? project;
|
|
25032
25032
|
}
|
|
25033
25033
|
async function framePathParts(root, ref, cwd) {
|
|
25034
|
-
const path = resolve(cwd, ref);
|
|
25034
|
+
const path = resolve$1(cwd, ref);
|
|
25035
25035
|
let folder = dirname(path);
|
|
25036
25036
|
try {
|
|
25037
25037
|
folder = await realpath(folder);
|
|
@@ -25673,15 +25673,11 @@ var PageLayout = class {
|
|
|
25673
25673
|
/**
|
|
25674
25674
|
* Writes the seven fixed keys on the entry it creates or changes, after any
|
|
25675
25675
|
* key the entry already held, so unknown keys survive in place. A hug flag
|
|
25676
|
-
* is written
|
|
25677
|
-
*
|
|
25678
|
-
*
|
|
25679
|
-
*
|
|
25680
|
-
*
|
|
25681
|
-
* value no reader understands is left as it stands. `device` is written
|
|
25682
|
-
* while the frame holds one and removed once it is cleared, leaving a held
|
|
25683
|
-
* value no reader understands as `widths` does. `transition` is written
|
|
25684
|
-
* the same way as `device`.
|
|
25676
|
+
* is written once it is on or when the entry holds it, so an entry from
|
|
25677
|
+
* before the flags gains no key, and a scroll entry writes both hug flags
|
|
25678
|
+
* false, since it fixes both axes. `scroll` follows the same rule. `widths`,
|
|
25679
|
+
* `device`, and `transition` are written while the frame holds one and
|
|
25680
|
+
* removed once cleared, leaving a held value no reader understands as is.
|
|
25685
25681
|
*/
|
|
25686
25682
|
set(name, { box, order, hidden, locked, scroll, widths, device, transition, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
|
|
25687
25683
|
const hugWidth = hugsWidth && !scroll;
|
|
@@ -26377,6 +26373,7 @@ Object.defineProperty(requestPrototype, "signal", { get() {
|
|
|
26377
26373
|
"cache",
|
|
26378
26374
|
"credentials",
|
|
26379
26375
|
"destination",
|
|
26376
|
+
"duplex",
|
|
26380
26377
|
"integrity",
|
|
26381
26378
|
"mode",
|
|
26382
26379
|
"redirect",
|
|
@@ -26596,6 +26593,11 @@ function writeFromReadableStreamDefaultReader(reader, writable, currentReadPromi
|
|
|
26596
26593
|
const cancel = (error) => {
|
|
26597
26594
|
reader.cancel(error).catch(() => {});
|
|
26598
26595
|
};
|
|
26596
|
+
const stream = writable.stream;
|
|
26597
|
+
if (writable.destroyed || stream?.closed || stream?.destroyed) {
|
|
26598
|
+
cancel();
|
|
26599
|
+
return reader.closed;
|
|
26600
|
+
}
|
|
26599
26601
|
writable.on("close", cancel);
|
|
26600
26602
|
writable.on("error", cancel);
|
|
26601
26603
|
(currentReadPromise ?? reader.read()).then(flow, handleStreamError);
|
|
@@ -26613,7 +26615,7 @@ function writeFromReadableStreamDefaultReader(reader, writable, currentReadPromi
|
|
|
26613
26615
|
try {
|
|
26614
26616
|
if (done) writable.end();
|
|
26615
26617
|
else if (!writable.write(value)) writable.once("drain", onDrain);
|
|
26616
|
-
else
|
|
26618
|
+
else reader.read().then(flow, handleStreamError);
|
|
26617
26619
|
} catch (e) {
|
|
26618
26620
|
handleStreamError(e);
|
|
26619
26621
|
}
|
|
@@ -26621,7 +26623,10 @@ function writeFromReadableStreamDefaultReader(reader, writable, currentReadPromi
|
|
|
26621
26623
|
}
|
|
26622
26624
|
function writeFromReadableStream(stream, writable) {
|
|
26623
26625
|
if (stream.locked) throw new TypeError("ReadableStream is locked.");
|
|
26624
|
-
else if (writable.destroyed)
|
|
26626
|
+
else if (writable.destroyed) {
|
|
26627
|
+
stream.cancel().catch(() => {});
|
|
26628
|
+
return;
|
|
26629
|
+
}
|
|
26625
26630
|
return writeFromReadableStreamDefaultReader(stream.getReader(), writable);
|
|
26626
26631
|
}
|
|
26627
26632
|
const buildOutgoingHttpHeaders = (headers, defaultContentType) => {
|
|
@@ -26812,10 +26817,7 @@ const responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
26812
26817
|
let maxReadCount = 2;
|
|
26813
26818
|
for (let i = 0; i < maxReadCount; i++) {
|
|
26814
26819
|
currentReadPromise ||= reader.read();
|
|
26815
|
-
const chunk = await readWithoutBlocking(currentReadPromise)
|
|
26816
|
-
console.error(e);
|
|
26817
|
-
done = true;
|
|
26818
|
-
});
|
|
26820
|
+
const chunk = await readWithoutBlocking(currentReadPromise);
|
|
26819
26821
|
if (!chunk) {
|
|
26820
26822
|
if (i === 1) {
|
|
26821
26823
|
await new Promise((resolve) => setTimeout(resolve));
|
|
@@ -27280,16 +27282,7 @@ const tryDecode$1 = (str, decoder) => {
|
|
|
27280
27282
|
});
|
|
27281
27283
|
}
|
|
27282
27284
|
};
|
|
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);
|
|
27285
|
+
const decodeURIWithPreservedPercent = (value) => decodeURI(value.includes("%25") ? value.replace(/%25/g, "%2525") : value);
|
|
27293
27286
|
const getPath = (request) => {
|
|
27294
27287
|
const url = request.url;
|
|
27295
27288
|
const start = url.indexOf("/", url.indexOf(":") + 4);
|
|
@@ -27301,7 +27294,13 @@ const getPath = (request) => {
|
|
|
27301
27294
|
const hashIndex = url.indexOf("#", i);
|
|
27302
27295
|
const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
27303
27296
|
const path = url.slice(start, end);
|
|
27304
|
-
|
|
27297
|
+
const decoded = tryDecode$1(path, decodeURIWithPreservedPercent);
|
|
27298
|
+
if (/%(?![0-9A-Fa-f]{2})/.test(path)) {
|
|
27299
|
+
const rewritten = new URL("http://localhost");
|
|
27300
|
+
rewritten.pathname = decoded.replace(/[\\\t\n\r]/g, encodeURIComponent);
|
|
27301
|
+
if (tryDecode$1(rewritten.pathname, decodeURIWithPreservedPercent) !== decoded) return tryDecode$1(path.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"), decodeURIWithPreservedPercent);
|
|
27302
|
+
}
|
|
27303
|
+
return decoded;
|
|
27305
27304
|
} else if (charCode === 63 || charCode === 35) break;
|
|
27306
27305
|
}
|
|
27307
27306
|
return url.slice(start, i);
|
|
@@ -27310,15 +27309,6 @@ const getPathNoStrict = (request) => {
|
|
|
27310
27309
|
const result = getPath(request);
|
|
27311
27310
|
return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
|
|
27312
27311
|
};
|
|
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
27312
|
/**
|
|
27323
27313
|
* Merge paths.
|
|
27324
27314
|
* @param {string[]} ...paths - The paths to merge.
|
|
@@ -28138,6 +28128,57 @@ const compose = (middleware, onError, onNotFound) => {
|
|
|
28138
28128
|
}
|
|
28139
28129
|
};
|
|
28140
28130
|
};
|
|
28131
|
+
// node_modules/hono/dist/helper/route/index.js
|
|
28132
|
+
/**
|
|
28133
|
+
* Get matched routes in the handler
|
|
28134
|
+
*
|
|
28135
|
+
* @param {Context} c - The context object
|
|
28136
|
+
* @returns An array of matched routes
|
|
28137
|
+
*
|
|
28138
|
+
* @example
|
|
28139
|
+
* ```ts
|
|
28140
|
+
* import { matchedRoutes } from 'hono/route'
|
|
28141
|
+
*
|
|
28142
|
+
* app.use('*', async function logger(c, next) {
|
|
28143
|
+
* await next()
|
|
28144
|
+
* matchedRoutes(c).forEach(({ handler, method, path }, i) => {
|
|
28145
|
+
* const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')
|
|
28146
|
+
* console.log(
|
|
28147
|
+
* method,
|
|
28148
|
+
* ' ',
|
|
28149
|
+
* path,
|
|
28150
|
+
* ' '.repeat(Math.max(10 - path.length, 0)),
|
|
28151
|
+
* name,
|
|
28152
|
+
* i === c.req.routeIndex ? '<- respond from here' : ''
|
|
28153
|
+
* )
|
|
28154
|
+
* })
|
|
28155
|
+
* })
|
|
28156
|
+
* ```
|
|
28157
|
+
*/
|
|
28158
|
+
const matchedRoutes = (c) => c.req[GET_MATCH_RESULT][0].map(([[, route]]) => route);
|
|
28159
|
+
/**
|
|
28160
|
+
* Get the route path registered within the handler
|
|
28161
|
+
*
|
|
28162
|
+
* @param {Context} c - The context object
|
|
28163
|
+
* @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.
|
|
28164
|
+
* @returns The route path registered within the handler
|
|
28165
|
+
*
|
|
28166
|
+
* @example
|
|
28167
|
+
* ```ts
|
|
28168
|
+
* import { routePath } from 'hono/route'
|
|
28169
|
+
*
|
|
28170
|
+
* app.use('*', (c, next) => {
|
|
28171
|
+
* console.log(routePath(c)) // '*'
|
|
28172
|
+
* console.log(routePath(c, -1)) // '/posts/:id'
|
|
28173
|
+
* return next()
|
|
28174
|
+
* })
|
|
28175
|
+
*
|
|
28176
|
+
* app.get('/posts/:id', (c) => {
|
|
28177
|
+
* return c.text(routePath(c)) // '/posts/:id'
|
|
28178
|
+
* })
|
|
28179
|
+
* ```
|
|
28180
|
+
*/
|
|
28181
|
+
const routePath = (c, index) => matchedRoutes(c).at(index ?? c.req.routeIndex)?.path ?? "";
|
|
28141
28182
|
// node_modules/hono/dist/router.js
|
|
28142
28183
|
/**
|
|
28143
28184
|
* Array of supported HTTP methods.
|
|
@@ -28165,6 +28206,11 @@ var UnsupportedPathError = class extends Error {};
|
|
|
28165
28206
|
*/
|
|
28166
28207
|
const COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
28167
28208
|
// node_modules/hono/dist/utils/mount.js
|
|
28209
|
+
const countTrailingSlashes = (path) => {
|
|
28210
|
+
let index = path.length;
|
|
28211
|
+
while (index > 0 && path.charCodeAt(index - 1) === 47) index--;
|
|
28212
|
+
return path.length - index;
|
|
28213
|
+
};
|
|
28168
28214
|
const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
28169
28215
|
if (!/[:*]/.test(pathPrefix)) return pathPrefix.length;
|
|
28170
28216
|
const path = c.req.path;
|
|
@@ -28172,6 +28218,7 @@ const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
|
28172
28218
|
const paramNames = /* @__PURE__ */ new Set();
|
|
28173
28219
|
let length = 0;
|
|
28174
28220
|
for (const part of splitRoutingPath(pathPrefix)) {
|
|
28221
|
+
if (part[0] === ":" && part.endsWith("}?")) throw new Error(`mount(): Optional regular expression parameters are not supported in "${routePath}".`);
|
|
28175
28222
|
const pattern = getPattern(part);
|
|
28176
28223
|
if (pattern && pattern !== "*") {
|
|
28177
28224
|
const name = pattern[1];
|
|
@@ -28190,8 +28237,17 @@ const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
|
28190
28237
|
};
|
|
28191
28238
|
const createMountedRequest = (c, pathPrefix, routePath) => {
|
|
28192
28239
|
if (/[^/]\*$/.test(routePath)) throw new Error(`mount(): Wildcard must follow "/" in "${routePath}".`);
|
|
28193
|
-
const
|
|
28194
|
-
|
|
28240
|
+
const prefixLength = getPathPrefixLength(c, pathPrefix, routePath);
|
|
28241
|
+
const path = c.req.path.slice(prefixLength) || "/";
|
|
28242
|
+
if (prefixLength > c.req.path.length || path[0] !== "/" || /\/(?:\.|%2e){1,2}(?:\/|$)/i.test(path)) throw new HTTPException(400, { message: "Invalid mounted path" });
|
|
28243
|
+
const rawUrl = c.req.raw.url;
|
|
28244
|
+
if (/^[^/?#]*\/\/[^/?#\\]*[?#\\]/.test(rawUrl)) throw new HTTPException(400, { message: "Invalid mounted path" });
|
|
28245
|
+
const rawPathEnd = rawUrl.search(/[?#]/);
|
|
28246
|
+
const rawTrailingSlashes = countTrailingSlashes(rawPathEnd === -1 ? rawUrl : rawUrl.slice(0, rawPathEnd));
|
|
28247
|
+
if (rawTrailingSlashes > 1 && countTrailingSlashes(c.req.path) === rawTrailingSlashes - 1) throw new HTTPException(400, { message: "Invalid mounted path" });
|
|
28248
|
+
const url = new URL(rawUrl);
|
|
28249
|
+
url.pathname = path.replace(/[\\\t\n\r]/g, encodeURIComponent);
|
|
28250
|
+
if (path.includes("%")) {}
|
|
28195
28251
|
return new Request(url, c.req.raw);
|
|
28196
28252
|
};
|
|
28197
28253
|
// node_modules/hono/dist/hono-base.js
|
|
@@ -28374,6 +28430,8 @@ var Hono$1 = class Hono {
|
|
|
28374
28430
|
* @param {Function} applicationHandler - other Request Handler
|
|
28375
28431
|
* @param {MountOptions} [options] - options of `.mount()`
|
|
28376
28432
|
* @returns {Hono} mounted Hono instance
|
|
28433
|
+
* @throws {Error} If automatic request rewriting encounters duplicate path parameter names or an optional regular expression parameter.
|
|
28434
|
+
* @throws {HTTPException} With status 400 if automatic request rewriting cannot safely preserve the routed path.
|
|
28377
28435
|
*
|
|
28378
28436
|
* @example
|
|
28379
28437
|
* ```ts
|
|
@@ -28418,8 +28476,10 @@ var Hono$1 = class Hono {
|
|
|
28418
28476
|
} catch {}
|
|
28419
28477
|
return [c.env, executionContext];
|
|
28420
28478
|
};
|
|
28421
|
-
const
|
|
28422
|
-
|
|
28479
|
+
const defaultReplaceRequest = (c) => {
|
|
28480
|
+
const mountedRoutePath = routePath(c);
|
|
28481
|
+
return createMountedRequest(c, mountedRoutePath.replace(/\/?\*$/, ""), mountedRoutePath);
|
|
28482
|
+
};
|
|
28423
28483
|
const handler = async (c, next) => {
|
|
28424
28484
|
const res = await applicationHandler(replaceRequest ? replaceRequest(c.req.raw) : defaultReplaceRequest(c), ...getOptions(c));
|
|
28425
28485
|
if (res) return res;
|
|
@@ -29204,8 +29264,8 @@ const serveStatic = (options = { root: "" }) => {
|
|
|
29204
29264
|
let filename;
|
|
29205
29265
|
if (optionPath) filename = optionPath;
|
|
29206
29266
|
else try {
|
|
29207
|
-
if (!options.allowPercentInPath && c.req.path.includes("%")) throw new Error();
|
|
29208
29267
|
filename = tryDecodeURI(c.req.path);
|
|
29268
|
+
if (c.req.path.includes("%") && (!options.allowPercentInPath || filename !== c.req.path.replace(/%25/g, "%"))) throw new Error();
|
|
29209
29269
|
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}|\\/.test(filename)) throw new Error();
|
|
29210
29270
|
} catch {
|
|
29211
29271
|
await options.onNotFound?.(c.req.path, c);
|
|
@@ -30424,23 +30484,22 @@ const bodyLimit = (options) => {
|
|
|
30424
30484
|
const hasTransferEncoding = c.req.raw.headers.has("transfer-encoding");
|
|
30425
30485
|
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
30486
|
let size = 0;
|
|
30427
|
-
|
|
30487
|
+
let buffer = /* @__PURE__ */ new Uint8Array(0);
|
|
30428
30488
|
const rawReader = c.req.raw.body.getReader();
|
|
30429
30489
|
for (;;) {
|
|
30430
30490
|
const { done, value } = await rawReader.read();
|
|
30431
30491
|
if (done) break;
|
|
30492
|
+
const offset = size;
|
|
30432
30493
|
size += value.length;
|
|
30433
30494
|
if (size > maxSize) return onError(c);
|
|
30434
|
-
|
|
30495
|
+
if (size > buffer.length) {
|
|
30496
|
+
const grown = new Uint8Array(Math.min(maxSize, Math.max(size, buffer.length * 2)));
|
|
30497
|
+
grown.set(buffer.subarray(0, offset));
|
|
30498
|
+
buffer = grown;
|
|
30499
|
+
}
|
|
30500
|
+
buffer.set(value, offset);
|
|
30435
30501
|
}
|
|
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);
|
|
30502
|
+
c.req.raw = new Request(c.req.raw, { body: buffer.subarray(0, size) });
|
|
30444
30503
|
return next();
|
|
30445
30504
|
};
|
|
30446
30505
|
};
|
|
@@ -30946,7 +31005,7 @@ function processHost() {
|
|
|
30946
31005
|
const run = promisify(execFile);
|
|
30947
31006
|
return {
|
|
30948
31007
|
platform: process.platform,
|
|
30949
|
-
release: release(),
|
|
31008
|
+
release: release$2(),
|
|
30950
31009
|
env: process.env,
|
|
30951
31010
|
run: async (command, args) => (await run(command, args)).stdout,
|
|
30952
31011
|
onPath: (command) => (process.env.PATH ?? "").split(delimiter).some((dir) => dir !== "" && existsSync(join(dir, command)))
|
|
@@ -31270,424 +31329,6 @@ function swapSpan(source, span, side) {
|
|
|
31270
31329
|
span: moved
|
|
31271
31330
|
};
|
|
31272
31331
|
}
|
|
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
31332
|
// node_modules/@bramus/specificity/dist/index.js
|
|
31692
31333
|
var Jn = Object.create;
|
|
31693
31334
|
var te = Object.defineProperty;
|
|
@@ -33805,7 +33446,7 @@ var cs = 35;
|
|
|
33805
33446
|
var ls = 38;
|
|
33806
33447
|
var us = 42;
|
|
33807
33448
|
var hs = 43;
|
|
33808
|
-
var fs
|
|
33449
|
+
var fs = 47;
|
|
33809
33450
|
var Hn = 46;
|
|
33810
33451
|
var ps = 62;
|
|
33811
33452
|
var ms = 124;
|
|
@@ -33832,7 +33473,7 @@ function xs() {
|
|
|
33832
33473
|
case hs:
|
|
33833
33474
|
case ps:
|
|
33834
33475
|
case ds:
|
|
33835
|
-
case fs
|
|
33476
|
+
case fs: return this.Combinator();
|
|
33836
33477
|
case Hn: return this.ClassSelector();
|
|
33837
33478
|
case us:
|
|
33838
33479
|
case ms: return this.TypeSelector();
|
|
@@ -34920,7 +34561,7 @@ const textEscapeRegex = /[&<>\u{A0}]/gu;
|
|
|
34920
34561
|
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
|
34921
34562
|
* @param data String to escape.
|
|
34922
34563
|
*/
|
|
34923
|
-
function escapeText(data) {
|
|
34564
|
+
function escapeText$1(data) {
|
|
34924
34565
|
return escapeWithRegex(textEscapeRegex, data);
|
|
34925
34566
|
}
|
|
34926
34567
|
// node_modules/dom-serializer/dist/foreign-names.js
|
|
@@ -34984,7 +34625,7 @@ function renderNode(node, options, xmlMode) {
|
|
|
34984
34625
|
case Text$1: {
|
|
34985
34626
|
const element = node;
|
|
34986
34627
|
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);
|
|
34628
|
+
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
34629
|
return data;
|
|
34989
34630
|
}
|
|
34990
34631
|
}
|
|
@@ -36884,6 +36525,77 @@ function splitTopLevel(text, separator) {
|
|
|
36884
36525
|
parts.push(text.slice(start));
|
|
36885
36526
|
return parts;
|
|
36886
36527
|
}
|
|
36528
|
+
/** Words of a `border` or `background` shorthand that are never its color. */
|
|
36529
|
+
const NOT_COLOR = /* @__PURE__ */ new Set([
|
|
36530
|
+
"none",
|
|
36531
|
+
"hidden",
|
|
36532
|
+
"dotted",
|
|
36533
|
+
"dashed",
|
|
36534
|
+
"solid",
|
|
36535
|
+
"double",
|
|
36536
|
+
"groove",
|
|
36537
|
+
"ridge",
|
|
36538
|
+
"inset",
|
|
36539
|
+
"outset",
|
|
36540
|
+
"thin",
|
|
36541
|
+
"medium",
|
|
36542
|
+
"thick",
|
|
36543
|
+
"repeat",
|
|
36544
|
+
"no-repeat",
|
|
36545
|
+
"repeat-x",
|
|
36546
|
+
"repeat-y",
|
|
36547
|
+
"space",
|
|
36548
|
+
"round",
|
|
36549
|
+
"fixed",
|
|
36550
|
+
"scroll",
|
|
36551
|
+
"local",
|
|
36552
|
+
"center",
|
|
36553
|
+
"top",
|
|
36554
|
+
"bottom",
|
|
36555
|
+
"left",
|
|
36556
|
+
"right",
|
|
36557
|
+
"cover",
|
|
36558
|
+
"contain",
|
|
36559
|
+
"auto",
|
|
36560
|
+
"border-box",
|
|
36561
|
+
"padding-box",
|
|
36562
|
+
"content-box"
|
|
36563
|
+
]);
|
|
36564
|
+
/**
|
|
36565
|
+
* The part of a `border` or `background` shorthand that sets `property`:
|
|
36566
|
+
* the last part that reads as a color for a color, since a color comes last
|
|
36567
|
+
* in a border, and the first length for a width. Null when none does. An
|
|
36568
|
+
* `!important` ends the parts, so a raw attribute value reads as the parsed
|
|
36569
|
+
* one does, and `start` lets a writer replace the part in place.
|
|
36570
|
+
*/
|
|
36571
|
+
function shorthandPart(value, property) {
|
|
36572
|
+
const parts = [];
|
|
36573
|
+
let start = 0;
|
|
36574
|
+
for (const text of splitTopLevel(value, " ")) {
|
|
36575
|
+
const bang = text.search(/!\s*important$/i);
|
|
36576
|
+
if (bang === 0 || text.startsWith("!")) break;
|
|
36577
|
+
if (bang > 0) {
|
|
36578
|
+
parts.push({
|
|
36579
|
+
text: text.slice(0, bang),
|
|
36580
|
+
start
|
|
36581
|
+
});
|
|
36582
|
+
break;
|
|
36583
|
+
}
|
|
36584
|
+
if (text !== "") parts.push({
|
|
36585
|
+
text,
|
|
36586
|
+
start
|
|
36587
|
+
});
|
|
36588
|
+
start += text.length + 1;
|
|
36589
|
+
}
|
|
36590
|
+
if (property === "border-width") return parts.find(({ text }) => /^(?:[\d.]|thin|medium|thick)/i.test(text)) ?? null;
|
|
36591
|
+
return parts.findLast(({ text }) => isColorish(text)) ?? null;
|
|
36592
|
+
}
|
|
36593
|
+
function isColorish(part) {
|
|
36594
|
+
const lower = part.toLowerCase();
|
|
36595
|
+
if (NOT_COLOR.has(lower)) return false;
|
|
36596
|
+
if (/^[\d.+-]/.test(lower) || lower.includes("/")) return false;
|
|
36597
|
+
return !/^(?:url|[a-z-]*gradient|image-set)\(/.test(lower);
|
|
36598
|
+
}
|
|
36887
36599
|
/** The first family of a `font-family` list, unquoted. */
|
|
36888
36600
|
function firstOf(families) {
|
|
36889
36601
|
return (splitTopLevel(families, ",")[0] ?? "").trim().replace(/^(['"])(.*)\1$/, "$2").trim();
|
|
@@ -36915,6 +36627,486 @@ function shorthandFamily(value) {
|
|
|
36915
36627
|
const family = tokens.slice(familyAt).join(" ");
|
|
36916
36628
|
return family === "" ? null : family;
|
|
36917
36629
|
}
|
|
36630
|
+
// src/server/edit/style.ts
|
|
36631
|
+
/**
|
|
36632
|
+
* The longhands a shorthand write drops, so a later longhand in the attribute
|
|
36633
|
+
* does not keep overriding the value just set. A longhand write leaves its
|
|
36634
|
+
* shorthand alone, since the longhand comes later and already wins, except
|
|
36635
|
+
* where `PART_SHORTHANDS` rewrites the shorthand's own part instead.
|
|
36636
|
+
*/
|
|
36637
|
+
const BORDER_SIDES = [
|
|
36638
|
+
"top",
|
|
36639
|
+
"right",
|
|
36640
|
+
"bottom",
|
|
36641
|
+
"left"
|
|
36642
|
+
];
|
|
36643
|
+
const BORDER_PARTS = [
|
|
36644
|
+
"color",
|
|
36645
|
+
"style",
|
|
36646
|
+
"width"
|
|
36647
|
+
];
|
|
36648
|
+
const SHORTHAND_LONGHANDS = {
|
|
36649
|
+
background: [
|
|
36650
|
+
"background-attachment",
|
|
36651
|
+
"background-clip",
|
|
36652
|
+
"background-color",
|
|
36653
|
+
"background-image",
|
|
36654
|
+
"background-origin",
|
|
36655
|
+
"background-position",
|
|
36656
|
+
"background-repeat",
|
|
36657
|
+
"background-size"
|
|
36658
|
+
],
|
|
36659
|
+
border: [...BORDER_PARTS.map((part) => `border-${part}`), ...BORDER_SIDES.flatMap((side) => [`border-${side}`, ...BORDER_PARTS.map((part) => `border-${side}-${part}`)])],
|
|
36660
|
+
"border-radius": [
|
|
36661
|
+
"border-top-left-radius",
|
|
36662
|
+
"border-top-right-radius",
|
|
36663
|
+
"border-bottom-right-radius",
|
|
36664
|
+
"border-bottom-left-radius"
|
|
36665
|
+
],
|
|
36666
|
+
padding: [
|
|
36667
|
+
"padding-top",
|
|
36668
|
+
"padding-right",
|
|
36669
|
+
"padding-bottom",
|
|
36670
|
+
"padding-left"
|
|
36671
|
+
]
|
|
36672
|
+
};
|
|
36673
|
+
/** The paint longhands whose part of a shorthand the inspector reads, and that shorthand. */
|
|
36674
|
+
const PART_SHORTHANDS = {
|
|
36675
|
+
"background-color": "background",
|
|
36676
|
+
"border-color": "border",
|
|
36677
|
+
"border-width": "border"
|
|
36678
|
+
};
|
|
36679
|
+
const CHARACTER_REFERENCE = /&(?:#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/iy;
|
|
36680
|
+
const DOUBLE_QUOTE_REFERENCES = /* @__PURE__ */ new Set([
|
|
36681
|
+
""",
|
|
36682
|
+
""",
|
|
36683
|
+
"""
|
|
36684
|
+
]);
|
|
36685
|
+
const SINGLE_QUOTE_REFERENCES = /* @__PURE__ */ new Set([
|
|
36686
|
+
"'",
|
|
36687
|
+
"'",
|
|
36688
|
+
"'"
|
|
36689
|
+
]);
|
|
36690
|
+
/** The end of the character reference starting at an offset, or undefined. */
|
|
36691
|
+
function referenceEnd(style, at) {
|
|
36692
|
+
if (style[at] !== "&") return void 0;
|
|
36693
|
+
CHARACTER_REFERENCE.lastIndex = at;
|
|
36694
|
+
return CHARACTER_REFERENCE.test(style) ? CHARACTER_REFERENCE.lastIndex : void 0;
|
|
36695
|
+
}
|
|
36696
|
+
/**
|
|
36697
|
+
* Splits a raw, still-encoded style value at each semicolon outside
|
|
36698
|
+
* parentheses, quotes, and comments, keeping every segment's own spacing so
|
|
36699
|
+
* an untouched one is written back as it was. A character reference's own
|
|
36700
|
+
* semicolon never splits, a quote written as one is still a quote to CSS once
|
|
36701
|
+
* decoded, and a backslash escapes the character after it, so `'a\'` leaves
|
|
36702
|
+
* the quote open.
|
|
36703
|
+
*/
|
|
36704
|
+
function declarations(style) {
|
|
36705
|
+
const segments = [];
|
|
36706
|
+
let depth = 0;
|
|
36707
|
+
let quote;
|
|
36708
|
+
let isComment = false;
|
|
36709
|
+
let start = 0;
|
|
36710
|
+
for (let at = 0; at < style.length; at += 1) {
|
|
36711
|
+
const char = style[at];
|
|
36712
|
+
if (isComment) {
|
|
36713
|
+
if (style.startsWith("*/", at)) {
|
|
36714
|
+
isComment = false;
|
|
36715
|
+
at += 1;
|
|
36716
|
+
}
|
|
36717
|
+
continue;
|
|
36718
|
+
}
|
|
36719
|
+
if (char === "\\") {
|
|
36720
|
+
at = (referenceEnd(style, at + 1) ?? at + 2) - 1;
|
|
36721
|
+
continue;
|
|
36722
|
+
}
|
|
36723
|
+
const end = referenceEnd(style, at);
|
|
36724
|
+
if (end !== void 0) {
|
|
36725
|
+
const reference = style.slice(at, end).toLowerCase();
|
|
36726
|
+
at = end - 1;
|
|
36727
|
+
const referenced = DOUBLE_QUOTE_REFERENCES.has(reference) ? "\"" : SINGLE_QUOTE_REFERENCES.has(reference) ? "'" : void 0;
|
|
36728
|
+
if (referenced && quote === referenced) quote = void 0;
|
|
36729
|
+
else if (referenced && !quote) quote = referenced;
|
|
36730
|
+
} else if (quote) {
|
|
36731
|
+
if (char === quote) quote = void 0;
|
|
36732
|
+
} else if (style.startsWith("/*", at)) {
|
|
36733
|
+
isComment = true;
|
|
36734
|
+
at += 1;
|
|
36735
|
+
} else if (char === "\"" || char === "'") quote = char;
|
|
36736
|
+
else if (char === "(") depth += 1;
|
|
36737
|
+
else if (char === ")") depth = Math.max(0, depth - 1);
|
|
36738
|
+
else if (char === ";" && depth === 0) {
|
|
36739
|
+
segments.push(style.slice(start, at));
|
|
36740
|
+
start = at + 1;
|
|
36741
|
+
}
|
|
36742
|
+
}
|
|
36743
|
+
segments.push(style.slice(start));
|
|
36744
|
+
return {
|
|
36745
|
+
segments,
|
|
36746
|
+
isOpen: quote !== void 0 || isComment
|
|
36747
|
+
};
|
|
36748
|
+
}
|
|
36749
|
+
/** The property a declaration names, read past any comment ahead of it. */
|
|
36750
|
+
function propertyOf(segment) {
|
|
36751
|
+
return segment.replace(/\/\*[\s\S]*?\*\//g, "").split(":", 1)[0]?.trim().toLowerCase() ?? "";
|
|
36752
|
+
}
|
|
36753
|
+
/** The values a style declares for one property, in order, read from a decoded style. */
|
|
36754
|
+
function declaredValues(style, property) {
|
|
36755
|
+
return declarations(style).segments.filter((segment) => propertyOf(segment) === property).map((segment) => segment.slice(segment.indexOf(":") + 1).trim());
|
|
36756
|
+
}
|
|
36757
|
+
/**
|
|
36758
|
+
* The part of a decoded style's last shorthand that a paint longhand reads
|
|
36759
|
+
* from, which `setDeclaration` writes in place of the longhand. Undefined for
|
|
36760
|
+
* a property with no such shorthand, or a shorthand holding no such part.
|
|
36761
|
+
*/
|
|
36762
|
+
function shorthandValue(style, property) {
|
|
36763
|
+
const shorthand = PART_SHORTHANDS[property];
|
|
36764
|
+
if (!shorthand) return void 0;
|
|
36765
|
+
const value = declaredValues(style, shorthand).at(-1);
|
|
36766
|
+
return value === void 0 ? void 0 : shorthandPart(value, property)?.text;
|
|
36767
|
+
}
|
|
36768
|
+
/**
|
|
36769
|
+
* Sets one declaration in a raw style value, or drops it on an empty value.
|
|
36770
|
+
* The first declaration of the property is replaced in place and any later one
|
|
36771
|
+
* dropped, so nothing further in the attribute overrides the edit, and a
|
|
36772
|
+
* shorthand also drops its longhands. A paint longhand over a shorthand
|
|
36773
|
+
* holding its part rewrites that part instead. The value arrives already escaped for
|
|
36774
|
+
* the attribute. An empty style means none is left. A style ending inside an
|
|
36775
|
+
* open quote or comment refuses, since an appended declaration would land in it.
|
|
36776
|
+
*/
|
|
36777
|
+
function setDeclaration(style, property, value) {
|
|
36778
|
+
const parsed = declarations(style);
|
|
36779
|
+
if (parsed.isOpen) return { ok: false };
|
|
36780
|
+
const longhands = SHORTHAND_LONGHANDS[property] ?? [];
|
|
36781
|
+
const segments = parsed.segments.filter((segment) => !longhands.includes(propertyOf(segment)));
|
|
36782
|
+
const declaration = `${property}: ${value.trim()}`;
|
|
36783
|
+
if (value.trim() === "") {
|
|
36784
|
+
const kept = segments.filter((segment) => propertyOf(segment) !== property);
|
|
36785
|
+
if (kept.every((segment) => segment.trim() === "")) return {
|
|
36786
|
+
ok: true,
|
|
36787
|
+
style: ""
|
|
36788
|
+
};
|
|
36789
|
+
return {
|
|
36790
|
+
ok: true,
|
|
36791
|
+
style: kept.join(";").replace(/^[\s;]+/, "")
|
|
36792
|
+
};
|
|
36793
|
+
}
|
|
36794
|
+
const rewritten = withShorthandPart(segments, property, value.trim());
|
|
36795
|
+
if (rewritten !== null) return {
|
|
36796
|
+
ok: true,
|
|
36797
|
+
style: rewritten
|
|
36798
|
+
};
|
|
36799
|
+
if (!segments.some((segment) => propertyOf(segment) === property)) {
|
|
36800
|
+
const kept = segments.filter((segment) => segment.trim() !== "").join(";").replace(/^\s+/, "");
|
|
36801
|
+
return {
|
|
36802
|
+
ok: true,
|
|
36803
|
+
style: kept === "" ? declaration : `${kept}; ${declaration}`
|
|
36804
|
+
};
|
|
36805
|
+
}
|
|
36806
|
+
let isReplaced = false;
|
|
36807
|
+
return {
|
|
36808
|
+
ok: true,
|
|
36809
|
+
style: segments.flatMap((segment) => {
|
|
36810
|
+
if (propertyOf(segment) !== property) return [segment];
|
|
36811
|
+
if (isReplaced) return [];
|
|
36812
|
+
isReplaced = true;
|
|
36813
|
+
return [`${/^\s*/.exec(segment)?.[0] ?? ""}${declaration}`];
|
|
36814
|
+
}).join(";")
|
|
36815
|
+
};
|
|
36816
|
+
}
|
|
36817
|
+
/**
|
|
36818
|
+
* The segments with `value` in place of the part of the last shorthand that
|
|
36819
|
+
* sets `property`, so a paint edit over `border: 1px solid var(--primary)`
|
|
36820
|
+
* leaves no token behind it as dead text. A declaration of the property ahead
|
|
36821
|
+
* of the shorthand is already overridden by it, so it drops. Null when the
|
|
36822
|
+
* property has no such shorthand, a later declaration sets the part on any
|
|
36823
|
+
* side and would keep winning there, its value holds no such part, or a
|
|
36824
|
+
* comment sits in it.
|
|
36825
|
+
*/
|
|
36826
|
+
function withShorthandPart(segments, property, value) {
|
|
36827
|
+
const shorthand = PART_SHORTHANDS[property];
|
|
36828
|
+
if (!shorthand) return null;
|
|
36829
|
+
const at = segments.findLastIndex((segment) => propertyOf(segment) === shorthand);
|
|
36830
|
+
const segment = segments[at];
|
|
36831
|
+
if (segment === void 0 || segment.includes("/*")) return null;
|
|
36832
|
+
if (segments.slice(at + 1).some((later) => setsPart(propertyOf(later), property))) return null;
|
|
36833
|
+
const colon = segment.indexOf(":");
|
|
36834
|
+
const part = shorthandPart(segment.slice(colon + 1), property);
|
|
36835
|
+
if (!part) return null;
|
|
36836
|
+
const from = colon + 1 + part.start;
|
|
36837
|
+
const rewritten = segment.slice(0, from) + value + segment.slice(from + part.text.length);
|
|
36838
|
+
return segments.flatMap((each, index) => {
|
|
36839
|
+
if (index === at) return [rewritten];
|
|
36840
|
+
return index < at && propertyOf(each) === property ? [] : [each];
|
|
36841
|
+
}).join(";").replace(/^\s+/, "");
|
|
36842
|
+
}
|
|
36843
|
+
const BORDER_SIDE = /^border-(?:top|right|bottom|left|block|inline)(?:-(?:start|end))?(?:-(color|width|style))?$/;
|
|
36844
|
+
/**
|
|
36845
|
+
* Whether a declaration of `declared` sets the part `property` names on any
|
|
36846
|
+
* side, as `border-top` or `border-top-width` does for `border-width`.
|
|
36847
|
+
*/
|
|
36848
|
+
function setsPart(declared, property) {
|
|
36849
|
+
if (declared === property) return true;
|
|
36850
|
+
const side = BORDER_SIDE.exec(declared);
|
|
36851
|
+
if (!side || !property.startsWith("border-")) return false;
|
|
36852
|
+
return side[1] === void 0 || `border-${side[1]}` === property;
|
|
36853
|
+
}
|
|
36854
|
+
/**
|
|
36855
|
+
* Rewrites each declaration's value in a raw style through `rewrite`, which
|
|
36856
|
+
* takes the property and the value with its spacing and answers the value to
|
|
36857
|
+
* keep, so every byte it leaves alone is written back as it was. A
|
|
36858
|
+
* declaration carrying a comment is kept as written, since its `:` may sit
|
|
36859
|
+
* inside the comment. Null for a style ending inside an open quote or comment.
|
|
36860
|
+
*/
|
|
36861
|
+
function rewriteValues(style, rewrite) {
|
|
36862
|
+
const parsed = declarations(style);
|
|
36863
|
+
if (parsed.isOpen) return null;
|
|
36864
|
+
return parsed.segments.map((segment) => {
|
|
36865
|
+
const colon = segment.indexOf(":");
|
|
36866
|
+
if (colon < 0 || segment.includes("/*")) return segment;
|
|
36867
|
+
return segment.slice(0, colon + 1) + rewrite(propertyOf(segment), segment.slice(colon + 1));
|
|
36868
|
+
}).join(";");
|
|
36869
|
+
}
|
|
36870
|
+
// src/server/edit/text.ts
|
|
36871
|
+
/** Elements whose content the tokenizer reads as raw text, not as a text node to splice. */
|
|
36872
|
+
const RAW_TEXT = /* @__PURE__ */ new Set([
|
|
36873
|
+
"script",
|
|
36874
|
+
"style",
|
|
36875
|
+
"template",
|
|
36876
|
+
"textarea",
|
|
36877
|
+
"title"
|
|
36878
|
+
]);
|
|
36879
|
+
/** Elements whose text the tree builder moves elsewhere, so a write never lands inside them. */
|
|
36880
|
+
const RELOCATING = /* @__PURE__ */ new Set([
|
|
36881
|
+
"html",
|
|
36882
|
+
"head",
|
|
36883
|
+
"table",
|
|
36884
|
+
"thead",
|
|
36885
|
+
"tbody",
|
|
36886
|
+
"tfoot",
|
|
36887
|
+
"tr",
|
|
36888
|
+
"colgroup",
|
|
36889
|
+
"select",
|
|
36890
|
+
"frameset"
|
|
36891
|
+
]);
|
|
36892
|
+
/** The parser drops one leading newline inside these. */
|
|
36893
|
+
const LEADING_NEWLINE_DROPPED = /* @__PURE__ */ new Set(["pre", "listing"]);
|
|
36894
|
+
function escapeText(value) {
|
|
36895
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
36896
|
+
}
|
|
36897
|
+
/**
|
|
36898
|
+
* Replaces the text of an element holding text alone. The source between its
|
|
36899
|
+
* tags must be exactly its one text node, or nothing, since misnested markup
|
|
36900
|
+
* such as `<b>1<p>2</b>` leaves the element's end tag past markup the tree
|
|
36901
|
+
* builder gave to another element.
|
|
36902
|
+
*/
|
|
36903
|
+
function setText(source, element, value) {
|
|
36904
|
+
const tag = element.tagName;
|
|
36905
|
+
const location = element.sourceCodeLocation;
|
|
36906
|
+
if (RAW_TEXT.has(tag)) return {
|
|
36907
|
+
ok: false,
|
|
36908
|
+
detail: `<${tag}> holds raw content, not text`
|
|
36909
|
+
};
|
|
36910
|
+
if (RELOCATING.has(tag)) return {
|
|
36911
|
+
ok: false,
|
|
36912
|
+
detail: `the parser moves text written inside <${tag}>`
|
|
36913
|
+
};
|
|
36914
|
+
if (!location?.startTag || !location.endTag) return {
|
|
36915
|
+
ok: false,
|
|
36916
|
+
detail: `<${tag}> has no end tag to bound its text`
|
|
36917
|
+
};
|
|
36918
|
+
const from = location.startTag.endOffset;
|
|
36919
|
+
const to = location.endTag.startOffset;
|
|
36920
|
+
const [only, ...rest] = element.childNodes;
|
|
36921
|
+
if (!(only === void 0 ? from === to : rest.length === 0 && only.nodeName === "#text" && only.sourceCodeLocation?.startOffset === from && only.sourceCodeLocation.endOffset === to)) return {
|
|
36922
|
+
ok: false,
|
|
36923
|
+
detail: `<${tag}> holds more than one text node`
|
|
36924
|
+
};
|
|
36925
|
+
const written = LEADING_NEWLINE_DROPPED.has(tag) && value.startsWith("\n") ? `\n${value}` : value;
|
|
36926
|
+
return {
|
|
36927
|
+
ok: true,
|
|
36928
|
+
html: source.slice(0, from) + escapeText(written) + source.slice(to)
|
|
36929
|
+
};
|
|
36930
|
+
}
|
|
36931
|
+
// src/server/edit/apply.ts
|
|
36932
|
+
const MAX_VALUE_LENGTH = 200;
|
|
36933
|
+
/** Anything that would end the declaration and start another. */
|
|
36934
|
+
const DECLARATION_BREAK = /[;{}<>\n\r]/;
|
|
36935
|
+
const PROPERTY_NAME = /^(?:--[\w-]+|-?[a-z][a-z0-9-]*)$/i;
|
|
36936
|
+
/** What the tokenizer reads as one attribute name. */
|
|
36937
|
+
const ATTRIBUTE_NAME = /^[^\s"'<>/=]+$/;
|
|
36938
|
+
function refuse$2(reason, detail) {
|
|
36939
|
+
return {
|
|
36940
|
+
ok: false,
|
|
36941
|
+
reason,
|
|
36942
|
+
detail
|
|
36943
|
+
};
|
|
36944
|
+
}
|
|
36945
|
+
function checkValue(value) {
|
|
36946
|
+
return value.length > MAX_VALUE_LENGTH ? refuse$2("invalid-edit", `the value runs past ${MAX_VALUE_LENGTH} characters`) : void 0;
|
|
36947
|
+
}
|
|
36948
|
+
function checkDeclaration({ property, value }) {
|
|
36949
|
+
const invalid = checkValue(value);
|
|
36950
|
+
if (invalid) return invalid;
|
|
36951
|
+
if (!PROPERTY_NAME.test(property)) return refuse$2("invalid-edit", `${property} is not a CSS property name`);
|
|
36952
|
+
if (DECLARATION_BREAK.test(value)) return refuse$2("invalid-edit", `${property} takes one value, with no ; { } < > or line break`);
|
|
36953
|
+
}
|
|
36954
|
+
function checkChange(change) {
|
|
36955
|
+
if (change.kind === "style") return checkDeclaration(change);
|
|
36956
|
+
if (change.kind === "styles") {
|
|
36957
|
+
const { declarations } = change;
|
|
36958
|
+
if (declarations.length === 0) return refuse$2("invalid-edit", "a styles edit names no declaration");
|
|
36959
|
+
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");
|
|
36960
|
+
for (const declaration of declarations) {
|
|
36961
|
+
const invalid = checkDeclaration(declaration);
|
|
36962
|
+
if (invalid) return invalid;
|
|
36963
|
+
}
|
|
36964
|
+
return;
|
|
36965
|
+
}
|
|
36966
|
+
if ("value" in change) {
|
|
36967
|
+
const invalid = checkValue(change.value);
|
|
36968
|
+
if (invalid) return invalid;
|
|
36969
|
+
}
|
|
36970
|
+
if (change.kind === "attribute") {
|
|
36971
|
+
if (!ATTRIBUTE_NAME.test(change.name)) return refuse$2("invalid-edit", `${change.name} is not an attribute name`);
|
|
36972
|
+
if (change.name.toLowerCase() === "style") return refuse$2("invalid-edit", "style is edited one declaration at a time, as a style edit");
|
|
36973
|
+
}
|
|
36974
|
+
}
|
|
36975
|
+
function resolve(tree, index) {
|
|
36976
|
+
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`);
|
|
36977
|
+
const element = Number.isInteger(index) ? tree.elements[index] : void 0;
|
|
36978
|
+
if (!element) return refuse$2("invalid-address", `the frame holds elements 0 to ${tree.elements.length - 1}, so ${index} names none`);
|
|
36979
|
+
if (!element.sourceCodeLocation?.startTag) return refuse$2("address-mismatch", `<${element.tagName}> at ${index} is implied, not stated in the file`);
|
|
36980
|
+
return element;
|
|
36981
|
+
}
|
|
36982
|
+
/** Which bytes of the element a change reads and writes, as `SpanScope` splits them. */
|
|
36983
|
+
function scopeOf(change) {
|
|
36984
|
+
return change.kind === "text" ? "element" : "start-tag";
|
|
36985
|
+
}
|
|
36986
|
+
/** The attribute name an edit writes, or undefined for a text edit. */
|
|
36987
|
+
function editedAttribute(change) {
|
|
36988
|
+
if (change.kind === "style" || change.kind === "styles") return "style";
|
|
36989
|
+
if (change.kind === "attribute") return change.name;
|
|
36990
|
+
}
|
|
36991
|
+
function write(source, element, change) {
|
|
36992
|
+
if (change.kind === "text") {
|
|
36993
|
+
const written = setText(source, element, change.value);
|
|
36994
|
+
return written.ok ? written : refuse$2("not-text-only", written.detail);
|
|
36995
|
+
}
|
|
36996
|
+
if (change.kind === "attribute") {
|
|
36997
|
+
if ("remove" in change) return {
|
|
36998
|
+
ok: true,
|
|
36999
|
+
html: removeAttribute(source, element, change.name)
|
|
37000
|
+
};
|
|
37001
|
+
return {
|
|
37002
|
+
ok: true,
|
|
37003
|
+
html: setRawAttribute(source, element, change.name, escapeAttribute$1(change.value))
|
|
37004
|
+
};
|
|
37005
|
+
}
|
|
37006
|
+
const declarations = change.kind === "styles" ? change.declarations : [change];
|
|
37007
|
+
let style = rawAttribute(source, element, "style") ?? "";
|
|
37008
|
+
for (const { property, value } of declarations) {
|
|
37009
|
+
const next = setDeclaration(style, property, escapeAttribute$1(value));
|
|
37010
|
+
if (!next.ok) return refuse$2("open-quote", `the style on <${element.tagName}> ends inside an open quote or comment`);
|
|
37011
|
+
style = next.style;
|
|
37012
|
+
}
|
|
37013
|
+
return {
|
|
37014
|
+
ok: true,
|
|
37015
|
+
html: style === "" ? removeAttribute(source, element, "style") : setRawAttribute(source, element, "style", style)
|
|
37016
|
+
};
|
|
37017
|
+
}
|
|
37018
|
+
/**
|
|
37019
|
+
* Whether an attribute is the one the file states under a lowercased name.
|
|
37020
|
+
* In SVG and MathML, parse5 adjusts names after tokenizing, turning `viewbox`
|
|
37021
|
+
* into `viewBox` and `xlink:href` into `href` under an `xlink` prefix.
|
|
37022
|
+
*/
|
|
37023
|
+
function isNamed(attribute, name) {
|
|
37024
|
+
return (attribute.prefix ? `${attribute.prefix}:${attribute.name}` : attribute.name).toLowerCase() === name;
|
|
37025
|
+
}
|
|
37026
|
+
/**
|
|
37027
|
+
* Whether the output's tree is the input's with only the target changed. The
|
|
37028
|
+
* target's edited attribute, or its text, is copied across from the output,
|
|
37029
|
+
* so the comparison covers every other node, and the caller's own check
|
|
37030
|
+
* covers the value itself.
|
|
37031
|
+
*/
|
|
37032
|
+
function changesOnlyTarget(before, after, index, change) {
|
|
37033
|
+
if (after.elements.length !== before.elements.length) return false;
|
|
37034
|
+
const was = before.elements[index];
|
|
37035
|
+
const now = after.elements[index];
|
|
37036
|
+
if (!was || !now || was.tagName !== now.tagName) return false;
|
|
37037
|
+
const name = editedAttribute(change);
|
|
37038
|
+
if (name === void 0) was.childNodes = now.childNodes;
|
|
37039
|
+
else {
|
|
37040
|
+
const written = now.attrs.find((attribute) => isNamed(attribute, name));
|
|
37041
|
+
const others = was.attrs.filter((attribute) => !isNamed(attribute, name));
|
|
37042
|
+
was.attrs = written ? [...others, written] : others;
|
|
37043
|
+
now.attrs = written ? [...now.attrs.filter((attribute) => attribute !== written), written] : now.attrs;
|
|
37044
|
+
}
|
|
37045
|
+
return serialize$1(before.document) === serialize$1(after.document);
|
|
37046
|
+
}
|
|
37047
|
+
function textOf$1(element) {
|
|
37048
|
+
return element.childNodes.map((node) => "value" in node && node.nodeName === "#text" ? node.value : "").join("");
|
|
37049
|
+
}
|
|
37050
|
+
/** Whether the target holds the value the change asked for. */
|
|
37051
|
+
function holdsValue(element, change) {
|
|
37052
|
+
if (change.kind === "text") return textOf$1(element) === change.value;
|
|
37053
|
+
if (change.kind === "attribute") {
|
|
37054
|
+
const stated = element.attrs.find((attribute) => isNamed(attribute, change.name));
|
|
37055
|
+
return "remove" in change ? stated === void 0 : stated?.value === change.value;
|
|
37056
|
+
}
|
|
37057
|
+
const style = element.attrs.find((attribute) => attribute.name === "style")?.value ?? "";
|
|
37058
|
+
return (change.kind === "styles" ? change.declarations : [change]).every(({ property, value }) => {
|
|
37059
|
+
const declared = declaredValues(style, property);
|
|
37060
|
+
const wanted = value.trim();
|
|
37061
|
+
if (wanted === "") return declared.length === 0;
|
|
37062
|
+
return declared.length === 0 ? shorthandValue(style, property) === wanted : declared.length === 1 && declared[0] === wanted;
|
|
37063
|
+
});
|
|
37064
|
+
}
|
|
37065
|
+
/**
|
|
37066
|
+
* Applies one change to the element the address names and leaves every other
|
|
37067
|
+
* byte of the source as it was, a `styles` change writing each declaration in
|
|
37068
|
+
* turn into the one style attribute. The output is parsed again and refused as
|
|
37069
|
+
* `verify-failed` unless its tree is the input's with that one change, so an
|
|
37070
|
+
* input the guards never met is refused rather than written corrupted.
|
|
37071
|
+
*/
|
|
37072
|
+
function applyEdit(source, address, change) {
|
|
37073
|
+
const normalized = change.kind === "style" ? {
|
|
37074
|
+
...change,
|
|
37075
|
+
property: change.property.toLowerCase()
|
|
37076
|
+
} : change.kind === "styles" ? {
|
|
37077
|
+
...change,
|
|
37078
|
+
declarations: change.declarations.map((declaration) => ({
|
|
37079
|
+
...declaration,
|
|
37080
|
+
property: declaration.property.toLowerCase()
|
|
37081
|
+
}))
|
|
37082
|
+
} : change.kind === "attribute" ? {
|
|
37083
|
+
...change,
|
|
37084
|
+
name: change.name.toLowerCase()
|
|
37085
|
+
} : change;
|
|
37086
|
+
const invalid = checkChange(normalized);
|
|
37087
|
+
if (invalid) return invalid;
|
|
37088
|
+
const before = parseFrame(source);
|
|
37089
|
+
const element = resolve(before, address.index);
|
|
37090
|
+
if ("ok" in element) return element;
|
|
37091
|
+
const written = write(source, element, normalized);
|
|
37092
|
+
if (!written.ok) return written;
|
|
37093
|
+
const after = parseFrame(written.html);
|
|
37094
|
+
const target = after.elements[address.index];
|
|
37095
|
+
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`);
|
|
37096
|
+
const scope = scopeOf(normalized);
|
|
37097
|
+
const span = {
|
|
37098
|
+
scope,
|
|
37099
|
+
index: address.index,
|
|
37100
|
+
count: before.elements.length,
|
|
37101
|
+
before: spanText(source, element, scope),
|
|
37102
|
+
after: spanText(written.html, target, scope)
|
|
37103
|
+
};
|
|
37104
|
+
return {
|
|
37105
|
+
ok: true,
|
|
37106
|
+
html: written.html,
|
|
37107
|
+
span
|
|
37108
|
+
};
|
|
37109
|
+
}
|
|
36918
37110
|
// src/server/edit/elements.ts
|
|
36919
37111
|
/** How long a text-only element's text may run as its name. */
|
|
36920
37112
|
const NAME_LENGTH = 40;
|
|
@@ -37792,42 +37984,6 @@ const NEVER_USES = /* @__PURE__ */ new Set([
|
|
|
37792
37984
|
"optgroup",
|
|
37793
37985
|
"option"
|
|
37794
37986
|
]);
|
|
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
37987
|
const VAR = /^var\(\s*(--[\w-]+)\s*(?:,.*)?\)$/is;
|
|
37832
37988
|
const MIX = /^color-mix\(\s*in\s+srgb\s*,\s*var\(\s*(--[\w-]+)\s*(?:,[^)]*)?\)\s+([\d.]+)%\s*,\s*transparent\s*\)$/is;
|
|
37833
37989
|
const HEX_ALPHA = /^#([0-9a-f]{6})([0-9a-f]{2})$/i;
|
|
@@ -37858,7 +38014,7 @@ function frameStyles(source, tokens, index) {
|
|
|
37858
38014
|
const read = (element, property) => {
|
|
37859
38015
|
const found = cascade.specified(element, property);
|
|
37860
38016
|
if (!found) return null;
|
|
37861
|
-
const part = found.shorthand ? shorthandPart(found.value, property) : found.value;
|
|
38017
|
+
const part = found.shorthand ? shorthandPart(found.value, property)?.text ?? null : found.value;
|
|
37862
38018
|
return part === null ? null : named(part, found.element);
|
|
37863
38019
|
};
|
|
37864
38020
|
const family = (element) => {
|
|
@@ -37985,22 +38141,6 @@ function declaredNames(sheets) {
|
|
|
37985
38141
|
}
|
|
37986
38142
|
return names;
|
|
37987
38143
|
}
|
|
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
38144
|
function within$1(element, root) {
|
|
38005
38145
|
for (let current = element; current;) {
|
|
38006
38146
|
if (current === root) return true;
|
|
@@ -38154,6 +38294,13 @@ function children(element) {
|
|
|
38154
38294
|
function subtree(element) {
|
|
38155
38295
|
return children(element).reduce((count, child) => count + subtree(child), 1);
|
|
38156
38296
|
}
|
|
38297
|
+
/** The first of `Container`, `Container 2`, and on that no element of `elements` is named. */
|
|
38298
|
+
function containerName(elements) {
|
|
38299
|
+
const taken = new Set(elements.flatMap((element) => element.attrs.flatMap((attr) => attr.name === "data-name" ? [attr.value.trim()] : [])));
|
|
38300
|
+
let name = "Container";
|
|
38301
|
+
for (let n = 2; taken.has(name); n += 1) name = `Container ${n}`;
|
|
38302
|
+
return name;
|
|
38303
|
+
}
|
|
38157
38304
|
function isFree(facts) {
|
|
38158
38305
|
const position = facts?.position?.trim().toLowerCase();
|
|
38159
38306
|
return position === "absolute" || position === "fixed";
|
|
@@ -38196,7 +38343,7 @@ function wrapElements(source, indexes, flow, spot, facts) {
|
|
|
38196
38343
|
if (!start || ranges.some((range) => !range)) return refuse$2("verify-failed", "a member lost its place in the file, so nothing was written");
|
|
38197
38344
|
const indent = /\n[ \t]*$/.exec(html.slice(0, start[0]))?.[0] ?? "";
|
|
38198
38345
|
const inner = indent === "" ? "" : `${indent} `;
|
|
38199
|
-
const
|
|
38346
|
+
const declarations = [
|
|
38200
38347
|
"display: flex",
|
|
38201
38348
|
`flex-direction: ${flow.direction}`,
|
|
38202
38349
|
`gap: ${px(flow.gap)}`,
|
|
@@ -38205,7 +38352,8 @@ function wrapElements(source, indexes, flow, spot, facts) {
|
|
|
38205
38352
|
`left: ${px(spot.left)}`,
|
|
38206
38353
|
`top: ${px(spot.top)}`
|
|
38207
38354
|
] : []
|
|
38208
|
-
]
|
|
38355
|
+
];
|
|
38356
|
+
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
38357
|
let wrapped = html;
|
|
38210
38358
|
for (const range of ranges.slice(1).toReversed()) {
|
|
38211
38359
|
if (!range) continue;
|
|
@@ -38373,13 +38521,10 @@ function namedOnceEach(indexes, edits) {
|
|
|
38373
38521
|
* edit, through a temporary file and a rename after reading the file again.
|
|
38374
38522
|
* A hash the file no longer has is refused as stale with no search, since the
|
|
38375
38523
|
* 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.
|
|
38524
|
+
* insert at most once. Given `place`, the element is placed out of the flow
|
|
38525
|
+
* in the same write. Its span carries the placed bytes and `parent` the start
|
|
38526
|
+
* tag a static parent took, so one undo takes the element out after the
|
|
38527
|
+
* parent's tag goes back, and a redo finds the gap as it first stood.
|
|
38383
38528
|
*/
|
|
38384
38529
|
function insertFrameFile(path, hash, placement, markup, place) {
|
|
38385
38530
|
const read = readSource(path);
|
|
@@ -40423,69 +40568,13 @@ const recolorSchema = object$1({
|
|
|
40423
40568
|
* A hand edit of one element, a placed element, and a deleted one, each behind
|
|
40424
40569
|
* `requireWriter` and refused on a frame another session holds.
|
|
40425
40570
|
*
|
|
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.
|
|
40571
|
+
* Every write names the frame by the `hash` the board rendered and goes through
|
|
40572
|
+
* `editFrameFile`, which finds the element again in a frame an agent wrote
|
|
40573
|
+
* since and records the span as one undoable step. A refusal answers 409 with
|
|
40574
|
+
* its code, such as `stale-address`, and writes nothing. A batch field
|
|
40575
|
+
* (`edits`, `indexes`, `places`) writes each item as one step and is refused
|
|
40576
|
+
* whole on any refusal. An insert takes an element kind, never markup, and a
|
|
40577
|
+
* recolor rewrites inline colors only. Each write remaps pinned notes.
|
|
40489
40578
|
*/
|
|
40490
40579
|
function editRoutes(root, access, history, version, sheets) {
|
|
40491
40580
|
const app = new Hono();
|
|
@@ -41424,24 +41513,15 @@ const CONTENT_TYPES$1 = {
|
|
|
41424
41513
|
".m4a": "audio/mp4"
|
|
41425
41514
|
};
|
|
41426
41515
|
/**
|
|
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.
|
|
41516
|
+
* Serves `/frames/<project>/<page>/<file>`, `/frames/<project>/assets/<path>`,
|
|
41517
|
+
* and `/frames/<project>/tokens.css` from the board, so a frame's relative
|
|
41518
|
+
* links resolve with no rewriting. It is a handler of its own rather than
|
|
41519
|
+
* static serving, since it must refuse board records, dot-named paths, and any
|
|
41520
|
+
* path whose realpath leaves its project. Every refusal answers 404, so
|
|
41521
|
+
* nothing tells a caller what exists. A frame gets the faces and token sheets
|
|
41522
|
+
* spliced into its `head`, in the response alone and never cached. Any other
|
|
41523
|
+
* file is served byte for byte under a validator, and `?at=<hash>` serves the
|
|
41524
|
+
* version `version` holds. `base` prefixes the head's sheet URLs.
|
|
41445
41525
|
*/
|
|
41446
41526
|
function frameRoutes(root, look, version, base = "") {
|
|
41447
41527
|
const app = new Hono();
|
|
@@ -41712,7 +41792,7 @@ const START_WINDOW_MS = 2e3;
|
|
|
41712
41792
|
*/
|
|
41713
41793
|
function createDispatcher({ command, cwd, root, env, windowMs = START_WINDOW_MS }) {
|
|
41714
41794
|
return async ({ session, id, line }) => {
|
|
41715
|
-
const log = await open(join(await ensureRunFolder(root), DISPATCH_LOG), "a");
|
|
41795
|
+
const log = await open$1(join(await ensureRunFolder(root), DISPATCH_LOG), "a");
|
|
41716
41796
|
try {
|
|
41717
41797
|
await started(spawn("sh", ["-c", command], {
|
|
41718
41798
|
cwd,
|
|
@@ -41876,22 +41956,12 @@ const sendSchema = object$1({
|
|
|
41876
41956
|
/**
|
|
41877
41957
|
* The board's note writes, each behind `requireWriter`: pin a note, reply in
|
|
41878
41958
|
* 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`.
|
|
41959
|
+
* the CLI's `{ ok, data }` envelope, and a refusal its `{ ok, error }`. Pin,
|
|
41960
|
+
* reply, and send take `dispatch: true` in place of `to`, which starts a
|
|
41961
|
+
* session through `dispatch` and marks the thread's root delivered to it, and
|
|
41962
|
+
* a failed start takes back the message the request added. Images go up first
|
|
41963
|
+
* to `/api/notes/images`, and `/api/note-images/...` reads one back with no
|
|
41964
|
+
* writer check, since an `<img>` sends no `Origin`.
|
|
41895
41965
|
*/
|
|
41896
41966
|
function notesRoutes(root, access, delivery, dispatch, imageLimit = ASSET_BODY_LIMIT) {
|
|
41897
41967
|
const app = new Hono();
|
|
@@ -42085,20 +42155,14 @@ const STATUS = {
|
|
|
42085
42155
|
const DEFAULT_SCALE = 2;
|
|
42086
42156
|
/**
|
|
42087
42157
|
* `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.
|
|
42158
|
+
* frame rendered at `scale` times its layout size, twice when none is given.
|
|
42159
|
+
* Three additions each change what is drawn and exclude each other, each
|
|
42160
|
+
* refusing as `usage`: `filmstrip=<n>` renders `n` moments of the timeline in
|
|
42161
|
+
* one row, `device=1` draws a frame's device inside its body, and
|
|
42162
|
+
* `element=<index>&hash=<hash>` renders that one element alone on a
|
|
42163
|
+
* transparent ground, refusing a moved file as 409 `stale-address`. It takes
|
|
42164
|
+
* no token, since the image shows only what the frame route already serves,
|
|
42165
|
+
* and a refusal answers the CLI's `{ ok, error }` envelope.
|
|
42102
42166
|
*/
|
|
42103
42167
|
function pngRoutes(root, render, renderFilmstrip) {
|
|
42104
42168
|
const app = new Hono();
|
|
@@ -43005,16 +43069,10 @@ async function platformFamilies(page, domIndexes) {
|
|
|
43005
43069
|
* Waits, within `timeoutMs`, until every `<img>` in the frame has loaded and
|
|
43006
43070
|
* decoded, so an image marked `decoding="async"` never shoots as an empty
|
|
43007
43071
|
* 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.
|
|
43072
|
+
* file. Under `require` an image that errored or is still loading at the
|
|
43073
|
+
* deadline refuses `image-missing`, and under `wait` the frame opens as the
|
|
43074
|
+
* board shows it. `stalled` reads a page whose load event never fired, and
|
|
43075
|
+
* refuses only for an image that failed or whose request is still open.
|
|
43018
43076
|
*/
|
|
43019
43077
|
async function settleImages(page, ref, mode, timeoutMs, { stalled = false } = {}) {
|
|
43020
43078
|
const unsettled = await page.evaluate(waitForImages, Math.max(0, timeoutMs));
|
|
@@ -43486,15 +43544,10 @@ const HUG_MAX_WIDTH = FRAME_SIZES.desktop.width;
|
|
|
43486
43544
|
* both read it, in one page resized between readings. A hugging width takes
|
|
43487
43545
|
* the content's `fit-content` width up to `HUG_MAX_WIDTH`, and the height is
|
|
43488
43546
|
* 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.
|
|
43547
|
+
* height, never the box's own, so content sized off the window height reads
|
|
43548
|
+
* one height however tall the frame already is. Readings that differ, or a
|
|
43549
|
+
* fresh page drawing another height, mean the content sizes itself off the
|
|
43550
|
+
* viewport and refuse `fit-unbounded`. Finite animations finish first.
|
|
43498
43551
|
*/
|
|
43499
43552
|
async function measureContent(browser, { baseUrl, ref, box, hugWidth, fonts }) {
|
|
43500
43553
|
const reference = referenceHeight(box.width);
|
|
@@ -43680,7 +43733,7 @@ function readContentSize() {
|
|
|
43680
43733
|
};
|
|
43681
43734
|
const hangOf = (lineHeight, height) => lineHeight < height ? (height - lineHeight) / 2 : 0;
|
|
43682
43735
|
const textBottom = (element) => {
|
|
43683
|
-
let bottom = -
|
|
43736
|
+
let bottom = -1e400;
|
|
43684
43737
|
if (crops(element)) return bottom;
|
|
43685
43738
|
const lineHeight = parseFloat(getComputedStyle(element).lineHeight);
|
|
43686
43739
|
for (const child of element.childNodes) {
|
|
@@ -43865,8 +43918,8 @@ function readLayout() {
|
|
|
43865
43918
|
};
|
|
43866
43919
|
const hangOf = (lineHeight, height) => lineHeight < height ? (height - lineHeight) / 2 : 0;
|
|
43867
43920
|
const textReach = (element) => {
|
|
43868
|
-
let bottom = -
|
|
43869
|
-
let right = -
|
|
43921
|
+
let bottom = -1e400;
|
|
43922
|
+
let right = -1e400;
|
|
43870
43923
|
if (crops(element)) return {
|
|
43871
43924
|
bottom,
|
|
43872
43925
|
right
|
|
@@ -43915,7 +43968,7 @@ function readLayout() {
|
|
|
43915
43968
|
if (node === root || node === document.body || !document.body.contains(node)) continue;
|
|
43916
43969
|
const rect = node.getBoundingClientRect();
|
|
43917
43970
|
const text = textReach(node);
|
|
43918
|
-
if (rect.width === 0 && rect.height === 0 && text.right === -
|
|
43971
|
+
if (rect.width === 0 && rect.height === 0 && text.right === -1e400) continue;
|
|
43919
43972
|
const tag = node.tagName.toLowerCase();
|
|
43920
43973
|
boxes.push({
|
|
43921
43974
|
index: own,
|
|
@@ -45846,21 +45899,14 @@ const editSchema = union([object$1({
|
|
|
45846
45899
|
reset: literal(true)
|
|
45847
45900
|
})]);
|
|
45848
45901
|
/**
|
|
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.
|
|
45902
|
+
* The Theme tab's token write, behind `requireWriter`. `POST /api/tokens/edit`
|
|
45903
|
+
* sets one token the project's sheets list on one theme or both in the sheet
|
|
45904
|
+
* `sheet` names. `project`, the default, writes the project's `tokens.css`,
|
|
45905
|
+
* and a reset there takes its override back to the board's value. `board`
|
|
45906
|
+
* writes the board's sheet for a token it already sets. A stale `hash` answers
|
|
45907
|
+
* 409 `stale-tokens` and an invalid edit 409 `invalid-edit`, each writing
|
|
45908
|
+
* nothing. A landed edit records one step and answers the token's values and
|
|
45909
|
+
* the hash written.
|
|
45864
45910
|
*/
|
|
45865
45911
|
function tokenRoutes(root, access, history, look) {
|
|
45866
45912
|
const app = new Hono();
|
|
@@ -46498,7 +46544,7 @@ function registerCapture(program, context) {
|
|
|
46498
46544
|
cwd: io.cwd
|
|
46499
46545
|
};
|
|
46500
46546
|
const themes = options.theme === "both" ? THEMES : [options.theme];
|
|
46501
|
-
const outOf = async () => options.out ? resolve(io.cwd, options.out) : join(await ensureRunFolder(root), "captures");
|
|
46547
|
+
const outOf = async () => options.out ? resolve$1(io.cwd, options.out) : join(await ensureRunFolder(root), "captures");
|
|
46502
46548
|
if (options.page !== void 0) {
|
|
46503
46549
|
const page = await pageOf(root, options.page, refOptions);
|
|
46504
46550
|
const frames = page.frames.filter((frame) => !frame.hidden);
|
|
@@ -47635,7 +47681,7 @@ function registerEditing(program, context) {
|
|
|
47635
47681
|
const [ref] = refs;
|
|
47636
47682
|
if (options.release) {
|
|
47637
47683
|
const session = sessionOf(options.session);
|
|
47638
|
-
const released = await release
|
|
47684
|
+
const released = await release(root, session, ref ? await claimable(root, ref, resolving(options, io.cwd), now) : void 0, now);
|
|
47639
47685
|
return {
|
|
47640
47686
|
data: { released },
|
|
47641
47687
|
human: released.length === 0 ? `${session} held no claim to release` : `Released ${released.map((each) => each.frame).join(", ")}`
|
|
@@ -48025,7 +48071,7 @@ var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
48025
48071
|
this.pending--;
|
|
48026
48072
|
this[kRun]();
|
|
48027
48073
|
};
|
|
48028
|
-
this.concurrency = concurrency ||
|
|
48074
|
+
this.concurrency = concurrency || 1e400;
|
|
48029
48075
|
this.jobs = [];
|
|
48030
48076
|
this.pending = 0;
|
|
48031
48077
|
}
|
|
@@ -48885,6 +48931,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
48885
48931
|
data = this.consume(this._payloadLength);
|
|
48886
48932
|
if (this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0) unmask(data, this._mask);
|
|
48887
48933
|
}
|
|
48934
|
+
this._mask = void 0;
|
|
48888
48935
|
if (this._opcode > 7) {
|
|
48889
48936
|
this.controlMessage(data, cb);
|
|
48890
48937
|
return;
|
|
@@ -49926,6 +49973,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
49926
49973
|
const https = __require("https");
|
|
49927
49974
|
const http = __require("http");
|
|
49928
49975
|
const net = __require("net");
|
|
49976
|
+
const querystring = __require("querystring");
|
|
49929
49977
|
const tls = __require("tls");
|
|
49930
49978
|
const { randomBytes, createHash } = __require("crypto");
|
|
49931
49979
|
const { Duplex, Readable } = __require("stream");
|
|
@@ -50484,8 +50532,10 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
50484
50532
|
} catch {
|
|
50485
50533
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
50486
50534
|
}
|
|
50487
|
-
if (parsedUrl.protocol === "http:"
|
|
50488
|
-
|
|
50535
|
+
if (parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:") {
|
|
50536
|
+
parsedUrl = new URL(parsedUrl);
|
|
50537
|
+
parsedUrl.protocol = parsedUrl.protocol === "http:" ? "ws:" : "wss:";
|
|
50538
|
+
}
|
|
50489
50539
|
websocket._url = parsedUrl.href;
|
|
50490
50540
|
const isSecure = parsedUrl.protocol === "wss:";
|
|
50491
50541
|
const isIpcUrl = parsedUrl.protocol === "ws+unix:";
|
|
@@ -50538,7 +50588,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
50538
50588
|
if (opts.protocolVersion < 13) opts.headers["Sec-WebSocket-Origin"] = opts.origin;
|
|
50539
50589
|
else opts.headers.Origin = opts.origin;
|
|
50540
50590
|
}
|
|
50541
|
-
if (parsedUrl.username || parsedUrl.password) opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
|
|
50591
|
+
if (parsedUrl.username || parsedUrl.password) opts.auth = `${querystring.unescape(parsedUrl.username)}:${querystring.unescape(parsedUrl.password)}`;
|
|
50542
50592
|
if (isIpcUrl) {
|
|
50543
50593
|
const i = opts.path.indexOf(":");
|
|
50544
50594
|
if (i === -1) {
|
|
@@ -50754,8 +50804,12 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
50754
50804
|
function receiverOnConclude(code, reason) {
|
|
50755
50805
|
const websocket = this[kWebSocket];
|
|
50756
50806
|
websocket._closeFrameReceived = true;
|
|
50757
|
-
websocket._closeMessage = reason;
|
|
50758
50807
|
websocket._closeCode = code;
|
|
50808
|
+
if (reason.length === 0) websocket._closeMessage = EMPTY_BUFFER;
|
|
50809
|
+
else {
|
|
50810
|
+
websocket._closeMessage = Buffer.allocUnsafeSlow(reason.length);
|
|
50811
|
+
websocket._closeMessage.set(reason);
|
|
50812
|
+
}
|
|
50759
50813
|
if (websocket._socket[kWebSocket] === void 0) return;
|
|
50760
50814
|
websocket._socket.removeListener("data", socketOnData);
|
|
50761
50815
|
process.nextTick(resume, websocket._socket);
|
|
@@ -52676,7 +52730,7 @@ async function removeEmptyFolders(dir, folder) {
|
|
|
52676
52730
|
function registerReferences(program, context) {
|
|
52677
52731
|
const { io } = context;
|
|
52678
52732
|
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);
|
|
52733
|
+
const folder = resolve$1(io.cwd, given);
|
|
52680
52734
|
if (!existsSync(join(folder, "frames.json"))) throw new FrameboardError("usage", `${folder} holds no frames.json, mapping each reference to a board frame.`);
|
|
52681
52735
|
const target = {
|
|
52682
52736
|
root: await boardOf(options, io),
|
|
@@ -53254,7 +53308,7 @@ var ReaddirpStream = class extends Readable {
|
|
|
53254
53308
|
this._wantsDir = DIR_TYPES.has(type);
|
|
53255
53309
|
this._wantsFile = FILE_TYPES.has(type);
|
|
53256
53310
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
53257
|
-
this._root = resolve(root);
|
|
53311
|
+
this._root = resolve$1(root);
|
|
53258
53312
|
this._relStart = this._root.endsWith(sep) ? this._root.length : this._root.length + 1;
|
|
53259
53313
|
this._isDirent = !opts.alwaysStat;
|
|
53260
53314
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
@@ -53653,13 +53707,13 @@ function projectNativeRelativePath(nativeRoot, relativePath) {
|
|
|
53653
53707
|
}
|
|
53654
53708
|
const FsWatchInstances = /* @__PURE__ */ new Map();
|
|
53655
53709
|
function systemNativeWatchFactory(path, options, listener) {
|
|
53656
|
-
return watch(path, options, listener);
|
|
53710
|
+
return watch$1(path, options, listener);
|
|
53657
53711
|
}
|
|
53658
53712
|
let nativeWatchFactory = systemNativeWatchFactory;
|
|
53659
53713
|
const RecursiveWatchInstances = /* @__PURE__ */ new Map();
|
|
53660
53714
|
let recursiveWatchUnsupported = false;
|
|
53661
53715
|
function systemRecursiveWatchFactory(path, options, listener) {
|
|
53662
|
-
return watch(path, options, listener);
|
|
53716
|
+
return watch$1(path, options, listener);
|
|
53663
53717
|
}
|
|
53664
53718
|
let recursiveWatchFactory = systemRecursiveWatchFactory;
|
|
53665
53719
|
function failRecursiveResource(resource, error) {
|
|
@@ -53774,7 +53828,7 @@ function closeFailedNativeResource(cont, error) {
|
|
|
53774
53828
|
}
|
|
53775
53829
|
async function handleNativeError(path, cont, error) {
|
|
53776
53830
|
if (isWindows && error.code === "EPERM") try {
|
|
53777
|
-
await (await open(path, "r")).close();
|
|
53831
|
+
await (await open$1(path, "r")).close();
|
|
53778
53832
|
broadcastNativeError(cont, error);
|
|
53779
53833
|
} catch {
|
|
53780
53834
|
publishNativeTrigger(cont, "rename", null, false);
|
|
@@ -56301,7 +56355,7 @@ var FSWatcher = class extends EventEmitter {
|
|
|
56301
56355
|
* const watcher = watch('.').on('all', (event, path) => { console.log(event, path); });
|
|
56302
56356
|
* watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
|
|
56303
56357
|
*/
|
|
56304
|
-
function watch
|
|
56358
|
+
function watch(paths, options = {}) {
|
|
56305
56359
|
const watcher = new FSWatcher(options);
|
|
56306
56360
|
watcher.add(paths);
|
|
56307
56361
|
return watcher;
|
|
@@ -56336,10 +56390,10 @@ async function watchBoard(root, files = []) {
|
|
|
56336
56390
|
});
|
|
56337
56391
|
const runFolder = join(root, RUN_FOLDER);
|
|
56338
56392
|
const outside = files.filter((file) => relative(root, file).startsWith(".."));
|
|
56339
|
-
const watchers = [watch
|
|
56393
|
+
const watchers = [watch(root, {
|
|
56340
56394
|
ignoreInitial: true,
|
|
56341
56395
|
ignored: (path) => isIgnored(root, path)
|
|
56342
|
-
}), ...outside.length > 0 ? [watch
|
|
56396
|
+
}), ...outside.length > 0 ? [watch([...outside], { ignoreInitial: true })] : []];
|
|
56343
56397
|
let warm = false;
|
|
56344
56398
|
await Promise.all(watchers.map((watcher) => {
|
|
56345
56399
|
watcher.on("all", (_event, path) => {
|
|
@@ -57834,7 +57888,7 @@ const RECONNECT_WAIT_MS = 1e3;
|
|
|
57834
57888
|
function registerServe(program, context) {
|
|
57835
57889
|
const { io } = context;
|
|
57836
57890
|
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);
|
|
57891
|
+
const tokens = options.tokens === void 0 ? void 0 : resolve$1(io.cwd, options.tokens);
|
|
57838
57892
|
if (tokens !== void 0 && !isFile(tokens)) throw new FrameboardError("tokens-not-found", `No token sheet at ${tokens}.`, { tokens });
|
|
57839
57893
|
const existing = await resolveBoard({
|
|
57840
57894
|
root: options.root,
|