sunpeak 0.20.15 → 0.20.18

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 (84) hide show
  1. package/bin/commands/dev.mjs +28 -3
  2. package/bin/sunpeak.js +13 -8
  3. package/dist/chatgpt/index.cjs +1 -1
  4. package/dist/chatgpt/index.js +2 -2
  5. package/dist/claude/index.cjs +1 -1
  6. package/dist/claude/index.js +1 -1
  7. package/dist/host/chatgpt/index.cjs +1 -1
  8. package/dist/host/chatgpt/index.js +1 -1
  9. package/dist/index.cjs +5 -5
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.js +5 -5
  12. package/dist/index.js.map +1 -1
  13. package/dist/inspector/index.cjs +1 -1
  14. package/dist/inspector/index.js +2 -2
  15. package/dist/{inspector-mL_Ysqj6.cjs → inspector-Dnxjqhu3.cjs} +4 -4
  16. package/dist/{inspector-mL_Ysqj6.cjs.map → inspector-Dnxjqhu3.cjs.map} +1 -1
  17. package/dist/{inspector-BVYIkjfw.js → inspector-l1Eo18H7.js} +4 -4
  18. package/dist/{inspector-BVYIkjfw.js.map → inspector-l1Eo18H7.js.map} +1 -1
  19. package/dist/mcp/index.cjs +27 -21
  20. package/dist/mcp/index.cjs.map +1 -1
  21. package/dist/mcp/index.js +27 -21
  22. package/dist/mcp/index.js.map +1 -1
  23. package/dist/mcp/types.d.ts +21 -1
  24. package/dist/{protocol-CFifOG2U.cjs → protocol-BIXQsZGa.cjs} +51 -51
  25. package/dist/{protocol-CFifOG2U.cjs.map → protocol-BIXQsZGa.cjs.map} +1 -1
  26. package/dist/{protocol-C58brCtf.js → protocol-CMhIkbSk.js} +51 -51
  27. package/dist/{protocol-C58brCtf.js.map → protocol-CMhIkbSk.js.map} +1 -1
  28. package/dist/{use-app-BXVq24n8.cjs → use-app-BU-dLZiv.cjs} +5 -5
  29. package/dist/{use-app-BXVq24n8.cjs.map → use-app-BU-dLZiv.cjs.map} +1 -1
  30. package/dist/{use-app-L0OZBROc.js → use-app-CIOwvd3s.js} +5 -5
  31. package/dist/{use-app-L0OZBROc.js.map → use-app-CIOwvd3s.js.map} +1 -1
  32. package/dist/{v4-BtFbnniV.cjs → v4-BihNk0P-.cjs} +117 -89
  33. package/dist/v4-BihNk0P-.cjs.map +1 -0
  34. package/dist/{v4-DfWETn4d.js → v4-COy4jjxX.js} +117 -89
  35. package/dist/v4-COy4jjxX.js.map +1 -0
  36. package/package.json +6 -6
  37. package/template/dist/albums/albums.html +15 -15
  38. package/template/dist/albums/albums.json +1 -1
  39. package/template/dist/carousel/carousel.html +18 -18
  40. package/template/dist/carousel/carousel.json +1 -1
  41. package/template/dist/map/map.html +16 -16
  42. package/template/dist/map/map.json +1 -1
  43. package/template/dist/review/review.html +14 -14
  44. package/template/dist/review/review.json +1 -1
  45. package/template/dist/server.js +1 -0
  46. package/template/node_modules/.vite/deps/_metadata.json +3 -3
  47. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js +4 -4
  48. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js.map +1 -1
  49. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js +3 -3
  50. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js.map +1 -1
  51. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js +4 -4
  52. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js.map +1 -1
  53. package/template/node_modules/.vite-mcp/deps/@testing-library_react.js +4 -4
  54. package/template/node_modules/.vite-mcp/deps/@testing-library_react.js.map +1 -1
  55. package/template/node_modules/.vite-mcp/deps/_metadata.json +39 -39
  56. package/template/node_modules/.vite-mcp/deps/{client-BfIQfwlw.js → client-fN4-gZGh.js} +7 -7
  57. package/template/node_modules/.vite-mcp/deps/{client-BfIQfwlw.js.map → client-fN4-gZGh.js.map} +1 -1
  58. package/template/node_modules/.vite-mcp/deps/embla-carousel-react.js +1 -1
  59. package/template/node_modules/.vite-mcp/deps/embla-carousel-react.js.map +1 -1
  60. package/template/node_modules/.vite-mcp/deps/{external-BzlnL8_g.js → external-cQ9vWK3t.js} +116 -89
  61. package/template/node_modules/.vite-mcp/deps/external-cQ9vWK3t.js.map +1 -0
  62. package/template/node_modules/.vite-mcp/deps/mapbox-gl.js +3 -3
  63. package/template/node_modules/.vite-mcp/deps/mapbox-gl.js.map +1 -1
  64. package/template/node_modules/.vite-mcp/deps/{protocol-Depaaj0Z.js → protocol-iv-c8IeO.js} +6 -6
  65. package/template/node_modules/.vite-mcp/deps/{protocol-Depaaj0Z.js.map → protocol-iv-c8IeO.js.map} +1 -1
  66. package/template/node_modules/.vite-mcp/deps/react-dom.js +3 -3
  67. package/template/node_modules/.vite-mcp/deps/react-dom.js.map +1 -1
  68. package/template/node_modules/.vite-mcp/deps/react-dom_client.js +1 -1
  69. package/template/node_modules/.vite-mcp/deps/react.js +3 -3
  70. package/template/node_modules/.vite-mcp/deps/react.js.map +1 -1
  71. package/template/node_modules/.vite-mcp/deps/react_jsx-dev-runtime.js +2 -2
  72. package/template/node_modules/.vite-mcp/deps/react_jsx-dev-runtime.js.map +1 -1
  73. package/template/node_modules/.vite-mcp/deps/react_jsx-runtime.js +2 -2
  74. package/template/node_modules/.vite-mcp/deps/react_jsx-runtime.js.map +1 -1
  75. package/template/node_modules/.vite-mcp/deps/{v4-3k5wOzJw.js → v4-qpnbH1Zm.js} +4 -3
  76. package/template/node_modules/.vite-mcp/deps/v4-qpnbH1Zm.js.map +1 -0
  77. package/template/node_modules/.vite-mcp/deps/zod.js +3 -3
  78. package/template/node_modules/.vite-mcp/deps/zod.js.map +1 -1
  79. package/template/package.json +4 -4
  80. package/template/src/server.ts +5 -0
  81. package/dist/v4-BtFbnniV.cjs.map +0 -1
  82. package/dist/v4-DfWETn4d.js.map +0 -1
  83. package/template/node_modules/.vite-mcp/deps/external-BzlnL8_g.js.map +0 -1
  84. package/template/node_modules/.vite-mcp/deps/v4-3k5wOzJw.js.map +0 -1
