frameboard 0.22.0 → 0.23.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 CHANGED
@@ -9109,6 +9109,20 @@ const DEVICE_SIZES = [
9109
9109
  group: "slide",
9110
9110
  width: 1024,
9111
9111
  height: 768
9112
+ },
9113
+ {
9114
+ name: "og-card",
9115
+ label: "Open Graph",
9116
+ group: "social",
9117
+ width: 1200,
9118
+ height: 630
9119
+ },
9120
+ {
9121
+ name: "linkedin-post",
9122
+ label: "LinkedIn post",
9123
+ group: "social",
9124
+ width: 1200,
9125
+ height: 627
9112
9126
  }
9113
9127
  ];
9114
9128
  /** Every size name, the three presets first, then the devices. */
@@ -9482,7 +9496,7 @@ async function isDirectory(path) {
9482
9496
  }
9483
9497
  }
9484
9498
  // package.json
9485
- var version$1 = "0.22.0";
9499
+ var version$1 = "0.23.0";
9486
9500
  var dependencies = { "playwright-core": "1.64.1" };
9487
9501
  // src/shared/version.ts
9488
9502
  const version = version$1;
@@ -28095,7 +28109,7 @@ function readTokenTable(root, paths) {
28095
28109
  read.push({
28096
28110
  label,
28097
28111
  kind,
28098
- tokens: readSheet(bytes.toString("utf8"))
28112
+ tokens: readSheet$1(bytes.toString("utf8"))
28099
28113
  });
28100
28114
  sheets.push({
28101
28115
  path: label,
@@ -28134,7 +28148,7 @@ function readTokenTable(root, paths) {
28134
28148
  }))
28135
28149
  };
28136
28150
  }
