@tpitre/story-ui 2.8.0 → 3.0.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 (254) hide show
  1. package/dist/cli/index.js +0 -0
  2. package/dist/cli/index.js.map +1 -0
  3. package/dist/cli/setup.js.map +1 -0
  4. package/dist/cloudflare-edge/src/mcp-session.js +462 -0
  5. package/dist/cloudflare-edge/src/types.js +4 -0
  6. package/dist/cloudflare-edge/src/worker.js +106 -0
  7. package/dist/cloudflare-pages/vite.config.js +14 -0
  8. package/dist/index.d.ts +13 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +12 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/mcp-server/index.js.map +1 -0
  13. package/dist/mcp-server/mcp-stdio-server.js.map +1 -0
  14. package/dist/mcp-server/routes/claude.js.map +1 -0
  15. package/dist/mcp-server/routes/components.js.map +1 -0
  16. package/dist/mcp-server/routes/generateStory.js.map +1 -0
  17. package/dist/mcp-server/routes/hybridStories.js.map +1 -0
  18. package/dist/mcp-server/routes/memoryStories.js.map +1 -0
  19. package/dist/mcp-server/routes/storySync.js.map +1 -0
  20. package/dist/mcp-server/routes/updateStory.js +246 -0
  21. package/dist/mcp-server/sessionManager.js.map +1 -0
  22. package/dist/playground/components/AIAssistant/AIAssistant.d.ts +6 -0
  23. package/dist/playground/components/AIAssistant/AIAssistant.d.ts.map +1 -0
  24. package/dist/playground/components/AIAssistant/AIAssistant.js +109 -0
  25. package/dist/playground/components/AIAssistant/AIAssistant.js.map +1 -0
  26. package/dist/playground/components/AIAssistant/AIAssistant.module.css +166 -0
  27. package/dist/playground/components/Canvas/Canvas.d.ts +9 -0
  28. package/dist/playground/components/Canvas/Canvas.d.ts.map +1 -0
  29. package/dist/playground/components/Canvas/Canvas.js +58 -0
  30. package/dist/playground/components/Canvas/Canvas.js.map +1 -0
  31. package/dist/playground/components/Canvas/Canvas.module.css +189 -0
  32. package/dist/playground/components/Canvas/CanvasWithDnd.d.ts +9 -0
  33. package/dist/playground/components/Canvas/CanvasWithDnd.d.ts.map +1 -0
  34. package/dist/playground/components/Canvas/CanvasWithDnd.js +158 -0
  35. package/dist/playground/components/Canvas/CanvasWithDnd.js.map +1 -0
  36. package/dist/playground/components/Canvas/ComponentRenderer.d.ts +15 -0
  37. package/dist/playground/components/Canvas/ComponentRenderer.d.ts.map +1 -0
  38. package/dist/playground/components/Canvas/ComponentRenderer.js +177 -0
  39. package/dist/playground/components/Canvas/ComponentRenderer.js.map +1 -0
  40. package/dist/playground/components/Canvas/DraggableComponent.d.ts +15 -0
  41. package/dist/playground/components/Canvas/DraggableComponent.d.ts.map +1 -0
  42. package/dist/playground/components/Canvas/DraggableComponent.js +49 -0
  43. package/dist/playground/components/Canvas/DraggableComponent.js.map +1 -0
  44. package/dist/playground/components/Canvas/index.d.ts +9 -0
  45. package/dist/playground/components/Canvas/index.d.ts.map +1 -0
  46. package/dist/playground/components/Canvas/index.js +5 -0
  47. package/dist/playground/components/Canvas/index.js.map +1 -0
  48. package/dist/playground/components/CodeView/CodeView.d.ts +12 -0
  49. package/dist/playground/components/CodeView/CodeView.d.ts.map +1 -0
  50. package/dist/playground/components/CodeView/CodeView.js +77 -0
  51. package/dist/playground/components/CodeView/CodeView.js.map +1 -0
  52. package/dist/playground/components/CodeView/CodeView.module.css +178 -0
  53. package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts +17 -0
  54. package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts.map +1 -0
  55. package/dist/playground/components/ComponentPalette/ComponentPalette.js +138 -0
  56. package/dist/playground/components/ComponentPalette/ComponentPalette.js.map +1 -0
  57. package/dist/playground/components/ComponentPalette/ComponentPalette.module.css +217 -0
  58. package/dist/playground/components/ComponentPalette/index.d.ts +3 -0
  59. package/dist/playground/components/ComponentPalette/index.d.ts.map +1 -0
  60. package/dist/playground/components/ComponentPalette/index.js +2 -0
  61. package/dist/playground/components/ComponentPalette/index.js.map +1 -0
  62. package/dist/playground/components/DropZone/DropZone.d.ts +17 -0
  63. package/dist/playground/components/DropZone/DropZone.d.ts.map +1 -0
  64. package/dist/playground/components/DropZone/DropZone.js +73 -0
  65. package/dist/playground/components/DropZone/DropZone.js.map +1 -0
  66. package/dist/playground/components/DropZone/DropZone.module.css +86 -0
  67. package/dist/playground/components/ExportDialog/ExportDialog.d.ts +10 -0
  68. package/dist/playground/components/ExportDialog/ExportDialog.d.ts.map +1 -0
  69. package/dist/playground/components/ExportDialog/ExportDialog.js +57 -0
  70. package/dist/playground/components/ExportDialog/ExportDialog.js.map +1 -0
  71. package/dist/playground/components/ExportDialog/ExportDialog.module.css +328 -0
  72. package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts +134 -0
  73. package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts.map +1 -0
  74. package/dist/playground/components/LayoutHelpers/LayoutHelpers.js +254 -0
  75. package/dist/playground/components/LayoutHelpers/LayoutHelpers.js.map +1 -0
  76. package/dist/playground/components/LayoutHelpers/index.d.ts +3 -0
  77. package/dist/playground/components/LayoutHelpers/index.d.ts.map +1 -0
  78. package/dist/playground/components/LayoutHelpers/index.js +2 -0
  79. package/dist/playground/components/LayoutHelpers/index.js.map +1 -0
  80. package/dist/playground/components/Playground/Playground.d.ts +10 -0
  81. package/dist/playground/components/Playground/Playground.d.ts.map +1 -0
  82. package/dist/playground/components/Playground/Playground.js +128 -0
  83. package/dist/playground/components/Playground/Playground.js.map +1 -0
  84. package/dist/playground/components/Playground/Playground.module.css +308 -0
  85. package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts +10 -0
  86. package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts.map +1 -0
  87. package/dist/playground/components/PropertiesPanel/PropertiesPanel.js +150 -0
  88. package/dist/playground/components/PropertiesPanel/PropertiesPanel.js.map +1 -0
  89. package/dist/playground/components/PropertiesPanel/PropertiesPanel.module.css +155 -0
  90. package/dist/playground/components/PropertiesPanel/index.d.ts +3 -0
  91. package/dist/playground/components/PropertiesPanel/index.d.ts.map +1 -0
  92. package/dist/playground/components/PropertiesPanel/index.js +2 -0
  93. package/dist/playground/components/PropertiesPanel/index.js.map +1 -0
  94. package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts +12 -0
  95. package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts.map +1 -0
  96. package/dist/playground/components/PropertyEditors/BooleanEditor.js +14 -0
  97. package/dist/playground/components/PropertyEditors/BooleanEditor.js.map +1 -0
  98. package/dist/playground/components/PropertyEditors/ColorEditor.d.ts +12 -0
  99. package/dist/playground/components/PropertyEditors/ColorEditor.d.ts.map +1 -0
  100. package/dist/playground/components/PropertyEditors/ColorEditor.js +62 -0
  101. package/dist/playground/components/PropertyEditors/ColorEditor.js.map +1 -0
  102. package/dist/playground/components/PropertyEditors/IconEditor.d.ts +12 -0
  103. package/dist/playground/components/PropertyEditors/IconEditor.d.ts.map +1 -0
  104. package/dist/playground/components/PropertyEditors/IconEditor.js +123 -0
  105. package/dist/playground/components/PropertyEditors/IconEditor.js.map +1 -0
  106. package/dist/playground/components/PropertyEditors/NumberEditor.d.ts +15 -0
  107. package/dist/playground/components/PropertyEditors/NumberEditor.d.ts.map +1 -0
  108. package/dist/playground/components/PropertyEditors/NumberEditor.js +46 -0
  109. package/dist/playground/components/PropertyEditors/NumberEditor.js.map +1 -0
  110. package/dist/playground/components/PropertyEditors/PropertyEditors.module.css +432 -0
  111. package/dist/playground/components/PropertyEditors/SelectEditor.d.ts +19 -0
  112. package/dist/playground/components/PropertyEditors/SelectEditor.d.ts.map +1 -0
  113. package/dist/playground/components/PropertyEditors/SelectEditor.js +17 -0
  114. package/dist/playground/components/PropertyEditors/SelectEditor.js.map +1 -0
  115. package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts +19 -0
  116. package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts.map +1 -0
  117. package/dist/playground/components/PropertyEditors/SpacingEditor.js +162 -0
  118. package/dist/playground/components/PropertyEditors/SpacingEditor.js.map +1 -0
  119. package/dist/playground/components/PropertyEditors/SpacingEditor.module.css +214 -0
  120. package/dist/playground/components/PropertyEditors/TextEditor.d.ts +14 -0
  121. package/dist/playground/components/PropertyEditors/TextEditor.d.ts.map +1 -0
  122. package/dist/playground/components/PropertyEditors/TextEditor.js +38 -0
  123. package/dist/playground/components/PropertyEditors/TextEditor.js.map +1 -0
  124. package/dist/playground/components/PropertyEditors/TokenEditor.d.ts +23 -0
  125. package/dist/playground/components/PropertyEditors/TokenEditor.d.ts.map +1 -0
  126. package/dist/playground/components/PropertyEditors/TokenEditor.js +50 -0
  127. package/dist/playground/components/PropertyEditors/TokenEditor.js.map +1 -0
  128. package/dist/playground/components/PropertyEditors/index.d.ts +20 -0
  129. package/dist/playground/components/PropertyEditors/index.d.ts.map +1 -0
  130. package/dist/playground/components/PropertyEditors/index.js +12 -0
  131. package/dist/playground/components/PropertyEditors/index.js.map +1 -0
  132. package/dist/playground/components/TreeView/TreeView.d.ts +10 -0
  133. package/dist/playground/components/TreeView/TreeView.d.ts.map +1 -0
  134. package/dist/playground/components/TreeView/TreeView.js +146 -0
  135. package/dist/playground/components/TreeView/TreeView.js.map +1 -0
  136. package/dist/playground/components/TreeView/TreeView.module.css +214 -0
  137. package/dist/playground/components/TreeView/index.d.ts +3 -0
  138. package/dist/playground/components/TreeView/index.d.ts.map +1 -0
  139. package/dist/playground/components/TreeView/index.js +2 -0
  140. package/dist/playground/components/TreeView/index.js.map +1 -0
  141. package/dist/playground/config/propertyDefinitions.d.ts +73 -0
  142. package/dist/playground/config/propertyDefinitions.d.ts.map +1 -0
  143. package/dist/playground/config/propertyDefinitions.js +809 -0
  144. package/dist/playground/config/propertyDefinitions.js.map +1 -0
  145. package/dist/playground/hooks/useKeyboardShortcuts.d.ts +38 -0
  146. package/dist/playground/hooks/useKeyboardShortcuts.d.ts.map +1 -0
  147. package/dist/playground/hooks/useKeyboardShortcuts.js +191 -0
  148. package/dist/playground/hooks/useKeyboardShortcuts.js.map +1 -0
  149. package/dist/playground/index.d.ts +21 -0
  150. package/dist/playground/index.d.ts.map +1 -0
  151. package/dist/playground/index.js +23 -0
  152. package/dist/playground/index.js.map +1 -0
  153. package/dist/playground/services/CodeGenerator.d.ts +73 -0
  154. package/dist/playground/services/CodeGenerator.d.ts.map +1 -0
  155. package/dist/playground/services/CodeGenerator.js +359 -0
  156. package/dist/playground/services/CodeGenerator.js.map +1 -0
  157. package/dist/playground/services/DragDropManager.d.ts +95 -0
  158. package/dist/playground/services/DragDropManager.d.ts.map +1 -0
  159. package/dist/playground/services/DragDropManager.js +408 -0
  160. package/dist/playground/services/DragDropManager.js.map +1 -0
  161. package/dist/playground/services/StoryParser.d.ts +73 -0
  162. package/dist/playground/services/StoryParser.d.ts.map +1 -0
  163. package/dist/playground/services/StoryParser.js +419 -0
  164. package/dist/playground/services/StoryParser.js.map +1 -0
  165. package/dist/playground/store/playgroundStore.d.ts +86 -0
  166. package/dist/playground/store/playgroundStore.d.ts.map +1 -0
  167. package/dist/playground/store/playgroundStore.js +337 -0
  168. package/dist/playground/store/playgroundStore.js.map +1 -0
  169. package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts +13 -0
  170. package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts.map +1 -0
  171. package/dist/playground/stories/PlaygroundDragDrop.stories.js +227 -0
  172. package/dist/playground/stories/PlaygroundDragDrop.stories.js.map +1 -0
  173. package/dist/playground/stories/PlaygroundPhase4.stories.d.ts +13 -0
  174. package/dist/playground/stories/PlaygroundPhase4.stories.d.ts.map +1 -0
  175. package/dist/playground/stories/PlaygroundPhase4.stories.js +334 -0
  176. package/dist/playground/stories/PlaygroundPhase4.stories.js.map +1 -0
  177. package/dist/playground/stories/PlaygroundPhase5.stories.d.ts +14 -0
  178. package/dist/playground/stories/PlaygroundPhase5.stories.d.ts.map +1 -0
  179. package/dist/playground/stories/PlaygroundPhase5.stories.js +512 -0
  180. package/dist/playground/stories/PlaygroundPhase5.stories.js.map +1 -0
  181. package/dist/playground/stories/PlaygroundProperties.stories.d.ts +13 -0
  182. package/dist/playground/stories/PlaygroundProperties.stories.d.ts.map +1 -0
  183. package/dist/playground/stories/PlaygroundProperties.stories.js +342 -0
  184. package/dist/playground/stories/PlaygroundProperties.stories.js.map +1 -0
  185. package/dist/playground/types/index.d.ts +251 -0
  186. package/dist/playground/types/index.d.ts.map +1 -0
  187. package/dist/playground/types/index.js +5 -0
  188. package/dist/playground/types/index.js.map +1 -0
  189. package/dist/scripts/verify-framework-adapters.js +105 -0
  190. package/dist/story-generator/componentBlacklist.js.map +1 -0
  191. package/dist/story-generator/componentDiscovery.js.map +1 -0
  192. package/dist/story-generator/configLoader.js.map +1 -0
  193. package/dist/story-generator/considerationsLoader.js.map +1 -0
  194. package/dist/story-generator/documentation-sources.js.map +1 -0
  195. package/dist/story-generator/documentationLoader.js.map +1 -0
  196. package/dist/story-generator/dynamicPackageDiscovery.js.map +1 -0
  197. package/dist/story-generator/enhancedComponentDiscovery.js.map +1 -0
  198. package/dist/story-generator/generateStory.js.map +1 -0
  199. package/dist/story-generator/gitignoreManager.js.map +1 -0
  200. package/dist/story-generator/inMemoryStoryService.js.map +1 -0
  201. package/dist/story-generator/logger.js.map +1 -0
  202. package/dist/story-generator/postProcessStory.js.map +1 -0
  203. package/dist/story-generator/productionGitignoreManager.js.map +1 -0
  204. package/dist/story-generator/promptGenerator.js.map +1 -0
  205. package/dist/story-generator/providerPresets.d.ts +54 -0
  206. package/dist/story-generator/providerPresets.d.ts.map +1 -0
  207. package/dist/story-generator/providerPresets.js +214 -0
  208. package/dist/story-generator/storyHistory.js.map +1 -0
  209. package/dist/story-generator/storySync.js.map +1 -0
  210. package/dist/story-generator/storyTracker.js.map +1 -0
  211. package/dist/story-generator/storyValidator.js.map +1 -0
  212. package/dist/story-generator/test_validation.d.ts +2 -0
  213. package/dist/story-generator/test_validation.d.ts.map +1 -0
  214. package/dist/story-generator/test_validation.js +51 -0
  215. package/dist/story-generator/universalDesignSystemAdapter.js.map +1 -0
  216. package/dist/story-generator/urlRedirectService.js.map +1 -0
  217. package/dist/story-generator/validateStory.js.map +1 -0
  218. package/dist/story-ui.config.js.map +1 -0
  219. package/dist/story-ui.config.loader.d.ts +36 -0
  220. package/dist/story-ui.config.loader.d.ts.map +1 -0
  221. package/dist/story-ui.config.loader.js +205 -0
  222. package/dist/story-ui.config.loader.js.map +1 -0
  223. package/dist/temp/package/templates/StoryUI/StoryUIPanel.js +807 -0
  224. package/dist/temp/package/templates/StoryUI/StoryUIPanel.stories.js +37 -0
  225. package/dist/temp/package/templates/StoryUI/index.js +2 -0
  226. package/dist/templates/StoryUI/StoryUIPanel.d.ts.map +1 -1
  227. package/dist/templates/StoryUI/StoryUIPanel.js +30 -2
  228. package/dist/templates/StoryUI/StoryUIPanel.js.map +1 -0
  229. package/dist/templates/StoryUI/StoryUIPanel.stories.js.map +1 -0
  230. package/dist/templates/StoryUI/index.js.map +1 -0
  231. package/dist/templates/StoryUI/manager.d.ts +14 -0
  232. package/dist/templates/StoryUI/manager.d.ts.map +1 -0
  233. package/dist/templates/production-app/src/App.d.ts +10 -0
  234. package/dist/templates/production-app/src/App.d.ts.map +1 -0
  235. package/dist/templates/production-app/src/App.js +653 -0
  236. package/dist/templates/production-app/src/LivePreviewRenderer.d.ts +24 -0
  237. package/dist/templates/production-app/src/LivePreviewRenderer.d.ts.map +1 -0
  238. package/dist/templates/production-app/src/LivePreviewRenderer.js +199 -0
  239. package/dist/templates/production-app/src/componentRegistry.d.ts +20 -0
  240. package/dist/templates/production-app/src/componentRegistry.d.ts.map +1 -0
  241. package/dist/templates/production-app/src/componentRegistry.js +316 -0
  242. package/dist/templates/production-app/src/main.d.ts +9 -0
  243. package/dist/templates/production-app/src/main.d.ts.map +1 -0
  244. package/dist/templates/production-app/src/main.js +18 -0
  245. package/dist/templates/production-app/vite.config.d.ts +3 -0
  246. package/dist/templates/production-app/vite.config.d.ts.map +1 -0
  247. package/dist/templates/production-app/vite.config.js +71 -0
  248. package/dist/test-storybooks/angular-material-storybook/src/main.js +66 -0
  249. package/dist/test-storybooks/chakra-storybook/vite.config.js +6 -0
  250. package/dist/test-storybooks/mantine-storybook/vite.config.js +93 -0
  251. package/dist/test-storybooks/web-components-shoelace/vite.config.js +9 -0
  252. package/dist/tsconfig.tsbuildinfo +1 -0
  253. package/package.json +1 -1
  254. package/templates/StoryUI/StoryUIPanel.tsx +35 -2
