sunpeak 0.5.28 → 0.5.30

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 (66) hide show
  1. package/bin/commands/build.mjs +64 -29
  2. package/bin/commands/dev.mjs +21 -37
  3. package/bin/commands/mcp.mjs +11 -9
  4. package/dist/chatgpt/globals.css +0 -3
  5. package/package.json +1 -1
  6. package/template/dist/chatgpt/albums.js +54 -14
  7. package/template/dist/chatgpt/carousel.js +54 -14
  8. package/template/dist/chatgpt/counter.js +54 -14
  9. package/template/index.html +2 -0
  10. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Button.js +858 -13
  11. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Button.js.map +4 -4
  12. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Icon.js +4 -4
  13. package/template/node_modules/.vite/deps/_metadata.json +24 -81
  14. package/template/node_modules/.vite/deps/{chunk-ILHRZGIS.js → chunk-5WRI5ZAA.js} +2 -17
  15. package/template/node_modules/.vite/deps/{chunk-PTVT3RFX.js → chunk-7IRBE5E4.js} +3 -3
  16. package/template/node_modules/.vite/deps/{chunk-XB525PXG.js → chunk-D3BYX6F4.js} +3 -3
  17. package/template/node_modules/.vite/deps/{chunk-KFGKZMLK.js → chunk-DUV225XW.js} +3 -3
  18. package/template/node_modules/.vite/deps/{chunk-4TLBUCVB.js → chunk-TNWQ7JGO.js} +2 -2
  19. package/template/node_modules/.vite/deps/clsx.js +1 -1
  20. package/template/node_modules/.vite/deps/embla-carousel-react.js +2 -2
  21. package/template/node_modules/.vite/deps/embla-carousel-wheel-gestures.js +1 -1
  22. package/template/node_modules/.vite/deps/react-dom.js +3 -3
  23. package/template/node_modules/.vite/deps/react-dom_client.js +3 -3
  24. package/template/node_modules/.vite/deps/react.js +2 -2
  25. package/template/node_modules/.vite/deps/react_jsx-dev-runtime.js +2 -2
  26. package/template/node_modules/.vite/deps/react_jsx-runtime.js +3 -3
  27. package/template/node_modules/.vite/deps/tailwind-merge.js +1 -1
  28. package/template/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
  29. package/template/src/styles/globals.css +0 -3
  30. package/template/tsconfig.json +2 -9
  31. package/template/vitest.config.ts +0 -1
  32. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Checkbox.js +0 -33
  33. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Checkbox.js.map +0 -7
  34. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Input.js +0 -13
  35. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_SegmentedControl.js +0 -103
  36. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_SegmentedControl.js.map +0 -7
  37. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Select.js +0 -1019
  38. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Select.js.map +0 -7
  39. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Textarea.js +0 -95
  40. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_components_Textarea.js.map +0 -7
  41. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_theme.js +0 -45
  42. package/template/node_modules/.vite/deps/@openai_apps-sdk-ui_theme.js.map +0 -7
  43. package/template/node_modules/.vite/deps/chunk-BAG6OO6S.js +0 -115
  44. package/template/node_modules/.vite/deps/chunk-BAG6OO6S.js.map +0 -7
  45. package/template/node_modules/.vite/deps/chunk-CQ3GYAYB.js +0 -112
  46. package/template/node_modules/.vite/deps/chunk-CQ3GYAYB.js.map +0 -7
  47. package/template/node_modules/.vite/deps/chunk-EGRHWZRV.js +0 -1
  48. package/template/node_modules/.vite/deps/chunk-EGRHWZRV.js.map +0 -7
  49. package/template/node_modules/.vite/deps/chunk-EVJ3DVH5.js +0 -628
  50. package/template/node_modules/.vite/deps/chunk-EVJ3DVH5.js.map +0 -7
  51. package/template/node_modules/.vite/deps/chunk-ILHRZGIS.js.map +0 -7
  52. package/template/node_modules/.vite/deps/chunk-QPJAV452.js +0 -13
  53. package/template/node_modules/.vite/deps/chunk-QPJAV452.js.map +0 -7
  54. package/template/node_modules/.vite/deps/chunk-SGWD4VEU.js +0 -15195
  55. package/template/node_modules/.vite/deps/chunk-SGWD4VEU.js.map +0 -7
  56. package/template/node_modules/.vite/deps/chunk-YOJ6QPGS.js +0 -231
  57. package/template/node_modules/.vite/deps/chunk-YOJ6QPGS.js.map +0 -7
  58. package/template/nodemon.json +0 -7
  59. package/template/tsconfig.node.json +0 -11
  60. package/template/vite.config.build.ts +0 -75
  61. package/template/vite.config.ts +0 -25
  62. /package/template/node_modules/.vite/deps/{@openai_apps-sdk-ui_components_Input.js.map → chunk-5WRI5ZAA.js.map} +0 -0
  63. /package/template/node_modules/.vite/deps/{chunk-PTVT3RFX.js.map → chunk-7IRBE5E4.js.map} +0 -0
  64. /package/template/node_modules/.vite/deps/{chunk-XB525PXG.js.map → chunk-D3BYX6F4.js.map} +0 -0
  65. /package/template/node_modules/.vite/deps/{chunk-KFGKZMLK.js.map → chunk-DUV225XW.js.map} +0 -0
  66. /package/template/node_modules/.vite/deps/{chunk-4TLBUCVB.js.map → chunk-TNWQ7JGO.js.map} +0 -0
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { execSync } from 'child_process';
3
- import { existsSync, rmSync, readdirSync, readFileSync, writeFileSync, mkdirSync, copyFileSync } from 'fs';
2
+ import { build as viteBuild } from 'vite';
3
+ import react from '@vitejs/plugin-react';
4
+ import tailwindcss from '@tailwindcss/vite';
5
+ import { existsSync, rmSync, readdirSync, readFileSync, writeFileSync, mkdirSync, copyFileSync, unlinkSync } from 'fs';
4
6
  import path from 'path';