28137
- function readSheet(css) {
28151
+ function readSheet$1(css) {
28138
28152
  const tokens = /* @__PURE__ */ new Map();
28139
28153
  postcss_default.parse(css).walkRules((rule) => {
28140
28154
  const side = sideOf(rule);
@@ -38414,9 +38428,10 @@ function themeOf(value, usage) {
38414
38428
  const NAME = /^--[\w-]+$/;
38415
38429
  const UNSAFE_VALUE = /[;{}\n\r]|\/\*/;
38416
38430
  /**
38417
- * The project sheet with `edit` applied, every byte outside the token's
38418
- * declarations left as it stood. `board` is the token's declarations in the
38419
- * board sheet. A one-theme edit keeps the other theme rendering as it did,
38431
+ * The project or board sheet with `edit` applied, every byte outside the
38432
+ * token's declarations left as it stood. `board` is the token's declarations
38433
+ * in the board sheet under it, none when `css` is the board sheet itself. A
38434
+ * one-theme edit keeps the other theme rendering as it did,
38420
38435
  * pinning its old value under that theme's rule when the new declaration
38421
38436
  * would reach it, since a project `:root` ties a board dark rule on
38422
38437
  * specificity and wins by coming later. Refuses `invalid-edit` for a name or
@@ -38469,7 +38484,7 @@ function tokenSides(css, name) {
38469
38484
  return sidesIn(parseSheet(css), name);
38470
38485
  }
38471
38486
  /**
38472
- * Writes the project sheet at `path` through a temporary file and a rename,
38487
+ * Writes the token sheet at `path` through a temporary file and a rename,
38473
38488
  * reading the sheet again just before the rename and leaving it as it is
38474
38489
  * when its hash is no longer `hash`. A null `hash` means the sheet did not
38475
38490
  * exist, so it is created only while none does. Takes no lock, since an
@@ -38512,7 +38527,7 @@ function parseSheet(css) {
38512
38527
  try {
38513
38528
  return postcss_default.parse(css);
38514
38529
  } catch (error) {
38515
- return refuse(`The project token sheet does not parse: ${error instanceof postcss_default.CssSyntaxError ? error.reason : String(error)}.`);
38530
+ return refuse(`The token sheet does not parse: ${error instanceof postcss_default.CssSyntaxError ? error.reason : String(error)}.`);
38516
38531
  }
38517
38532
  }
38518
38533
  /** Every declaration of `name` in a rule the table reads, by side, in sheet order. */
@@ -38631,7 +38646,9 @@ function refuse(message) {
38631
38646
  const common = {
38632
38647
  project: string$1().min(1).max(256),
38633
38648
  name: string$1().min(1).max(256),
38634
- /** The project sheet's hash as the tab read it, null when it had none. */
38649
+ /** The sheet the edit writes, the project's own when absent. */
38650
+ sheet: _enum$1(["project", "board"]).default("project"),
38651
+ /** That sheet's hash as the tab read it, null when it had none. */
38635
38652
  hash: string$1().regex(/^[0-9a-f]{64}$/).nullable()
38636
38653
  };
38637
38654
  const editSchema = union([object$1({
@@ -38649,15 +38666,19 @@ const editSchema = union([object$1({
38649
38666
  /**
38650
38667
  * The Theme tab's token write, behind `requireWriter`. `POST
38651
38668
  * /api/tokens/edit` sets one token the project's sheets list on one theme or
38652
- * both, or resets a token the project overrides back to the board's value,
38653
- * writing the project's `tokens.css` alone and creating it when the project
38654
- * has none. The board sheet and a `--tokens` sheet are never written. A
38655
- * `hash` the project sheet no longer has, or a sheet created since the tab
38656
- * read none, answers 409 `stale-tokens` with nothing written, which also
38657
- * lands a retried edit once. A name the sheets do not list, a value that is
38658
- * not one declaration, a reset with no board value, and a project sheet that
38659
- * does not parse answer 409 `invalid-edit`. A landed edit records one step
38660
- * and answers the token's values after it with the hash written.
38669
+ * both in the sheet `sheet` names. `project`, the default, writes the
38670
+ * project's `tokens.css`, creating it when the project has none, and a reset
38671
+ * there takes the project's override back to the board's value. `board`
38672
+ * writes the board's sheet, which every project without an override follows,
38673
+ * for a token that sheet already sets. A `hash` the named sheet no longer
38674
+ * has, or a project sheet created since the tab read none, answers 409
38675
+ * `stale-tokens` with nothing written, which also lands a retried edit once.
38676
+ * A name the sheets do not list, a value that is not one declaration, a
38677
+ * reset with no board value, and a sheet that does not parse answer 409
38678
+ * `invalid-edit`, as does a board edit that is a reset, names a token the
38679
+ * board sheet does not set, or meets a `--tokens` sheet outside the board
38680
+ * folder, which belongs to whatever handed it over. A landed edit records
38681
+ * one step and answers the token's values after it with the hash written.
38661
38682
  */
38662
38683
  function tokenRoutes(root, access, history, look) {
38663
38684
  const app = new Hono();
@@ -38665,9 +38686,14 @@ function tokenRoutes(root, access, history, look) {
38665
38686
  const body = await parseBody$1(c.req.raw, editSchema);
38666
38687
  const project = await resolveProject(root, body.project);
38667
38688
  const sheets = look.sheets(project.name);
38668
- const path = join(project.path, TOKEN_FILE);
38669
38689
  if (!readTokenTable(root, sheets).tokens.some((row) => row.name === body.name)) throw new FrameboardError("invalid-edit", `${project.name}'s token sheets set no ${body.name}.`, { name: body.name });
38670
- const css = readProjectSheet(path, body.hash, project.name);
38690
+ const target = body.sheet === "board" ? boardTarget(root, sheets.board, "reset" in body) : {
38691
+ path: join(project.path, TOKEN_FILE),
38692
+ under: boardSides(sheets.board, body.name)
38693
+ };
38694
+ const refuseStale = () => stale(project.name, body.sheet);
38695
+ const css = readSheet(target.path, body.hash, refuseStale);
38696
+ if (body.sheet === "board" && Object.keys(tokenSides(css, body.name)).length === 0) throw new FrameboardError("invalid-edit", `The board token sheet sets no ${body.name}, so it has no board value to change.`, { name: body.name });
38671
38697
  const edit = "reset" in body ? {
38672
38698
  name: body.name,
38673
38699
  reset: true
@@ -38676,12 +38702,12 @@ function tokenRoutes(root, access, history, look) {
38676
38702
  side: body.side,
38677
38703
  value: body.value
38678
38704
  };
38679
- const written = editTokenCss(css, boardSides(sheets.board, body.name), edit);
38680
- const outcome = writeTokenSheet(path, body.hash, written);
38681
- if (outcome === "stale") stale(project.name);
38705
+ const written = editTokenCss(css, target.under, edit);
38706
+ const outcome = writeTokenSheet(target.path, body.hash, written);
38707
+ if (outcome === "stale") refuseStale();
38682
38708
  const journal = history.journal();
38683
- if (outcome === "created") await journal.created(path);
38684
- else journal.token(path, body.name, tokenSides(css, body.name), tokenSides(written, body.name));
38709
+ if (outcome === "created") await journal.created(target.path);
38710
+ else journal.token(target.path, body.name, tokenSides(css, body.name), tokenSides(written, body.name));
38685
38711
  history.record({
38686
38712
  id: journal.id,
38687
38713
  changes: journal.changes,
@@ -38695,6 +38721,7 @@ function tokenRoutes(root, access, history, look) {
38695
38721
  light: row?.light ?? null,
38696
38722
  dark: row?.dark ?? null,
38697
38723
  hash: contentHash(written),
38724
+ sheet: body.sheet,
38698
38725
  created: outcome === "created"
38699
38726
  };
38700
38727
  return c.json({
@@ -38705,14 +38732,25 @@ function tokenRoutes(root, access, history, look) {
38705
38732
  app.onError(answerRefusal);
38706
38733
  return app;
38707
38734
  }
38708
- /** The project sheet's text as `hash` names it, empty for a null hash, refusing a sheet that moved since. */
38709
- function readProjectSheet(path, hash, project) {
38735
+ /** The board sheet as an edit target, refusing a reset, a board with no sheet, and a sheet outside the board folder. */
38736
+ function boardTarget(root, board, reset) {
38737
+ if (reset) throw new FrameboardError("invalid-edit", "A board token has no value under it to reset to.");
38738
+ if (!board) throw new FrameboardError("invalid-edit", "The board has no token sheet.");
38739
+ const inside = relative(root, board);
38740
+ if (inside.startsWith("..") || isAbsolute(inside)) throw new FrameboardError("invalid-edit", `${board} sits outside the board folder, so it belongs to whatever handed it over and stays read-only here.`, { path: board });
38741
+ return {
38742
+ path: board,
38743
+ under: {}
38744
+ };
38745
+ }
38746
+ /** The sheet's text as `hash` names it, empty for a null hash, refusing a sheet that moved since. */
38747
+ function readSheet(path, hash, refuseStale) {
38710
38748
  const now = hashOrNull(path);
38711
- if (now !== hash) stale(project);
38749
+ if (now !== hash) refuseStale();
38712
38750
  if (now === null) return "";
38713
38751
  const bytes = readFileSync(path);
38714
38752
  const text = bytes.toString("utf8");
38715
- if (!Buffer.from(text, "utf8").equals(bytes)) throw new FrameboardError("invalid-edit", "The project token sheet is not UTF-8, so it was left as it is.");
38753
+ if (!Buffer.from(text, "utf8").equals(bytes)) throw new FrameboardError("invalid-edit", "The token sheet is not UTF-8, so it was left as it is.");
38716
38754
  return text;
38717
38755
  }
38718
38756
  /** The token's declarations in the board sheet, none when it has no sheet or one that does not parse. */
@@ -38725,8 +38763,11 @@ function boardSides(board, name) {
38725
38763
  throw error;
38726
38764
  }
38727
38765
  }
38728
- function stale(project) {
38729
- throw new FrameboardError("stale-tokens", `${project}'s token sheet changed since the Theme tab read it, so nothing was written.`, { project });
38766
+ function stale(project, sheet) {
38767
+ throw new FrameboardError("stale-tokens", `${sheet === "board" ? "The board" : `${project}'s`} token sheet changed since the Theme tab read it, so nothing was written.`, {
38768
+ project,
38769
+ sheet
38770
+ });
38730
38771
  }
38731
38772
  // src/server/app.ts
38732
38773
  const LOOPBACK_NAMES = /* @__PURE__ */ new Set(["127.0.0.1", "localhost"]);