@@ -0,0 +1,66 @@
1
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
2
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
3
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
4
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
5
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6
+ var _, done = false;
7
+ for (var i = decorators.length - 1; i >= 0; i--) {
8
+ var context = {};
9
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
10
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
11
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
12
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13
+ if (kind === "accessor") {
14
+ if (result === void 0) continue;
15
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
16
+ if (_ = accept(result.get)) descriptor.get = _;
17
+ if (_ = accept(result.set)) descriptor.set = _;
18
+ if (_ = accept(result.init)) initializers.unshift(_);
19
+ }
20
+ else if (_ = accept(result)) {
21
+ if (kind === "field") initializers.unshift(_);
22
+ else descriptor[key] = _;
23
+ }
24
+ }
25
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
26
+ done = true;
27
+ };
28
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
29
+ var useValue = arguments.length > 2;
30
+ for (var i = 0; i < initializers.length; i++) {
31
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
32
+ }
33
+ return useValue ? value : void 0;
34
+ };
35
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
36
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
37
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
38
+ };
39
+ import { bootstrapApplication } from '@angular/platform-browser';
40
+ import { provideAnimations } from '@angular/platform-browser/animations';
41
+ import { Component } from '@angular/core';
42
+ let AppComponent = (() => {
43
+ let _classDecorators = [Component({
44
+ selector: 'app-root',
45
+ standalone: true,
46
+ template: '<h1>Angular Material Storybook</h1>',
47
+ })];
48
+ let _classDescriptor;
49
+ let _classExtraInitializers = [];
50
+ let _classThis;
51
+ var AppComponent = _classThis = class {
52
+ };
53
+ __setFunctionName(_classThis, "AppComponent");
54
+ (() => {
55
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
56
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
57
+ AppComponent = _classThis = _classDescriptor.value;
58
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
59
+ __runInitializers(_classThis, _classExtraInitializers);
60
+ })();
61
+ return AppComponent = _classThis;
62
+ })();
63
+ export { AppComponent };
64
+ bootstrapApplication(AppComponent, {
65
+ providers: [provideAnimations()],
66
+ });
@@ -0,0 +1,6 @@
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+ // https://vite.dev/config/
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ });
@@ -0,0 +1,93 @@
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ // Custom plugin to serve raw source files for Visual Builder
6
+ function rawSourcePlugin() {
7
+ return {
8
+ name: 'raw-source-plugin',
9
+ configureServer(server) {
10
+ server.middlewares.use('/api/raw-source', (req, res) => {
11
+ const url = new URL(req.url, `http://${req.headers.host}`);
12
+ const fileName = url.searchParams.get('file');
13
+ const isEdited = url.searchParams.get('isEdited') === 'true';
14
+ if (!fileName) {
15
+ res.statusCode = 400;
16
+ res.end(JSON.stringify({ error: 'File parameter is required' }));
17
+ return;
18
+ }
19
+ console.log(`[Vite Plugin] Loading story: ${fileName}, isEdited: ${isEdited}`);
20
+ try {
21
+ let filePath;
22
+ let sourceCode;
23
+ // Priority-based file lookup: edited stories get priority in edited/ directory
24
+ if (isEdited) {
25
+ // For edited stories, check edited/ directory first
26
+ const editedPath = path.join(process.cwd(), 'src', 'stories', 'edited', `${fileName}.stories.tsx`);
27
+ const generatedPath = path.join(process.cwd(), 'src', 'stories', 'generated', `${fileName}.stories.tsx`);
28
+ if (fs.existsSync(editedPath)) {
29
+ filePath = editedPath;
30
+ sourceCode = fs.readFileSync(filePath, 'utf-8');
31
+ }
32
+ else if (fs.existsSync(generatedPath)) {
33
+ filePath = generatedPath;
34
+ sourceCode = fs.readFileSync(filePath, 'utf-8');
35
+ }
36
+ else {
37
+ res.statusCode = 404;
38
+ res.end(JSON.stringify({
39
+ error: `File not found: ${fileName}`,
40
+ searched: ['edited/', 'generated/']
41
+ }));
42
+ return;
43
+ }
44
+ }
45
+ else {
46
+ // For generated stories, check generated/ directory first
47
+ const generatedPath = path.join(process.cwd(), 'src', 'stories', 'generated', `${fileName}.stories.tsx`);
48
+ const editedPath = path.join(process.cwd(), 'src', 'stories', 'edited', `${fileName}.stories.tsx`);
49
+ if (fs.existsSync(generatedPath)) {
50
+ filePath = generatedPath;
51
+ sourceCode = fs.readFileSync(filePath, 'utf-8');
52
+ }
53
+ else if (fs.existsSync(editedPath)) {
54
+ filePath = editedPath;
55
+ sourceCode = fs.readFileSync(filePath, 'utf-8');
56
+ }
57
+ else {
58
+ res.statusCode = 404;
59
+ res.end(JSON.stringify({
60
+ error: `File not found: ${fileName}`,
61
+ searched: ['generated/', 'edited/']
62
+ }));
63
+ return;
64
+ }
65
+ }
66
+ console.log(`[Vite Plugin] Successfully loaded from: ${filePath}`);
67
+ res.setHeader('Content-Type', 'application/json');
68
+ res.setHeader('Access-Control-Allow-Origin', '*');
69
+ res.setHeader('Access-Control-Allow-Methods', 'GET');
70
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
71
+ res.end(JSON.stringify({
72
+ success: true,
73
+ fileName: fileName,
74
+ source: sourceCode,
75
+ loadedFrom: filePath
76
+ }));
77
+ }
78
+ catch (error) {
79
+ console.error('Error reading source file:', error);
80
+ res.statusCode = 500;
81
+ res.end(JSON.stringify({
82
+ error: 'Failed to read source file',
83
+ details: error instanceof Error ? error.message : 'Unknown error'
84
+ }));
85
+ }
86
+ });
87
+ }
88
+ };
89
+ }
90
+ // https://vite.dev/config/
91
+ export default defineConfig({
92
+ plugins: [react(), rawSourcePlugin()],
93
+ });
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from 'vite';
2
+ export default defineConfig({
3
+ build: {
4
+ target: 'esnext',
5
+ },
6
+ server: {
7
+ port: 5173,
8
+ },
9
+ });
@@ -0,0 +1 @@
1
+ {"root":["../index.ts","../story-ui.config.loader.ts","../story-ui.config.ts","../cli/index.ts","../cli/setup.ts","../mcp-server/index.ts","../mcp-server/mcp-stdio-server.ts","../mcp-server/sessionmanager.ts","../mcp-server/routes/claude.ts","../mcp-server/routes/components.ts","../mcp-server/routes/generatestory.ts","../mcp-server/routes/hybridstories.ts","../mcp-server/routes/memorystories.ts","../mcp-server/routes/storysync.ts","../playground/index.ts","../playground/styles.d.ts","../playground/components/canvas/index.ts","../playground/components/componentpalette/index.ts","../playground/components/layouthelpers/index.ts","../playground/components/propertiespanel/index.ts","../playground/components/propertyeditors/index.ts","../playground/components/treeview/index.ts","../playground/config/propertydefinitions.ts","../playground/hooks/usekeyboardshortcuts.ts","../playground/services/codegenerator.ts","../playground/services/dragdropmanager.ts","../playground/services/storyparser.ts","../playground/store/playgroundstore.ts","../playground/types/index.ts","../story-generator/componentblacklist.ts","../story-generator/componentdiscovery.ts","../story-generator/configloader.ts","../story-generator/considerationsloader.ts","../story-generator/documentation-sources.ts","../story-generator/documentationloader.ts","../story-generator/dynamicpackagediscovery.ts","../story-generator/enhancedcomponentdiscovery.ts","../story-generator/generatestory.ts","../story-generator/gitignoremanager.ts","../story-generator/inmemorystoryservice.ts","../story-generator/logger.ts","../story-generator/postprocessstory.ts","../story-generator/productiongitignoremanager.ts","../story-generator/promptgenerator.ts","../story-generator/storyhistory.ts","../story-generator/storysync.ts","../story-generator/storytracker.ts","../story-generator/storyvalidator.ts","../story-generator/universaldesignsystemadapter.ts","../story-generator/urlredirectservice.ts","../story-generator/validatestory.ts","../playground/components/aiassistant/aiassistant.tsx","../playground/components/canvas/canvas.tsx","../playground/components/canvas/canvaswithdnd.tsx","../playground/components/canvas/componentrenderer.tsx","../playground/components/canvas/draggablecomponent.tsx","../playground/components/codeview/codeview.tsx","../playground/components/componentpalette/componentpalette.tsx","../playground/components/dropzone/dropzone.tsx","../playground/components/exportdialog/exportdialog.tsx","../playground/components/layouthelpers/layouthelpers.tsx","../playground/components/playground/playground.tsx","../playground/components/propertiespanel/propertiespanel.tsx","../playground/components/propertyeditors/booleaneditor.tsx","../playground/components/propertyeditors/coloreditor.tsx","../playground/components/propertyeditors/iconeditor.tsx","../playground/components/propertyeditors/numbereditor.tsx","../playground/components/propertyeditors/selecteditor.tsx","../playground/components/propertyeditors/spacingeditor.tsx","../playground/components/propertyeditors/texteditor.tsx","../playground/components/propertyeditors/tokeneditor.tsx","../playground/components/treeview/treeview.tsx","../playground/stories/playgrounddragdrop.stories.tsx","../playground/stories/playgroundphase4.stories.tsx","../playground/stories/playgroundphase5.stories.tsx","../playground/stories/playgroundproperties.stories.tsx","../templates/storyui/storyuipanel.stories.tsx","../templates/storyui/storyuipanel.tsx","../templates/storyui/index.tsx"],"version":"5.8.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpitre/story-ui",
3
- "version": "2.8.0",
3
+ "version": "3.0.0",
4
4
  "description": "AI-powered Storybook story generator with dynamic component discovery",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -284,6 +284,30 @@ const isEdgeMode = () => {
284
284
  baseUrl.startsWith('https://') && !baseUrl.includes('localhost');
285
285
  };
286
286
 
287
+ // Helper to convert story title to Storybook URL format
288
+ // e.g., "Simple Card With Image" -> "generated-simple-card-with-image--default"
289
+ const titleToStoryPath = (title: string): string => {
290
+ const kebabTitle = title.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
291
+ return `generated-${kebabTitle}--default`;
292
+ };
293
+
294
+ // Helper to navigate to a newly created story after generation completes
295
+ // In dev mode with HMR, this prevents the "Couldn't find story after HMR" error
296
+ // In all modes, this provides a better UX by auto-navigating to the new story
297
+ const navigateToNewStory = (title: string, delayMs: number = 4000) => {
298
+ const storyPath = titleToStoryPath(title);
299
+ console.log(`[Story UI] Will navigate to story "${storyPath}" in ${delayMs}ms...`);
300
+
301
+ setTimeout(() => {
302
+ // Navigate the TOP window (parent Storybook UI), not the iframe
303
+ // The Story UI panel runs inside an iframe, so we need window.top to escape it
304
+ const topWindow = window.top || window;
305
+ const newUrl = `${topWindow.location.origin}/?path=/story/${storyPath}`;
306
+ console.log(`[Story UI] Navigating parent window to: ${newUrl}`);
307
+ topWindow.location.href = newUrl;
308
+ }, delayMs);
309
+ };
310
+
287
311
  // Legacy helper for backwards compatibility
288
312
  const getApiPort = () => {
289
313
  const baseUrl = getApiBaseUrl();
@@ -1899,6 +1923,11 @@ function StoryUIPanel() {
1899
1923
  }
1900
1924
  saveChats(chats);
1901
1925
  setRecentChats(chats);
1926
+
1927
+ // Auto-navigate to the newly created story after HMR processes the file
1928
+ // This prevents the "Couldn't find story after HMR" error by refreshing
1929
+ // after the file system has been updated and HMR has processed the change
1930
+ navigateToNewStory(chatTitle);
1902
1931
  }
1903
1932
  }, [activeChatId, activeTitle, conversation.length]);
