frameboard 0.45.0 → 0.46.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 +246 -185
- package/dist/client/assets/index-7T-3-XIO.css +2 -0
- package/dist/client/assets/index-DS22rwPq.js +165 -0
- package/dist/client/index.html +2 -2
- package/package.json +1 -1
- package/dist/client/assets/index-CoWunAt4.js +0 -165
- package/dist/client/assets/index-Dy9ZssFI.css +0 -2
package/dist/cli.js
CHANGED
|
@@ -24845,8 +24845,8 @@ function readTransitionSheet(name, css) {
|
|
|
24845
24845
|
const leave = held.get("leave");
|
|
24846
24846
|
return {
|
|
24847
24847
|
ok: true,
|
|
24848
|
-
enter: bodyOf(enter),
|
|
24849
|
-
leave: leave ? bodyOf(leave) : null
|
|
24848
|
+
enter: bodyOf$1(enter),
|
|
24849
|
+
leave: leave ? bodyOf$1(leave) : null
|
|
24850
24850
|
};
|
|
24851
24851
|
}
|
|
24852
24852
|
function refused$2(problems) {
|
|
@@ -24917,7 +24917,7 @@ function problemAt(node, message) {
|
|
|
24917
24917
|
};
|
|
24918
24918
|
}
|
|
24919
24919
|
/** The steps inside a keyframes block, on one line, with its comments dropped. */
|
|
24920
|
-
function bodyOf(block) {
|
|
24920
|
+
function bodyOf$1(block) {
|
|
24921
24921
|
return (block.nodes ?? []).filter((node) => node.type === "rule").map((step) => {
|
|
24922
24922
|
const declarations = step.nodes.filter((child) => child.type === "decl").map((child) => `${child.prop}: ${child.value}${child.important ? " !important" : ""}`);
|
|
24923
24923
|
return `${step.selector.trim()} { ${declarations.join("; ")} }`;
|
|
@@ -25392,7 +25392,7 @@ async function isDirectory(path) {
|
|
|
25392
25392
|
}
|
|
25393
25393
|
}
|
|
25394
25394
|
// package.json
|
|
25395
|
-
var version$1 = "0.
|
|
25395
|
+
var version$1 = "0.46.0";
|
|
25396
25396
|
var dependencies = { "playwright-core": "1.65.0" };
|
|
25397
25397
|
var peerDependencies = { "oxfmt": "0.78.0" };
|
|
25398
25398
|
// src/shared/version.ts
|
|
@@ -26253,7 +26253,39 @@ async function setFrameDevice(root, ref, show, { foldable: name, pose: fold, isl
|
|
|
26253
26253
|
hugWidth: false,
|
|
26254
26254
|
hugHeight: false
|
|
26255
26255
|
};
|
|
26256
|
-
});
|
|
26256
|
+
}, fold || turn || name !== void 0 ? pushAlong : void 0);
|
|
26257
|
+
}
|
|
26258
|
+
/**
|
|
26259
|
+
* Shifts each frame on the grown body's rows at or past its old right edge by
|
|
26260
|
+
* the growth, keeping the gap. A shrink pulls none back, since the developer
|
|
26261
|
+
* may have arranged them since, and a bare show or hide never calls this.
|
|
26262
|
+
*/
|
|
26263
|
+
function pushAlong(layout, name, before) {
|
|
26264
|
+
const was = bodyOf(before);
|
|
26265
|
+
const now = bodyOf(layout.placement(name));
|
|
26266
|
+
const edge = was.x + was.width;
|
|
26267
|
+
const growth = now.x + now.width - edge;
|
|
26268
|
+
if (growth <= 0) return;
|
|
26269
|
+
const pushed = layout.names.filter((other) => other !== name && layout.hasEntry(other)).map((other) => ({
|
|
26270
|
+
other,
|
|
26271
|
+
placement: layout.placement(other)
|
|
26272
|
+
})).filter(({ placement }) => {
|
|
26273
|
+
const body = bodyOf(placement);
|
|
26274
|
+
return body.x >= edge && body.y < now.y + now.height && body.y + body.height > now.y;
|
|
26275
|
+
});
|
|
26276
|
+
for (const { other, placement } of pushed) {
|
|
26277
|
+
const { box } = placement;
|
|
26278
|
+
layout.set(other, {
|
|
26279
|
+
...placement,
|
|
26280
|
+
box: {
|
|
26281
|
+
...box,
|
|
26282
|
+
x: box.x + growth
|
|
26283
|
+
}
|
|
26284
|
+
});
|
|
26285
|
+
}
|
|
26286
|
+
}
|
|
26287
|
+
function bodyOf({ box, device, turn }) {
|
|
26288
|
+
return bezelBox(box, device, turn);
|
|
26257
26289
|
}
|
|
26258
26290
|
/**
|
|
26259
26291
|
* A named foldable left as it is while it stays named, and stood upright at
|
|
@@ -26401,12 +26433,14 @@ async function deleteFrame(root, ref, options) {
|
|
|
26401
26433
|
}, journal);
|
|
26402
26434
|
return { deleted: refOf$1(frame) };
|
|
26403
26435
|
}
|
|
26404
|
-
async function updatePlacement(root, ref, options, change) {
|
|
26436
|
+
async function updatePlacement(root, ref, options, change, settle) {
|
|
26405
26437
|
const frame = await resolveFrameRef(root, ref, options);
|
|
26406
26438
|
const page = pageDir(frame);
|
|
26407
26439
|
await withLayouts([page], async (layouts) => {
|
|
26408
26440
|
const layout = layoutAt(layouts, page);
|
|
26409
|
-
|
|
26441
|
+
const before = layout.placement(frame.name);
|
|
26442
|
+
layout.set(frame.name, change(before, refOf$1(frame)));
|
|
26443
|
+
settle?.(layout, frame.name, before);
|
|
26410
26444
|
}, options.journal);
|
|
26411
26445
|
return frameRecord(root, frame.project, frame.page, frame.name);
|
|
26412
26446
|
}
|
|
@@ -31467,6 +31501,149 @@ function cssUrls(css) {
|
|
|
31467
31501
|
});
|
|
31468
31502
|
return urls;
|
|
31469
31503
|
}
|
|
31504
|
+
// src/server/edit/start-tag.ts
|
|
31505
|
+
function isSpace(char) {
|
|
31506
|
+
return char === " " || char === " " || char === "\n" || char === "\f" || char === "\r";
|
|
31507
|
+
}
|
|
31508
|
+
/**
|
|
31509
|
+
* Scans a start tag through the tokenizer states, since parse5 records neither
|
|
31510
|
+
* self-closing nor duplicates, and `<circle id=x/>` is not self-closed.
|
|
31511
|
+
*/
|
|
31512
|
+
function scanStartTag(source, tag) {
|
|
31513
|
+
const names = [];
|
|
31514
|
+
let state = "tagName";
|
|
31515
|
+
let quote = "";
|
|
31516
|
+
let nameStart = 0;
|
|
31517
|
+
let slash;
|
|
31518
|
+
const end = tag.endOffset - 1;
|
|
31519
|
+
for (let at = tag.startOffset + 1; at < end; at += 1) {
|
|
31520
|
+
const char = source[at];
|
|
31521
|
+
slash = void 0;
|
|
31522
|
+
switch (state) {
|
|
31523
|
+
case "tagName":
|
|
31524
|
+
if (isSpace(char)) state = "beforeAttrName";
|
|
31525
|
+
else if (char === "/") {
|
|
31526
|
+
state = "beforeAttrName";
|
|
31527
|
+
slash = at;
|
|
31528
|
+
}
|
|
31529
|
+
break;
|
|
31530
|
+
case "beforeAttrName":
|
|
31531
|
+
if (char === "/") slash = at;
|
|
31532
|
+
else if (!isSpace(char)) {
|
|
31533
|
+
state = "attrName";
|
|
31534
|
+
nameStart = at;
|
|
31535
|
+
}
|
|
31536
|
+
break;
|
|
31537
|
+
case "attrName":
|
|
31538
|
+
if (isSpace(char) || char === "/" || char === "=") {
|
|
31539
|
+
names.push(source.slice(nameStart, at).toLowerCase());
|
|
31540
|
+
if (char === "=") state = "beforeValue";
|
|
31541
|
+
else if (char === "/") {
|
|
31542
|
+
state = "beforeAttrName";
|
|
31543
|
+
slash = at;
|
|
31544
|
+
} else state = "afterAttrName";
|
|
31545
|
+
}
|
|
31546
|
+
break;
|
|
31547
|
+
case "afterAttrName":
|
|
31548
|
+
if (char === "/") {
|
|
31549
|
+
state = "beforeAttrName";
|
|
31550
|
+
slash = at;
|
|
31551
|
+
} else if (char === "=") state = "beforeValue";
|
|
31552
|
+
else if (!isSpace(char)) {
|
|
31553
|
+
state = "attrName";
|
|
31554
|
+
nameStart = at;
|
|
31555
|
+
}
|
|
31556
|
+
break;
|
|
31557
|
+
case "beforeValue":
|
|
31558
|
+
if (char === "\"" || char === "'") {
|
|
31559
|
+
quote = char;
|
|
31560
|
+
state = "quoted";
|
|
31561
|
+
} else if (!isSpace(char)) state = "unquoted";
|
|
31562
|
+
break;
|
|
31563
|
+
case "quoted":
|
|
31564
|
+
if (char === quote) state = "beforeAttrName";
|
|
31565
|
+
break;
|
|
31566
|
+
case "unquoted": if (isSpace(char)) state = "beforeAttrName";
|
|
31567
|
+
}
|
|
31568
|
+
}
|
|
31569
|
+
if (state === "attrName") names.push(source.slice(nameStart, end).toLowerCase());
|
|
31570
|
+
return {
|
|
31571
|
+
slash,
|
|
31572
|
+
names
|
|
31573
|
+
};
|
|
31574
|
+
}
|
|
31575
|
+
// src/server/edit/attribute.ts
|
|
31576
|
+
/** Escapes a value for a double-quoted attribute. */
|
|
31577
|
+
function escapeAttribute$1(value) {
|
|
31578
|
+
return value.replace(/&/g, "&").replace(/"/g, """);
|
|
31579
|
+
}
|
|
31580
|
+
function splice(source, start, end, insert) {
|
|
31581
|
+
return source.slice(0, start) + insert + source.slice(end);
|
|
31582
|
+
}
|
|
31583
|
+
/** The value inside one attribute's source span, without its quotes. */
|
|
31584
|
+
function valueSpan(source, span) {
|
|
31585
|
+
const text = source.slice(span.startOffset, span.endOffset);
|
|
31586
|
+
const equals = text.indexOf("=");
|
|
31587
|
+
if (equals === -1) return {
|
|
31588
|
+
start: span.endOffset,
|
|
31589
|
+
end: span.endOffset,
|
|
31590
|
+
quote: void 0,
|
|
31591
|
+
isBare: true
|
|
31592
|
+
};
|
|
31593
|
+
let at = equals + 1;
|
|
31594
|
+
while (/\s/.test(text[at] ?? "")) at += 1;
|
|
31595
|
+
const opener = text[at];
|
|
31596
|
+
const quote = opener === "\"" || opener === "'" ? opener : void 0;
|
|
31597
|
+
return {
|
|
31598
|
+
start: span.startOffset + at + (quote ? 1 : 0),
|
|
31599
|
+
end: span.endOffset - (quote ? 1 : 0),
|
|
31600
|
+
quote,
|
|
31601
|
+
isBare: false
|
|
31602
|
+
};
|
|
31603
|
+
}
|
|
31604
|
+
function attributeSpan(element, name) {
|
|
31605
|
+
return element.sourceCodeLocation?.attrs?.[name];
|
|
31606
|
+
}
|
|
31607
|
+
/** The attribute's value as the file states it, still encoded, or undefined when it is absent. */
|
|
31608
|
+
function rawAttribute(source, element, name) {
|
|
31609
|
+
const span = attributeSpan(element, name);
|
|
31610
|
+
if (!span) return void 0;
|
|
31611
|
+
const value = valueSpan(source, span);
|
|
31612
|
+
return source.slice(value.start, value.end);
|
|
31613
|
+
}
|
|
31614
|
+
/**
|
|
31615
|
+
* Sets one attribute inside its value span, a new one going before the real
|
|
31616
|
+
* self-closing `/`, which only the start-tag scan tells from an unquoted value's.
|
|
31617
|
+
*/
|
|
31618
|
+
function setRawAttribute(source, element, name, raw) {
|
|
31619
|
+
const span = attributeSpan(element, name);
|
|
31620
|
+
if (span) {
|
|
31621
|
+
const value = valueSpan(source, span);
|
|
31622
|
+
if (value.isBare) return splice(source, span.endOffset, span.endOffset, `="${raw}"`);
|
|
31623
|
+
if (value.quote === "'") return splice(source, value.start, value.end, raw.replace(/'/g, "'"));
|
|
31624
|
+
if (value.quote === "\"") return splice(source, value.start, value.end, raw);
|
|
31625
|
+
return splice(source, value.start, value.end, `"${raw.replace(/"/g, """)}"`);
|
|
31626
|
+
}
|
|
31627
|
+
const startTag = element.sourceCodeLocation?.startTag;
|
|
31628
|
+
if (!startTag) return source;
|
|
31629
|
+
const at = scanStartTag(source, startTag).slash ?? startTag.endOffset - 1;
|
|
31630
|
+
return splice(source, at, at, `${/\s/.test(source[at - 1] ?? "") ? "" : " "}${name}="${raw}"${source[at] === "/" ? " " : ""}`);
|
|
31631
|
+
}
|
|
31632
|
+
/**
|
|
31633
|
+
* Removes one attribute and the whitespace run ahead of it. A later duplicate
|
|
31634
|
+
* would come into force once the first is gone, so the first is emptied
|
|
31635
|
+
* instead, and a bare one is left as it is, already empty.
|
|
31636
|
+
*/
|
|
31637
|
+
function removeAttribute(source, element, name) {
|
|
31638
|
+
const span = attributeSpan(element, name);
|
|
31639
|
+
const startTag = element.sourceCodeLocation?.startTag;
|
|
31640
|
+
if (!span || !startTag) return source;
|
|
31641
|
+
const { names } = scanStartTag(source, startTag);
|
|
31642
|
+
if (names.filter((stated) => stated === name).length > 1) return valueSpan(source, span).isBare ? source : setRawAttribute(source, element, name, "");
|
|
31643
|
+
let start = span.startOffset;
|
|
31644
|
+
while (/\s/.test(source[start - 1] ?? "")) start -= 1;
|
|
31645
|
+
return splice(source, start, span.endOffset, "");
|
|
31646
|
+
}
|
|
31470
31647
|
// src/server/board/asset-usage.ts
|
|
31471
31648
|
/**
|
|
31472
31649
|
* A per-project cache of how many frames link each asset, counted from the
|
|
@@ -31547,32 +31724,49 @@ async function framesLinking(root, project, path) {
|
|
|
31547
31724
|
}
|
|
31548
31725
|
/**
|
|
31549
31726
|
* The frame's markup with each load of `from` pointed at `to`, or null when no load in its own file names it.
|
|
31727
|
+
* An element whose load moved takes the new file name while its `data-name` is still the old one, so a name set by hand stays.
|
|
31550
31728
|
* A linked sheet's load, or a URL written through an entity or escape, stays for the link check to report.
|
|
31551
31729
|
*/
|
|
31552
31730
|
function rewriteAssetLinks(source, from, to) {
|
|
31553
31731
|
const framePath = boardPath(source.root, source.path);
|
|
31554
|
-
const
|
|
31732
|
+
const moved = /* @__PURE__ */ new Map();
|
|
31555
31733
|
for (const load of frameLoads(source)) {
|
|
31556
31734
|
if (load.path !== framePath || load.location === null) continue;
|
|
31557
31735
|
if (localTarget(load.url, load.base) !== from) continue;
|
|
31558
31736
|
const { startOffset: start, endOffset: end } = load.location;
|
|
31559
|
-
|
|
31737
|
+
moved.set(`${start}:${end}:${load.url}`, {
|
|
31560
31738
|
start,
|
|
31561
31739
|
end,
|
|
31562
31740
|
url: load.url
|
|
31563
31741
|
});
|
|
31564
31742
|
}
|
|
31743
|
+
const loads = [...moved.values()];
|
|
31744
|
+
const edits = loads.map(({ start, end, url }) => ({
|
|
31745
|
+
start,
|
|
31746
|
+
end,
|
|
31747
|
+
write: (span) => span.replace(urlPattern(url), (_, lead) => `${lead}${renamedUrl(url, basename(to))}`)
|
|
31748
|
+
}));
|
|
31749
|
+
const rewritten = loads.filter(({ start, end, url }) => urlPattern(url).test(source.html.slice(start, end)));
|
|
31750
|
+
edits.push(...nameEdits(source, rewritten, basename(from), basename(to)));
|
|
31565
31751
|
let html = source.html;
|
|
31566
|
-
|
|
31567
|
-
|
|
31568
|
-
|
|
31569
|
-
|
|
31570
|
-
|
|
31571
|
-
|
|
31572
|
-
|
|
31573
|
-
|
|
31574
|
-
|
|
31575
|
-
|
|
31752
|
+
for (const { start, end, write } of edits.sort((a, b) => b.start - a.start)) html = html.slice(0, start) + write(html.slice(start, end)) + html.slice(end);
|
|
31753
|
+
return html === source.html ? null : html;
|
|
31754
|
+
}
|
|
31755
|
+
/** A `data-name` of `oldName` set to `newName` on each element one of `loads` sits in. */
|
|
31756
|
+
function nameEdits(source, loads, oldName, newName) {
|
|
31757
|
+
return source.elements.flatMap((element) => {
|
|
31758
|
+
if (element.attribs["data-name"] !== oldName) return [];
|
|
31759
|
+
const tag = element.sourceCodeLocation;
|
|
31760
|
+
const name = tag?.attrs?.["data-name"];
|
|
31761
|
+
const startTag = tag?.startTag;
|
|
31762
|
+
if (!name || !startTag) return [];
|
|
31763
|
+
if (!loads.some(({ start }) => start >= startTag.startOffset && start < startTag.endOffset)) return [];
|
|
31764
|
+
return [{
|
|
31765
|
+
start: name.startOffset,
|
|
31766
|
+
end: name.endOffset,
|
|
31767
|
+
write: () => `data-name="${escapeAttribute$1(newName)}"`
|
|
31768
|
+
}];
|
|
31769
|
+
});
|
|
31576
31770
|
}
|
|
31577
31771
|
/** The URL as a whole token, so `a.jpg` never matches inside `a.jpg-2.jpg`. */
|
|
31578
31772
|
function urlPattern(url) {
|
|
@@ -31866,8 +32060,6 @@ const imageGenerateSchema = object$1({
|
|
|
31866
32060
|
});
|
|
31867
32061
|
object$1({
|
|
31868
32062
|
version: literal(1),
|
|
31869
|
-
/** Whether the board may generate at all, false while generating from a tab is switched off. */
|
|
31870
|
-
enabled: boolean$1(),
|
|
31871
32063
|
/** The first provider whose key is set, null when none is. */
|
|
31872
32064
|
provider: object$1({
|
|
31873
32065
|
name: _enum$1(IMAGE_PROVIDERS),
|
|
@@ -33180,149 +33372,6 @@ function clipboardRoutes(root, access, render, clipboard) {
|
|
|
33180
33372
|
});
|
|
33181
33373
|
return app;
|
|
33182
33374
|
}
|
|
33183
|
-
// src/server/edit/start-tag.ts
|
|
33184
|
-
function isSpace(char) {
|
|
33185
|
-
return char === " " || char === " " || char === "\n" || char === "\f" || char === "\r";
|
|
33186
|
-
}
|
|
33187
|
-
/**
|
|
33188
|
-
* Scans a start tag through the tokenizer states, since parse5 records neither
|
|
33189
|
-
* self-closing nor duplicates, and `<circle id=x/>` is not self-closed.
|
|
33190
|
-
*/
|
|
33191
|
-
function scanStartTag(source, tag) {
|
|
33192
|
-
const names = [];
|
|
33193
|
-
let state = "tagName";
|
|
33194
|
-
let quote = "";
|
|
33195
|
-
let nameStart = 0;
|
|
33196
|
-
let slash;
|
|
33197
|
-
const end = tag.endOffset - 1;
|
|
33198
|
-
for (let at = tag.startOffset + 1; at < end; at += 1) {
|
|
33199
|
-
const char = source[at];
|
|
33200
|
-
slash = void 0;
|
|
33201
|
-
switch (state) {
|
|
33202
|
-
case "tagName":
|
|
33203
|
-
if (isSpace(char)) state = "beforeAttrName";
|
|
33204
|
-
else if (char === "/") {
|
|
33205
|
-
state = "beforeAttrName";
|
|
33206
|
-
slash = at;
|
|
33207
|
-
}
|
|
33208
|
-
break;
|
|
33209
|
-
case "beforeAttrName":
|
|
33210
|
-
if (char === "/") slash = at;
|
|
33211
|
-
else if (!isSpace(char)) {
|
|
33212
|
-
state = "attrName";
|
|
33213
|
-
nameStart = at;
|
|
33214
|
-
}
|
|
33215
|
-
break;
|
|
33216
|
-
case "attrName":
|
|
33217
|
-
if (isSpace(char) || char === "/" || char === "=") {
|
|
33218
|
-
names.push(source.slice(nameStart, at).toLowerCase());
|
|
33219
|
-
if (char === "=") state = "beforeValue";
|
|
33220
|
-
else if (char === "/") {
|
|
33221
|
-
state = "beforeAttrName";
|
|
33222
|
-
slash = at;
|
|
33223
|
-
} else state = "afterAttrName";
|
|
33224
|
-
}
|
|
33225
|
-
break;
|
|
33226
|
-
case "afterAttrName":
|
|
33227
|
-
if (char === "/") {
|
|
33228
|
-
state = "beforeAttrName";
|
|
33229
|
-
slash = at;
|
|
33230
|
-
} else if (char === "=") state = "beforeValue";
|
|
33231
|
-
else if (!isSpace(char)) {
|
|
33232
|
-
state = "attrName";
|
|
33233
|
-
nameStart = at;
|
|
33234
|
-
}
|
|
33235
|
-
break;
|
|
33236
|
-
case "beforeValue":
|
|
33237
|
-
if (char === "\"" || char === "'") {
|
|
33238
|
-
quote = char;
|
|
33239
|
-
state = "quoted";
|
|
33240
|
-
} else if (!isSpace(char)) state = "unquoted";
|
|
33241
|
-
break;
|
|
33242
|
-
case "quoted":
|
|
33243
|
-
if (char === quote) state = "beforeAttrName";
|
|
33244
|
-
break;
|
|
33245
|
-
case "unquoted": if (isSpace(char)) state = "beforeAttrName";
|
|
33246
|
-
}
|
|
33247
|
-
}
|
|
33248
|
-
if (state === "attrName") names.push(source.slice(nameStart, end).toLowerCase());
|
|
33249
|
-
return {
|
|
33250
|
-
slash,
|
|
33251
|
-
names
|
|
33252
|
-
};
|
|
33253
|
-
}
|
|
33254
|
-
// src/server/edit/attribute.ts
|
|
33255
|
-
/** Escapes a value for a double-quoted attribute. */
|
|
33256
|
-
function escapeAttribute$1(value) {
|
|
33257
|
-
return value.replace(/&/g, "&").replace(/"/g, """);
|
|
33258
|
-
}
|
|
33259
|
-
function splice(source, start, end, insert) {
|
|
33260
|
-
return source.slice(0, start) + insert + source.slice(end);
|
|
33261
|
-
}
|
|
33262
|
-
/** The value inside one attribute's source span, without its quotes. */
|
|
33263
|
-
function valueSpan(source, span) {
|
|
33264
|
-
const text = source.slice(span.startOffset, span.endOffset);
|
|
33265
|
-
const equals = text.indexOf("=");
|
|
33266
|
-
if (equals === -1) return {
|
|
33267
|
-
start: span.endOffset,
|
|
33268
|
-
end: span.endOffset,
|
|
33269
|
-
quote: void 0,
|
|
33270
|
-
isBare: true
|
|
33271
|
-
};
|
|
33272
|
-
let at = equals + 1;
|
|
33273
|
-
while (/\s/.test(text[at] ?? "")) at += 1;
|
|
33274
|
-
const opener = text[at];
|
|
33275
|
-
const quote = opener === "\"" || opener === "'" ? opener : void 0;
|
|
33276
|
-
return {
|
|
33277
|
-
start: span.startOffset + at + (quote ? 1 : 0),
|
|
33278
|
-
end: span.endOffset - (quote ? 1 : 0),
|
|
33279
|
-
quote,
|
|
33280
|
-
isBare: false
|
|
33281
|
-
};
|
|
33282
|
-
}
|
|
33283
|
-
function attributeSpan(element, name) {
|
|
33284
|
-
return element.sourceCodeLocation?.attrs?.[name];
|
|
33285
|
-
}
|
|
33286
|
-
/** The attribute's value as the file states it, still encoded, or undefined when it is absent. */
|
|
33287
|
-
function rawAttribute(source, element, name) {
|
|
33288
|
-
const span = attributeSpan(element, name);
|
|
33289
|
-
if (!span) return void 0;
|
|
33290
|
-
const value = valueSpan(source, span);
|
|
33291
|
-
return source.slice(value.start, value.end);
|
|
33292
|
-
}
|
|
33293
|
-
/**
|
|
33294
|
-
* Sets one attribute inside its value span, a new one going before the real
|
|
33295
|
-
* self-closing `/`, which only the start-tag scan tells from an unquoted value's.
|
|
33296
|
-
*/
|
|
33297
|
-
function setRawAttribute(source, element, name, raw) {
|
|
33298
|
-
const span = attributeSpan(element, name);
|
|
33299
|
-
if (span) {
|
|
33300
|
-
const value = valueSpan(source, span);
|
|
33301
|
-
if (value.isBare) return splice(source, span.endOffset, span.endOffset, `="${raw}"`);
|
|
33302
|
-
if (value.quote === "'") return splice(source, value.start, value.end, raw.replace(/'/g, "'"));
|
|
33303
|
-
if (value.quote === "\"") return splice(source, value.start, value.end, raw);
|
|
33304
|
-
return splice(source, value.start, value.end, `"${raw.replace(/"/g, """)}"`);
|
|
33305
|
-
}
|
|
33306
|
-
const startTag = element.sourceCodeLocation?.startTag;
|
|
33307
|
-
if (!startTag) return source;
|
|
33308
|
-
const at = scanStartTag(source, startTag).slash ?? startTag.endOffset - 1;
|
|
33309
|
-
return splice(source, at, at, `${/\s/.test(source[at - 1] ?? "") ? "" : " "}${name}="${raw}"${source[at] === "/" ? " " : ""}`);
|
|
33310
|
-
}
|
|
33311
|
-
/**
|
|
33312
|
-
* Removes one attribute and the whitespace run ahead of it. A later duplicate
|
|
33313
|
-
* would come into force once the first is gone, so the first is emptied
|
|
33314
|
-
* instead, and a bare one is left as it is, already empty.
|
|
33315
|
-
*/
|
|
33316
|
-
function removeAttribute(source, element, name) {
|
|
33317
|
-
const span = attributeSpan(element, name);
|
|
33318
|
-
const startTag = element.sourceCodeLocation?.startTag;
|
|
33319
|
-
if (!span || !startTag) return source;
|
|
33320
|
-
const { names } = scanStartTag(source, startTag);
|
|
33321
|
-
if (names.filter((stated) => stated === name).length > 1) return valueSpan(source, span).isBare ? source : setRawAttribute(source, element, name, "");
|
|
33322
|
-
let start = span.startOffset;
|
|
33323
|
-
while (/\s/.test(source[start - 1] ?? "")) start -= 1;
|
|
33324
|
-
return splice(source, start, span.endOffset, "");
|
|
33325
|
-
}
|
|
33326
33375
|
// src/server/edit/element-span.ts
|
|
33327
33376
|
const OTHER$1 = {
|
|
33328
33377
|
before: "after",
|
|
@@ -41079,15 +41128,16 @@ function taken(page, holder) {
|
|
|
41079
41128
|
});
|
|
41080
41129
|
}
|
|
41081
41130
|
// src/server/board/projects.ts
|
|
41082
|
-
/** A new project holding one empty page. */
|
|
41083
|
-
async function addProject(root, name, now = /* @__PURE__ */ new Date(), { journal } = {}) {
|
|
41131
|
+
/** A new project holding one empty page, filed under `group` when one is given. */
|
|
41132
|
+
async function addProject(root, name, now = /* @__PURE__ */ new Date(), { journal, group } = {}) {
|
|
41084
41133
|
assertValidName("project", name);
|
|
41085
41134
|
await assertFree$1(root, name);
|
|
41086
41135
|
await mkdir(join(root, name, START_PAGE), { recursive: true });
|
|
41087
41136
|
await writeRecord(join(root, name, PROJECT_FILE), {
|
|
41088
41137
|
version: 1,
|
|
41089
41138
|
pages: [START_PAGE],
|
|
41090
|
-
createdAt: now.toISOString()
|
|
41139
|
+
createdAt: now.toISOString(),
|
|
41140
|
+
...group?.trim() ? { group: group.trim() } : {}
|
|
41091
41141
|
});
|
|
41092
41142
|
await journal?.created(join(root, name));
|
|
41093
41143
|
return scanProject(root, name);
|
|
@@ -41810,6 +41860,12 @@ var StepJournal = class {
|
|
|
41810
41860
|
}
|
|
41811
41861
|
entry(page, frame, before, after) {
|
|
41812
41862
|
const layout = join(page, LAYOUT_FILE);
|
|
41863
|
+
const last = this.changes.findLastIndex((change) => change.kind === "entry" && change.layout === layout && change.frame === frame);
|
|
41864
|
+
const held = this.changes[last];
|
|
41865
|
+
if (held?.kind === "entry" && this.changes.slice(last + 1).every((change) => change.kind === "entry")) {
|
|
41866
|
+
held.after = after;
|
|
41867
|
+
return;
|
|
41868
|
+
}
|
|
41813
41869
|
this.changes.push({
|
|
41814
41870
|
kind: "entry",
|
|
41815
41871
|
layout,
|
|
@@ -46205,7 +46261,7 @@ const STATUS = {
|
|
|
46205
46261
|
* the modules `frameboard image` calls. Finding and the provider's price read
|
|
46206
46262
|
* only; saving and generating need a writer. No answer carries a key.
|
|
46207
46263
|
*/
|
|
46208
|
-
function sourcingRoutes(root, access, { send = (input, init) => fetch(input, init), env = process.env
|
|
46264
|
+
function sourcingRoutes(root, access, { send = (input, init) => fetch(input, init), env = process.env } = {}) {
|
|
46209
46265
|
const app = new Hono();
|
|
46210
46266
|
const authorized = requireWriter(access);
|
|
46211
46267
|
const base = "/api/projects/:project/sourcing";
|
|
@@ -46280,18 +46336,11 @@ function sourcingRoutes(root, access, { send = (input, init) => fetch(input, ini
|
|
|
46280
46336
|
projectOf$1(root, c.req.param("project"));
|
|
46281
46337
|
return c.json({
|
|
46282
46338
|
ok: true,
|
|
46283
|
-
data: offer(env
|
|
46339
|
+
data: offer(env)
|
|
46284
46340
|
});
|
|
46285
46341
|
});
|
|
46286
46342
|
app.post(`${base}/generate`, authorized, async (c) => {
|
|
46287
46343
|
const project = projectOf$1(root, c.req.param("project"));
|
|
46288
|
-
if (!generate) return c.json({
|
|
46289
|
-
ok: false,
|
|
46290
|
-
error: {
|
|
46291
|
-
code: "generate-off",
|
|
46292
|
-
message: "Generating from the board is off in this release. Run `frameboard image generate` instead."
|
|
46293
|
-
}
|
|
46294
|
-
}, 403);
|
|
46295
46344
|
const { prompt } = await parseBody$1(c.req.raw, generateBodySchema);
|
|
46296
46345
|
if (generating) return c.json({
|
|
46297
46346
|
ok: false,
|
|
@@ -46315,6 +46364,7 @@ function sourcingRoutes(root, access, { send = (input, init) => fetch(input, ini
|
|
|
46315
46364
|
prompt,
|
|
46316
46365
|
...plan.size,
|
|
46317
46366
|
priceUsd: plan.priceUsd,
|
|
46367
|
+
...plan.provider.name === "comfyui" && { seed: plan.seed },
|
|
46318
46368
|
savedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
46319
46369
|
});
|
|
46320
46370
|
const record = {
|
|
@@ -46350,7 +46400,7 @@ async function saveFoundModel(project, body, send) {
|
|
|
46350
46400
|
}, /* @__PURE__ */ new Date()));
|
|
46351
46401
|
}
|
|
46352
46402
|
/** The provider a generation would run on and its price, naming each key by its variable alone. */
|
|
46353
|
-
function offer(env
|
|
46403
|
+
function offer(env) {
|
|
46354
46404
|
const keys = PROVIDERS.map((provider) => provider.keyEnv);
|
|
46355
46405
|
try {
|
|
46356
46406
|
const plan = planGeneration({
|
|
@@ -46359,7 +46409,6 @@ function offer(env, enabled) {
|
|
|
46359
46409
|
}, env);
|
|
46360
46410
|
return {
|
|
46361
46411
|
version: 1,
|
|
46362
|
-
enabled,
|
|
46363
46412
|
provider: {
|
|
46364
46413
|
name: plan.provider.name,
|
|
46365
46414
|
model: plan.provider.model,
|
|
@@ -46373,7 +46422,6 @@ function offer(env, enabled) {
|
|
|
46373
46422
|
if (!(error instanceof FrameboardError) || error.code !== "no-provider") throw error;
|
|
46374
46423
|
return {
|
|
46375
46424
|
version: 1,
|
|
46376
|
-
enabled,
|
|
46377
46425
|
provider: null,
|
|
46378
46426
|
keys
|
|
46379
46427
|
};
|
|
@@ -49419,7 +49467,11 @@ const sectionSchema = object$1({
|
|
|
49419
49467
|
page: ref,
|
|
49420
49468
|
section: name
|
|
49421
49469
|
});
|
|
49422
|
-
const projectAddSchema = object$1({
|
|
49470
|
+
const projectAddSchema = object$1({
|
|
49471
|
+
name: name.optional(),
|
|
49472
|
+
/** The home folder the project starts filed in. */
|
|
49473
|
+
group: name.optional()
|
|
49474
|
+
});
|
|
49423
49475
|
const projectSchema = object$1({ ref });
|
|
49424
49476
|
/** More projects than any board holds, so a body cannot grow without bound. */
|
|
49425
49477
|
const projectRefs$1 = array$1(ref).min(1).max(1e3);
|
|
@@ -49941,8 +49993,12 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
49941
49993
|
frames: []
|
|
49942
49994
|
});
|
|
49943
49995
|
app.post("/api/project/add", async (c) => {
|
|
49944
|
-
const
|
|
49945
|
-
const
|
|
49996
|
+
const body = await parseBody$1(c.req.raw, projectAddSchema);
|
|
49997
|
+
const projectName = body.name ?? nextFreeName("untitled", await listProjects(root));
|
|
49998
|
+
const project = await recorded((journal) => addProject(root, projectName, /* @__PURE__ */ new Date(), {
|
|
49999
|
+
journal,
|
|
50000
|
+
group: body.group
|
|
50001
|
+
}), onHome);
|
|
49946
50002
|
return c.json({
|
|
49947
50003
|
ok: true,
|
|
49948
50004
|
data: project
|
|
@@ -57341,11 +57397,12 @@ function terminalCode(modules) {
|
|
|
57341
57397
|
function registerProject(program, context) {
|
|
57342
57398
|
const { io } = context;
|
|
57343
57399
|
const project = program.command("project").description("Manage projects");
|
|
57344
|
-
act(addVerb(project, "add", "Add a project holding one empty page").argument("<name>", "the new project"), context, async ([name = ""], options) => {
|
|
57345
|
-
const
|
|
57400
|
+
act(addVerb(project, "add", "Add a project holding one empty page").argument("<name>", "the new project").option("--group <folder>", "file the project under a home folder, created when no project holds it"), context, async ([name = ""], options) => {
|
|
57401
|
+
const group = options.group === void 0 ? void 0 : validFolder(options.group);
|
|
57402
|
+
const record = await addProject(await boardOf(options, io), name, void 0, { group });
|
|
57346
57403
|
return {
|
|
57347
57404
|
data: record,
|
|
57348
|
-
human: `Added project ${record.name}`
|
|
57405
|
+
human: group ? `Added project ${record.name} under ${group}` : `Added project ${record.name}`
|
|
57349
57406
|
};
|
|
57350
57407
|
});
|
|
57351
57408
|
act(addVerb(project, "rename", "Rename a project").argument("<name>", "the project").argument("<new-name>", "its new name"), context, async ([name = "", newName = ""], options) => {
|
|
@@ -57410,6 +57467,10 @@ function folderOf(folder, clear) {
|
|
|
57410
57467
|
if (clear && folder !== void 0) throw new FrameboardError("usage", "Give a folder or --clear, not both.");
|
|
57411
57468
|
if (clear) return null;
|
|
57412
57469
|
if (folder === void 0) throw new FrameboardError("usage", "Give a folder, or --clear to leave one.");
|
|
57470
|
+
return validFolder(folder);
|
|
57471
|
+
}
|
|
57472
|
+
/** The trimmed folder, refusing a blank or overlong one. */
|
|
57473
|
+
function validFolder(folder) {
|
|
57413
57474
|
const name = folder.trim();
|
|
57414
57475
|
if (name === "" || name.length > MAX_FOLDER) throw new FrameboardError("invalid-name", `A folder name holds 1 to ${MAX_FOLDER} characters.`);
|
|
57415
57476
|
return name;
|