sunpeak 0.16.21 → 0.16.24

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 (68) hide show
  1. package/README.md +4 -3
  2. package/bin/commands/dev.mjs +22 -3
  3. package/bin/commands/new.mjs +6 -2
  4. package/bin/commands/start.mjs +4 -0
  5. package/bin/lib/get-port.mjs +60 -0
  6. package/bin/lib/live/browser-auth.mjs +125 -0
  7. package/bin/lib/live/chatgpt-config.d.mts +5 -0
  8. package/bin/lib/live/chatgpt-config.mjs +12 -0
  9. package/bin/lib/live/chatgpt-fixtures.d.mts +12 -0
  10. package/bin/lib/live/chatgpt-fixtures.mjs +25 -0
  11. package/bin/lib/live/chatgpt-page.mjs +210 -0
  12. package/bin/lib/live/global-setup.mjs +150 -0
  13. package/bin/lib/live/host-fixtures.mjs +61 -0
  14. package/bin/lib/live/host-page.mjs +242 -0
  15. package/bin/lib/live/live-config.d.mts +38 -0
  16. package/bin/lib/live/live-config.mjs +98 -0
  17. package/bin/lib/live/live-fixtures.d.mts +11 -0
  18. package/bin/lib/live/live-fixtures.mjs +102 -0
  19. package/bin/lib/live/test-config.d.mts +10 -0
  20. package/bin/lib/live/test-config.mjs +35 -0
  21. package/bin/lib/live/types.d.mts +54 -0
  22. package/bin/lib/live/utils.mjs +70 -0
  23. package/bin/sunpeak.js +1 -1
  24. package/dist/chatgpt/index.cjs +1 -1
  25. package/dist/chatgpt/index.js +1 -1
  26. package/dist/claude/index.cjs +1 -1
  27. package/dist/claude/index.js +1 -1
  28. package/dist/{index-CX6Z4bED.js → index-B7Qw3Vhh.js} +2 -2
  29. package/dist/index-B7Qw3Vhh.js.map +1 -0
  30. package/dist/{index-B4aC3vjH.js → index-BEHP_bM8.js} +2 -2
  31. package/dist/index-BEHP_bM8.js.map +1 -0
  32. package/dist/{index-bKBBCBK6.cjs → index-SfudQ9Y_.cjs} +2 -2
  33. package/dist/index-SfudQ9Y_.cjs.map +1 -0
  34. package/dist/{index-CKabCJyV.cjs → index-XKHXfBiD.cjs} +2 -2
  35. package/dist/index-XKHXfBiD.cjs.map +1 -0
  36. package/dist/index.cjs +13 -5
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.js +13 -5
  39. package/dist/index.js.map +1 -1
  40. package/dist/mcp/index.cjs +38 -13
  41. package/dist/mcp/index.cjs.map +1 -1
  42. package/dist/mcp/index.js +38 -13
  43. package/dist/mcp/index.js.map +1 -1
  44. package/dist/mcp/types.d.ts +2 -0
  45. package/dist/simulator/index.cjs +1 -1
  46. package/dist/simulator/index.js +1 -1
  47. package/dist/simulator/simple-sidebar.d.ts +3 -1
  48. package/dist/{simulator-D8t-r7HH.js → simulator-BCq2iOT-.js} +67 -27
  49. package/dist/simulator-BCq2iOT-.js.map +1 -0
  50. package/dist/{simulator-FFNttkqL.cjs → simulator-DRUsm6IZ.cjs} +67 -27
  51. package/dist/simulator-DRUsm6IZ.cjs.map +1 -0
  52. package/package.json +25 -1
  53. package/template/README.md +24 -2
  54. package/template/_gitignore +1 -0
  55. package/template/package.json +3 -2
  56. package/template/playwright.config.ts +24 -1
  57. package/template/tests/live/albums.spec.ts +53 -0
  58. package/template/tests/live/carousel.spec.ts +52 -0
  59. package/template/tests/live/map.spec.ts +31 -0
  60. package/template/tests/live/playwright.config.ts +3 -0
  61. package/template/tests/live/review.spec.ts +54 -0
  62. package/template/vitest.config.ts +1 -1
  63. package/dist/index-B4aC3vjH.js.map +0 -1
  64. package/dist/index-CKabCJyV.cjs.map +0 -1
  65. package/dist/index-CX6Z4bED.js.map +0 -1
  66. package/dist/index-bKBBCBK6.cjs.map +0 -1
  67. package/dist/simulator-D8t-r7HH.js.map +0 -1
  68. package/dist/simulator-FFNttkqL.cjs.map +0 -1
@@ -9523,8 +9523,8 @@ function dZ(Z) {
9523
9523
  if (!Z) return;
9524
9524
  return Z.extensions?.[OQ];
9525
9525
  }