1904
1933
 
@@ -2091,11 +2120,12 @@ function StoryUIPanel() {
2091
2120
  setRecentChats(chats);
2092
2121
  } else {
2093
2122
  const chatId = data.storyId || data.fileName || Date.now().toString();
2123
+ const chatTitle = data.title || userInput;
2094
2124
  setActiveChatId(chatId);
2095
- setActiveTitle(data.title || userInput);
2125
+ setActiveTitle(chatTitle);
2096
2126
  const newSession: ChatSession = {
2097
2127
  id: chatId,
2098
- title: data.title || userInput,
2128
+ title: chatTitle,
2099
2129
  fileName: data.fileName || '',
2100
2130
  conversation: updatedConversation,
2101
2131
  lastUpdated: Date.now(),
@@ -2105,6 +2135,9 @@ function StoryUIPanel() {
2105
2135
  if (chats.length > MAX_RECENT_CHATS) chats.splice(MAX_RECENT_CHATS);
2106
2136
  saveChats(chats);
2107
2137
  setRecentChats(chats);
2138
+
2139
+ // Auto-navigate to the newly created story
2140
+ navigateToNewStory(chatTitle);
2108
2141
  }
2109
2142
  } catch (fallbackErr: unknown) {
2110
2143
  const errorMessage = fallbackErr instanceof Error ? fallbackErr.message : 'Unknown error';