@@ -4,7 +4,7 @@ import * as path from 'path';
4
4
  const { existsSync, readFileSync, watch: fsWatch } = fs;
5
5
  const { join, resolve, basename, dirname } = path;
6
6
  import { createRequire } from 'module';
7
- import { pathToFileURL } from 'url';
7
+ import { fileURLToPath, pathToFileURL } from 'url';
8
8
  import { spawn } from 'child_process';
9
9
  import { getPort } from '../lib/get-port.mjs';
10
10
  import { startSandboxServer } from '../lib/sandbox-server.mjs';
@@ -68,7 +68,7 @@ async function importFromProject(require, moduleName) {
68
68
  */
69
69
  function startBuildWatcher(projectRoot, resourcesDir, mcpHandle, { skipInitialBuild = false } = {}) {
70
70
  let activeChild = null;
71
- const sunpeakBin = join(dirname(new URL(import.meta.url).pathname), '..', 'sunpeak.js');
71
+ const sunpeakBin = join(dirname(fileURLToPath(import.meta.url)), '..', 'sunpeak.js');
72
72
 
73
73
  const runBuild = () => {
74
74
  // Kill any in-progress build and start fresh
@@ -205,7 +205,7 @@ export async function dev(projectRoot = process.cwd(), args = []) {
205
205
  // --prod-resources: Run initial production build so dist/ is ready before server starts
206
206
  if (isProdResources) {
207
207
  console.log('Building production resources...');
208
- const sunpeakBin = join(dirname(new URL(import.meta.url).pathname), '..', 'sunpeak.js');
208
+ const sunpeakBin = join(dirname(fileURLToPath(import.meta.url)), '..', 'sunpeak.js');
209
209
  const { execSync } = await import('child_process');
210
210
  try {
211
211
  execSync(`${process.execPath} ${sunpeakBin} build`, {
@@ -483,6 +483,31 @@ if (import.meta.hot) {
483
483
  appType: 'custom',
484
484
  });
485
485
 
486
+ // Pre-bundle resource and tool entries before exposing the server. Vite's
487
+ // depsOptimizer.entries scan kicks off on server creation but doesn't block
488
+ // request handling — the first inspector iframe load can race the optimizer
489
+ // and produce a 504 with a blank widget. Warming each entry and awaiting
490
+ // requests-idle forces pre-bundling to settle before any host can hit it.
491
+ // Skipped under --prod-resources where mcpViteServer is created but unused.
492
+ if (!isProdResources && (resourceDirs.length > 0 || toolFiles.length > 0)) {
493
+ const warmupTargets = [
494
+ ...resourceDirs.map(({ key, resourcePath }) =>
495
+ `/src/resources/${key}/${basename(resourcePath)}`
496
+ ),
497
+ ...toolFiles.map(({ name: toolName }) => `/src/tools/${toolName}.ts`),
498
+ ];
499
+ const warmStart = Date.now();
500
+ await Promise.all(
501
+ warmupTargets.map((url) =>
502
+ mcpViteServer.warmupRequest(url).catch((err) => {
503
+ console.warn(`[warmup] ${url}: ${err?.message ?? err}`);
504
+ })
505
+ )
506
+ );
507
+ await mcpViteServer.waitForRequestsIdle();
508
+ console.log(`Warmed Vite (${warmupTargets.length} ${warmupTargets.length === 1 ? 'entry' : 'entries'}) in ${Date.now() - warmStart}ms`);
509
+ }
510
+
486
511
  // Load server config from src/server.ts (if present) for server identity
487
512
  const serverEntryPath = join(projectRoot, 'src/server.ts');
488
513
  let serverInfo = undefined;
package/bin/sunpeak.js CHANGED
@@ -2,12 +2,17 @@
2
2
 
3
3
  import { existsSync, readFileSync } from 'fs';
4
4
  import { join, dirname } from 'path';
5
- import { fileURLToPath } from 'url';
5
+ import { fileURLToPath, pathToFileURL } from 'url';
6
6
  import { discoverResources } from './lib/patterns.mjs';
7
7
 
8
8
  const __dirname = dirname(fileURLToPath(import.meta.url));
9
9
  const COMMANDS_DIR = join(__dirname, 'commands');
10
10
 
11
+ // On Windows, absolute paths like "C:\..." can't be passed directly to dynamic
12
+ // import() — Node's ESM loader parses "C:" as a URL scheme and rejects it.
13
+ // Wrap with pathToFileURL().href to produce a valid file:// URL.
14
+ const commandUrl = (file) => pathToFileURL(join(COMMANDS_DIR, file)).href;
15
+
11
16
  function checkPackageJson() {
12
17
  const pkgPath = join(process.cwd(), 'package.json');
13
18
  if (!existsSync(pkgPath)) {
@@ -46,49 +51,49 @@ function getVersion() {
46
51
  switch (command) {
47
52
  case 'new':
48
53
  {
49
- const { init } = await import(join(COMMANDS_DIR, 'new.mjs'));
54
+ const { init } = await import(commandUrl('new.mjs'));
50
55
  await init(args[0], args[1]);
51
56
  }
52
57
  break;
53
58
 
54
59
  case 'dev':
55
60
  {
56
- const { dev } = await import(join(COMMANDS_DIR, 'dev.mjs'));
61
+ const { dev } = await import(commandUrl('dev.mjs'));
57
62
  await dev(process.cwd(), args);
58
63
  }
59
64
  break;
60
65
 
61
66
  case 'build':
62
67
  {
63
- const { build } = await import(join(COMMANDS_DIR, 'build.mjs'));
68
+ const { build } = await import(commandUrl('build.mjs'));
64
69
  await build(process.cwd());
65
70
  }
66
71
  break;
67
72
 
68
73
  case 'start':
69
74
  {
70
- const { start } = await import(join(COMMANDS_DIR, 'start.mjs'));
75
+ const { start } = await import(commandUrl('start.mjs'));
71
76
  await start(process.cwd(), args);
72
77
  }
73
78
  break;
74
79
 
75
80
  case 'inspect':
76
81
  {
77
- const { inspect } = await import(join(COMMANDS_DIR, 'inspect.mjs'));
82
+ const { inspect } = await import(commandUrl('inspect.mjs'));
78
83
  await inspect(args);
79
84
  }
80
85
  break;
81
86
 
82
87
  case 'test':
83
88
  {
84
- const { runTest } = await import(join(COMMANDS_DIR, 'test.mjs'));
89
+ const { runTest } = await import(commandUrl('test.mjs'));
85
90
  await runTest(args);
86
91
  }
87
92
  break;
88
93
 
89
94
  case 'upgrade':
90
95
  {
91
- const { upgrade } = await import(join(COMMANDS_DIR, 'upgrade.mjs'));
96
+ const { upgrade } = await import(commandUrl('upgrade.mjs'));
92
97
  const options = {
93
98
  check: args.includes('--check') || args.includes('-c'),
94
99
  help: args.includes('--help') || args.includes('-h'),
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../chunk-CoPdw6nB.cjs");
3
- const require_inspector = require("../inspector-mL_Ysqj6.cjs");
3
+ const require_inspector = require("../inspector-Dnxjqhu3.cjs");
4
4
  const require_inspector_url = require("../inspector-url-CCgv8H74.cjs");
5
5
  const require_discovery = require("../discovery-C9fQVb1u.cjs");
6
6
  //#region src/chatgpt/index.ts
@@ -1,5 +1,5 @@
1
- import { I as __exportAll } from "../v4-DfWETn4d.js";
2
- import { _ as McpAppHost, d as ThemeProvider, f as useThemeContext, g as extractResourceCSP, h as IframeResource, n as resolveServerToolResult, t as Inspector, v as SCREEN_WIDTHS } from "../inspector-BVYIkjfw.js";
1
+ import { I as __exportAll } from "../v4-COy4jjxX.js";
2
+ import { _ as McpAppHost, d as ThemeProvider, f as useThemeContext, g as extractResourceCSP, h as IframeResource, n as resolveServerToolResult, t as Inspector, v as SCREEN_WIDTHS } from "../inspector-l1Eo18H7.js";
3
3
  import { t as createInspectorUrl } from "../inspector-url-CyQcuBI9.js";
4
4
  import { c as toPascalCase, i as findResourceKey, n as extractSimulationKey, r as findResourceDirs, s as getComponentName, t as extractResourceKey } from "../discovery-Cgoegt62.js";
5
5
  //#region src/chatgpt/index.ts
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../chunk-CoPdw6nB.cjs");
3
- const require_inspector = require("../inspector-mL_Ysqj6.cjs");
3
+ const require_inspector = require("../inspector-Dnxjqhu3.cjs");
4
4
  exports.Inspector = require_inspector.Inspector;
@@ -1,2 +1,2 @@
1
- import { t as Inspector } from "../inspector-BVYIkjfw.js";
1
+ import { t as Inspector } from "../inspector-l1Eo18H7.js";
2
2
  export { Inspector };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../chunk-CoPdw6nB.cjs");
3
- const require_use_app = require("../../use-app-BXVq24n8.cjs");
3
+ const require_use_app = require("../../use-app-BU-dLZiv.cjs");
4
4
  let react = require("react");
5
5
  //#region src/host/chatgpt/openai-types.ts
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { t as useApp } from "../../use-app-L0OZBROc.js";
1
+ import { t as useApp } from "../../use-app-CIOwvd3s.js";
2
2
  import { useCallback } from "react";
3
3
  //#region src/host/chatgpt/openai-types.ts
4
4
  /**
package/dist/index.cjs CHANGED
@@ -1,16 +1,16 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-CoPdw6nB.cjs");
3
- const require_protocol = require("./protocol-CFifOG2U.cjs");
4
- const require_v4 = require("./v4-BtFbnniV.cjs");
5
- const require_use_app = require("./use-app-BXVq24n8.cjs");
6
- const require_inspector = require("./inspector-mL_Ysqj6.cjs");
3
+ const require_protocol = require("./protocol-BIXQsZGa.cjs");
4
+ const require_v4 = require("./v4-BihNk0P-.cjs");
5
+ const require_use_app = require("./use-app-BU-dLZiv.cjs");
6
+ const require_inspector = require("./inspector-Dnxjqhu3.cjs");
7
7
  const require_host_index = require("./host/index.cjs");
8
8
  const require_inspector_index = require("./inspector/index.cjs");
9
9
  const require_chatgpt_index = require("./chatgpt/index.cjs");
10
10
  let react = require("react");
11
11
  react = require_chunk.__toESM(react, 1);
12
12
  let react_jsx_runtime = require("react/jsx-runtime");
13
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+ext-apps@1.7.1_@modelcontextprotocol+sdk@1.29.0_zod@4.4.1__react-_92433c7acac2d73b76b395fab111ea67/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.js
13
+ //#region ../../node_modules/.pnpm/@modelcontextprotocol+ext-apps@1.7.1_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__react-_3f5c1a6a4033ae62a19a2bb834f0e050/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.js
14
14
  ((K) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(K, { get: (Q, X) => (typeof require < "u" ? require : Q)[X] }) : K)(function(K) {
15
15
  if (typeof require < "u") return require.apply(this, arguments);
16
16
  throw Error("Dynamic require of \"" + K + "\" is not supported");