@dfosco/storyboard 0.5.0-alpha.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.
- package/commandpalette.config.json +152 -0
- package/dist/storyboard-ui.css +1 -0
- package/dist/storyboard-ui.js +21328 -0
- package/dist/storyboard-ui.js.map +1 -0
- package/dist/tailwind.css +2 -0
- package/dist/tiny-canvas.css +1 -0
- package/dist/tiny-canvas.js +389 -0
- package/package.json +121 -0
- package/paste.config.json +67 -0
- package/scaffold/AGENTS.md +432 -0
- package/scaffold/agents/prompt-agent.agent.md +181 -0
- package/scaffold/agents/terminal-agent.agent.md +351 -0
- package/scaffold/codex/config.toml +246 -0
- package/scaffold/deploy.yml +103 -0
- package/scaffold/githooks/pre-push +114 -0
- package/scaffold/gitignore +64 -0
- package/scaffold/manifest.json +56 -0
- package/scaffold/preview.yml +181 -0
- package/scaffold/scripts/link.sh +26 -0
- package/scaffold/scripts/unlink.sh +10 -0
- package/scaffold/skills/agent-browser/SKILL.md +260 -0
- package/scaffold/skills/canvas/SKILL.md +364 -0
- package/scaffold/skills/create/SKILL.md +501 -0
- package/scaffold/skills/ship/SKILL.md +237 -0
- package/scaffold/skills/storyboard/SKILL.md +360 -0
- package/scaffold/skills/update-storyboard/SKILL.md +16 -0
- package/scaffold/skills/update-storyboard/update-storyboard-packages.sh +26 -0
- package/scaffold/skills/vitest/GENERATION.md +5 -0
- package/scaffold/skills/vitest/SKILL.md +52 -0
- package/scaffold/skills/vitest/references/advanced-environments.md +264 -0
- package/scaffold/skills/vitest/references/advanced-projects.md +300 -0
- package/scaffold/skills/vitest/references/advanced-type-testing.md +237 -0
- package/scaffold/skills/vitest/references/advanced-vi.md +249 -0
- package/scaffold/skills/vitest/references/core-cli.md +166 -0
- package/scaffold/skills/vitest/references/core-config.md +174 -0
- package/scaffold/skills/vitest/references/core-describe.md +193 -0
- package/scaffold/skills/vitest/references/core-expect.md +219 -0
- package/scaffold/skills/vitest/references/core-hooks.md +244 -0
- package/scaffold/skills/vitest/references/core-test-api.md +233 -0
- package/scaffold/skills/vitest/references/features-concurrency.md +250 -0
- package/scaffold/skills/vitest/references/features-context.md +238 -0
- package/scaffold/skills/vitest/references/features-coverage.md +207 -0
- package/scaffold/skills/vitest/references/features-filtering.md +211 -0
- package/scaffold/skills/vitest/references/features-mocking.md +265 -0
- package/scaffold/skills/vitest/references/features-snapshots.md +207 -0
- package/scaffold/skills/worktree/SKILL.md +93 -0
- package/scaffold/storyboard.config.json +44 -0
- package/src/canvas/Canvas.jsx +78 -0
- package/src/canvas/Draggable.jsx +235 -0
- package/src/canvas/index.d.ts +41 -0
- package/src/canvas/index.js +6 -0
- package/src/canvas/style.css +118 -0
- package/src/canvas/useResetCanvas.js +17 -0
- package/src/canvas/utils.js +136 -0
- package/src/core/assets/fonts/IoskeleyMono-Bold.woff2 +0 -0
- package/src/core/assets/fonts/IoskeleyMono-Italic.woff2 +0 -0
- package/src/core/assets/fonts/IoskeleyMono-Medium.woff2 +0 -0
- package/src/core/assets/fonts/IoskeleyMono-Regular.woff2 +0 -0
- package/src/core/assets/fonts/IoskeleyMono-SemiBold.woff2 +0 -0
- package/src/core/autosync/server.js +714 -0
- package/src/core/autosync/server.test.js +158 -0
- package/src/core/canvas/__tests__/agent-integration.test.js +596 -0
- package/src/core/canvas/__tests__/helpers/browser.js +95 -0
- package/src/core/canvas/__tests__/helpers/canvas-api.js +129 -0
- package/src/core/canvas/__tests__/helpers/perf.js +118 -0
- package/src/core/canvas/__tests__/helpers/setup.js +176 -0
- package/src/core/canvas/__tests__/helpers/tmux.js +130 -0
- package/src/core/canvas/__tests__/helpers/transcript.js +132 -0
- package/src/core/canvas/__tests__/terminal-integration.test.js +177 -0
- package/src/core/canvas/collision.js +292 -0
- package/src/core/canvas/collision.test.js +371 -0
- package/src/core/canvas/compact.js +83 -0
- package/src/core/canvas/deriveCanvasId.test.js +40 -0
- package/src/core/canvas/githubEmbeds.js +527 -0
- package/src/core/canvas/githubEmbeds.test.js +302 -0
- package/src/core/canvas/hot-pool.js +766 -0
- package/src/core/canvas/identity.js +107 -0
- package/src/core/canvas/identity.test.js +100 -0
- package/src/core/canvas/materializer.js +259 -0
- package/src/core/canvas/materializer.test.js +356 -0
- package/src/core/canvas/selectedWidgets.js +270 -0
- package/src/core/canvas/selectedWidgets.test.js +321 -0
- package/src/core/canvas/server.js +3134 -0
- package/src/core/canvas/server.test.js +379 -0
- package/src/core/canvas/terminal-config.js +330 -0
- package/src/core/canvas/terminal-registry.js +465 -0
- package/src/core/canvas/terminal-server.js +1436 -0
- package/src/core/canvas/writeGuard.js +53 -0
- package/src/core/cli/agent.js +85 -0
- package/src/core/cli/branch.js +386 -0
- package/src/core/cli/canvasAdd.js +241 -0
- package/src/core/cli/canvasBatch.js +98 -0
- package/src/core/cli/canvasBounds.js +160 -0
- package/src/core/cli/canvasRead.js +236 -0
- package/src/core/cli/canvasUpdate.js +179 -0
- package/src/core/cli/code.js +67 -0
- package/src/core/cli/compact.js +62 -0
- package/src/core/cli/create.js +674 -0
- package/src/core/cli/dev-helpers.js +53 -0
- package/src/core/cli/dev-helpers.test.js +53 -0
- package/src/core/cli/dev.js +430 -0
- package/src/core/cli/exit.js +38 -0
- package/src/core/cli/flags.js +174 -0
- package/src/core/cli/flags.test.js +155 -0
- package/src/core/cli/index.js +233 -0
- package/src/core/cli/intro.js +37 -0
- package/src/core/cli/proxy.js +319 -0
- package/src/core/cli/proxy.test.js +63 -0
- package/src/core/cli/schemas.js +223 -0
- package/src/core/cli/server.js +192 -0
- package/src/core/cli/serverUrl.js +61 -0
- package/src/core/cli/sessions.js +459 -0
- package/src/core/cli/setup.js +404 -0
- package/src/core/cli/terminal-commands.js +287 -0
- package/src/core/cli/terminal-messaging.js +231 -0
- package/src/core/cli/terminal-welcome.js +515 -0
- package/src/core/cli/updateVersion.js +124 -0
- package/src/core/comments/api.js +284 -0
- package/src/core/comments/api.test.js +282 -0
- package/src/core/comments/auth.js +151 -0
- package/src/core/comments/auth.test.js +167 -0
- package/src/core/comments/commentCache.js +109 -0
- package/src/core/comments/commentCache.test.js +48 -0
- package/src/core/comments/commentDrafts.js +68 -0
- package/src/core/comments/commentMode.js +63 -0
- package/src/core/comments/commentMode.test.js +90 -0
- package/src/core/comments/config.js +47 -0
- package/src/core/comments/config.test.js +77 -0
- package/src/core/comments/graphql.js +65 -0
- package/src/core/comments/graphql.test.js +95 -0
- package/src/core/comments/index.js +42 -0
- package/src/core/comments/metadata.js +52 -0
- package/src/core/comments/metadata.test.js +110 -0
- package/src/core/comments/queries.js +245 -0
- package/src/core/comments/ui/AuthModal.jsx +114 -0
- package/src/core/comments/ui/CommentOverlay.js +52 -0
- package/src/core/comments/ui/CommentWindow.jsx +329 -0
- package/src/core/comments/ui/CommentsDrawer.jsx +102 -0
- package/src/core/comments/ui/Composer.jsx +64 -0
- package/src/core/comments/ui/authModal.js +66 -0
- package/src/core/comments/ui/authModal.test.js +76 -0
- package/src/core/comments/ui/comment-cursor-dark.svg +1 -0
- package/src/core/comments/ui/comment-cursor.svg +1 -0
- package/src/core/comments/ui/comment-layout.css +142 -0
- package/src/core/comments/ui/commentWindow.js +121 -0
- package/src/core/comments/ui/comments.css +242 -0
- package/src/core/comments/ui/commentsDrawer.js +84 -0
- package/src/core/comments/ui/composer.js +136 -0
- package/src/core/comments/ui/index.js +14 -0
- package/src/core/comments/ui/mount.js +687 -0
- package/src/core/comments/ui/mount.test.js +336 -0
- package/src/core/data/dotPath.js +53 -0
- package/src/core/data/dotPath.test.js +114 -0
- package/src/core/data/loader.js +409 -0
- package/src/core/data/loader.test.js +599 -0
- package/src/core/data/viewfinder.js +363 -0
- package/src/core/data/viewfinder.test.js +456 -0
- package/src/core/devtools/devtools-consumer.js +28 -0
- package/src/core/devtools/devtools.js +144 -0
- package/src/core/devtools/devtools.test.js +75 -0
- package/src/core/devtools/sceneDebug.js +112 -0
- package/src/core/devtools/sceneDebug.test.js +141 -0
- package/src/core/index.js +124 -0
- package/src/core/inspector/fiberWalker.js +239 -0
- package/src/core/inspector/highlighter.js +275 -0
- package/src/core/inspector/mouseMode.js +259 -0
- package/src/core/lib/components/ui/alert/alert-action.jsx +11 -0
- package/src/core/lib/components/ui/alert/alert-description.jsx +11 -0
- package/src/core/lib/components/ui/alert/alert-title.jsx +11 -0
- package/src/core/lib/components/ui/alert/alert.jsx +25 -0
- package/src/core/lib/components/ui/alert/index.js +17 -0
- package/src/core/lib/components/ui/avatar/avatar-badge.jsx +22 -0
- package/src/core/lib/components/ui/avatar/avatar-fallback.jsx +18 -0
- package/src/core/lib/components/ui/avatar/avatar-group-count.jsx +19 -0
- package/src/core/lib/components/ui/avatar/avatar-group.jsx +19 -0
- package/src/core/lib/components/ui/avatar/avatar-image.jsx +15 -0
- package/src/core/lib/components/ui/avatar/avatar.jsx +19 -0
- package/src/core/lib/components/ui/avatar/index.js +22 -0
- package/src/core/lib/components/ui/badge/badge.jsx +31 -0
- package/src/core/lib/components/ui/badge/index.js +2 -0
- package/src/core/lib/components/ui/button/button.jsx +100 -0
- package/src/core/lib/components/ui/button/index.js +12 -0
- package/src/core/lib/components/ui/card/card-action.jsx +11 -0
- package/src/core/lib/components/ui/card/card-content.jsx +11 -0
- package/src/core/lib/components/ui/card/card-description.jsx +11 -0
- package/src/core/lib/components/ui/card/card-footer.jsx +11 -0
- package/src/core/lib/components/ui/card/card-header.jsx +19 -0
- package/src/core/lib/components/ui/card/card-title.jsx +11 -0
- package/src/core/lib/components/ui/card/card.jsx +17 -0
- package/src/core/lib/components/ui/card/index.js +25 -0
- package/src/core/lib/components/ui/checkbox/checkbox.jsx +29 -0
- package/src/core/lib/components/ui/checkbox/index.js +6 -0
- package/src/core/lib/components/ui/collapsible/collapsible-content.jsx +7 -0
- package/src/core/lib/components/ui/collapsible/collapsible-trigger.jsx +7 -0
- package/src/core/lib/components/ui/collapsible/collapsible.jsx +7 -0
- package/src/core/lib/components/ui/collapsible/index.js +13 -0
- package/src/core/lib/components/ui/dialog/dialog-close.jsx +7 -0
- package/src/core/lib/components/ui/dialog/dialog-content.jsx +34 -0
- package/src/core/lib/components/ui/dialog/dialog-description.jsx +15 -0
- package/src/core/lib/components/ui/dialog/dialog-footer.jsx +23 -0
- package/src/core/lib/components/ui/dialog/dialog-header.jsx +11 -0
- package/src/core/lib/components/ui/dialog/dialog-overlay.jsx +15 -0
- package/src/core/lib/components/ui/dialog/dialog-portal.jsx +4 -0
- package/src/core/lib/components/ui/dialog/dialog-title.jsx +15 -0
- package/src/core/lib/components/ui/dialog/dialog-trigger.jsx +7 -0
- package/src/core/lib/components/ui/dialog/dialog.jsx +4 -0
- package/src/core/lib/components/ui/dialog/index.js +34 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-checkbox-group.jsx +8 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-checkbox-item.jsx +30 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-content.jsx +22 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-group-heading.jsx +16 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-group.jsx +7 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-item.jsx +20 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-label.jsx +17 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-portal.jsx +4 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-radio-group.jsx +7 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-radio-item.jsx +29 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-separator.jsx +15 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-shortcut.jsx +16 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-sub-content.jsx +15 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-sub-trigger.jsx +23 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-sub.jsx +4 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu-trigger.jsx +7 -0
- package/src/core/lib/components/ui/dropdown-menu/dropdown-menu.jsx +4 -0
- package/src/core/lib/components/ui/dropdown-menu/index.js +54 -0
- package/src/core/lib/components/ui/input/index.js +7 -0
- package/src/core/lib/components/ui/input/input.jsx +19 -0
- package/src/core/lib/components/ui/label/index.js +7 -0
- package/src/core/lib/components/ui/label/label.jsx +19 -0
- package/src/core/lib/components/ui/panel/index.js +24 -0
- package/src/core/lib/components/ui/panel/panel-body.jsx +11 -0
- package/src/core/lib/components/ui/panel/panel-close.jsx +16 -0
- package/src/core/lib/components/ui/panel/panel-content.jsx +29 -0
- package/src/core/lib/components/ui/panel/panel-footer.jsx +11 -0
- package/src/core/lib/components/ui/panel/panel-header.jsx +11 -0
- package/src/core/lib/components/ui/panel/panel-title.jsx +12 -0
- package/src/core/lib/components/ui/panel/panel.jsx +4 -0
- package/src/core/lib/components/ui/popover/index.js +28 -0
- package/src/core/lib/components/ui/popover/popover-close.jsx +7 -0
- package/src/core/lib/components/ui/popover/popover-content.jsx +22 -0
- package/src/core/lib/components/ui/popover/popover-description.jsx +11 -0
- package/src/core/lib/components/ui/popover/popover-header.jsx +11 -0
- package/src/core/lib/components/ui/popover/popover-portal.jsx +4 -0
- package/src/core/lib/components/ui/popover/popover-title.jsx +11 -0
- package/src/core/lib/components/ui/popover/popover-trigger.jsx +8 -0
- package/src/core/lib/components/ui/popover/popover.jsx +4 -0
- package/src/core/lib/components/ui/searchable-list.jsx +160 -0
- package/src/core/lib/components/ui/select/index.js +37 -0
- package/src/core/lib/components/ui/select/select-content.jsx +30 -0
- package/src/core/lib/components/ui/select/select-group-heading.jsx +17 -0
- package/src/core/lib/components/ui/select/select-group.jsx +15 -0
- package/src/core/lib/components/ui/select/select-item.jsx +26 -0
- package/src/core/lib/components/ui/select/select-label.jsx +11 -0
- package/src/core/lib/components/ui/select/select-portal.jsx +4 -0
- package/src/core/lib/components/ui/select/select-scroll-down-button.jsx +18 -0
- package/src/core/lib/components/ui/select/select-scroll-up-button.jsx +18 -0
- package/src/core/lib/components/ui/select/select-separator.jsx +15 -0
- package/src/core/lib/components/ui/select/select-trigger.jsx +25 -0
- package/src/core/lib/components/ui/select/select.jsx +4 -0
- package/src/core/lib/components/ui/separator/index.js +7 -0
- package/src/core/lib/components/ui/separator/separator.jsx +22 -0
- package/src/core/lib/components/ui/sheet/index.js +34 -0
- package/src/core/lib/components/ui/sheet/sheet-close.jsx +7 -0
- package/src/core/lib/components/ui/sheet/sheet-content.jsx +35 -0
- package/src/core/lib/components/ui/sheet/sheet-description.jsx +15 -0
- package/src/core/lib/components/ui/sheet/sheet-footer.jsx +11 -0
- package/src/core/lib/components/ui/sheet/sheet-header.jsx +11 -0
- package/src/core/lib/components/ui/sheet/sheet-overlay.jsx +15 -0
- package/src/core/lib/components/ui/sheet/sheet-portal.jsx +4 -0
- package/src/core/lib/components/ui/sheet/sheet-title.jsx +15 -0
- package/src/core/lib/components/ui/sheet/sheet-trigger.jsx +7 -0
- package/src/core/lib/components/ui/sheet/sheet.jsx +4 -0
- package/src/core/lib/components/ui/textarea/index.js +7 -0
- package/src/core/lib/components/ui/textarea/textarea.jsx +18 -0
- package/src/core/lib/components/ui/toggle/index.js +8 -0
- package/src/core/lib/components/ui/toggle/toggle.jsx +36 -0
- package/src/core/lib/components/ui/toggle-group/index.js +10 -0
- package/src/core/lib/components/ui/toggle-group/toggle-group-item.jsx +29 -0
- package/src/core/lib/components/ui/toggle-group/toggle-group.jsx +43 -0
- package/src/core/lib/components/ui/tooltip/index.js +3 -0
- package/src/core/lib/components/ui/tooltip/tooltip-content.jsx +21 -0
- package/src/core/lib/components/ui/tooltip/tooltip-trigger.jsx +23 -0
- package/src/core/lib/components/ui/tooltip/tooltip.jsx +11 -0
- package/src/core/lib/components/ui/trigger-button/index.js +6 -0
- package/src/core/lib/components/ui/trigger-button/trigger-button.css +38 -0
- package/src/core/lib/components/ui/trigger-button/trigger-button.jsx +63 -0
- package/src/core/lib/utils/index.js +6 -0
- package/src/core/logger/devLogger.js +238 -0
- package/src/core/logger/devLogger.test.js +193 -0
- package/src/core/modes/modes.css +98 -0
- package/src/core/modes/modes.js +492 -0
- package/src/core/modes/modes.test.js +562 -0
- package/src/core/mountStoryboardCore.js +478 -0
- package/src/core/rename-watcher/config.json +23 -0
- package/src/core/rename-watcher/watcher.js +531 -0
- package/src/core/scaffold.js +100 -0
- package/src/core/server/index.js +391 -0
- package/src/core/session/bodyClasses.js +128 -0
- package/src/core/session/bodyClasses.test.js +192 -0
- package/src/core/session/hashSubscribe.js +19 -0
- package/src/core/session/hashSubscribe.test.js +62 -0
- package/src/core/session/hideMode.js +424 -0
- package/src/core/session/hideMode.test.js +268 -0
- package/src/core/session/interceptHideParams.js +35 -0
- package/src/core/session/interceptHideParams.test.js +90 -0
- package/src/core/session/localStorage.js +134 -0
- package/src/core/session/localStorage.test.js +148 -0
- package/src/core/session/session.js +76 -0
- package/src/core/session/session.test.js +91 -0
- package/src/core/stores/canvasConfig.js +134 -0
- package/src/core/stores/canvasConfig.test.js +120 -0
- package/src/core/stores/commandActions.js +284 -0
- package/src/core/stores/commandPaletteConfig.js +31 -0
- package/src/core/stores/configSchema.js +232 -0
- package/src/core/stores/configSchema.test.js +72 -0
- package/src/core/stores/configStore.js +161 -0
- package/src/core/stores/customerModeConfig.js +30 -0
- package/src/core/stores/featureFlags.js +127 -0
- package/src/core/stores/paletteProviders.js +360 -0
- package/src/core/stores/paletteProviders.test.js +186 -0
- package/src/core/stores/plugins.js +40 -0
- package/src/core/stores/plugins.test.js +68 -0
- package/src/core/stores/recentArtifacts.js +68 -0
- package/src/core/stores/recentArtifacts.test.js +71 -0
- package/src/core/stores/sidePanelStore.ts +143 -0
- package/src/core/stores/themeStore.ts +291 -0
- package/src/core/stores/toolRegistry.js +227 -0
- package/src/core/stores/toolStateStore.js +183 -0
- package/src/core/stores/toolStateStore.test.js +220 -0
- package/src/core/stores/toolbarConfigStore.js +165 -0
- package/src/core/stores/uiConfig.js +64 -0
- package/src/core/stores/uiConfig.test.js +63 -0
- package/src/core/styles/tailwind.css +204 -0
- package/src/core/tools/handlers/autosync.js +12 -0
- package/src/core/tools/handlers/canvasAddWidget.js +11 -0
- package/src/core/tools/handlers/canvasAgents.js +20 -0
- package/src/core/tools/handlers/canvasToolbar.js +56 -0
- package/src/core/tools/handlers/commandPalette.js +9 -0
- package/src/core/tools/handlers/comments.js +16 -0
- package/src/core/tools/handlers/create.js +39 -0
- package/src/core/tools/handlers/devtools.js +122 -0
- package/src/core/tools/handlers/devtools.test.js +87 -0
- package/src/core/tools/handlers/featureFlags.js +21 -0
- package/src/core/tools/handlers/flows.js +68 -0
- package/src/core/tools/handlers/hideChrome.js +9 -0
- package/src/core/tools/handlers/hideToolbars.js +25 -0
- package/src/core/tools/handlers/inspector.js +19 -0
- package/src/core/tools/handlers/paletteTheme.js +35 -0
- package/src/core/tools/handlers/theme.js +9 -0
- package/src/core/tools/registry.js +26 -0
- package/src/core/tools/surfaces/canvasToolbar.js +10 -0
- package/src/core/tools/surfaces/commandList.js +10 -0
- package/src/core/tools/surfaces/mainToolbar.js +11 -0
- package/src/core/tools/surfaces/registry.js +19 -0
- package/src/core/ui/ActionMenuButton.jsx +114 -0
- package/src/core/ui/AutosyncMenuButton.css +67 -0
- package/src/core/ui/AutosyncMenuButton.jsx +242 -0
- package/src/core/ui/BranchSelect.jsx +29 -0
- package/src/core/ui/BranchSelect.module.css +30 -0
- package/src/core/ui/CanvasAgentsMenu.jsx +89 -0
- package/src/core/ui/CanvasCreateMenu.jsx +611 -0
- package/src/core/ui/CanvasSnap.css +27 -0
- package/src/core/ui/CanvasSnap.jsx +51 -0
- package/src/core/ui/CanvasUndoRedo.css +36 -0
- package/src/core/ui/CanvasUndoRedo.jsx +62 -0
- package/src/core/ui/CanvasZoomControl.css +53 -0
- package/src/core/ui/CanvasZoomControl.jsx +49 -0
- package/src/core/ui/CanvasZoomToFit.css +18 -0
- package/src/core/ui/CanvasZoomToFit.jsx +26 -0
- package/src/core/ui/CommandMenu.css +8 -0
- package/src/core/ui/CommandMenu.jsx +287 -0
- package/src/core/ui/CommandPalette.jsx +35 -0
- package/src/core/ui/CommandPaletteTrigger.jsx +25 -0
- package/src/core/ui/CommentsMenuButton.jsx +40 -0
- package/src/core/ui/CoreUIBar.css +47 -0
- package/src/core/ui/CoreUIBar.jsx +905 -0
- package/src/core/ui/CreateMenuButton.jsx +117 -0
- package/src/core/ui/HideChromeTrigger.jsx +48 -0
- package/src/core/ui/Icon.jsx +279 -0
- package/src/core/ui/InspectorPanel.css +109 -0
- package/src/core/ui/InspectorPanel.jsx +632 -0
- package/src/core/ui/PwaInstallBanner.css +42 -0
- package/src/core/ui/PwaInstallBanner.jsx +124 -0
- package/src/core/ui/SidePanel.jsx +261 -0
- package/src/core/ui/ThemeMenuButton.jsx +139 -0
- package/src/core/ui/core-ui-colors.css +129 -0
- package/src/core/ui/design-modes.ts +7 -0
- package/src/core/ui/sidepanel.css +301 -0
- package/src/core/ui/viewfinder.ts +7 -0
- package/src/core/ui-entry.js +30 -0
- package/src/core/utils/fuzzySearch.js +117 -0
- package/src/core/utils/fuzzySearch.test.js +119 -0
- package/src/core/utils/mobileViewport.js +57 -0
- package/src/core/utils/mobileViewport.test.js +68 -0
- package/src/core/utils/prodMode.js +38 -0
- package/src/core/utils/smoothCorners.js +20 -0
- package/src/core/vite/docs-handler.js +155 -0
- package/src/core/vite/server-plugin.js +797 -0
- package/src/core/workshop/features/createCanvas/CreateCanvasForm.jsx +260 -0
- package/src/core/workshop/features/createCanvas/index.js +14 -0
- package/src/core/workshop/features/createFlow/CreateFlowForm.jsx +334 -0
- package/src/core/workshop/features/createFlow/index.js +19 -0
- package/src/core/workshop/features/createFlow/server.js +663 -0
- package/src/core/workshop/features/createPage/CreatePageForm.jsx +304 -0
- package/src/core/workshop/features/createPage/index.js +11 -0
- package/src/core/workshop/features/createPrototype/CreatePrototypeForm.jsx +289 -0
- package/src/core/workshop/features/createPrototype/index.js +19 -0
- package/src/core/workshop/features/createPrototype/server.js +433 -0
- package/src/core/workshop/features/createStory/CreateStoryForm.jsx +208 -0
- package/src/core/workshop/features/createStory/index.js +14 -0
- package/src/core/workshop/features/registry-server.js +22 -0
- package/src/core/workshop/features/registry.js +28 -0
- package/src/core/workshop/features/templateIndex.js +155 -0
- package/src/core/workshop/ui/WorkshopPanel.jsx +98 -0
- package/src/core/workshop/ui/mount.ts +6 -0
- package/src/core/worktree/port.js +268 -0
- package/src/core/worktree/port.test.js +222 -0
- package/src/core/worktree/serverRegistry.js +120 -0
- package/src/internals/AuthModal/AuthModal.jsx +132 -0
- package/src/internals/AuthModal/AuthModal.module.css +221 -0
- package/src/internals/BranchBar/BranchBar.jsx +87 -0
- package/src/internals/BranchBar/BranchBar.module.css +247 -0
- package/src/internals/BranchBar/useBranches.js +93 -0
- package/src/internals/BranchBar/useBranches.test.js +68 -0
- package/src/internals/CommandPalette/CommandPalette.jsx +1361 -0
- package/src/internals/CommandPalette/CreateDialog.jsx +219 -0
- package/src/internals/CommandPalette/command-palette.css +180 -0
- package/src/internals/FlowError.module.css +30 -0
- package/src/internals/Icon.jsx +279 -0
- package/src/internals/StoryboardContext.js +3 -0
- package/src/internals/Viewfinder.jsx +1479 -0
- package/src/internals/Viewfinder.module.css +1540 -0
- package/src/internals/Workspace.jsx +7 -0
- package/src/internals/__mocks__/virtual-storyboard-data-index.js +4 -0
- package/src/internals/canvas/CanvasControls.jsx +112 -0
- package/src/internals/canvas/CanvasControls.module.css +135 -0
- package/src/internals/canvas/CanvasPage.bridge.test.jsx +387 -0
- package/src/internals/canvas/CanvasPage.dragdrop.test.jsx +350 -0
- package/src/internals/canvas/CanvasPage.jsx +3092 -0
- package/src/internals/canvas/CanvasPage.module.css +187 -0
- package/src/internals/canvas/CanvasPage.multiselect.test.jsx +358 -0
- package/src/internals/canvas/CanvasToolbar.jsx +73 -0
- package/src/internals/canvas/CanvasToolbar.module.css +92 -0
- package/src/internals/canvas/ComponentErrorBoundary.jsx +50 -0
- package/src/internals/canvas/ConnectorLayer.jsx +208 -0
- package/src/internals/canvas/ConnectorLayer.module.css +129 -0
- package/src/internals/canvas/MarqueeOverlay.jsx +20 -0
- package/src/internals/canvas/PageSelector.jsx +587 -0
- package/src/internals/canvas/PageSelector.module.css +261 -0
- package/src/internals/canvas/PageSelector.test.jsx +113 -0
- package/src/internals/canvas/WebGLContextPool.jsx +292 -0
- package/src/internals/canvas/WebGLContextPool.test.jsx +165 -0
- package/src/internals/canvas/canvasApi.js +164 -0
- package/src/internals/canvas/canvasReloadGuard.js +37 -0
- package/src/internals/canvas/canvasReloadGuard.test.js +27 -0
- package/src/internals/canvas/canvasTheme.js +118 -0
- package/src/internals/canvas/componentIsolate.jsx +165 -0
- package/src/internals/canvas/componentSetIsolate.jsx +257 -0
- package/src/internals/canvas/computeCanvasBounds.test.js +121 -0
- package/src/internals/canvas/connectorGeometry.js +132 -0
- package/src/internals/canvas/hotPoolDevLogs.js +25 -0
- package/src/internals/canvas/textSelection.js +10 -0
- package/src/internals/canvas/textSelection.test.js +26 -0
- package/src/internals/canvas/useCanvas.js +126 -0
- package/src/internals/canvas/useCanvas.test.js +26 -0
- package/src/internals/canvas/useMarqueeSelect.js +213 -0
- package/src/internals/canvas/useMarqueeSelect.test.js +78 -0
- package/src/internals/canvas/useUndoRedo.js +86 -0
- package/src/internals/canvas/useUndoRedo.test.js +231 -0
- package/src/internals/canvas/widgets/CodePenEmbed.jsx +293 -0
- package/src/internals/canvas/widgets/CodePenEmbed.module.css +161 -0
- package/src/internals/canvas/widgets/ComponentSetWidget.jsx +2 -0
- package/src/internals/canvas/widgets/ComponentSetWidget.module.css +89 -0
- package/src/internals/canvas/widgets/ComponentWidget.jsx +14 -0
- package/src/internals/canvas/widgets/ComponentWidget.module.css +0 -0
- package/src/internals/canvas/widgets/CropOverlay.jsx +179 -0
- package/src/internals/canvas/widgets/CropOverlay.module.css +154 -0
- package/src/internals/canvas/widgets/ExpandedPane.jsx +474 -0
- package/src/internals/canvas/widgets/ExpandedPane.module.css +179 -0
- package/src/internals/canvas/widgets/ExpandedPane.test.jsx +240 -0
- package/src/internals/canvas/widgets/ExpandedPaneTopBar.jsx +111 -0
- package/src/internals/canvas/widgets/ExpandedPaneTopBar.module.css +59 -0
- package/src/internals/canvas/widgets/ExpandedPaneTopBar.test.jsx +45 -0
- package/src/internals/canvas/widgets/FigmaEmbed.jsx +296 -0
- package/src/internals/canvas/widgets/FigmaEmbed.module.css +222 -0
- package/src/internals/canvas/widgets/FrozenTerminalOverlay.jsx +151 -0
- package/src/internals/canvas/widgets/FrozenTerminalOverlay.module.css +83 -0
- package/src/internals/canvas/widgets/ImageWidget.jsx +287 -0
- package/src/internals/canvas/widgets/ImageWidget.module.css +81 -0
- package/src/internals/canvas/widgets/LinkPreview.jsx +439 -0
- package/src/internals/canvas/widgets/LinkPreview.module.css +585 -0
- package/src/internals/canvas/widgets/LinkPreview.test.jsx +193 -0
- package/src/internals/canvas/widgets/MarkdownBlock.jsx +354 -0
- package/src/internals/canvas/widgets/MarkdownBlock.module.css +377 -0
- package/src/internals/canvas/widgets/MarkdownBlock.test.jsx +92 -0
- package/src/internals/canvas/widgets/PromptWidget.jsx +428 -0
- package/src/internals/canvas/widgets/PromptWidget.module.css +273 -0
- package/src/internals/canvas/widgets/PrototypeEmbed.jsx +463 -0
- package/src/internals/canvas/widgets/PrototypeEmbed.module.css +579 -0
- package/src/internals/canvas/widgets/PrototypeEmbed.test.jsx +10 -0
- package/src/internals/canvas/widgets/ResizeHandle.jsx +67 -0
- package/src/internals/canvas/widgets/ResizeHandle.module.css +29 -0
- package/src/internals/canvas/widgets/StickyNote.jsx +92 -0
- package/src/internals/canvas/widgets/StickyNote.module.css +70 -0
- package/src/internals/canvas/widgets/StickyNote.test.jsx +116 -0
- package/src/internals/canvas/widgets/StorySetWidget.jsx +208 -0
- package/src/internals/canvas/widgets/StorySetWidget.module.css +89 -0
- package/src/internals/canvas/widgets/StoryWidget.jsx +334 -0
- package/src/internals/canvas/widgets/StoryWidget.module.css +211 -0
- package/src/internals/canvas/widgets/TerminalReadWidget.jsx +146 -0
- package/src/internals/canvas/widgets/TerminalReadWidget.module.css +94 -0
- package/src/internals/canvas/widgets/TerminalWidget.jsx +704 -0
- package/src/internals/canvas/widgets/TerminalWidget.module.css +444 -0
- package/src/internals/canvas/widgets/TilesWidget.jsx +300 -0
- package/src/internals/canvas/widgets/TilesWidget.module.css +133 -0
- package/src/internals/canvas/widgets/WidgetChrome.jsx +580 -0
- package/src/internals/canvas/widgets/WidgetChrome.module.css +421 -0
- package/src/internals/canvas/widgets/WidgetWrapper.jsx +15 -0
- package/src/internals/canvas/widgets/WidgetWrapper.module.css +25 -0
- package/src/internals/canvas/widgets/codepenUrl.js +75 -0
- package/src/internals/canvas/widgets/codepenUrl.test.js +76 -0
- package/src/internals/canvas/widgets/embedInteraction.test.jsx +173 -0
- package/src/internals/canvas/widgets/embedOverlay.module.css +35 -0
- package/src/internals/canvas/widgets/embedTheme.js +148 -0
- package/src/internals/canvas/widgets/expandUtils.js +559 -0
- package/src/internals/canvas/widgets/expandUtils.test.js +155 -0
- package/src/internals/canvas/widgets/figmaUrl.js +118 -0
- package/src/internals/canvas/widgets/figmaUrl.test.js +139 -0
- package/src/internals/canvas/widgets/githubUrl.js +82 -0
- package/src/internals/canvas/widgets/githubUrl.test.js +74 -0
- package/src/internals/canvas/widgets/iframeDevLogs.js +49 -0
- package/src/internals/canvas/widgets/iframeDevLogs.test.jsx +81 -0
- package/src/internals/canvas/widgets/index.js +42 -0
- package/src/internals/canvas/widgets/pasteRules.js +295 -0
- package/src/internals/canvas/widgets/pasteRules.test.js +474 -0
- package/src/internals/canvas/widgets/snapshotDisplay.test.jsx +211 -0
- package/src/internals/canvas/widgets/tilePool.js +23 -0
- package/src/internals/canvas/widgets/tiles/diagonal-bl.png +0 -0
- package/src/internals/canvas/widgets/tiles/diagonal-br.png +0 -0
- package/src/internals/canvas/widgets/tiles/diagonal-tl.png +0 -0
- package/src/internals/canvas/widgets/tiles/leaf.png +0 -0
- package/src/internals/canvas/widgets/tiles/quarter-tl.png +0 -0
- package/src/internals/canvas/widgets/tiles/quarter-tr.png +0 -0
- package/src/internals/canvas/widgets/tiles/solid-a.png +0 -0
- package/src/internals/canvas/widgets/tiles/solid-b.png +0 -0
- package/src/internals/canvas/widgets/widgetConfig.js +291 -0
- package/src/internals/canvas/widgets/widgetConfig.test.js +68 -0
- package/src/internals/canvas/widgets/widgetIcons.jsx +190 -0
- package/src/internals/canvas/widgets/widgetProps.js +133 -0
- package/src/internals/context/FormContext.js +13 -0
- package/src/internals/context/FormContext.test.js +48 -0
- package/src/internals/context.jsx +481 -0
- package/src/internals/context.test.jsx +296 -0
- package/src/internals/hashPreserver.js +73 -0
- package/src/internals/hashPreserver.test.js +107 -0
- package/src/internals/hooks/useConfig.js +14 -0
- package/src/internals/hooks/useFeatureFlag.js +14 -0
- package/src/internals/hooks/useFlows.js +50 -0
- package/src/internals/hooks/useFlows.test.js +134 -0
- package/src/internals/hooks/useHideMode.js +31 -0
- package/src/internals/hooks/useHideMode.test.js +43 -0
- package/src/internals/hooks/useLocalStorage.js +57 -0
- package/src/internals/hooks/useLocalStorage.test.js +75 -0
- package/src/internals/hooks/useMode.js +43 -0
- package/src/internals/hooks/useObject.js +101 -0
- package/src/internals/hooks/useObject.test.js +74 -0
- package/src/internals/hooks/useOverride.js +84 -0
- package/src/internals/hooks/useOverride.test.js +71 -0
- package/src/internals/hooks/usePrototypeReloadGuard.js +64 -0
- package/src/internals/hooks/useRecord.js +158 -0
- package/src/internals/hooks/useRecord.test.js +221 -0
- package/src/internals/hooks/useScene.js +38 -0
- package/src/internals/hooks/useScene.test.js +66 -0
- package/src/internals/hooks/useSceneData.js +108 -0
- package/src/internals/hooks/useSceneData.test.js +136 -0
- package/src/internals/hooks/useSession.js +4 -0
- package/src/internals/hooks/useSession.test.js +8 -0
- package/src/internals/hooks/useThemeState.js +61 -0
- package/src/internals/hooks/useThemeState.test.js +66 -0
- package/src/internals/hooks/useUndoRedo.js +28 -0
- package/src/internals/hooks/useUndoRedo.test.js +64 -0
- package/src/internals/index.js +58 -0
- package/src/internals/story/ComponentSetPage.jsx +198 -0
- package/src/internals/story/ComponentSetPage.module.css +129 -0
- package/src/internals/story/StoryPage.jsx +147 -0
- package/src/internals/story/StoryPage.module.css +18 -0
- package/src/internals/test-utils.js +45 -0
- package/src/internals/vite/data-plugin.js +1508 -0
- package/src/internals/vite/data-plugin.test.js +1223 -0
- package/src/test-utils.js +44 -0
- package/toolbar.config.json +271 -0
- package/widgets.config.json +1537 -0
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workshop API — flow creation and listing.
|
|
3
|
+
*
|
|
4
|
+
* Routes (mounted at /_storyboard/workshop/):
|
|
5
|
+
* GET /flows — list prototypes, existing flows, and available objects
|
|
6
|
+
* POST /flows — create a new flow file
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import fs from 'node:fs'
|
|
10
|
+
import path from 'node:path'
|
|
11
|
+
import { parse as parseJsonc } from 'jsonc-parser'
|
|
12
|
+
import {
|
|
13
|
+
buildTemplateRecipeIndex,
|
|
14
|
+
resolveTemplateRecipeEntry,
|
|
15
|
+
} from '../templateIndex.js'
|
|
16
|
+
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Helpers
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
function toKebabCase(str) {
|
|
22
|
+
return str
|
|
23
|
+
.replace(/[^a-zA-Z0-9\s_-]/g, '')
|
|
24
|
+
.trim()
|
|
25
|
+
.replace(/[\s_]+/g, '-')
|
|
26
|
+
.toLowerCase()
|
|
27
|
+
.replace(/-+/g, '-')
|
|
28
|
+
.replace(/^-|-$/g, '')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function validateFlowName(name) {
|
|
32
|
+
if (!name || typeof name !== 'string') {
|
|
33
|
+
return { valid: false, error: 'Flow name is required' }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const kebab = toKebabCase(name.trim())
|
|
37
|
+
|
|
38
|
+
if (!kebab) {
|
|
39
|
+
return { valid: false, error: 'Name must contain at least one alphanumeric character' }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(kebab)) {
|
|
43
|
+
return { valid: false, error: 'Name must be kebab-case (lowercase letters, numbers, and hyphens)' }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { valid: true, kebab }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'packages'])
|
|
50
|
+
const PAGE_EXT_RE = /\.(jsx|tsx|js|ts)$/
|
|
51
|
+
|
|
52
|
+
function toPascalCase(input) {
|
|
53
|
+
return input
|
|
54
|
+
.replace(/\[|\]/g, '')
|
|
55
|
+
.replace(/[^a-zA-Z0-9\s_-]/g, '')
|
|
56
|
+
.trim()
|
|
57
|
+
.replace(/[\s_-]+/g, ' ')
|
|
58
|
+
.split(' ')
|
|
59
|
+
.filter(Boolean)
|
|
60
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
61
|
+
.join('')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function humanize(kebab) {
|
|
65
|
+
if (!kebab) return 'Page'
|
|
66
|
+
return kebab
|
|
67
|
+
.replace(/\[|\]/g, '')
|
|
68
|
+
.split('-')
|
|
69
|
+
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
|
|
70
|
+
.join(' ')
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function normalizePathSlashes(value) {
|
|
74
|
+
return value.replaceAll('\\', '/')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function isPathInside(parent, candidate) {
|
|
78
|
+
const relative = path.relative(parent, candidate)
|
|
79
|
+
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative))
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function parsePrototypeFromFlowPath(relPath) {
|
|
83
|
+
const normalized = normalizePathSlashes(relPath)
|
|
84
|
+
if (!normalized.startsWith('src/prototypes/')) return null
|
|
85
|
+
|
|
86
|
+
const parts = normalized.split('/').filter(Boolean)
|
|
87
|
+
if (parts.length < 4) return null
|
|
88
|
+
|
|
89
|
+
if (parts[2].endsWith('.folder') && parts.length >= 5) {
|
|
90
|
+
return {
|
|
91
|
+
folder: parts[2].replace(/\.folder$/, ''),
|
|
92
|
+
prototype: parts[3],
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
folder: undefined,
|
|
98
|
+
prototype: parts[2],
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function isExternalPrototype(prototypePath) {
|
|
103
|
+
try {
|
|
104
|
+
const raw = fs.readFileSync(prototypePath, 'utf-8')
|
|
105
|
+
const parsed = parseJsonc(raw)
|
|
106
|
+
return typeof parsed?.url === 'string' && parsed.url.trim().length > 0
|
|
107
|
+
} catch {
|
|
108
|
+
return false
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function findPrototypeDir(root, protoName, folderName) {
|
|
113
|
+
const prototypesDir = path.join(root, 'src', 'prototypes')
|
|
114
|
+
if (!fs.existsSync(prototypesDir)) {
|
|
115
|
+
return { error: 'No prototypes directory found' }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const matches = []
|
|
119
|
+
|
|
120
|
+
function scanDir(dir, folder) {
|
|
121
|
+
if (!fs.existsSync(dir)) return
|
|
122
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
123
|
+
if (!entry.isDirectory()) continue
|
|
124
|
+
if (entry.name.endsWith('.folder')) {
|
|
125
|
+
scanDir(path.join(dir, entry.name), entry.name.replace(/\.folder$/, ''))
|
|
126
|
+
continue
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (entry.name !== protoName) continue
|
|
130
|
+
if (folderName && folder !== folderName) continue
|
|
131
|
+
|
|
132
|
+
const protoDir = path.join(dir, entry.name)
|
|
133
|
+
const prototypeFile = fs.readdirSync(protoDir).find((f) => f.endsWith('.prototype.json'))
|
|
134
|
+
if (!prototypeFile) continue
|
|
135
|
+
if (isExternalPrototype(path.join(protoDir, prototypeFile))) continue
|
|
136
|
+
|
|
137
|
+
matches.push({ dir: protoDir, folder })
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
scanDir(prototypesDir)
|
|
142
|
+
|
|
143
|
+
if (matches.length === 0) {
|
|
144
|
+
return { error: `Prototype "${protoName}" not found` }
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (!folderName && matches.length > 1) {
|
|
148
|
+
return { error: `Prototype "${protoName}" is ambiguous; include its folder` }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return { dir: matches[0].dir, folder: matches[0].folder }
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function normalizeRouteForPrototype(protoName, route) {
|
|
155
|
+
if (typeof route !== 'string') return null
|
|
156
|
+
const trimmed = route.trim()
|
|
157
|
+
if (!trimmed) return null
|
|
158
|
+
if (trimmed.startsWith('/')) return trimmed
|
|
159
|
+
return `/${protoName}/${trimmed.replace(/^\/+/, '')}`
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function isRouteInPrototype(protoName, route) {
|
|
163
|
+
return route === `/${protoName}` || route.startsWith(`/${protoName}/`)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function findComponentFile(dir) {
|
|
167
|
+
if (!fs.existsSync(dir)) return null
|
|
168
|
+
const files = fs.readdirSync(dir)
|
|
169
|
+
const component = files.find((f) => /\.(jsx|tsx)$/.test(f) && !f.startsWith('_') && !f.includes('.test.'))
|
|
170
|
+
return component ? component.replace(/\.(jsx|tsx)$/, '') : null
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function generateBlankPageJsx(componentName, title) {
|
|
174
|
+
return `export default function ${componentName}() {
|
|
175
|
+
return (
|
|
176
|
+
<div>
|
|
177
|
+
<h1>${title}</h1>
|
|
178
|
+
<p>Start building your page here.</p>
|
|
179
|
+
</div>
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
`
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function generateTemplatePageJsx({ partialEntry, componentFile, componentName, title }) {
|
|
186
|
+
const importPath = `@/${partialEntry.baseDir}/${partialEntry.name}/${componentFile}`
|
|
187
|
+
return `import ${componentFile} from '${importPath}'
|
|
188
|
+
|
|
189
|
+
export default function ${componentName}() {
|
|
190
|
+
return (
|
|
191
|
+
<${componentFile} title="${title}">
|
|
192
|
+
<h1>${title}</h1>
|
|
193
|
+
<p>Start building your page here.</p>
|
|
194
|
+
</${componentFile}>
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
`
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function createPageInPrototype({
|
|
201
|
+
root,
|
|
202
|
+
targetDir,
|
|
203
|
+
protoName,
|
|
204
|
+
protoFolder,
|
|
205
|
+
createPage,
|
|
206
|
+
templateRecipes,
|
|
207
|
+
}) {
|
|
208
|
+
if (typeof createPage?.path !== 'string' || !createPage.path.trim()) {
|
|
209
|
+
return { ok: false, status: 400, error: 'New page path is required' }
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const rawPath = createPage.path.trim().replace(/^\/+/, '')
|
|
213
|
+
const normalizedPath = createPage.path.trim().startsWith('/')
|
|
214
|
+
? createPage.path.trim()
|
|
215
|
+
: `/${protoName}/${rawPath}`
|
|
216
|
+
|
|
217
|
+
if (!isRouteInPrototype(protoName, normalizedPath)) {
|
|
218
|
+
return { ok: false, status: 400, error: `New page path must be within "/${protoName}"` }
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const relativePageRoute = normalizedPath.replace(new RegExp(`^/${protoName}/?`), '')
|
|
222
|
+
if (!relativePageRoute) {
|
|
223
|
+
return { ok: false, status: 400, error: 'New page path must include at least one segment after the prototype prefix' }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const parts = relativePageRoute.split('/').filter(Boolean)
|
|
227
|
+
if (parts.some((part) => part === '.' || part === '..')) {
|
|
228
|
+
return { ok: false, status: 400, error: 'New page path contains invalid segments' }
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const safePartRe = /^[a-zA-Z0-9\-_.[\]]+$/
|
|
232
|
+
if (parts.some((part) => !safePartRe.test(part))) {
|
|
233
|
+
return {
|
|
234
|
+
ok: false,
|
|
235
|
+
status: 400,
|
|
236
|
+
error: 'New page path can only include letters, numbers, "-", "_", ".", and [] for dynamic segments',
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const pageDirParts = parts.slice(0, -1)
|
|
241
|
+
const pageName = parts[parts.length - 1]
|
|
242
|
+
const pageFile = `${pageName}.jsx`
|
|
243
|
+
const pageDir = path.join(targetDir, ...pageDirParts)
|
|
244
|
+
const pageFilePath = path.join(pageDir, pageFile)
|
|
245
|
+
|
|
246
|
+
if (fs.existsSync(pageFilePath)) {
|
|
247
|
+
return { ok: false, status: 409, error: `Page "${normalizedPath}" already exists` }
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
let pageContent
|
|
251
|
+
const titleBase = humanize(pageName)
|
|
252
|
+
const componentName = toPascalCase(pageName) || 'Page'
|
|
253
|
+
if (createPage.template) {
|
|
254
|
+
const partialEntry = resolveTemplateRecipeEntry(templateRecipes, createPage.template, {
|
|
255
|
+
prototype: protoName,
|
|
256
|
+
folder: protoFolder,
|
|
257
|
+
})
|
|
258
|
+
if (!partialEntry) {
|
|
259
|
+
const validNames = templateRecipes.map((p) => p.id).join(', ')
|
|
260
|
+
return {
|
|
261
|
+
ok: false,
|
|
262
|
+
status: 400,
|
|
263
|
+
error: `Unknown template/recipe "${createPage.template}". Available: ${validNames}`,
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const partialDir = path.join(root, 'src', partialEntry.baseDir, partialEntry.name)
|
|
268
|
+
const componentFile = findComponentFile(partialDir)
|
|
269
|
+
if (!componentFile) {
|
|
270
|
+
return {
|
|
271
|
+
ok: false,
|
|
272
|
+
status: 400,
|
|
273
|
+
error: `No .jsx or .tsx file found in src/${partialEntry.directory}/${partialEntry.name}/`,
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
pageContent = generateTemplatePageJsx({
|
|
278
|
+
partialEntry,
|
|
279
|
+
componentFile,
|
|
280
|
+
componentName,
|
|
281
|
+
title: titleBase,
|
|
282
|
+
})
|
|
283
|
+
} else {
|
|
284
|
+
pageContent = generateBlankPageJsx(componentName, titleBase)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
fs.mkdirSync(pageDir, { recursive: true })
|
|
288
|
+
fs.writeFileSync(pageFilePath, pageContent, 'utf-8')
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
ok: true,
|
|
292
|
+
createdPagePath: path.relative(root, pageFilePath),
|
|
293
|
+
createdPageRoute: normalizedPath,
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function listPrototypeRoutes(protoDir, protoName) {
|
|
298
|
+
const routes = []
|
|
299
|
+
|
|
300
|
+
function scanDir(dir, routeParts = []) {
|
|
301
|
+
if (!fs.existsSync(dir)) return
|
|
302
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
303
|
+
if (entry.isDirectory()) {
|
|
304
|
+
scanDir(path.join(dir, entry.name), [...routeParts, entry.name])
|
|
305
|
+
continue
|
|
306
|
+
}
|
|
307
|
+
if (!PAGE_EXT_RE.test(entry.name)) continue
|
|
308
|
+
if (entry.name.startsWith('_')) continue
|
|
309
|
+
|
|
310
|
+
const baseName = entry.name.replace(PAGE_EXT_RE, '')
|
|
311
|
+
const fileRouteParts = baseName === 'index' ? routeParts : [...routeParts, baseName]
|
|
312
|
+
const suffix = fileRouteParts.length > 0 ? `/${fileRouteParts.join('/')}` : ''
|
|
313
|
+
routes.push(`/${protoName}${suffix}`)
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
scanDir(protoDir)
|
|
318
|
+
return Array.from(new Set(routes)).sort((a, b) => a.localeCompare(b))
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* List prototypes by scanning src/prototypes/, following .folder directories.
|
|
323
|
+
* Returns array of { name, folder?, routes }.
|
|
324
|
+
*/
|
|
325
|
+
function listPrototypes(root) {
|
|
326
|
+
const prototypesDir = path.join(root, 'src', 'prototypes')
|
|
327
|
+
if (!fs.existsSync(prototypesDir)) return []
|
|
328
|
+
|
|
329
|
+
const results = []
|
|
330
|
+
|
|
331
|
+
function scanDir(dir, folder) {
|
|
332
|
+
if (!fs.existsSync(dir)) return
|
|
333
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
334
|
+
if (!entry.isDirectory()) continue
|
|
335
|
+
if (entry.name.endsWith('.folder')) {
|
|
336
|
+
scanDir(path.join(dir, entry.name), entry.name.replace('.folder', ''))
|
|
337
|
+
} else {
|
|
338
|
+
const protoDir = path.join(dir, entry.name)
|
|
339
|
+
const prototypeFile = fs.readdirSync(protoDir).find((f) => f.endsWith('.prototype.json'))
|
|
340
|
+
if (!prototypeFile) continue
|
|
341
|
+
|
|
342
|
+
const prototypePath = path.join(protoDir, prototypeFile)
|
|
343
|
+
if (!isExternalPrototype(prototypePath)) {
|
|
344
|
+
results.push({
|
|
345
|
+
name: entry.name,
|
|
346
|
+
...(folder ? { folder } : {}),
|
|
347
|
+
routes: listPrototypeRoutes(protoDir, entry.name),
|
|
348
|
+
})
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
scanDir(prototypesDir)
|
|
355
|
+
return results
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* List existing flow files from the src/ tree.
|
|
360
|
+
* Returns array of { name, title, path, prototype?, folder?, route? }.
|
|
361
|
+
*/
|
|
362
|
+
function listFlows(root) {
|
|
363
|
+
const results = []
|
|
364
|
+
|
|
365
|
+
function scanDir(dir) {
|
|
366
|
+
if (!fs.existsSync(dir)) return
|
|
367
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
368
|
+
if (entry.isDirectory()) {
|
|
369
|
+
if (SKIP_DIRS.has(entry.name)) continue
|
|
370
|
+
scanDir(path.join(dir, entry.name))
|
|
371
|
+
} else if (/\.flow\.jsonc?$/.test(entry.name)) {
|
|
372
|
+
const flowName = entry.name.replace(/\.flow\.jsonc?$/, '')
|
|
373
|
+
const filePath = path.join(dir, entry.name)
|
|
374
|
+
const relPath = path.relative(root, filePath)
|
|
375
|
+
const flowPrototype = parsePrototypeFromFlowPath(relPath)
|
|
376
|
+
|
|
377
|
+
let title = flowName
|
|
378
|
+
let route
|
|
379
|
+
try {
|
|
380
|
+
const raw = fs.readFileSync(filePath, 'utf-8')
|
|
381
|
+
const parsed = parseJsonc(raw)
|
|
382
|
+
if (parsed?.meta?.title) title = parsed.meta.title
|
|
383
|
+
if (typeof parsed?.meta?.route === 'string') route = parsed.meta.route
|
|
384
|
+
} catch { /* ignore */ }
|
|
385
|
+
|
|
386
|
+
results.push({
|
|
387
|
+
name: flowName,
|
|
388
|
+
title,
|
|
389
|
+
path: relPath,
|
|
390
|
+
...(flowPrototype ? { prototype: flowPrototype.prototype } : {}),
|
|
391
|
+
...(flowPrototype?.folder ? { folder: flowPrototype.folder } : {}),
|
|
392
|
+
...(route ? { route } : {}),
|
|
393
|
+
})
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
scanDir(path.join(root, 'src'))
|
|
399
|
+
return results
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* List available object names from the src/ tree.
|
|
404
|
+
*/
|
|
405
|
+
function listObjects(root) {
|
|
406
|
+
const results = []
|
|
407
|
+
|
|
408
|
+
function scanDir(dir) {
|
|
409
|
+
if (!fs.existsSync(dir)) return
|
|
410
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
411
|
+
if (entry.isDirectory()) {
|
|
412
|
+
if (SKIP_DIRS.has(entry.name)) continue
|
|
413
|
+
scanDir(path.join(dir, entry.name))
|
|
414
|
+
} else if (/\.object\.jsonc?$/.test(entry.name)) {
|
|
415
|
+
results.push(entry.name.replace(/\.object\.jsonc?$/, ''))
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
scanDir(path.join(root, 'src'))
|
|
421
|
+
return results
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function generateFlowJson({ title, author, description, globals, sourceData, route }) {
|
|
425
|
+
let data = sourceData ? { ...sourceData } : {}
|
|
426
|
+
|
|
427
|
+
data.meta = {
|
|
428
|
+
...(sourceData?.meta || {}),
|
|
429
|
+
title,
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if (author) {
|
|
433
|
+
const authors = author.split(',').map((a) => a.trim()).filter(Boolean)
|
|
434
|
+
data.meta.author = authors.length === 1 ? authors[0] : authors
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (description) {
|
|
438
|
+
data.meta.description = description
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (route) {
|
|
442
|
+
data.meta.route = route
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
if (globals && globals.length > 0) {
|
|
446
|
+
data.$global = globals
|
|
447
|
+
} else if (!sourceData) {
|
|
448
|
+
data.$global = []
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return JSON.stringify(data, null, 2) + '\n'
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// ---------------------------------------------------------------------------
|
|
455
|
+
// Handler
|
|
456
|
+
// ---------------------------------------------------------------------------
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Create the flows API route handler.
|
|
460
|
+
* @param {object} ctx - Server context ({ root, sendJson, workshopConfig })
|
|
461
|
+
*/
|
|
462
|
+
export function createFlowsHandler(ctx) {
|
|
463
|
+
const { root, sendJson, workshopConfig = {} } = ctx
|
|
464
|
+
const getTemplateRecipes = () => buildTemplateRecipeIndex(root, workshopConfig.partials)
|
|
465
|
+
|
|
466
|
+
return async (req, res, { body, path: routePath, method }) => {
|
|
467
|
+
const templateRecipes = getTemplateRecipes()
|
|
468
|
+
|
|
469
|
+
if (routePath === '/flows' && method === 'GET') {
|
|
470
|
+
const prototypes = listPrototypes(root)
|
|
471
|
+
const flows = listFlows(root)
|
|
472
|
+
const objects = listObjects(root)
|
|
473
|
+
sendJson(res, 200, { prototypes, flows, objects, partials: templateRecipes })
|
|
474
|
+
return
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if (routePath === '/pages' && method === 'GET') {
|
|
478
|
+
const prototypes = listPrototypes(root)
|
|
479
|
+
sendJson(res, 200, { prototypes, partials: templateRecipes })
|
|
480
|
+
return
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
if (routePath === '/pages' && method === 'POST') {
|
|
484
|
+
const {
|
|
485
|
+
prototype: protoName,
|
|
486
|
+
folder: folderName,
|
|
487
|
+
path: pagePath,
|
|
488
|
+
template,
|
|
489
|
+
} = body
|
|
490
|
+
|
|
491
|
+
if (!protoName || typeof protoName !== 'string' || !protoName.trim()) {
|
|
492
|
+
sendJson(res, 400, { error: 'Prototype is required when creating a page' })
|
|
493
|
+
return
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
const resolvedPrototype = findPrototypeDir(root, protoName.trim(), folderName)
|
|
497
|
+
if (!resolvedPrototype.dir) {
|
|
498
|
+
sendJson(res, 400, { error: resolvedPrototype.error || `Prototype "${protoName}" not found` })
|
|
499
|
+
return
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const pageResult = createPageInPrototype({
|
|
503
|
+
root,
|
|
504
|
+
targetDir: resolvedPrototype.dir,
|
|
505
|
+
protoName: protoName.trim(),
|
|
506
|
+
protoFolder: resolvedPrototype.folder,
|
|
507
|
+
createPage: { path: pagePath, template },
|
|
508
|
+
templateRecipes,
|
|
509
|
+
})
|
|
510
|
+
|
|
511
|
+
if (!pageResult.ok) {
|
|
512
|
+
sendJson(res, pageResult.status, { error: pageResult.error })
|
|
513
|
+
return
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
sendJson(res, 201, {
|
|
517
|
+
success: true,
|
|
518
|
+
path: pageResult.createdPagePath,
|
|
519
|
+
route: pageResult.createdPageRoute,
|
|
520
|
+
files: [pageResult.createdPagePath],
|
|
521
|
+
})
|
|
522
|
+
return
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (routePath === '/flows' && method === 'POST') {
|
|
526
|
+
const {
|
|
527
|
+
name,
|
|
528
|
+
title: customTitle,
|
|
529
|
+
prototype: protoName,
|
|
530
|
+
folder: folderName,
|
|
531
|
+
existingFlow,
|
|
532
|
+
author,
|
|
533
|
+
description,
|
|
534
|
+
globals = [],
|
|
535
|
+
copyFrom,
|
|
536
|
+
startingPage,
|
|
537
|
+
createPage,
|
|
538
|
+
} = body
|
|
539
|
+
|
|
540
|
+
// Validate name
|
|
541
|
+
const validation = validateFlowName(name)
|
|
542
|
+
if (!validation.valid) {
|
|
543
|
+
sendJson(res, 400, { error: validation.error })
|
|
544
|
+
return
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const { kebab } = validation
|
|
548
|
+
const title = customTitle || humanize(kebab)
|
|
549
|
+
|
|
550
|
+
if (!protoName || typeof protoName !== 'string' || !protoName.trim()) {
|
|
551
|
+
sendJson(res, 400, { error: 'Prototype is required when creating a flow' })
|
|
552
|
+
return
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// Determine target directory
|
|
556
|
+
const resolvedPrototype = findPrototypeDir(root, protoName.trim(), folderName)
|
|
557
|
+
if (!resolvedPrototype.dir) {
|
|
558
|
+
sendJson(res, 400, { error: resolvedPrototype.error || `Prototype "${protoName}" not found` })
|
|
559
|
+
return
|
|
560
|
+
}
|
|
561
|
+
const targetDir = resolvedPrototype.dir
|
|
562
|
+
|
|
563
|
+
// Check for existing flow file
|
|
564
|
+
const flowFileName = `${kebab}.flow.json`
|
|
565
|
+
const flowFilePath = path.join(targetDir, flowFileName)
|
|
566
|
+
if (fs.existsSync(flowFilePath)) {
|
|
567
|
+
sendJson(res, 409, { error: `Flow "${kebab}" already exists in this location` })
|
|
568
|
+
return
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// Load source flow data if copying
|
|
572
|
+
let sourceData = null
|
|
573
|
+
const selectedExistingFlow = typeof existingFlow === 'string' && existingFlow.trim()
|
|
574
|
+
? existingFlow.trim()
|
|
575
|
+
: (typeof copyFrom === 'string' && copyFrom.trim() ? copyFrom.trim() : '')
|
|
576
|
+
if (selectedExistingFlow) {
|
|
577
|
+
let sourceFlowPath
|
|
578
|
+
if (selectedExistingFlow.includes('/') || selectedExistingFlow.includes('\\')) {
|
|
579
|
+
if (path.isAbsolute(selectedExistingFlow)) {
|
|
580
|
+
sendJson(res, 400, { error: 'Existing flow path must be relative to repository root' })
|
|
581
|
+
return
|
|
582
|
+
}
|
|
583
|
+
sourceFlowPath = path.resolve(root, selectedExistingFlow)
|
|
584
|
+
} else {
|
|
585
|
+
sourceFlowPath = path.join(targetDir, `${selectedExistingFlow.replace(/\.flow\.jsonc?$/, '')}.flow.json`)
|
|
586
|
+
if (!fs.existsSync(sourceFlowPath)) {
|
|
587
|
+
const jsoncPath = sourceFlowPath.replace(/\.flow\.json$/, '.flow.jsonc')
|
|
588
|
+
if (fs.existsSync(jsoncPath)) sourceFlowPath = jsoncPath
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
if (!sourceFlowPath || !fs.existsSync(sourceFlowPath)) {
|
|
593
|
+
sendJson(res, 400, { error: `Existing flow not found: ${selectedExistingFlow}` })
|
|
594
|
+
return
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
if (!/\.flow\.jsonc?$/.test(sourceFlowPath)) {
|
|
598
|
+
sendJson(res, 400, { error: 'Existing flow must be a .flow.json or .flow.jsonc file' })
|
|
599
|
+
return
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (!isPathInside(targetDir, sourceFlowPath)) {
|
|
603
|
+
sendJson(res, 400, { error: 'Existing flow must belong to the selected prototype' })
|
|
604
|
+
return
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
try {
|
|
608
|
+
const raw = fs.readFileSync(sourceFlowPath, 'utf-8')
|
|
609
|
+
sourceData = parseJsonc(raw)
|
|
610
|
+
} catch {
|
|
611
|
+
sendJson(res, 400, { error: `Failed to read source flow: ${selectedExistingFlow}` })
|
|
612
|
+
return
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
let createdPagePath = null
|
|
617
|
+
let createdPageRoute = null
|
|
618
|
+
if (createPage) {
|
|
619
|
+
const pageResult = createPageInPrototype({
|
|
620
|
+
root,
|
|
621
|
+
targetDir,
|
|
622
|
+
protoName,
|
|
623
|
+
protoFolder: resolvedPrototype.folder,
|
|
624
|
+
createPage,
|
|
625
|
+
templateRecipes,
|
|
626
|
+
})
|
|
627
|
+
if (!pageResult.ok) {
|
|
628
|
+
sendJson(res, pageResult.status, { error: pageResult.error })
|
|
629
|
+
return
|
|
630
|
+
}
|
|
631
|
+
createdPagePath = pageResult.createdPagePath
|
|
632
|
+
createdPageRoute = pageResult.createdPageRoute
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
const normalizedStartingPage = normalizeRouteForPrototype(protoName, startingPage)
|
|
636
|
+
if (normalizedStartingPage && !isRouteInPrototype(protoName, normalizedStartingPage)) {
|
|
637
|
+
sendJson(res, 400, { error: `Starting page must be within "/${protoName}"` })
|
|
638
|
+
return
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// Ensure target directory exists
|
|
642
|
+
fs.mkdirSync(targetDir, { recursive: true })
|
|
643
|
+
|
|
644
|
+
// Generate and write flow file
|
|
645
|
+
const route = normalizedStartingPage || createdPageRoute
|
|
646
|
+
const content = generateFlowJson({ title, author, description, globals, sourceData, route })
|
|
647
|
+
fs.writeFileSync(flowFilePath, content, 'utf-8')
|
|
648
|
+
|
|
649
|
+
const relPath = path.relative(root, flowFilePath)
|
|
650
|
+
const files = [relPath]
|
|
651
|
+
if (createdPagePath) files.push(createdPagePath)
|
|
652
|
+
sendJson(res, 201, {
|
|
653
|
+
success: true,
|
|
654
|
+
path: relPath,
|
|
655
|
+
files,
|
|
656
|
+
...(createdPagePath ? { createdPagePath } : {}),
|
|
657
|
+
})
|
|
658
|
+
return
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// Unmatched routes fall through — the server plugin compositor handles 404
|
|
662
|
+
}
|
|
663
|
+
}
|