5
- import { detectPackageManager } from '../utils.mjs';
6
7
 
7
8
  /**
8
9
  * Build all resources for a Sunpeak project
9
10
  * Runs in the context of a user's project directory
10
11
  */
11
12
  export async function build(projectRoot = process.cwd()) {
12
- const pm = detectPackageManager(projectRoot);
13
13
 
14
14
  // Check for package.json first
15
15
  const pkgJsonPath = path.join(projectRoot, 'package.json');
@@ -24,7 +24,6 @@ export async function build(projectRoot = process.cwd()) {
24
24
  const tempDir = path.join(projectRoot, '.tmp');
25
25
  const resourcesDir = path.join(projectRoot, 'src/components/resources');
26
26
  const templateFile = path.join(projectRoot, 'src/index-resource.tsx');
27
- const viteConfigFile = path.join(projectRoot, 'vite.config.build.ts');
28
27
 
29
28
  // Validate project structure
30
29
  if (!existsSync(resourcesDir)) {
@@ -44,13 +43,31 @@ export async function build(projectRoot = process.cwd()) {
44
43
  process.exit(1);
45
44
  }
46
45
 
47
- if (!existsSync(viteConfigFile)) {
48
- console.error('Error: vite.config.build.ts not found');
49
- console.error('Expected location: ' + viteConfigFile);
50
- console.error('\nThis Vite config is required for building resources.');
51
- console.error('If you have renamed it, you may need to use a custom build script.');
52
- process.exit(1);
53
- }
46
+ // Plugin factory to inline CSS into the JS bundle for all output files
47
+ const inlineCssPlugin = (buildOutDir) => ({
48
+ name: 'inline-css',
49
+ closeBundle() {
50
+ const cssFile = path.join(buildOutDir, 'style.css');
51
+
52
+ if (existsSync(cssFile)) {
53
+ const css = readFileSync(cssFile, 'utf-8');
54
+ const injectCss = `(function(){var s=document.createElement('style');s.textContent=${JSON.stringify(css)};document.head.appendChild(s);})();`;
55
+
56
+ // Find all .js files in the dist directory and inject CSS
57
+ const files = readdirSync(buildOutDir);
58
+ files.forEach((file) => {
59
+ if (file.endsWith('.js')) {
60
+ const jsFile = path.join(buildOutDir, file);
61
+ const js = readFileSync(jsFile, 'utf-8');
62
+ writeFileSync(jsFile, injectCss + js);
63
+ }
64
+ });
65
+
66
+ // Remove the separate CSS file after injecting into all bundles
67
+ unlinkSync(cssFile);
68
+ }
69
+ },
70
+ });
54
71
 
55
72
  // Clean dist and temp directories
56
73
  if (existsSync(distDir)) {
@@ -111,8 +128,9 @@ export async function build(projectRoot = process.cwd()) {
111
128
  }
112
129
 
113
130
  // Build all resources (but don't copy yet)
114
- resourceFiles.forEach(({ componentName, componentFile, entry, output, buildOutDir }, index) => {
115
- console.log(`[${index + 1}/${resourceFiles.length}] Building ${output}...`);
131
+ for (let i = 0; i < resourceFiles.length; i++) {
132
+ const { componentName, componentFile, entry, output, buildOutDir } = resourceFiles[i];
133
+ console.log(`[${i + 1}/${resourceFiles.length}] Building ${output}...`);
116
134
 
117
135
  try {
118
136
  // Create build directory if it doesn't exist
@@ -128,26 +146,43 @@ export async function build(projectRoot = process.cwd()) {
128
146
  const entryPath = path.join(projectRoot, entry);
129
147
  writeFileSync(entryPath, entryContent);
130
148
 
131
- // Build with vite to build directory
132
- const viteCommand = pm === 'npm' ? 'npx vite' : `${pm} exec vite`;
133
- execSync(
134
- `${viteCommand} build --config vite.config.build.ts`,
135
- {
136
- cwd: projectRoot,
137
- stdio: 'inherit',
138
- env: {
139
- ...process.env,
140
- ENTRY_FILE: entry,
141
- OUTPUT_FILE: output,
142
- OUT_DIR: buildOutDir,
149
+ // Build with vite programmatically
150
+ await viteBuild({
151
+ root: projectRoot,
152
+ plugins: [react(), tailwindcss(), inlineCssPlugin(buildOutDir)],
153
+ define: {
154
+ 'process.env.NODE_ENV': JSON.stringify('production'),
155
+ },
156
+ resolve: {
157
+ conditions: ['style', 'import', 'module', 'browser', 'default'],
158
+ },
159
+ build: {
160
+ target: 'es2020',
161
+ outDir: buildOutDir,
162
+ emptyOutDir: true,
163
+ cssCodeSplit: false,
164
+ lib: {
165
+ entry: entryPath,
166
+ name: 'SunpeakApp',
167
+ formats: ['iife'],
168
+ fileName: () => output,
143
169
  },
144
- }
145
- );
170
+ rollupOptions: {
171
+ output: {
172
+ inlineDynamicImports: true,
173
+ assetFileNames: 'style.css',
174
+ },
175
+ },
176
+ minify: true,
177
+ cssMinify: true,
178
+ },
179
+ });
146
180
  } catch (error) {
147
181
  console.error(`Failed to build ${output}`);
182
+ console.error(error);
148
183
  process.exit(1);
149
184
  }
150
- });
185
+ }
151
186
 
152
187
  // Now copy all files from build-output to dist/chatgpt
153
188
  console.log('\nCopying built files to dist/chatgpt...');
@@ -1,16 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { spawn } from 'child_process';
2
+ import { createServer } from 'vite';
3
+ import react from '@vitejs/plugin-react';
4
+ import tailwindcss from '@tailwindcss/vite';
3
5
  import { existsSync } from 'fs';
4
6
  import { join } from 'path';
5
- import { detectPackageManager } from '../utils.mjs';
6
7
 
7
8
  /**
8
9
  * Start the Vite development server
9
10
  * Runs in the context of a user's project directory
10
11
  */
11
12
  export async function dev(projectRoot = process.cwd(), args = []) {
12
- const pm = detectPackageManager(projectRoot);
13
-
14
13
  // Check for package.json
15
14
  const pkgJsonPath = join(projectRoot, 'package.json');
16
15
  if (!existsSync(pkgJsonPath)) {
@@ -20,52 +19,37 @@ export async function dev(projectRoot = process.cwd(), args = []) {
20
19
  }
21
20
 
22
21
  // Parse port from args or use default
23
- let port = process.env.PORT || '6767';
22
+ let port = parseInt(process.env.PORT || '6767');
24
23
  const portArgIndex = args.findIndex(arg => arg === '--port' || arg === '-p');
25
24
  if (portArgIndex !== -1 && args[portArgIndex + 1]) {
26
- port = args[portArgIndex + 1];
25
+ port = parseInt(args[portArgIndex + 1]);
27
26
  }
28
27
 
29
- // Build vite command
30
- const viteCommand = pm === 'npm' ? 'npx' : pm;
31
- const viteArgs = pm === 'npm' ? ['vite'] : ['exec', 'vite'];
32
-
33
- // Add port
34
- viteArgs.push('--port', port);
35
-
36
- // Add any additional args (filtering out port if already handled)
37
- const additionalArgs = portArgIndex !== -1
38
- ? [...args.slice(0, portArgIndex), ...args.slice(portArgIndex + 2)]
39
- : args;
40
- viteArgs.push(...additionalArgs);
41
-
42
28
  console.log(`Starting Vite dev server on port ${port}...`);
43
29
 
44
- // Spawn vite process
45
- const child = spawn(viteCommand, viteArgs, {
46
- cwd: projectRoot,
47
- stdio: 'inherit',
48
- env: {
49
- ...process.env,
50
- PORT: port,
51
- FORCE_COLOR: '1',
30
+ // Create and start Vite dev server programmatically
31
+ const server = await createServer({
32
+ root: projectRoot,
33
+ plugins: [react(), tailwindcss()],
34
+ server: {
35
+ port,
36
+ open: true,
52
37
  },
53
38
  });
54
39
 
55
- // Forward signals
56
- process.on('SIGINT', () => {
57
- child.kill('SIGINT');
58
- process.exit(0);
59
- });
40
+ await server.listen();
41
+ server.printUrls();
42
+ server.bindCLIShortcuts({ print: true });
60
43
 
61
- process.on('SIGTERM', () => {
62
- child.kill('SIGTERM');
44
+ // Handle signals
45
+ process.on('SIGINT', async () => {
46
+ await server.close();
63
47
  process.exit(0);
64
48
  });
65
49
 
66
- // Handle child exit
67
- child.on('exit', (code) => {
68
- process.exit(code || 0);
50
+ process.on('SIGTERM', async () => {
51
+ await server.close();
52
+ process.exit(0);
69
53
  });
70
54
  }
71
55
 
@@ -19,15 +19,6 @@ export async function mcp(projectRoot = process.cwd(), args = []) {
19
19
  process.exit(1);
20
20
  }
21
21
 
22
- // Check for nodemon config
23
- const nodemonConfigPath = join(projectRoot, 'nodemon.json');
24
- if (!existsSync(nodemonConfigPath)) {
25
- console.error('Error: nodemon.json not found');
26
- console.error('Expected location: ' + nodemonConfigPath);
27
- console.error('\nThe MCP server requires nodemon.json for auto-reload configuration.');
28
- process.exit(1);
29
- }
30
-
31
22
  console.log('Starting MCP server with auto-reload...');
32
23
  console.log('Watching src/ for changes...\n');
33
24
 
@@ -35,6 +26,17 @@ export async function mcp(projectRoot = process.cwd(), args = []) {
35
26
  const nodemonCommand = pm === 'npm' ? 'npx' : pm;
36
27
  const nodemonArgs = pm === 'npm' ? ['nodemon'] : ['exec', 'nodemon'];
37
28
 
29
+ // Add inline nodemon configuration
30
+ nodemonArgs.push(
31
+ '--watch', 'src',
32
+ '--ext', 'ts,tsx,js,jsx,css',
33
+ '--ignore', 'dist',
34
+ '--ignore', 'node_modules',
35
+ '--ignore', '.tmp',
36
+ '--delay', '500ms',
37
+ '--exec', 'sunpeak build && tsx node_modules/sunpeak/dist/mcp/entry.js'
38
+ );
39
+
38
40
  // Add any additional args
39
41
  nodemonArgs.push(...args);
40
42
 
@@ -1,6 +1,3 @@
1
- /* Establish explicit layer order to ensure SDK UI components beat Tailwind's preflight */
2
- @layer properties, theme, base, components, utilities;
3
-
4
1
  @import "tailwindcss";
5
2
  @import "@openai/apps-sdk-ui/css";
6
3
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sunpeak",
3
- "version": "0.5.28",
3
+ "version": "0.5.30",
4
4
  "description": "The MCP App SDK. Quickstart, build, & test your ChatGPT App locally!",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",