@tpitre/story-ui 3.0.0 → 3.1.0

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 (256) hide show
  1. package/dist/cli/index.js +0 -0
  2. package/dist/templates/StoryUI/StoryUIPanel.d.ts +5 -0
  3. package/dist/templates/StoryUI/StoryUIPanel.d.ts.map +1 -1
  4. package/dist/templates/StoryUI/StoryUIPanel.js +18 -3
  5. package/package.json +1 -1
  6. package/templates/StoryUI/StoryUIPanel.tsx +28 -3
  7. package/templates/StoryUI/manager.tsx +444 -213
  8. package/dist/cli/index.js.map +0 -1
  9. package/dist/cli/setup.js.map +0 -1
  10. package/dist/cloudflare-edge/src/mcp-session.js +0 -462
  11. package/dist/cloudflare-edge/src/types.js +0 -4
  12. package/dist/cloudflare-edge/src/worker.js +0 -106
  13. package/dist/cloudflare-pages/vite.config.js +0 -14
  14. package/dist/index.d.ts +0 -13
  15. package/dist/index.d.ts.map +0 -1
  16. package/dist/index.js +0 -12
  17. package/dist/index.js.map +0 -1
  18. package/dist/mcp-server/index.js.map +0 -1
  19. package/dist/mcp-server/mcp-stdio-server.js.map +0 -1
  20. package/dist/mcp-server/routes/claude.js.map +0 -1
  21. package/dist/mcp-server/routes/components.js.map +0 -1
  22. package/dist/mcp-server/routes/generateStory.js.map +0 -1
  23. package/dist/mcp-server/routes/hybridStories.js.map +0 -1
  24. package/dist/mcp-server/routes/memoryStories.js.map +0 -1
  25. package/dist/mcp-server/routes/storySync.js.map +0 -1
  26. package/dist/mcp-server/routes/updateStory.js +0 -246
  27. package/dist/mcp-server/sessionManager.js.map +0 -1
  28. package/dist/playground/components/AIAssistant/AIAssistant.d.ts +0 -6
  29. package/dist/playground/components/AIAssistant/AIAssistant.d.ts.map +0 -1
  30. package/dist/playground/components/AIAssistant/AIAssistant.js +0 -109
  31. package/dist/playground/components/AIAssistant/AIAssistant.js.map +0 -1
  32. package/dist/playground/components/AIAssistant/AIAssistant.module.css +0 -166
  33. package/dist/playground/components/Canvas/Canvas.d.ts +0 -9
  34. package/dist/playground/components/Canvas/Canvas.d.ts.map +0 -1
  35. package/dist/playground/components/Canvas/Canvas.js +0 -58
  36. package/dist/playground/components/Canvas/Canvas.js.map +0 -1
  37. package/dist/playground/components/Canvas/Canvas.module.css +0 -189
  38. package/dist/playground/components/Canvas/CanvasWithDnd.d.ts +0 -9
  39. package/dist/playground/components/Canvas/CanvasWithDnd.d.ts.map +0 -1
  40. package/dist/playground/components/Canvas/CanvasWithDnd.js +0 -158
  41. package/dist/playground/components/Canvas/CanvasWithDnd.js.map +0 -1
  42. package/dist/playground/components/Canvas/ComponentRenderer.d.ts +0 -15
  43. package/dist/playground/components/Canvas/ComponentRenderer.d.ts.map +0 -1
  44. package/dist/playground/components/Canvas/ComponentRenderer.js +0 -177
  45. package/dist/playground/components/Canvas/ComponentRenderer.js.map +0 -1
  46. package/dist/playground/components/Canvas/DraggableComponent.d.ts +0 -15
  47. package/dist/playground/components/Canvas/DraggableComponent.d.ts.map +0 -1
  48. package/dist/playground/components/Canvas/DraggableComponent.js +0 -49
  49. package/dist/playground/components/Canvas/DraggableComponent.js.map +0 -1
  50. package/dist/playground/components/Canvas/index.d.ts +0 -9
  51. package/dist/playground/components/Canvas/index.d.ts.map +0 -1
  52. package/dist/playground/components/Canvas/index.js +0 -5
  53. package/dist/playground/components/Canvas/index.js.map +0 -1
  54. package/dist/playground/components/CodeView/CodeView.d.ts +0 -12
  55. package/dist/playground/components/CodeView/CodeView.d.ts.map +0 -1
  56. package/dist/playground/components/CodeView/CodeView.js +0 -77
  57. package/dist/playground/components/CodeView/CodeView.js.map +0 -1
  58. package/dist/playground/components/CodeView/CodeView.module.css +0 -178
  59. package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts +0 -17
  60. package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts.map +0 -1
  61. package/dist/playground/components/ComponentPalette/ComponentPalette.js +0 -138
  62. package/dist/playground/components/ComponentPalette/ComponentPalette.js.map +0 -1
  63. package/dist/playground/components/ComponentPalette/ComponentPalette.module.css +0 -217
  64. package/dist/playground/components/ComponentPalette/index.d.ts +0 -3
  65. package/dist/playground/components/ComponentPalette/index.d.ts.map +0 -1
  66. package/dist/playground/components/ComponentPalette/index.js +0 -2
  67. package/dist/playground/components/ComponentPalette/index.js.map +0 -1
  68. package/dist/playground/components/DropZone/DropZone.d.ts +0 -17
  69. package/dist/playground/components/DropZone/DropZone.d.ts.map +0 -1
  70. package/dist/playground/components/DropZone/DropZone.js +0 -73
  71. package/dist/playground/components/DropZone/DropZone.js.map +0 -1
  72. package/dist/playground/components/DropZone/DropZone.module.css +0 -86
  73. package/dist/playground/components/ExportDialog/ExportDialog.d.ts +0 -10
  74. package/dist/playground/components/ExportDialog/ExportDialog.d.ts.map +0 -1
  75. package/dist/playground/components/ExportDialog/ExportDialog.js +0 -57
  76. package/dist/playground/components/ExportDialog/ExportDialog.js.map +0 -1
  77. package/dist/playground/components/ExportDialog/ExportDialog.module.css +0 -328
  78. package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts +0 -134
  79. package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts.map +0 -1
  80. package/dist/playground/components/LayoutHelpers/LayoutHelpers.js +0 -254
  81. package/dist/playground/components/LayoutHelpers/LayoutHelpers.js.map +0 -1
  82. package/dist/playground/components/LayoutHelpers/index.d.ts +0 -3
  83. package/dist/playground/components/LayoutHelpers/index.d.ts.map +0 -1
  84. package/dist/playground/components/LayoutHelpers/index.js +0 -2
  85. package/dist/playground/components/LayoutHelpers/index.js.map +0 -1
  86. package/dist/playground/components/Playground/Playground.d.ts +0 -10
  87. package/dist/playground/components/Playground/Playground.d.ts.map +0 -1
  88. package/dist/playground/components/Playground/Playground.js +0 -128
  89. package/dist/playground/components/Playground/Playground.js.map +0 -1
  90. package/dist/playground/components/Playground/Playground.module.css +0 -308
  91. package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts +0 -10
  92. package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts.map +0 -1
  93. package/dist/playground/components/PropertiesPanel/PropertiesPanel.js +0 -150
  94. package/dist/playground/components/PropertiesPanel/PropertiesPanel.js.map +0 -1
  95. package/dist/playground/components/PropertiesPanel/PropertiesPanel.module.css +0 -155
  96. package/dist/playground/components/PropertiesPanel/index.d.ts +0 -3
  97. package/dist/playground/components/PropertiesPanel/index.d.ts.map +0 -1
  98. package/dist/playground/components/PropertiesPanel/index.js +0 -2
  99. package/dist/playground/components/PropertiesPanel/index.js.map +0 -1
  100. package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts +0 -12
  101. package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts.map +0 -1
  102. package/dist/playground/components/PropertyEditors/BooleanEditor.js +0 -14
  103. package/dist/playground/components/PropertyEditors/BooleanEditor.js.map +0 -1
  104. package/dist/playground/components/PropertyEditors/ColorEditor.d.ts +0 -12
  105. package/dist/playground/components/PropertyEditors/ColorEditor.d.ts.map +0 -1
  106. package/dist/playground/components/PropertyEditors/ColorEditor.js +0 -62
  107. package/dist/playground/components/PropertyEditors/ColorEditor.js.map +0 -1
  108. package/dist/playground/components/PropertyEditors/IconEditor.d.ts +0 -12
  109. package/dist/playground/components/PropertyEditors/IconEditor.d.ts.map +0 -1
  110. package/dist/playground/components/PropertyEditors/IconEditor.js +0 -123
  111. package/dist/playground/components/PropertyEditors/IconEditor.js.map +0 -1
  112. package/dist/playground/components/PropertyEditors/NumberEditor.d.ts +0 -15
  113. package/dist/playground/components/PropertyEditors/NumberEditor.d.ts.map +0 -1
  114. package/dist/playground/components/PropertyEditors/NumberEditor.js +0 -46
  115. package/dist/playground/components/PropertyEditors/NumberEditor.js.map +0 -1
  116. package/dist/playground/components/PropertyEditors/PropertyEditors.module.css +0 -432
  117. package/dist/playground/components/PropertyEditors/SelectEditor.d.ts +0 -19
  118. package/dist/playground/components/PropertyEditors/SelectEditor.d.ts.map +0 -1
  119. package/dist/playground/components/PropertyEditors/SelectEditor.js +0 -17
  120. package/dist/playground/components/PropertyEditors/SelectEditor.js.map +0 -1
  121. package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts +0 -19
  122. package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts.map +0 -1
  123. package/dist/playground/components/PropertyEditors/SpacingEditor.js +0 -162
  124. package/dist/playground/components/PropertyEditors/SpacingEditor.js.map +0 -1
  125. package/dist/playground/components/PropertyEditors/SpacingEditor.module.css +0 -214
  126. package/dist/playground/components/PropertyEditors/TextEditor.d.ts +0 -14
  127. package/dist/playground/components/PropertyEditors/TextEditor.d.ts.map +0 -1
  128. package/dist/playground/components/PropertyEditors/TextEditor.js +0 -38
  129. package/dist/playground/components/PropertyEditors/TextEditor.js.map +0 -1
  130. package/dist/playground/components/PropertyEditors/TokenEditor.d.ts +0 -23
  131. package/dist/playground/components/PropertyEditors/TokenEditor.d.ts.map +0 -1
  132. package/dist/playground/components/PropertyEditors/TokenEditor.js +0 -50
  133. package/dist/playground/components/PropertyEditors/TokenEditor.js.map +0 -1
  134. package/dist/playground/components/PropertyEditors/index.d.ts +0 -20
  135. package/dist/playground/components/PropertyEditors/index.d.ts.map +0 -1
  136. package/dist/playground/components/PropertyEditors/index.js +0 -12
  137. package/dist/playground/components/PropertyEditors/index.js.map +0 -1
  138. package/dist/playground/components/TreeView/TreeView.d.ts +0 -10
  139. package/dist/playground/components/TreeView/TreeView.d.ts.map +0 -1
  140. package/dist/playground/components/TreeView/TreeView.js +0 -146
  141. package/dist/playground/components/TreeView/TreeView.js.map +0 -1
  142. package/dist/playground/components/TreeView/TreeView.module.css +0 -214
  143. package/dist/playground/components/TreeView/index.d.ts +0 -3
  144. package/dist/playground/components/TreeView/index.d.ts.map +0 -1
  145. package/dist/playground/components/TreeView/index.js +0 -2
  146. package/dist/playground/components/TreeView/index.js.map +0 -1
  147. package/dist/playground/config/propertyDefinitions.d.ts +0 -73
  148. package/dist/playground/config/propertyDefinitions.d.ts.map +0 -1
  149. package/dist/playground/config/propertyDefinitions.js +0 -809
  150. package/dist/playground/config/propertyDefinitions.js.map +0 -1
  151. package/dist/playground/hooks/useKeyboardShortcuts.d.ts +0 -38
  152. package/dist/playground/hooks/useKeyboardShortcuts.d.ts.map +0 -1
  153. package/dist/playground/hooks/useKeyboardShortcuts.js +0 -191
  154. package/dist/playground/hooks/useKeyboardShortcuts.js.map +0 -1
  155. package/dist/playground/index.d.ts +0 -21
  156. package/dist/playground/index.d.ts.map +0 -1
  157. package/dist/playground/index.js +0 -23
  158. package/dist/playground/index.js.map +0 -1
  159. package/dist/playground/services/CodeGenerator.d.ts +0 -73
  160. package/dist/playground/services/CodeGenerator.d.ts.map +0 -1
  161. package/dist/playground/services/CodeGenerator.js +0 -359
  162. package/dist/playground/services/CodeGenerator.js.map +0 -1
  163. package/dist/playground/services/DragDropManager.d.ts +0 -95
  164. package/dist/playground/services/DragDropManager.d.ts.map +0 -1
  165. package/dist/playground/services/DragDropManager.js +0 -408
  166. package/dist/playground/services/DragDropManager.js.map +0 -1
  167. package/dist/playground/services/StoryParser.d.ts +0 -73
  168. package/dist/playground/services/StoryParser.d.ts.map +0 -1
  169. package/dist/playground/services/StoryParser.js +0 -419
  170. package/dist/playground/services/StoryParser.js.map +0 -1
  171. package/dist/playground/store/playgroundStore.d.ts +0 -86
  172. package/dist/playground/store/playgroundStore.d.ts.map +0 -1
  173. package/dist/playground/store/playgroundStore.js +0 -337
  174. package/dist/playground/store/playgroundStore.js.map +0 -1
  175. package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts +0 -13
  176. package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts.map +0 -1
  177. package/dist/playground/stories/PlaygroundDragDrop.stories.js +0 -227
  178. package/dist/playground/stories/PlaygroundDragDrop.stories.js.map +0 -1
  179. package/dist/playground/stories/PlaygroundPhase4.stories.d.ts +0 -13
  180. package/dist/playground/stories/PlaygroundPhase4.stories.d.ts.map +0 -1
  181. package/dist/playground/stories/PlaygroundPhase4.stories.js +0 -334
  182. package/dist/playground/stories/PlaygroundPhase4.stories.js.map +0 -1
  183. package/dist/playground/stories/PlaygroundPhase5.stories.d.ts +0 -14
  184. package/dist/playground/stories/PlaygroundPhase5.stories.d.ts.map +0 -1
  185. package/dist/playground/stories/PlaygroundPhase5.stories.js +0 -512
  186. package/dist/playground/stories/PlaygroundPhase5.stories.js.map +0 -1
  187. package/dist/playground/stories/PlaygroundProperties.stories.d.ts +0 -13
  188. package/dist/playground/stories/PlaygroundProperties.stories.d.ts.map +0 -1
  189. package/dist/playground/stories/PlaygroundProperties.stories.js +0 -342
  190. package/dist/playground/stories/PlaygroundProperties.stories.js.map +0 -1
  191. package/dist/playground/types/index.d.ts +0 -251
  192. package/dist/playground/types/index.d.ts.map +0 -1
  193. package/dist/playground/types/index.js +0 -5
  194. package/dist/playground/types/index.js.map +0 -1
  195. package/dist/scripts/verify-framework-adapters.js +0 -105
  196. package/dist/story-generator/componentBlacklist.js.map +0 -1
  197. package/dist/story-generator/componentDiscovery.js.map +0 -1
  198. package/dist/story-generator/configLoader.js.map +0 -1
  199. package/dist/story-generator/considerationsLoader.js.map +0 -1
  200. package/dist/story-generator/documentation-sources.js.map +0 -1
  201. package/dist/story-generator/documentationLoader.js.map +0 -1
  202. package/dist/story-generator/dynamicPackageDiscovery.js.map +0 -1
  203. package/dist/story-generator/enhancedComponentDiscovery.js.map +0 -1
  204. package/dist/story-generator/generateStory.js.map +0 -1
  205. package/dist/story-generator/gitignoreManager.js.map +0 -1
  206. package/dist/story-generator/inMemoryStoryService.js.map +0 -1
  207. package/dist/story-generator/logger.js.map +0 -1
  208. package/dist/story-generator/postProcessStory.js.map +0 -1
  209. package/dist/story-generator/productionGitignoreManager.js.map +0 -1
  210. package/dist/story-generator/promptGenerator.js.map +0 -1
  211. package/dist/story-generator/providerPresets.d.ts +0 -54
  212. package/dist/story-generator/providerPresets.d.ts.map +0 -1
  213. package/dist/story-generator/providerPresets.js +0 -214
  214. package/dist/story-generator/storyHistory.js.map +0 -1
  215. package/dist/story-generator/storySync.js.map +0 -1
  216. package/dist/story-generator/storyTracker.js.map +0 -1
  217. package/dist/story-generator/storyValidator.js.map +0 -1
  218. package/dist/story-generator/test_validation.d.ts +0 -2
  219. package/dist/story-generator/test_validation.d.ts.map +0 -1
  220. package/dist/story-generator/test_validation.js +0 -51
  221. package/dist/story-generator/universalDesignSystemAdapter.js.map +0 -1
  222. package/dist/story-generator/urlRedirectService.js.map +0 -1
  223. package/dist/story-generator/validateStory.js.map +0 -1
  224. package/dist/story-ui.config.js.map +0 -1
  225. package/dist/story-ui.config.loader.d.ts +0 -36
  226. package/dist/story-ui.config.loader.d.ts.map +0 -1
  227. package/dist/story-ui.config.loader.js +0 -205
  228. package/dist/story-ui.config.loader.js.map +0 -1
  229. package/dist/temp/package/templates/StoryUI/StoryUIPanel.js +0 -807
  230. package/dist/temp/package/templates/StoryUI/StoryUIPanel.stories.js +0 -37
  231. package/dist/temp/package/templates/StoryUI/index.js +0 -2
  232. package/dist/templates/StoryUI/StoryUIPanel.js.map +0 -1
  233. package/dist/templates/StoryUI/StoryUIPanel.stories.js.map +0 -1
  234. package/dist/templates/StoryUI/index.js.map +0 -1
  235. package/dist/templates/StoryUI/manager.d.ts +0 -14
  236. package/dist/templates/StoryUI/manager.d.ts.map +0 -1
  237. package/dist/templates/production-app/src/App.d.ts +0 -10
  238. package/dist/templates/production-app/src/App.d.ts.map +0 -1
  239. package/dist/templates/production-app/src/App.js +0 -653
  240. package/dist/templates/production-app/src/LivePreviewRenderer.d.ts +0 -24
  241. package/dist/templates/production-app/src/LivePreviewRenderer.d.ts.map +0 -1
  242. package/dist/templates/production-app/src/LivePreviewRenderer.js +0 -199
  243. package/dist/templates/production-app/src/componentRegistry.d.ts +0 -20
  244. package/dist/templates/production-app/src/componentRegistry.d.ts.map +0 -1
  245. package/dist/templates/production-app/src/componentRegistry.js +0 -316
  246. package/dist/templates/production-app/src/main.d.ts +0 -9
  247. package/dist/templates/production-app/src/main.d.ts.map +0 -1
  248. package/dist/templates/production-app/src/main.js +0 -18
  249. package/dist/templates/production-app/vite.config.d.ts +0 -3
  250. package/dist/templates/production-app/vite.config.d.ts.map +0 -1
  251. package/dist/templates/production-app/vite.config.js +0 -71
  252. package/dist/test-storybooks/angular-material-storybook/src/main.js +0 -66
  253. package/dist/test-storybooks/chakra-storybook/vite.config.js +0 -6
  254. package/dist/test-storybooks/mantine-storybook/vite.config.js +0 -93
  255. package/dist/test-storybooks/web-components-shoelace/vite.config.js +0 -9
  256. package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/cli/index.js CHANGED
