spur-board 0.121.0 → 0.121.1

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/daemon.mjs CHANGED
@@ -20883,9 +20883,23 @@ async function loadFiles(root) {
20883
20883
  }
20884
20884
  return files;
20885
20885
  }
20886
+ function escapeHtml(value) {
20887
+ return value.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
20888
+ }
20889
+ /** Names the daemon version in the page right after its first `<head>` tag; no `<head>`, no change. */
20890
+ function stampVersion(index, version) {
20891
+ const html = index.toString("utf8");
20892
+ const head = /<head(?:\s[^>]*)?>/i.exec(html);
20893
+ if (head === null) return index;
20894
+ const end = head.index + head[0].length;
20895
+ return Buffer.from(`${html.slice(0, end)}<meta name="board-version" content="${escapeHtml(version)}">${html.slice(end)}`);
20896
+ }
20886
20897
  /** Independent browser transport; the caller owns listening and shutdown. */
20887
20898
  async function createWebServer(options) {
20888
20899
  const files = await loadFiles(options.webRoot);
20900
+ const { productVersion } = options;
20901
+ const index = files.get("/index.html");
20902
+ if (productVersion !== void 0 && index !== void 0) files.set("/index.html", stampVersion(index, productVersion));
20889
20903
  const app = Fastify({
20890
20904
  logger: false,
20891
20905
  genReqId: () => randomUUID(),
@@ -20930,6 +20944,7 @@ async function createWebServer(options) {
20930
20944
  reply.header("x-frame-options", "DENY");
20931
20945
  reply.header("x-content-type-options", "nosniff");
20932
20946
  reply.header("referrer-policy", "no-referrer");
20947
+ if (productVersion !== void 0) reply.header("x-board-version", productVersion);
20933
20948
  }
20934
20949
  const audited = /* @__PURE__ */ new WeakSet();
20935
20950
  function audit(request, reply) {
@@ -26783,7 +26798,8 @@ function createWebModule(ctx, options) {
26783
26798
  step
26784
26799
  }, "event stream read failed");
26785
26800
  },
26786
- ...options.instance === void 0 ? {} : { instance: options.instance }
26801
+ ...options.instance === void 0 ? {} : { instance: options.instance },
26802
+ ...options.productVersion === void 0 ? {} : { productVersion: options.productVersion }
26787
26803
  });
26788
26804
  if (aborted()) return;
26789
26805
  const address = await server.listen({
@@ -27186,6 +27202,7 @@ function createDaemonModules(ctxFor, ports = {}) {
27186
27202
  firstPollDone: () => firstPollDone(board.store.db, board.config, core.completeSince),
27187
27203
  ...ports.afterOperation === void 0 ? {} : { afterOperation: ports.afterOperation },
27188
27204
  ...ports.webRoot === void 0 ? {} : { webRoot: ports.webRoot },
27205
+ ...ports.productVersion === void 0 ? {} : { productVersion: ports.productVersion },
27189
27206
  onListening: (address) => {
27190
27207
  webPort = listenerPort(address);
27191
27208
  ports.onWebListening?.(address);