@tpitre/story-ui 2.7.1 → 2.8.1
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.
- package/README.md +40 -9
- package/dist/cli/deploy.d.ts +1 -1
- package/dist/cli/deploy.d.ts.map +1 -1
- package/dist/cli/deploy.js +5 -115
- package/dist/cli/index.js +0 -0
- package/dist/cli/setup.js +3 -3
- package/dist/templates/StoryUI/StoryUIPanel.d.ts.map +1 -1
- package/dist/templates/StoryUI/StoryUIPanel.js +30 -2
- package/package.json +1 -1
- package/templates/StoryUI/StoryUIPanel.tsx +35 -2
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/setup.js.map +0 -1
- package/dist/cloudflare-edge/src/mcp-session.js +0 -462
- package/dist/cloudflare-edge/src/types.js +0 -4
- package/dist/cloudflare-edge/src/worker.js +0 -106
- package/dist/cloudflare-pages/vite.config.js +0 -14
- package/dist/index.d.ts +0 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -12
- package/dist/index.js.map +0 -1
- package/dist/mcp-server/index.js.map +0 -1
- package/dist/mcp-server/mcp-stdio-server.js.map +0 -1
- package/dist/mcp-server/routes/claude.js.map +0 -1
- package/dist/mcp-server/routes/components.js.map +0 -1
- package/dist/mcp-server/routes/generateStory.js.map +0 -1
- package/dist/mcp-server/routes/hybridStories.js.map +0 -1
- package/dist/mcp-server/routes/memoryStories.js.map +0 -1
- package/dist/mcp-server/routes/storySync.js.map +0 -1
- package/dist/mcp-server/routes/updateStory.js +0 -246
- package/dist/mcp-server/sessionManager.js.map +0 -1
- package/dist/playground/components/AIAssistant/AIAssistant.d.ts +0 -6
- package/dist/playground/components/AIAssistant/AIAssistant.d.ts.map +0 -1
- package/dist/playground/components/AIAssistant/AIAssistant.js +0 -109
- package/dist/playground/components/AIAssistant/AIAssistant.js.map +0 -1
- package/dist/playground/components/AIAssistant/AIAssistant.module.css +0 -166
- package/dist/playground/components/Canvas/Canvas.d.ts +0 -9
- package/dist/playground/components/Canvas/Canvas.d.ts.map +0 -1
- package/dist/playground/components/Canvas/Canvas.js +0 -58
- package/dist/playground/components/Canvas/Canvas.js.map +0 -1
- package/dist/playground/components/Canvas/Canvas.module.css +0 -189
- package/dist/playground/components/Canvas/CanvasWithDnd.d.ts +0 -9
- package/dist/playground/components/Canvas/CanvasWithDnd.d.ts.map +0 -1
- package/dist/playground/components/Canvas/CanvasWithDnd.js +0 -158
- package/dist/playground/components/Canvas/CanvasWithDnd.js.map +0 -1
- package/dist/playground/components/Canvas/ComponentRenderer.d.ts +0 -15
- package/dist/playground/components/Canvas/ComponentRenderer.d.ts.map +0 -1
- package/dist/playground/components/Canvas/ComponentRenderer.js +0 -177
- package/dist/playground/components/Canvas/ComponentRenderer.js.map +0 -1
- package/dist/playground/components/Canvas/DraggableComponent.d.ts +0 -15
- package/dist/playground/components/Canvas/DraggableComponent.d.ts.map +0 -1
- package/dist/playground/components/Canvas/DraggableComponent.js +0 -49
- package/dist/playground/components/Canvas/DraggableComponent.js.map +0 -1
- package/dist/playground/components/Canvas/index.d.ts +0 -9
- package/dist/playground/components/Canvas/index.d.ts.map +0 -1
- package/dist/playground/components/Canvas/index.js +0 -5
- package/dist/playground/components/Canvas/index.js.map +0 -1
- package/dist/playground/components/CodeView/CodeView.d.ts +0 -12
- package/dist/playground/components/CodeView/CodeView.d.ts.map +0 -1
- package/dist/playground/components/CodeView/CodeView.js +0 -77
- package/dist/playground/components/CodeView/CodeView.js.map +0 -1
- package/dist/playground/components/CodeView/CodeView.module.css +0 -178
- package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts +0 -17
- package/dist/playground/components/ComponentPalette/ComponentPalette.d.ts.map +0 -1
- package/dist/playground/components/ComponentPalette/ComponentPalette.js +0 -138
- package/dist/playground/components/ComponentPalette/ComponentPalette.js.map +0 -1
- package/dist/playground/components/ComponentPalette/ComponentPalette.module.css +0 -217
- package/dist/playground/components/ComponentPalette/index.d.ts +0 -3
- package/dist/playground/components/ComponentPalette/index.d.ts.map +0 -1
- package/dist/playground/components/ComponentPalette/index.js +0 -2
- package/dist/playground/components/ComponentPalette/index.js.map +0 -1
- package/dist/playground/components/DropZone/DropZone.d.ts +0 -17
- package/dist/playground/components/DropZone/DropZone.d.ts.map +0 -1
- package/dist/playground/components/DropZone/DropZone.js +0 -73
- package/dist/playground/components/DropZone/DropZone.js.map +0 -1
- package/dist/playground/components/DropZone/DropZone.module.css +0 -86
- package/dist/playground/components/ExportDialog/ExportDialog.d.ts +0 -10
- package/dist/playground/components/ExportDialog/ExportDialog.d.ts.map +0 -1
- package/dist/playground/components/ExportDialog/ExportDialog.js +0 -57
- package/dist/playground/components/ExportDialog/ExportDialog.js.map +0 -1
- package/dist/playground/components/ExportDialog/ExportDialog.module.css +0 -328
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts +0 -134
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.d.ts.map +0 -1
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.js +0 -254
- package/dist/playground/components/LayoutHelpers/LayoutHelpers.js.map +0 -1
- package/dist/playground/components/LayoutHelpers/index.d.ts +0 -3
- package/dist/playground/components/LayoutHelpers/index.d.ts.map +0 -1
- package/dist/playground/components/LayoutHelpers/index.js +0 -2
- package/dist/playground/components/LayoutHelpers/index.js.map +0 -1
- package/dist/playground/components/Playground/Playground.d.ts +0 -10
- package/dist/playground/components/Playground/Playground.d.ts.map +0 -1
- package/dist/playground/components/Playground/Playground.js +0 -128
- package/dist/playground/components/Playground/Playground.js.map +0 -1
- package/dist/playground/components/Playground/Playground.module.css +0 -308
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts +0 -10
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.d.ts.map +0 -1
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.js +0 -150
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.js.map +0 -1
- package/dist/playground/components/PropertiesPanel/PropertiesPanel.module.css +0 -155
- package/dist/playground/components/PropertiesPanel/index.d.ts +0 -3
- package/dist/playground/components/PropertiesPanel/index.d.ts.map +0 -1
- package/dist/playground/components/PropertiesPanel/index.js +0 -2
- package/dist/playground/components/PropertiesPanel/index.js.map +0 -1
- package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts +0 -12
- package/dist/playground/components/PropertyEditors/BooleanEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/BooleanEditor.js +0 -14
- package/dist/playground/components/PropertyEditors/BooleanEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/ColorEditor.d.ts +0 -12
- package/dist/playground/components/PropertyEditors/ColorEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/ColorEditor.js +0 -62
- package/dist/playground/components/PropertyEditors/ColorEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/IconEditor.d.ts +0 -12
- package/dist/playground/components/PropertyEditors/IconEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/IconEditor.js +0 -123
- package/dist/playground/components/PropertyEditors/IconEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/NumberEditor.d.ts +0 -15
- package/dist/playground/components/PropertyEditors/NumberEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/NumberEditor.js +0 -46
- package/dist/playground/components/PropertyEditors/NumberEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/PropertyEditors.module.css +0 -432
- package/dist/playground/components/PropertyEditors/SelectEditor.d.ts +0 -19
- package/dist/playground/components/PropertyEditors/SelectEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/SelectEditor.js +0 -17
- package/dist/playground/components/PropertyEditors/SelectEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts +0 -19
- package/dist/playground/components/PropertyEditors/SpacingEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/SpacingEditor.js +0 -162
- package/dist/playground/components/PropertyEditors/SpacingEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/SpacingEditor.module.css +0 -214
- package/dist/playground/components/PropertyEditors/TextEditor.d.ts +0 -14
- package/dist/playground/components/PropertyEditors/TextEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/TextEditor.js +0 -38
- package/dist/playground/components/PropertyEditors/TextEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/TokenEditor.d.ts +0 -23
- package/dist/playground/components/PropertyEditors/TokenEditor.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/TokenEditor.js +0 -50
- package/dist/playground/components/PropertyEditors/TokenEditor.js.map +0 -1
- package/dist/playground/components/PropertyEditors/index.d.ts +0 -20
- package/dist/playground/components/PropertyEditors/index.d.ts.map +0 -1
- package/dist/playground/components/PropertyEditors/index.js +0 -12
- package/dist/playground/components/PropertyEditors/index.js.map +0 -1
- package/dist/playground/components/TreeView/TreeView.d.ts +0 -10
- package/dist/playground/components/TreeView/TreeView.d.ts.map +0 -1
- package/dist/playground/components/TreeView/TreeView.js +0 -146
- package/dist/playground/components/TreeView/TreeView.js.map +0 -1
- package/dist/playground/components/TreeView/TreeView.module.css +0 -214
- package/dist/playground/components/TreeView/index.d.ts +0 -3
- package/dist/playground/components/TreeView/index.d.ts.map +0 -1
- package/dist/playground/components/TreeView/index.js +0 -2
- package/dist/playground/components/TreeView/index.js.map +0 -1
- package/dist/playground/config/propertyDefinitions.d.ts +0 -73
- package/dist/playground/config/propertyDefinitions.d.ts.map +0 -1
- package/dist/playground/config/propertyDefinitions.js +0 -809
- package/dist/playground/config/propertyDefinitions.js.map +0 -1
- package/dist/playground/hooks/useKeyboardShortcuts.d.ts +0 -38
- package/dist/playground/hooks/useKeyboardShortcuts.d.ts.map +0 -1
- package/dist/playground/hooks/useKeyboardShortcuts.js +0 -191
- package/dist/playground/hooks/useKeyboardShortcuts.js.map +0 -1
- package/dist/playground/index.d.ts +0 -21
- package/dist/playground/index.d.ts.map +0 -1
- package/dist/playground/index.js +0 -23
- package/dist/playground/index.js.map +0 -1
- package/dist/playground/services/CodeGenerator.d.ts +0 -73
- package/dist/playground/services/CodeGenerator.d.ts.map +0 -1
- package/dist/playground/services/CodeGenerator.js +0 -359
- package/dist/playground/services/CodeGenerator.js.map +0 -1
- package/dist/playground/services/DragDropManager.d.ts +0 -95
- package/dist/playground/services/DragDropManager.d.ts.map +0 -1
- package/dist/playground/services/DragDropManager.js +0 -408
- package/dist/playground/services/DragDropManager.js.map +0 -1
- package/dist/playground/services/StoryParser.d.ts +0 -73
- package/dist/playground/services/StoryParser.d.ts.map +0 -1
- package/dist/playground/services/StoryParser.js +0 -419
- package/dist/playground/services/StoryParser.js.map +0 -1
- package/dist/playground/store/playgroundStore.d.ts +0 -86
- package/dist/playground/store/playgroundStore.d.ts.map +0 -1
- package/dist/playground/store/playgroundStore.js +0 -337
- package/dist/playground/store/playgroundStore.js.map +0 -1
- package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts +0 -13
- package/dist/playground/stories/PlaygroundDragDrop.stories.d.ts.map +0 -1
- package/dist/playground/stories/PlaygroundDragDrop.stories.js +0 -227
- package/dist/playground/stories/PlaygroundDragDrop.stories.js.map +0 -1
- package/dist/playground/stories/PlaygroundPhase4.stories.d.ts +0 -13
- package/dist/playground/stories/PlaygroundPhase4.stories.d.ts.map +0 -1
- package/dist/playground/stories/PlaygroundPhase4.stories.js +0 -334
- package/dist/playground/stories/PlaygroundPhase4.stories.js.map +0 -1
- package/dist/playground/stories/PlaygroundPhase5.stories.d.ts +0 -14
- package/dist/playground/stories/PlaygroundPhase5.stories.d.ts.map +0 -1
- package/dist/playground/stories/PlaygroundPhase5.stories.js +0 -512
- package/dist/playground/stories/PlaygroundPhase5.stories.js.map +0 -1
- package/dist/playground/stories/PlaygroundProperties.stories.d.ts +0 -13
- package/dist/playground/stories/PlaygroundProperties.stories.d.ts.map +0 -1
- package/dist/playground/stories/PlaygroundProperties.stories.js +0 -342
- package/dist/playground/stories/PlaygroundProperties.stories.js.map +0 -1
- package/dist/playground/types/index.d.ts +0 -251
- package/dist/playground/types/index.d.ts.map +0 -1
- package/dist/playground/types/index.js +0 -5
- package/dist/playground/types/index.js.map +0 -1
- package/dist/scripts/verify-framework-adapters.js +0 -105
- package/dist/story-generator/componentBlacklist.js.map +0 -1
- package/dist/story-generator/componentDiscovery.js.map +0 -1
- package/dist/story-generator/configLoader.js.map +0 -1
- package/dist/story-generator/considerationsLoader.js.map +0 -1
- package/dist/story-generator/documentation-sources.js.map +0 -1
- package/dist/story-generator/documentationLoader.js.map +0 -1
- package/dist/story-generator/dynamicPackageDiscovery.js.map +0 -1
- package/dist/story-generator/enhancedComponentDiscovery.js.map +0 -1
- package/dist/story-generator/generateStory.js.map +0 -1
- package/dist/story-generator/gitignoreManager.js.map +0 -1
- package/dist/story-generator/inMemoryStoryService.js.map +0 -1
- package/dist/story-generator/logger.js.map +0 -1
- package/dist/story-generator/postProcessStory.js.map +0 -1
- package/dist/story-generator/productionGitignoreManager.js.map +0 -1
- package/dist/story-generator/promptGenerator.js.map +0 -1
- package/dist/story-generator/providerPresets.d.ts +0 -54
- package/dist/story-generator/providerPresets.d.ts.map +0 -1
- package/dist/story-generator/providerPresets.js +0 -214
- package/dist/story-generator/storyHistory.js.map +0 -1
- package/dist/story-generator/storySync.js.map +0 -1
- package/dist/story-generator/storyTracker.js.map +0 -1
- package/dist/story-generator/storyValidator.js.map +0 -1
- package/dist/story-generator/test_validation.d.ts +0 -2
- package/dist/story-generator/test_validation.d.ts.map +0 -1
- package/dist/story-generator/test_validation.js +0 -51
- package/dist/story-generator/universalDesignSystemAdapter.js.map +0 -1
- package/dist/story-generator/urlRedirectService.js.map +0 -1
- package/dist/story-generator/validateStory.js.map +0 -1
- package/dist/story-ui.config.js.map +0 -1
- package/dist/story-ui.config.loader.d.ts +0 -36
- package/dist/story-ui.config.loader.d.ts.map +0 -1
- package/dist/story-ui.config.loader.js +0 -205
- package/dist/story-ui.config.loader.js.map +0 -1
- package/dist/temp/package/templates/StoryUI/StoryUIPanel.js +0 -807
- package/dist/temp/package/templates/StoryUI/StoryUIPanel.stories.js +0 -37
- package/dist/temp/package/templates/StoryUI/index.js +0 -2
- package/dist/templates/StoryUI/StoryUIPanel.js.map +0 -1
- package/dist/templates/StoryUI/StoryUIPanel.stories.js.map +0 -1
- package/dist/templates/StoryUI/index.js.map +0 -1
- package/dist/templates/StoryUI/manager.d.ts +0 -14
- package/dist/templates/StoryUI/manager.d.ts.map +0 -1
- package/dist/templates/production-app/src/App.d.ts +0 -10
- package/dist/templates/production-app/src/App.d.ts.map +0 -1
- package/dist/templates/production-app/src/App.js +0 -653
- package/dist/templates/production-app/src/LivePreviewRenderer.d.ts +0 -24
- package/dist/templates/production-app/src/LivePreviewRenderer.d.ts.map +0 -1
- package/dist/templates/production-app/src/LivePreviewRenderer.js +0 -199
- package/dist/templates/production-app/src/componentRegistry.d.ts +0 -20
- package/dist/templates/production-app/src/componentRegistry.d.ts.map +0 -1
- package/dist/templates/production-app/src/componentRegistry.js +0 -316
- package/dist/templates/production-app/src/main.d.ts +0 -9
- package/dist/templates/production-app/src/main.d.ts.map +0 -1
- package/dist/templates/production-app/src/main.js +0 -18
- package/dist/templates/production-app/vite.config.d.ts +0 -3
- package/dist/templates/production-app/vite.config.d.ts.map +0 -1
- package/dist/templates/production-app/vite.config.js +0 -71
- package/dist/test-storybooks/angular-material-storybook/src/main.js +0 -66
- package/dist/test-storybooks/chakra-storybook/vite.config.js +0 -6
- package/dist/test-storybooks/mantine-storybook/vite.config.js +0 -93
- package/dist/test-storybooks/web-components-shoelace/vite.config.js +0 -9
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/visual-builder/components/Canvas/Canvas.js +0 -70
- package/dist/visual-builder/components/Canvas/ComponentRenderer.js +0 -545
- package/dist/visual-builder/components/CodeExporter/CodeExporter.js +0 -25
- package/dist/visual-builder/components/CodeExporter/codeGenerator.js +0 -99
- package/dist/visual-builder/components/ComponentPalette/ComponentPalette.js +0 -8
- package/dist/visual-builder/components/ComponentPalette/ComponentPaletteItem.js +0 -51
- package/dist/visual-builder/components/EmbeddedVisualBuilder.js +0 -107
- package/dist/visual-builder/components/PropertyEditor/PropertyEditor.js +0 -16
- package/dist/visual-builder/components/PropertyEditor/PropertyForm.js +0 -88
- package/dist/visual-builder/components/PropertyEditor/SpacingControl.js +0 -145
- package/dist/visual-builder/components/PropertyEditor/SpacingEditor.js +0 -32
- package/dist/visual-builder/components/StoryManager/SaveOnlyManager.js +0 -94
- package/dist/visual-builder/components/StoryManager/StoryManager.js +0 -68
- package/dist/visual-builder/components/StoryManager/index.js +0 -1
- package/dist/visual-builder/components/VisualBuilder.js +0 -256
- package/dist/visual-builder/config/componentRegistry.js +0 -1758
- package/dist/visual-builder/decorators/VisualBuilderDecorator.js +0 -184
- package/dist/visual-builder/example-integration.js +0 -59
- package/dist/visual-builder/example.js +0 -23
- package/dist/visual-builder/hooks/useDragAndDrop.js +0 -137
- package/dist/visual-builder/hooks/useSelection.js +0 -27
- package/dist/visual-builder/index.js +0 -7
- package/dist/visual-builder/store/visualBuilderStore.js +0 -305
- package/dist/visual-builder/types/index.js +0 -1
- package/dist/visual-builder/utils/__tests__/storyFileUpdater.test.js +0 -145
- package/dist/visual-builder/utils/aiParser.js +0 -336
- package/dist/visual-builder/utils/componentTreeUtils.js +0 -111
- package/dist/visual-builder/utils/parserValidation.js +0 -122
- package/dist/visual-builder/utils/storyFileManager.js +0 -73
- package/dist/visual-builder/utils/storyFileUpdater.js +0 -326
- package/dist/visual-builder/utils/storyNameExtraction.test.js +0 -211
- package/dist/visual-builder/utils/storyPersistence.js +0 -180
- package/dist/visual-builder/utils/storyToBuilder.js +0 -813
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
const STORAGE_KEY = 'visual-builder-stories';
|
|
2
|
-
/**
|
|
3
|
-
* Get all saved stories from localStorage
|
|
4
|
-
*/
|
|
5
|
-
export function getSavedStories() {
|
|
6
|
-
try {
|
|
7
|
-
const stored = localStorage.getItem(STORAGE_KEY);
|
|
8
|
-
return stored ? JSON.parse(stored) : [];
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
console.error('Failed to load saved stories:', error);
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Save a story to localStorage
|
|
17
|
-
*/
|
|
18
|
-
export function saveStory(name, components, existingId) {
|
|
19
|
-
const stories = getSavedStories();
|
|
20
|
-
const now = new Date().toISOString();
|
|
21
|
-
if (existingId) {
|
|
22
|
-
// Update existing story
|
|
23
|
-
const existingIndex = stories.findIndex(story => story.id === existingId);
|
|
24
|
-
if (existingIndex >= 0) {
|
|
25
|
-
const updatedStory = {
|
|
26
|
-
...stories[existingIndex],
|
|
27
|
-
name,
|
|
28
|
-
components,
|
|
29
|
-
updatedAt: now
|
|
30
|
-
};
|
|
31
|
-
stories[existingIndex] = updatedStory;
|
|
32
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(stories));
|
|
33
|
-
return updatedStory;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// Create new story
|
|
37
|
-
const newStory = {
|
|
38
|
-
id: `story-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
39
|
-
name,
|
|
40
|
-
components,
|
|
41
|
-
createdAt: now,
|
|
42
|
-
updatedAt: now
|
|
43
|
-
};
|
|
44
|
-
stories.push(newStory);
|
|
45
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(stories));
|
|
46
|
-
return newStory;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Load a story by ID
|
|
50
|
-
*/
|
|
51
|
-
export function loadStory(id) {
|
|
52
|
-
const stories = getSavedStories();
|
|
53
|
-
return stories.find(story => story.id === id) || null;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Delete a story by ID
|
|
57
|
-
*/
|
|
58
|
-
export function deleteStory(id) {
|
|
59
|
-
try {
|
|
60
|
-
const stories = getSavedStories();
|
|
61
|
-
const filteredStories = stories.filter(story => story.id !== id);
|
|
62
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(filteredStories));
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
console.error('Failed to delete story:', error);
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Generate a URL with story parameters
|
|
72
|
-
*/
|
|
73
|
-
export function generateStoryURL(storyId, baseURL) {
|
|
74
|
-
const url = new URL(baseURL || window.location.href);
|
|
75
|
-
url.searchParams.set('story', storyId);
|
|
76
|
-
return url.toString();
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Get story ID from URL parameters
|
|
80
|
-
*/
|
|
81
|
-
export function getStoryIdFromURL() {
|
|
82
|
-
const params = new URLSearchParams(window.location.search);
|
|
83
|
-
return params.get('story');
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Auto-save functionality
|
|
87
|
-
*/
|
|
88
|
-
let autoSaveTimer = null;
|
|
89
|
-
export function scheduleAutoSave(name, components, storyId, delay = 2000) {
|
|
90
|
-
// Clear existing timer
|
|
91
|
-
if (autoSaveTimer) {
|
|
92
|
-
clearTimeout(autoSaveTimer);
|
|
93
|
-
}
|
|
94
|
-
// Schedule new save
|
|
95
|
-
autoSaveTimer = setTimeout(() => {
|
|
96
|
-
try {
|
|
97
|
-
saveStory(name, components, storyId);
|
|
98
|
-
console.debug('Auto-saved story:', name);
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
console.error('Auto-save failed:', error);
|
|
102
|
-
}
|
|
103
|
-
}, delay);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Cancel scheduled auto-save
|
|
107
|
-
*/
|
|
108
|
-
export function cancelAutoSave() {
|
|
109
|
-
if (autoSaveTimer) {
|
|
110
|
-
clearTimeout(autoSaveTimer);
|
|
111
|
-
autoSaveTimer = null;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Save draft to localStorage (for recovery on refresh)
|
|
116
|
-
*/
|
|
117
|
-
export function saveDraft(storyId, components, isImportedFromStory = false, storyName, sourceFile) {
|
|
118
|
-
const draftKey = `visual-builder-draft-${storyId}`;
|
|
119
|
-
const draft = {
|
|
120
|
-
components,
|
|
121
|
-
timestamp: Date.now(),
|
|
122
|
-
storyId,
|
|
123
|
-
isImportedFromStory,
|
|
124
|
-
storyName,
|
|
125
|
-
sourceFile
|
|
126
|
-
};
|
|
127
|
-
try {
|
|
128
|
-
localStorage.setItem(draftKey, JSON.stringify(draft));
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
console.error('Failed to save draft:', error);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Restore draft from localStorage
|
|
136
|
-
*/
|
|
137
|
-
export function restoreDraft(storyId) {
|
|
138
|
-
const draftKey = `visual-builder-draft-${storyId}`;
|
|
139
|
-
try {
|
|
140
|
-
const stored = localStorage.getItem(draftKey);
|
|
141
|
-
if (stored) {
|
|
142
|
-
const draft = JSON.parse(stored);
|
|
143
|
-
// Check if draft is recent (within last 24 hours)
|
|
144
|
-
const ageInHours = (Date.now() - draft.timestamp) / (1000 * 60 * 60);
|
|
145
|
-
if (ageInHours < 24) {
|
|
146
|
-
return {
|
|
147
|
-
components: draft.components,
|
|
148
|
-
isImportedFromStory: draft.isImportedFromStory || false,
|
|
149
|
-
storyName: draft.storyName,
|
|
150
|
-
sourceFile: draft.sourceFile
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
// Clean up old draft
|
|
154
|
-
localStorage.removeItem(draftKey);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
catch (error) {
|
|
158
|
-
console.error('Failed to restore draft:', error);
|
|
159
|
-
}
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Clear draft from localStorage
|
|
164
|
-
*/
|
|
165
|
-
export function clearDraft(storyId) {
|
|
166
|
-
const draftKey = `visual-builder-draft-${storyId}`;
|
|
167
|
-
try {
|
|
168
|
-
localStorage.removeItem(draftKey);
|
|
169
|
-
}
|
|
170
|
-
catch (error) {
|
|
171
|
-
console.error('Failed to clear draft:', error);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Get Visual Builder edit URL
|
|
176
|
-
*/
|
|
177
|
-
export function getVisualBuilderEditURL(storyId) {
|
|
178
|
-
const baseURL = window.location.origin + window.location.pathname;
|
|
179
|
-
return `${baseURL}?path=/visual-builder&edit=${storyId}`;
|
|
180
|
-
}
|