File without changes
@@ -1,3 +1,8 @@
1
+ declare global {
2
+ interface Window {
3
+ __STORY_UI_GENERATED_CODE__?: Record<string, string>;
4
+ }
5
+ }
1
6
  declare function StoryUIPanel(): import("react/jsx-runtime").JSX.Element;
2
7
  export default StoryUIPanel;
3
8
  export { StoryUIPanel };
@@ -1 +1 @@
1
- {"version":3,"file":"StoryUIPanel.d.ts","sourceRoot":"","sources":["../../../templates/StoryUI/StoryUIPanel.tsx"],"names":[],"mappings":"AA85CA,iBAAS,YAAY,4CA8sCpB;AAED,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"StoryUIPanel.d.ts","sourceRoot":"","sources":["../../../templates/StoryUI/StoryUIPanel.tsx"],"names":[],"mappings":"AAsSA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,2BAA2B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACtD;CACF;AA6oCD,iBAAS,YAAY,4CA8sCpB;AAED,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -121,12 +121,27 @@ const titleToStoryPath = (title) => {
121
121
  const kebabTitle = title.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
122
122
  return `generated-${kebabTitle}--default`;
123
123
  };
124
+ // Helper to store generated code for the Source Code panel to display
125
+ const storeGeneratedCode = (title, code) => {
126
+ const storyPath = titleToStoryPath(title);
127
+ const topWindow = window.top || window;
128
+ // Store code in the top window so it's accessible from manager frame
129
+ if (!topWindow.__STORY_UI_GENERATED_CODE__) {
130
+ topWindow.__STORY_UI_GENERATED_CODE__ = {};
131
+ }
132
+ topWindow.__STORY_UI_GENERATED_CODE__[storyPath] = code;
133
+ console.log(`[Story UI] Stored code for story "${storyPath}" in window cache`);
134
+ };
124
135
  // Helper to navigate to a newly created story after generation completes
125
136
  // In dev mode with HMR, this prevents the "Couldn't find story after HMR" error
126
137
  // In all modes, this provides a better UX by auto-navigating to the new story
127
- const navigateToNewStory = (title, delayMs = 4000) => {
138
+ const navigateToNewStory = (title, code, delayMs = 1500) => {
128
139
  const storyPath = titleToStoryPath(title);
129
140
  console.log(`[Story UI] Will navigate to story "${storyPath}" in ${delayMs}ms...`);
141
+ // Store the code for the Source Code panel if provided
142
+ if (code) {
143
+ storeGeneratedCode(title, code);
144
+ }
130
145
  setTimeout(() => {
131
146
  // Navigate the TOP window (parent Storybook UI), not the iframe
132
147
  // The Story UI panel runs inside an iframe, so we need window.top to escape it
@@ -1438,7 +1453,7 @@ function StoryUIPanel() {
1438
1453
  // Auto-navigate to the newly created story after HMR processes the file
1439
1454
  // This prevents the "Couldn't find story after HMR" error by refreshing
1440
1455
  // after the file system has been updated and HMR has processed the change
1441
- navigateToNewStory(chatTitle);
1456
+ navigateToNewStory(chatTitle, completion.code);
1442
1457
  }
1443
1458
  }, [activeChatId, activeTitle, conversation.length]);
1444
1459
  const handleSend = async (e) => {
@@ -1631,7 +1646,7 @@ function StoryUIPanel() {
1631
1646
  saveChats(chats);
1632
1647
  setRecentChats(chats);
1633
1648
  // Auto-navigate to the newly created story
1634
- navigateToNewStory(chatTitle);
1649
+ navigateToNewStory(chatTitle, data.code);
1635
1650
  }
1636
1651
  }
1637
1652
  catch (fallbackErr) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpitre/story-ui",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "AI-powered Storybook story generator with dynamic component discovery",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -291,13 +291,38 @@ const titleToStoryPath = (title: string): string => {
291
291
  return `generated-${kebabTitle}--default`;
292
292
  };
293
293
 
294
+ // Extend window to include our code cache for the Source Code panel
295
+ declare global {
296
+ interface Window {
297
+ __STORY_UI_GENERATED_CODE__?: Record<string, string>;
298
+ }
299
+ }
300
+
301
+ // Helper to store generated code for the Source Code panel to display
302
+ const storeGeneratedCode = (title: string, code: string) => {
303
+ const storyPath = titleToStoryPath(title);
304
+ const topWindow = window.top || window;
305
+
306
+ // Store code in the top window so it's accessible from manager frame
307
+ if (!topWindow.__STORY_UI_GENERATED_CODE__) {
308
+ topWindow.__STORY_UI_GENERATED_CODE__ = {};
309
+ }
310
+ topWindow.__STORY_UI_GENERATED_CODE__[storyPath] = code;
311
+ console.log(`[Story UI] Stored code for story "${storyPath}" in window cache`);
312
+ };
313
+
294
314
  // Helper to navigate to a newly created story after generation completes
295
315
  // In dev mode with HMR, this prevents the "Couldn't find story after HMR" error
296
316
  // In all modes, this provides a better UX by auto-navigating to the new story
297
- const navigateToNewStory = (title: string, delayMs: number = 4000) => {
317
+ const navigateToNewStory = (title: string, code?: string, delayMs: number = 1500) => {
298
318
  const storyPath = titleToStoryPath(title);
299
319
  console.log(`[Story UI] Will navigate to story "${storyPath}" in ${delayMs}ms...`);
300
320
 
321
+ // Store the code for the Source Code panel if provided
322
+ if (code) {
323
+ storeGeneratedCode(title, code);
324
+ }
325
+
301
326
  setTimeout(() => {
302
327
  // Navigate the TOP window (parent Storybook UI), not the iframe
303
328
  // The Story UI panel runs inside an iframe, so we need window.top to escape it
@@ -1927,7 +1952,7 @@ function StoryUIPanel() {
1927
1952
  // Auto-navigate to the newly created story after HMR processes the file
1928
1953
  // This prevents the "Couldn't find story after HMR" error by refreshing
1929
1954
  // after the file system has been updated and HMR has processed the change
1930
- navigateToNewStory(chatTitle);
1955
+ navigateToNewStory(chatTitle, completion.code);
1931
1956
  }
1932
1957
  }, [activeChatId, activeTitle, conversation.length]);
1933
1958
 
@@ -2137,7 +2162,7 @@ function StoryUIPanel() {
2137
2162
  setRecentChats(chats);
2138
2163
 
2139
2164
  // Auto-navigate to the newly created story
2140
- navigateToNewStory(chatTitle);
2165
+ navigateToNewStory(chatTitle, data.code);
2141
2166
  }
2142
2167
  } catch (fallbackErr: unknown) {
2143
2168
  const errorMessage = fallbackErr instanceof Error ? fallbackErr.message : 'Unknown error';