frameboard 0.15.0 → 0.17.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.
Files changed (35) hide show
  1. package/dist/cli.js +188 -71
  2. package/dist/client/assets/index-EciSUFrP.css +2 -0
  3. package/dist/client/assets/index-LnvyTC8J.js +110 -0
  4. package/dist/client/index.html +2 -2
  5. package/dist/faces/inter/LICENSE +93 -0
  6. package/dist/faces/inter/files/inter-cyrillic-ext-wght-normal.woff2 +0 -0
  7. package/dist/faces/inter/files/inter-cyrillic-wght-normal.woff2 +0 -0
  8. package/dist/faces/inter/files/inter-greek-ext-wght-normal.woff2 +0 -0
  9. package/dist/faces/inter/files/inter-greek-wght-normal.woff2 +0 -0
  10. package/dist/faces/inter/files/inter-latin-ext-wght-normal.woff2 +0 -0
  11. package/dist/faces/inter/files/inter-latin-wght-normal.woff2 +0 -0
  12. package/dist/faces/inter/files/inter-vietnamese-wght-normal.woff2 +0 -0
  13. package/dist/faces/inter/index.css +69 -0
  14. package/dist/faces/source-serif-4/LICENSE +93 -0
  15. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-ext-wght-normal.woff2 +0 -0
  16. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-wght-normal.woff2 +0 -0
  17. package/dist/faces/source-serif-4/files/source-serif-4-greek-wght-normal.woff2 +0 -0
  18. package/dist/faces/source-serif-4/files/source-serif-4-latin-ext-wght-normal.woff2 +0 -0
  19. package/dist/faces/source-serif-4/files/source-serif-4-latin-wght-normal.woff2 +0 -0
  20. package/dist/faces/source-serif-4/files/source-serif-4-vietnamese-wght-normal.woff2 +0 -0
  21. package/dist/faces/source-serif-4/index.css +59 -0
  22. package/package.json +6 -4
  23. package/dist/client/assets/index-Dw9kkXht.css +0 -2
  24. package/dist/client/assets/index-l0GcY95w.js +0 -110
  25. package/dist/faces/geist/files/geist-cyrillic-ext-wght-italic.woff2 +0 -0
  26. package/dist/faces/geist/files/geist-cyrillic-wght-italic.woff2 +0 -0
  27. package/dist/faces/geist/files/geist-latin-ext-wght-italic.woff2 +0 -0
  28. package/dist/faces/geist/files/geist-latin-wght-italic.woff2 +0 -0
  29. package/dist/faces/geist/files/geist-vietnamese-wght-italic.woff2 +0 -0
  30. package/dist/faces/geist-mono/files/geist-mono-cyrillic-ext-wght-italic.woff2 +0 -0
  31. package/dist/faces/geist-mono/files/geist-mono-cyrillic-wght-italic.woff2 +0 -0
  32. package/dist/faces/geist-mono/files/geist-mono-latin-ext-wght-italic.woff2 +0 -0
  33. package/dist/faces/geist-mono/files/geist-mono-latin-wght-italic.woff2 +0 -0
  34. package/dist/faces/geist-mono/files/geist-mono-symbols2-wght-italic.woff2 +0 -0
  35. package/dist/faces/geist-mono/files/geist-mono-vietnamese-wght-italic.woff2 +0 -0
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import childProcess, { execFile, spawn } from "node:child_process";
4
4
  import { EventEmitter, once } from "node:events";
5
5
  import * as sp from "node:path";
