frameboard 0.17.0 → 0.19.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
@@ -9415,7 +9415,7 @@ async function isDirectory(path) {
9415
9415
  }
9416
9416
  }
9417
9417
  // package.json
9418
- var version$1 = "0.17.0";
9418
+ var version$1 = "0.19.0";
9419
9419
  var dependencies = { "playwright-core": "1.64.1" };
9420
9420
  // src/shared/version.ts
9421
9421
  const version = version$1;
@@ -13628,8 +13628,13 @@ const COOKIE_MAX_AGE_S = 3456e4;
13628
13628
  * trades for the board's cookie, and answers a 303 home either way so a used
13629
13629
  * ticket still lands on a board that reads. A failed redeem lands on
13630
13630
  * `/?link=expired`, the flag the client's expired-link toast reads.
13631
+ *
13632
+ * With `openRoute`, `GET /api/access/open` mints a ticket per request and
13633
+ * redirects through redeem, so a browser with no shell, such as a recorder's,
13634
+ * lands on a writing board. It is off unless `serve` is asked for it, since it
13635
+ * makes any local browser navigating to it a writer.
13631
13636
  */
13632
- function accessRoutes(access, tickets) {
13637
+ function accessRoutes(access, tickets, { openRoute = false } = {}) {
13633
13638
  const app = new Hono();
13634
13639
  app.get("/api/access/redeem", (c) => {
13635
13640
  const ticket = c.req.query("ticket");
@@ -13644,6 +13649,7 @@ function accessRoutes(access, tickets) {
13644
13649
  }
13645
13650
  return c.redirect("/?link=expired", 303);
13646
13651
  });
13652
+ if (openRoute) app.get("/api/access/open", (c) => c.redirect(`/api/access/redeem?ticket=${tickets.mint().ticket}`, 303));
13647
13653
  app.post("/api/access/ticket", (c) => {
13648
13654
  if (!isWriter({ authorization: c.req.header("authorization") }, access)) return c.json({
13649
13655
  ok: false,
@@ -34929,7 +34935,7 @@ function buildCascade(source, tokens, { properties = READ } = {}) {
34929
34935
  }
34930
34936
  return null;
34931
34937
  };
34932
- const resolveVars = (value, element, depth = 0) => {
34938
+ const resolveVars = (value, element, keep = /* @__PURE__ */ new Set(), depth = 0) => {
34933
34939
  if (depth > 16) return null;
34934
34940
  let resolved = "";
34935
34941
  let rest = value;
@@ -34938,8 +34944,12 @@ function buildCascade(source, tokens, { properties = READ } = {}) {
34938
34944
  if (end === -1) return null;
34939
34945
  const [name = "", ...fallbackParts] = splitTopLevel(rest.slice(start + 4, end), ",");
34940
34946
  const fallback = fallbackParts.length > 0 ? fallbackParts.join(",") : null;
34941
- const custom = inherited(element, name.trim());
34942
- const replacement = custom === null ? fallback === null ? null : resolveVars(fallback, element, depth + 1) : resolveVars(custom.value, custom.element, depth + 1);
34947
+ let replacement;
34948
+ if (keep.has(name.trim())) replacement = rest.slice(start, end + 1);
34949
+ else {
34950
+ const custom = inherited(element, name.trim());
34951
+ replacement = custom === null ? fallback === null ? null : resolveVars(fallback, element, keep, depth + 1) : resolveVars(custom.value.trim(), custom.element, keep, depth + 1);
34952
+ }
34943
34953
  if (replacement === null) return null;
34944
34954
  resolved += rest.slice(0, start) + replacement;
34945
34955
  rest = rest.slice(end + 1);
@@ -34976,7 +34986,8 @@ function buildCascade(source, tokens, { properties = READ } = {}) {
34976
34986
  userAgent: false,
34977
34987
  shorthand: declaration.property !== property
34978
34988
  };
34979
- }
34989
+ },
34990
+ resolve: (value, element, keep) => resolveVars(value, element, keep)
34980
34991
  };
34981
34992
  }
34982
34993
  /** A rule styles elements unless it sits in a non-styling at-rule or inside another rule. */
@@ -35282,19 +35293,33 @@ const MIX = /^color-mix\(\s*in\s+srgb\s*,\s*var\(\s*(--[\w-]+)\s*(?:,[^)]*)?\)\s
35282
35293
  const HEX_ALPHA = /^#([0-9a-f]{6})([0-9a-f]{2})$/i;
35283
35294
  /**
35284
35295
  * A frame's colors as its source states them, read through the static
35285
- * cascade the checks use, so `var(--token)` is named exactly and a raw
35296
+ * cascade the checks use, so a `var()` over a name a token sheet declares
35297
+ * is named exactly, one over a name only the frame declares answers the
35298
+ * value it resolves to, and a raw
35286
35299
  * value is answered raw rather than matched to a token that happens to
35287
35300
  * share its value. `index` is the edit address's, naming the selected
35288
35301
  * element, whose subtree the colors then cover in place of the frame's.
35289
35302
  */
35290
35303
  function frameStyles(source, tokens, index) {
35291
35304
  const cascade = buildCascade(source, tokens, { properties: PROPERTIES });
35305
+ const tokenNames = declaredNames(tokens);
35292
35306
  const target = index === void 0 ? void 0 : source.elements[index];
35307
+ const named = (written, element) => {
35308
+ const value = styleValue(written);
35309
+ if (!value.token || tokenNames.has(value.token)) return value;
35310
+ const resolved = cascade.resolve(`var(${value.token})`, element, tokenNames);
35311
+ if (resolved === null) return value;
35312
+ const raw = styleValue(resolved);
35313
+ return {
35314
+ ...raw,
35315
+ percent: Math.round(raw.percent * value.percent / 100)
35316
+ };
35317
+ };
35293
35318
  const read = (element, property) => {
35294
35319
  const found = cascade.specified(element, property);
35295
35320
  if (!found) return null;
35296
35321
  const part = found.shorthand ? shorthandPart(found.value, property) : found.value;
35297
- return part === null ? null : styleValue(part);
35322
+ return part === null ? null : named(part, found.element);
35298
35323
  };
35299
35324
  const family = (element) => {
35300
35325
  const found = cascade.specified(element, "font-family");
@@ -35350,6 +35375,18 @@ function styleValue(written) {
35350
35375
  percent: 100
35351
35376
  };
35352
35377
  }
35378
+ /** The custom properties the token sheets declare, which alone are tokens. */
35379
+ function declaredNames(sheets) {
35380
+ const names = /* @__PURE__ */ new Set();
35381
+ for (const sheet of sheets) try {
35382
+ postcss_default.parse(sheet.css).walkDecls(/^--/, (node) => {
35383
+ names.add(node.prop);
35384
+ });
35385
+ } catch {
35386
+ continue;
35387
+ }
35388
+ return names;
35389
+ }
35353
35390
  /**
35354
35391
  * The part of a `border` or `background` shorthand that sets `property`:
35355
35392
  * the last part that reads as a color for a color, since a color comes last
@@ -37514,7 +37551,7 @@ function boardHostGuard(port) {
37514
37551
  await next();
37515
37552
  };
37516
37553
  }
37517
- function createApp({ clientDir, root, port, actions, tickets, renderFrame, facesDir, tokens, delivery, dispatch, history, selection, checks, thumbnails, measure, frameVersion, settledVersion }) {
37554
+ function createApp({ clientDir, root, port, actions, tickets, openRoute, renderFrame, facesDir, tokens, delivery, dispatch, history, selection, checks, thumbnails, measure, frameVersion, settledVersion }) {
37518
37555
  const app = new Hono();
37519
37556
  const given = tokens ?? null;
37520
37557
  app.use("*", async (c, next) => {
@@ -37532,7 +37569,7 @@ function createApp({ clientDir, root, port, actions, tickets, renderFrame, faces
37532
37569
  root,
37533
37570
  tokens: given
37534
37571
  }));
37535
- app.route("/", accessRoutes(actions.access, tickets));
37572
+ app.route("/", accessRoutes(actions.access, tickets, { openRoute }));
37536
37573
  app.route("/", apiRoutes(root, actions, frames.look, history));
37537
37574
  app.route("/", structureRoutes(root, actions.access, history, measure, given));
37538
37575
  app.route("/", historyRoutes(actions.access, history));
@@ -49100,7 +49137,7 @@ async function startServer({ strictPort = true, port, ...options }) {
49100
49137
  });
49101
49138
  }
49102
49139
  }
49103
- async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch, dispatch }) {
49140
+ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch, dispatch, openRoute }) {
49104
49141
  const tabs = new BoardTabs();
49105
49142
  const tickets = createTickets();
49106
49143
  let bound = 0;
@@ -49273,6 +49310,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
49273
49310
  root,
49274
49311
  port: boundPort,
49275
49312
  tickets,
49313
+ openRoute,
49276
49314
  delivery,
49277
49315
  dispatch: dispatcher,
49278
49316
  history,
@@ -49491,7 +49529,7 @@ const DEFAULT_PORT = 4173;
49491
49529
  const RECONNECT_WAIT_MS = 1e3;
49492
49530
  function registerServe(program, context) {
49493
49531
  const { io } = context;
49494
- act(addVerb(program, "serve", `Serve the board in a local browser. A note sent to a new session runs the shell command in ${DISPATCH_ENV}, read once at start, with the note in FRAMEBOARD_NOTE, FRAMEBOARD_NOTE_ID, FRAMEBOARD_SESSION, and FRAMEBOARD_ROOT`).option("-p, --port <port>", "port to listen on, falling back to a free one when the default is taken", parsePort, DEFAULT_PORT).option("--no-open", "leave the browser alone").option("--tokens <path>", "a token sheet another tool manages, standing in for the board's tokens.css"), context, async (_args, options, self) => {
49532
+ act(addVerb(program, "serve", `Serve the board in a local browser. A note sent to a new session runs the shell command in ${DISPATCH_ENV}, read once at start, with the note in FRAMEBOARD_NOTE, FRAMEBOARD_NOTE_ID, FRAMEBOARD_SESSION, and FRAMEBOARD_ROOT`).option("-p, --port <port>", "port to listen on, falling back to a free one when the default is taken", parsePort, DEFAULT_PORT).option("--no-open", "leave the browser alone").option("--tokens <path>", "a token sheet another tool manages, standing in for the board's tokens.css").addOption(new Option("--open-route", "answer /api/access/open with a fresh edit link per request").default(false).hideHelp()), context, async (_args, options, self) => {
49495
49533
  const tokens = options.tokens === void 0 ? void 0 : resolve(io.cwd, options.tokens);
49496
49534
  if (tokens !== void 0 && !isFile(tokens)) throw new FrameboardError("tokens-not-found", `No token sheet at ${tokens}.`, { tokens });
49497
49535
  const existing = await resolveBoard({
@@ -49528,7 +49566,8 @@ function registerServe(program, context) {
49528
49566
  port: options.port,
49529
49567
  strictPort: self.getOptionValueSource("port") !== "default",
49530
49568
  openUrl: io.openUrl,
49531
- dispatch: dispatchCommand(io.cwd)
49569
+ dispatch: dispatchCommand(io.cwd),
49570
+ openRoute: options.openRoute
49532
49571
  });
49533
49572
  const address = newAddress({
49534
49573
  root,