9526
- const LOCAL_DEV_SERVER_URL = "http://localhost:8000";
9527
- const LOCAL_HMR_WS_URL = "ws://localhost:24678";
9526
+ let localDevServerUrl = "http://localhost:8000";
9527
+ let localHmrWsUrl = "ws://localhost:24678";
9528
9528
  function needsProdBuild(headers) {
9529
9529
  const ua = headers["user-agent"];
9530
9530
  const userAgent = typeof ua === "string" ? ua : Array.isArray(ua) ? ua[0] : "";
@@ -9543,7 +9543,7 @@ function getViteResourceHtml(srcPath) {
9543
9543
  const rawFileName = srcPath.split("/").pop() ?? "";
9544
9544
  const fileName = rawFileName.replace(/\.tsx$/, "");
9545
9545
  const componentName = fileName.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("") + "Resource";
9546
- const devServerUrl = LOCAL_DEV_SERVER_URL;
9546
+ const devServerUrl = localDevServerUrl;
9547
9547
  const entryParams = new URLSearchParams({ src: srcPath, component: componentName });
9548
9548
  const virtualModuleUrl = `${devServerUrl}/@id/virtual:sunpeak-entry?${entryParams.toString()}`;
9549
9549
  return `<!DOCTYPE html>
@@ -9593,11 +9593,11 @@ function injectViteCSP(existingMeta) {
9593
9593
  const ui = meta.ui ?? {};
9594
9594
  const csp = ui.csp ?? {};
9595
9595
  const existingResourceDomains = csp.resourceDomains ?? [];
9596
- const resourceDomains = existingResourceDomains.includes(LOCAL_DEV_SERVER_URL) ? existingResourceDomains : [...existingResourceDomains, LOCAL_DEV_SERVER_URL];
9596
+ const resourceDomains = existingResourceDomains.includes(localDevServerUrl) ? existingResourceDomains : [...existingResourceDomains, localDevServerUrl];
9597
9597
  const existingConnectDomains = csp.connectDomains ?? [];
9598
9598
  const connectDomains = [...existingConnectDomains];
9599
- if (!connectDomains.includes(LOCAL_DEV_SERVER_URL)) connectDomains.push(LOCAL_DEV_SERVER_URL);
9600
- if (!connectDomains.includes(LOCAL_HMR_WS_URL)) connectDomains.push(LOCAL_HMR_WS_URL);
9599
+ if (!connectDomains.includes(localDevServerUrl)) connectDomains.push(localDevServerUrl);
9600
+ if (!connectDomains.includes(localHmrWsUrl)) connectDomains.push(localHmrWsUrl);
9601
9601
  return {
9602
9602
  ...meta,
9603
9603
  ui: {
@@ -9902,6 +9902,10 @@ function runMCPServer(config) {
9902
9902
  const portEnv = Number(process.env.PORT ?? 8e3);
9903
9903
  const port = config.port ?? (Number.isFinite(portEnv) ? portEnv : 8e3);
9904
9904
  const { simulations } = config;
9905
+ localDevServerUrl = `http://localhost:${port}`;
9906
+ if (config.hmrPort) {
9907
+ localHmrWsUrl = `ws://localhost:${config.hmrPort}`;
9908
+ }
9905
9909
  const viteServer = config.viteServer;
9906
9910
  const viteMode = !!viteServer;
9907
9911
  const httpServer = node_http.createServer(async (req, res) => {
@@ -9963,13 +9967,24 @@ function runMCPServer(config) {
9963
9967
  console.error("HTTP client error", err);
9964
9968
  socket.end("HTTP/1.1 400 Bad Request\r\n\r\n");
9965
9969
  });
9966
- httpServer.listen(port, () => {
9967
- console.log(`Sunpeak MCP server listening on http://localhost:${port}`);
9968
- console.log(` MCP endpoint: http://localhost:${port}${MCP_PATH$1}`);
9970
+ const onListening = () => {
9971
+ const actualPort = httpServer.address().port;
9972
+ localDevServerUrl = `http://localhost:${actualPort}`;
9973
+ console.log(`Sunpeak MCP server listening on http://localhost:${actualPort}`);
9974
+ console.log(` MCP endpoint: http://localhost:${actualPort}${MCP_PATH$1}`);
9969
9975
  if (viteMode) {
9970
9976
  console.log(` Vite HMR: enabled (source files served with hot reload)`);
9971
9977
  }
9978
+ };
9979
+ httpServer.on("error", (err) => {
9980
+ if (err.code === "EADDRINUSE") {
9981
+ console.warn(`Port ${port} in use, finding an available port...`);
9982
+ httpServer.listen(0);
9983
+ } else {
9984
+ throw err;
9985
+ }
9972
9986
  });
9987
+ httpServer.listen(port, onListening);
9973
9988
  const shutdown = async () => {
9974
9989
  console.log("\nShutting down MCP server...");
9975
9990
  httpServer.close(() => {
@@ -10429,11 +10444,21 @@ function startProductionHttpServer(config, portOrOptions) {
10429
10444
  socket.end("HTTP/1.1 400 Bad Request\r\n\r\n");
10430
10445
  });
10431
10446
  const displayHost = host === "0.0.0.0" ? "localhost" : host;
10432
- httpServer.listen(port, host, () => {
10433
- log("info", `Server listening on http://${displayHost}:${port}`);
10434
- log("info", `MCP endpoint: http://${displayHost}:${port}${MCP_PATH}`);
10435
- log("info", `Health check: http://${displayHost}:${port}/health`);
10447
+ const onListening = () => {
10448
+ const addr = httpServer.address();
10449
+ log("info", `Server listening on http://${displayHost}:${addr.port}`);
10450
+ log("info", `MCP endpoint: http://${displayHost}:${addr.port}${MCP_PATH}`);
10451
+ log("info", `Health check: http://${displayHost}:${addr.port}/health`);
10452
+ };
10453
+ httpServer.on("error", (err) => {
10454
+ if (err.code === "EADDRINUSE") {
10455
+ log("warn", `Port ${port} in use, finding an available port...`);
10456
+ httpServer.listen(0, host);
10457
+ } else {
10458
+ throw err;
10459
+ }
10436
10460
  });
10461
+ httpServer.listen(port, host, onListening);
10437
10462
  const shutdown = async () => {
10438
10463
  log("info", "Shutting down MCP server...");
10439
10464
  httpServer.close(() => {