frameboard 0.41.0 → 0.43.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 +1265 -480
- package/dist/client/assets/index-CX8erJFM.js +181 -0
- package/dist/client/assets/index-KpPQ0t7L.css +2 -0
- package/dist/client/index.html +2 -2
- package/dist/frame-bridge.js +71 -71
- package/dist/hook.js +70 -11
- package/dist/viewer/LICENSE +202 -0
- package/dist/viewer/model-viewer.min.js +1118 -0
- package/package.json +3 -2
- package/dist/client/assets/index-D-jPOVe6.css +0 -2
- package/dist/client/assets/index-D_JiNG33.js +0 -180
package/dist/cli.js
CHANGED
|
@@ -3090,6 +3090,7 @@ var FrameboardError = class extends Error {
|
|
|
3090
3090
|
*/
|
|
3091
3091
|
const BOARD_FILE = "board.json";
|
|
3092
3092
|
const PROJECT_FILE = "project.json";
|
|
3093
|
+
const LAYOUT_FILE = "layout.json";
|
|
3093
3094
|
const ASSETS_FOLDER = "assets";
|
|
3094
3095
|
const FRAME_EXTENSION = ".html";
|
|
3095
3096
|
const TOKEN_FILE = "tokens.css";
|
|
@@ -9164,7 +9165,10 @@ const BEZEL_COLORS = {
|
|
|
9164
9165
|
base: "#2c2e33",
|
|
9165
9166
|
edge: "#45484f",
|
|
9166
9167
|
island: "#050506",
|
|
9167
|
-
homeBar: "rgba(128, 128, 128, 0.6)"
|
|
9168
|
+
homeBar: "rgba(128, 128, 128, 0.6)",
|
|
9169
|
+
button: "#2a2c31",
|
|
9170
|
+
islandText: "#ffffff",
|
|
9171
|
+
islandLive: "#34c759"
|
|
9168
9172
|
};
|
|
9169
9173
|
/**
|
|
9170
9174
|
* The phone's island, a generic pill standing in for a size no source gives,
|
|
@@ -9180,6 +9184,125 @@ const HOME_BAR = {
|
|
|
9180
9184
|
height: 5,
|
|
9181
9185
|
bottom: 8
|
|
9182
9186
|
};
|
|
9187
|
+
/** The island's two widths, the compact pill and the wide one a call or a timer shows. */
|
|
9188
|
+
const ISLANDS = ["compact", "wide"];
|
|
9189
|
+
/** A layout entry's `island` as an island, compact for none or a value no reader knows. */
|
|
9190
|
+
function islandOf(value) {
|
|
9191
|
+
return value === "wide" ? "wide" : "compact";
|
|
9192
|
+
}
|
|
9193
|
+
/** The wide island's width, scaled off the picked mock's ratio to the compact one. */
|
|
9194
|
+
const WIDE_ISLAND_WIDTH = 126;
|
|
9195
|
+
/** The phone's island at its picked width, the wide one holding a timer. */
|
|
9196
|
+
function phoneIsland(island) {
|
|
9197
|
+
return island === "wide" ? {
|
|
9198
|
+
...PHONE_ISLAND,
|
|
9199
|
+
width: WIDE_ISLAND_WIDTH
|
|
9200
|
+
} : { ...PHONE_ISLAND };
|
|
9201
|
+
}
|
|
9202
|
+
/** What the wide island shows, a running timer no frame sets, and the heights of the level bars beside it. */
|
|
9203
|
+
const WIDE_ISLAND_TIMER = "0:42";
|
|
9204
|
+
const WIDE_ISLAND_LEVEL = [
|
|
9205
|
+
5,
|
|
9206
|
+
9,
|
|
9207
|
+
7
|
|
9208
|
+
];
|
|
9209
|
+
/**
|
|
9210
|
+
* The phone's side buttons, each from the body's top edge, scaled off the
|
|
9211
|
+
* picked mock: the action button and two volume buttons on the left, and
|
|
9212
|
+
* the side button on the right.
|
|
9213
|
+
*/
|
|
9214
|
+
const PHONE_BUTTONS = [
|
|
9215
|
+
{
|
|
9216
|
+
side: "left",
|
|
9217
|
+
top: 142,
|
|
9218
|
+
height: 33
|
|
9219
|
+
},
|
|
9220
|
+
{
|
|
9221
|
+
side: "left",
|
|
9222
|
+
top: 195,
|
|
9223
|
+
height: 59
|
|
9224
|
+
},
|
|
9225
|
+
{
|
|
9226
|
+
side: "left",
|
|
9227
|
+
top: 266,
|
|
9228
|
+
height: 59
|
|
9229
|
+
},
|
|
9230
|
+
{
|
|
9231
|
+
side: "right",
|
|
9232
|
+
top: 222,
|
|
9233
|
+
height: 95
|
|
9234
|
+
}
|
|
9235
|
+
];
|
|
9236
|
+
/**
|
|
9237
|
+
* The phone's status bar, ending 10 below the island so a page under it
|
|
9238
|
+
* clears the island, its time and marks in the island's band `side` in from
|
|
9239
|
+
* each edge, past the screen's corner arc.
|
|
9240
|
+
*/
|
|
9241
|
+
const STATUS_BAR = {
|
|
9242
|
+
height: PHONE_ISLAND.top + PHONE_ISLAND.height + 10,
|
|
9243
|
+
band: {
|
|
9244
|
+
top: PHONE_ISLAND.top,
|
|
9245
|
+
height: PHONE_ISLAND.height
|
|
9246
|
+
},
|
|
9247
|
+
side: 40,
|
|
9248
|
+
time: "9:41",
|
|
9249
|
+
font: 16
|
|
9250
|
+
};
|
|
9251
|
+
/** The face the status bar and the wide island draw in, a system face every surface holds. */
|
|
9252
|
+
const STATUS_FONT = "system-ui, -apple-system, sans-serif";
|
|
9253
|
+
/** The status bar's signal bars, shortest first, and its battery, each in points. */
|
|
9254
|
+
const SIGNAL_BARS = [
|
|
9255
|
+
4,
|
|
9256
|
+
6.5,
|
|
9257
|
+
9,
|
|
9258
|
+
11.5
|
|
9259
|
+
];
|
|
9260
|
+
const BATTERY = {
|
|
9261
|
+
width: 25,
|
|
9262
|
+
height: 12,
|
|
9263
|
+
radius: 3.5,
|
|
9264
|
+
cap: 2
|
|
9265
|
+
};
|
|
9266
|
+
/** The height the device's status bar takes off the top of a frame's box, 0 for any device but the phone. */
|
|
9267
|
+
function topInset(device) {
|
|
9268
|
+
return device === "phone" ? STATUS_BAR.height : 0;
|
|
9269
|
+
}
|
|
9270
|
+
/**
|
|
9271
|
+
* The page's box inside a frame's box, the box less the status bar while a
|
|
9272
|
+
* phone shows and the box itself on every other device or none. A frame's
|
|
9273
|
+
* box keeps the screen's size, and every surface reads the page through this.
|
|
9274
|
+
*/
|
|
9275
|
+
function pageBox(box, device) {
|
|
9276
|
+
const inset = topInset(device);
|
|
9277
|
+
return {
|
|
9278
|
+
x: box.x,
|
|
9279
|
+
y: box.y + inset,
|
|
9280
|
+
width: box.width,
|
|
9281
|
+
height: Math.max(0, box.height - inset)
|
|
9282
|
+
};
|
|
9283
|
+
}
|
|
9284
|
+
/** The page's corners as a CSS `border-radius`, square on top under a phone's status bar. */
|
|
9285
|
+
function pageCorners(device) {
|
|
9286
|
+
if (device !== "phone") return screenCorners(device);
|
|
9287
|
+
const { screenRadius } = BEZELS.phone;
|
|
9288
|
+
return `0 0 ${screenRadius}px ${screenRadius}px`;
|
|
9289
|
+
}
|
|
9290
|
+
/**
|
|
9291
|
+
* The fill a page shows at its top and its text color, read off its root and
|
|
9292
|
+
* then its body as the browser paints the canvas. Self-contained, so a
|
|
9293
|
+
* browser runs it in the page by its source alone.
|
|
9294
|
+
*/
|
|
9295
|
+
function pageColors(doc = document) {
|
|
9296
|
+
const view = doc.defaultView;
|
|
9297
|
+
const read = (element) => element && view ? view.getComputedStyle(element) : null;
|
|
9298
|
+
const root = read(doc.documentElement);
|
|
9299
|
+
const body = read(doc.body);
|
|
9300
|
+
const painted = (color) => color !== void 0 && color !== "transparent" && !/^rgba\(.*,\s*0\)$/.test(color);
|
|
9301
|
+
return {
|
|
9302
|
+
fill: [root?.backgroundColor, body?.backgroundColor].find(painted) ?? null,
|
|
9303
|
+
ink: body?.color ?? root?.color ?? "CanvasText"
|
|
9304
|
+
};
|
|
9305
|
+
}
|
|
9183
9306
|
/** The ways a foldable is held, each a screen the frame's box takes the size of. */
|
|
9184
9307
|
const POSES = [
|
|
9185
9308
|
"closed",
|
|
@@ -9265,6 +9388,11 @@ function laptopParts({ width, height }) {
|
|
|
9265
9388
|
}
|
|
9266
9389
|
};
|
|
9267
9390
|
}
|
|
9391
|
+
/** How far a device's parts stand past its body's sides, a laptop's base or a phone's buttons. */
|
|
9392
|
+
function sideReach(device, width) {
|
|
9393
|
+
if (device === "laptop") return baseReach(width);
|
|
9394
|
+
return device === "phone" ? 4 : 0;
|
|
9395
|
+
}
|
|
9268
9396
|
function baseReach(width) {
|
|
9269
9397
|
return Math.round((width + 2 * BEZELS.laptop.border) * LAPTOP_BASE.reach);
|
|
9270
9398
|
}
|
|
@@ -9283,13 +9411,13 @@ function bezelShadow(device, { board = true } = {}) {
|
|
|
9283
9411
|
}
|
|
9284
9412
|
/**
|
|
9285
9413
|
* The box a device's body covers around a frame's box, the box itself with
|
|
9286
|
-
* none. A laptop's base reaches past its lid
|
|
9287
|
-
* than
|
|
9414
|
+
* none. A laptop's base reaches past its lid and a phone's buttons past its
|
|
9415
|
+
* sides, so their sides grow by more than their top.
|
|
9288
9416
|
*/
|
|
9289
9417
|
function bezelBox(box, device) {
|
|
9290
9418
|
if (!device) return { ...box };
|
|
9291
9419
|
const { border, bottom } = BEZELS[device];
|
|
9292
|
-
const side =
|
|
9420
|
+
const side = border + sideReach(device, box.width);
|
|
9293
9421
|
return {
|
|
9294
9422
|
x: box.x - side,
|
|
9295
9423
|
y: box.y - border,
|
|
@@ -9558,6 +9686,85 @@ function xPast(edge, width, device) {
|
|
|
9558
9686
|
}, device);
|
|
9559
9687
|
return edge + 80 - body.x;
|
|
9560
9688
|
}
|
|
9689
|
+
// src/shared/names.ts
|
|
9690
|
+
/** One rule for project, page, and frame names, matching v01.3's naming check. */
|
|
9691
|
+
const NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
9692
|
+
/** Names a page may not take, since the folder means something else in a project. */
|
|
9693
|
+
const RESERVED_PAGE_NAMES = ["assets"];
|
|
9694
|
+
function isValidName(name) {
|
|
9695
|
+
return name.length <= 64 && NAME_PATTERN.test(name);
|
|
9696
|
+
}
|
|
9697
|
+
function isReservedPageName(name) {
|
|
9698
|
+
return RESERVED_PAGE_NAMES.some((reserved) => namesCollide(reserved, name));
|
|
9699
|
+
}
|
|
9700
|
+
/** Case-insensitive, since the default macOS volume is. */
|
|
9701
|
+
function namesCollide(a, b) {
|
|
9702
|
+
return a.toLowerCase() === b.toLowerCase();
|
|
9703
|
+
}
|
|
9704
|
+
/** `base` when free, else the first free `base-2`, `base-3`, and onward. */
|
|
9705
|
+
function nextFreeName(base, taken) {
|
|
9706
|
+
const lowered = new Set([...taken].map((name) => name.toLowerCase()));
|
|
9707
|
+
if (!lowered.has(base.toLowerCase())) return base;
|
|
9708
|
+
for (let suffix = 2;; suffix++) {
|
|
9709
|
+
const candidate = `${base}-${suffix}`;
|
|
9710
|
+
if (!lowered.has(candidate.toLowerCase())) return candidate;
|
|
9711
|
+
}
|
|
9712
|
+
}
|
|
9713
|
+
/**
|
|
9714
|
+
* The folder a retitled project lands in, cut back near the length limit so
|
|
9715
|
+
* the folder always stays a valid name.
|
|
9716
|
+
*/
|
|
9717
|
+
function titledFolder(current, title, taken) {
|
|
9718
|
+
const folder = folderName(title);
|
|
9719
|
+
if (folder === "" || namesCollide(folder, current)) return current;
|
|
9720
|
+
const others = [...taken].filter((name) => name !== current);
|
|
9721
|
+
for (let cut = folder.length; cut > 0; cut--) {
|
|
9722
|
+
const base = folder.slice(0, cut).replace(/-+$/, "");
|
|
9723
|
+
const free = nextFreeName(base, others);
|
|
9724
|
+
if (base !== "" && free.length <= 64) return free;
|
|
9725
|
+
}
|
|
9726
|
+
return current;
|
|
9727
|
+
}
|
|
9728
|
+
/**
|
|
9729
|
+
* A typed title as the folder it names, lower case with each run of
|
|
9730
|
+
* characters a name may not hold turned into one dash, so `Acme mobile`
|
|
9731
|
+
* becomes `acme-mobile`. Empty when the title holds nothing a name may.
|
|
9732
|
+
*/
|
|
9733
|
+
function folderName(typed) {
|
|
9734
|
+
return typed.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "").slice(0, 64).replace(/-+$/, "");
|
|
9735
|
+
}
|
|
9736
|
+
// src/shared/kits.ts
|
|
9737
|
+
/**
|
|
9738
|
+
* The names a design kit's folder of plain files is laid out by, installed so
|
|
9739
|
+
* the frame route imports `assets/kit/` after the token sheets.
|
|
9740
|
+
*/
|
|
9741
|
+
const KIT_FILE = "kit.json";
|
|
9742
|
+
const KIT_SHEET = "kit.css";
|
|
9743
|
+
const KIT_NOTE = "kit.md";
|
|
9744
|
+
/** The folder under a project's `assets/` holding each kit it added, one folder per kit. */
|
|
9745
|
+
const PROJECT_KITS = "kits";
|
|
9746
|
+
/** The dot folder in a board holding the kits saved from its projects, which home never lists as a project. */
|
|
9747
|
+
const KITS_FOLDER = ".kits";
|
|
9748
|
+
/**
|
|
9749
|
+
* Where the board serves a kit's files, under `/frameboard/`, since a bare
|
|
9750
|
+
* `/kits` would shadow the client's module folder under the dev server.
|
|
9751
|
+
*/
|
|
9752
|
+
const KITS_URL = "/frameboard/kits";
|
|
9753
|
+
/** The word `frame kit` takes in place of a kit to clear the frame's, so a project kit by this name is set over the route alone. */
|
|
9754
|
+
const NO_KIT_WORD = "none";
|
|
9755
|
+
/** The kits the tool ships, in the order a picker shows them. */
|
|
9756
|
+
const SHIPPED_KITS = [
|
|
9757
|
+
"clean",
|
|
9758
|
+
"sketch",
|
|
9759
|
+
"wireframe"
|
|
9760
|
+
];
|
|
9761
|
+
/**
|
|
9762
|
+
* The project kit a layout entry's `kit` names, null for none, a value of
|
|
9763
|
+
* another type, or a name that could leave the project's kits folder.
|
|
9764
|
+
*/
|
|
9765
|
+
function kitOf(value) {
|
|
9766
|
+
return typeof value === "string" && isValidName(value) ? value : null;
|
|
9767
|
+
}
|
|
9561
9768
|
// src/shared/present-transition.ts
|
|
9562
9769
|
/**
|
|
9563
9770
|
* The board's own present transitions in inspector order, beside a project's
|
|
@@ -9729,8 +9936,10 @@ const layoutEntrySchema = looseObject({
|
|
|
9729
9936
|
device: unknown().optional(),
|
|
9730
9937
|
foldable: unknown().optional(),
|
|
9731
9938
|
pose: unknown().optional(),
|
|
9939
|
+
island: unknown().optional(),
|
|
9732
9940
|
transition: unknown().optional(),
|
|
9733
|
-
speakerNotes: unknown().optional()
|
|
9941
|
+
speakerNotes: unknown().optional(),
|
|
9942
|
+
kit: unknown().optional()
|
|
9734
9943
|
});
|
|
9735
9944
|
/** The longest speaker note a write accepts, in characters. */
|
|
9736
9945
|
const SPEAKER_NOTES_MAX = 1e4;
|
|
@@ -9768,6 +9977,185 @@ function membersOf(sections, frames) {
|
|
|
9768
9977
|
}
|
|
9769
9978
|
return members;
|
|
9770
9979
|
}
|
|
9980
|
+
// src/server/board/refs.ts
|
|
9981
|
+
/**
|
|
9982
|
+
* The project a verb acts on: the one named, else the board's only project.
|
|
9983
|
+
* A name matching an existing project in another case resolves to that one.
|
|
9984
|
+
*/
|
|
9985
|
+
async function resolveProject(root, project) {
|
|
9986
|
+
const projects = await listProjects(root);
|
|
9987
|
+
if (project === void 0) {
|
|
9988
|
+
const [only, ...others] = projects;
|
|
9989
|
+
if (!only || others.length > 0) throw new FrameboardError("project-required", projects.length === 0 ? "The board has no project. Run frameboard project add <name> first." : `The board has ${projects.length} projects, so pass --project <name> or a ref naming one.`, { projects });
|
|
9990
|
+
return {
|
|
9991
|
+
name: only,
|
|
9992
|
+
path: join(root, only)
|
|
9993
|
+
};
|
|
9994
|
+
}
|
|
9995
|
+
const name = matchName(projects, project);
|
|
9996
|
+
if (!name) throw new FrameboardError("project-not-found", `No project ${project} in ${root}.`, {
|
|
9997
|
+
project,
|
|
9998
|
+
projects
|
|
9999
|
+
});
|
|
10000
|
+
return {
|
|
10001
|
+
name,
|
|
10002
|
+
path: join(root, name)
|
|
10003
|
+
};
|
|
10004
|
+
}
|
|
10005
|
+
/** A page ref is `<page>` or `<project>/<page>`. */
|
|
10006
|
+
async function resolvePageRef(root, ref, options) {
|
|
10007
|
+
const parts = splitRef(ref, 2);
|
|
10008
|
+
const pageName = parts.at(-1) ?? "";
|
|
10009
|
+
const project = await resolveProject(root, agreeingProject(ref, parts.length === 2 ? parts[0] : void 0, options));
|
|
10010
|
+
const page = await findPage(project.path, pageName, options.allowMissing);
|
|
10011
|
+
return {
|
|
10012
|
+
root,
|
|
10013
|
+
project: project.name,
|
|
10014
|
+
page: page.name,
|
|
10015
|
+
name: page.name,
|
|
10016
|
+
path: page.path
|
|
10017
|
+
};
|
|
10018
|
+
}
|
|
10019
|
+
/**
|
|
10020
|
+
* A frame ref is `<page>/<frame>` or `<project>/<page>/<frame>`. An argument
|
|
10021
|
+
* ending in `.html` is instead a path against `cwd`, which must sit in a page
|
|
10022
|
+
* of this board.
|
|
10023
|
+
*/
|
|
10024
|
+
async function resolveFrameRef(root, ref, options) {
|
|
10025
|
+
const parts = ref.endsWith(".html") ? await framePathParts(root, ref, options.cwd) : splitRef(ref, 3);
|
|
10026
|
+
if (parts.length < 2) throw new FrameboardError("usage", `${ref} is not a frame ref. Write <page>/<frame>, <project>/<page>/<frame>, or a path to the .html file.`, { ref });
|
|
10027
|
+
const frameName = parts.at(-1) ?? "";
|
|
10028
|
+
const pageName = parts.at(-2) ?? "";
|
|
10029
|
+
const project = await resolveProject(root, agreeingProject(ref, parts.length === 3 ? parts[0] : void 0, options));
|
|
10030
|
+
const page = await findPage(project.path, pageName, false);
|
|
10031
|
+
const frames = await listFrames(page.path);
|
|
10032
|
+
const found = matchName(frames, frameName);
|
|
10033
|
+
if (!found && !options.allowMissing) throw new FrameboardError("frame-not-found", `No frame ${frameName} in ${project.name}/${page.name}.`, {
|
|
10034
|
+
ref,
|
|
10035
|
+
frames
|
|
10036
|
+
});
|
|
10037
|
+
if (!found) assertValidName("frame", frameName);
|
|
10038
|
+
const name = found ?? frameName;
|
|
10039
|
+
return {
|
|
10040
|
+
root,
|
|
10041
|
+
project: project.name,
|
|
10042
|
+
page: page.name,
|
|
10043
|
+
name,
|
|
10044
|
+
path: join(page.path, `${name}${FRAME_EXTENSION}`)
|
|
10045
|
+
};
|
|
10046
|
+
}
|
|
10047
|
+
/** Throws `invalid-name` for a name a new project, page, or frame may not take. */
|
|
10048
|
+
function assertValidName(kind, name) {
|
|
10049
|
+
if (!isValidName(name)) throw new FrameboardError("invalid-name", `${name} is not a valid ${kind} name. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit, at most 64 characters.`, {
|
|
10050
|
+
kind,
|
|
10051
|
+
name
|
|
10052
|
+
});
|
|
10053
|
+
if (kind === "page" && isReservedPageName(name)) throw new FrameboardError("invalid-name", `${name} is reserved for the project's shared files, so a page cannot take it.`, {
|
|
10054
|
+
kind,
|
|
10055
|
+
name
|
|
10056
|
+
});
|
|
10057
|
+
}
|
|
10058
|
+
/** The existing name equal to `name`, else one equal in another case. */
|
|
10059
|
+
function matchName(names, name) {
|
|
10060
|
+
return names.find((n) => n === name) ?? names.find((n) => namesCollide(n, name));
|
|
10061
|
+
}
|
|
10062
|
+
async function findPage(projectDir, name, allowMissing = false) {
|
|
10063
|
+
const pages = await listPageFolders(projectDir);
|
|
10064
|
+
const found = matchName(pages, name);
|
|
10065
|
+
if (!found && !allowMissing) throw new FrameboardError("page-not-found", `No page ${name} in ${projectDir}.`, {
|
|
10066
|
+
page: name,
|
|
10067
|
+
pages
|
|
10068
|
+
});
|
|
10069
|
+
if (!found) assertValidName("page", name);
|
|
10070
|
+
const resolved = found ?? name;
|
|
10071
|
+
return {
|
|
10072
|
+
name: resolved,
|
|
10073
|
+
path: join(projectDir, resolved)
|
|
10074
|
+
};
|
|
10075
|
+
}
|
|
10076
|
+
function splitRef(ref, max) {
|
|
10077
|
+
const parts = ref.split("/");
|
|
10078
|
+
if (parts.length > max || parts.some((part) => part === "")) throw new FrameboardError("usage", `${ref} is not a ${max === 2 ? "page" : "frame"} ref.`, { ref });
|
|
10079
|
+
return parts;
|
|
10080
|
+
}
|
|
10081
|
+
function agreeingProject(ref, fromRef, { project }) {
|
|
10082
|
+
if (fromRef !== void 0 && project !== void 0 && !namesCollide(fromRef, project)) throw new FrameboardError("usage", `${ref} names project ${fromRef} but --project names ${project}.`, {
|
|
10083
|
+
ref,
|
|
10084
|
+
project
|
|
10085
|
+
});
|
|
10086
|
+
return fromRef ?? project;
|
|
10087
|
+
}
|
|
10088
|
+
async function framePathParts(root, ref, cwd) {
|
|
10089
|
+
const path = resolve$1(cwd, ref);
|
|
10090
|
+
let folder = dirname(path);
|
|
10091
|
+
try {
|
|
10092
|
+
folder = await realpath(folder);
|
|
10093
|
+
} catch (error) {
|
|
10094
|
+
if (!isCode(error, "ENOENT")) throw error;
|
|
10095
|
+
}
|
|
10096
|
+
const inside = relative(root, folder);
|
|
10097
|
+
const parts = inside.split(sep);
|
|
10098
|
+
if (inside === "" || inside.startsWith("..") || isAbsolute(inside) || parts.length !== 2) throw new FrameboardError("usage", `${path} does not sit in a page of the board at ${root}.`, {
|
|
10099
|
+
path,
|
|
10100
|
+
root
|
|
10101
|
+
});
|
|
10102
|
+
const file = path.slice(dirname(path).length + 1);
|
|
10103
|
+
return [...parts, file.slice(0, -5)];
|
|
10104
|
+
}
|
|
10105
|
+
// src/server/kits/project.ts
|
|
10106
|
+
/** The folder a project keeps the kit named `kit` in, which a caller checks is a valid name first. */
|
|
10107
|
+
function projectKitDir(projectDir, kit) {
|
|
10108
|
+
return join(projectDir, ASSETS_FOLDER, PROJECT_KITS, kit);
|
|
10109
|
+
}
|
|
10110
|
+
/**
|
|
10111
|
+
* The kits a project added, sorted by name, being each folder under its
|
|
10112
|
+
* `assets/kits/` a frame could name. A hand-built folder counts, since a
|
|
10113
|
+
* kit reaches a frame only where the frame names it.
|
|
10114
|
+
*/
|
|
10115
|
+
async function projectKitNames(projectDir) {
|
|
10116
|
+
let entries;
|
|
10117
|
+
try {
|
|
10118
|
+
entries = await readdir(join(projectDir, ASSETS_FOLDER, PROJECT_KITS), { withFileTypes: true });
|
|
10119
|
+
} catch {
|
|
10120
|
+
return [];
|
|
10121
|
+
}
|
|
10122
|
+
return entries.filter((entry) => entry.isDirectory() && isValidName(entry.name)).map((entry) => entry.name).sort();
|
|
10123
|
+
}
|
|
10124
|
+
/** The project's kit `name` answers to, refusing `kit-not-found` with the kits it holds. */
|
|
10125
|
+
async function heldKit(project, name) {
|
|
10126
|
+
const known = await projectKitNames(project.path);
|
|
10127
|
+
const found = matchName(known, name);
|
|
10128
|
+
if (found) return found;
|
|
10129
|
+
throw new FrameboardError("kit-not-found", `${project.name} holds no kit named ${name}. Add one with \`frameboard kit add ${project.name} <kit>\`.`, {
|
|
10130
|
+
kit: name,
|
|
10131
|
+
project: project.name,
|
|
10132
|
+
known
|
|
10133
|
+
});
|
|
10134
|
+
}
|
|
10135
|
+
/**
|
|
10136
|
+
* A project's kits as `list --json` answers them, each with how many of
|
|
10137
|
+
* `pages`' frames name it. The pages come scanned, so a scan never reads
|
|
10138
|
+
* a layout twice.
|
|
10139
|
+
*/
|
|
10140
|
+
async function projectKits(projectDir, pages) {
|
|
10141
|
+
const named = pages.flatMap((page) => page.frames.map((frame) => frame.kit));
|
|
10142
|
+
const names = await projectKitNames(projectDir);
|
|
10143
|
+
return Promise.all(names.map(async (name) => ({
|
|
10144
|
+
name,
|
|
10145
|
+
title: await titleOf$1(projectKitDir(projectDir, name), name),
|
|
10146
|
+
frameCount: named.filter((kit) => kit === name).length
|
|
10147
|
+
})));
|
|
10148
|
+
}
|
|
10149
|
+
/** The title a kit's `kit.json` gives, or its folder name where the file gives none. */
|
|
10150
|
+
async function titleOf$1(kitDir, name) {
|
|
10151
|
+
try {
|
|
10152
|
+
const parsed = JSON.parse(await readFile(join(kitDir, KIT_FILE), "utf8"));
|
|
10153
|
+
const title = typeof parsed === "object" && parsed !== null && "title" in parsed ? parsed.title : void 0;
|
|
10154
|
+
return typeof title === "string" && title.trim() !== "" ? title.trim() : name;
|
|
10155
|
+
} catch {
|
|
10156
|
+
return name;
|
|
10157
|
+
}
|
|
10158
|
+
}
|
|
9771
10159
|
// node_modules/picocolors/picocolors.js
|
|
9772
10160
|
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9773
10161
|
let p = process || {};
|
|
@@ -23556,7 +23944,7 @@ var Document = class extends NodeWithChildren {
|
|
|
23556
23944
|
/**
|
|
23557
23945
|
* An element within the DOM.
|
|
23558
23946
|
*/
|
|
23559
|
-
var Element = class extends NodeWithChildren {
|
|
23947
|
+
var Element$1 = class extends NodeWithChildren {
|
|
23560
23948
|
name;
|
|
23561
23949
|
attribs;
|
|
23562
23950
|
type;
|
|
@@ -23668,7 +24056,7 @@ function cloneNode(node, recursive = false) {
|
|
|
23668
24056
|
else if (isComment(node)) result = new Comment(node.data);
|
|
23669
24057
|
else if (isTag(node)) {
|
|
23670
24058
|
const children = recursive ? cloneChildren(node.children) : [];
|
|
23671
|
-
const clone = new Element(node.name, { ...node.attribs }, children);
|
|
24059
|
+
const clone = new Element$1(node.name, { ...node.attribs }, children);
|
|
23672
24060
|
for (const child of children) child.parent = clone;
|
|
23673
24061
|
if (node.namespace != null) clone.namespace = node.namespace;
|
|
23674
24062
|
if (node["x-attribsNamespace"]) clone["x-attribsNamespace"] = { ...node["x-attribsNamespace"] };
|
|
@@ -23748,7 +24136,7 @@ const adapter = {
|
|
|
23748
24136
|
attribsNamespace[attrName] = attrs[i].namespace;
|
|
23749
24137
|
attribsPrefix[attrName] = attrs[i].prefix;
|
|
23750
24138
|
}
|
|
23751
|
-
const node = new Element(tagName, attribs, []);
|
|
24139
|
+
const node = new Element$1(tagName, attribs, []);
|
|
23752
24140
|
node.namespace = namespaceURI;
|
|
23753
24141
|
node["x-attribsNamespace"] = attribsNamespace;
|
|
23754
24142
|
node["x-attribsPrefix"] = attribsPrefix;
|
|
@@ -24408,7 +24796,6 @@ async function assertKnownTransition(projectDir, transition) {
|
|
|
24408
24796
|
});
|
|
24409
24797
|
}
|
|
24410
24798
|
// src/server/board/scan.ts
|
|
24411
|
-
const LAYOUT_FILE = "layout.json";
|
|
24412
24799
|
const layoutSpec = {
|
|
24413
24800
|
schema: layoutFileSchema,
|
|
24414
24801
|
invalidCode: "layout-invalid",
|
|
@@ -24536,6 +24923,7 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
|
|
|
24536
24923
|
const device = shown ? named : null;
|
|
24537
24924
|
const transition = readTransition(entry.transition);
|
|
24538
24925
|
const speakerNotes = speakerNotesOf(entry.speakerNotes);
|
|
24926
|
+
const kit = kitOf(entry.kit);
|
|
24539
24927
|
placements.set(name, {
|
|
24540
24928
|
box,
|
|
24541
24929
|
order: entry.order,
|
|
@@ -24552,8 +24940,10 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
|
|
|
24552
24940
|
pose: poseOf(entry.pose)
|
|
24553
24941
|
} : {},
|
|
24554
24942
|
...foldable && kept.length > 0 ? { keptWidths: kept } : {},
|
|
24943
|
+
...islandOf(entry.island) === "wide" ? { island: "wide" } : {},
|
|
24555
24944
|
...transition ? { transition } : {},
|
|
24556
24945
|
...speakerNotes ? { speakerNotes } : {},
|
|
24946
|
+
...kit ? { kit } : {},
|
|
24557
24947
|
placed: true
|
|
24558
24948
|
});
|
|
24559
24949
|
}
|
|
@@ -24631,6 +25021,7 @@ async function scanProject(root, name) {
|
|
|
24631
25021
|
projectFileError: error,
|
|
24632
25022
|
transitions,
|
|
24633
25023
|
checksOff,
|
|
25024
|
+
kits: await projectKits(path, pages),
|
|
24634
25025
|
pages
|
|
24635
25026
|
};
|
|
24636
25027
|
}
|
|
@@ -24781,7 +25172,7 @@ async function isDirectory(path) {
|
|
|
24781
25172
|
}
|
|
24782
25173
|
}
|
|
24783
25174
|
// package.json
|
|
24784
|
-
var version$1 = "0.
|
|
25175
|
+
var version$1 = "0.43.0";
|
|
24785
25176
|
var dependencies = { "playwright-core": "1.65.0" };
|
|
24786
25177
|
var peerDependencies = { "oxfmt": "0.78.0" };
|
|
24787
25178
|
// src/shared/version.ts
|
|
@@ -24882,53 +25273,6 @@ async function findLiveServer(root) {
|
|
|
24882
25273
|
return null;
|
|
24883
25274
|
}
|
|
24884
25275
|
}
|
|
24885
|
-
// src/shared/names.ts
|
|
24886
|
-
/** One rule for project, page, and frame names, matching v01.3's naming check. */
|
|
24887
|
-
const NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
24888
|
-
/** Names a page may not take, since the folder means something else in a project. */
|
|
24889
|
-
const RESERVED_PAGE_NAMES = ["assets"];
|
|
24890
|
-
function isValidName(name) {
|
|
24891
|
-
return name.length <= 64 && NAME_PATTERN.test(name);
|
|
24892
|
-
}
|
|
24893
|
-
function isReservedPageName(name) {
|
|
24894
|
-
return RESERVED_PAGE_NAMES.some((reserved) => namesCollide(reserved, name));
|
|
24895
|
-
}
|
|
24896
|
-
/** Case-insensitive, since the default macOS volume is. */
|
|
24897
|
-
function namesCollide(a, b) {
|
|
24898
|
-
return a.toLowerCase() === b.toLowerCase();
|
|
24899
|
-
}
|
|
24900
|
-
/** `base` when free, else the first free `base-2`, `base-3`, and onward. */
|
|
24901
|
-
function nextFreeName(base, taken) {
|
|
24902
|
-
const lowered = new Set([...taken].map((name) => name.toLowerCase()));
|
|
24903
|
-
if (!lowered.has(base.toLowerCase())) return base;
|
|
24904
|
-
for (let suffix = 2;; suffix++) {
|
|
24905
|
-
const candidate = `${base}-${suffix}`;
|
|
24906
|
-
if (!lowered.has(candidate.toLowerCase())) return candidate;
|
|
24907
|
-
}
|
|
24908
|
-
}
|
|
24909
|
-
/**
|
|
24910
|
-
* The folder a retitled project lands in, cut back near the length limit so
|
|
24911
|
-
* the folder always stays a valid name.
|
|
24912
|
-
*/
|
|
24913
|
-
function titledFolder(current, title, taken) {
|
|
24914
|
-
const folder = folderName(title);
|
|
24915
|
-
if (folder === "" || namesCollide(folder, current)) return current;
|
|
24916
|
-
const others = [...taken].filter((name) => name !== current);
|
|
24917
|
-
for (let cut = folder.length; cut > 0; cut--) {
|
|
24918
|
-
const base = folder.slice(0, cut).replace(/-+$/, "");
|
|
24919
|
-
const free = nextFreeName(base, others);
|
|
24920
|
-
if (base !== "" && free.length <= 64) return free;
|
|
24921
|
-
}
|
|
24922
|
-
return current;
|
|
24923
|
-
}
|
|
24924
|
-
/**
|
|
24925
|
-
* A typed title as the folder it names, lower case with each run of
|
|
24926
|
-
* characters a name may not hold turned into one dash, so `Acme mobile`
|
|
24927
|
-
* becomes `acme-mobile`. Empty when the title holds nothing a name may.
|
|
24928
|
-
*/
|
|
24929
|
-
function folderName(typed) {
|
|
24930
|
-
return typed.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "").slice(0, 64).replace(/-+$/, "");
|
|
24931
|
-
}
|
|
24932
25276
|
// src/shared/records/claims.ts
|
|
24933
25277
|
/**
|
|
24934
25278
|
* Where a reserved frame will land, and which axes take their size from the
|
|
@@ -25126,131 +25470,6 @@ async function release(root, session, frame, now) {
|
|
|
25126
25470
|
});
|
|
25127
25471
|
return dropped;
|
|
25128
25472
|
}
|
|
25129
|
-
// src/server/board/refs.ts
|
|
25130
|
-
/**
|
|
25131
|
-
* The project a verb acts on: the one named, else the board's only project.
|
|
25132
|
-
* A name matching an existing project in another case resolves to that one.
|
|
25133
|
-
*/
|
|
25134
|
-
async function resolveProject(root, project) {
|
|
25135
|
-
const projects = await listProjects(root);
|
|
25136
|
-
if (project === void 0) {
|
|
25137
|
-
const [only, ...others] = projects;
|
|
25138
|
-
if (!only || others.length > 0) throw new FrameboardError("project-required", projects.length === 0 ? "The board has no project. Run frameboard project add <name> first." : `The board has ${projects.length} projects, so pass --project <name> or a ref naming one.`, { projects });
|
|
25139
|
-
return {
|
|
25140
|
-
name: only,
|
|
25141
|
-
path: join(root, only)
|
|
25142
|
-
};
|
|
25143
|
-
}
|
|
25144
|
-
const name = matchName(projects, project);
|
|
25145
|
-
if (!name) throw new FrameboardError("project-not-found", `No project ${project} in ${root}.`, {
|
|
25146
|
-
project,
|
|
25147
|
-
projects
|
|
25148
|
-
});
|
|
25149
|
-
return {
|
|
25150
|
-
name,
|
|
25151
|
-
path: join(root, name)
|
|
25152
|
-
};
|
|
25153
|
-
}
|
|
25154
|
-
/** A page ref is `<page>` or `<project>/<page>`. */
|
|
25155
|
-
async function resolvePageRef(root, ref, options) {
|
|
25156
|
-
const parts = splitRef(ref, 2);
|
|
25157
|
-
const pageName = parts.at(-1) ?? "";
|
|
25158
|
-
const project = await resolveProject(root, agreeingProject(ref, parts.length === 2 ? parts[0] : void 0, options));
|
|
25159
|
-
const page = await findPage(project.path, pageName, options.allowMissing);
|
|
25160
|
-
return {
|
|
25161
|
-
root,
|
|
25162
|
-
project: project.name,
|
|
25163
|
-
page: page.name,
|
|
25164
|
-
name: page.name,
|
|
25165
|
-
path: page.path
|
|
25166
|
-
};
|
|
25167
|
-
}
|
|
25168
|
-
/**
|
|
25169
|
-
* A frame ref is `<page>/<frame>` or `<project>/<page>/<frame>`. An argument
|
|
25170
|
-
* ending in `.html` is instead a path against `cwd`, which must sit in a page
|
|
25171
|
-
* of this board.
|
|
25172
|
-
*/
|
|
25173
|
-
async function resolveFrameRef(root, ref, options) {
|
|
25174
|
-
const parts = ref.endsWith(".html") ? await framePathParts(root, ref, options.cwd) : splitRef(ref, 3);
|
|
25175
|
-
if (parts.length < 2) throw new FrameboardError("usage", `${ref} is not a frame ref. Write <page>/<frame>, <project>/<page>/<frame>, or a path to the .html file.`, { ref });
|
|
25176
|
-
const frameName = parts.at(-1) ?? "";
|
|
25177
|
-
const pageName = parts.at(-2) ?? "";
|
|
25178
|
-
const project = await resolveProject(root, agreeingProject(ref, parts.length === 3 ? parts[0] : void 0, options));
|
|
25179
|
-
const page = await findPage(project.path, pageName, false);
|
|
25180
|
-
const frames = await listFrames(page.path);
|
|
25181
|
-
const found = matchName(frames, frameName);
|
|
25182
|
-
if (!found && !options.allowMissing) throw new FrameboardError("frame-not-found", `No frame ${frameName} in ${project.name}/${page.name}.`, {
|
|
25183
|
-
ref,
|
|
25184
|
-
frames
|
|
25185
|
-
});
|
|
25186
|
-
if (!found) assertValidName("frame", frameName);
|
|
25187
|
-
const name = found ?? frameName;
|
|
25188
|
-
return {
|
|
25189
|
-
root,
|
|
25190
|
-
project: project.name,
|
|
25191
|
-
page: page.name,
|
|
25192
|
-
name,
|
|
25193
|
-
path: join(page.path, `${name}${FRAME_EXTENSION}`)
|
|
25194
|
-
};
|
|
25195
|
-
}
|
|
25196
|
-
/** Throws `invalid-name` for a name a new project, page, or frame may not take. */
|
|
25197
|
-
function assertValidName(kind, name) {
|
|
25198
|
-
if (!isValidName(name)) throw new FrameboardError("invalid-name", `${name} is not a valid ${kind} name. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit, at most 64 characters.`, {
|
|
25199
|
-
kind,
|
|
25200
|
-
name
|
|
25201
|
-
});
|
|
25202
|
-
if (kind === "page" && isReservedPageName(name)) throw new FrameboardError("invalid-name", `${name} is reserved for the project's shared files, so a page cannot take it.`, {
|
|
25203
|
-
kind,
|
|
25204
|
-
name
|
|
25205
|
-
});
|
|
25206
|
-
}
|
|
25207
|
-
/** The existing name equal to `name`, else one equal in another case. */
|
|
25208
|
-
function matchName(names, name) {
|
|
25209
|
-
return names.find((n) => n === name) ?? names.find((n) => namesCollide(n, name));
|
|
25210
|
-
}
|
|
25211
|
-
async function findPage(projectDir, name, allowMissing = false) {
|
|
25212
|
-
const pages = await listPageFolders(projectDir);
|
|
25213
|
-
const found = matchName(pages, name);
|
|
25214
|
-
if (!found && !allowMissing) throw new FrameboardError("page-not-found", `No page ${name} in ${projectDir}.`, {
|
|
25215
|
-
page: name,
|
|
25216
|
-
pages
|
|
25217
|
-
});
|
|
25218
|
-
if (!found) assertValidName("page", name);
|
|
25219
|
-
const resolved = found ?? name;
|
|
25220
|
-
return {
|
|
25221
|
-
name: resolved,
|
|
25222
|
-
path: join(projectDir, resolved)
|
|
25223
|
-
};
|
|
25224
|
-
}
|
|
25225
|
-
function splitRef(ref, max) {
|
|
25226
|
-
const parts = ref.split("/");
|
|
25227
|
-
if (parts.length > max || parts.some((part) => part === "")) throw new FrameboardError("usage", `${ref} is not a ${max === 2 ? "page" : "frame"} ref.`, { ref });
|
|
25228
|
-
return parts;
|
|
25229
|
-
}
|
|
25230
|
-
function agreeingProject(ref, fromRef, { project }) {
|
|
25231
|
-
if (fromRef !== void 0 && project !== void 0 && !namesCollide(fromRef, project)) throw new FrameboardError("usage", `${ref} names project ${fromRef} but --project names ${project}.`, {
|
|
25232
|
-
ref,
|
|
25233
|
-
project
|
|
25234
|
-
});
|
|
25235
|
-
return fromRef ?? project;
|
|
25236
|
-
}
|
|
25237
|
-
async function framePathParts(root, ref, cwd) {
|
|
25238
|
-
const path = resolve$1(cwd, ref);
|
|
25239
|
-
let folder = dirname(path);
|
|
25240
|
-
try {
|
|
25241
|
-
folder = await realpath(folder);
|
|
25242
|
-
} catch (error) {
|
|
25243
|
-
if (!isCode(error, "ENOENT")) throw error;
|
|
25244
|
-
}
|
|
25245
|
-
const inside = relative(root, folder);
|
|
25246
|
-
const parts = inside.split(sep);
|
|
25247
|
-
if (inside === "" || inside.startsWith("..") || isAbsolute(inside) || parts.length !== 2) throw new FrameboardError("usage", `${path} does not sit in a page of the board at ${root}.`, {
|
|
25248
|
-
path,
|
|
25249
|
-
root
|
|
25250
|
-
});
|
|
25251
|
-
const file = path.slice(dirname(path).length + 1);
|
|
25252
|
-
return [...parts, file.slice(0, -5)];
|
|
25253
|
-
}
|
|
25254
25473
|
// src/server/board/frames.ts
|
|
25255
25474
|
/**
|
|
25256
25475
|
* Places a frame, writing a skeleton only when no file exists. Every axis no
|
|
@@ -25297,7 +25516,7 @@ async function addFrame(root, ref, options) {
|
|
|
25297
25516
|
held: []
|
|
25298
25517
|
});
|
|
25299
25518
|
if (!exists) {
|
|
25300
|
-
await writeFile(frame.path, skeleton(frame.name, options.body), { flag: "wx" });
|
|
25519
|
+
await writeFile(frame.path, skeleton(frame.name, options.body, options.head), { flag: "wx" });
|
|
25301
25520
|
await journal?.created(frame.path);
|
|
25302
25521
|
}
|
|
25303
25522
|
layout.names = names;
|
|
@@ -25744,18 +25963,24 @@ async function setFrameFlag(root, ref, flag, { on, ...options }) {
|
|
|
25744
25963
|
* it, never writing the frame's file. Naming a foldable shows it and, as a
|
|
25745
25964
|
* pose does, sets the box to that pose's screen, fixed on both axes.
|
|
25746
25965
|
*/
|
|
25747
|
-
async function setFrameDevice(root, ref, show, { foldable: name, pose: fold, ...options }) {
|
|
25966
|
+
async function setFrameDevice(root, ref, show, { foldable: name, pose: fold, island: pick, ...options }) {
|
|
25748
25967
|
return updatePlacement(root, ref, options, (placement, frameRef) => {
|
|
25749
|
-
const { showDevice: held, device: _device, foldable: named, pose: stored, keptWidths, ...rest } = placement;
|
|
25968
|
+
const { showDevice: held, device: _device, foldable: named, pose: stored, keptWidths, island: picked, ...rest } = placement;
|
|
25750
25969
|
const foldable = name ?? named === true;
|
|
25751
25970
|
if (fold && !foldable) throw new FrameboardError("usage", `${frameRef} is not a foldable, so it has no pose. Name it with --foldable first.`, {
|
|
25752
25971
|
ref: frameRef,
|
|
25753
25972
|
pose: fold
|
|
25754
25973
|
});
|
|
25974
|
+
if (pick && (foldable || deviceForWidth(placement.box.width) !== "phone")) throw new FrameboardError("usage", `${frameRef} draws no phone, so it has no island. A frame 320 to 479 px wide that names no foldable draws one.`, {
|
|
25975
|
+
ref: frameRef,
|
|
25976
|
+
island: pick
|
|
25977
|
+
});
|
|
25978
|
+
const island = pick ?? islandOf(picked);
|
|
25755
25979
|
const shown = show ?? (name === true || held === true);
|
|
25756
25980
|
const base = {
|
|
25757
25981
|
...rest,
|
|
25758
|
-
...shown ? { showDevice: true } : {}
|
|
25982
|
+
...shown ? { showDevice: true } : {},
|
|
25983
|
+
...island === "wide" ? { island } : {}
|
|
25759
25984
|
};
|
|
25760
25985
|
if (!foldable) {
|
|
25761
25986
|
const widths = (keptWidths ?? rest.widths).filter((linked) => linked.width !== placement.box.width);
|
|
@@ -25806,6 +26031,25 @@ async function setFrameTransition(root, ref, transition, options) {
|
|
|
25806
26031
|
});
|
|
25807
26032
|
}
|
|
25808
26033
|
/**
|
|
26034
|
+
* Sets the project kit a frame draws with, or clears it with null, writing
|
|
26035
|
+
* only its layout entry. Refuses `kit-not-found` for a name the frame's
|
|
26036
|
+
* project holds no kit under, and stores the folder's own spelling.
|
|
26037
|
+
*/
|
|
26038
|
+
async function setFrameKit(root, ref, kit, options) {
|
|
26039
|
+
const frame = await resolveFrameRef(root, ref, options);
|
|
26040
|
+
const held = kit === null ? null : await heldKit({
|
|
26041
|
+
name: frame.project,
|
|
26042
|
+
path: join(root, frame.project)
|
|
26043
|
+
}, kit);
|
|
26044
|
+
return updatePlacement(root, ref, options, (placement) => {
|
|
26045
|
+
const { kit: _held, ...rest } = placement;
|
|
26046
|
+
return held ? {
|
|
26047
|
+
...rest,
|
|
26048
|
+
kit: held
|
|
26049
|
+
} : rest;
|
|
26050
|
+
});
|
|
26051
|
+
}
|
|
26052
|
+
/**
|
|
25809
26053
|
* Sets a frame's speaker note on its layout entry, null or blank clearing it.
|
|
25810
26054
|
* Refuses `usage` past `SPEAKER_NOTES_MAX` rather than cutting, and
|
|
25811
26055
|
* `stale-layout` once `expected`, the note the edit began from, is gone.
|
|
@@ -25875,14 +26119,15 @@ function sizeOf({ size, width, height }) {
|
|
|
25875
26119
|
* The skeleton states `head` with `body`, so the browser builds neither and
|
|
25876
26120
|
* every address holds, and a body column has no margin, so media fits exactly.
|
|
25877
26121
|
*/
|
|
25878
|
-
function skeleton(name, body) {
|
|
26122
|
+
function skeleton(name, body, head) {
|
|
26123
|
+
const content = body === void 0 ? "<body></body>" : `<body style="margin: 0; display: flex; flex-direction: column; align-items: flex-start">${body}</body>`;
|
|
25879
26124
|
return `<!doctype html>
|
|
25880
26125
|
<html lang="en">
|
|
25881
26126
|
<head>
|
|
25882
26127
|
<meta charset="utf-8" />
|
|
25883
|
-
<title>${name}</title
|
|
26128
|
+
<title>${name}</title>${head === void 0 ? "" : `\n ${head}`}
|
|
25884
26129
|
</head>
|
|
25885
|
-
${
|
|
26130
|
+
${content}
|
|
25886
26131
|
</html>
|
|
25887
26132
|
`;
|
|
25888
26133
|
}
|
|
@@ -25918,7 +26163,7 @@ var PageLayout = class {
|
|
|
25918
26163
|
* Writes the fixed keys after the entry's own, so unknown keys survive, and a
|
|
25919
26164
|
* flag only once on or already held, so an older entry gains no key.
|
|
25920
26165
|
*/
|
|
25921
|
-
set(name, { box, order, hidden, locked, scroll, widths, showDevice, foldable, pose, keptWidths, transition, speakerNotes, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
|
|
26166
|
+
set(name, { box, order, hidden, locked, scroll, widths, showDevice, foldable, pose, keptWidths, island, transition, speakerNotes, kit, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
|
|
25922
26167
|
const hugWidth = hugsWidth && !scroll;
|
|
25923
26168
|
const hugHeight = hugsHeight && !scroll;
|
|
25924
26169
|
const held = this.file.frames[name];
|
|
@@ -25942,8 +26187,10 @@ var PageLayout = class {
|
|
|
25942
26187
|
...showDevice ? { showDevice } : {},
|
|
25943
26188
|
...foldable ? { foldable } : {},
|
|
25944
26189
|
...foldable && pose && (held?.foldable !== true || poseOf(held.pose) !== pose) ? { pose } : {},
|
|
26190
|
+
...island ? { island } : {},
|
|
25945
26191
|
...transition ? { transition: { ...transition } } : {},
|
|
25946
|
-
...speakerNotes ? { speakerNotes } : {}
|
|
26192
|
+
...speakerNotes ? { speakerNotes } : {},
|
|
26193
|
+
...kit ? { kit } : {}
|
|
25947
26194
|
};
|
|
25948
26195
|
if (listed.length === 0 && widthsOf(held?.widths).length > 0) delete entry.widths;
|
|
25949
26196
|
if (!foldable && held?.foldable === true) {
|
|
@@ -25951,9 +26198,11 @@ var PageLayout = class {
|
|
|
25951
26198
|
delete entry.pose;
|
|
25952
26199
|
}
|
|
25953
26200
|
if (!showDevice && held?.showDevice === true) delete entry.showDevice;
|
|
26201
|
+
if (!island && islandOf(held?.island) === "wide") delete entry.island;
|
|
25954
26202
|
if (typeof held?.device === "string") delete entry.device;
|
|
25955
26203
|
if (!transition && storedTransitionOf(held?.transition)) delete entry.transition;
|
|
25956
26204
|
if (!speakerNotes && speakerNotesOf(held?.speakerNotes)) delete entry.speakerNotes;
|
|
26205
|
+
if (!kit && kitOf(held?.kit)) delete entry.kit;
|
|
25957
26206
|
this.file.frames[name] = entry;
|
|
25958
26207
|
this.changed = true;
|
|
25959
26208
|
}
|
|
@@ -30729,18 +30978,20 @@ const ASSET_KINDS = [
|
|
|
30729
30978
|
"svg",
|
|
30730
30979
|
"video",
|
|
30731
30980
|
"audio",
|
|
30981
|
+
"model",
|
|
30732
30982
|
"font",
|
|
30733
30983
|
"stylesheet",
|
|
30734
30984
|
"script",
|
|
30735
30985
|
"other"
|
|
30736
30986
|
];
|
|
30737
|
-
/** The kinds a frame shows as an `<img>`, a `<video>`,
|
|
30987
|
+
/** The kinds a frame shows as an `<img>`, a `<video>`, an `<audio>`, or a `<model-viewer>`, which the board places by hand. */
|
|
30738
30988
|
const PLACEABLE_KINDS = [
|
|
30739
30989
|
"image",
|
|
30740
30990
|
"gif",
|
|
30741
30991
|
"svg",
|
|
30742
30992
|
"video",
|
|
30743
|
-
"audio"
|
|
30993
|
+
"audio",
|
|
30994
|
+
"model"
|
|
30744
30995
|
];
|
|
30745
30996
|
function isPlaceableKind(kind) {
|
|
30746
30997
|
return PLACEABLE_KINDS.includes(kind);
|
|
@@ -30762,6 +31013,8 @@ const ACCEPTED = {
|
|
|
30762
31013
|
wav: "audio",
|
|
30763
31014
|
ogg: "audio",
|
|
30764
31015
|
m4a: "audio",
|
|
31016
|
+
glb: "model",
|
|
31017
|
+
gltf: "model",
|
|
30765
31018
|
woff: "font",
|
|
30766
31019
|
woff2: "font",
|
|
30767
31020
|
ttf: "font",
|
|
@@ -30770,6 +31023,17 @@ const ACCEPTED = {
|
|
|
30770
31023
|
js: "script",
|
|
30771
31024
|
mjs: "script"
|
|
30772
31025
|
};
|
|
31026
|
+
/** Model formats no frame shows, which a drop refuses with the way to a GLB rather than as an unknown file. */
|
|
31027
|
+
const FOREIGN_MODELS = [
|
|
31028
|
+
"fbx",
|
|
31029
|
+
"obj",
|
|
31030
|
+
"blend",
|
|
31031
|
+
"usd",
|
|
31032
|
+
"stl"
|
|
31033
|
+
];
|
|
31034
|
+
function isForeignModel(name) {
|
|
31035
|
+
return FOREIGN_MODELS.includes(extensionOf(name));
|
|
31036
|
+
}
|
|
30773
31037
|
/** The lowercase text after the last dot, empty when the name has none. */
|
|
30774
31038
|
function extensionOf(name) {
|
|
30775
31039
|
const dot = name.lastIndexOf(".");
|
|
@@ -30983,7 +31247,7 @@ async function resolveAsset(projectDir, path) {
|
|
|
30983
31247
|
if (!isPlaceableKind(kind)) return {
|
|
30984
31248
|
ok: false,
|
|
30985
31249
|
code: "asset-not-placeable",
|
|
30986
|
-
message: `assets/${path} is not an image, GIF, SVG, video, or
|
|
31250
|
+
message: `assets/${path} is not an image, GIF, SVG, video, audio, or 3D model, so a frame cannot show it`
|
|
30987
31251
|
};
|
|
30988
31252
|
return {
|
|
30989
31253
|
ok: true,
|
|
@@ -31004,11 +31268,12 @@ async function addAssets(projectDir, uploads) {
|
|
|
31004
31268
|
refused: []
|
|
31005
31269
|
};
|
|
31006
31270
|
for (const upload of uploads) {
|
|
31007
|
-
|
|
31271
|
+
const refusal = uploadRefusal(upload);
|
|
31272
|
+
if (refusal !== null) {
|
|
31008
31273
|
result.refused.push({
|
|
31009
31274
|
name: upload.name,
|
|
31010
31275
|
code: "asset-type-refused",
|
|
31011
|
-
message:
|
|
31276
|
+
message: refusal
|
|
31012
31277
|
});
|
|
31013
31278
|
continue;
|
|
31014
31279
|
}
|
|
@@ -31021,6 +31286,37 @@ async function addAssets(projectDir, uploads) {
|
|
|
31021
31286
|
}
|
|
31022
31287
|
return result;
|
|
31023
31288
|
}
|
|
31289
|
+
/** Why a drop refuses a file, or null for one it keeps. */
|
|
31290
|
+
function uploadRefusal({ name, bytes }) {
|
|
31291
|
+
if (isForeignModel(name)) return `${name} is a 3D model a frame cannot show. Open it in Blender, export it through File, Export, glTF 2.0 as a glTF Binary (.glb), and drop that file.`;
|
|
31292
|
+
if (!isAcceptedUpload(name)) return `${name} is not an image, GIF, SVG, video, audio, 3D model, font, stylesheet, or script.`;
|
|
31293
|
+
return extensionOf(name) === "gltf" ? gltfRefusal(name, bytes) : null;
|
|
31294
|
+
}
|
|
31295
|
+
/**
|
|
31296
|
+
* Why a `.gltf` cannot land alone, or null for one carrying its buffers and
|
|
31297
|
+
* images inside itself. A drop keeps one file per name, so a `.bin` or a
|
|
31298
|
+
* texture the model loads beside it would be left behind.
|
|
31299
|
+
*/
|
|
31300
|
+
function gltfRefusal(name, bytes) {
|
|
31301
|
+
let parsed;
|
|
31302
|
+
try {
|
|
31303
|
+
parsed = JSON.parse(new TextDecoder().decode(bytes));
|
|
31304
|
+
} catch {
|
|
31305
|
+
return `${name} is not a glTF file a model reads. Export it again as a glTF Binary (.glb).`;
|
|
31306
|
+
}
|
|
31307
|
+
const [first] = [...linkedUris(parsed, "buffers"), ...linkedUris(parsed, "images")];
|
|
31308
|
+
return first === void 0 ? null : `${name} loads ${first} from beside it, which a drop cannot keep with it. Export it as one glTF Binary (.glb) instead.`;
|
|
31309
|
+
}
|
|
31310
|
+
/** The `uri` of each entry under `key` that names a file rather than carrying its bytes. */
|
|
31311
|
+
function linkedUris(gltf, key) {
|
|
31312
|
+
if (typeof gltf !== "object" || gltf === null) return [];
|
|
31313
|
+
const entries = gltf[key];
|
|
31314
|
+
if (!Array.isArray(entries)) return [];
|
|
31315
|
+
return entries.flatMap((entry) => {
|
|
31316
|
+
const uri = typeof entry === "object" && entry !== null ? entry.uri : void 0;
|
|
31317
|
+
return typeof uri === "string" && !uri.startsWith("data:") ? [uri] : [];
|
|
31318
|
+
});
|
|
31319
|
+
}
|
|
31024
31320
|
async function writeFree(folder, { name, bytes }) {
|
|
31025
31321
|
const { stem, extension } = splitName(name);
|
|
31026
31322
|
const temp = join(folder, `${randomBytes(6).toString("hex")}${TEMP_SUFFIX}`);
|
|
@@ -31389,6 +31685,85 @@ function clipboardRoutes(root, access, render, clipboard) {
|
|
|
31389
31685
|
});
|
|
31390
31686
|
return app;
|
|
31391
31687
|
}
|
|
31688
|
+
// src/server/checks/tokens.ts
|
|
31689
|
+
/**
|
|
31690
|
+
* Where a project's token sheets sit, the address file read by plain
|
|
31691
|
+
* `JSON.parse`, since the write hook cannot afford its schema.
|
|
31692
|
+
*/
|
|
31693
|
+
function tokenSheetPaths(root, project, tokens) {
|
|
31694
|
+
const own = join(root, project, TOKEN_FILE);
|
|
31695
|
+
return {
|
|
31696
|
+
board: boardSheetPath(root, tokens),
|
|
31697
|
+
project: existsSync(own) ? own : null
|
|
31698
|
+
};
|
|
31699
|
+
}
|
|
31700
|
+
/** The board's token sheet alone, resolved the way `tokenSheetPaths` resolves it. */
|
|
31701
|
+
function boardSheetPath(root, tokens = recordedTokens(root)) {
|
|
31702
|
+
const board = tokens ?? join(root, "tokens.css");
|
|
31703
|
+
return existsSync(board) ? board : null;
|
|
31704
|
+
}
|
|
31705
|
+
/** The `--tokens` path the board's running server recorded, or null. */
|
|
31706
|
+
function recordedTokens(root) {
|
|
31707
|
+
try {
|
|
31708
|
+
const parsed = JSON.parse(readFileSync(join(root, RUN_FOLDER, ADDRESS_FILE), "utf8"));
|
|
31709
|
+
const tokens = typeof parsed === "object" && parsed !== null && "tokens" in parsed ? parsed.tokens : void 0;
|
|
31710
|
+
return typeof tokens === "string" ? tokens : null;
|
|
31711
|
+
} catch {
|
|
31712
|
+
return null;
|
|
31713
|
+
}
|
|
31714
|
+
}
|
|
31715
|
+
/**
|
|
31716
|
+
* The kit a frame's layout entry names, null for none or a layout that does
|
|
31717
|
+
* not read, parsed plainly as the address file is.
|
|
31718
|
+
*/
|
|
31719
|
+
function frameKit({ root, project, page, name }) {
|
|
31720
|
+
try {
|
|
31721
|
+
return kitOf(keyOf$1(keyOf$1(keyOf$1(JSON.parse(readFileSync(join(root, project, page, LAYOUT_FILE), "utf8")), "frames"), name), "kit"));
|
|
31722
|
+
} catch {
|
|
31723
|
+
return null;
|
|
31724
|
+
}
|
|
31725
|
+
}
|
|
31726
|
+
/** An object's own key, undefined for a value holding none. */
|
|
31727
|
+
function keyOf$1(value, key) {
|
|
31728
|
+
return typeof value === "object" && value !== null && Object.hasOwn(value, key) ? value[key] : void 0;
|
|
31729
|
+
}
|
|
31730
|
+
/**
|
|
31731
|
+
* The kit sheets a frame draws with, as paths under its project in cascade
|
|
31732
|
+
* order: a project-wide kit's where `assets/kit/` holds `kit.json`, then the
|
|
31733
|
+
* tokens and stylesheet of the kit the frame names, each that exists.
|
|
31734
|
+
*/
|
|
31735
|
+
function kitSheetFiles(root, project, kit) {
|
|
31736
|
+
const wide = [ASSETS_FOLDER, "kit"];
|
|
31737
|
+
const named = kitOf(kit);
|
|
31738
|
+
return [...existsSync(join(root, project, ...wide, "kit.json")) ? [[...wide, KIT_SHEET]] : [], ...named ? [TOKEN_FILE, KIT_SHEET].map((file) => [
|
|
31739
|
+
ASSETS_FOLDER,
|
|
31740
|
+
PROJECT_KITS,
|
|
31741
|
+
named,
|
|
31742
|
+
file
|
|
31743
|
+
]) : []].filter((file) => existsSync(join(root, project, ...file))).map((file) => file.join("/"));
|
|
31744
|
+
}
|
|
31745
|
+
/**
|
|
31746
|
+
* The sheets the frame route imports ahead of a frame, being the board's
|
|
31747
|
+
* tokens, the project's, then its kit sheets, which the cascade reads ahead
|
|
31748
|
+
* of the frame's own. `kit` is the kit the frame names, null for a plain one.
|
|
31749
|
+
*/
|
|
31750
|
+
function tokenSheets(root, project, tokens, kit = null) {
|
|
31751
|
+
return readSheets(root, project, tokenSheetPaths(root, project, tokens), kit);
|
|
31752
|
+
}
|
|
31753
|
+
/** `tokenSheets` for a caller already holding the project's sheet paths. */
|
|
31754
|
+
function readSheets(root, project, paths, kit) {
|
|
31755
|
+
const kitSheets = kitSheetFiles(root, project, kit).map((file) => join(root, project, file));
|
|
31756
|
+
return [
|
|
31757
|
+
paths.board,
|
|
31758
|
+
paths.project,
|
|
31759
|
+
...kitSheets
|
|
31760
|
+
].filter((path) => path !== null).map((path) => ({
|
|
31761
|
+
css: readFileSync(path, "utf8"),
|
|
31762
|
+
origin: "token",
|
|
31763
|
+
path,
|
|
31764
|
+
offset: 0
|
|
31765
|
+
}));
|
|
31766
|
+
}
|
|
31392
31767
|
// src/server/edit/start-tag.ts
|
|
31393
31768
|
function isSpace(char) {
|
|
31394
31769
|
return char === " " || char === " " || char === "\n" || char === "\f" || char === "\r";
|
|
@@ -37576,6 +37951,11 @@ function isText(node) {
|
|
|
37576
37951
|
function attribute$1(element, name) {
|
|
37577
37952
|
return element.attrs.find((attr) => attr.name === name)?.value;
|
|
37578
37953
|
}
|
|
37954
|
+
// src/shared/model-viewer.ts
|
|
37955
|
+
/** The custom element a frame shows a 3D model through. */
|
|
37956
|
+
const VIEWER_TAG = "model-viewer";
|
|
37957
|
+
/** The viewer's script as a project's `assets/` holds it, copied in with the first model placed. */
|
|
37958
|
+
const VIEWER_FILE = "model-viewer.min.js";
|
|
37579
37959
|
// src/shared/faces.ts
|
|
37580
37960
|
const FACES = [
|
|
37581
37961
|
{
|
|
@@ -37712,6 +38092,11 @@ function starterSheet({ accent, font }) {
|
|
|
37712
38092
|
`;
|
|
37713
38093
|
}
|
|
37714
38094
|
// src/server/edit/insert.ts
|
|
38095
|
+
/** The tag a frame shows an asset of `kind` through. */
|
|
38096
|
+
function assetTag(kind) {
|
|
38097
|
+
if (kind === "video" || kind === "audio") return kind;
|
|
38098
|
+
return kind === "model" ? VIEWER_TAG : "img";
|
|
38099
|
+
}
|
|
37715
38100
|
const SHAPE_SIZE = 100;
|
|
37716
38101
|
const TEXT_FONT_TOKEN = "--font-text";
|
|
37717
38102
|
const PAINT_VALUE = /^(?:var\(--[\w-]+\)|#[0-9a-f]{6})$/i;
|
|
@@ -37737,6 +38122,7 @@ const CLOSED = /* @__PURE__ */ new Set([
|
|
|
37737
38122
|
"title",
|
|
37738
38123
|
"noscript",
|
|
37739
38124
|
"iframe",
|
|
38125
|
+
VIEWER_TAG,
|
|
37740
38126
|
"html",
|
|
37741
38127
|
"head"
|
|
37742
38128
|
]);
|
|
@@ -37768,6 +38154,7 @@ function elementMarkup(element, paint, font) {
|
|
|
37768
38154
|
if (!Number.isInteger(element.width)) throw new Error(`Unexpected audio width ${element.width}`);
|
|
37769
38155
|
return `<audio data-name="${name}" src="${src}" controls style="width: ${element.width}px"></audio>`;
|
|
37770
38156
|
}
|
|
38157
|
+
if (element.tag === "model-viewer") return `<model-viewer data-name="${name}" src="${src}" alt="" style="${size(element)}"></model-viewer>`;
|
|
37771
38158
|
const style = `${size(element)}; object-fit: cover`;
|
|
37772
38159
|
return element.tag === "video" ? `<video data-name="${name}" src="${src}" controls autoplay muted loop playsinline style="${style}"></video>` : `<img data-name="${name}" src="${src}" alt="" style="${style}">`;
|
|
37773
38160
|
}
|
|
@@ -37784,6 +38171,66 @@ function assetLink(path) {
|
|
|
37784
38171
|
function attribute(text) {
|
|
37785
38172
|
return text.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<");
|
|
37786
38173
|
}
|
|
38174
|
+
/** The tag a frame loads the viewer by, from its project's `assets/`. */
|
|
38175
|
+
const VIEWER_SCRIPT = `<script type="module" src="${assetLink(VIEWER_FILE)}"><\/script>`;
|
|
38176
|
+
/**
|
|
38177
|
+
* Writes the viewer's script at the end of the frame's head unless a script
|
|
38178
|
+
* there already loads one, an agent's own copy included. A frame stating no
|
|
38179
|
+
* head takes it ahead of its content, where the browser builds the head.
|
|
38180
|
+
*/
|
|
38181
|
+
function ensureViewerScript(source) {
|
|
38182
|
+
const before = parseFrame(source);
|
|
38183
|
+
if (before.elements.some(loadsViewer)) return {
|
|
38184
|
+
ok: true,
|
|
38185
|
+
html: source,
|
|
38186
|
+
index: null
|
|
38187
|
+
};
|
|
38188
|
+
const { offset, lead } = headEnd(source, before);
|
|
38189
|
+
const written = source.slice(0, offset) + lead + VIEWER_SCRIPT + source.slice(offset);
|
|
38190
|
+
const after = parseFrame(written);
|
|
38191
|
+
const index = after.elements.findIndex((element) => element.sourceCodeLocation?.startOffset === offset + lead.length);
|
|
38192
|
+
const added = after.elements[index];
|
|
38193
|
+
const parent = added?.parentNode;
|
|
38194
|
+
if (!added || !parent || !hasTag(parent) || parent.tagName !== "head" || after.elements.length !== before.elements.length + 1 || !addsOnly(before, after, added, lead)) return refuse$2("verify-failed", "the viewer's script would change more than the frame's head, so nothing was written");
|
|
38195
|
+
return {
|
|
38196
|
+
ok: true,
|
|
38197
|
+
html: written,
|
|
38198
|
+
index
|
|
38199
|
+
};
|
|
38200
|
+
}
|
|
38201
|
+
/** Whether an element is a script loading a model viewer build, by its file name. */
|
|
38202
|
+
function loadsViewer(element) {
|
|
38203
|
+
if (element.tagName !== "script") return false;
|
|
38204
|
+
return ((element.attrs.find((attr) => attr.name === "src")?.value ?? "").split(/[?#]/)[0]?.split("/").at(-1) ?? "").includes(VIEWER_TAG);
|
|
38205
|
+
}
|
|
38206
|
+
/**
|
|
38207
|
+
* Where a head's last child ends, with the line break and indent that child
|
|
38208
|
+
* sits on, so the script lands on a line of its own. An unstated head takes
|
|
38209
|
+
* the offset its content would start at.
|
|
38210
|
+
*/
|
|
38211
|
+
function headEnd(source, tree) {
|
|
38212
|
+
const head = tree.elements.find((element) => element.tagName === "head");
|
|
38213
|
+
const at = head?.sourceCodeLocation;
|
|
38214
|
+
const last = head?.childNodes.findLast(hasTag)?.sourceCodeLocation;
|
|
38215
|
+
if (last) {
|
|
38216
|
+
const indent = /\n[ \t]*$/.exec(source.slice(0, last.startOffset));
|
|
38217
|
+
return {
|
|
38218
|
+
offset: last.endOffset,
|
|
38219
|
+
lead: indent?.[0] ?? ""
|
|
38220
|
+
};
|
|
38221
|
+
}
|
|
38222
|
+
const stated = at?.startTag?.endOffset;
|
|
38223
|
+
if (stated !== void 0) return {
|
|
38224
|
+
offset: stated,
|
|
38225
|
+
lead: ""
|
|
38226
|
+
};
|
|
38227
|
+
const html = tree.elements.find((element) => element.tagName === "html");
|
|
38228
|
+
const doctype = tree.document.childNodes.find((node) => node.nodeName === "#documentType");
|
|
38229
|
+
return {
|
|
38230
|
+
offset: html?.sourceCodeLocation?.startTag?.endOffset ?? doctype?.sourceCodeLocation?.endOffset ?? 0,
|
|
38231
|
+
lead: ""
|
|
38232
|
+
};
|
|
38233
|
+
}
|
|
37787
38234
|
function startTag(source, element) {
|
|
37788
38235
|
return spanText(source, element, "start-tag");
|
|
37789
38236
|
}
|
|
@@ -37858,10 +38305,18 @@ function insertElement(source, placement, markup, lead = "") {
|
|
|
37858
38305
|
function descendants(element) {
|
|
37859
38306
|
return children$1(element).reduce((count, child) => count + 1 + descendants(child), 0);
|
|
37860
38307
|
}
|
|
37861
|
-
/**
|
|
37862
|
-
|
|
38308
|
+
/**
|
|
38309
|
+
* Whether `after` is `before` with `added` alone added, compared once it is
|
|
38310
|
+
* taken out with the `lead` white space written ahead of it.
|
|
38311
|
+
*/
|
|
38312
|
+
function addsOnly(before, after, added, lead = "") {
|
|
37863
38313
|
const parent = added.parentNode;
|
|
37864
|
-
|
|
38314
|
+
const previous = parent.childNodes[parent.childNodes.indexOf(added) - 1];
|
|
38315
|
+
if (lead !== "") {
|
|
38316
|
+
if (!previous || !("value" in previous) || !previous.value.endsWith(lead)) return false;
|
|
38317
|
+
previous.value = previous.value.slice(0, -lead.length);
|
|
38318
|
+
}
|
|
38319
|
+
parent.childNodes = parent.childNodes.filter((node) => node !== added && !("value" in node && node.value === ""));
|
|
37865
38320
|
return serialize$1(before.document) === serialize$1(after.document);
|
|
37866
38321
|
}
|
|
37867
38322
|
/**
|
|
@@ -38714,8 +39169,8 @@ function editFrameFile(path, address, change, sourceAt) {
|
|
|
38714
39169
|
}
|
|
38715
39170
|
/**
|
|
38716
39171
|
* Edits several elements as one write, all or none. One element named twice is
|
|
38717
|
-
* refused, since one undo could not put both spans back, except a text
|
|
38718
|
-
* style
|
|
39172
|
+
* refused, since one undo could not put both spans back, except a text beside
|
|
39173
|
+
* a style or several attributes, which answer one span over the element.
|
|
38719
39174
|
*/
|
|
38720
39175
|
function editFrameFileAll(path, hash, edits, sourceAt) {
|
|
38721
39176
|
const read = readSource(path);
|
|
@@ -38779,24 +39234,46 @@ function mergedTwice(source, html, indexes, spans) {
|
|
|
38779
39234
|
});
|
|
38780
39235
|
}
|
|
38781
39236
|
/**
|
|
38782
|
-
* Whether each element a batch names is named once,
|
|
38783
|
-
*
|
|
39237
|
+
* Whether each element a batch names is named once, twice as one `text`
|
|
39238
|
+
* change and one `style` or `styles` change, or by `attribute` changes that
|
|
39239
|
+
* each name another attribute.
|
|
38784
39240
|
*/
|
|
38785
39241
|
function namedOnceEach(indexes, edits) {
|
|
38786
|
-
const
|
|
38787
|
-
for (const [at, index] of indexes.entries())
|
|
38788
|
-
|
|
39242
|
+
const changes = /* @__PURE__ */ new Map();
|
|
39243
|
+
for (const [at, index] of indexes.entries()) {
|
|
39244
|
+
const change = edits[at]?.change;
|
|
39245
|
+
if (change) changes.set(index, [...changes.get(index) ?? [], change]);
|
|
39246
|
+
}
|
|
39247
|
+
return [...changes.values()].every((named) => named.length === 1 || textAndStyle(named) || separateAttributes(named));
|
|
39248
|
+
}
|
|
39249
|
+
function textAndStyle(named) {
|
|
39250
|
+
return named.length === 2 && named.filter(({ kind }) => kind === "text").length === 1 && named.some(({ kind }) => kind === "style" || kind === "styles");
|
|
39251
|
+
}
|
|
39252
|
+
function separateAttributes(named) {
|
|
39253
|
+
const names = named.flatMap((change) => change.kind === "attribute" ? [change.name.toLowerCase()] : []);
|
|
39254
|
+
return names.length === named.length && new Set(names).size === names.length;
|
|
38789
39255
|
}
|
|
38790
39256
|
/**
|
|
38791
|
-
* Writes one new element
|
|
38792
|
-
*
|
|
38793
|
-
*
|
|
39257
|
+
* Writes one new element, refusing a moved hash with no search, since the
|
|
39258
|
+
* gap's indices name nothing once the file moved, so a retry lands at most
|
|
39259
|
+
* once. With `viewer`, it adds the viewer's script, which an undo leaves.
|
|
38794
39260
|
*/
|
|
38795
|
-
function insertFrameFile(path, hash, placement, markup, place) {
|
|
39261
|
+
function insertFrameFile(path, hash, placement, markup, place, viewer = false) {
|
|
38796
39262
|
const read = readSource(path);
|
|
38797
39263
|
if (!read.ok) return read;
|
|
38798
39264
|
if (read.hash !== hash) return stale$1(path);
|
|
38799
|
-
const
|
|
39265
|
+
const scripted = viewer ? ensureViewerScript(read.source) : {
|
|
39266
|
+
ok: true,
|
|
39267
|
+
html: read.source,
|
|
39268
|
+
index: null
|
|
39269
|
+
};
|
|
39270
|
+
if (!scripted.ok) return scripted;
|
|
39271
|
+
const script = scripted.index;
|
|
39272
|
+
const pastScript = (index) => script !== null && index >= script ? index + 1 : index;
|
|
39273
|
+
const inserted = insertElement(scripted.html, {
|
|
39274
|
+
parent: pastScript(placement.parent),
|
|
39275
|
+
before: placement.before === null ? null : pastScript(placement.before)
|
|
39276
|
+
}, markup);
|
|
38800
39277
|
if (!inserted.ok) return inserted;
|
|
38801
39278
|
const placed = place?.(inserted.html, inserted.index);
|
|
38802
39279
|
if (placed && !placed.ok) return placed;
|
|
@@ -38804,6 +39281,7 @@ function insertFrameFile(path, hash, placement, markup, place) {
|
|
|
38804
39281
|
const element = parseFrame(html).elements[inserted.index];
|
|
38805
39282
|
if (!element) return stale$1(path);
|
|
38806
39283
|
if (!replaceFile(path, hash, html)) return stale$1(path);
|
|
39284
|
+
const pastElement = shiftedPast(inserted.index, subtreeSize(html, inserted.index));
|
|
38807
39285
|
return {
|
|
38808
39286
|
ok: true,
|
|
38809
39287
|
hash: contentHash(html),
|
|
@@ -38813,7 +39291,7 @@ function insertFrameFile(path, hash, placement, markup, place) {
|
|
|
38813
39291
|
markup: spanText(html, element, "element")
|
|
38814
39292
|
},
|
|
38815
39293
|
parent: placed && placed.spans.length > 1 ? placed.spans[0] ?? null : null,
|
|
38816
|
-
remap:
|
|
39294
|
+
remap: (index) => pastElement(pastScript(index))
|
|
38817
39295
|
};
|
|
38818
39296
|
}
|
|
38819
39297
|
/**
|
|
@@ -39040,6 +39518,33 @@ function replaceFile(path, hash, html) {
|
|
|
39040
39518
|
renameSync(temp, path);
|
|
39041
39519
|
return true;
|
|
39042
39520
|
}
|
|
39521
|
+
// src/server/models/viewer.ts
|
|
39522
|
+
/**
|
|
39523
|
+
* The viewer build a project's copy is taken from. A built run reads the
|
|
39524
|
+
* `viewer` folder the build put beside the bundle, and a source run reads the
|
|
39525
|
+
* pinned package.
|
|
39526
|
+
*/
|
|
39527
|
+
function shippedViewerPath(moduleUrl = import.meta.url) {
|
|
39528
|
+
if (!moduleUrl.endsWith(".ts")) return fileURLToPath(new URL(`./viewer/${VIEWER_FILE}`, moduleUrl));
|
|
39529
|
+
const manifest = createRequire(moduleUrl).resolve("@google/model-viewer/package.json");
|
|
39530
|
+
return join(dirname(manifest), "dist", VIEWER_FILE);
|
|
39531
|
+
}
|
|
39532
|
+
/**
|
|
39533
|
+
* Copies the viewer script into a project's `assets/` unless a file already
|
|
39534
|
+
* holds its name, answering whether this call wrote it. A frame loads nothing
|
|
39535
|
+
* over the network, so each project carries its own copy.
|
|
39536
|
+
*/
|
|
39537
|
+
async function ensureViewer(projectDir, shipped = shippedViewerPath()) {
|
|
39538
|
+
const folder = join(projectDir, ASSETS_FOLDER);
|
|
39539
|
+
await mkdir(folder, { recursive: true });
|
|
39540
|
+
try {
|
|
39541
|
+
await copyFile(shipped, join(folder, VIEWER_FILE), constants.COPYFILE_EXCL);
|
|
39542
|
+
return true;
|
|
39543
|
+
} catch (error) {
|
|
39544
|
+
if (isCode(error, "EEXIST")) return false;
|
|
39545
|
+
throw error;
|
|
39546
|
+
}
|
|
39547
|
+
}
|
|
39043
39548
|
// src/shared/records/notes.ts
|
|
39044
39549
|
/** Where a note on one element points, in the edit address's terms. */
|
|
39045
39550
|
const noteAnchorSchema = looseObject({
|
|
@@ -40749,7 +41254,7 @@ const insertSchema = object$1({
|
|
|
40749
41254
|
orFlow: boolean$1().optional()
|
|
40750
41255
|
}).optional()
|
|
40751
41256
|
});
|
|
40752
|
-
const removeSchema = union([object$1({
|
|
41257
|
+
const removeSchema$1 = union([object$1({
|
|
40753
41258
|
ref: string$1().min(1).max(1024),
|
|
40754
41259
|
index: int$1().min(0),
|
|
40755
41260
|
hash: string$1().regex(/^[0-9a-f]{64}$/)
|
|
@@ -40928,14 +41433,16 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
40928
41433
|
}, 409);
|
|
40929
41434
|
element = {
|
|
40930
41435
|
...body.element,
|
|
40931
|
-
tag: asset.kind
|
|
41436
|
+
tag: assetTag(asset.kind)
|
|
40932
41437
|
};
|
|
40933
41438
|
}
|
|
41439
|
+
const viewer = element.kind === "asset" && element.tag === "model-viewer";
|
|
41440
|
+
if (viewer) await ensureViewer(join(root, frame.project));
|
|
40934
41441
|
const { at } = body;
|
|
40935
41442
|
const insert = (place) => insertFrameFile(frame.path, body.hash, {
|
|
40936
41443
|
parent: body.parent,
|
|
40937
41444
|
before: body.before
|
|
40938
|
-
}, elementMarkup(element, shapePaint(tokens), textFont(tokens)), place);
|
|
41445
|
+
}, elementMarkup(element, shapePaint(tokens), textFont(tokens)), place, viewer);
|
|
40939
41446
|
const placed = at && insert((html, index) => {
|
|
40940
41447
|
const bare = element.kind === "text" ? applyEdit(html, { index }, {
|
|
40941
41448
|
kind: "style",
|
|
@@ -40946,7 +41453,7 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
40946
41453
|
html
|
|
40947
41454
|
};
|
|
40948
41455
|
if (!bare.ok) return bare;
|
|
40949
|
-
const facts = elementPlaceFacts(frameFrom(frame, bare.html), tokenSheets(frame
|
|
41456
|
+
const facts = elementPlaceFacts(frameFrom(frame, bare.html), tokenSheets(frame));
|
|
40950
41457
|
return placeElement(bare.html, index, {
|
|
40951
41458
|
left: at.left,
|
|
40952
41459
|
top: at.top
|
|
@@ -40985,7 +41492,7 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
40985
41492
|
});
|
|
40986
41493
|
});
|
|
40987
41494
|
app.post("/api/frames/remove", requireWriter(access), async (c) => {
|
|
40988
|
-
const body = await parseBody$1(c.req.raw, removeSchema);
|
|
41495
|
+
const body = await parseBody$1(c.req.raw, removeSchema$1);
|
|
40989
41496
|
const frame = await resolveFrameRef(root, body.ref, { cwd: root });
|
|
40990
41497
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
40991
41498
|
await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
|
|
@@ -41097,7 +41604,7 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
41097
41604
|
index,
|
|
41098
41605
|
spot,
|
|
41099
41606
|
drop: spot ? [] : drop ?? []
|
|
41100
|
-
})), (html) => elementPlaceFacts(frameFrom(frame, html), tokenSheets(frame
|
|
41607
|
+
})), (html) => elementPlaceFacts(frameFrom(frame, html), tokenSheets(frame)));
|
|
41101
41608
|
if (!result.ok) return c.json({
|
|
41102
41609
|
ok: false,
|
|
41103
41610
|
error: {
|
|
@@ -41135,7 +41642,7 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
41135
41642
|
});
|
|
41136
41643
|
}
|
|
41137
41644
|
const source = readFrame$1(frame);
|
|
41138
|
-
const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame
|
|
41645
|
+
const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame)) : [];
|
|
41139
41646
|
const result = placeFrameFile(frame.path, body.hash, body.index, body.spot, facts, body.spot ? [] : body.drop ?? []);
|
|
41140
41647
|
if (!result.ok) return c.json({
|
|
41141
41648
|
ok: false,
|
|
@@ -41177,7 +41684,7 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
41177
41684
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
41178
41685
|
await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
|
|
41179
41686
|
const source = readFrame$1(frame);
|
|
41180
|
-
const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame
|
|
41687
|
+
const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame)) : [];
|
|
41181
41688
|
const result = wrapFrameFile(frame.path, body.hash, body.indexes, body.flow, body.spot, facts);
|
|
41182
41689
|
if (!result.ok) return c.json({
|
|
41183
41690
|
ok: false,
|
|
@@ -41262,86 +41769,11 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
41262
41769
|
data
|
|
41263
41770
|
});
|
|
41264
41771
|
});
|
|
41265
|
-
/** The
|
|
41266
|
-
const tokenSheets = (
|
|
41267
|
-
const paths = sheets?.(project);
|
|
41268
|
-
return [paths?.board ?? null, paths?.project ?? null].filter((path) => path !== null).map((path) => ({
|
|
41269
|
-
css: readFileSync(path, "utf8"),
|
|
41270
|
-
origin: "token",
|
|
41271
|
-
path,
|
|
41272
|
-
offset: 0
|
|
41273
|
-
}));
|
|
41274
|
-
};
|
|
41772
|
+
/** The sheets the frame renders with ahead of its own, as the frame route imports them. */
|
|
41773
|
+
const tokenSheets = (frame) => sheets ? readSheets(root, frame.project, sheets(frame.project), frameKit(frame)) : [];
|
|
41275
41774
|
app.onError(answerRefusal);
|
|
41276
41775
|
return app;
|
|
41277
41776
|
}
|
|
41278
|
-
// src/shared/kits.ts
|
|
41279
|
-
/**
|
|
41280
|
-
* The names a design kit's folder of plain files is laid out by, installed so
|
|
41281
|
-
* the frame route imports `assets/kit/` after the token sheets.
|
|
41282
|
-
*/
|
|
41283
|
-
const KIT_FILE = "kit.json";
|
|
41284
|
-
const KIT_SHEET = "kit.css";
|
|
41285
|
-
const KIT_NOTE = "kit.md";
|
|
41286
|
-
/** The dot folder in a board holding the kits saved from its projects, which home never lists as a project. */
|
|
41287
|
-
const KITS_FOLDER = ".kits";
|
|
41288
|
-
/**
|
|
41289
|
-
* Where the board serves a kit's files, under `/frameboard/`, since a bare
|
|
41290
|
-
* `/kits` would shadow the client's module folder under the dev server.
|
|
41291
|
-
*/
|
|
41292
|
-
const KITS_URL = "/frameboard/kits";
|
|
41293
|
-
/** The kits the tool ships, in the order a picker shows them. */
|
|
41294
|
-
const SHIPPED_KITS = [
|
|
41295
|
-
"clean",
|
|
41296
|
-
"sketch",
|
|
41297
|
-
"wireframe"
|
|
41298
|
-
];
|
|
41299
|
-
// src/server/checks/tokens.ts
|
|
41300
|
-
/**
|
|
41301
|
-
* Where a project's token sheets sit, the address file read by plain
|
|
41302
|
-
* `JSON.parse`, since the write hook cannot afford its schema.
|
|
41303
|
-
*/
|
|
41304
|
-
function tokenSheetPaths(root, project, tokens) {
|
|
41305
|
-
const own = join(root, project, TOKEN_FILE);
|
|
41306
|
-
return {
|
|
41307
|
-
board: boardSheetPath(root, tokens),
|
|
41308
|
-
project: existsSync(own) ? own : null
|
|
41309
|
-
};
|
|
41310
|
-
}
|
|
41311
|
-
/** The board's token sheet alone, resolved the way `tokenSheetPaths` resolves it. */
|
|
41312
|
-
function boardSheetPath(root, tokens = recordedTokens(root)) {
|
|
41313
|
-
const board = tokens ?? join(root, "tokens.css");
|
|
41314
|
-
return existsSync(board) ? board : null;
|
|
41315
|
-
}
|
|
41316
|
-
/** The `--tokens` path the board's running server recorded, or null. */
|
|
41317
|
-
function recordedTokens(root) {
|
|
41318
|
-
try {
|
|
41319
|
-
const parsed = JSON.parse(readFileSync(join(root, RUN_FOLDER, ADDRESS_FILE), "utf8"));
|
|
41320
|
-
const tokens = typeof parsed === "object" && parsed !== null && "tokens" in parsed ? parsed.tokens : void 0;
|
|
41321
|
-
return typeof tokens === "string" ? tokens : null;
|
|
41322
|
-
} catch {
|
|
41323
|
-
return null;
|
|
41324
|
-
}
|
|
41325
|
-
}
|
|
41326
|
-
/**
|
|
41327
|
-
* The sheets the frame route imports ahead of a project's frames, being the
|
|
41328
|
-
* board's tokens, then the project's, then an installed kit's stylesheet,
|
|
41329
|
-
* which the cascade reads ahead of each frame's own sheets.
|
|
41330
|
-
*/
|
|
41331
|
-
function tokenSheets(root, project, tokens) {
|
|
41332
|
-
const paths = tokenSheetPaths(root, project, tokens);
|
|
41333
|
-
const kit = join(root, project, ASSETS_FOLDER, "kit", KIT_SHEET);
|
|
41334
|
-
return [
|
|
41335
|
-
paths.board,
|
|
41336
|
-
paths.project,
|
|
41337
|
-
existsSync(kit) ? kit : null
|
|
41338
|
-
].filter((path) => path !== null).map((path) => ({
|
|
41339
|
-
css: readFileSync(path, "utf8"),
|
|
41340
|
-
origin: "token",
|
|
41341
|
-
path,
|
|
41342
|
-
offset: 0
|
|
41343
|
-
}));
|
|
41344
|
-
}
|
|
41345
41777
|
// src/shared/records/selection.ts
|
|
41346
41778
|
const hashSchema = string$1().regex(/^[0-9a-f]{64}$/);
|
|
41347
41779
|
/** More frames than any page holds, so a report cannot grow without bound. */
|
|
@@ -41401,7 +41833,7 @@ function elementsRoutes(root, access, selection, tokens = null) {
|
|
|
41401
41833
|
const frame = await resolveFrameRef(root, ref, { cwd: root });
|
|
41402
41834
|
const bytes = await readFile(frame.path);
|
|
41403
41835
|
const source = readFrame$1(frame);
|
|
41404
|
-
const sheets = tokenSheets(root, frame.project, tokens);
|
|
41836
|
+
const sheets = tokenSheets(root, frame.project, tokens, frameKit(frame));
|
|
41405
41837
|
const elements = elementTree(bytes.toString("utf8"), elementLayouts(source, sheets), elementRounds(source, sheets), elementPlaceFacts(source, sheets));
|
|
41406
41838
|
if (!Array.isArray(elements)) throw new FrameboardError(elements.reason, elements.detail, { ref });
|
|
41407
41839
|
return {
|
|
@@ -41441,7 +41873,7 @@ function elementsRoutes(root, access, selection, tokens = null) {
|
|
|
41441
41873
|
const data = {
|
|
41442
41874
|
ref: source.ref,
|
|
41443
41875
|
hash: contentHash(source.html),
|
|
41444
|
-
...frameStyles(source, tokenSheets(root, frame.project, tokens), index)
|
|
41876
|
+
...frameStyles(source, tokenSheets(root, frame.project, tokens, frameKit(frame)), index)
|
|
41445
41877
|
};
|
|
41446
41878
|
return c.json({
|
|
41447
41879
|
ok: true,
|
|
@@ -41754,99 +42186,73 @@ async function boardKitNames(root) {
|
|
|
41754
42186
|
}
|
|
41755
42187
|
// src/server/kits/install.ts
|
|
41756
42188
|
/**
|
|
41757
|
-
*
|
|
41758
|
-
*
|
|
41759
|
-
*
|
|
42189
|
+
* Adds a kit to a project as a copy of its folder under `assets/kits/`, so
|
|
42190
|
+
* a frame can name it, touching no token sheet and no page. Refuses
|
|
42191
|
+
* `name-taken` where the project holds a kit by that name, writing nothing.
|
|
41760
42192
|
*/
|
|
41761
|
-
async function
|
|
42193
|
+
async function installKit(root, ref, kit, { journal } = {}) {
|
|
41762
42194
|
const project = await resolveProject(root, ref);
|
|
41763
|
-
|
|
41764
|
-
|
|
41765
|
-
|
|
41766
|
-
|
|
41767
|
-
|
|
41768
|
-
|
|
41769
|
-
}
|
|
41770
|
-
return taken;
|
|
41771
|
-
}
|
|
41772
|
-
/** The project's sheet, kit page, and kit files, the paths an install writes. */
|
|
41773
|
-
function lookPaths(projectPath) {
|
|
41774
|
-
return [
|
|
41775
|
-
join(projectPath, TOKEN_FILE),
|
|
41776
|
-
join(projectPath, "kit"),
|
|
41777
|
-
join(projectPath, ASSETS_FOLDER, "kit")
|
|
41778
|
-
];
|
|
41779
|
-
}
|
|
41780
|
-
/**
|
|
41781
|
-
* Installs a kit into a project, refusing without `replace` where a sheet
|
|
41782
|
-
* already reaches it, so a kit never writes under a chosen look, and writing
|
|
41783
|
-
* nothing on any refusal.
|
|
41784
|
-
*/
|
|
41785
|
-
async function installKit(root, ref, kit, { tokens, journal, replace = false } = {}) {
|
|
41786
|
-
const project = await resolveProject(root, ref);
|
|
41787
|
-
const sheet = join(project.path, TOKEN_FILE);
|
|
41788
|
-
const assets = join(project.path, ASSETS_FOLDER);
|
|
41789
|
-
const kitAssets = join(assets, "kit");
|
|
41790
|
-
const page = join(project.path, "kit");
|
|
41791
|
-
if (!replace) {
|
|
41792
|
-
const sheets = tokenSheetPaths(root, project.name, tokens);
|
|
41793
|
-
const existing = sheets.project ?? sheets.board;
|
|
41794
|
-
if (existing) refuseSheet(project.name, existing);
|
|
41795
|
-
for (const taken of [page, kitAssets]) if (existsSync(taken)) throw new FrameboardError("name-taken", `${project.name} already holds ${relative(project.path, taken)}, so no kit was installed.`, {
|
|
41796
|
-
project: project.name,
|
|
41797
|
-
path: taken
|
|
41798
|
-
});
|
|
41799
|
-
}
|
|
42195
|
+
assertValidName("kit", kit.name);
|
|
42196
|
+
const held = matchName(await projectKitNames(project.path), kit.name);
|
|
42197
|
+
const target = projectKitDir(project.path, kit.name);
|
|
42198
|
+
if (held !== void 0 || existsSync(target)) throw new FrameboardError("name-taken", `${project.name} already holds a kit named ${held ?? kit.name}, so none was added. Remove it first with \`frameboard kit remove ${project.name} ${held ?? kit.name}\`.`, {
|
|
42199
|
+
project: project.name,
|
|
42200
|
+
kit: held ?? kit.name
|
|
42201
|
+
});
|
|
41800
42202
|
await readKitFile(kit);
|
|
41801
|
-
|
|
41802
|
-
|
|
41803
|
-
|
|
41804
|
-
} catch (error) {
|
|
41805
|
-
if (isCode(error, "EEXIST")) refuseSheet(project.name, sheet);
|
|
41806
|
-
throw error;
|
|
41807
|
-
}
|
|
41808
|
-
await journal?.created(sheet);
|
|
41809
|
-
const written = [sheet];
|
|
41810
|
-
const assetsMade = !existsSync(assets);
|
|
41811
|
-
await mkdir(assets, { recursive: true });
|
|
41812
|
-
await cp(kit.path, kitAssets, {
|
|
42203
|
+
const made = topmostMissing(target);
|
|
42204
|
+
await mkdir(dirname(target), { recursive: true });
|
|
42205
|
+
await cp(kit.path, target, {
|
|
41813
42206
|
recursive: true,
|
|
41814
42207
|
errorOnExist: true,
|
|
41815
42208
|
force: false,
|
|
41816
|
-
filter: (path) =>
|
|
42209
|
+
filter: (path) => isKitFile(kit.path, path)
|
|
41817
42210
|
});
|
|
41818
|
-
await journal?.created(
|
|
41819
|
-
written.push(kitAssets);
|
|
41820
|
-
const samples = join(kit.path, "kit");
|
|
41821
|
-
if (existsSync(samples)) {
|
|
41822
|
-
await cp(samples, page, {
|
|
41823
|
-
recursive: true,
|
|
41824
|
-
errorOnExist: true,
|
|
41825
|
-
force: false,
|
|
41826
|
-
filter: (path) => isCopied(basename(path))
|
|
41827
|
-
});
|
|
41828
|
-
await journal?.created(page);
|
|
41829
|
-
written.push(page);
|
|
41830
|
-
}
|
|
42211
|
+
await journal?.created(made);
|
|
41831
42212
|
return {
|
|
41832
42213
|
project: project.name,
|
|
41833
42214
|
kit: kit.name,
|
|
41834
|
-
written
|
|
42215
|
+
written: [target]
|
|
41835
42216
|
};
|
|
41836
42217
|
}
|
|
41837
|
-
/**
|
|
41838
|
-
function
|
|
42218
|
+
/** The highest folder on the way to `path` that does not exist yet, which an undo removes whole. */
|
|
42219
|
+
function topmostMissing(path) {
|
|
42220
|
+
const parent = dirname(path);
|
|
42221
|
+
return existsSync(parent) ? path : topmostMissing(parent);
|
|
42222
|
+
}
|
|
42223
|
+
/** Whether a path in the kit folder is copied, being anything but a dot-named entry or a lock or temp file. */
|
|
42224
|
+
function isKitFile(kitPath, path) {
|
|
41839
42225
|
const inside = relative(kitPath, path);
|
|
41840
42226
|
if (inside === "") return true;
|
|
41841
|
-
|
|
41842
|
-
if (rest.length === 0 && (top === "tokens.css" || top === "kit")) return false;
|
|
41843
|
-
return !top.startsWith(".") && isCopied(basename(path));
|
|
42227
|
+
return !inside.split("/").some((part) => part.startsWith(".")) && isCopied(basename(path));
|
|
41844
42228
|
}
|
|
41845
|
-
|
|
41846
|
-
|
|
41847
|
-
|
|
41848
|
-
|
|
41849
|
-
|
|
42229
|
+
// src/server/kits/remove.ts
|
|
42230
|
+
/**
|
|
42231
|
+
* Takes a kit out of a project and clears it from every frame naming it,
|
|
42232
|
+
* under every page's lock, so no frame is left naming a folder that is
|
|
42233
|
+
* gone. Refuses `kit-not-found` for a name the project holds no kit under.
|
|
42234
|
+
*/
|
|
42235
|
+
async function removeKit(root, ref, kit, { journal } = {}) {
|
|
42236
|
+
const project = await resolveProject(root, ref);
|
|
42237
|
+
const held = await heldKit(project, kit);
|
|
42238
|
+
const frames = await withLayouts((await listPageFolders(project.path)).map((page) => join(project.path, page)), async (layouts) => {
|
|
42239
|
+
const cleared = [];
|
|
42240
|
+
for (const [page, layout] of layouts) for (const name of layout.names) {
|
|
42241
|
+
const { kit: named, ...rest } = layout.placement(name);
|
|
42242
|
+
if (named !== held) continue;
|
|
42243
|
+
layout.set(name, rest);
|
|
42244
|
+
cleared.push(`${project.name}/${basename(page)}/${name}`);
|
|
42245
|
+
}
|
|
42246
|
+
const folder = projectKitDir(project.path, held);
|
|
42247
|
+
if (journal) await journal.removed(folder);
|
|
42248
|
+
else await rm(folder, { recursive: true });
|
|
42249
|
+
return cleared;
|
|
42250
|
+
}, journal);
|
|
42251
|
+
return {
|
|
42252
|
+
project: project.name,
|
|
42253
|
+
kit: held,
|
|
42254
|
+
frames
|
|
42255
|
+
};
|
|
41850
42256
|
}
|
|
41851
42257
|
// src/server/kits/save.ts
|
|
41852
42258
|
/**
|
|
@@ -41867,7 +42273,7 @@ async function saveKit(root, ref, name, { tokens, journal } = {}) {
|
|
|
41867
42273
|
await mkdir(staging, { recursive: true });
|
|
41868
42274
|
try {
|
|
41869
42275
|
const assets = join(project.path, ASSETS_FOLDER, "kit");
|
|
41870
|
-
if (existsSync(assets)) await cp(assets, staging, {
|
|
42276
|
+
if (existsSync(join(assets, "kit.json"))) await cp(assets, staging, {
|
|
41871
42277
|
recursive: true,
|
|
41872
42278
|
filter: (from) => isCopied(basename(from))
|
|
41873
42279
|
});
|
|
@@ -42056,7 +42462,9 @@ const CONTENT_TYPES$2 = {
|
|
|
42056
42462
|
".mp3": "audio/mpeg",
|
|
42057
42463
|
".wav": "audio/wav",
|
|
42058
42464
|
".ogg": "audio/ogg",
|
|
42059
|
-
".m4a": "audio/mp4"
|
|
42465
|
+
".m4a": "audio/mp4",
|
|
42466
|
+
".glb": "model/gltf-binary",
|
|
42467
|
+
".gltf": "model/gltf+json"
|
|
42060
42468
|
};
|
|
42061
42469
|
/**
|
|
42062
42470
|
* Serves the board's frames so relative links resolve unrewritten, its own
|
|
@@ -42118,7 +42526,13 @@ function frameRoutes(root, look, version, base = "") {
|
|
|
42118
42526
|
if (held === null) return c.notFound();
|
|
42119
42527
|
bytes = new TextEncoder().encode(held);
|
|
42120
42528
|
}
|
|
42121
|
-
const
|
|
42529
|
+
const kit = isFrame ? frameKit({
|
|
42530
|
+
root,
|
|
42531
|
+
project,
|
|
42532
|
+
page,
|
|
42533
|
+
name: name.slice(0, -5)
|
|
42534
|
+
}) : null;
|
|
42535
|
+
const body = injectHead(bytes, frameHead(sheetUrls(project, look.sheets(project), kitSheetFiles(root, project, kit)).map((url) => `${base}${url}`), contentHash(bytes), `${base}${BRIDGE_URL}`));
|
|
42122
42536
|
return c.body(body, 200, {
|
|
42123
42537
|
"Content-Type": contentType,
|
|
42124
42538
|
"Cache-Control": "no-store"
|
|
@@ -42170,22 +42584,18 @@ function parseRange(header, size) {
|
|
|
42170
42584
|
}
|
|
42171
42585
|
/**
|
|
42172
42586
|
* The sheets a frame imports, being every face, then the board's tokens, then
|
|
42173
|
-
* the project's, then
|
|
42174
|
-
*
|
|
42587
|
+
* the project's, then its kit sheets, which read the tokens and still lose to
|
|
42588
|
+
* the frame's own sheets. `kitFiles` come as `kitSheetFiles` answers them.
|
|
42175
42589
|
*/
|
|
42176
|
-
function sheetUrls(project, sheets,
|
|
42590
|
+
function sheetUrls(project, sheets, kitFiles) {
|
|
42177
42591
|
const folder = `/frames/${encodeURIComponent(project)}`;
|
|
42178
42592
|
return [
|
|
42179
42593
|
...FACES.map(faceSheetUrl),
|
|
42180
42594
|
...sheets.board ? [BOARD_SHEET_URL] : [],
|
|
42181
42595
|
...sheets.project ? [`${folder}/${TOKEN_FILE}`] : [],
|
|
42182
|
-
...
|
|
42596
|
+
...kitFiles.map((file) => `${folder}/${file.split("/").map(encodeURIComponent).join("/")}`)
|
|
42183
42597
|
];
|
|
42184
42598
|
}
|
|
42185
|
-
/** Whether a kit is installed in the project, read per request so an install reaches the next load. */
|
|
42186
|
-
function hasKit(root, project) {
|
|
42187
|
-
return existsSync(join(root, project, ASSETS_FOLDER, "kit", KIT_SHEET));
|
|
42188
|
-
}
|
|
42189
42599
|
function decodeSegments(segments) {
|
|
42190
42600
|
const decoded = [];
|
|
42191
42601
|
for (const segment of segments) {
|
|
@@ -42240,8 +42650,12 @@ const PREVIEW_POLICY = `script-src 'sha256-${createHash("sha256").update(THEME_S
|
|
|
42240
42650
|
const installSchema = object$1({
|
|
42241
42651
|
project: name$1,
|
|
42242
42652
|
kit: name$1,
|
|
42243
|
-
/**
|
|
42244
|
-
replace: boolean$1().
|
|
42653
|
+
/** Accepted and ignored, since a caller written for the install that replaced a look may still send it. */
|
|
42654
|
+
replace: boolean$1().optional()
|
|
42655
|
+
});
|
|
42656
|
+
const removeSchema = object$1({
|
|
42657
|
+
project: name$1,
|
|
42658
|
+
kit: name$1
|
|
42245
42659
|
});
|
|
42246
42660
|
const saveSchema = object$1({
|
|
42247
42661
|
project: name$1,
|
|
@@ -42263,15 +42677,15 @@ const CONTENT_TYPES$1 = {
|
|
|
42263
42677
|
*/
|
|
42264
42678
|
function kitRoutes(root, access, history, { tokens, shipped = shippedKitsDir() }) {
|
|
42265
42679
|
const app = new Hono();
|
|
42266
|
-
/** Runs one write with a fresh journal and records it as a step that moves no page. */
|
|
42267
|
-
const recorded = async (write) => {
|
|
42680
|
+
/** Runs one write with a fresh journal and records it as a step that moves no page, touching the frames `touched` reads off it. */
|
|
42681
|
+
const recorded = async (write, touched = () => []) => {
|
|
42268
42682
|
const journal = history.journal();
|
|
42269
42683
|
const result = await write(journal);
|
|
42270
42684
|
history.record({
|
|
42271
42685
|
id: journal.id,
|
|
42272
42686
|
changes: journal.changes,
|
|
42273
42687
|
page: null,
|
|
42274
|
-
frames:
|
|
42688
|
+
frames: touched(result)
|
|
42275
42689
|
});
|
|
42276
42690
|
return result;
|
|
42277
42691
|
};
|
|
@@ -42282,20 +42696,21 @@ function kitRoutes(root, access, history, { tokens, shipped = shippedKitsDir() }
|
|
|
42282
42696
|
app.post("/api/kits/install", requireWriter(access), async (c) => {
|
|
42283
42697
|
const body = await parseBody$1(c.req.raw, installSchema);
|
|
42284
42698
|
const kit = findKit(root, body.kit, shipped);
|
|
42285
|
-
|
|
42286
|
-
await readKitFile(kit);
|
|
42287
|
-
await recorded((journal) => takeOutLook(root, body.project, { journal }));
|
|
42288
|
-
}
|
|
42289
|
-
const installed = await recorded((journal) => installKit(root, body.project, kit, {
|
|
42290
|
-
tokens,
|
|
42291
|
-
journal,
|
|
42292
|
-
replace: body.replace
|
|
42293
|
-
}));
|
|
42699
|
+
const installed = await recorded((journal) => installKit(root, body.project, kit, { journal }));
|
|
42294
42700
|
return c.json({
|
|
42295
42701
|
ok: true,
|
|
42296
42702
|
data: installed
|
|
42297
42703
|
});
|
|
42298
42704
|
});
|
|
42705
|
+
/** Takes a kit out of a project and off every frame naming it, as one step an undo brings back whole. */
|
|
42706
|
+
app.post("/api/kits/remove", requireWriter(access), async (c) => {
|
|
42707
|
+
const body = await parseBody$1(c.req.raw, removeSchema);
|
|
42708
|
+
const removed = await recorded((journal) => removeKit(root, body.project, body.kit, { journal }), (record) => record.frames);
|
|
42709
|
+
return c.json({
|
|
42710
|
+
ok: true,
|
|
42711
|
+
data: removed
|
|
42712
|
+
});
|
|
42713
|
+
});
|
|
42299
42714
|
app.post("/api/kits/save", requireWriter(access), async (c) => {
|
|
42300
42715
|
const body = await parseBody$1(c.req.raw, saveSchema);
|
|
42301
42716
|
const saved = await recorded((journal) => saveKit(root, body.project, body.name, {
|
|
@@ -44614,6 +45029,105 @@ async function waitForImages(timeoutMs) {
|
|
|
44614
45029
|
});
|
|
44615
45030
|
return unsettled;
|
|
44616
45031
|
}
|
|
45032
|
+
// src/server/capture/model-loads.ts
|
|
45033
|
+
/**
|
|
45034
|
+
* Records each viewer whose load fails, from before the frame's scripts run.
|
|
45035
|
+
* A viewer keeps no failed state to read and can fire its `error` ahead of
|
|
45036
|
+
* `settleModels`, which would then wait on an event already gone.
|
|
45037
|
+
*/
|
|
45038
|
+
async function watchModels(page) {
|
|
45039
|
+
await page.addInitScript(recordFailedModels);
|
|
45040
|
+
}
|
|
45041
|
+
function recordFailedModels() {
|
|
45042
|
+
const failed = /* @__PURE__ */ new WeakSet();
|
|
45043
|
+
Object.defineProperty(window, Symbol.for("frameboard.failed-models"), { value: failed });
|
|
45044
|
+
const isViewer = (target) => target instanceof Element && target.localName === "model-viewer";
|
|
45045
|
+
document.addEventListener("error", ({ target }) => {
|
|
45046
|
+
if (isViewer(target)) failed.add(target);
|
|
45047
|
+
}, true);
|
|
45048
|
+
document.addEventListener("load", ({ target }) => {
|
|
45049
|
+
if (isViewer(target)) failed.delete(target);
|
|
45050
|
+
}, true);
|
|
45051
|
+
}
|
|
45052
|
+
/**
|
|
45053
|
+
* Waits for each `<model-viewer>` to draw, holds it at its clip's start, and
|
|
45054
|
+
* hides its loading bar, so two captures match. A model with no picture is
|
|
45055
|
+
* returned, never refused, read from the failures `watchModels` recorded.
|
|
45056
|
+
*/
|
|
45057
|
+
async function settleModels(page, timeoutMs) {
|
|
45058
|
+
return page.evaluate(waitForModels, {
|
|
45059
|
+
timeoutMs: Math.max(0, timeoutMs),
|
|
45060
|
+
marker: LOOK_MARKER
|
|
45061
|
+
});
|
|
45062
|
+
}
|
|
45063
|
+
async function waitForModels({ timeoutMs, marker }) {
|
|
45064
|
+
const viewers = [];
|
|
45065
|
+
let index = 0;
|
|
45066
|
+
for (const element of document.querySelectorAll("*")) {
|
|
45067
|
+
if (element.closest("[data-frameboard]")) continue;
|
|
45068
|
+
const own = index;
|
|
45069
|
+
index += 1;
|
|
45070
|
+
if (element.localName !== "model-viewer") continue;
|
|
45071
|
+
const src = element.getAttribute("src") ?? "";
|
|
45072
|
+
if (!src) continue;
|
|
45073
|
+
viewers.push({
|
|
45074
|
+
index: own,
|
|
45075
|
+
viewer: element,
|
|
45076
|
+
src
|
|
45077
|
+
});
|
|
45078
|
+
}
|
|
45079
|
+
if (viewers.length === 0) return [];
|
|
45080
|
+
const bar = document.createElement("style");
|
|
45081
|
+
bar.setAttribute(marker, "");
|
|
45082
|
+
bar.textContent = "model-viewer { --progress-bar-height: 0px !important }";
|
|
45083
|
+
document.head.append(bar);
|
|
45084
|
+
const failed = window[Symbol.for("frameboard.failed-models")];
|
|
45085
|
+
const nextFrame = () => new Promise((done) => requestAnimationFrame(() => done()));
|
|
45086
|
+
const inViewport = (viewer) => new Promise((done) => {
|
|
45087
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
45088
|
+
observer.disconnect();
|
|
45089
|
+
done(entry?.isIntersecting ?? false);
|
|
45090
|
+
}, { threshold: 1e-5 });
|
|
45091
|
+
observer.observe(viewer);
|
|
45092
|
+
});
|
|
45093
|
+
const settle = async (viewer) => {
|
|
45094
|
+
if (!customElements.get("model-viewer")) return "error";
|
|
45095
|
+
viewer.loading = "eager";
|
|
45096
|
+
if (!viewer.loaded) {
|
|
45097
|
+
if (failed?.has(viewer)) return "error";
|
|
45098
|
+
if (!await new Promise((done) => {
|
|
45099
|
+
viewer.addEventListener("load", () => done(true), { once: true });
|
|
45100
|
+
viewer.addEventListener("error", () => done(false), { once: true });
|
|
45101
|
+
})) return "error";
|
|
45102
|
+
}
|
|
45103
|
+
viewer.pause();
|
|
45104
|
+
viewer.currentTime = 0;
|
|
45105
|
+
if (!await inViewport(viewer)) return "ok";
|
|
45106
|
+
while (!viewer.modelIsVisible && viewer.getAttribute("reveal") !== "manual") await nextFrame();
|
|
45107
|
+
await nextFrame();
|
|
45108
|
+
await nextFrame();
|
|
45109
|
+
return "ok";
|
|
45110
|
+
};
|
|
45111
|
+
const outcomes = viewers.map(({ viewer }) => ({
|
|
45112
|
+
state: "pending",
|
|
45113
|
+
done: settle(viewer)
|
|
45114
|
+
}));
|
|
45115
|
+
for (const outcome of outcomes) outcome.done.then((state) => {
|
|
45116
|
+
outcome.state = state;
|
|
45117
|
+
});
|
|
45118
|
+
await Promise.race([Promise.all(outcomes.map((outcome) => outcome.done)), new Promise((done) => setTimeout(done, timeoutMs))]);
|
|
45119
|
+
const unloaded = [];
|
|
45120
|
+
viewers.forEach(({ index: own, src }, at) => {
|
|
45121
|
+
const state = outcomes[at]?.state;
|
|
45122
|
+
if (state === void 0 || state === "ok") return;
|
|
45123
|
+
unloaded.push({
|
|
45124
|
+
index: own,
|
|
45125
|
+
src,
|
|
45126
|
+
state
|
|
45127
|
+
});
|
|
45128
|
+
});
|
|
45129
|
+
return unloaded;
|
|
45130
|
+
}
|
|
44617
45131
|
// src/shared/motion.ts
|
|
44618
45132
|
/**
|
|
44619
45133
|
* Finds a page's motion timeline. Capture evaluates it by source text, so it
|
|
@@ -44647,6 +45161,14 @@ async function readMotionIn(view, timeoutMs) {
|
|
|
44647
45161
|
duration: ends.length === 0 ? null : Math.round(Math.max(...ends))
|
|
44648
45162
|
};
|
|
44649
45163
|
}
|
|
45164
|
+
const clips = [...view.document.querySelectorAll("model-viewer")].map((viewer) => viewer).filter((viewer) => (viewer.availableAnimations?.length ?? 0) > 0);
|
|
45165
|
+
if (clips.length > 0) {
|
|
45166
|
+
const lengths = clips.map((viewer) => seconds(viewer.duration)).filter((length) => length !== null);
|
|
45167
|
+
return {
|
|
45168
|
+
source: "model",
|
|
45169
|
+
duration: lengths.length === 0 ? null : Math.max(...lengths)
|
|
45170
|
+
};
|
|
45171
|
+
}
|
|
44650
45172
|
return null;
|
|
44651
45173
|
};
|
|
44652
45174
|
await nextFrame();
|
|
@@ -44657,8 +45179,8 @@ async function readMotionIn(view, timeoutMs) {
|
|
|
44657
45179
|
}
|
|
44658
45180
|
}
|
|
44659
45181
|
/**
|
|
44660
|
-
* Holds the page at `ms` once painted, converting to the seconds HyperFrames
|
|
44661
|
-
* and
|
|
45182
|
+
* Holds the page at `ms` once painted, converting to the seconds HyperFrames,
|
|
45183
|
+
* GSAP, and a model viewer take here alone, self-contained as `readMotionIn` is.
|
|
44662
45184
|
*/
|
|
44663
45185
|
async function holdMotionIn(view, { motion, ms }) {
|
|
44664
45186
|
const at = motion.duration === null ? ms : Math.min(Math.max(ms, 0), motion.duration);
|
|
@@ -44670,10 +45192,16 @@ async function holdMotionIn(view, { motion, ms }) {
|
|
|
44670
45192
|
timeline.pause?.();
|
|
44671
45193
|
await timeline.seek(at / 1e3);
|
|
44672
45194
|
}
|
|
44673
|
-
} else for (const animation of view.document.getAnimations()) {
|
|
45195
|
+
} else if (motion.source === "css") for (const animation of view.document.getAnimations()) {
|
|
44674
45196
|
animation.pause();
|
|
44675
45197
|
animation.currentTime = at;
|
|
44676
45198
|
}
|
|
45199
|
+
for (const element of view.document.querySelectorAll("model-viewer")) {
|
|
45200
|
+
const viewer = element;
|
|
45201
|
+
if (typeof viewer.pause !== "function") continue;
|
|
45202
|
+
viewer.pause();
|
|
45203
|
+
viewer.currentTime = at / 1e3;
|
|
45204
|
+
}
|
|
44677
45205
|
await new Promise((done) => view.requestAnimationFrame(() => view.requestAnimationFrame(() => done())));
|
|
44678
45206
|
return at;
|
|
44679
45207
|
}
|
|
@@ -44828,9 +45356,9 @@ async function waitForVideos(timeoutMs) {
|
|
|
44828
45356
|
/** How long a frame has to load, its faces and images included, before its capture fails. */
|
|
44829
45357
|
const LOAD_TIMEOUT_MS = 1e4;
|
|
44830
45358
|
/**
|
|
44831
|
-
* Loads a frame within one budget for faces, images, and
|
|
44832
|
-
* finite animations. A missing face or image refuses, while an
|
|
44833
|
-
* is returned rather than refused.
|
|
45359
|
+
* Loads a frame within one budget for faces, images, videos, and models, then
|
|
45360
|
+
* settles finite animations. A missing face or image refuses, while an
|
|
45361
|
+
* unloaded video or model is returned rather than refused.
|
|
44834
45362
|
*/
|
|
44835
45363
|
async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts = "require", timeoutMs = LOAD_TIMEOUT_MS, motion = "settle" }) {
|
|
44836
45364
|
const context = await browser.newContext({
|
|
@@ -44846,6 +45374,7 @@ async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts =
|
|
|
44846
45374
|
try {
|
|
44847
45375
|
const page = await context.newPage();
|
|
44848
45376
|
if (motion === "hold") await holdAnimationClock(page);
|
|
45377
|
+
if (fonts === "require") await watchModels(page);
|
|
44849
45378
|
await page.goto(new URL(frameThemeUrl(ref, theme), baseUrl).href, {
|
|
44850
45379
|
timeout: timeoutMs,
|
|
44851
45380
|
waitUntil: "domcontentloaded"
|
|
@@ -44859,10 +45388,12 @@ async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts =
|
|
|
44859
45388
|
if (fonts === "require") await assertFontsPresent(page, ref);
|
|
44860
45389
|
await settleImages(page, ref, fonts, deadline - Date.now());
|
|
44861
45390
|
const videos = fonts === "require" ? await settleVideos(page, deadline - Date.now()) : [];
|
|
45391
|
+
const models = fonts === "require" ? await settleModels(page, deadline - Date.now()) : [];
|
|
44862
45392
|
if (fonts === "require" && motion === "settle") await settleAnimations(page, deadline - Date.now());
|
|
44863
45393
|
return {
|
|
44864
45394
|
page,
|
|
44865
45395
|
videos,
|
|
45396
|
+
models,
|
|
44866
45397
|
close
|
|
44867
45398
|
};
|
|
44868
45399
|
} catch (error) {
|
|
@@ -44930,13 +45461,15 @@ function createWarmRenderer({ baseUrl, browser, scale: defaultScale }) {
|
|
|
44930
45461
|
const opened = await openFrame(open, {
|
|
44931
45462
|
baseUrl: baseUrl(),
|
|
44932
45463
|
ref: frame.ref,
|
|
44933
|
-
box: frame.box,
|
|
45464
|
+
box: pageSize(frame.box, device),
|
|
44934
45465
|
theme,
|
|
44935
45466
|
scale
|
|
44936
45467
|
});
|
|
44937
45468
|
let shot;
|
|
45469
|
+
let colors = null;
|
|
44938
45470
|
try {
|
|
44939
45471
|
await hideControls(opened.page);
|
|
45472
|
+
if (topInset(device) > 0) colors = await readPageColors(opened.page);
|
|
44940
45473
|
shot = element === void 0 ? await opened.page.screenshot({
|
|
44941
45474
|
animations: "disabled",
|
|
44942
45475
|
caret: "hide"
|
|
@@ -44946,7 +45479,12 @@ function createWarmRenderer({ baseUrl, browser, scale: defaultScale }) {
|
|
|
44946
45479
|
}
|
|
44947
45480
|
return device ? drawBezel(open, shot, frame.box, {
|
|
44948
45481
|
device,
|
|
44949
|
-
pose: frame.pose
|
|
45482
|
+
pose: frame.pose,
|
|
45483
|
+
island: frame.island,
|
|
45484
|
+
bar: {
|
|
45485
|
+
colors,
|
|
45486
|
+
theme
|
|
45487
|
+
}
|
|
44950
45488
|
}, scale) : shot;
|
|
44951
45489
|
});
|
|
44952
45490
|
queue = run.catch(() => {});
|
|
@@ -44985,12 +45523,17 @@ async function shootElement(page, ref, index, scale) {
|
|
|
44985
45523
|
* A frame's shot drawn inside a device's body, as the board draws it, on a
|
|
44986
45524
|
* page the size of the body, so the PNG holds the body and nothing past it.
|
|
44987
45525
|
*/
|
|
44988
|
-
async function drawBezel(browser, shot, box, { device, pose = "closed" }, scale) {
|
|
45526
|
+
async function drawBezel(browser, shot, box, { device, pose = "closed", island = "compact", bar }, scale) {
|
|
44989
45527
|
const outer = bezelBox({
|
|
44990
45528
|
x: 0,
|
|
44991
45529
|
y: 0,
|
|
44992
45530
|
...box
|
|
44993
45531
|
}, device);
|
|
45532
|
+
const page = pageBox({
|
|
45533
|
+
x: 0,
|
|
45534
|
+
y: 0,
|
|
45535
|
+
...box
|
|
45536
|
+
}, device);
|
|
44994
45537
|
const laptop = device === "laptop";
|
|
44995
45538
|
const context = await browser.newContext({
|
|
44996
45539
|
viewport: {
|
|
@@ -45000,11 +45543,11 @@ async function drawBezel(browser, shot, box, { device, pose = "closed" }, scale)
|
|
|
45000
45543
|
deviceScaleFactor: scale
|
|
45001
45544
|
});
|
|
45002
45545
|
try {
|
|
45003
|
-
const
|
|
45004
|
-
const marks = device === "phone" ?
|
|
45546
|
+
const tab = await context.newPage();
|
|
45547
|
+
const marks = device === "phone" ? statusBarHtml(bar.colors, bar.theme) + phoneMarks(island) : laptop ? laptopMarks(box) : device === "foldable" ? foldableMarks(pose) : "";
|
|
45005
45548
|
const radius = screenCorners(device);
|
|
45006
|
-
await
|
|
45007
|
-
return await
|
|
45549
|
+
await tab.setContent(`<!doctype html><html><body style="margin:0;background:transparent"><div style="position:absolute;left:${-outer.x}px;top:${-outer.y}px;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="position:absolute;left:0;top:${page.y}px;width:${page.width}px;height:${page.height}px;border-radius:${pageCorners(device)}"><div style="position:absolute;inset:0;border-radius:${radius};box-shadow:${bezelShadow(device, { board: false })}">${marks}</div></div></body></html>`, { waitUntil: "load" });
|
|
45550
|
+
return await tab.screenshot({
|
|
45008
45551
|
omitBackground: true,
|
|
45009
45552
|
caret: "hide"
|
|
45010
45553
|
});
|
|
@@ -45013,6 +45556,56 @@ async function drawBezel(browser, shot, box, { device, pose = "closed" }, scale)
|
|
|
45013
45556
|
}
|
|
45014
45557
|
}
|
|
45015
45558
|
/**
|
|
45559
|
+
* A phone frame's shot of its page set under the status bar, at the frame's
|
|
45560
|
+
* box with no body, so a capture holds the screen the board draws.
|
|
45561
|
+
*/
|
|
45562
|
+
async function underStatusBar(browser, shot, box, { colors, theme }, scale) {
|
|
45563
|
+
const page = pageBox({
|
|
45564
|
+
x: 0,
|
|
45565
|
+
y: 0,
|
|
45566
|
+
...box
|
|
45567
|
+
}, "phone");
|
|
45568
|
+
const context = await browser.newContext({
|
|
45569
|
+
viewport: box,
|
|
45570
|
+
deviceScaleFactor: scale
|
|
45571
|
+
});
|
|
45572
|
+
try {
|
|
45573
|
+
const tab = await context.newPage();
|
|
45574
|
+
await tab.setContent(`<!doctype html><html><body style="margin:0;position:relative;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="position:absolute;left:0;top:${page.y}px;width:${page.width}px;height:${page.height}px">` + statusBarHtml(colors, theme, { rounded: false }) + `</body></html>`, { waitUntil: "load" });
|
|
45575
|
+
return await tab.screenshot({ caret: "hide" });
|
|
45576
|
+
} finally {
|
|
45577
|
+
await context.close();
|
|
45578
|
+
}
|
|
45579
|
+
}
|
|
45580
|
+
/** A loaded page's fill and text color, which the browser reads off its own document. */
|
|
45581
|
+
function readPageColors(page) {
|
|
45582
|
+
return page.evaluate(pageColors);
|
|
45583
|
+
}
|
|
45584
|
+
/** The viewport a frame's page opens at, its box less a phone's status bar, at least one pixel tall. */
|
|
45585
|
+
function pageSize(box, device) {
|
|
45586
|
+
const page = pageBox({
|
|
45587
|
+
x: 0,
|
|
45588
|
+
y: 0,
|
|
45589
|
+
...box
|
|
45590
|
+
}, device);
|
|
45591
|
+
return {
|
|
45592
|
+
width: page.width,
|
|
45593
|
+
height: Math.max(1, page.height)
|
|
45594
|
+
};
|
|
45595
|
+
}
|
|
45596
|
+
/**
|
|
45597
|
+
* The phone's status bar as the board draws it, in the page's fill and text
|
|
45598
|
+
* color or its theme's own, its top corners rounded to the screen inside a
|
|
45599
|
+
* body and square on a frame's bare box.
|
|
45600
|
+
*/
|
|
45601
|
+
function statusBarHtml(colors, theme, { rounded = true } = {}) {
|
|
45602
|
+
const { screenRadius } = BEZELS.phone;
|
|
45603
|
+
const corners = rounded ? `${screenRadius}px ${screenRadius}px 0 0` : "0";
|
|
45604
|
+
const signal = SIGNAL_BARS.map((tall) => `<span style="width:3px;height:${tall}px;border-radius:1px;background:currentColor"></span>`).join("");
|
|
45605
|
+
const battery = `<span style="display:flex;align-items:center"><span style="box-sizing:border-box;display:flex;align-items:center;width:${BATTERY.width}px;height:${BATTERY.height}px;border:1px solid currentColor;border-radius:${BATTERY.radius}px;padding:1.5px;opacity:.9"><span style="width:80%;height:100%;border-radius:2px;background:currentColor"></span></span><span style="width:${BATTERY.cap}px;height:4px;margin-left:1px;border-radius:0 1px 1px 0;background:currentColor;opacity:.6"></span></span>`;
|
|
45606
|
+
return `<div style="position:absolute;left:0;right:0;top:0;height:${STATUS_BAR.height}px;border-radius:${corners};color-scheme:${theme};background:${colors?.fill ?? "Canvas"};color:${colors?.ink ?? "CanvasText"}"><div style="position:absolute;left:0;right:0;top:${STATUS_BAR.band.top}px;height:${STATUS_BAR.band.height}px;box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;padding:0 ${STATUS_BAR.side}px;font:600 ${STATUS_BAR.font}px/1 ${STATUS_FONT};font-variant-numeric:tabular-nums"><span>${STATUS_BAR.time}</span><span style="display:flex;align-items:center;gap:6px"><span style="display:flex;align-items:flex-end;gap:2px">${signal}</span>${battery}</span></div></div>`;
|
|
45607
|
+
}
|
|
45608
|
+
/**
|
|
45016
45609
|
* The laptop's chin and base as the board draws them, past the screen's
|
|
45017
45610
|
* bottom, with the body's edge as its last pixel rather than past it.
|
|
45018
45611
|
*/
|
|
@@ -45021,6 +45614,14 @@ function laptopMarks(box) {
|
|
|
45021
45614
|
const edge = `1px solid ${BEZEL_COLORS.edge}`;
|
|
45022
45615
|
return `<span style="position:absolute;box-sizing:border-box;left:${chin.x}px;top:${chin.y}px;width:${chin.width}px;height:${chin.height}px;background:${BEZEL_COLORS.body};border-left:${edge};border-right:${edge}"></span><span style="position:absolute;box-sizing:border-box;left:${base.x}px;top:${base.y}px;width:${base.width}px;height:${base.height}px;background:${BEZEL_COLORS.base};border:${edge};border-radius:0 0 ${LAPTOP_BASE.radius}px ${LAPTOP_BASE.radius}px"></span>`;
|
|
45023
45616
|
}
|
|
45617
|
+
/** The phone's buttons, island, and home bar as the board draws them. */
|
|
45618
|
+
function phoneMarks(island) {
|
|
45619
|
+
const { border } = BEZELS.phone;
|
|
45620
|
+
const buttons = PHONE_BUTTONS.map(({ side, top, height }) => `<span style="position:absolute;${side}:${-border - 4}px;top:${top - border}px;width:4px;height:${height}px;border-radius:2px;background:${BEZEL_COLORS.button}"></span>`).join("");
|
|
45621
|
+
const shape = phoneIsland(island);
|
|
45622
|
+
const timer = island === "wide" ? `<span style="display:flex;align-items:center;gap:5px"><span style="width:6px;height:6px;border-radius:3px;background:${BEZEL_COLORS.islandLive}"></span>${WIDE_ISLAND_TIMER}</span><span style="display:flex;align-items:flex-end;gap:2px">${WIDE_ISLAND_LEVEL.map((tall) => `<span style="width:2px;height:${tall}px;border-radius:1px;background:${BEZEL_COLORS.islandLive}"></span>`).join("")}</span>` : "";
|
|
45623
|
+
return buttons + `<span style="${pill(shape.width, shape.height, BEZEL_COLORS.island)}top:${shape.top}px;box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;padding:0 11px;color:${BEZEL_COLORS.islandText};font:600 11px/1 ${STATUS_FONT};font-variant-numeric:tabular-nums">${timer}</span><span style="${pill(HOME_BAR.width, HOME_BAR.height, BEZEL_COLORS.homeBar)}bottom:${HOME_BAR.bottom}px"></span>`;
|
|
45624
|
+
}
|
|
45024
45625
|
/** The foldable's fold band, island, and home bar as the board draws them for a pose. */
|
|
45025
45626
|
function foldableMarks(pose) {
|
|
45026
45627
|
const band = foldBand(pose);
|
|
@@ -45126,7 +45727,7 @@ async function fitFrame(browser, { baseUrl, frame, ...options }) {
|
|
|
45126
45727
|
const measured = await measureContent(browser, {
|
|
45127
45728
|
baseUrl,
|
|
45128
45729
|
ref: frame.ref,
|
|
45129
|
-
box: frame.box,
|
|
45730
|
+
box: pageBox(frame.box, frame.device),
|
|
45130
45731
|
hugWidth: false
|
|
45131
45732
|
});
|
|
45132
45733
|
const widths = [];
|
|
@@ -45146,7 +45747,7 @@ async function fitFrame(browser, { baseUrl, frame, ...options }) {
|
|
|
45146
45747
|
});
|
|
45147
45748
|
}
|
|
45148
45749
|
return {
|
|
45149
|
-
frame: await fitHeight(options.root, frame.ref, measured.height, {
|
|
45750
|
+
frame: await fitHeight(options.root, frame.ref, measured.height + topInset(frame.device), {
|
|
45150
45751
|
...options,
|
|
45151
45752
|
widths
|
|
45152
45753
|
}),
|
|
@@ -45770,6 +46371,13 @@ const LINK_RULES = [
|
|
|
45770
46371
|
}
|
|
45771
46372
|
];
|
|
45772
46373
|
const finding$3 = findingFor(LINK_RULES);
|
|
46374
|
+
/** The attributes a `<model-viewer>` loads a file through, which `docs` states beside the rule. */
|
|
46375
|
+
const MODEL_LOADS = [
|
|
46376
|
+
"src",
|
|
46377
|
+
"poster",
|
|
46378
|
+
"environment-image",
|
|
46379
|
+
"skybox-image"
|
|
46380
|
+
];
|
|
45773
46381
|
/**
|
|
45774
46382
|
* The attributes that load a resource, by element. An `a href` navigates
|
|
45775
46383
|
* rather than loads, so it is left out.
|
|
@@ -45787,8 +46395,11 @@ const RESOURCE_ATTRIBUTES = {
|
|
|
45787
46395
|
object: ["data"],
|
|
45788
46396
|
input: ["src"],
|
|
45789
46397
|
image: ["href", "xlink:href"],
|
|
45790
|
-
use: ["href", "xlink:href"]
|
|
46398
|
+
use: ["href", "xlink:href"],
|
|
46399
|
+
"model-viewer": [...MODEL_LOADS]
|
|
45791
46400
|
};
|
|
46401
|
+
/** The lighting a viewer builds itself, which `environment-image` names in place of a file. */
|
|
46402
|
+
const BUILT_IN_ENVIRONMENTS = /* @__PURE__ */ new Set(["neutral", "legacy"]);
|
|
45792
46403
|
/** `outside-link`, `network`, and `missing-file` over every load a frame makes. */
|
|
45793
46404
|
function checkLinks(source) {
|
|
45794
46405
|
return frameLoads(source).flatMap((load) => judge(source, load));
|
|
@@ -45805,6 +46416,7 @@ function frameLoads(source) {
|
|
|
45805
46416
|
for (const name of RESOURCE_ATTRIBUTES[element.name] ?? []) {
|
|
45806
46417
|
const value = element.attribs[name];
|
|
45807
46418
|
if (value === void 0) continue;
|
|
46419
|
+
if (name === "environment-image" && BUILT_IN_ENVIRONMENTS.has(value)) continue;
|
|
45808
46420
|
const urls = name === "srcset" ? srcsetUrls(value) : [value];
|
|
45809
46421
|
for (const url of urls) loads.push({
|
|
45810
46422
|
url,
|
|
@@ -46173,8 +46785,9 @@ function checkFrame(target) {
|
|
|
46173
46785
|
findings: checkFrameIn(target, readProjectContext(target.root, target.project))
|
|
46174
46786
|
};
|
|
46175
46787
|
}
|
|
46176
|
-
function checkFrameIn(target, { config, tokens }) {
|
|
46788
|
+
function checkFrameIn(target, { config, tokens: tokensFor }) {
|
|
46177
46789
|
const source = readFrame$1(target);
|
|
46790
|
+
const tokens = tokensFor(frameKit(target));
|
|
46178
46791
|
const cascade = buildCascade(source, tokens);
|
|
46179
46792
|
return withoutOff([
|
|
46180
46793
|
...checkNaming(target, boardPath(target.root, source.path)),
|
|
@@ -46196,9 +46809,16 @@ function checkFrameIn(target, { config, tokens }) {
|
|
|
46196
46809
|
* address file names to every other caller.
|
|
46197
46810
|
*/
|
|
46198
46811
|
function readProjectContext(root, project, boardSheet) {
|
|
46812
|
+
const byKit = /* @__PURE__ */ new Map();
|
|
46199
46813
|
return {
|
|
46200
46814
|
config: readConfig(root, project),
|
|
46201
|
-
tokens:
|
|
46815
|
+
tokens: (kit) => {
|
|
46816
|
+
const held = byKit.get(kit);
|
|
46817
|
+
if (held) return held;
|
|
46818
|
+
const sheets = tokenSheets(root, project, boardSheet, kit);
|
|
46819
|
+
byKit.set(kit, sheets);
|
|
46820
|
+
return sheets;
|
|
46821
|
+
}
|
|
46202
46822
|
};
|
|
46203
46823
|
}
|
|
46204
46824
|
/**
|
|
@@ -46598,7 +47218,8 @@ const frameDeviceSchema = object$1({
|
|
|
46598
47218
|
/** Absent leaves the device as it stands, but for naming a foldable, which shows it. */
|
|
46599
47219
|
show: boolean$1().optional(),
|
|
46600
47220
|
foldable: boolean$1().optional(),
|
|
46601
|
-
pose: _enum$1(POSES).optional()
|
|
47221
|
+
pose: _enum$1(POSES).optional(),
|
|
47222
|
+
island: _enum$1(ISLANDS).optional()
|
|
46602
47223
|
});
|
|
46603
47224
|
/** More widths than any device list offers, so a body cannot grow without bound. */
|
|
46604
47225
|
const widthList = array$1(int$1().min(1)).max(64);
|
|
@@ -46628,6 +47249,11 @@ const frameTransitionSchema = object$1({
|
|
|
46628
47249
|
refs,
|
|
46629
47250
|
transition: transition.nullable()
|
|
46630
47251
|
});
|
|
47252
|
+
/** Null clears each frame's kit, so it draws with the project's sheets alone. */
|
|
47253
|
+
const frameKitSchema = object$1({
|
|
47254
|
+
refs,
|
|
47255
|
+
kit: name.nullable()
|
|
47256
|
+
});
|
|
46631
47257
|
/**
|
|
46632
47258
|
* Blank text clears the note, and the setter refuses one past its limit.
|
|
46633
47259
|
* `expected` is the note the edit began from, so one an agent set since is kept.
|
|
@@ -46697,7 +47323,7 @@ const projectTokensSchema = object$1({
|
|
|
46697
47323
|
* frame hugs the player's height.
|
|
46698
47324
|
*/
|
|
46699
47325
|
function mediaMarkup(ref, path, kind, { width, height }) {
|
|
46700
|
-
const tag = kind
|
|
47326
|
+
const tag = assetTag(kind);
|
|
46701
47327
|
if (width === void 0 || tag !== "audio" && height === void 0) throw new FrameboardError("usage", `A frame added with an asset takes the media's width${tag === "audio" ? "" : " and height"}.`, {
|
|
46702
47328
|
ref,
|
|
46703
47329
|
path
|
|
@@ -46883,6 +47509,7 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
46883
47509
|
await refuseHeld([targetRef]);
|
|
46884
47510
|
const { asset: path, ...placing } = body;
|
|
46885
47511
|
let media;
|
|
47512
|
+
let head;
|
|
46886
47513
|
if (path !== void 0) {
|
|
46887
47514
|
const asset = await resolveAsset(join(root, target.project), path);
|
|
46888
47515
|
if (!asset.ok) return c.json({
|
|
@@ -46897,10 +47524,15 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
46897
47524
|
}
|
|
46898
47525
|
}, 409);
|
|
46899
47526
|
media = mediaMarkup(targetRef, path, asset.kind, body);
|
|
47527
|
+
if (asset.kind === "model") {
|
|
47528
|
+
await ensureViewer(join(root, target.project));
|
|
47529
|
+
head = VIEWER_SCRIPT;
|
|
47530
|
+
}
|
|
46900
47531
|
}
|
|
46901
47532
|
const frame = await recorded((journal) => addFrame(root, body.ref, {
|
|
46902
47533
|
...placing,
|
|
46903
47534
|
body: media,
|
|
47535
|
+
head,
|
|
46904
47536
|
cwd,
|
|
46905
47537
|
journal
|
|
46906
47538
|
}), (added) => onFrames([added.ref]));
|
|
@@ -46964,14 +47596,15 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
46964
47596
|
data: frames
|
|
46965
47597
|
});
|
|
46966
47598
|
});
|
|
46967
|
-
/** Shows or hides each frame's device, names the foldable,
|
|
47599
|
+
/** Shows or hides each frame's device, names the foldable, folds it, or picks a phone's island, in one step, leaving every frame file alone. */
|
|
46968
47600
|
app.post("/api/frame/device", async (c) => {
|
|
46969
47601
|
const body = await parseBody$1(c.req.raw, frameDeviceSchema);
|
|
46970
47602
|
const frames = await eachFrame(body.refs, (frame, journal) => setFrameDevice(root, frame, body.show, {
|
|
46971
47603
|
cwd,
|
|
46972
47604
|
journal,
|
|
46973
47605
|
foldable: body.foldable,
|
|
46974
|
-
pose: body.pose
|
|
47606
|
+
pose: body.pose,
|
|
47607
|
+
island: body.island
|
|
46975
47608
|
}), (records) => records.map((record) => record.ref));
|
|
46976
47609
|
return c.json({
|
|
46977
47610
|
ok: true,
|
|
@@ -47010,6 +47643,18 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
47010
47643
|
data: frames
|
|
47011
47644
|
});
|
|
47012
47645
|
});
|
|
47646
|
+
/** Sets or clears the project kit each frame draws with, in one step, leaving every frame file alone. */
|
|
47647
|
+
app.post("/api/frame/kit", async (c) => {
|
|
47648
|
+
const body = await parseBody$1(c.req.raw, frameKitSchema);
|
|
47649
|
+
const frames = await eachFrame(body.refs, (frame, journal) => setFrameKit(root, frame, body.kit, {
|
|
47650
|
+
cwd,
|
|
47651
|
+
journal
|
|
47652
|
+
}), (records) => records.map((record) => record.ref));
|
|
47653
|
+
return c.json({
|
|
47654
|
+
ok: true,
|
|
47655
|
+
data: frames
|
|
47656
|
+
});
|
|
47657
|
+
});
|
|
47013
47658
|
/** Sets or clears one frame's speaker note in one step, leaving its file alone. */
|
|
47014
47659
|
app.post("/api/frame/speaker-notes", async (c) => {
|
|
47015
47660
|
const body = await parseBody$1(c.req.raw, frameSpeakerNotesSchema);
|
|
@@ -47604,16 +48249,22 @@ async function withFrameHost(board, purpose, run) {
|
|
|
47604
48249
|
}
|
|
47605
48250
|
}
|
|
47606
48251
|
// src/server/capture/images.ts
|
|
47607
|
-
/** The `videos`
|
|
47608
|
-
function
|
|
47609
|
-
return
|
|
48252
|
+
/** The `videos` and `models` keys of an image, each left off when every one loaded. */
|
|
48253
|
+
function unloadedKeys(videos, models) {
|
|
48254
|
+
return {
|
|
48255
|
+
...videos.length === 0 ? {} : { videos },
|
|
48256
|
+
...models.length === 0 ? {} : { models }
|
|
48257
|
+
};
|
|
47610
48258
|
}
|
|
47611
|
-
function inFrame(ref,
|
|
47612
|
-
return
|
|
48259
|
+
function inFrame(ref, unloaded) {
|
|
48260
|
+
return unloaded.map((each) => ({
|
|
47613
48261
|
ref,
|
|
47614
|
-
...
|
|
48262
|
+
...each
|
|
47615
48263
|
}));
|
|
47616
48264
|
}
|
|
48265
|
+
function keysIn(ref, { videos, models }) {
|
|
48266
|
+
return unloadedKeys(inFrame(ref, videos), inFrame(ref, models));
|
|
48267
|
+
}
|
|
47617
48268
|
const SCREENSHOT = {
|
|
47618
48269
|
animations: "disabled",
|
|
47619
48270
|
caret: "hide"
|
|
@@ -47706,7 +48357,7 @@ async function captureFrameImages(browser, { baseUrl, frames, themes, out, scale
|
|
|
47706
48357
|
height: view.height,
|
|
47707
48358
|
scale,
|
|
47708
48359
|
...shot.scrollY === void 0 ? {} : { scrollY: shot.scrollY },
|
|
47709
|
-
...
|
|
48360
|
+
...keysIn(frame.ref, shot),
|
|
47710
48361
|
bytes: shot.bytes
|
|
47711
48362
|
});
|
|
47712
48363
|
}
|
|
@@ -47731,10 +48382,12 @@ async function captureComposite(browser, { baseUrl, page, frames, themes, out, s
|
|
|
47731
48382
|
for (const theme of themes) {
|
|
47732
48383
|
const tiles = [];
|
|
47733
48384
|
const videos = /* @__PURE__ */ new Map();
|
|
48385
|
+
const models = /* @__PURE__ */ new Map();
|
|
47734
48386
|
for (const frame of frames) for (const box of [frame.box, ...linkedBoxes(frame.box, frame.widths, frame.device)]) {
|
|
47735
|
-
const
|
|
47736
|
-
for (const video of inFrame(frame.ref,
|
|
47737
|
-
|
|
48387
|
+
const shot = await renderFrame(browser, baseUrl, frame, box, theme, scale);
|
|
48388
|
+
for (const video of inFrame(frame.ref, shot.videos)) videos.set(`${video.ref} ${video.index}`, video);
|
|
48389
|
+
for (const model of inFrame(frame.ref, shot.models)) models.set(`${model.ref} ${model.index}`, model);
|
|
48390
|
+
tiles.push(`<img src="data:image/png;base64,${shot.bytes.toString("base64")}" style="position:absolute;left:${box.x + bounds.dx}px;top:${box.y + bounds.dy}px;width:${box.width}px;height:${box.height}px">`);
|
|
47738
48391
|
}
|
|
47739
48392
|
rendered.push({
|
|
47740
48393
|
ref: page.ref,
|
|
@@ -47743,7 +48396,7 @@ async function captureComposite(browser, { baseUrl, page, frames, themes, out, s
|
|
|
47743
48396
|
width: bounds.width,
|
|
47744
48397
|
height: bounds.height,
|
|
47745
48398
|
scale,
|
|
47746
|
-
...
|
|
48399
|
+
...unloadedKeys([...videos.values()], [...models.values()]),
|
|
47747
48400
|
bytes: await renderComposite(browser, bounds, theme, tiles, scale)
|
|
47748
48401
|
});
|
|
47749
48402
|
}
|
|
@@ -47764,7 +48417,8 @@ async function captureMotionImages(browser, { baseUrl, frame, themes, out, scale
|
|
|
47764
48417
|
baseUrl,
|
|
47765
48418
|
frame: {
|
|
47766
48419
|
ref: frame.ref,
|
|
47767
|
-
box: view
|
|
48420
|
+
box: view,
|
|
48421
|
+
device: viewDevice(frame, view)
|
|
47768
48422
|
},
|
|
47769
48423
|
theme,
|
|
47770
48424
|
scale,
|
|
@@ -47780,7 +48434,7 @@ async function captureMotionImages(browser, { baseUrl, frame, themes, out, scale
|
|
|
47780
48434
|
height: strip.height,
|
|
47781
48435
|
scale,
|
|
47782
48436
|
moments: strip.moments,
|
|
47783
|
-
...
|
|
48437
|
+
...keysIn(frame.ref, strip),
|
|
47784
48438
|
bytes: strip.bytes
|
|
47785
48439
|
});
|
|
47786
48440
|
continue;
|
|
@@ -47789,6 +48443,7 @@ async function captureMotionImages(browser, { baseUrl, frame, themes, out, scale
|
|
|
47789
48443
|
baseUrl,
|
|
47790
48444
|
ref: frame.ref,
|
|
47791
48445
|
view,
|
|
48446
|
+
device: viewDevice(frame, view),
|
|
47792
48447
|
theme,
|
|
47793
48448
|
scale,
|
|
47794
48449
|
motionTimeoutMs,
|
|
@@ -47804,7 +48459,7 @@ async function captureMotionImages(browser, { baseUrl, frame, themes, out, scale
|
|
|
47804
48459
|
height: view.height,
|
|
47805
48460
|
scale,
|
|
47806
48461
|
at: held,
|
|
47807
|
-
...
|
|
48462
|
+
...keysIn(frame.ref, shots),
|
|
47808
48463
|
bytes
|
|
47809
48464
|
});
|
|
47810
48465
|
});
|
|
@@ -47825,10 +48480,11 @@ async function renderFilmstrip(browser, { baseUrl, frame, theme, scale = 1, coun
|
|
|
47825
48480
|
height: frame.box.height
|
|
47826
48481
|
};
|
|
47827
48482
|
const strip = filmstripBounds(frame.ref, view, count, scale);
|
|
47828
|
-
const { motion, held, videos } = await holdShots(browser, {
|
|
48483
|
+
const { motion, held, videos, models } = await holdShots(browser, {
|
|
47829
48484
|
baseUrl,
|
|
47830
48485
|
ref: frame.ref,
|
|
47831
48486
|
view,
|
|
48487
|
+
device: frame.device,
|
|
47832
48488
|
theme,
|
|
47833
48489
|
scale,
|
|
47834
48490
|
motionTimeoutMs,
|
|
@@ -47840,61 +48496,81 @@ async function renderFilmstrip(browser, { baseUrl, frame, theme, scale = 1, coun
|
|
|
47840
48496
|
height: strip.height,
|
|
47841
48497
|
moments: held.map((shot) => shot.held),
|
|
47842
48498
|
motion,
|
|
47843
|
-
videos
|
|
48499
|
+
videos,
|
|
48500
|
+
models
|
|
47844
48501
|
};
|
|
47845
48502
|
}
|
|
47846
48503
|
/**
|
|
47847
48504
|
* Opens one frame with its animation clock held, finds its timeline, and
|
|
47848
48505
|
* shoots it at each moment `moments` picks from what it found.
|
|
47849
48506
|
*/
|
|
47850
|
-
async function holdShots(browser, { baseUrl, ref, view, theme, scale, motionTimeoutMs, moments }) {
|
|
48507
|
+
async function holdShots(browser, { baseUrl, ref, view, device, theme, scale, motionTimeoutMs, moments }) {
|
|
47851
48508
|
assertScreenshotFits(ref, view, scale);
|
|
47852
48509
|
const opened = await openFrame(browser, {
|
|
47853
48510
|
baseUrl,
|
|
47854
48511
|
ref,
|
|
47855
|
-
box: view,
|
|
48512
|
+
box: pageSize(view, device),
|
|
47856
48513
|
theme,
|
|
47857
48514
|
scale,
|
|
47858
48515
|
motion: "hold"
|
|
47859
48516
|
});
|
|
47860
48517
|
try {
|
|
47861
48518
|
const motion = await findMotion(opened.page, ref, motionTimeoutMs);
|
|
48519
|
+
const colors = topInset(device) > 0 ? await readPageColors(opened.page) : null;
|
|
47862
48520
|
const held = [];
|
|
47863
48521
|
for (const moment of moments(motion)) {
|
|
47864
48522
|
const at = await seekMotion(opened.page, motion, moment);
|
|
48523
|
+
const shot = await opened.page.screenshot(HELD_SCREENSHOT);
|
|
47865
48524
|
held.push({
|
|
47866
48525
|
held: at,
|
|
47867
|
-
bytes: await
|
|
48526
|
+
bytes: colors ? await underStatusBar(browser, shot, view, {
|
|
48527
|
+
colors,
|
|
48528
|
+
theme
|
|
48529
|
+
}, scale) : shot
|
|
47868
48530
|
});
|
|
47869
48531
|
}
|
|
47870
48532
|
return {
|
|
47871
48533
|
motion,
|
|
47872
48534
|
held,
|
|
47873
|
-
videos: opened.videos
|
|
48535
|
+
videos: opened.videos,
|
|
48536
|
+
models: opened.models
|
|
47874
48537
|
};
|
|
47875
48538
|
} finally {
|
|
47876
48539
|
await opened.close();
|
|
47877
48540
|
}
|
|
47878
48541
|
}
|
|
48542
|
+
/**
|
|
48543
|
+
* The device a view draws its page under: the frame's own while the view
|
|
48544
|
+
* is the frame's own box, and none at a linked width, which draws no device.
|
|
48545
|
+
*/
|
|
48546
|
+
function viewDevice(frame, view) {
|
|
48547
|
+
return view.width === frame.box.width ? frame.device : void 0;
|
|
48548
|
+
}
|
|
47879
48549
|
async function renderFrame(browser, baseUrl, frame, view, theme, scale, scroll) {
|
|
47880
48550
|
const box = {
|
|
47881
48551
|
width: view.width,
|
|
47882
48552
|
height: view.height
|
|
47883
48553
|
};
|
|
47884
48554
|
assertScreenshotFits(frame.ref, box, scale);
|
|
48555
|
+
const device = viewDevice(frame, view);
|
|
47885
48556
|
const opened = await openFrame(browser, {
|
|
47886
48557
|
baseUrl,
|
|
47887
48558
|
ref: frame.ref,
|
|
47888
|
-
box,
|
|
48559
|
+
box: pageSize(box, device),
|
|
47889
48560
|
theme,
|
|
47890
48561
|
scale
|
|
47891
48562
|
});
|
|
47892
48563
|
try {
|
|
47893
48564
|
const scrollY = scroll === void 0 ? void 0 : await opened.page.evaluate(scrollAndSettle, scroll);
|
|
48565
|
+
const shot = await opened.page.screenshot(SCREENSHOT);
|
|
47894
48566
|
return {
|
|
47895
|
-
bytes: await
|
|
48567
|
+
bytes: topInset(device) > 0 ? await underStatusBar(browser, shot, box, {
|
|
48568
|
+
colors: await readPageColors(opened.page),
|
|
48569
|
+
theme
|
|
48570
|
+
}, scale) : shot,
|
|
47896
48571
|
scrollY,
|
|
47897
|
-
videos: opened.videos
|
|
48572
|
+
videos: opened.videos,
|
|
48573
|
+
models: opened.models
|
|
47898
48574
|
};
|
|
47899
48575
|
} finally {
|
|
47900
48576
|
await opened.close();
|
|
@@ -48065,9 +48741,13 @@ async function pageOf(root, ref, options) {
|
|
|
48065
48741
|
const { pages } = await readPageOrder(join(root, resolved.project));
|
|
48066
48742
|
return scanPage(root, resolved.project, resolved.page, pages.indexOf(resolved.page));
|
|
48067
48743
|
}
|
|
48068
|
-
/** One line per image written, and under it one per video it shows with no picture. */
|
|
48744
|
+
/** One line per image written, and under it one per video or model it shows with no picture. */
|
|
48069
48745
|
function describe$6(images) {
|
|
48070
|
-
return images.flatMap((image) => [
|
|
48746
|
+
return images.flatMap((image) => [
|
|
48747
|
+
`Wrote ${image.path}`,
|
|
48748
|
+
...(image.videos ?? []).map((video) => ` No picture for the video ${video.src} at element ${video.index} of ${video.ref}, which ${video.state === "error" ? "failed to load" : "was still loading when the load budget ran out"}`),
|
|
48749
|
+
...(image.models ?? []).map((model) => ` No model drawn for ${model.src} at element ${model.index} of ${model.ref}, which ${model.state === "error" ? "failed to load" : "was still loading when the load budget ran out"}`)
|
|
48750
|
+
]).join("\n");
|
|
48071
48751
|
}
|
|
48072
48752
|
// src/cli/board-server.ts
|
|
48073
48753
|
/** How long a running server has to answer before the verb gives up on it. */
|
|
@@ -48327,10 +49007,14 @@ const frameRecordSchema = object$1({
|
|
|
48327
49007
|
device: _enum$1(DEVICES).optional(),
|
|
48328
49008
|
/** The pose a frame naming the foldable is folded to, shown or not, absent on every other frame. */
|
|
48329
49009
|
pose: _enum$1(POSES).optional(),
|
|
49010
|
+
/** `wide` while the frame picks the phone's wide island, shown or not, absent for the compact one. */
|
|
49011
|
+
island: literal("wide").optional(),
|
|
48330
49012
|
/** The transition the frame arrives with in present mode, over its page's, absent when it holds none. */
|
|
48331
49013
|
transition: transitionRecordSchema.optional(),
|
|
48332
49014
|
/** What the presenter means to say over the slide, plain text with its line breaks, absent when it holds none. */
|
|
48333
49015
|
speakerNotes: string$1().optional(),
|
|
49016
|
+
/** The project kit the frame names, absent when it names none, and still given where the project holds no such kit. */
|
|
49017
|
+
kit: string$1().optional(),
|
|
48334
49018
|
placed: boolean$1(),
|
|
48335
49019
|
modifiedAt: string$1()
|
|
48336
49020
|
});
|
|
@@ -48359,6 +49043,15 @@ const pageRecordSchema = object$1({
|
|
|
48359
49043
|
/** Bottom first, as frames are. */
|
|
48360
49044
|
sections: array$1(sectionRecordSchema)
|
|
48361
49045
|
});
|
|
49046
|
+
/** One kit a project added, a folder under its `assets/kits/`. */
|
|
49047
|
+
const projectKitRecordSchema = object$1({
|
|
49048
|
+
/** The kit's folder, which a frame's `kit` and `frame kit` name it by. */
|
|
49049
|
+
name: string$1(),
|
|
49050
|
+
/** The name a person reads, the folder's where its `kit.json` gives none. */
|
|
49051
|
+
title: string$1(),
|
|
49052
|
+
/** How many of the project's frames name the kit. */
|
|
49053
|
+
frameCount: number()
|
|
49054
|
+
});
|
|
48362
49055
|
const projectRecordSchema = object$1({
|
|
48363
49056
|
/** The folder, which every ref, URL, and CLI argument names the project by. */
|
|
48364
49057
|
name: string$1(),
|
|
@@ -48377,6 +49070,8 @@ const projectRecordSchema = object$1({
|
|
|
48377
49070
|
transitions: array$1(string$1()),
|
|
48378
49071
|
/** The rule ids `checks.off` in `project.json` turns off, in the file's order and each once, empty when it holds none. */
|
|
48379
49072
|
checksOff: array$1(string$1()),
|
|
49073
|
+
/** The kits the project added, by name, empty when it holds none. */
|
|
49074
|
+
kits: array$1(projectKitRecordSchema),
|
|
48380
49075
|
pages: array$1(pageRecordSchema)
|
|
48381
49076
|
});
|
|
48382
49077
|
const listResultSchema = object$1({
|
|
@@ -48411,6 +49106,16 @@ const captureResultSchema = object$1({
|
|
|
48411
49106
|
src: string$1(),
|
|
48412
49107
|
/** `error` for a file that failed to load or decode, `pending` for one still loading when the load budget ran out. */
|
|
48413
49108
|
state: _enum$1(["error", "pending"])
|
|
49109
|
+
})).optional(),
|
|
49110
|
+
/** Each model the image shows undrawn, absent when every model loaded. */
|
|
49111
|
+
models: array$1(object$1({
|
|
49112
|
+
/** The frame holding the model, which a composite needs to tell its frames apart. */
|
|
49113
|
+
ref: string$1(),
|
|
49114
|
+
/** The element's index in document order, as `edit --index` takes it. */
|
|
49115
|
+
index: int$1().min(0),
|
|
49116
|
+
src: string$1(),
|
|
49117
|
+
/** `error` for a model or a viewer script that failed to load, `pending` for one still loading when the load budget ran out. */
|
|
49118
|
+
state: _enum$1(["error", "pending"])
|
|
48414
49119
|
})).optional()
|
|
48415
49120
|
})),
|
|
48416
49121
|
/** The timeline an `--at` or `--filmstrip` capture seeked, absent on any other. */
|
|
@@ -48418,7 +49123,8 @@ const captureResultSchema = object$1({
|
|
|
48418
49123
|
source: _enum$1([
|
|
48419
49124
|
"hf",
|
|
48420
49125
|
"timelines",
|
|
48421
|
-
"css"
|
|
49126
|
+
"css",
|
|
49127
|
+
"model"
|
|
48422
49128
|
]),
|
|
48423
49129
|
/** Its length in ms, or null when every animation repeats forever. */
|
|
48424
49130
|
duration: int$1().min(0).nullable()
|
|
@@ -48889,7 +49595,9 @@ function contentFormat() {
|
|
|
48889
49595
|
"hidden, locked, hugWidth, hugHeight, and scroll read as false when absent, and an axis whose hug flag is false holds the size its entry states.",
|
|
48890
49596
|
`scroll marks a frame that holds a fixed screen height and scrolls past it, such as a page with a sticky section. It fixes both axes, so either hug flag beside it reads as false, frame fit refuses it, and serve never measures it. frame add --scroll sets it, taking the height given or else the preset height of the width (${FRAME_SIZES.desktop.height} px at ${FRAME_SIZES.desktop.width}). frame resize --scroll sets it on a placed frame, dropping a hugging height to that preset height unless a height is given and keeping a fixed height as it stands, so resize a frame fixed past a screen with --height too. frame resize --no-scroll clears it, keeping the box.`,
|
|
48891
49597
|
`widths lists the extra widths one frame file also shows at, as { width, height } objects, each drawn 80 px past the last in a row beside the frame at its y, so a responsive page is one file rather than a copy per width. Each width follows the frame's own height mode: it hugs its content at that width while hugHeight is on, and otherwise holds its height, the preset height of its width when first set and on frame resize --scroll. A value of any other shape reads as none. frame add --widths 834,390 and frame resize --widths set it, refusing a repeated width, the frame's own width, or a frame hugging its width, and frame resize --no-widths clears it. capture writes <frame>@<width>.<theme>.png beside <frame>.<theme>.png, check reports a browser finding at a linked width with that width and prints it as <path>@<width>, and a frames.json value of <project>/<page>/<frame>@<width> syncs that width's images.`,
|
|
48892
|
-
`showDevice true has the board draw the frame inside the device its width names: a phone from 320 to 479 px wide, a tablet from 480 to 1023, and a laptop from 1024 up, with none under 320. The phone's body stands ${BEZELS.phone.border} px past the box on every side and the tablet's ${BEZELS.tablet.border}, and the laptop's lid ${BEZELS.laptop.border} px past its top and sides, with a chin and a wider base below. A resize redraws the body with no write, and list reports the device the width names as device, absent when off or under 320. It never changes the frame file, its size, or its box. frame add, frame duplicate, and a paste place a frame beside another with its own body, a laptop's base included, 80 px past the other's body. A frame given --x keeps that x, a frame landing in a reserved box keeps that box with no room for a device, and a placed frame stays where it stands when its device turns on. Linked widths draw no device. Any other value of showDevice reads as off and is kept on write. A device string from before showDevice reads as on, and the entry's next write replaces it with showDevice. frame add --device on and frame device <frame-ref> <on|off> set it, taking phone and tablet as on and none as off.`,
|
|
49598
|
+
`showDevice true has the board draw the frame inside the device its width names: a phone from 320 to 479 px wide, a tablet from 480 to 1023, and a laptop from 1024 up, with none under 320. The phone's body stands ${BEZELS.phone.border} px past the box on every side, with side buttons 4 px past that, and the tablet's ${BEZELS.tablet.border}, and the laptop's lid ${BEZELS.laptop.border} px past its top and sides, with a chin and a wider base below. A resize redraws the body with no write, and list reports the device the width names as device, absent when off or under 320. It never changes the frame file, its size, or its box. frame add, frame duplicate, and a paste place a frame beside another with its own body, a laptop's base included, 80 px past the other's body. A frame given --x keeps that x, a frame landing in a reserved box keeps that box with no room for a device, and a placed frame stays where it stands when its device turns on. Linked widths draw no device. Any other value of showDevice reads as off and is kept on write. A device string from before showDevice reads as on, and the entry's next write replaces it with showDevice. frame add --device on and frame device <frame-ref> <on|off> set it, taking phone and tablet as on and none as off.`,
|
|
49599
|
+
`While a phone shows, the board draws a status bar over the top ${STATUS_BAR.height} px of the frame's box, in the page's own fill and text color, and the page starts under it: a frame ${FRAME_SIZES.phone.width} by ${FRAME_SIZES.phone.height} shows a page ${FRAME_SIZES.phone.width} by ${FRAME_SIZES.phone.height - STATUS_BAR.height}. The box in layout.json keeps the screen's size, and the frame file gains no padding. A hugging height measures the page and stores it plus the bar, frame fit does the same, and capture, check, inspect, and present each read the page under the bar. An export draws the bar only with its device included, and lays the page out at the whole box without it. A linked width draws no device and no bar. With the device off, or on any other device, the page is the whole box.`,
|
|
49600
|
+
`island wide has a phone draw its wide island, the one a call or a timer shows, and absent draws the compact one. It is kept while the device is off and reads as compact on any other device. Any other value reads as compact and is kept on write. frame device <frame-ref> --island wide sets it, --island compact clears it, and both refuse a frame whose width names no phone or that names the foldable.`,
|
|
48893
49601
|
`foldable true has the frame name the foldable device over the one its width picks, and pose folds it: closed is the cover screen at ${POSE_SIZES.closed.width} by ${POSE_SIZES.closed.height}, and half and open are the inner screen at ${POSE_SIZES.open.width} by ${POSE_SIZES.open.height}, half shading the fold. Naming a foldable or setting a pose sets the box's width and height to that screen and turns both hug flags off, and writes the layout entry alone, never the frame file, so one file shows every pose and its content reflows as on the device. The body stands ${BEZELS.foldable.border} px past the box on every side. A newly named foldable starts in the pose nearest its width, closed up to 678 px wide and open past it. list reports device as foldable while it shows, and pose on every frame naming one, shown or not. With showDevice off the box keeps its pose's size and no body draws. A foldable draws no linked width and refuses a new one, and widths its entry held from before stay in the file undrawn, draw again once --no-foldable un-names it, and clear on frame resize --no-widths. Any other value of foldable reads as width-picked, a pose no reader knows reads as closed, and both are kept on write. An older Frameboard rewriting the entry may drop both keys, leaving a width-picked frame at the pose's size. frame device <frame-ref> --foldable names it and shows it, --pose <closed|half|open> folds it, and --no-foldable hands the pick back to the width at the size it stands.`,
|
|
48894
49602
|
`An axis that hugs takes its size from the frame's content: a running serve measures it after each write to the frame file and when frame add places a file already written, its width at most ${FRAME_SIZES.desktop.width} px, and writes width and height alone, never a flag. Content sized off the viewport keeps the box it has.`,
|
|
48895
49603
|
"frame add with no size hugs both axes, --size or --width fixes the width and hugs the height, and --height fixes the height alone, its box standing in until serve measures. frame resize and a hand resize fix each axis they set, and frame fit sets the height and turns hugHeight on.",
|
|
@@ -48915,8 +49623,10 @@ function contentFormat() {
|
|
|
48915
49623
|
],
|
|
48916
49624
|
kits: [
|
|
48917
49625
|
`A kit is a folder of plain files: ${KIT_FILE} naming it, ${TOKEN_FILE} with a light and a dark block, ${KIT_SHEET} of component styles, ${KIT_NOTE} saying what to reach for, and a kit page of sample frames. The tool ships ${SHIPPED_KITS.join(", ")}, and a board keeps the kits saved from its projects in ${KITS_FOLDER}/.`,
|
|
48918
|
-
`kit add copies the kit's
|
|
48919
|
-
`
|
|
49626
|
+
`kit add copies the kit's folder into the project's ${ASSETS_FOLDER}/${PROJECT_KITS}/<kit>/ and writes no token sheet and no page, so a project holds several kits beside its own look. It refuses name-taken where the project already holds a kit by that name, and accepts --replace without acting on it. kit remove deletes that folder and clears the kit from every frame naming it, refusing kit-not-found for a kit the project lacks. kit save refuses name-taken for a name a shipped or saved kit holds, and tokens-not-found for a project no sheet reaches.`,
|
|
49627
|
+
`A frame draws with a kit only where its ${LAYOUT_FILE} entry names one under kit. frame kit <frame-ref> <kit> sets it and frame kit <frame-ref> ${NO_KIT_WORD} clears it, each writing ${LAYOUT_FILE} alone, and it refuses kit-not-found for a kit the project lacks. The frame file never names the kit, so rewriting the frame keeps it. list --json answers kit on each frame naming one and kits on each project, with every kit's name, title, and frameCount.`,
|
|
49628
|
+
`The server imports ${ASSETS_FOLDER}/${PROJECT_KITS}/<kit>/${TOKEN_FILE} then ${KIT_SHEET} into a frame naming that kit, after the project sheet, and check reads the same sheets. A plain frame beside it loads neither, and a frame naming a kit whose folder is gone loads none and keeps the name. Read ${ASSETS_FOLDER}/${PROJECT_KITS}/<kit>/${KIT_NOTE} and the sample frames under its kit/ folder before drawing a frame that names it.`,
|
|
49629
|
+
`A project holding ${ASSETS_FOLDER}/kit/${KIT_FILE} took its kit before a frame could name one, and every frame in it still loads ${ASSETS_FOLDER}/kit/${KIT_SHEET} after the project sheet. An ${ASSETS_FOLDER}/kit/ holding no ${KIT_FILE} is loaded into no frame, so a frame using it links it itself.`
|
|
48920
49630
|
],
|
|
48921
49631
|
images: [
|
|
48922
49632
|
`image find searches Openverse under ${DEFAULT_LICENSES.join(", ")} alone, and --credited widens it to ${CREDITED_LICENSES.join(", ")}. It lists up to 20 results numbered from 1 and writes nothing. --save <number> runs the search again and saves that result, and --save <id> saves the Openverse image with that id with no search, refusing result-not-found for an id under a license the flags do not allow. Openverse allows an address 200 anonymous requests a day, so save by id.`,
|
|
@@ -48925,10 +49635,16 @@ function contentFormat() {
|
|
|
48925
49635
|
"image doctor reports the GPU nvidia-smi names, whether a ComfyUI server answers at FRAMEBOARD_COMFYUI_URL or the default address, and each key as set or unset, never its value. It installs and spends nothing.",
|
|
48926
49636
|
`A frame links a saved image as ../${ASSETS_FOLDER}/<path>, never by its web address, since a frame loads nothing over the network.`
|
|
48927
49637
|
],
|
|
49638
|
+
models: [
|
|
49639
|
+
`A frame shows a 3D model through one <${VIEWER_TAG} src="../${ASSETS_FOLDER}/<file>.glb" alt=""> element, sized by its own width and height as an image is. It reads .glb and .gltf alone, and a .gltf carries its buffers and images inside itself. A drop refuses ${FOREIGN_MODELS.join(", ")}, so export any of those from Blender through File, Export, glTF 2.0 as a glTF Binary (.glb).`,
|
|
49640
|
+
`The element draws only in a frame whose head loads the viewer, as ${VIEWER_SCRIPT}. Placing a model on the board copies ${VIEWER_FILE} into the project's ${ASSETS_FOLDER}/ once and adds that tag to a head loading no viewer, and removing the last model leaves both. The file ships with the tool at ${shippedViewerPath()}, so copy it to the project's ${ASSETS_FOLDER}/${VIEWER_FILE} before writing the element in a project that holds none. A frame loads nothing over the network, so never link the viewer from a CDN.`,
|
|
49641
|
+
`Every staging control is an attribute on the element, set with edit --attr. camera-orbit="<theta>deg <phi>deg <radius>" places the camera, across and then down from the top, and defaults to 0deg 75deg auto. The viewer holds the camera inside max-camera-orbit, so state both once the radius passes the model's own framing, as camera-orbit="30deg 70deg 6m" max-camera-orbit="auto auto 6m". orientation="<roll>deg <pitch>deg <yaw>deg" turns the model itself, scale="<x> <y> <z>" sizes it, animation-name picks one of its clips, and autoplay starts it. The board's Model section writes these same attributes, the angle as both orbit attributes in one undo step, and a double-click on a selected model turns it by drag.`,
|
|
49642
|
+
`check reports missing-file at error for a ${VIEWER_TAG} whose ${MODEL_LOADS.join(", ")} names no file, as it does for the viewer script. capture waits for each model to draw inside the frame's load budget and holds its clip at the start, and --at seeks every clip to that moment, so two captures match. A model that fails to load, or is still loading when the budget ends, never refuses: the image lists it under models with state error or pending.`
|
|
49643
|
+
],
|
|
48928
49644
|
assets: `A frame links files in its own page folder or in its project's ${ASSETS_FOLDER}/ folder. frame duplicate and frame move carry the ${FRAME_EXTENSION} file alone, so keep files shared between frames or pages in ${ASSETS_FOLDER}/.`,
|
|
48929
49645
|
look: [
|
|
48930
49646
|
`The board's ${TOKEN_FILE} holds the design tokens every project shares, and a project's own ${TOKEN_FILE} overrides it. serve --tokens <path> stands in for the board's sheet, resolved against the working folder and recorded as tokens in ${RUN_FOLDER}/${ADDRESS_FILE} while that server runs.`,
|
|
48931
|
-
`The server puts one <style ${LOOK_MARKER}> first in each frame's head, importing the faces, then the board sheet, then the project sheet, then
|
|
49647
|
+
`The server puts one <style ${LOOK_MARKER}> first in each frame's head, importing the faces, then the board sheet, then the project sheet, then the sheets of the kit the frame names, so a frame's own sheets win. The file on disk never changes, and a count of a live frame's elements skips elements carrying ${LOOK_MARKER}.`,
|
|
48932
49648
|
`Every frame can use the families ${FACES.map((face) => face.family).join(", ")} with no link of its own. A project adds other faces in its ${ASSETS_FOLDER}/ folder.`,
|
|
48933
49649
|
"The board sets data-theme and color-scheme to light or dark on each frame's root, with the class dark or light, so define both themes through [data-theme], .dark, prefers-color-scheme, or light-dark(), or take every color from token variables. Never paste a token sheet into a frame.",
|
|
48934
49650
|
`A change to a token sheet reloads every frame it reaches.`,
|
|
@@ -48986,6 +49702,8 @@ function formatLines(format) {
|
|
|
48986
49702
|
...format.kits.map((line) => `${INDENT}${line}`),
|
|
48987
49703
|
"Images",
|
|
48988
49704
|
...format.images.map((line) => `${INDENT}${line}`),
|
|
49705
|
+
"Models",
|
|
49706
|
+
...format.models.map((line) => `${INDENT}${line}`),
|
|
48989
49707
|
"Assets",
|
|
48990
49708
|
`${INDENT}${format.assets}`,
|
|
48991
49709
|
"Look",
|
|
@@ -49308,11 +50026,11 @@ const DEVICE_ON = [
|
|
|
49308
50026
|
"tablet"
|
|
49309
50027
|
];
|
|
49310
50028
|
/** What `frame device` did, naming the device the frame draws inside and a foldable's pose. */
|
|
49311
|
-
function deviceHeadline({ ref, box, showDevice, device, pose }) {
|
|
50029
|
+
function deviceHeadline({ ref, box, showDevice, device, pose, island }) {
|
|
49312
50030
|
const folded = pose ? `, folded ${pose} at ${box.width} by ${box.height}` : "";
|
|
49313
50031
|
if (!showDevice) return `Hid the device on ${ref}${folded}`;
|
|
49314
50032
|
if (!device) return `Showed the device on ${ref}, though no device fits its ${box.width} px width`;
|
|
49315
|
-
return `Showed the ${device} on ${ref}${folded}`;
|
|
50033
|
+
return `Showed the ${device} on ${ref}${folded}${device === "phone" ? ` with the ${islandOf(island)} island` : ""}`;
|
|
49316
50034
|
}
|
|
49317
50035
|
const WIDTHS_HELP = "the extra widths the frame also shows at, a comma list such as 834,390, each drawn beside it and hugging or holding its height as the frame does";
|
|
49318
50036
|
const POSITIVE = parseInteger(1);
|
|
@@ -49394,14 +50112,15 @@ function registerFrame(program, context) {
|
|
|
49394
50112
|
human: `Deleted frame ${result.deleted}`
|
|
49395
50113
|
};
|
|
49396
50114
|
});
|
|
49397
|
-
act(verb("device", "Show or hide the device the board draws around a frame, the phone, tablet, or laptop its width names or the foldable the frame names,
|
|
49398
|
-
if (value === void 0 && foldable === void 0 && pose === void 0) throw new FrameboardError("usage", "frame device takes on or off, --foldable, --no-foldable, or --
|
|
50115
|
+
act(verb("device", "Show or hide the device the board draws around a frame, the phone, tablet, or laptop its width names or the foldable the frame names, fold a foldable, and pick a phone’s island, leaving the frame file as it is").addArgument(new Argument("[on|off]", "on to show the device, off to hide it, with phone and tablet taken as on and none as off, and absent to leave it, which --foldable takes as on").choices(Object.keys(DEVICE_SWITCH))).addOption(new Option("--foldable", "name the foldable over the device the width picks, setting the box to the pose nearest its width")).addOption(new Option("--no-foldable", "hand the pick back to the width, leaving the box at its size")).addOption(new Option("--pose <pose>", "fold a foldable, setting its box to 466 by 678 closed and 890 by 626 half or open").choices(POSES)).addOption(new Option("--island <width>", "pick the phone island drawn over a frame 320 to 479 px wide, compact or the wide one a call or a timer shows").choices(ISLANDS)), context, async ([ref = "", value], { foldable, pose, island, ...options }) => {
|
|
50116
|
+
if (value === void 0 && foldable === void 0 && pose === void 0 && island === void 0) throw new FrameboardError("usage", "frame device takes on or off, --foldable, --no-foldable, --pose, or --island.");
|
|
49399
50117
|
const show = value !== void 0 && Object.hasOwn(DEVICE_SWITCH, value) ? DEVICE_SWITCH[value] : void 0;
|
|
49400
50118
|
const record = await setFrameDevice(await boardOf(options, io), ref, show, {
|
|
49401
50119
|
...options,
|
|
49402
50120
|
cwd: io.cwd,
|
|
49403
50121
|
foldable,
|
|
49404
|
-
pose
|
|
50122
|
+
pose,
|
|
50123
|
+
island
|
|
49405
50124
|
});
|
|
49406
50125
|
return {
|
|
49407
50126
|
data: record,
|
|
@@ -49415,6 +50134,13 @@ function registerFrame(program, context) {
|
|
|
49415
50134
|
});
|
|
49416
50135
|
return done(record, record.transition ? `Set ${transitionLabel(record.transition.name)} on` : "Cleared the transition on");
|
|
49417
50136
|
});
|
|
50137
|
+
act(verb("kit", `Set the project kit this frame draws with, one \`kit add\` copied into the project, or clear it with ${NO_KIT_WORD} so it draws with the project's sheets alone, writing only layout.json. Refuses kit-not-found for a kit the project holds none under`).argument("<kit>", `a kit the project holds, or ${NO_KIT_WORD}`), context, async ([ref = "", name = ""], options) => {
|
|
50138
|
+
const record = await setFrameKit(await boardOf(options, io), ref, name === "none" ? null : name, {
|
|
50139
|
+
...options,
|
|
50140
|
+
cwd: io.cwd
|
|
50141
|
+
});
|
|
50142
|
+
return done(record, record.kit ? `Set the kit ${record.kit} on` : "Cleared the kit on");
|
|
50143
|
+
});
|
|
49418
50144
|
act(verb("speaker-notes", `Print a slide's speaker note, set it to the text given, or remove it with --clear, writing only layout.json and never the frame file. Plain text up to ${SPEAKER_NOTES_MAX} characters with its line breaks kept, and blank text clears it.`).argument("[text]", "the note to set, in place of the one it holds").option("--clear", "remove the note"), context, async ([ref = "", text], { clear, ...options }) => {
|
|
49419
50145
|
if (clear && text !== void 0) throw new FrameboardError("usage", "Pass the text or --clear, not both.");
|
|
49420
50146
|
const root = await boardOf(options, io);
|
|
@@ -53323,7 +54049,7 @@ async function inspectFrame(browser, { baseUrl, frame, theme, index }) {
|
|
|
53323
54049
|
const opened = await openFrame(browser, {
|
|
53324
54050
|
baseUrl,
|
|
53325
54051
|
ref: frame.ref,
|
|
53326
|
-
box: frame.box,
|
|
54052
|
+
box: pageSize(frame.box, frame.device),
|
|
53327
54053
|
theme
|
|
53328
54054
|
});
|
|
53329
54055
|
let live;
|
|
@@ -53419,28 +54145,36 @@ function describe$3(result) {
|
|
|
53419
54145
|
// src/cli/commands/kit.ts
|
|
53420
54146
|
function registerKit(program, context) {
|
|
53421
54147
|
const { io } = context;
|
|
53422
|
-
const kit = program.command("kit").description("
|
|
53423
|
-
act(addVerb(kit, "list", "List the kits a project can
|
|
54148
|
+
const kit = program.command("kit").description("Add a design kit to a project for its frames to name, remove one, or save a project's look as a kit");
|
|
54149
|
+
act(addVerb(kit, "list", "List the kits a project can add, the shipped ones first and then the board’s own"), context, async (_args, options) => {
|
|
53424
54150
|
const kits = await listKits(await boardOf(options, io));
|
|
53425
54151
|
return {
|
|
53426
54152
|
data: kits,
|
|
53427
54153
|
human: kits.map((each) => `${each.name}\t${each.description}`).join("\n")
|
|
53428
54154
|
};
|
|
53429
54155
|
});
|
|
53430
|
-
act(addVerb(kit, "add", "
|
|
54156
|
+
act(addVerb(kit, "add", "Add a kit to a project as a copy under assets/kits/<kit>/, leaving its token sheets alone, so frame kit can set it on a frame. Refuses name-taken where the project already holds a kit by that name").argument("<project>", "the project").argument("[kit]", "a kit `kit list` names").option("--from <folder>", "add the kit in this folder instead").addOption(new Option("--replace").hideHelp()), context, async ([project = "", name], options) => {
|
|
53431
54157
|
if (name === void 0 === (options.from === void 0)) throw new FrameboardError("usage", "Name a kit or pass --from <folder>, not both.");
|
|
53432
54158
|
const root = await boardOf(options, io);
|
|
53433
54159
|
const folder = options.from === void 0 ? null : resolve$1(io.cwd, options.from);
|
|
53434
54160
|
const record = await installKit(root, project, folder === null ? findKit(root, name ?? "") : {
|
|
53435
54161
|
name: basename(folder),
|
|
53436
54162
|
path: folder
|
|
53437
|
-
}
|
|
54163
|
+
});
|
|
54164
|
+
return {
|
|
54165
|
+
data: record,
|
|
54166
|
+
human: `Added ${record.kit} to ${record.project}`
|
|
54167
|
+
};
|
|
54168
|
+
});
|
|
54169
|
+
act(addVerb(kit, "remove", "Take a kit out of a project, deleting its folder under assets/kits/ and clearing it from every frame naming it, so each draws with the project’s sheets alone. Refuses kit-not-found for a kit the project holds none under").argument("<project>", "the project").argument("<kit>", "a kit the project holds"), context, async ([project = "", name = ""], options) => {
|
|
54170
|
+
const record = await removeKit(await boardOf(options, io), project, name);
|
|
54171
|
+
const count = record.frames.length;
|
|
53438
54172
|
return {
|
|
53439
54173
|
data: record,
|
|
53440
|
-
human: `
|
|
54174
|
+
human: `Removed ${record.kit} from ${record.project}, clearing it from ${count} ${count === 1 ? "frame" : "frames"}`
|
|
53441
54175
|
};
|
|
53442
54176
|
});
|
|
53443
|
-
act(addVerb(kit, "save", "Save a project's tokens, kit files, and kit page as a kit the board's projects can
|
|
54177
|
+
act(addVerb(kit, "save", "Save a project's tokens, kit files, and kit page as a kit the board's projects can add").argument("<project>", "the project").argument("<name>", "the new kit"), context, async ([project = "", name = ""], options) => {
|
|
53444
54178
|
const record = await saveKit(await boardOf(options, io), project, name);
|
|
53445
54179
|
return {
|
|
53446
54180
|
data: record,
|
|
@@ -54635,7 +55369,11 @@ async function countProject(root, project) {
|
|
|
54635
55369
|
for (const page of await listPageFolders(projectDir)) for (const name of await listFrames(join(projectDir, page))) for (const path of linkedAssets(root, project, page, name)) counts.set(path, (counts.get(path) ?? 0) + 1);
|
|
54636
55370
|
return counts;
|
|
54637
55371
|
}
|
|
54638
|
-
/**
|
|
55372
|
+
/**
|
|
55373
|
+
* The asset paths one frame links, each once, read from its file as it stands
|
|
55374
|
+
* rather than from a cached count. A frame gone between the listing and the
|
|
55375
|
+
* read links none.
|
|
55376
|
+
*/
|
|
54639
55377
|
function linkedAssets(root, project, page, name) {
|
|
54640
55378
|
const linked = /* @__PURE__ */ new Set();
|
|
54641
55379
|
let source;
|
|
@@ -54739,7 +55477,12 @@ const THEMED_RULES = [
|
|
|
54739
55477
|
* Runs every browser rule in both themes and merges them, measuring a missing
|
|
54740
55478
|
* face in the board's fallback rather than refusing, after animations finish.
|
|
54741
55479
|
*/
|
|
54742
|
-
async function checkRendered(browser, { baseUrl, root, frame, config }) {
|
|
55480
|
+
async function checkRendered(browser, { baseUrl, root, frame: shown, config }) {
|
|
55481
|
+
const { device, ...target } = shown;
|
|
55482
|
+
const frame = {
|
|
55483
|
+
...target,
|
|
55484
|
+
box: pageSize(target.box, device)
|
|
55485
|
+
};
|
|
54743
55486
|
const [project = "", page = "", name = ""] = frame.ref.split("/");
|
|
54744
55487
|
const source = readFrame$1({
|
|
54745
55488
|
root,
|
|
@@ -58149,27 +58892,41 @@ function isIgnored(root, path) {
|
|
|
58149
58892
|
* reloading nothing, since moving a frame must not restart it.
|
|
58150
58893
|
*/
|
|
58151
58894
|
function reloadRefs(root, paths, board, tokens = null) {
|
|
58152
|
-
const { refs, everyFrame } = reloadCauses(root, paths, tokens);
|
|
58895
|
+
const { refs, everyFrame, media } = reloadCauses(root, paths, tokens);
|
|
58153
58896
|
const named = [];
|
|
58154
|
-
for (const project of board.projects)
|
|
58897
|
+
for (const project of board.projects) {
|
|
58898
|
+
const changed = media.get(project.name);
|
|
58899
|
+
for (const page of project.pages) for (const frame of page.frames) if (everyFrame || refs.has(frame.ref) || refs.has(`${page.ref}/*`) || refs.has(`${project.name}/*`) || changed !== void 0 && links(root, frame, changed)) named.push(frame.ref);
|
|
58900
|
+
}
|
|
58155
58901
|
return named;
|
|
58156
58902
|
}
|
|
58903
|
+
/** Whether the frame's file, read as it stands, loads any of the changed asset paths. */
|
|
58904
|
+
function links(root, frame, changed) {
|
|
58905
|
+
for (const path of linkedAssets(root, frame.project, frame.page, frame.name)) if (changed.has(path)) return true;
|
|
58906
|
+
return false;
|
|
58907
|
+
}
|
|
58157
58908
|
/**
|
|
58158
58909
|
* The frames `reloadRefs` names through their own file alone, with no token
|
|
58159
58910
|
* sheet, asset, or other page-folder file in the batch reaching them, in
|
|
58160
58911
|
* board order. Only these reload into bytes a hash of that one file names.
|
|
58161
58912
|
*/
|
|
58162
58913
|
function ownReloadRefs(root, paths, board, tokens = null) {
|
|
58163
|
-
const { refs, everyFrame } = reloadCauses(root, paths, tokens);
|
|
58914
|
+
const { refs, everyFrame, media } = reloadCauses(root, paths, tokens);
|
|
58164
58915
|
if (everyFrame) return [];
|
|
58165
|
-
return board.projects.flatMap((project) =>
|
|
58916
|
+
return board.projects.flatMap((project) => {
|
|
58917
|
+
if (refs.has(`${project.name}/*`)) return [];
|
|
58918
|
+
const changed = media.get(project.name);
|
|
58919
|
+
return project.pages.flatMap((page) => refs.has(`${page.ref}/*`) ? [] : page.frames.filter((frame) => refs.has(frame.ref) && (changed === void 0 || !links(root, frame, changed))).map((frame) => frame.ref));
|
|
58920
|
+
});
|
|
58166
58921
|
}
|
|
58167
58922
|
/**
|
|
58168
58923
|
* What a batch's paths reach: frame refs, `<page>/*` and `<project>/*`
|
|
58169
|
-
* wildcards,
|
|
58924
|
+
* wildcards, whether a board-wide sheet reaches every frame, and per project
|
|
58925
|
+
* the placeable media under `assets/` that reach only the frames loading them.
|
|
58170
58926
|
*/
|
|
58171
58927
|
function reloadCauses(root, paths, tokens) {
|
|
58172
58928
|
const refs = /* @__PURE__ */ new Set();
|
|
58929
|
+
const media = /* @__PURE__ */ new Map();
|
|
58173
58930
|
let everyFrame = false;
|
|
58174
58931
|
for (const path of paths) {
|
|
58175
58932
|
const [project, folder, ...rest] = relative(root, path).split(sep);
|
|
@@ -58182,8 +58939,17 @@ function reloadCauses(root, paths, tokens) {
|
|
|
58182
58939
|
continue;
|
|
58183
58940
|
}
|
|
58184
58941
|
if (!project || !folder || rest.length === 0) continue;
|
|
58185
|
-
if (folder === "assets")
|
|
58186
|
-
|
|
58942
|
+
if (folder === "assets") {
|
|
58943
|
+
const name = rest.at(-1) ?? "";
|
|
58944
|
+
if (name.endsWith(".license.json")) continue;
|
|
58945
|
+
if (rest[0] === "kits" || rest[0] === "kit" || !isPlaceableKind(assetKind(name))) {
|
|
58946
|
+
refs.add(`${project}/*`);
|
|
58947
|
+
continue;
|
|
58948
|
+
}
|
|
58949
|
+
const changed = media.get(project) ?? /* @__PURE__ */ new Set();
|
|
58950
|
+
changed.add(rest.join("/"));
|
|
58951
|
+
media.set(project, changed);
|
|
58952
|
+
} else if (rest.length === 1) {
|
|
58187
58953
|
const name = rest[0] ?? "";
|
|
58188
58954
|
if (name === "layout.json" || name === NOTES_FILE) continue;
|
|
58189
58955
|
const frame = frameNameOf(name);
|
|
@@ -58192,7 +58958,8 @@ function reloadCauses(root, paths, tokens) {
|
|
|
58192
58958
|
}
|
|
58193
58959
|
return {
|
|
58194
58960
|
refs,
|
|
58195
|
-
everyFrame
|
|
58961
|
+
everyFrame,
|
|
58962
|
+
media
|
|
58196
58963
|
};
|
|
58197
58964
|
}
|
|
58198
58965
|
/**
|
|
@@ -58242,6 +59009,17 @@ function relistedRefs(previous, next) {
|
|
|
58242
59009
|
function listed(frame) {
|
|
58243
59010
|
return frame.widths.map(({ width }) => width).join(",");
|
|
58244
59011
|
}
|
|
59012
|
+
/**
|
|
59013
|
+
* Frames whose kit changed, reloaded here, since the kit lives in
|
|
59014
|
+
* `layout.json`, which reloads nothing, and the frame route imports its sheets.
|
|
59015
|
+
*/
|
|
59016
|
+
function rekittedRefs(previous, next) {
|
|
59017
|
+
const before = new Map(previous.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.map((frame) => [frame.ref, frame.kit ?? null]))));
|
|
59018
|
+
return next.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.filter((frame) => {
|
|
59019
|
+
const was = before.get(frame.ref);
|
|
59020
|
+
return was !== void 0 && was !== (frame.kit ?? null);
|
|
59021
|
+
}).map((frame) => frame.ref)));
|
|
59022
|
+
}
|
|
58245
59023
|
// src/server/live/findings.ts
|
|
58246
59024
|
/**
|
|
58247
59025
|
* The board's findings, held between batches so a hello needs no check, and
|
|
@@ -58551,10 +59329,14 @@ function createHug({ root, measure }) {
|
|
|
58551
59329
|
async function measureParts(measure, frame, parts) {
|
|
58552
59330
|
const size = {};
|
|
58553
59331
|
if (parts !== "linked") {
|
|
58554
|
-
const
|
|
59332
|
+
const page = pageBox(frame.box, frame.device);
|
|
59333
|
+
const own = await measure({
|
|
59334
|
+
...frame,
|
|
59335
|
+
box: page
|
|
59336
|
+
});
|
|
58555
59337
|
if (!own.empty) Object.assign(size, {
|
|
58556
59338
|
width: own.width,
|
|
58557
|
-
height: own.height
|
|
59339
|
+
height: own.height + topInset(frame.device)
|
|
58558
59340
|
});
|
|
58559
59341
|
}
|
|
58560
59342
|
if (parts !== "own" && frame.hugHeight && frame.widths.length > 0) {
|
|
@@ -59219,7 +60001,8 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
59219
60001
|
path: boardPath(root, frame.path),
|
|
59220
60002
|
box,
|
|
59221
60003
|
scroll: frame.scroll,
|
|
59222
|
-
hugHeight: frame.hugHeight
|
|
60004
|
+
hugHeight: frame.hugHeight,
|
|
60005
|
+
device: box.width === frame.box.width ? frame.device : void 0
|
|
59223
60006
|
},
|
|
59224
60007
|
config: readConfig(root, frame.project)
|
|
59225
60008
|
}));
|
|
@@ -59435,6 +60218,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
|
|
|
59435
60218
|
let own;
|
|
59436
60219
|
let placed;
|
|
59437
60220
|
let relisted = [];
|
|
60221
|
+
let rekitted = [];
|
|
59438
60222
|
try {
|
|
59439
60223
|
await landReserved(root, /* @__PURE__ */ new Date()).catch(() => []);
|
|
59440
60224
|
board = await scanBoard(root);
|
|
@@ -59443,6 +60227,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
|
|
|
59443
60227
|
own = ownFileRefs(board, paths);
|
|
59444
60228
|
placed = previous ? placedRefs(previous, board, paths).filter((ref) => !own.includes(ref)) : [];
|
|
59445
60229
|
relisted = previous ? relistedRefs(previous, board) : [];
|
|
60230
|
+
rekitted = previous ? rekittedRefs(previous, board) : [];
|
|
59446
60231
|
if (await hug.now(board, [...own, ...placed]).catch(() => false)) {
|
|
59447
60232
|
const measured = board;
|
|
59448
60233
|
board = await scanBoard(root);
|
|
@@ -59462,7 +60247,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
|
|
|
59462
60247
|
});
|
|
59463
60248
|
const last = shown.board;
|
|
59464
60249
|
shown.board = board;
|
|
59465
|
-
const refs = reloadRefs(root, paths, board, tokens);
|
|
60250
|
+
const refs = [.../* @__PURE__ */ new Set([...reloadRefs(root, paths, board, tokens), ...rekitted])];
|
|
59466
60251
|
hug.later(board, [.../* @__PURE__ */ new Set([...refs, ...relisted])].filter((ref) => !own.includes(ref) && !placed.includes(ref)));
|
|
59467
60252
|
if (refs.length > 0) {
|
|
59468
60253
|
const reloads = unmovedRefs(refs, board, moved(), last);
|