6
6
  import path, { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
7
- import fs, { copyFileSync, createReadStream, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
7
+ import fs, { copyFileSync, createReadStream, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
8
8
  import process$1, { versions } from "node:process";
9
9
  import { isDeepStrictEqual, promisify, stripVTControlCharacters } from "node:util";
10
10
  import { constants, copyFile, cp, link, lstat, mkdir, open, readFile, readdir, readlink, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
@@ -9415,7 +9415,7 @@ async function isDirectory(path) {
9415
9415
  }
9416
9416
  }
9417
9417
  // package.json
9418
- var version$1 = "0.15.0";
9418
+ var version$1 = "0.17.0";
9419
9419
  var dependencies = { "playwright-core": "1.64.1" };
9420
9420
  // src/shared/version.ts
9421
9421
  const version = version$1;
@@ -28911,12 +28911,29 @@ function refuse$1(reason, detail) {
28911
28911
  detail
28912
28912
  };
28913
28913
  }
28914
+ function checkValue(value) {
28915
+ return value.length > MAX_VALUE_LENGTH ? refuse$1("invalid-edit", `the value runs past ${MAX_VALUE_LENGTH} characters`) : void 0;
28916
+ }
28917
+ function checkDeclaration({ property, value }) {
28918
+ const invalid = checkValue(value);
28919
+ if (invalid) return invalid;
28920
+ if (!PROPERTY_NAME.test(property)) return refuse$1("invalid-edit", `${property} is not a CSS property name`);
28921
+ if (DECLARATION_BREAK.test(value)) return refuse$1("invalid-edit", `${property} takes one value, with no ; { } < > or line break`);
28922
+ }
28914
28923
  function checkChange(change) {
28915
- if (change.value.length > MAX_VALUE_LENGTH) return refuse$1("invalid-edit", `the value runs past ${MAX_VALUE_LENGTH} characters`);
28916
- if (change.kind === "style") {
28917
- if (!PROPERTY_NAME.test(change.property)) return refuse$1("invalid-edit", `${change.property} is not a CSS property name`);
28918
- if (DECLARATION_BREAK.test(change.value)) return refuse$1("invalid-edit", `${change.property} takes one value, with no ; { } < > or line break`);
28924
+ if (change.kind === "style") return checkDeclaration(change);
28925
+ if (change.kind === "styles") {
28926
+ const { declarations } = change;
28927
+ if (declarations.length === 0) return refuse$1("invalid-edit", "a styles edit names no declaration");
28928
+ if (new Set(declarations.map(({ property }) => property)).size !== declarations.length) return refuse$1("invalid-edit", "a styles edit names one property twice, so one value would be lost");
28929
+ for (const declaration of declarations) {
28930
+ const invalid = checkDeclaration(declaration);
28931
+ if (invalid) return invalid;
28932
+ }
28933
+ return;
28919
28934
  }
28935
+ const invalid = checkValue(change.value);
28936
+ if (invalid) return invalid;
28920
28937
  if (change.kind === "attribute") {
28921
28938
  if (!ATTRIBUTE_NAME.test(change.name)) return refuse$1("invalid-edit", `${change.name} is not an attribute name`);
28922
28939
  if (change.name.toLowerCase() === "style") return refuse$1("invalid-edit", "style is edited one declaration at a time, as a style edit");
@@ -28935,7 +28952,7 @@ function scopeOf(change) {
28935
28952
  }
28936
28953
  /** The attribute name an edit writes, or undefined for a text edit. */
28937
28954
  function editedAttribute(change) {
28938
- if (change.kind === "style") return "style";
28955
+ if (change.kind === "style" || change.kind === "styles") return "style";
28939
28956
  if (change.kind === "attribute") return change.name;
28940
28957
  }
28941
28958
  function write(source, element, change) {
@@ -28947,11 +28964,16 @@ function write(source, element, change) {
28947
28964
  ok: true,
28948
28965
  html: setRawAttribute(source, element, change.name, escapeAttribute(change.value))
28949
28966
  };
28950
- const next = setDeclaration(rawAttribute(source, element, "style") ?? "", change.property, escapeAttribute(change.value));
28951
- if (!next.ok) return refuse$1("open-quote", `the style on <${element.tagName}> ends inside an open quote or comment`);
28967
+ const declarations = change.kind === "styles" ? change.declarations : [change];
28968
+ let style = rawAttribute(source, element, "style") ?? "";
28969
+ for (const { property, value } of declarations) {
28970
+ const next = setDeclaration(style, property, escapeAttribute(value));
28971
+ if (!next.ok) return refuse$1("open-quote", `the style on <${element.tagName}> ends inside an open quote or comment`);
28972
+ style = next.style;
28973
+ }
28952
28974
  return {
28953
28975
  ok: true,
28954
- html: next.style === "" ? removeAttribute(source, element, "style") : setRawAttribute(source, element, "style", next.style)
28976
+ html: style === "" ? removeAttribute(source, element, "style") : setRawAttribute(source, element, "style", style)
28955
28977
  };
28956
28978
  }
28957
28979
  /**
@@ -28990,13 +29012,17 @@ function textOf(element) {
28990
29012
  function holdsValue(element, change) {
28991
29013
  if (change.kind === "text") return textOf(element) === change.value;
28992
29014
  if (change.kind === "attribute") return element.attrs.find((attribute) => isNamed(attribute, change.name))?.value === change.value;
28993
- const declared = declaredValues(element.attrs.find((attribute) => attribute.name === "style")?.value ?? "", change.property);
28994
- const value = change.value.trim();
28995
- return value === "" ? declared.length === 0 : declared.length === 1 && declared[0] === value;
29015
+ const style = element.attrs.find((attribute) => attribute.name === "style")?.value ?? "";
29016
+ return (change.kind === "styles" ? change.declarations : [change]).every(({ property, value }) => {
29017
+ const declared = declaredValues(style, property);
29018
+ const wanted = value.trim();
29019
+ return wanted === "" ? declared.length === 0 : declared.length === 1 && declared[0] === wanted;
29020
+ });
28996
29021
  }
28997
29022
  /**
28998
29023
  * Applies one change to the element the address names and leaves every other
28999
- * byte of the source as it was. The output is parsed again and refused as
29024
+ * byte of the source as it was, a `styles` change writing each declaration in
29025
+ * turn into the one style attribute. The output is parsed again and refused as
29000
29026
  * `verify-failed` unless its tree is the input's with that one change, so an
29001
29027
  * input the guards never met is refused rather than written corrupted.
29002
29028
  */
@@ -29004,6 +29030,12 @@ function applyEdit(source, address, change) {
29004
29030
  const normalized = change.kind === "style" ? {
29005
29031
  ...change,
29006
29032
  property: change.property.toLowerCase()
29033
+ } : change.kind === "styles" ? {
29034
+ ...change,
29035
+ declarations: change.declarations.map((declaration) => ({
29036
+ ...declaration,
29037
+ property: declaration.property.toLowerCase()
29038
+ }))
29007
29039
  } : change.kind === "attribute" ? {
29008
29040
  ...change,
29009
29041
  name: change.name.toLowerCase()
@@ -29032,6 +29064,79 @@ function applyEdit(source, address, change) {
29032
29064
  span
29033
29065
  };
29034
29066
  }
29067
+ // src/shared/faces.ts
29068
+ const FACES = [
29069
+ {
29070
+ family: "Geist",
29071
+ package: "@fontsource-variable/geist",
29072
+ packageFamily: "Geist Variable",
29073
+ folder: "geist",
29074
+ weights: {
29075
+ min: 100,
29076
+ max: 900
29077
+ },
29078
+ fallback: "sans-serif",
29079
+ startsLook: true
29080
+ },
29081
+ {
29082
+ family: "Geist Mono",
29083
+ package: "@fontsource-variable/geist-mono",
29084
+ packageFamily: "Geist Mono Variable",
29085
+ folder: "geist-mono",
29086
+ weights: {
29087
+ min: 100,
29088
+ max: 900
29089
+ },
29090
+ fallback: "monospace",
29091
+ startsLook: true
29092
+ },
29093
+ {
29094
+ family: "Inter",
29095
+ package: "@fontsource-variable/inter",
29096
+ packageFamily: "Inter Variable",
29097
+ folder: "inter",
29098
+ weights: {
29099
+ min: 100,
29100
+ max: 900
29101
+ },
29102
+ fallback: "sans-serif",
29103
+ startsLook: true
29104
+ },
29105
+ {
29106
+ family: "Source Serif 4",
29107
+ package: "@fontsource-variable/source-serif-4",
29108
+ packageFamily: "Source Serif 4 Variable",
29109
+ folder: "source-serif-4",
29110
+ weights: {
29111
+ min: 200,
29112
+ max: 900
29113
+ },
29114
+ fallback: "serif",
29115
+ startsLook: true
29116
+ },
29117
+ {
29118
+ family: "Caveat",
29119
+ package: "@fontsource-variable/caveat",
29120
+ packageFamily: "Caveat Variable",
29121
+ folder: "caveat",
29122
+ weights: {
29123
+ min: 400,
29124
+ max: 700
29125
+ },
29126
+ fallback: "cursive",
29127
+ startsLook: false
29128
+ }
29129
+ ];
29130
+ /** Where the server serves the faces folder. */
29131
+ const FACES_URL = "/frameboard/faces";
29132
+ /** The sheet a frame imports to get one face. */
29133
+ function faceSheetUrl(face) {
29134
+ return `${FACES_URL}/${face.folder}/index.css`;
29135
+ }
29136
+ /** The stack naming a face then its fallback, as `'Geist Mono', monospace`. */
29137
+ function faceStack(face) {
29138
+ return `${/\s/.test(face.family) ? `'${face.family}'` : face.family}, ${face.fallback}`;
29139
+ }
29035
29140
  // src/shared/starter-tokens.ts
29036
29141
  /**
29037
29142
  * The looks a new project can start from, each accent paired by hand with a
@@ -29061,16 +29166,10 @@ const STARTER_ACCENTS = {
29061
29166
  }
29062
29167
  };
29063
29168
  /** The served faces a starter sheet may name, keyed by their face folder. */
29064
- const STARTER_FONTS = {
29065
- geist: {
29066
- family: "Geist",
29067
- stack: "Geist, sans-serif"
29068
- },
29069
- "geist-mono": {
29070
- family: "Geist Mono",
29071
- stack: "'Geist Mono', monospace"
29072
- }
29073
- };
29169
+ const STARTER_FONTS = Object.fromEntries(FACES.filter((face) => face.startsLook).map((face) => [face.folder, {
29170
+ family: face.family,
29171
+ stack: faceStack(face)
29172
+ }]));
29074
29173
  const DEFAULT_LOOK = {
29075
29174
  accent: "blue",
29076
29175
  font: "geist"
@@ -29647,6 +29746,13 @@ const editSchema = object$1({
29647
29746
  object$1({
29648
29747
  kind: literal("text"),
29649
29748
  value
29749
+ }),
29750
+ object$1({
29751
+ kind: literal("styles"),
29752
+ declarations: array$1(object$1({
29753
+ property: name$1,
29754
+ value
29755
+ })).max(16)
29650
29756
  })
29651
29757
  ])
29652
29758
  });
@@ -29691,7 +29797,8 @@ const moveSchema$1 = object$1({
29691
29797
  *
29692
29798
  * The edit's body mirrors
29693
29799
  * `edit`'s flags with the hash required, since the board always holds the
29694
- * one it rendered. It writes through `editFrameFile`, which finds the element
29800
+ * one it rendered, plus a `styles` change the CLI never sends, which writes
29801
+ * several declarations as one step. It writes through `editFrameFile`, which finds the element
29695
29802
  * again in a frame an agent wrote since from the source `version` kept, and
29696
29803
  * records the edited element's span as one step. It answers the `edit`
29697
29804
  * record with the index written and the hash written over. Each refusal the
@@ -35118,7 +35225,9 @@ const PROPERTIES = /* @__PURE__ */ new Set([
35118
35225
  "border-color",
35119
35226
  "border-width",
35120
35227
  "border",
35121
- "box-shadow"
35228
+ "box-shadow",
35229
+ "font-family",
35230
+ "font"
35122
35231
  ]);
35123
35232
  /** The colors Selection colors lists, each a property every element may set. */
35124
35233
  const COLOR_PROPERTIES = [
@@ -35187,12 +35296,18 @@ function frameStyles(source, tokens, index) {
35187
35296
  const part = found.shorthand ? shorthandPart(found.value, property) : found.value;
35188
35297
  return part === null ? null : styleValue(part);
35189
35298
  };
35299
+ const family = (element) => {
35300
+ const found = cascade.specified(element, "font-family");
35301
+ if (!found || found.userAgent || found.shorthand) return null;
35302
+ return styleValue(found.value);
35303
+ };
35190
35304
  const element = target ? {
35191
35305
  color: read(target, "color"),
35192
35306
  backgroundColor: read(target, "background-color"),
35193
35307
  borderColor: read(target, "border-color"),
35194
35308
  borderWidth: read(target, "border-width"),
35195
- boxShadow: read(target, "box-shadow")
35309
+ boxShadow: read(target, "box-shadow"),
35310
+ fontFamily: family(target)
35196
35311
  } : null;
35197
35312
  const root = target ?? source.elements.find((candidate) => candidate.name === "body");
35198
35313
  const subtree = root ? source.elements.filter((candidate) => within(candidate, root)) : source.elements;
@@ -35557,33 +35672,6 @@ function historyRoutes(access, history) {
35557
35672
  app.onError(answerRefusal);
35558
35673
  return app;
35559
35674
  }
35560
- // src/shared/faces.ts
35561
- const FACES = [
35562
- {
35563
- family: "Geist",
35564
- package: "@fontsource-variable/geist",
35565
- packageFamily: "Geist Variable",
35566
- folder: "geist"
35567
- },
35568
- {
35569
- family: "Geist Mono",
35570
- package: "@fontsource-variable/geist-mono",
35571
- packageFamily: "Geist Mono Variable",
35572
- folder: "geist-mono"
35573
- },
35574
- {
35575
- family: "Caveat",
35576
- package: "@fontsource-variable/caveat",
35577
- packageFamily: "Caveat Variable",
35578
- folder: "caveat"
35579
- }
35580
- ];
35581
- /** Where the server serves the faces folder. */
35582
- const FACES_URL = "/frameboard/faces";
35583
- /** The sheet a frame imports to get one face. */
35584
- function faceSheetUrl(face) {
35585
- return `${FACES_URL}/${face.folder}/index.css`;
35586
- }
35587
35675
  // src/shared/board-urls.ts
35588
35676
  /** Where the server serves a frame's file, with each name encoded as its own segment. */
35589
35677
  function frameUrl(ref) {
@@ -37156,11 +37244,18 @@ function structureRoutes(root, access, history, measure, tokens = null) {
37156
37244
  });
37157
37245
  app.post("/api/frame/rename", async (c) => {
37158
37246
  const body = await parseBody$1(c.req.raw, renameSchema);
37159
- await refuseHeldFrames([body.ref]);
37247
+ const source = await readFrame$1(root, body.ref, { cwd });
37248
+ await refuseHeld([source.ref]);
37160
37249
  const frame = await recorded((journal) => renameFrame(root, body.ref, body.name, {
37161
37250
  cwd,
37162
37251
  journal
37163
- }), (renamed) => onFrames([renamed.ref]));
37252
+ }), async (renamed) => ({
37253
+ ...await onFrames([renamed.ref]),
37254
+ ...renamed.ref === source.ref ? {} : { renamed: {
37255
+ before: source.ref,
37256
+ after: renamed.ref
37257
+ } }
37258
+ }));
37164
37259
  return c.json({
37165
37260
  ok: true,
37166
37261
  data: frame
@@ -39619,13 +39714,15 @@ const styleValueSchema = object$1({
39619
39714
  /** The percent a `color-mix()` over the token or a raw hex's alpha keeps, 100 otherwise. */
39620
39715
  percent: number().min(0).max(100)
39621
39716
  });
39622
- /** The selected element's colors, border, and shadow, each null when no author rule sets it. */
39717
+ /** The selected element's colors, border, shadow, and font family, each null when no author rule sets it. */
39623
39718
  const elementStylesSchema = object$1({
39624
39719
  color: styleValueSchema.nullable(),
39625
39720
  backgroundColor: styleValueSchema.nullable(),
39626
39721
  borderColor: styleValueSchema.nullable(),
39627
39722
  borderWidth: styleValueSchema.nullable(),
39628
- boxShadow: styleValueSchema.nullable()
39723
+ boxShadow: styleValueSchema.nullable(),
39724
+ /** The family as written, inherited from an ancestor when the element states none, null for one a `font` shorthand sets. */
39725
+ fontFamily: styleValueSchema.nullable()
39629
39726
  });
39630
39727
  object$1({
39631
39728
  ref: string$1(),
@@ -48411,12 +48508,13 @@ function frameNameOf(name) {
48411
48508
  * agent wrote and then placed. Placing writes `layout.json` alone, which
48412
48509
  * reloads nothing, so these are measured without a reload. A frame that only
48413
48510
  * moved was placed in both, and one a folder rename carried has a new ref
48414
- * but a batch naming the folder alone, so both are left out.
48511
+ * but a batch naming the folder alone, so both are left out. Given no
48512
+ * `paths`, as for two scans of one batch, every page is read.
48415
48513
  */
48416
48514
  function placedRefs(previous, next, paths) {
48417
- const written = new Set(paths);
48515
+ const written = paths && new Set(paths);
48418
48516
  const before = new Set(previous.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.filter((frame) => frame.placed).map((frame) => frame.ref))));
48419
- return next.projects.flatMap((project) => project.pages.filter((page) => written.has(join(page.path, LAYOUT_FILE))).flatMap((page) => page.frames.filter((frame) => frame.placed && (frame.hugWidth || frame.hugHeight) && !before.has(frame.ref)).map((frame) => frame.ref)));
48517
+ return next.projects.flatMap((project) => project.pages.filter((page) => !written || written.has(join(page.path, "layout.json"))).flatMap((page) => page.frames.filter((frame) => frame.placed && (frame.hugWidth || frame.hugHeight) && !before.has(frame.ref)).map((frame) => frame.ref)));
48420
48518
  }
48421
48519
  // src/server/live/findings.ts
48422
48520
  /**
@@ -48669,14 +48767,17 @@ function createHug({ root, measure }) {
48669
48767
  if (size.empty) continue;
48670
48768
  stale ||= frame.hugWidth && size.width !== frame.box.width || frame.hugHeight && size.height !== frame.box.height;
48671
48769
  const page = `${frame.project}/${frame.page}`;
48672
- pages.set(page, {
48673
- ...pages.get(page),
48674
- [frame.name]: size
48675
- });
48770
+ pages.set(page, [...pages.get(page) ?? [], {
48771
+ frame,
48772
+ size
48773
+ }]);
48676
48774
  }
48677
48775
  let written = false;
48678
- for (const [page, sizes] of pages) {
48776
+ for (const [page, measured] of pages) {
48679
48777
  if (closed) break;
48778
+ const unchanged = await Promise.all(measured.map(({ frame }) => unchangedSince(frame)));
48779
+ const sizes = Object.fromEntries(measured.filter((_, index) => unchanged[index]).map(({ frame, size }) => [frame.name, size]));
48780
+ if (Object.keys(sizes).length === 0) continue;
48680
48781
  try {
48681
48782
  const names = await setMeasured(root, page, sizes, { cwd: root });
48682
48783
  written ||= names.length > 0;
@@ -48715,6 +48816,9 @@ async function writtenSinceLayout(board) {
48715
48816
  return hugging.filter((frame) => Date.parse(frame.modifiedAt) > layout).map((frame) => frame.ref);
48716
48817
  }))).flat();
48717
48818
  }
48819
+ async function unchangedSince(frame) {
48820
+ return new Date(await mtimeOf(frame.path)).toISOString() === frame.modifiedAt;
48821
+ }
48718
48822
  async function mtimeOf(path) {
48719
48823
  try {
48720
48824
  return (await stat(path)).mtimeMs;
@@ -49294,8 +49398,14 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
49294
49398
  own = ownFileRefs(board, paths);
49295
49399
  placed = previous ? placedRefs(previous, board, paths).filter((ref) => !own.includes(ref)) : [];
49296
49400
  if (await hug.now(board, [...own, ...placed]).catch(() => false)) {
49401
+ const measured = board;
49297
49402
  board = await scanBoard(root);
49298
49403
  scanned.board = board;
49404
+ const late = placedRefs(measured, board);
49405
+ if (late.length > 0) {
49406
+ placed = [...placed, ...late];
49407
+ if (await hug.now(board, late).catch(() => false)) board = await scanBoard(root);
49408
+ }
49299
49409
  }
49300
49410
  } catch {
49301
49411
  return;
@@ -49496,30 +49606,37 @@ const require$1 = createRequire(import.meta.url);
49496
49606
  function hasFaces(dir) {
49497
49607
  return FACES.every((face) => existsSync(join(dir, face.folder, "index.css")));
49498
49608
  }
49609
+ const FILE_REFERENCE = /url\(\s*(['"]?)\.\/files\/([^'")\s]+)\1\s*\)/g;
49610
+ /** The distinct file names a package sheet loads from its `files` folder. */
49611
+ function referencedFiles(sheet) {
49612
+ const names = [...sheet.matchAll(FILE_REFERENCE)].flatMap((m) => m[2] ? [m[2]] : []);
49613
+ return [...new Set(names)];
49614
+ }
49499
49615
  /**
49500
49616
  * Copies each face every frame imports from its package into `outDir`,
49501
- * replacing what was there. The faces fill a sibling folder first and rename
49502
- * into place, so `outDir` holds every file or does not exist, and an
49617
+ * replacing what was there. Only the files a package sheet references are
49618
+ * copied, and a reference to a file the package lacks throws. The faces fill
49619
+ * a sibling folder first and rename into place, so `outDir` holds every file or does not exist, and an
49503
49620
  * interrupted write leaves no half-filled face behind. Each sheet is
49504
49621
  * rewritten to declare the plain family a frame names, such as Geist, rather
49505
49622
  * than the package's own, such as Geist Variable. With `keepComplete`, a
49506
49623
  * folder that filled in meanwhile, as from a parallel run, stays as it is.
49507
49624
  */
49508
- function writeFaces(outDir, { keepComplete = false } = {}) {
49625
+ function writeFaces(outDir, { keepComplete = false, faces = FACES } = {}) {
49509
49626
  const staging = `${outDir}.${process.pid}.tmp`;
49510
49627
  rmSync(staging, {
49511
49628
  recursive: true,
49512
49629
  force: true
49513
49630
  });
49514
49631
  try {
49515
- for (const face of FACES) {
49632
+ for (const face of faces) {
49516
49633
  const from = dirname(require$1.resolve(`${face.package}/package.json`));
49517
49634
  const to = join(staging, face.folder);
49518
49635
  mkdirSync(join(to, "files"), { recursive: true });
49519
49636
  const sheet = readFileSync(join(from, "index.css"), "utf8");
49520
49637
  writeFileSync(join(to, "index.css"), sheet.replaceAll(`'${face.packageFamily}'`, `'${face.family}'`));
49521
49638
  copyFileSync(join(from, "LICENSE"), join(to, "LICENSE"));
49522
- for (const file of readdirSync(join(from, "files"))) if (file.endsWith(".woff2")) copyFileSync(join(from, "files", file), join(to, "files", file));
49639
+ for (const file of referencedFiles(sheet)) copyFileSync(join(from, "files", file), join(to, "files", file));
49523
49640
  }
49524
49641
  if (keepComplete && hasFaces(outDir)) return;
49525
49642
  rmSync(outDir, {