frameboard 0.41.0 → 0.42.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 +948 -435
- package/dist/client/assets/index-Broai9D9.js +181 -0
- package/dist/client/assets/index-E0z1fVUW.css +2 -0
- package/dist/client/index.html +2 -2
- package/dist/frame-bridge.js +15 -15
- 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";
|
|
@@ -9558,6 +9559,85 @@ function xPast(edge, width, device) {
|
|
|
9558
9559
|
}, device);
|
|
9559
9560
|
return edge + 80 - body.x;
|
|
9560
9561
|
}
|
|
9562
|
+
// src/shared/names.ts
|
|
9563
|
+
/** One rule for project, page, and frame names, matching v01.3's naming check. */
|
|
9564
|
+
const NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
9565
|
+
/** Names a page may not take, since the folder means something else in a project. */
|
|
9566
|
+
const RESERVED_PAGE_NAMES = ["assets"];
|
|
9567
|
+
function isValidName(name) {
|
|
9568
|
+
return name.length <= 64 && NAME_PATTERN.test(name);
|
|
9569
|
+
}
|
|
9570
|
+
function isReservedPageName(name) {
|
|
9571
|
+
return RESERVED_PAGE_NAMES.some((reserved) => namesCollide(reserved, name));
|
|
9572
|
+
}
|
|
9573
|
+
/** Case-insensitive, since the default macOS volume is. */
|
|
9574
|
+
function namesCollide(a, b) {
|
|
9575
|
+
return a.toLowerCase() === b.toLowerCase();
|
|
9576
|
+
}
|
|
9577
|
+
/** `base` when free, else the first free `base-2`, `base-3`, and onward. */
|
|
9578
|
+
function nextFreeName(base, taken) {
|
|
9579
|
+
const lowered = new Set([...taken].map((name) => name.toLowerCase()));
|
|
9580
|
+
if (!lowered.has(base.toLowerCase())) return base;
|
|
9581
|
+
for (let suffix = 2;; suffix++) {
|
|
9582
|
+
const candidate = `${base}-${suffix}`;
|
|
9583
|
+
if (!lowered.has(candidate.toLowerCase())) return candidate;
|
|
9584
|
+
}
|
|
9585
|
+
}
|
|
9586
|
+
/**
|
|
9587
|
+
* The folder a retitled project lands in, cut back near the length limit so
|
|
9588
|
+
* the folder always stays a valid name.
|
|
9589
|
+
*/
|
|
9590
|
+
function titledFolder(current, title, taken) {
|
|
9591
|
+
const folder = folderName(title);
|
|
9592
|
+
if (folder === "" || namesCollide(folder, current)) return current;
|
|
9593
|
+
const others = [...taken].filter((name) => name !== current);
|
|
9594
|
+
for (let cut = folder.length; cut > 0; cut--) {
|
|
9595
|
+
const base = folder.slice(0, cut).replace(/-+$/, "");
|
|
9596
|
+
const free = nextFreeName(base, others);
|
|
9597
|
+
if (base !== "" && free.length <= 64) return free;
|
|
9598
|
+
}
|
|
9599
|
+
return current;
|
|
9600
|
+
}
|
|
9601
|
+
/**
|
|
9602
|
+
* A typed title as the folder it names, lower case with each run of
|
|
9603
|
+
* characters a name may not hold turned into one dash, so `Acme mobile`
|
|
9604
|
+
* becomes `acme-mobile`. Empty when the title holds nothing a name may.
|
|
9605
|
+
*/
|
|
9606
|
+
function folderName(typed) {
|
|
9607
|
+
return typed.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "").slice(0, 64).replace(/-+$/, "");
|
|
9608
|
+
}
|
|
9609
|
+
// src/shared/kits.ts
|
|
9610
|
+
/**
|
|
9611
|
+
* The names a design kit's folder of plain files is laid out by, installed so
|
|
9612
|
+
* the frame route imports `assets/kit/` after the token sheets.
|
|
9613
|
+
*/
|
|
9614
|
+
const KIT_FILE = "kit.json";
|
|
9615
|
+
const KIT_SHEET = "kit.css";
|
|
9616
|
+
const KIT_NOTE = "kit.md";
|
|
9617
|
+
/** The folder under a project's `assets/` holding each kit it added, one folder per kit. */
|
|
9618
|
+
const PROJECT_KITS = "kits";
|
|
9619
|
+
/** The dot folder in a board holding the kits saved from its projects, which home never lists as a project. */
|
|
9620
|
+
const KITS_FOLDER = ".kits";
|
|
9621
|
+
/**
|
|
9622
|
+
* Where the board serves a kit's files, under `/frameboard/`, since a bare
|
|
9623
|
+
* `/kits` would shadow the client's module folder under the dev server.
|
|
9624
|
+
*/
|
|
9625
|
+
const KITS_URL = "/frameboard/kits";
|
|
9626
|
+
/** 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. */
|
|
9627
|
+
const NO_KIT_WORD = "none";
|
|
9628
|
+
/** The kits the tool ships, in the order a picker shows them. */
|
|
9629
|
+
const SHIPPED_KITS = [
|
|
9630
|
+
"clean",
|
|
9631
|
+
"sketch",
|
|
9632
|
+
"wireframe"
|
|
9633
|
+
];
|
|
9634
|
+
/**
|
|
9635
|
+
* The project kit a layout entry's `kit` names, null for none, a value of
|
|
9636
|
+
* another type, or a name that could leave the project's kits folder.
|
|
9637
|
+
*/
|
|
9638
|
+
function kitOf(value) {
|
|
9639
|
+
return typeof value === "string" && isValidName(value) ? value : null;
|
|
9640
|
+
}
|
|
9561
9641
|
// src/shared/present-transition.ts
|
|
9562
9642
|
/**
|
|
9563
9643
|
* The board's own present transitions in inspector order, beside a project's
|
|
@@ -9730,7 +9810,8 @@ const layoutEntrySchema = looseObject({
|
|
|
9730
9810
|
foldable: unknown().optional(),
|
|
9731
9811
|
pose: unknown().optional(),
|
|
9732
9812
|
transition: unknown().optional(),
|
|
9733
|
-
speakerNotes: unknown().optional()
|
|
9813
|
+
speakerNotes: unknown().optional(),
|
|
9814
|
+
kit: unknown().optional()
|
|
9734
9815
|
});
|
|
9735
9816
|
/** The longest speaker note a write accepts, in characters. */
|
|
9736
9817
|
const SPEAKER_NOTES_MAX = 1e4;
|
|
@@ -9768,6 +9849,185 @@ function membersOf(sections, frames) {
|
|
|
9768
9849
|
}
|
|
9769
9850
|
return members;
|
|
9770
9851
|
}
|
|
9852
|
+
// src/server/board/refs.ts
|
|
9853
|
+
/**
|
|
9854
|
+
* The project a verb acts on: the one named, else the board's only project.
|
|
9855
|
+
* A name matching an existing project in another case resolves to that one.
|
|
9856
|
+
*/
|
|
9857
|
+
async function resolveProject(root, project) {
|
|
9858
|
+
const projects = await listProjects(root);
|
|
9859
|
+
if (project === void 0) {
|
|
9860
|
+
const [only, ...others] = projects;
|
|
9861
|
+
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 });
|
|
9862
|
+
return {
|
|
9863
|
+
name: only,
|
|
9864
|
+
path: join(root, only)
|
|
9865
|
+
};
|
|
9866
|
+
}
|
|
9867
|
+
const name = matchName(projects, project);
|
|
9868
|
+
if (!name) throw new FrameboardError("project-not-found", `No project ${project} in ${root}.`, {
|
|
9869
|
+
project,
|
|
9870
|
+
projects
|
|
9871
|
+
});
|
|
9872
|
+
return {
|
|
9873
|
+
name,
|
|
9874
|
+
path: join(root, name)
|
|
9875
|
+
};
|
|
9876
|
+
}
|
|
9877
|
+
/** A page ref is `<page>` or `<project>/<page>`. */
|
|
9878
|
+
async function resolvePageRef(root, ref, options) {
|
|
9879
|
+
const parts = splitRef(ref, 2);
|
|
9880
|
+
const pageName = parts.at(-1) ?? "";
|
|
9881
|
+
const project = await resolveProject(root, agreeingProject(ref, parts.length === 2 ? parts[0] : void 0, options));
|
|
9882
|
+
const page = await findPage(project.path, pageName, options.allowMissing);
|
|
9883
|
+
return {
|
|
9884
|
+
root,
|
|
9885
|
+
project: project.name,
|
|
9886
|
+
page: page.name,
|
|
9887
|
+
name: page.name,
|
|
9888
|
+
path: page.path
|
|
9889
|
+
};
|
|
9890
|
+
}
|
|
9891
|
+
/**
|
|
9892
|
+
* A frame ref is `<page>/<frame>` or `<project>/<page>/<frame>`. An argument
|
|
9893
|
+
* ending in `.html` is instead a path against `cwd`, which must sit in a page
|
|
9894
|
+
* of this board.
|
|
9895
|
+
*/
|
|
9896
|
+
async function resolveFrameRef(root, ref, options) {
|
|
9897
|
+
const parts = ref.endsWith(".html") ? await framePathParts(root, ref, options.cwd) : splitRef(ref, 3);
|
|
9898
|
+
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 });
|
|
9899
|
+
const frameName = parts.at(-1) ?? "";
|
|
9900
|
+
const pageName = parts.at(-2) ?? "";
|
|
9901
|
+
const project = await resolveProject(root, agreeingProject(ref, parts.length === 3 ? parts[0] : void 0, options));
|
|
9902
|
+
const page = await findPage(project.path, pageName, false);
|
|
9903
|
+
const frames = await listFrames(page.path);
|
|
9904
|
+
const found = matchName(frames, frameName);
|
|
9905
|
+
if (!found && !options.allowMissing) throw new FrameboardError("frame-not-found", `No frame ${frameName} in ${project.name}/${page.name}.`, {
|
|
9906
|
+
ref,
|
|
9907
|
+
frames
|
|
9908
|
+
});
|
|
9909
|
+
if (!found) assertValidName("frame", frameName);
|
|
9910
|
+
const name = found ?? frameName;
|
|
9911
|
+
return {
|
|
9912
|
+
root,
|
|
9913
|
+
project: project.name,
|
|
9914
|
+
page: page.name,
|
|
9915
|
+
name,
|
|
9916
|
+
path: join(page.path, `${name}${FRAME_EXTENSION}`)
|
|
9917
|
+
};
|
|
9918
|
+
}
|
|
9919
|
+
/** Throws `invalid-name` for a name a new project, page, or frame may not take. */
|
|
9920
|
+
function assertValidName(kind, name) {
|
|
9921
|
+
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.`, {
|
|
9922
|
+
kind,
|
|
9923
|
+
name
|
|
9924
|
+
});
|
|
9925
|
+
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.`, {
|
|
9926
|
+
kind,
|
|
9927
|
+
name
|
|
9928
|
+
});
|
|
9929
|
+
}
|
|
9930
|
+
/** The existing name equal to `name`, else one equal in another case. */
|
|
9931
|
+
function matchName(names, name) {
|
|
9932
|
+
return names.find((n) => n === name) ?? names.find((n) => namesCollide(n, name));
|
|
9933
|
+
}
|
|
9934
|
+
async function findPage(projectDir, name, allowMissing = false) {
|
|
9935
|
+
const pages = await listPageFolders(projectDir);
|
|
9936
|
+
const found = matchName(pages, name);
|
|
9937
|
+
if (!found && !allowMissing) throw new FrameboardError("page-not-found", `No page ${name} in ${projectDir}.`, {
|
|
9938
|
+
page: name,
|
|
9939
|
+
pages
|
|
9940
|
+
});
|
|
9941
|
+
if (!found) assertValidName("page", name);
|
|
9942
|
+
const resolved = found ?? name;
|
|
9943
|
+
return {
|
|
9944
|
+
name: resolved,
|
|
9945
|
+
path: join(projectDir, resolved)
|
|
9946
|
+
};
|
|
9947
|
+
}
|
|
9948
|
+
function splitRef(ref, max) {
|
|
9949
|
+
const parts = ref.split("/");
|
|
9950
|
+
if (parts.length > max || parts.some((part) => part === "")) throw new FrameboardError("usage", `${ref} is not a ${max === 2 ? "page" : "frame"} ref.`, { ref });
|
|
9951
|
+
return parts;
|
|
9952
|
+
}
|
|
9953
|
+
function agreeingProject(ref, fromRef, { project }) {
|
|
9954
|
+
if (fromRef !== void 0 && project !== void 0 && !namesCollide(fromRef, project)) throw new FrameboardError("usage", `${ref} names project ${fromRef} but --project names ${project}.`, {
|
|
9955
|
+
ref,
|
|
9956
|
+
project
|
|
9957
|
+
});
|
|
9958
|
+
return fromRef ?? project;
|
|
9959
|
+
}
|
|
9960
|
+
async function framePathParts(root, ref, cwd) {
|
|
9961
|
+
const path = resolve$1(cwd, ref);
|
|
9962
|
+
let folder = dirname(path);
|
|
9963
|
+
try {
|
|
9964
|
+
folder = await realpath(folder);
|
|
9965
|
+
} catch (error) {
|
|
9966
|
+
if (!isCode(error, "ENOENT")) throw error;
|
|
9967
|
+
}
|
|
9968
|
+
const inside = relative(root, folder);
|
|
9969
|
+
const parts = inside.split(sep);
|
|
9970
|
+
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}.`, {
|
|
9971
|
+
path,
|
|
9972
|
+
root
|
|
9973
|
+
});
|
|
9974
|
+
const file = path.slice(dirname(path).length + 1);
|
|
9975
|
+
return [...parts, file.slice(0, -5)];
|
|
9976
|
+
}
|
|
9977
|
+
// src/server/kits/project.ts
|
|
9978
|
+
/** The folder a project keeps the kit named `kit` in, which a caller checks is a valid name first. */
|
|
9979
|
+
function projectKitDir(projectDir, kit) {
|
|
9980
|
+
return join(projectDir, ASSETS_FOLDER, PROJECT_KITS, kit);
|
|
9981
|
+
}
|
|
9982
|
+
/**
|
|
9983
|
+
* The kits a project added, sorted by name, being each folder under its
|
|
9984
|
+
* `assets/kits/` a frame could name. A hand-built folder counts, since a
|
|
9985
|
+
* kit reaches a frame only where the frame names it.
|
|
9986
|
+
*/
|
|
9987
|
+
async function projectKitNames(projectDir) {
|
|
9988
|
+
let entries;
|
|
9989
|
+
try {
|
|
9990
|
+
entries = await readdir(join(projectDir, ASSETS_FOLDER, PROJECT_KITS), { withFileTypes: true });
|
|
9991
|
+
} catch {
|
|
9992
|
+
return [];
|
|
9993
|
+
}
|
|
9994
|
+
return entries.filter((entry) => entry.isDirectory() && isValidName(entry.name)).map((entry) => entry.name).sort();
|
|
9995
|
+
}
|
|
9996
|
+
/** The project's kit `name` answers to, refusing `kit-not-found` with the kits it holds. */
|
|
9997
|
+
async function heldKit(project, name) {
|
|
9998
|
+
const known = await projectKitNames(project.path);
|
|
9999
|
+
const found = matchName(known, name);
|
|
10000
|
+
if (found) return found;
|
|
10001
|
+
throw new FrameboardError("kit-not-found", `${project.name} holds no kit named ${name}. Add one with \`frameboard kit add ${project.name} <kit>\`.`, {
|
|
10002
|
+
kit: name,
|
|
10003
|
+
project: project.name,
|
|
10004
|
+
known
|
|
10005
|
+
});
|
|
10006
|
+
}
|
|
10007
|
+
/**
|
|
10008
|
+
* A project's kits as `list --json` answers them, each with how many of
|
|
10009
|
+
* `pages`' frames name it. The pages come scanned, so a scan never reads
|
|
10010
|
+
* a layout twice.
|
|
10011
|
+
*/
|
|
10012
|
+
async function projectKits(projectDir, pages) {
|
|
10013
|
+
const named = pages.flatMap((page) => page.frames.map((frame) => frame.kit));
|
|
10014
|
+
const names = await projectKitNames(projectDir);
|
|
10015
|
+
return Promise.all(names.map(async (name) => ({
|
|
10016
|
+
name,
|
|
10017
|
+
title: await titleOf$1(projectKitDir(projectDir, name), name),
|
|
10018
|
+
frameCount: named.filter((kit) => kit === name).length
|
|
10019
|
+
})));
|
|
10020
|
+
}
|
|
10021
|
+
/** The title a kit's `kit.json` gives, or its folder name where the file gives none. */
|
|
10022
|
+
async function titleOf$1(kitDir, name) {
|
|
10023
|
+
try {
|
|
10024
|
+
const parsed = JSON.parse(await readFile(join(kitDir, KIT_FILE), "utf8"));
|
|
10025
|
+
const title = typeof parsed === "object" && parsed !== null && "title" in parsed ? parsed.title : void 0;
|
|
10026
|
+
return typeof title === "string" && title.trim() !== "" ? title.trim() : name;
|
|
10027
|
+
} catch {
|
|
10028
|
+
return name;
|
|
10029
|
+
}
|
|
10030
|
+
}
|
|
9771
10031
|
// node_modules/picocolors/picocolors.js
|
|
9772
10032
|
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9773
10033
|
let p = process || {};
|
|
@@ -23556,7 +23816,7 @@ var Document = class extends NodeWithChildren {
|
|
|
23556
23816
|
/**
|
|
23557
23817
|
* An element within the DOM.
|
|
23558
23818
|
*/
|
|
23559
|
-
var Element = class extends NodeWithChildren {
|
|
23819
|
+
var Element$1 = class extends NodeWithChildren {
|
|
23560
23820
|
name;
|
|
23561
23821
|
attribs;
|
|
23562
23822
|
type;
|
|
@@ -23668,7 +23928,7 @@ function cloneNode(node, recursive = false) {
|
|
|
23668
23928
|
else if (isComment(node)) result = new Comment(node.data);
|
|
23669
23929
|
else if (isTag(node)) {
|
|
23670
23930
|
const children = recursive ? cloneChildren(node.children) : [];
|
|
23671
|
-
const clone = new Element(node.name, { ...node.attribs }, children);
|
|
23931
|
+
const clone = new Element$1(node.name, { ...node.attribs }, children);
|
|
23672
23932
|
for (const child of children) child.parent = clone;
|
|
23673
23933
|
if (node.namespace != null) clone.namespace = node.namespace;
|
|
23674
23934
|
if (node["x-attribsNamespace"]) clone["x-attribsNamespace"] = { ...node["x-attribsNamespace"] };
|
|
@@ -23748,7 +24008,7 @@ const adapter = {
|
|
|
23748
24008
|
attribsNamespace[attrName] = attrs[i].namespace;
|
|
23749
24009
|
attribsPrefix[attrName] = attrs[i].prefix;
|
|
23750
24010
|
}
|
|
23751
|
-
const node = new Element(tagName, attribs, []);
|
|
24011
|
+
const node = new Element$1(tagName, attribs, []);
|
|
23752
24012
|
node.namespace = namespaceURI;
|
|
23753
24013
|
node["x-attribsNamespace"] = attribsNamespace;
|
|
23754
24014
|
node["x-attribsPrefix"] = attribsPrefix;
|
|
@@ -24408,7 +24668,6 @@ async function assertKnownTransition(projectDir, transition) {
|
|
|
24408
24668
|
});
|
|
24409
24669
|
}
|
|
24410
24670
|
// src/server/board/scan.ts
|
|
24411
|
-
const LAYOUT_FILE = "layout.json";
|
|
24412
24671
|
const layoutSpec = {
|
|
24413
24672
|
schema: layoutFileSchema,
|
|
24414
24673
|
invalidCode: "layout-invalid",
|
|
@@ -24536,6 +24795,7 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
|
|
|
24536
24795
|
const device = shown ? named : null;
|
|
24537
24796
|
const transition = readTransition(entry.transition);
|
|
24538
24797
|
const speakerNotes = speakerNotesOf(entry.speakerNotes);
|
|
24798
|
+
const kit = kitOf(entry.kit);
|
|
24539
24799
|
placements.set(name, {
|
|
24540
24800
|
box,
|
|
24541
24801
|
order: entry.order,
|
|
@@ -24554,6 +24814,7 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
|
|
|
24554
24814
|
...foldable && kept.length > 0 ? { keptWidths: kept } : {},
|
|
24555
24815
|
...transition ? { transition } : {},
|
|
24556
24816
|
...speakerNotes ? { speakerNotes } : {},
|
|
24817
|
+
...kit ? { kit } : {},
|
|
24557
24818
|
placed: true
|
|
24558
24819
|
});
|
|
24559
24820
|
}
|
|
@@ -24631,6 +24892,7 @@ async function scanProject(root, name) {
|
|
|
24631
24892
|
projectFileError: error,
|
|
24632
24893
|
transitions,
|
|
24633
24894
|
checksOff,
|
|
24895
|
+
kits: await projectKits(path, pages),
|
|
24634
24896
|
pages
|
|
24635
24897
|
};
|
|
24636
24898
|
}
|
|
@@ -24781,7 +25043,7 @@ async function isDirectory(path) {
|
|
|
24781
25043
|
}
|
|
24782
25044
|
}
|
|
24783
25045
|
// package.json
|
|
24784
|
-
var version$1 = "0.
|
|
25046
|
+
var version$1 = "0.42.0";
|
|
24785
25047
|
var dependencies = { "playwright-core": "1.65.0" };
|
|
24786
25048
|
var peerDependencies = { "oxfmt": "0.78.0" };
|
|
24787
25049
|
// src/shared/version.ts
|
|
@@ -24882,53 +25144,6 @@ async function findLiveServer(root) {
|
|
|
24882
25144
|
return null;
|
|
24883
25145
|
}
|
|
24884
25146
|
}
|
|
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
25147
|
// src/shared/records/claims.ts
|
|
24933
25148
|
/**
|
|
24934
25149
|
* Where a reserved frame will land, and which axes take their size from the
|
|
@@ -25126,131 +25341,6 @@ async function release(root, session, frame, now) {
|
|
|
25126
25341
|
});
|
|
25127
25342
|
return dropped;
|
|
25128
25343
|
}
|
|
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
25344
|
// src/server/board/frames.ts
|
|
25255
25345
|
/**
|
|
25256
25346
|
* Places a frame, writing a skeleton only when no file exists. Every axis no
|
|
@@ -25297,7 +25387,7 @@ async function addFrame(root, ref, options) {
|
|
|
25297
25387
|
held: []
|
|
25298
25388
|
});
|
|
25299
25389
|
if (!exists) {
|
|
25300
|
-
await writeFile(frame.path, skeleton(frame.name, options.body), { flag: "wx" });
|
|
25390
|
+
await writeFile(frame.path, skeleton(frame.name, options.body, options.head), { flag: "wx" });
|
|
25301
25391
|
await journal?.created(frame.path);
|
|
25302
25392
|
}
|
|
25303
25393
|
layout.names = names;
|
|
@@ -25806,6 +25896,25 @@ async function setFrameTransition(root, ref, transition, options) {
|
|
|
25806
25896
|
});
|
|
25807
25897
|
}
|
|
25808
25898
|
/**
|
|
25899
|
+
* Sets the project kit a frame draws with, or clears it with null, writing
|
|
25900
|
+
* only its layout entry. Refuses `kit-not-found` for a name the frame's
|
|
25901
|
+
* project holds no kit under, and stores the folder's own spelling.
|
|
25902
|
+
*/
|
|
25903
|
+
async function setFrameKit(root, ref, kit, options) {
|
|
25904
|
+
const frame = await resolveFrameRef(root, ref, options);
|
|
25905
|
+
const held = kit === null ? null : await heldKit({
|
|
25906
|
+
name: frame.project,
|
|
25907
|
+
path: join(root, frame.project)
|
|
25908
|
+
}, kit);
|
|
25909
|
+
return updatePlacement(root, ref, options, (placement) => {
|
|
25910
|
+
const { kit: _held, ...rest } = placement;
|
|
25911
|
+
return held ? {
|
|
25912
|
+
...rest,
|
|
25913
|
+
kit: held
|
|
25914
|
+
} : rest;
|
|
25915
|
+
});
|
|
25916
|
+
}
|
|
25917
|
+
/**
|
|
25809
25918
|
* Sets a frame's speaker note on its layout entry, null or blank clearing it.
|
|
25810
25919
|
* Refuses `usage` past `SPEAKER_NOTES_MAX` rather than cutting, and
|
|
25811
25920
|
* `stale-layout` once `expected`, the note the edit began from, is gone.
|
|
@@ -25875,14 +25984,15 @@ function sizeOf({ size, width, height }) {
|
|
|
25875
25984
|
* The skeleton states `head` with `body`, so the browser builds neither and
|
|
25876
25985
|
* every address holds, and a body column has no margin, so media fits exactly.
|
|
25877
25986
|
*/
|
|
25878
|
-
function skeleton(name, body) {
|
|
25987
|
+
function skeleton(name, body, head) {
|
|
25988
|
+
const content = body === void 0 ? "<body></body>" : `<body style="margin: 0; display: flex; flex-direction: column; align-items: flex-start">${body}</body>`;
|
|
25879
25989
|
return `<!doctype html>
|
|
25880
25990
|
<html lang="en">
|
|
25881
25991
|
<head>
|
|
25882
25992
|
<meta charset="utf-8" />
|
|
25883
|
-
<title>${name}</title
|
|
25993
|
+
<title>${name}</title>${head === void 0 ? "" : `\n ${head}`}
|
|
25884
25994
|
</head>
|
|
25885
|
-
${
|
|
25995
|
+
${content}
|
|
25886
25996
|
</html>
|
|
25887
25997
|
`;
|
|
25888
25998
|
}
|
|
@@ -25918,7 +26028,7 @@ var PageLayout = class {
|
|
|
25918
26028
|
* Writes the fixed keys after the entry's own, so unknown keys survive, and a
|
|
25919
26029
|
* flag only once on or already held, so an older entry gains no key.
|
|
25920
26030
|
*/
|
|
25921
|
-
set(name, { box, order, hidden, locked, scroll, widths, showDevice, foldable, pose, keptWidths, transition, speakerNotes, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
|
|
26031
|
+
set(name, { box, order, hidden, locked, scroll, widths, showDevice, foldable, pose, keptWidths, transition, speakerNotes, kit, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
|
|
25922
26032
|
const hugWidth = hugsWidth && !scroll;
|
|
25923
26033
|
const hugHeight = hugsHeight && !scroll;
|
|
25924
26034
|
const held = this.file.frames[name];
|
|
@@ -25943,7 +26053,8 @@ var PageLayout = class {
|
|
|
25943
26053
|
...foldable ? { foldable } : {},
|
|
25944
26054
|
...foldable && pose && (held?.foldable !== true || poseOf(held.pose) !== pose) ? { pose } : {},
|
|
25945
26055
|
...transition ? { transition: { ...transition } } : {},
|
|
25946
|
-
...speakerNotes ? { speakerNotes } : {}
|
|
26056
|
+
...speakerNotes ? { speakerNotes } : {},
|
|
26057
|
+
...kit ? { kit } : {}
|
|
25947
26058
|
};
|
|
25948
26059
|
if (listed.length === 0 && widthsOf(held?.widths).length > 0) delete entry.widths;
|
|
25949
26060
|
if (!foldable && held?.foldable === true) {
|
|
@@ -25954,6 +26065,7 @@ var PageLayout = class {
|
|
|
25954
26065
|
if (typeof held?.device === "string") delete entry.device;
|
|
25955
26066
|
if (!transition && storedTransitionOf(held?.transition)) delete entry.transition;
|
|
25956
26067
|
if (!speakerNotes && speakerNotesOf(held?.speakerNotes)) delete entry.speakerNotes;
|
|
26068
|
+
if (!kit && kitOf(held?.kit)) delete entry.kit;
|
|
25957
26069
|
this.file.frames[name] = entry;
|
|
25958
26070
|
this.changed = true;
|
|
25959
26071
|
}
|
|
@@ -30729,18 +30841,20 @@ const ASSET_KINDS = [
|
|
|
30729
30841
|
"svg",
|
|
30730
30842
|
"video",
|
|
30731
30843
|
"audio",
|
|
30844
|
+
"model",
|
|
30732
30845
|
"font",
|
|
30733
30846
|
"stylesheet",
|
|
30734
30847
|
"script",
|
|
30735
30848
|
"other"
|
|
30736
30849
|
];
|
|
30737
|
-
/** The kinds a frame shows as an `<img>`, a `<video>`,
|
|
30850
|
+
/** The kinds a frame shows as an `<img>`, a `<video>`, an `<audio>`, or a `<model-viewer>`, which the board places by hand. */
|
|
30738
30851
|
const PLACEABLE_KINDS = [
|
|
30739
30852
|
"image",
|
|
30740
30853
|
"gif",
|
|
30741
30854
|
"svg",
|
|
30742
30855
|
"video",
|
|
30743
|
-
"audio"
|
|
30856
|
+
"audio",
|
|
30857
|
+
"model"
|
|
30744
30858
|
];
|
|
30745
30859
|
function isPlaceableKind(kind) {
|
|
30746
30860
|
return PLACEABLE_KINDS.includes(kind);
|
|
@@ -30762,6 +30876,8 @@ const ACCEPTED = {
|
|
|
30762
30876
|
wav: "audio",
|
|
30763
30877
|
ogg: "audio",
|
|
30764
30878
|
m4a: "audio",
|
|
30879
|
+
glb: "model",
|
|
30880
|
+
gltf: "model",
|
|
30765
30881
|
woff: "font",
|
|
30766
30882
|
woff2: "font",
|
|
30767
30883
|
ttf: "font",
|
|
@@ -30770,6 +30886,17 @@ const ACCEPTED = {
|
|
|
30770
30886
|
js: "script",
|
|
30771
30887
|
mjs: "script"
|
|
30772
30888
|
};
|
|
30889
|
+
/** Model formats no frame shows, which a drop refuses with the way to a GLB rather than as an unknown file. */
|
|
30890
|
+
const FOREIGN_MODELS = [
|
|
30891
|
+
"fbx",
|
|
30892
|
+
"obj",
|
|
30893
|
+
"blend",
|
|
30894
|
+
"usd",
|
|
30895
|
+
"stl"
|
|
30896
|
+
];
|
|
30897
|
+
function isForeignModel(name) {
|
|
30898
|
+
return FOREIGN_MODELS.includes(extensionOf(name));
|
|
30899
|
+
}
|
|
30773
30900
|
/** The lowercase text after the last dot, empty when the name has none. */
|
|
30774
30901
|
function extensionOf(name) {
|
|
30775
30902
|
const dot = name.lastIndexOf(".");
|
|
@@ -30983,7 +31110,7 @@ async function resolveAsset(projectDir, path) {
|
|
|
30983
31110
|
if (!isPlaceableKind(kind)) return {
|
|
30984
31111
|
ok: false,
|
|
30985
31112
|
code: "asset-not-placeable",
|
|
30986
|
-
message: `assets/${path} is not an image, GIF, SVG, video, or
|
|
31113
|
+
message: `assets/${path} is not an image, GIF, SVG, video, audio, or 3D model, so a frame cannot show it`
|
|
30987
31114
|
};
|
|
30988
31115
|
return {
|
|
30989
31116
|
ok: true,
|
|
@@ -31004,11 +31131,12 @@ async function addAssets(projectDir, uploads) {
|
|
|
31004
31131
|
refused: []
|
|
31005
31132
|
};
|
|
31006
31133
|
for (const upload of uploads) {
|
|
31007
|
-
|
|
31134
|
+
const refusal = uploadRefusal(upload);
|
|
31135
|
+
if (refusal !== null) {
|
|
31008
31136
|
result.refused.push({
|
|
31009
31137
|
name: upload.name,
|
|
31010
31138
|
code: "asset-type-refused",
|
|
31011
|
-
message:
|
|
31139
|
+
message: refusal
|
|
31012
31140
|
});
|
|
31013
31141
|
continue;
|
|
31014
31142
|
}
|
|
@@ -31021,6 +31149,37 @@ async function addAssets(projectDir, uploads) {
|
|
|
31021
31149
|
}
|
|
31022
31150
|
return result;
|
|
31023
31151
|
}
|
|
31152
|
+
/** Why a drop refuses a file, or null for one it keeps. */
|
|
31153
|
+
function uploadRefusal({ name, bytes }) {
|
|
31154
|
+
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.`;
|
|
31155
|
+
if (!isAcceptedUpload(name)) return `${name} is not an image, GIF, SVG, video, audio, 3D model, font, stylesheet, or script.`;
|
|
31156
|
+
return extensionOf(name) === "gltf" ? gltfRefusal(name, bytes) : null;
|
|
31157
|
+
}
|
|
31158
|
+
/**
|
|
31159
|
+
* Why a `.gltf` cannot land alone, or null for one carrying its buffers and
|
|
31160
|
+
* images inside itself. A drop keeps one file per name, so a `.bin` or a
|
|
31161
|
+
* texture the model loads beside it would be left behind.
|
|
31162
|
+
*/
|
|
31163
|
+
function gltfRefusal(name, bytes) {
|
|
31164
|
+
let parsed;
|
|
31165
|
+
try {
|
|
31166
|
+
parsed = JSON.parse(new TextDecoder().decode(bytes));
|
|
31167
|
+
} catch {
|
|
31168
|
+
return `${name} is not a glTF file a model reads. Export it again as a glTF Binary (.glb).`;
|
|
31169
|
+
}
|
|
31170
|
+
const [first] = [...linkedUris(parsed, "buffers"), ...linkedUris(parsed, "images")];
|
|
31171
|
+
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.`;
|
|
31172
|
+
}
|
|
31173
|
+
/** The `uri` of each entry under `key` that names a file rather than carrying its bytes. */
|
|
31174
|
+
function linkedUris(gltf, key) {
|
|
31175
|
+
if (typeof gltf !== "object" || gltf === null) return [];
|
|
31176
|
+
const entries = gltf[key];
|
|
31177
|
+
if (!Array.isArray(entries)) return [];
|
|
31178
|
+
return entries.flatMap((entry) => {
|
|
31179
|
+
const uri = typeof entry === "object" && entry !== null ? entry.uri : void 0;
|
|
31180
|
+
return typeof uri === "string" && !uri.startsWith("data:") ? [uri] : [];
|
|
31181
|
+
});
|
|
31182
|
+
}
|
|
31024
31183
|
async function writeFree(folder, { name, bytes }) {
|
|
31025
31184
|
const { stem, extension } = splitName(name);
|
|
31026
31185
|
const temp = join(folder, `${randomBytes(6).toString("hex")}${TEMP_SUFFIX}`);
|
|
@@ -31389,6 +31548,85 @@ function clipboardRoutes(root, access, render, clipboard) {
|
|
|
31389
31548
|
});
|
|
31390
31549
|
return app;
|
|
31391
31550
|
}
|
|
31551
|
+
// src/server/checks/tokens.ts
|
|
31552
|
+
/**
|
|
31553
|
+
* Where a project's token sheets sit, the address file read by plain
|
|
31554
|
+
* `JSON.parse`, since the write hook cannot afford its schema.
|
|
31555
|
+
*/
|
|
31556
|
+
function tokenSheetPaths(root, project, tokens) {
|
|
31557
|
+
const own = join(root, project, TOKEN_FILE);
|
|
31558
|
+
return {
|
|
31559
|
+
board: boardSheetPath(root, tokens),
|
|
31560
|
+
project: existsSync(own) ? own : null
|
|
31561
|
+
};
|
|
31562
|
+
}
|
|
31563
|
+
/** The board's token sheet alone, resolved the way `tokenSheetPaths` resolves it. */
|
|
31564
|
+
function boardSheetPath(root, tokens = recordedTokens(root)) {
|
|
31565
|
+
const board = tokens ?? join(root, "tokens.css");
|
|
31566
|
+
return existsSync(board) ? board : null;
|
|
31567
|
+
}
|
|
31568
|
+
/** The `--tokens` path the board's running server recorded, or null. */
|
|
31569
|
+
function recordedTokens(root) {
|
|
31570
|
+
try {
|
|
31571
|
+
const parsed = JSON.parse(readFileSync(join(root, RUN_FOLDER, ADDRESS_FILE), "utf8"));
|
|
31572
|
+
const tokens = typeof parsed === "object" && parsed !== null && "tokens" in parsed ? parsed.tokens : void 0;
|
|
31573
|
+
return typeof tokens === "string" ? tokens : null;
|
|
31574
|
+
} catch {
|
|
31575
|
+
return null;
|
|
31576
|
+
}
|
|
31577
|
+
}
|
|
31578
|
+
/**
|
|
31579
|
+
* The kit a frame's layout entry names, null for none or a layout that does
|
|
31580
|
+
* not read, parsed plainly as the address file is.
|
|
31581
|
+
*/
|
|
31582
|
+
function frameKit({ root, project, page, name }) {
|
|
31583
|
+
try {
|
|
31584
|
+
return kitOf(keyOf$1(keyOf$1(keyOf$1(JSON.parse(readFileSync(join(root, project, page, LAYOUT_FILE), "utf8")), "frames"), name), "kit"));
|
|
31585
|
+
} catch {
|
|
31586
|
+
return null;
|
|
31587
|
+
}
|
|
31588
|
+
}
|
|
31589
|
+
/** An object's own key, undefined for a value holding none. */
|
|
31590
|
+
function keyOf$1(value, key) {
|
|
31591
|
+
return typeof value === "object" && value !== null && Object.hasOwn(value, key) ? value[key] : void 0;
|
|
31592
|
+
}
|
|
31593
|
+
/**
|
|
31594
|
+
* The kit sheets a frame draws with, as paths under its project in cascade
|
|
31595
|
+
* order: a project-wide kit's where `assets/kit/` holds `kit.json`, then the
|
|
31596
|
+
* tokens and stylesheet of the kit the frame names, each that exists.
|
|
31597
|
+
*/
|
|
31598
|
+
function kitSheetFiles(root, project, kit) {
|
|
31599
|
+
const wide = [ASSETS_FOLDER, "kit"];
|
|
31600
|
+
const named = kitOf(kit);
|
|
31601
|
+
return [...existsSync(join(root, project, ...wide, "kit.json")) ? [[...wide, KIT_SHEET]] : [], ...named ? [TOKEN_FILE, KIT_SHEET].map((file) => [
|
|
31602
|
+
ASSETS_FOLDER,
|
|
31603
|
+
PROJECT_KITS,
|
|
31604
|
+
named,
|
|
31605
|
+
file
|
|
31606
|
+
]) : []].filter((file) => existsSync(join(root, project, ...file))).map((file) => file.join("/"));
|
|
31607
|
+
}
|
|
31608
|
+
/**
|
|
31609
|
+
* The sheets the frame route imports ahead of a frame, being the board's
|
|
31610
|
+
* tokens, the project's, then its kit sheets, which the cascade reads ahead
|
|
31611
|
+
* of the frame's own. `kit` is the kit the frame names, null for a plain one.
|
|
31612
|
+
*/
|
|
31613
|
+
function tokenSheets(root, project, tokens, kit = null) {
|
|
31614
|
+
return readSheets(root, project, tokenSheetPaths(root, project, tokens), kit);
|
|
31615
|
+
}
|
|
31616
|
+
/** `tokenSheets` for a caller already holding the project's sheet paths. */
|
|
31617
|
+
function readSheets(root, project, paths, kit) {
|
|
31618
|
+
const kitSheets = kitSheetFiles(root, project, kit).map((file) => join(root, project, file));
|
|
31619
|
+
return [
|
|
31620
|
+
paths.board,
|
|
31621
|
+
paths.project,
|
|
31622
|
+
...kitSheets
|
|
31623
|
+
].filter((path) => path !== null).map((path) => ({
|
|
31624
|
+
css: readFileSync(path, "utf8"),
|
|
31625
|
+
origin: "token",
|
|
31626
|
+
path,
|
|
31627
|
+
offset: 0
|
|
31628
|
+
}));
|
|
31629
|
+
}
|
|
31392
31630
|
// src/server/edit/start-tag.ts
|
|
31393
31631
|
function isSpace(char) {
|
|
31394
31632
|
return char === " " || char === " " || char === "\n" || char === "\f" || char === "\r";
|
|
@@ -37576,6 +37814,11 @@ function isText(node) {
|
|
|
37576
37814
|
function attribute$1(element, name) {
|
|
37577
37815
|
return element.attrs.find((attr) => attr.name === name)?.value;
|
|
37578
37816
|
}
|
|
37817
|
+
// src/shared/model-viewer.ts
|
|
37818
|
+
/** The custom element a frame shows a 3D model through. */
|
|
37819
|
+
const VIEWER_TAG = "model-viewer";
|
|
37820
|
+
/** The viewer's script as a project's `assets/` holds it, copied in with the first model placed. */
|
|
37821
|
+
const VIEWER_FILE = "model-viewer.min.js";
|
|
37579
37822
|
// src/shared/faces.ts
|
|
37580
37823
|
const FACES = [
|
|
37581
37824
|
{
|
|
@@ -37712,6 +37955,11 @@ function starterSheet({ accent, font }) {
|
|
|
37712
37955
|
`;
|
|
37713
37956
|
}
|
|
37714
37957
|
// src/server/edit/insert.ts
|
|
37958
|
+
/** The tag a frame shows an asset of `kind` through. */
|
|
37959
|
+
function assetTag(kind) {
|
|
37960
|
+
if (kind === "video" || kind === "audio") return kind;
|
|
37961
|
+
return kind === "model" ? VIEWER_TAG : "img";
|
|
37962
|
+
}
|
|
37715
37963
|
const SHAPE_SIZE = 100;
|
|
37716
37964
|
const TEXT_FONT_TOKEN = "--font-text";
|
|
37717
37965
|
const PAINT_VALUE = /^(?:var\(--[\w-]+\)|#[0-9a-f]{6})$/i;
|
|
@@ -37737,6 +37985,7 @@ const CLOSED = /* @__PURE__ */ new Set([
|
|
|
37737
37985
|
"title",
|
|
37738
37986
|
"noscript",
|
|
37739
37987
|
"iframe",
|
|
37988
|
+
VIEWER_TAG,
|
|
37740
37989
|
"html",
|
|
37741
37990
|
"head"
|
|
37742
37991
|
]);
|
|
@@ -37768,6 +38017,7 @@ function elementMarkup(element, paint, font) {
|
|
|
37768
38017
|
if (!Number.isInteger(element.width)) throw new Error(`Unexpected audio width ${element.width}`);
|
|
37769
38018
|
return `<audio data-name="${name}" src="${src}" controls style="width: ${element.width}px"></audio>`;
|
|
37770
38019
|
}
|
|
38020
|
+
if (element.tag === "model-viewer") return `<model-viewer data-name="${name}" src="${src}" alt="" style="${size(element)}"></model-viewer>`;
|
|
37771
38021
|
const style = `${size(element)}; object-fit: cover`;
|
|
37772
38022
|
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
38023
|
}
|
|
@@ -37784,6 +38034,66 @@ function assetLink(path) {
|
|
|
37784
38034
|
function attribute(text) {
|
|
37785
38035
|
return text.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<");
|
|
37786
38036
|
}
|
|
38037
|
+
/** The tag a frame loads the viewer by, from its project's `assets/`. */
|
|
38038
|
+
const VIEWER_SCRIPT = `<script type="module" src="${assetLink(VIEWER_FILE)}"><\/script>`;
|
|
38039
|
+
/**
|
|
38040
|
+
* Writes the viewer's script at the end of the frame's head unless a script
|
|
38041
|
+
* there already loads one, an agent's own copy included. A frame stating no
|
|
38042
|
+
* head takes it ahead of its content, where the browser builds the head.
|
|
38043
|
+
*/
|
|
38044
|
+
function ensureViewerScript(source) {
|
|
38045
|
+
const before = parseFrame(source);
|
|
38046
|
+
if (before.elements.some(loadsViewer)) return {
|
|
38047
|
+
ok: true,
|
|
38048
|
+
html: source,
|
|
38049
|
+
index: null
|
|
38050
|
+
};
|
|
38051
|
+
const { offset, lead } = headEnd(source, before);
|
|
38052
|
+
const written = source.slice(0, offset) + lead + VIEWER_SCRIPT + source.slice(offset);
|
|
38053
|
+
const after = parseFrame(written);
|
|
38054
|
+
const index = after.elements.findIndex((element) => element.sourceCodeLocation?.startOffset === offset + lead.length);
|
|
38055
|
+
const added = after.elements[index];
|
|
38056
|
+
const parent = added?.parentNode;
|
|
38057
|
+
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");
|
|
38058
|
+
return {
|
|
38059
|
+
ok: true,
|
|
38060
|
+
html: written,
|
|
38061
|
+
index
|
|
38062
|
+
};
|
|
38063
|
+
}
|
|
38064
|
+
/** Whether an element is a script loading a model viewer build, by its file name. */
|
|
38065
|
+
function loadsViewer(element) {
|
|
38066
|
+
if (element.tagName !== "script") return false;
|
|
38067
|
+
return ((element.attrs.find((attr) => attr.name === "src")?.value ?? "").split(/[?#]/)[0]?.split("/").at(-1) ?? "").includes(VIEWER_TAG);
|
|
38068
|
+
}
|
|
38069
|
+
/**
|
|
38070
|
+
* Where a head's last child ends, with the line break and indent that child
|
|
38071
|
+
* sits on, so the script lands on a line of its own. An unstated head takes
|
|
38072
|
+
* the offset its content would start at.
|
|
38073
|
+
*/
|
|
38074
|
+
function headEnd(source, tree) {
|
|
38075
|
+
const head = tree.elements.find((element) => element.tagName === "head");
|
|
38076
|
+
const at = head?.sourceCodeLocation;
|
|
38077
|
+
const last = head?.childNodes.findLast(hasTag)?.sourceCodeLocation;
|
|
38078
|
+
if (last) {
|
|
38079
|
+
const indent = /\n[ \t]*$/.exec(source.slice(0, last.startOffset));
|
|
38080
|
+
return {
|
|
38081
|
+
offset: last.endOffset,
|
|
38082
|
+
lead: indent?.[0] ?? ""
|
|
38083
|
+
};
|
|
38084
|
+
}
|
|
38085
|
+
const stated = at?.startTag?.endOffset;
|
|
38086
|
+
if (stated !== void 0) return {
|
|
38087
|
+
offset: stated,
|
|
38088
|
+
lead: ""
|
|
38089
|
+
};
|
|
38090
|
+
const html = tree.elements.find((element) => element.tagName === "html");
|
|
38091
|
+
const doctype = tree.document.childNodes.find((node) => node.nodeName === "#documentType");
|
|
38092
|
+
return {
|
|
38093
|
+
offset: html?.sourceCodeLocation?.startTag?.endOffset ?? doctype?.sourceCodeLocation?.endOffset ?? 0,
|
|
38094
|
+
lead: ""
|
|
38095
|
+
};
|
|
38096
|
+
}
|
|
37787
38097
|
function startTag(source, element) {
|
|
37788
38098
|
return spanText(source, element, "start-tag");
|
|
37789
38099
|
}
|
|
@@ -37858,10 +38168,18 @@ function insertElement(source, placement, markup, lead = "") {
|
|
|
37858
38168
|
function descendants(element) {
|
|
37859
38169
|
return children$1(element).reduce((count, child) => count + 1 + descendants(child), 0);
|
|
37860
38170
|
}
|
|
37861
|
-
/**
|
|
37862
|
-
|
|
38171
|
+
/**
|
|
38172
|
+
* Whether `after` is `before` with `added` alone added, compared once it is
|
|
38173
|
+
* taken out with the `lead` white space written ahead of it.
|
|
38174
|
+
*/
|
|
38175
|
+
function addsOnly(before, after, added, lead = "") {
|
|
37863
38176
|
const parent = added.parentNode;
|
|
37864
|
-
|
|
38177
|
+
const previous = parent.childNodes[parent.childNodes.indexOf(added) - 1];
|
|
38178
|
+
if (lead !== "") {
|
|
38179
|
+
if (!previous || !("value" in previous) || !previous.value.endsWith(lead)) return false;
|
|
38180
|
+
previous.value = previous.value.slice(0, -lead.length);
|
|
38181
|
+
}
|
|
38182
|
+
parent.childNodes = parent.childNodes.filter((node) => node !== added && !("value" in node && node.value === ""));
|
|
37865
38183
|
return serialize$1(before.document) === serialize$1(after.document);
|
|
37866
38184
|
}
|
|
37867
38185
|
/**
|
|
@@ -38714,8 +39032,8 @@ function editFrameFile(path, address, change, sourceAt) {
|
|
|
38714
39032
|
}
|
|
38715
39033
|
/**
|
|
38716
39034
|
* 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
|
|
39035
|
+
* refused, since one undo could not put both spans back, except a text beside
|
|
39036
|
+
* a style or several attributes, which answer one span over the element.
|
|
38719
39037
|
*/
|
|
38720
39038
|
function editFrameFileAll(path, hash, edits, sourceAt) {
|
|
38721
39039
|
const read = readSource(path);
|
|
@@ -38779,24 +39097,46 @@ function mergedTwice(source, html, indexes, spans) {
|
|
|
38779
39097
|
});
|
|
38780
39098
|
}
|
|
38781
39099
|
/**
|
|
38782
|
-
* Whether each element a batch names is named once,
|
|
38783
|
-
*
|
|
39100
|
+
* Whether each element a batch names is named once, twice as one `text`
|
|
39101
|
+
* change and one `style` or `styles` change, or by `attribute` changes that
|
|
39102
|
+
* each name another attribute.
|
|
38784
39103
|
*/
|
|
38785
39104
|
function namedOnceEach(indexes, edits) {
|
|
38786
|
-
const
|
|
38787
|
-
for (const [at, index] of indexes.entries())
|
|
38788
|
-
|
|
39105
|
+
const changes = /* @__PURE__ */ new Map();
|
|
39106
|
+
for (const [at, index] of indexes.entries()) {
|
|
39107
|
+
const change = edits[at]?.change;
|
|
39108
|
+
if (change) changes.set(index, [...changes.get(index) ?? [], change]);
|
|
39109
|
+
}
|
|
39110
|
+
return [...changes.values()].every((named) => named.length === 1 || textAndStyle(named) || separateAttributes(named));
|
|
39111
|
+
}
|
|
39112
|
+
function textAndStyle(named) {
|
|
39113
|
+
return named.length === 2 && named.filter(({ kind }) => kind === "text").length === 1 && named.some(({ kind }) => kind === "style" || kind === "styles");
|
|
39114
|
+
}
|
|
39115
|
+
function separateAttributes(named) {
|
|
39116
|
+
const names = named.flatMap((change) => change.kind === "attribute" ? [change.name.toLowerCase()] : []);
|
|
39117
|
+
return names.length === named.length && new Set(names).size === names.length;
|
|
38789
39118
|
}
|
|
38790
39119
|
/**
|
|
38791
|
-
* Writes one new element
|
|
38792
|
-
*
|
|
38793
|
-
*
|
|
39120
|
+
* Writes one new element, refusing a moved hash with no search, since the
|
|
39121
|
+
* gap's indices name nothing once the file moved, so a retry lands at most
|
|
39122
|
+
* once. With `viewer`, it adds the viewer's script, which an undo leaves.
|
|
38794
39123
|
*/
|
|
38795
|
-
function insertFrameFile(path, hash, placement, markup, place) {
|
|
39124
|
+
function insertFrameFile(path, hash, placement, markup, place, viewer = false) {
|
|
38796
39125
|
const read = readSource(path);
|
|
38797
39126
|
if (!read.ok) return read;
|
|
38798
39127
|
if (read.hash !== hash) return stale$1(path);
|
|
38799
|
-
const
|
|
39128
|
+
const scripted = viewer ? ensureViewerScript(read.source) : {
|
|
39129
|
+
ok: true,
|
|
39130
|
+
html: read.source,
|
|
39131
|
+
index: null
|
|
39132
|
+
};
|
|
39133
|
+
if (!scripted.ok) return scripted;
|
|
39134
|
+
const script = scripted.index;
|
|
39135
|
+
const pastScript = (index) => script !== null && index >= script ? index + 1 : index;
|
|
39136
|
+
const inserted = insertElement(scripted.html, {
|
|
39137
|
+
parent: pastScript(placement.parent),
|
|
39138
|
+
before: placement.before === null ? null : pastScript(placement.before)
|
|
39139
|
+
}, markup);
|
|
38800
39140
|
if (!inserted.ok) return inserted;
|
|
38801
39141
|
const placed = place?.(inserted.html, inserted.index);
|
|
38802
39142
|
if (placed && !placed.ok) return placed;
|
|
@@ -38804,6 +39144,7 @@ function insertFrameFile(path, hash, placement, markup, place) {
|
|
|
38804
39144
|
const element = parseFrame(html).elements[inserted.index];
|
|
38805
39145
|
if (!element) return stale$1(path);
|
|
38806
39146
|
if (!replaceFile(path, hash, html)) return stale$1(path);
|
|
39147
|
+
const pastElement = shiftedPast(inserted.index, subtreeSize(html, inserted.index));
|
|
38807
39148
|
return {
|
|
38808
39149
|
ok: true,
|
|
38809
39150
|
hash: contentHash(html),
|
|
@@ -38813,7 +39154,7 @@ function insertFrameFile(path, hash, placement, markup, place) {
|
|
|
38813
39154
|
markup: spanText(html, element, "element")
|
|
38814
39155
|
},
|
|
38815
39156
|
parent: placed && placed.spans.length > 1 ? placed.spans[0] ?? null : null,
|
|
38816
|
-
remap:
|
|
39157
|
+
remap: (index) => pastElement(pastScript(index))
|
|
38817
39158
|
};
|
|
38818
39159
|
}
|
|
38819
39160
|
/**
|
|
@@ -39040,6 +39381,33 @@ function replaceFile(path, hash, html) {
|
|
|
39040
39381
|
renameSync(temp, path);
|
|
39041
39382
|
return true;
|
|
39042
39383
|
}
|
|
39384
|
+
// src/server/models/viewer.ts
|
|
39385
|
+
/**
|
|
39386
|
+
* The viewer build a project's copy is taken from. A built run reads the
|
|
39387
|
+
* `viewer` folder the build put beside the bundle, and a source run reads the
|
|
39388
|
+
* pinned package.
|
|
39389
|
+
*/
|
|
39390
|
+
function shippedViewerPath(moduleUrl = import.meta.url) {
|
|
39391
|
+
if (!moduleUrl.endsWith(".ts")) return fileURLToPath(new URL(`./viewer/${VIEWER_FILE}`, moduleUrl));
|
|
39392
|
+
const manifest = createRequire(moduleUrl).resolve("@google/model-viewer/package.json");
|
|
39393
|
+
return join(dirname(manifest), "dist", VIEWER_FILE);
|
|
39394
|
+
}
|
|
39395
|
+
/**
|
|
39396
|
+
* Copies the viewer script into a project's `assets/` unless a file already
|
|
39397
|
+
* holds its name, answering whether this call wrote it. A frame loads nothing
|
|
39398
|
+
* over the network, so each project carries its own copy.
|
|
39399
|
+
*/
|
|
39400
|
+
async function ensureViewer(projectDir, shipped = shippedViewerPath()) {
|
|
39401
|
+
const folder = join(projectDir, ASSETS_FOLDER);
|
|
39402
|
+
await mkdir(folder, { recursive: true });
|
|
39403
|
+
try {
|
|
39404
|
+
await copyFile(shipped, join(folder, VIEWER_FILE), constants.COPYFILE_EXCL);
|
|
39405
|
+
return true;
|
|
39406
|
+
} catch (error) {
|
|
39407
|
+
if (isCode(error, "EEXIST")) return false;
|
|
39408
|
+
throw error;
|
|
39409
|
+
}
|
|
39410
|
+
}
|
|
39043
39411
|
// src/shared/records/notes.ts
|
|
39044
39412
|
/** Where a note on one element points, in the edit address's terms. */
|
|
39045
39413
|
const noteAnchorSchema = looseObject({
|
|
@@ -40749,7 +41117,7 @@ const insertSchema = object$1({
|
|
|
40749
41117
|
orFlow: boolean$1().optional()
|
|
40750
41118
|
}).optional()
|
|
40751
41119
|
});
|
|
40752
|
-
const removeSchema = union([object$1({
|
|
41120
|
+
const removeSchema$1 = union([object$1({
|
|
40753
41121
|
ref: string$1().min(1).max(1024),
|
|
40754
41122
|
index: int$1().min(0),
|
|
40755
41123
|
hash: string$1().regex(/^[0-9a-f]{64}$/)
|
|
@@ -40928,14 +41296,16 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
40928
41296
|
}, 409);
|
|
40929
41297
|
element = {
|
|
40930
41298
|
...body.element,
|
|
40931
|
-
tag: asset.kind
|
|
41299
|
+
tag: assetTag(asset.kind)
|
|
40932
41300
|
};
|
|
40933
41301
|
}
|
|
41302
|
+
const viewer = element.kind === "asset" && element.tag === "model-viewer";
|
|
41303
|
+
if (viewer) await ensureViewer(join(root, frame.project));
|
|
40934
41304
|
const { at } = body;
|
|
40935
41305
|
const insert = (place) => insertFrameFile(frame.path, body.hash, {
|
|
40936
41306
|
parent: body.parent,
|
|
40937
41307
|
before: body.before
|
|
40938
|
-
}, elementMarkup(element, shapePaint(tokens), textFont(tokens)), place);
|
|
41308
|
+
}, elementMarkup(element, shapePaint(tokens), textFont(tokens)), place, viewer);
|
|
40939
41309
|
const placed = at && insert((html, index) => {
|
|
40940
41310
|
const bare = element.kind === "text" ? applyEdit(html, { index }, {
|
|
40941
41311
|
kind: "style",
|
|
@@ -40946,7 +41316,7 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
40946
41316
|
html
|
|
40947
41317
|
};
|
|
40948
41318
|
if (!bare.ok) return bare;
|
|
40949
|
-
const facts = elementPlaceFacts(frameFrom(frame, bare.html), tokenSheets(frame
|
|
41319
|
+
const facts = elementPlaceFacts(frameFrom(frame, bare.html), tokenSheets(frame));
|
|
40950
41320
|
return placeElement(bare.html, index, {
|
|
40951
41321
|
left: at.left,
|
|
40952
41322
|
top: at.top
|
|
@@ -40985,7 +41355,7 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
40985
41355
|
});
|
|
40986
41356
|
});
|
|
40987
41357
|
app.post("/api/frames/remove", requireWriter(access), async (c) => {
|
|
40988
|
-
const body = await parseBody$1(c.req.raw, removeSchema);
|
|
41358
|
+
const body = await parseBody$1(c.req.raw, removeSchema$1);
|
|
40989
41359
|
const frame = await resolveFrameRef(root, body.ref, { cwd: root });
|
|
40990
41360
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
40991
41361
|
await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
|
|
@@ -41097,7 +41467,7 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
41097
41467
|
index,
|
|
41098
41468
|
spot,
|
|
41099
41469
|
drop: spot ? [] : drop ?? []
|
|
41100
|
-
})), (html) => elementPlaceFacts(frameFrom(frame, html), tokenSheets(frame
|
|
41470
|
+
})), (html) => elementPlaceFacts(frameFrom(frame, html), tokenSheets(frame)));
|
|
41101
41471
|
if (!result.ok) return c.json({
|
|
41102
41472
|
ok: false,
|
|
41103
41473
|
error: {
|
|
@@ -41135,7 +41505,7 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
41135
41505
|
});
|
|
41136
41506
|
}
|
|
41137
41507
|
const source = readFrame$1(frame);
|
|
41138
|
-
const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame
|
|
41508
|
+
const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame)) : [];
|
|
41139
41509
|
const result = placeFrameFile(frame.path, body.hash, body.index, body.spot, facts, body.spot ? [] : body.drop ?? []);
|
|
41140
41510
|
if (!result.ok) return c.json({
|
|
41141
41511
|
ok: false,
|
|
@@ -41177,7 +41547,7 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
41177
41547
|
const ref = `${frame.project}/${frame.page}/${frame.name}`;
|
|
41178
41548
|
await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
|
|
41179
41549
|
const source = readFrame$1(frame);
|
|
41180
|
-
const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame
|
|
41550
|
+
const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame)) : [];
|
|
41181
41551
|
const result = wrapFrameFile(frame.path, body.hash, body.indexes, body.flow, body.spot, facts);
|
|
41182
41552
|
if (!result.ok) return c.json({
|
|
41183
41553
|
ok: false,
|
|
@@ -41262,86 +41632,11 @@ function editRoutes(root, access, history, version, sheets) {
|
|
|
41262
41632
|
data
|
|
41263
41633
|
});
|
|
41264
41634
|
});
|
|
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
|
-
};
|
|
41635
|
+
/** The sheets the frame renders with ahead of its own, as the frame route imports them. */
|
|
41636
|
+
const tokenSheets = (frame) => sheets ? readSheets(root, frame.project, sheets(frame.project), frameKit(frame)) : [];
|
|
41275
41637
|
app.onError(answerRefusal);
|
|
41276
41638
|
return app;
|
|
41277
41639
|
}
|
|
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
41640
|
// src/shared/records/selection.ts
|
|
41346
41641
|
const hashSchema = string$1().regex(/^[0-9a-f]{64}$/);
|
|
41347
41642
|
/** More frames than any page holds, so a report cannot grow without bound. */
|
|
@@ -41401,7 +41696,7 @@ function elementsRoutes(root, access, selection, tokens = null) {
|
|
|
41401
41696
|
const frame = await resolveFrameRef(root, ref, { cwd: root });
|
|
41402
41697
|
const bytes = await readFile(frame.path);
|
|
41403
41698
|
const source = readFrame$1(frame);
|
|
41404
|
-
const sheets = tokenSheets(root, frame.project, tokens);
|
|
41699
|
+
const sheets = tokenSheets(root, frame.project, tokens, frameKit(frame));
|
|
41405
41700
|
const elements = elementTree(bytes.toString("utf8"), elementLayouts(source, sheets), elementRounds(source, sheets), elementPlaceFacts(source, sheets));
|
|
41406
41701
|
if (!Array.isArray(elements)) throw new FrameboardError(elements.reason, elements.detail, { ref });
|
|
41407
41702
|
return {
|
|
@@ -41441,7 +41736,7 @@ function elementsRoutes(root, access, selection, tokens = null) {
|
|
|
41441
41736
|
const data = {
|
|
41442
41737
|
ref: source.ref,
|
|
41443
41738
|
hash: contentHash(source.html),
|
|
41444
|
-
...frameStyles(source, tokenSheets(root, frame.project, tokens), index)
|
|
41739
|
+
...frameStyles(source, tokenSheets(root, frame.project, tokens, frameKit(frame)), index)
|
|
41445
41740
|
};
|
|
41446
41741
|
return c.json({
|
|
41447
41742
|
ok: true,
|
|
@@ -41754,99 +42049,73 @@ async function boardKitNames(root) {
|
|
|
41754
42049
|
}
|
|
41755
42050
|
// src/server/kits/install.ts
|
|
41756
42051
|
/**
|
|
41757
|
-
*
|
|
41758
|
-
*
|
|
41759
|
-
*
|
|
41760
|
-
*/
|
|
41761
|
-
async function takeOutLook(root, ref, { journal } = {}) {
|
|
41762
|
-
const project = await resolveProject(root, ref);
|
|
41763
|
-
const taken = [];
|
|
41764
|
-
for (const old of lookPaths(project.path)) {
|
|
41765
|
-
if (!existsSync(old)) continue;
|
|
41766
|
-
if (journal) await journal.removed(old);
|
|
41767
|
-
else await rm(old, { recursive: true });
|
|
41768
|
-
taken.push(old);
|
|
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.
|
|
42052
|
+
* Adds a kit to a project as a copy of its folder under `assets/kits/`, so
|
|
42053
|
+
* a frame can name it, touching no token sheet and no page. Refuses
|
|
42054
|
+
* `name-taken` where the project holds a kit by that name, writing nothing.
|
|
41784
42055
|
*/
|
|
41785
|
-
async function installKit(root, ref, kit, {
|
|
42056
|
+
async function installKit(root, ref, kit, { journal } = {}) {
|
|
41786
42057
|
const project = await resolveProject(root, ref);
|
|
41787
|
-
|
|
41788
|
-
const
|
|
41789
|
-
const
|
|
41790
|
-
|
|
41791
|
-
|
|
41792
|
-
|
|
41793
|
-
|
|
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
|
-
}
|
|
42058
|
+
assertValidName("kit", kit.name);
|
|
42059
|
+
const held = matchName(await projectKitNames(project.path), kit.name);
|
|
42060
|
+
const target = projectKitDir(project.path, kit.name);
|
|
42061
|
+
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}\`.`, {
|
|
42062
|
+
project: project.name,
|
|
42063
|
+
kit: held ?? kit.name
|
|
42064
|
+
});
|
|
41800
42065
|
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, {
|
|
42066
|
+
const made = topmostMissing(target);
|
|
42067
|
+
await mkdir(dirname(target), { recursive: true });
|
|
42068
|
+
await cp(kit.path, target, {
|
|
41813
42069
|
recursive: true,
|
|
41814
42070
|
errorOnExist: true,
|
|
41815
42071
|
force: false,
|
|
41816
|
-
filter: (path) =>
|
|
42072
|
+
filter: (path) => isKitFile(kit.path, path)
|
|
41817
42073
|
});
|
|
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
|
-
}
|
|
42074
|
+
await journal?.created(made);
|
|
41831
42075
|
return {
|
|
41832
42076
|
project: project.name,
|
|
41833
42077
|
kit: kit.name,
|
|
41834
|
-
written
|
|
42078
|
+
written: [target]
|
|
41835
42079
|
};
|
|
41836
42080
|
}
|
|
41837
|
-
/**
|
|
41838
|
-
function
|
|
42081
|
+
/** The highest folder on the way to `path` that does not exist yet, which an undo removes whole. */
|
|
42082
|
+
function topmostMissing(path) {
|
|
42083
|
+
const parent = dirname(path);
|
|
42084
|
+
return existsSync(parent) ? path : topmostMissing(parent);
|
|
42085
|
+
}
|
|
42086
|
+
/** Whether a path in the kit folder is copied, being anything but a dot-named entry or a lock or temp file. */
|
|
42087
|
+
function isKitFile(kitPath, path) {
|
|
41839
42088
|
const inside = relative(kitPath, path);
|
|
41840
42089
|
if (inside === "") return true;
|
|
41841
|
-
|
|
41842
|
-
if (rest.length === 0 && (top === "tokens.css" || top === "kit")) return false;
|
|
41843
|
-
return !top.startsWith(".") && isCopied(basename(path));
|
|
42090
|
+
return !inside.split("/").some((part) => part.startsWith(".")) && isCopied(basename(path));
|
|
41844
42091
|
}
|
|
41845
|
-
|
|
41846
|
-
|
|
41847
|
-
|
|
41848
|
-
|
|
41849
|
-
|
|
42092
|
+
// src/server/kits/remove.ts
|
|
42093
|
+
/**
|
|
42094
|
+
* Takes a kit out of a project and clears it from every frame naming it,
|
|
42095
|
+
* under every page's lock, so no frame is left naming a folder that is
|
|
42096
|
+
* gone. Refuses `kit-not-found` for a name the project holds no kit under.
|
|
42097
|
+
*/
|
|
42098
|
+
async function removeKit(root, ref, kit, { journal } = {}) {
|
|
42099
|
+
const project = await resolveProject(root, ref);
|
|
42100
|
+
const held = await heldKit(project, kit);
|
|
42101
|
+
const frames = await withLayouts((await listPageFolders(project.path)).map((page) => join(project.path, page)), async (layouts) => {
|
|
42102
|
+
const cleared = [];
|
|
42103
|
+
for (const [page, layout] of layouts) for (const name of layout.names) {
|
|
42104
|
+
const { kit: named, ...rest } = layout.placement(name);
|
|
42105
|
+
if (named !== held) continue;
|
|
42106
|
+
layout.set(name, rest);
|
|
42107
|
+
cleared.push(`${project.name}/${basename(page)}/${name}`);
|
|
42108
|
+
}
|
|
42109
|
+
const folder = projectKitDir(project.path, held);
|
|
42110
|
+
if (journal) await journal.removed(folder);
|
|
42111
|
+
else await rm(folder, { recursive: true });
|
|
42112
|
+
return cleared;
|
|
42113
|
+
}, journal);
|
|
42114
|
+
return {
|
|
42115
|
+
project: project.name,
|
|
42116
|
+
kit: held,
|
|
42117
|
+
frames
|
|
42118
|
+
};
|
|
41850
42119
|
}
|
|
41851
42120
|
// src/server/kits/save.ts
|
|
41852
42121
|
/**
|
|
@@ -41867,7 +42136,7 @@ async function saveKit(root, ref, name, { tokens, journal } = {}) {
|
|
|
41867
42136
|
await mkdir(staging, { recursive: true });
|
|
41868
42137
|
try {
|
|
41869
42138
|
const assets = join(project.path, ASSETS_FOLDER, "kit");
|
|
41870
|
-
if (existsSync(assets)) await cp(assets, staging, {
|
|
42139
|
+
if (existsSync(join(assets, "kit.json"))) await cp(assets, staging, {
|
|
41871
42140
|
recursive: true,
|
|
41872
42141
|
filter: (from) => isCopied(basename(from))
|
|
41873
42142
|
});
|
|
@@ -42056,7 +42325,9 @@ const CONTENT_TYPES$2 = {
|
|
|
42056
42325
|
".mp3": "audio/mpeg",
|
|
42057
42326
|
".wav": "audio/wav",
|
|
42058
42327
|
".ogg": "audio/ogg",
|
|
42059
|
-
".m4a": "audio/mp4"
|
|
42328
|
+
".m4a": "audio/mp4",
|
|
42329
|
+
".glb": "model/gltf-binary",
|
|
42330
|
+
".gltf": "model/gltf+json"
|
|
42060
42331
|
};
|
|
42061
42332
|
/**
|
|
42062
42333
|
* Serves the board's frames so relative links resolve unrewritten, its own
|
|
@@ -42118,7 +42389,13 @@ function frameRoutes(root, look, version, base = "") {
|
|
|
42118
42389
|
if (held === null) return c.notFound();
|
|
42119
42390
|
bytes = new TextEncoder().encode(held);
|
|
42120
42391
|
}
|
|
42121
|
-
const
|
|
42392
|
+
const kit = isFrame ? frameKit({
|
|
42393
|
+
root,
|
|
42394
|
+
project,
|
|
42395
|
+
page,
|
|
42396
|
+
name: name.slice(0, -5)
|
|
42397
|
+
}) : null;
|
|
42398
|
+
const body = injectHead(bytes, frameHead(sheetUrls(project, look.sheets(project), kitSheetFiles(root, project, kit)).map((url) => `${base}${url}`), contentHash(bytes), `${base}${BRIDGE_URL}`));
|
|
42122
42399
|
return c.body(body, 200, {
|
|
42123
42400
|
"Content-Type": contentType,
|
|
42124
42401
|
"Cache-Control": "no-store"
|
|
@@ -42170,22 +42447,18 @@ function parseRange(header, size) {
|
|
|
42170
42447
|
}
|
|
42171
42448
|
/**
|
|
42172
42449
|
* The sheets a frame imports, being every face, then the board's tokens, then
|
|
42173
|
-
* the project's, then
|
|
42174
|
-
*
|
|
42450
|
+
* the project's, then its kit sheets, which read the tokens and still lose to
|
|
42451
|
+
* the frame's own sheets. `kitFiles` come as `kitSheetFiles` answers them.
|
|
42175
42452
|
*/
|
|
42176
|
-
function sheetUrls(project, sheets,
|
|
42453
|
+
function sheetUrls(project, sheets, kitFiles) {
|
|
42177
42454
|
const folder = `/frames/${encodeURIComponent(project)}`;
|
|
42178
42455
|
return [
|
|
42179
42456
|
...FACES.map(faceSheetUrl),
|
|
42180
42457
|
...sheets.board ? [BOARD_SHEET_URL] : [],
|
|
42181
42458
|
...sheets.project ? [`${folder}/${TOKEN_FILE}`] : [],
|
|
42182
|
-
...
|
|
42459
|
+
...kitFiles.map((file) => `${folder}/${file.split("/").map(encodeURIComponent).join("/")}`)
|
|
42183
42460
|
];
|
|
42184
42461
|
}
|
|
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
42462
|
function decodeSegments(segments) {
|
|
42190
42463
|
const decoded = [];
|
|
42191
42464
|
for (const segment of segments) {
|
|
@@ -42240,8 +42513,12 @@ const PREVIEW_POLICY = `script-src 'sha256-${createHash("sha256").update(THEME_S
|
|
|
42240
42513
|
const installSchema = object$1({
|
|
42241
42514
|
project: name$1,
|
|
42242
42515
|
kit: name$1,
|
|
42243
|
-
/**
|
|
42244
|
-
replace: boolean$1().
|
|
42516
|
+
/** Accepted and ignored, since a caller written for the install that replaced a look may still send it. */
|
|
42517
|
+
replace: boolean$1().optional()
|
|
42518
|
+
});
|
|
42519
|
+
const removeSchema = object$1({
|
|
42520
|
+
project: name$1,
|
|
42521
|
+
kit: name$1
|
|
42245
42522
|
});
|
|
42246
42523
|
const saveSchema = object$1({
|
|
42247
42524
|
project: name$1,
|
|
@@ -42263,15 +42540,15 @@ const CONTENT_TYPES$1 = {
|
|
|
42263
42540
|
*/
|
|
42264
42541
|
function kitRoutes(root, access, history, { tokens, shipped = shippedKitsDir() }) {
|
|
42265
42542
|
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) => {
|
|
42543
|
+
/** Runs one write with a fresh journal and records it as a step that moves no page, touching the frames `touched` reads off it. */
|
|
42544
|
+
const recorded = async (write, touched = () => []) => {
|
|
42268
42545
|
const journal = history.journal();
|
|
42269
42546
|
const result = await write(journal);
|
|
42270
42547
|
history.record({
|
|
42271
42548
|
id: journal.id,
|
|
42272
42549
|
changes: journal.changes,
|
|
42273
42550
|
page: null,
|
|
42274
|
-
frames:
|
|
42551
|
+
frames: touched(result)
|
|
42275
42552
|
});
|
|
42276
42553
|
return result;
|
|
42277
42554
|
};
|
|
@@ -42282,20 +42559,21 @@ function kitRoutes(root, access, history, { tokens, shipped = shippedKitsDir() }
|
|
|
42282
42559
|
app.post("/api/kits/install", requireWriter(access), async (c) => {
|
|
42283
42560
|
const body = await parseBody$1(c.req.raw, installSchema);
|
|
42284
42561
|
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
|
-
}));
|
|
42562
|
+
const installed = await recorded((journal) => installKit(root, body.project, kit, { journal }));
|
|
42294
42563
|
return c.json({
|
|
42295
42564
|
ok: true,
|
|
42296
42565
|
data: installed
|
|
42297
42566
|
});
|
|
42298
42567
|
});
|
|
42568
|
+
/** Takes a kit out of a project and off every frame naming it, as one step an undo brings back whole. */
|
|
42569
|
+
app.post("/api/kits/remove", requireWriter(access), async (c) => {
|
|
42570
|
+
const body = await parseBody$1(c.req.raw, removeSchema);
|
|
42571
|
+
const removed = await recorded((journal) => removeKit(root, body.project, body.kit, { journal }), (record) => record.frames);
|
|
42572
|
+
return c.json({
|
|
42573
|
+
ok: true,
|
|
42574
|
+
data: removed
|
|
42575
|
+
});
|
|
42576
|
+
});
|
|
42299
42577
|
app.post("/api/kits/save", requireWriter(access), async (c) => {
|
|
42300
42578
|
const body = await parseBody$1(c.req.raw, saveSchema);
|
|
42301
42579
|
const saved = await recorded((journal) => saveKit(root, body.project, body.name, {
|
|
@@ -44614,6 +44892,105 @@ async function waitForImages(timeoutMs) {
|
|
|
44614
44892
|
});
|
|
44615
44893
|
return unsettled;
|
|
44616
44894
|
}
|
|
44895
|
+
// src/server/capture/model-loads.ts
|
|
44896
|
+
/**
|
|
44897
|
+
* Records each viewer whose load fails, from before the frame's scripts run.
|
|
44898
|
+
* A viewer keeps no failed state to read and can fire its `error` ahead of
|
|
44899
|
+
* `settleModels`, which would then wait on an event already gone.
|
|
44900
|
+
*/
|
|
44901
|
+
async function watchModels(page) {
|
|
44902
|
+
await page.addInitScript(recordFailedModels);
|
|
44903
|
+
}
|
|
44904
|
+
function recordFailedModels() {
|
|
44905
|
+
const failed = /* @__PURE__ */ new WeakSet();
|
|
44906
|
+
Object.defineProperty(window, Symbol.for("frameboard.failed-models"), { value: failed });
|
|
44907
|
+
const isViewer = (target) => target instanceof Element && target.localName === "model-viewer";
|
|
44908
|
+
document.addEventListener("error", ({ target }) => {
|
|
44909
|
+
if (isViewer(target)) failed.add(target);
|
|
44910
|
+
}, true);
|
|
44911
|
+
document.addEventListener("load", ({ target }) => {
|
|
44912
|
+
if (isViewer(target)) failed.delete(target);
|
|
44913
|
+
}, true);
|
|
44914
|
+
}
|
|
44915
|
+
/**
|
|
44916
|
+
* Waits for each `<model-viewer>` to draw, holds it at its clip's start, and
|
|
44917
|
+
* hides its loading bar, so two captures match. A model with no picture is
|
|
44918
|
+
* returned, never refused, read from the failures `watchModels` recorded.
|
|
44919
|
+
*/
|
|
44920
|
+
async function settleModels(page, timeoutMs) {
|
|
44921
|
+
return page.evaluate(waitForModels, {
|
|
44922
|
+
timeoutMs: Math.max(0, timeoutMs),
|
|
44923
|
+
marker: LOOK_MARKER
|
|
44924
|
+
});
|
|
44925
|
+
}
|
|
44926
|
+
async function waitForModels({ timeoutMs, marker }) {
|
|
44927
|
+
const viewers = [];
|
|
44928
|
+
let index = 0;
|
|
44929
|
+
for (const element of document.querySelectorAll("*")) {
|
|
44930
|
+
if (element.closest("[data-frameboard]")) continue;
|
|
44931
|
+
const own = index;
|
|
44932
|
+
index += 1;
|
|
44933
|
+
if (element.localName !== "model-viewer") continue;
|
|
44934
|
+
const src = element.getAttribute("src") ?? "";
|
|
44935
|
+
if (!src) continue;
|
|
44936
|
+
viewers.push({
|
|
44937
|
+
index: own,
|
|
44938
|
+
viewer: element,
|
|
44939
|
+
src
|
|
44940
|
+
});
|
|
44941
|
+
}
|
|
44942
|
+
if (viewers.length === 0) return [];
|
|
44943
|
+
const bar = document.createElement("style");
|
|
44944
|
+
bar.setAttribute(marker, "");
|
|
44945
|
+
bar.textContent = "model-viewer { --progress-bar-height: 0px !important }";
|
|
44946
|
+
document.head.append(bar);
|
|
44947
|
+
const failed = window[Symbol.for("frameboard.failed-models")];
|
|
44948
|
+
const nextFrame = () => new Promise((done) => requestAnimationFrame(() => done()));
|
|
44949
|
+
const inViewport = (viewer) => new Promise((done) => {
|
|
44950
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
44951
|
+
observer.disconnect();
|
|
44952
|
+
done(entry?.isIntersecting ?? false);
|
|
44953
|
+
}, { threshold: 1e-5 });
|
|
44954
|
+
observer.observe(viewer);
|
|
44955
|
+
});
|
|
44956
|
+
const settle = async (viewer) => {
|
|
44957
|
+
if (!customElements.get("model-viewer")) return "error";
|
|
44958
|
+
viewer.loading = "eager";
|
|
44959
|
+
if (!viewer.loaded) {
|
|
44960
|
+
if (failed?.has(viewer)) return "error";
|
|
44961
|
+
if (!await new Promise((done) => {
|
|
44962
|
+
viewer.addEventListener("load", () => done(true), { once: true });
|
|
44963
|
+
viewer.addEventListener("error", () => done(false), { once: true });
|
|
44964
|
+
})) return "error";
|
|
44965
|
+
}
|
|
44966
|
+
viewer.pause();
|
|
44967
|
+
viewer.currentTime = 0;
|
|
44968
|
+
if (!await inViewport(viewer)) return "ok";
|
|
44969
|
+
while (!viewer.modelIsVisible && viewer.getAttribute("reveal") !== "manual") await nextFrame();
|
|
44970
|
+
await nextFrame();
|
|
44971
|
+
await nextFrame();
|
|
44972
|
+
return "ok";
|
|
44973
|
+
};
|
|
44974
|
+
const outcomes = viewers.map(({ viewer }) => ({
|
|
44975
|
+
state: "pending",
|
|
44976
|
+
done: settle(viewer)
|
|
44977
|
+
}));
|
|
44978
|
+
for (const outcome of outcomes) outcome.done.then((state) => {
|
|
44979
|
+
outcome.state = state;
|
|
44980
|
+
});
|
|
44981
|
+
await Promise.race([Promise.all(outcomes.map((outcome) => outcome.done)), new Promise((done) => setTimeout(done, timeoutMs))]);
|
|
44982
|
+
const unloaded = [];
|
|
44983
|
+
viewers.forEach(({ index: own, src }, at) => {
|
|
44984
|
+
const state = outcomes[at]?.state;
|
|
44985
|
+
if (state === void 0 || state === "ok") return;
|
|
44986
|
+
unloaded.push({
|
|
44987
|
+
index: own,
|
|
44988
|
+
src,
|
|
44989
|
+
state
|
|
44990
|
+
});
|
|
44991
|
+
});
|
|
44992
|
+
return unloaded;
|
|
44993
|
+
}
|
|
44617
44994
|
// src/shared/motion.ts
|
|
44618
44995
|
/**
|
|
44619
44996
|
* Finds a page's motion timeline. Capture evaluates it by source text, so it
|
|
@@ -44647,6 +45024,14 @@ async function readMotionIn(view, timeoutMs) {
|
|
|
44647
45024
|
duration: ends.length === 0 ? null : Math.round(Math.max(...ends))
|
|
44648
45025
|
};
|
|
44649
45026
|
}
|
|
45027
|
+
const clips = [...view.document.querySelectorAll("model-viewer")].map((viewer) => viewer).filter((viewer) => (viewer.availableAnimations?.length ?? 0) > 0);
|
|
45028
|
+
if (clips.length > 0) {
|
|
45029
|
+
const lengths = clips.map((viewer) => seconds(viewer.duration)).filter((length) => length !== null);
|
|
45030
|
+
return {
|
|
45031
|
+
source: "model",
|
|
45032
|
+
duration: lengths.length === 0 ? null : Math.max(...lengths)
|
|
45033
|
+
};
|
|
45034
|
+
}
|
|
44650
45035
|
return null;
|
|
44651
45036
|
};
|
|
44652
45037
|
await nextFrame();
|
|
@@ -44657,8 +45042,8 @@ async function readMotionIn(view, timeoutMs) {
|
|
|
44657
45042
|
}
|
|
44658
45043
|
}
|
|
44659
45044
|
/**
|
|
44660
|
-
* Holds the page at `ms` once painted, converting to the seconds HyperFrames
|
|
44661
|
-
* and
|
|
45045
|
+
* Holds the page at `ms` once painted, converting to the seconds HyperFrames,
|
|
45046
|
+
* GSAP, and a model viewer take here alone, self-contained as `readMotionIn` is.
|
|
44662
45047
|
*/
|
|
44663
45048
|
async function holdMotionIn(view, { motion, ms }) {
|
|
44664
45049
|
const at = motion.duration === null ? ms : Math.min(Math.max(ms, 0), motion.duration);
|
|
@@ -44670,10 +45055,16 @@ async function holdMotionIn(view, { motion, ms }) {
|
|
|
44670
45055
|
timeline.pause?.();
|
|
44671
45056
|
await timeline.seek(at / 1e3);
|
|
44672
45057
|
}
|
|
44673
|
-
} else for (const animation of view.document.getAnimations()) {
|
|
45058
|
+
} else if (motion.source === "css") for (const animation of view.document.getAnimations()) {
|
|
44674
45059
|
animation.pause();
|
|
44675
45060
|
animation.currentTime = at;
|
|
44676
45061
|
}
|
|
45062
|
+
for (const element of view.document.querySelectorAll("model-viewer")) {
|
|
45063
|
+
const viewer = element;
|
|
45064
|
+
if (typeof viewer.pause !== "function") continue;
|
|
45065
|
+
viewer.pause();
|
|
45066
|
+
viewer.currentTime = at / 1e3;
|
|
45067
|
+
}
|
|
44677
45068
|
await new Promise((done) => view.requestAnimationFrame(() => view.requestAnimationFrame(() => done())));
|
|
44678
45069
|
return at;
|
|
44679
45070
|
}
|
|
@@ -44828,9 +45219,9 @@ async function waitForVideos(timeoutMs) {
|
|
|
44828
45219
|
/** How long a frame has to load, its faces and images included, before its capture fails. */
|
|
44829
45220
|
const LOAD_TIMEOUT_MS = 1e4;
|
|
44830
45221
|
/**
|
|
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.
|
|
45222
|
+
* Loads a frame within one budget for faces, images, videos, and models, then
|
|
45223
|
+
* settles finite animations. A missing face or image refuses, while an
|
|
45224
|
+
* unloaded video or model is returned rather than refused.
|
|
44834
45225
|
*/
|
|
44835
45226
|
async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts = "require", timeoutMs = LOAD_TIMEOUT_MS, motion = "settle" }) {
|
|
44836
45227
|
const context = await browser.newContext({
|
|
@@ -44846,6 +45237,7 @@ async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts =
|
|
|
44846
45237
|
try {
|
|
44847
45238
|
const page = await context.newPage();
|
|
44848
45239
|
if (motion === "hold") await holdAnimationClock(page);
|
|
45240
|
+
if (fonts === "require") await watchModels(page);
|
|
44849
45241
|
await page.goto(new URL(frameThemeUrl(ref, theme), baseUrl).href, {
|
|
44850
45242
|
timeout: timeoutMs,
|
|
44851
45243
|
waitUntil: "domcontentloaded"
|
|
@@ -44859,10 +45251,12 @@ async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts =
|
|
|
44859
45251
|
if (fonts === "require") await assertFontsPresent(page, ref);
|
|
44860
45252
|
await settleImages(page, ref, fonts, deadline - Date.now());
|
|
44861
45253
|
const videos = fonts === "require" ? await settleVideos(page, deadline - Date.now()) : [];
|
|
45254
|
+
const models = fonts === "require" ? await settleModels(page, deadline - Date.now()) : [];
|
|
44862
45255
|
if (fonts === "require" && motion === "settle") await settleAnimations(page, deadline - Date.now());
|
|
44863
45256
|
return {
|
|
44864
45257
|
page,
|
|
44865
45258
|
videos,
|
|
45259
|
+
models,
|
|
44866
45260
|
close
|
|
44867
45261
|
};
|
|
44868
45262
|
} catch (error) {
|
|
@@ -45770,6 +46164,13 @@ const LINK_RULES = [
|
|
|
45770
46164
|
}
|
|
45771
46165
|
];
|
|
45772
46166
|
const finding$3 = findingFor(LINK_RULES);
|
|
46167
|
+
/** The attributes a `<model-viewer>` loads a file through, which `docs` states beside the rule. */
|
|
46168
|
+
const MODEL_LOADS = [
|
|
46169
|
+
"src",
|
|
46170
|
+
"poster",
|
|
46171
|
+
"environment-image",
|
|
46172
|
+
"skybox-image"
|
|
46173
|
+
];
|
|
45773
46174
|
/**
|
|
45774
46175
|
* The attributes that load a resource, by element. An `a href` navigates
|
|
45775
46176
|
* rather than loads, so it is left out.
|
|
@@ -45787,8 +46188,11 @@ const RESOURCE_ATTRIBUTES = {
|
|
|
45787
46188
|
object: ["data"],
|
|
45788
46189
|
input: ["src"],
|
|
45789
46190
|
image: ["href", "xlink:href"],
|
|
45790
|
-
use: ["href", "xlink:href"]
|
|
46191
|
+
use: ["href", "xlink:href"],
|
|
46192
|
+
"model-viewer": [...MODEL_LOADS]
|
|
45791
46193
|
};
|
|
46194
|
+
/** The lighting a viewer builds itself, which `environment-image` names in place of a file. */
|
|
46195
|
+
const BUILT_IN_ENVIRONMENTS = /* @__PURE__ */ new Set(["neutral", "legacy"]);
|
|
45792
46196
|
/** `outside-link`, `network`, and `missing-file` over every load a frame makes. */
|
|
45793
46197
|
function checkLinks(source) {
|
|
45794
46198
|
return frameLoads(source).flatMap((load) => judge(source, load));
|
|
@@ -45805,6 +46209,7 @@ function frameLoads(source) {
|
|
|
45805
46209
|
for (const name of RESOURCE_ATTRIBUTES[element.name] ?? []) {
|
|
45806
46210
|
const value = element.attribs[name];
|
|
45807
46211
|
if (value === void 0) continue;
|
|
46212
|
+
if (name === "environment-image" && BUILT_IN_ENVIRONMENTS.has(value)) continue;
|
|
45808
46213
|
const urls = name === "srcset" ? srcsetUrls(value) : [value];
|
|
45809
46214
|
for (const url of urls) loads.push({
|
|
45810
46215
|
url,
|
|
@@ -46173,8 +46578,9 @@ function checkFrame(target) {
|
|
|
46173
46578
|
findings: checkFrameIn(target, readProjectContext(target.root, target.project))
|
|
46174
46579
|
};
|
|
46175
46580
|
}
|
|
46176
|
-
function checkFrameIn(target, { config, tokens }) {
|
|
46581
|
+
function checkFrameIn(target, { config, tokens: tokensFor }) {
|
|
46177
46582
|
const source = readFrame$1(target);
|
|
46583
|
+
const tokens = tokensFor(frameKit(target));
|
|
46178
46584
|
const cascade = buildCascade(source, tokens);
|
|
46179
46585
|
return withoutOff([
|
|
46180
46586
|
...checkNaming(target, boardPath(target.root, source.path)),
|
|
@@ -46196,9 +46602,16 @@ function checkFrameIn(target, { config, tokens }) {
|
|
|
46196
46602
|
* address file names to every other caller.
|
|
46197
46603
|
*/
|
|
46198
46604
|
function readProjectContext(root, project, boardSheet) {
|
|
46605
|
+
const byKit = /* @__PURE__ */ new Map();
|
|
46199
46606
|
return {
|
|
46200
46607
|
config: readConfig(root, project),
|
|
46201
|
-
tokens:
|
|
46608
|
+
tokens: (kit) => {
|
|
46609
|
+
const held = byKit.get(kit);
|
|
46610
|
+
if (held) return held;
|
|
46611
|
+
const sheets = tokenSheets(root, project, boardSheet, kit);
|
|
46612
|
+
byKit.set(kit, sheets);
|
|
46613
|
+
return sheets;
|
|
46614
|
+
}
|
|
46202
46615
|
};
|
|
46203
46616
|
}
|
|
46204
46617
|
/**
|
|
@@ -46628,6 +47041,11 @@ const frameTransitionSchema = object$1({
|
|
|
46628
47041
|
refs,
|
|
46629
47042
|
transition: transition.nullable()
|
|
46630
47043
|
});
|
|
47044
|
+
/** Null clears each frame's kit, so it draws with the project's sheets alone. */
|
|
47045
|
+
const frameKitSchema = object$1({
|
|
47046
|
+
refs,
|
|
47047
|
+
kit: name.nullable()
|
|
47048
|
+
});
|
|
46631
47049
|
/**
|
|
46632
47050
|
* Blank text clears the note, and the setter refuses one past its limit.
|
|
46633
47051
|
* `expected` is the note the edit began from, so one an agent set since is kept.
|
|
@@ -46697,7 +47115,7 @@ const projectTokensSchema = object$1({
|
|
|
46697
47115
|
* frame hugs the player's height.
|
|
46698
47116
|
*/
|
|
46699
47117
|
function mediaMarkup(ref, path, kind, { width, height }) {
|
|
46700
|
-
const tag = kind
|
|
47118
|
+
const tag = assetTag(kind);
|
|
46701
47119
|
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
47120
|
ref,
|
|
46703
47121
|
path
|
|
@@ -46883,6 +47301,7 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
46883
47301
|
await refuseHeld([targetRef]);
|
|
46884
47302
|
const { asset: path, ...placing } = body;
|
|
46885
47303
|
let media;
|
|
47304
|
+
let head;
|
|
46886
47305
|
if (path !== void 0) {
|
|
46887
47306
|
const asset = await resolveAsset(join(root, target.project), path);
|
|
46888
47307
|
if (!asset.ok) return c.json({
|
|
@@ -46897,10 +47316,15 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
46897
47316
|
}
|
|
46898
47317
|
}, 409);
|
|
46899
47318
|
media = mediaMarkup(targetRef, path, asset.kind, body);
|
|
47319
|
+
if (asset.kind === "model") {
|
|
47320
|
+
await ensureViewer(join(root, target.project));
|
|
47321
|
+
head = VIEWER_SCRIPT;
|
|
47322
|
+
}
|
|
46900
47323
|
}
|
|
46901
47324
|
const frame = await recorded((journal) => addFrame(root, body.ref, {
|
|
46902
47325
|
...placing,
|
|
46903
47326
|
body: media,
|
|
47327
|
+
head,
|
|
46904
47328
|
cwd,
|
|
46905
47329
|
journal
|
|
46906
47330
|
}), (added) => onFrames([added.ref]));
|
|
@@ -47010,6 +47434,18 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
47010
47434
|
data: frames
|
|
47011
47435
|
});
|
|
47012
47436
|
});
|
|
47437
|
+
/** Sets or clears the project kit each frame draws with, in one step, leaving every frame file alone. */
|
|
47438
|
+
app.post("/api/frame/kit", async (c) => {
|
|
47439
|
+
const body = await parseBody$1(c.req.raw, frameKitSchema);
|
|
47440
|
+
const frames = await eachFrame(body.refs, (frame, journal) => setFrameKit(root, frame, body.kit, {
|
|
47441
|
+
cwd,
|
|
47442
|
+
journal
|
|
47443
|
+
}), (records) => records.map((record) => record.ref));
|
|
47444
|
+
return c.json({
|
|
47445
|
+
ok: true,
|
|
47446
|
+
data: frames
|
|
47447
|
+
});
|
|
47448
|
+
});
|
|
47013
47449
|
/** Sets or clears one frame's speaker note in one step, leaving its file alone. */
|
|
47014
47450
|
app.post("/api/frame/speaker-notes", async (c) => {
|
|
47015
47451
|
const body = await parseBody$1(c.req.raw, frameSpeakerNotesSchema);
|
|
@@ -47604,16 +48040,22 @@ async function withFrameHost(board, purpose, run) {
|
|
|
47604
48040
|
}
|
|
47605
48041
|
}
|
|
47606
48042
|
// src/server/capture/images.ts
|
|
47607
|
-
/** The `videos`
|
|
47608
|
-
function
|
|
47609
|
-
return
|
|
48043
|
+
/** The `videos` and `models` keys of an image, each left off when every one loaded. */
|
|
48044
|
+
function unloadedKeys(videos, models) {
|
|
48045
|
+
return {
|
|
48046
|
+
...videos.length === 0 ? {} : { videos },
|
|
48047
|
+
...models.length === 0 ? {} : { models }
|
|
48048
|
+
};
|
|
47610
48049
|
}
|
|
47611
|
-
function inFrame(ref,
|
|
47612
|
-
return
|
|
48050
|
+
function inFrame(ref, unloaded) {
|
|
48051
|
+
return unloaded.map((each) => ({
|
|
47613
48052
|
ref,
|
|
47614
|
-
...
|
|
48053
|
+
...each
|
|
47615
48054
|
}));
|
|
47616
48055
|
}
|
|
48056
|
+
function keysIn(ref, { videos, models }) {
|
|
48057
|
+
return unloadedKeys(inFrame(ref, videos), inFrame(ref, models));
|
|
48058
|
+
}
|
|
47617
48059
|
const SCREENSHOT = {
|
|
47618
48060
|
animations: "disabled",
|
|
47619
48061
|
caret: "hide"
|
|
@@ -47706,7 +48148,7 @@ async function captureFrameImages(browser, { baseUrl, frames, themes, out, scale
|
|
|
47706
48148
|
height: view.height,
|
|
47707
48149
|
scale,
|
|
47708
48150
|
...shot.scrollY === void 0 ? {} : { scrollY: shot.scrollY },
|
|
47709
|
-
...
|
|
48151
|
+
...keysIn(frame.ref, shot),
|
|
47710
48152
|
bytes: shot.bytes
|
|
47711
48153
|
});
|
|
47712
48154
|
}
|
|
@@ -47731,10 +48173,12 @@ async function captureComposite(browser, { baseUrl, page, frames, themes, out, s
|
|
|
47731
48173
|
for (const theme of themes) {
|
|
47732
48174
|
const tiles = [];
|
|
47733
48175
|
const videos = /* @__PURE__ */ new Map();
|
|
48176
|
+
const models = /* @__PURE__ */ new Map();
|
|
47734
48177
|
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
|
-
|
|
48178
|
+
const shot = await renderFrame(browser, baseUrl, frame, box, theme, scale);
|
|
48179
|
+
for (const video of inFrame(frame.ref, shot.videos)) videos.set(`${video.ref} ${video.index}`, video);
|
|
48180
|
+
for (const model of inFrame(frame.ref, shot.models)) models.set(`${model.ref} ${model.index}`, model);
|
|
48181
|
+
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
48182
|
}
|
|
47739
48183
|
rendered.push({
|
|
47740
48184
|
ref: page.ref,
|
|
@@ -47743,7 +48187,7 @@ async function captureComposite(browser, { baseUrl, page, frames, themes, out, s
|
|
|
47743
48187
|
width: bounds.width,
|
|
47744
48188
|
height: bounds.height,
|
|
47745
48189
|
scale,
|
|
47746
|
-
...
|
|
48190
|
+
...unloadedKeys([...videos.values()], [...models.values()]),
|
|
47747
48191
|
bytes: await renderComposite(browser, bounds, theme, tiles, scale)
|
|
47748
48192
|
});
|
|
47749
48193
|
}
|
|
@@ -47780,7 +48224,7 @@ async function captureMotionImages(browser, { baseUrl, frame, themes, out, scale
|
|
|
47780
48224
|
height: strip.height,
|
|
47781
48225
|
scale,
|
|
47782
48226
|
moments: strip.moments,
|
|
47783
|
-
...
|
|
48227
|
+
...keysIn(frame.ref, strip),
|
|
47784
48228
|
bytes: strip.bytes
|
|
47785
48229
|
});
|
|
47786
48230
|
continue;
|
|
@@ -47804,7 +48248,7 @@ async function captureMotionImages(browser, { baseUrl, frame, themes, out, scale
|
|
|
47804
48248
|
height: view.height,
|
|
47805
48249
|
scale,
|
|
47806
48250
|
at: held,
|
|
47807
|
-
...
|
|
48251
|
+
...keysIn(frame.ref, shots),
|
|
47808
48252
|
bytes
|
|
47809
48253
|
});
|
|
47810
48254
|
});
|
|
@@ -47825,7 +48269,7 @@ async function renderFilmstrip(browser, { baseUrl, frame, theme, scale = 1, coun
|
|
|
47825
48269
|
height: frame.box.height
|
|
47826
48270
|
};
|
|
47827
48271
|
const strip = filmstripBounds(frame.ref, view, count, scale);
|
|
47828
|
-
const { motion, held, videos } = await holdShots(browser, {
|
|
48272
|
+
const { motion, held, videos, models } = await holdShots(browser, {
|
|
47829
48273
|
baseUrl,
|
|
47830
48274
|
ref: frame.ref,
|
|
47831
48275
|
view,
|
|
@@ -47840,7 +48284,8 @@ async function renderFilmstrip(browser, { baseUrl, frame, theme, scale = 1, coun
|
|
|
47840
48284
|
height: strip.height,
|
|
47841
48285
|
moments: held.map((shot) => shot.held),
|
|
47842
48286
|
motion,
|
|
47843
|
-
videos
|
|
48287
|
+
videos,
|
|
48288
|
+
models
|
|
47844
48289
|
};
|
|
47845
48290
|
}
|
|
47846
48291
|
/**
|
|
@@ -47870,7 +48315,8 @@ async function holdShots(browser, { baseUrl, ref, view, theme, scale, motionTime
|
|
|
47870
48315
|
return {
|
|
47871
48316
|
motion,
|
|
47872
48317
|
held,
|
|
47873
|
-
videos: opened.videos
|
|
48318
|
+
videos: opened.videos,
|
|
48319
|
+
models: opened.models
|
|
47874
48320
|
};
|
|
47875
48321
|
} finally {
|
|
47876
48322
|
await opened.close();
|
|
@@ -47894,7 +48340,8 @@ async function renderFrame(browser, baseUrl, frame, view, theme, scale, scroll)
|
|
|
47894
48340
|
return {
|
|
47895
48341
|
bytes: await opened.page.screenshot(SCREENSHOT),
|
|
47896
48342
|
scrollY,
|
|
47897
|
-
videos: opened.videos
|
|
48343
|
+
videos: opened.videos,
|
|
48344
|
+
models: opened.models
|
|
47898
48345
|
};
|
|
47899
48346
|
} finally {
|
|
47900
48347
|
await opened.close();
|
|
@@ -48065,9 +48512,13 @@ async function pageOf(root, ref, options) {
|
|
|
48065
48512
|
const { pages } = await readPageOrder(join(root, resolved.project));
|
|
48066
48513
|
return scanPage(root, resolved.project, resolved.page, pages.indexOf(resolved.page));
|
|
48067
48514
|
}
|
|
48068
|
-
/** One line per image written, and under it one per video it shows with no picture. */
|
|
48515
|
+
/** One line per image written, and under it one per video or model it shows with no picture. */
|
|
48069
48516
|
function describe$6(images) {
|
|
48070
|
-
return images.flatMap((image) => [
|
|
48517
|
+
return images.flatMap((image) => [
|
|
48518
|
+
`Wrote ${image.path}`,
|
|
48519
|
+
...(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"}`),
|
|
48520
|
+
...(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"}`)
|
|
48521
|
+
]).join("\n");
|
|
48071
48522
|
}
|
|
48072
48523
|
// src/cli/board-server.ts
|
|
48073
48524
|
/** How long a running server has to answer before the verb gives up on it. */
|
|
@@ -48331,6 +48782,8 @@ const frameRecordSchema = object$1({
|
|
|
48331
48782
|
transition: transitionRecordSchema.optional(),
|
|
48332
48783
|
/** What the presenter means to say over the slide, plain text with its line breaks, absent when it holds none. */
|
|
48333
48784
|
speakerNotes: string$1().optional(),
|
|
48785
|
+
/** The project kit the frame names, absent when it names none, and still given where the project holds no such kit. */
|
|
48786
|
+
kit: string$1().optional(),
|
|
48334
48787
|
placed: boolean$1(),
|
|
48335
48788
|
modifiedAt: string$1()
|
|
48336
48789
|
});
|
|
@@ -48359,6 +48812,15 @@ const pageRecordSchema = object$1({
|
|
|
48359
48812
|
/** Bottom first, as frames are. */
|
|
48360
48813
|
sections: array$1(sectionRecordSchema)
|
|
48361
48814
|
});
|
|
48815
|
+
/** One kit a project added, a folder under its `assets/kits/`. */
|
|
48816
|
+
const projectKitRecordSchema = object$1({
|
|
48817
|
+
/** The kit's folder, which a frame's `kit` and `frame kit` name it by. */
|
|
48818
|
+
name: string$1(),
|
|
48819
|
+
/** The name a person reads, the folder's where its `kit.json` gives none. */
|
|
48820
|
+
title: string$1(),
|
|
48821
|
+
/** How many of the project's frames name the kit. */
|
|
48822
|
+
frameCount: number()
|
|
48823
|
+
});
|
|
48362
48824
|
const projectRecordSchema = object$1({
|
|
48363
48825
|
/** The folder, which every ref, URL, and CLI argument names the project by. */
|
|
48364
48826
|
name: string$1(),
|
|
@@ -48377,6 +48839,8 @@ const projectRecordSchema = object$1({
|
|
|
48377
48839
|
transitions: array$1(string$1()),
|
|
48378
48840
|
/** The rule ids `checks.off` in `project.json` turns off, in the file's order and each once, empty when it holds none. */
|
|
48379
48841
|
checksOff: array$1(string$1()),
|
|
48842
|
+
/** The kits the project added, by name, empty when it holds none. */
|
|
48843
|
+
kits: array$1(projectKitRecordSchema),
|
|
48380
48844
|
pages: array$1(pageRecordSchema)
|
|
48381
48845
|
});
|
|
48382
48846
|
const listResultSchema = object$1({
|
|
@@ -48411,6 +48875,16 @@ const captureResultSchema = object$1({
|
|
|
48411
48875
|
src: string$1(),
|
|
48412
48876
|
/** `error` for a file that failed to load or decode, `pending` for one still loading when the load budget ran out. */
|
|
48413
48877
|
state: _enum$1(["error", "pending"])
|
|
48878
|
+
})).optional(),
|
|
48879
|
+
/** Each model the image shows undrawn, absent when every model loaded. */
|
|
48880
|
+
models: array$1(object$1({
|
|
48881
|
+
/** The frame holding the model, which a composite needs to tell its frames apart. */
|
|
48882
|
+
ref: string$1(),
|
|
48883
|
+
/** The element's index in document order, as `edit --index` takes it. */
|
|
48884
|
+
index: int$1().min(0),
|
|
48885
|
+
src: string$1(),
|
|
48886
|
+
/** `error` for a model or a viewer script that failed to load, `pending` for one still loading when the load budget ran out. */
|
|
48887
|
+
state: _enum$1(["error", "pending"])
|
|
48414
48888
|
})).optional()
|
|
48415
48889
|
})),
|
|
48416
48890
|
/** The timeline an `--at` or `--filmstrip` capture seeked, absent on any other. */
|
|
@@ -48418,7 +48892,8 @@ const captureResultSchema = object$1({
|
|
|
48418
48892
|
source: _enum$1([
|
|
48419
48893
|
"hf",
|
|
48420
48894
|
"timelines",
|
|
48421
|
-
"css"
|
|
48895
|
+
"css",
|
|
48896
|
+
"model"
|
|
48422
48897
|
]),
|
|
48423
48898
|
/** Its length in ms, or null when every animation repeats forever. */
|
|
48424
48899
|
duration: int$1().min(0).nullable()
|
|
@@ -48915,8 +49390,10 @@ function contentFormat() {
|
|
|
48915
49390
|
],
|
|
48916
49391
|
kits: [
|
|
48917
49392
|
`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
|
-
`
|
|
49393
|
+
`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.`,
|
|
49394
|
+
`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.`,
|
|
49395
|
+
`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.`,
|
|
49396
|
+
`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
49397
|
],
|
|
48921
49398
|
images: [
|
|
48922
49399
|
`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 +49402,16 @@ function contentFormat() {
|
|
|
48925
49402
|
"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
49403
|
`A frame links a saved image as ../${ASSETS_FOLDER}/<path>, never by its web address, since a frame loads nothing over the network.`
|
|
48927
49404
|
],
|
|
49405
|
+
models: [
|
|
49406
|
+
`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).`,
|
|
49407
|
+
`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.`,
|
|
49408
|
+
`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.`,
|
|
49409
|
+
`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.`
|
|
49410
|
+
],
|
|
48928
49411
|
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
49412
|
look: [
|
|
48930
49413
|
`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
|
|
49414
|
+
`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
49415
|
`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
49416
|
"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
49417
|
`A change to a token sheet reloads every frame it reaches.`,
|
|
@@ -48986,6 +49469,8 @@ function formatLines(format) {
|
|
|
48986
49469
|
...format.kits.map((line) => `${INDENT}${line}`),
|
|
48987
49470
|
"Images",
|
|
48988
49471
|
...format.images.map((line) => `${INDENT}${line}`),
|
|
49472
|
+
"Models",
|
|
49473
|
+
...format.models.map((line) => `${INDENT}${line}`),
|
|
48989
49474
|
"Assets",
|
|
48990
49475
|
`${INDENT}${format.assets}`,
|
|
48991
49476
|
"Look",
|
|
@@ -49415,6 +49900,13 @@ function registerFrame(program, context) {
|
|
|
49415
49900
|
});
|
|
49416
49901
|
return done(record, record.transition ? `Set ${transitionLabel(record.transition.name)} on` : "Cleared the transition on");
|
|
49417
49902
|
});
|
|
49903
|
+
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) => {
|
|
49904
|
+
const record = await setFrameKit(await boardOf(options, io), ref, name === "none" ? null : name, {
|
|
49905
|
+
...options,
|
|
49906
|
+
cwd: io.cwd
|
|
49907
|
+
});
|
|
49908
|
+
return done(record, record.kit ? `Set the kit ${record.kit} on` : "Cleared the kit on");
|
|
49909
|
+
});
|
|
49418
49910
|
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
49911
|
if (clear && text !== void 0) throw new FrameboardError("usage", "Pass the text or --clear, not both.");
|
|
49420
49912
|
const root = await boardOf(options, io);
|
|
@@ -53419,28 +53911,36 @@ function describe$3(result) {
|
|
|
53419
53911
|
// src/cli/commands/kit.ts
|
|
53420
53912
|
function registerKit(program, context) {
|
|
53421
53913
|
const { io } = context;
|
|
53422
|
-
const kit = program.command("kit").description("
|
|
53423
|
-
act(addVerb(kit, "list", "List the kits a project can
|
|
53914
|
+
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");
|
|
53915
|
+
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
53916
|
const kits = await listKits(await boardOf(options, io));
|
|
53425
53917
|
return {
|
|
53426
53918
|
data: kits,
|
|
53427
53919
|
human: kits.map((each) => `${each.name}\t${each.description}`).join("\n")
|
|
53428
53920
|
};
|
|
53429
53921
|
});
|
|
53430
|
-
act(addVerb(kit, "add", "
|
|
53922
|
+
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
53923
|
if (name === void 0 === (options.from === void 0)) throw new FrameboardError("usage", "Name a kit or pass --from <folder>, not both.");
|
|
53432
53924
|
const root = await boardOf(options, io);
|
|
53433
53925
|
const folder = options.from === void 0 ? null : resolve$1(io.cwd, options.from);
|
|
53434
53926
|
const record = await installKit(root, project, folder === null ? findKit(root, name ?? "") : {
|
|
53435
53927
|
name: basename(folder),
|
|
53436
53928
|
path: folder
|
|
53437
|
-
}
|
|
53929
|
+
});
|
|
53930
|
+
return {
|
|
53931
|
+
data: record,
|
|
53932
|
+
human: `Added ${record.kit} to ${record.project}`
|
|
53933
|
+
};
|
|
53934
|
+
});
|
|
53935
|
+
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) => {
|
|
53936
|
+
const record = await removeKit(await boardOf(options, io), project, name);
|
|
53937
|
+
const count = record.frames.length;
|
|
53438
53938
|
return {
|
|
53439
53939
|
data: record,
|
|
53440
|
-
human: `
|
|
53940
|
+
human: `Removed ${record.kit} from ${record.project}, clearing it from ${count} ${count === 1 ? "frame" : "frames"}`
|
|
53441
53941
|
};
|
|
53442
53942
|
});
|
|
53443
|
-
act(addVerb(kit, "save", "Save a project's tokens, kit files, and kit page as a kit the board's projects can
|
|
53943
|
+
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
53944
|
const record = await saveKit(await boardOf(options, io), project, name);
|
|
53445
53945
|
return {
|
|
53446
53946
|
data: record,
|
|
@@ -58242,6 +58742,17 @@ function relistedRefs(previous, next) {
|
|
|
58242
58742
|
function listed(frame) {
|
|
58243
58743
|
return frame.widths.map(({ width }) => width).join(",");
|
|
58244
58744
|
}
|
|
58745
|
+
/**
|
|
58746
|
+
* Frames whose kit changed, reloaded here, since the kit lives in
|
|
58747
|
+
* `layout.json`, which reloads nothing, and the frame route imports its sheets.
|
|
58748
|
+
*/
|
|
58749
|
+
function rekittedRefs(previous, next) {
|
|
58750
|
+
const before = new Map(previous.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.map((frame) => [frame.ref, frame.kit ?? null]))));
|
|
58751
|
+
return next.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.filter((frame) => {
|
|
58752
|
+
const was = before.get(frame.ref);
|
|
58753
|
+
return was !== void 0 && was !== (frame.kit ?? null);
|
|
58754
|
+
}).map((frame) => frame.ref)));
|
|
58755
|
+
}
|
|
58245
58756
|
// src/server/live/findings.ts
|
|
58246
58757
|
/**
|
|
58247
58758
|
* The board's findings, held between batches so a hello needs no check, and
|
|
@@ -59435,6 +59946,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
|
|
|
59435
59946
|
let own;
|
|
59436
59947
|
let placed;
|
|
59437
59948
|
let relisted = [];
|
|
59949
|
+
let rekitted = [];
|
|
59438
59950
|
try {
|
|
59439
59951
|
await landReserved(root, /* @__PURE__ */ new Date()).catch(() => []);
|
|
59440
59952
|
board = await scanBoard(root);
|
|
@@ -59443,6 +59955,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
|
|
|
59443
59955
|
own = ownFileRefs(board, paths);
|
|
59444
59956
|
placed = previous ? placedRefs(previous, board, paths).filter((ref) => !own.includes(ref)) : [];
|
|
59445
59957
|
relisted = previous ? relistedRefs(previous, board) : [];
|
|
59958
|
+
rekitted = previous ? rekittedRefs(previous, board) : [];
|
|
59446
59959
|
if (await hug.now(board, [...own, ...placed]).catch(() => false)) {
|
|
59447
59960
|
const measured = board;
|
|
59448
59961
|
board = await scanBoard(root);
|
|
@@ -59462,7 +59975,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
|
|
|
59462
59975
|
});
|
|
59463
59976
|
const last = shown.board;
|
|
59464
59977
|
shown.board = board;
|
|
59465
|
-
const refs = reloadRefs(root, paths, board, tokens);
|
|
59978
|
+
const refs = [.../* @__PURE__ */ new Set([...reloadRefs(root, paths, board, tokens), ...rekitted])];
|
|
59466
59979
|
hug.later(board, [.../* @__PURE__ */ new Set([...refs, ...relisted])].filter((ref) => !own.includes(ref) && !placed.includes(ref)));
|
|
59467
59980
|
if (refs.length > 0) {
|
|
59468
59981
|
const reloads = unmovedRefs(refs, board, moved(), last);
|