@my-life-buddies/cli 0.27.1-dev.2 → 0.28.0-dev.2

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.
@@ -1373,52 +1373,9 @@ var PreviewController = class {
1373
1373
  import { randomBytes, timingSafeEqual } from "node:crypto";
1374
1374
  import { readFileSync as readFileSync2 } from "node:fs";
1375
1375
  import { createServer } from "node:http";
1376
- import { createRequire as createRequire2 } from "node:module";
1377
1376
  import QRCode from "qrcode";
1378
1377
  var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "::1", "localhost"]);
1379
1378
  var SESSION_COOKIE_PREFIX = "buddy_preview_session";
1380
- var require2 = createRequire2(import.meta.url);
1381
- var BRAND_ICON = Buffer.from(
1382
- readFileSync2(new URL("../web/assets/developer-platform-icon.png.base64", import.meta.url), "utf8").trim(),
1383
- "base64"
1384
- );
1385
- var WEB_ASSETS = Object.freeze(/* @__PURE__ */ new Map([
1386
- ["/", {
1387
- contentType: "text/html; charset=utf-8",
1388
- body: readFileSync2(new URL("../web/index.html", import.meta.url))
1389
- }],
1390
- ["/assets/app.css", {
1391
- contentType: "text/css; charset=utf-8",
1392
- body: readFileSync2(new URL("../web/app.css", import.meta.url))
1393
- }],
1394
- ["/assets/tokens.css", {
1395
- contentType: "text/css; charset=utf-8",
1396
- body: readFileSync2(new URL("../web/tokens.css", import.meta.url))
1397
- }],
1398
- ["/assets/brand.css", {
1399
- contentType: "text/css; charset=utf-8",
1400
- body: readFileSync2(new URL("../web/brand.css", import.meta.url))
1401
- }],
1402
- ["/assets/products.js", { contentType: "text/javascript; charset=utf-8", body: readFileSync2(new URL("../web/products.js", import.meta.url)) }],
1403
- ["/assets/products.css", { contentType: "text/css; charset=utf-8", body: readFileSync2(new URL("../web/products.css", import.meta.url)) }],
1404
- ["/assets/widgets.js", { contentType: "text/javascript; charset=utf-8", body: readFileSync2(new URL("../web/widgets.js", import.meta.url)) }],
1405
- ["/assets/widgets.css", { contentType: "text/css; charset=utf-8", body: readFileSync2(new URL("../web/widgets.css", import.meta.url)) }],
1406
- ["/assets/app.js", {
1407
- contentType: "text/javascript; charset=utf-8",
1408
- body: readFileSync2(new URL("../web/app.js", import.meta.url))
1409
- }],
1410
- ["/assets/diagnostics.js", { contentType: "text/javascript; charset=utf-8", body: readFileSync2(new URL("../web/diagnostics.js", import.meta.url)) }],
1411
- ["/assets/tool-inventory.js", { contentType: "text/javascript; charset=utf-8", body: readFileSync2(new URL("../web/tool-inventory.js", import.meta.url)) }],
1412
- ["/assets/chat-markdown.js", { contentType: "text/javascript; charset=utf-8", body: readFileSync2(new URL("../web/chat-markdown.js", import.meta.url)) }],
1413
- ["/assets/developer-platform-icon.png", {
1414
- contentType: "image/png",
1415
- body: BRAND_ICON
1416
- }],
1417
- ["/assets/iphone-16-max.js", {
1418
- contentType: "text/javascript; charset=utf-8",
1419
- body: readFileSync2(require2.resolve("@sneas/telephone/iphone-16-max.js"))
1420
- }]
1421
- ]));
1422
1379
  function closeServer(server) {
1423
1380
  if (!server.listening) return Promise.resolve();
1424
1381
  return new Promise((resolve2, reject) => {
@@ -1432,17 +1389,9 @@ function writeHeaders(response) {
1432
1389
  response.setHeader("Cross-Origin-Opener-Policy", "same-origin");
1433
1390
  response.setHeader(
1434
1391
  "Content-Security-Policy",
1435
- // Telephone injects its frame CSS into a shadow root and updates one inline sizing variable.
1436
1392
  "default-src 'self'; connect-src 'self'; img-src 'self' data:; script-src 'self'; style-src 'self' 'unsafe-inline'; object-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'"
1437
1393
  );
1438
1394
  }
1439
- function staticAsset(response, asset) {
1440
- response.statusCode = 200;
1441
- writeHeaders(response);
1442
- response.setHeader("Content-Type", asset.contentType);
1443
- response.setHeader("Content-Length", asset.body.length);
1444
- response.end(asset.body);
1445
- }
1446
1395
  function json(response, status, body) {
1447
1396
  const encoded = JSON.stringify(body);
1448
1397
  response.statusCode = status;
@@ -1494,7 +1443,7 @@ function widgetDocument(response, html, render, state = "ready", status = 200) {
1494
1443
  response.setHeader("Content-Security-Policy", "sandbox allow-scripts; default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:; connect-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'self'");
1495
1444
  response.setHeader("Content-Type", "text/html; charset=utf-8");
1496
1445
  if (validWidgetRender(render)) {
1497
- const script = state === "ready" ? readFileSync2(new URL("../web/widget-document.js", import.meta.url), "utf8").replace("__WIDGET_RENDER__", JSON.stringify(render)) : `window.addEventListener('load',()=>parent.postMessage({channel:'buddy-widget-document',render:${JSON.stringify(render)},state:'error'},'*'),{once:true})`;
1446
+ const script = state === "ready" ? readFileSync2(new URL("./resources/widget-document.js", import.meta.url), "utf8").replace("__WIDGET_RENDER__", JSON.stringify(render)) : `window.addEventListener('load',()=>parent.postMessage({channel:'buddy-widget-document',render:${JSON.stringify(render)},state:'error'},'*'),{once:true})`;
1498
1447
  const signal = `<script>${script}</script>`;
1499
1448
  if (/<!doctype[^>]*>/iu.test(html)) html = html.replace(/<!doctype[^>]*>/iu, (match) => match + signal);
1500
1449
  else html = signal + html;
@@ -1601,11 +1550,7 @@ data: ${JSON.stringify(value)}
1601
1550
  }
1602
1551
  const suppliedToken = cookieValue(request, sessionCookie);
1603
1552
  if (!suppliedToken || !safeEqual(suppliedToken, sessionToken)) {
1604
- return apiError(response, 401, "PREVIEW_UNAUTHORIZED", "\u9700\u8981\u4ECE CLI \u63D0\u4F9B\u7684\u4E00\u6B21\u6027\u5165\u53E3\u6253\u5F00 Preview");
1605
- }
1606
- if (request.method === "GET") {
1607
- const asset = WEB_ASSETS.get(url.pathname);
1608
- if (asset) return staticAsset(response, asset);
1553
+ return apiError(response, 401, "PREVIEW_UNAUTHORIZED", "\u672C\u5730\u8C03\u8BD5\u63A5\u53E3\u9700\u8981 CLI \u5185\u90E8\u4F1A\u8BDD");
1609
1554
  }
1610
1555
  if (request.method === "GET" && url.pathname === "/api/project") {
1611
1556
  try {