@superblocksteam/vite-plugin-file-sync 2.0.115-next.0 → 2.0.115-next.2
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/dist/ai-service/agent/middleware.d.ts.map +1 -1
- package/dist/ai-service/agent/middleware.js +19 -0
- package/dist/ai-service/agent/middleware.js.map +1 -1
- package/dist/ai-service/agent/prompts/api-prompts.d.ts.map +1 -1
- package/dist/ai-service/agent/prompts/api-prompts.js +13 -17
- package/dist/ai-service/agent/prompts/api-prompts.js.map +1 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js +22 -3
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
- package/dist/ai-service/agent/subagents/coding/prompt-builder.d.ts +16 -0
- package/dist/ai-service/agent/subagents/coding/prompt-builder.d.ts.map +1 -0
- package/dist/ai-service/agent/subagents/coding/prompt-builder.js +30 -0
- package/dist/ai-service/agent/subagents/coding/prompt-builder.js.map +1 -0
- package/dist/ai-service/agent/subagents/coding/run-coding-subagent.d.ts +29 -0
- package/dist/ai-service/agent/subagents/coding/run-coding-subagent.d.ts.map +1 -0
- package/dist/ai-service/agent/subagents/coding/run-coding-subagent.js +108 -0
- package/dist/ai-service/agent/subagents/coding/run-coding-subagent.js.map +1 -0
- package/dist/ai-service/agent/subagents/types.d.ts +9 -1
- package/dist/ai-service/agent/subagents/types.d.ts.map +1 -1
- package/dist/ai-service/agent/subagents/types.js +8 -0
- package/dist/ai-service/agent/subagents/types.js.map +1 -1
- package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
- package/dist/ai-service/agent/tool-message-utils.js +5 -0
- package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js +2 -1
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.d.ts +6 -0
- package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.js +138 -0
- package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.js.map +1 -0
- package/dist/ai-service/agent/tools/build-finalize.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-finalize.js +39 -15
- package/dist/ai-service/agent/tools/build-finalize.js.map +1 -1
- package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +6 -3
- package/dist/ai-service/agent/tools/build-manage-checklist.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-manage-checklist.js +116 -49
- package/dist/ai-service/agent/tools/build-manage-checklist.js.map +1 -1
- package/dist/ai-service/agent/tools/index.d.ts +2 -0
- package/dist/ai-service/agent/tools/index.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/index.js +2 -0
- package/dist/ai-service/agent/tools/index.js.map +1 -1
- package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +3 -0
- package/dist/ai-service/agent/tools/integrations/execute-request.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/integrations/execute-request.js +330 -204
- package/dist/ai-service/agent/tools/integrations/execute-request.js.map +1 -1
- package/dist/ai-service/agent/tools.d.ts.map +1 -1
- package/dist/ai-service/agent/tools.js +40 -2
- package/dist/ai-service/agent/tools.js.map +1 -1
- package/dist/ai-service/agent/tools2/access-control.d.ts +1 -1
- package/dist/ai-service/agent/tools2/access-control.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/access-control.js +15 -4
- package/dist/ai-service/agent/tools2/access-control.js.map +1 -1
- package/dist/ai-service/agent/tools2/registry.d.ts +3 -0
- package/dist/ai-service/agent/tools2/registry.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/registry.js +50 -8
- package/dist/ai-service/agent/tools2/registry.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/ask-multi-choice.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/ask-multi-choice.js +3 -2
- package/dist/ai-service/agent/tools2/tools/ask-multi-choice.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/ask-searchable-dropdown.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/ask-searchable-dropdown.js +2 -1
- package/dist/ai-service/agent/tools2/tools/ask-searchable-dropdown.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/deploy-service.d.ts +16 -0
- package/dist/ai-service/agent/tools2/tools/deploy-service.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/deploy-service.js +135 -0
- package/dist/ai-service/agent/tools2/tools/deploy-service.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/download-attachments.d.ts +33 -0
- package/dist/ai-service/agent/tools2/tools/download-attachments.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/download-attachments.js +308 -0
- package/dist/ai-service/agent/tools2/tools/download-attachments.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +8 -4
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/git.d.ts +57 -1
- package/dist/ai-service/agent/tools2/tools/git.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/git.js +275 -8
- package/dist/ai-service/agent/tools2/tools/git.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/index.d.ts +2 -1
- package/dist/ai-service/agent/tools2/tools/index.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/index.js +2 -1
- package/dist/ai-service/agent/tools2/tools/index.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/list-attachments.d.ts +4 -1
- package/dist/ai-service/agent/tools2/tools/list-attachments.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/list-attachments.js +20 -4
- package/dist/ai-service/agent/tools2/tools/list-attachments.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.d.ts +28 -0
- package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.js +152 -0
- package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.js.map +1 -0
- package/dist/ai-service/agent/tools2/types.d.ts +1 -18
- package/dist/ai-service/agent/tools2/types.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/types.js.map +1 -1
- package/dist/ai-service/agent/utils.d.ts.map +1 -1
- package/dist/ai-service/agent/utils.js +22 -5
- package/dist/ai-service/agent/utils.js.map +1 -1
- package/dist/ai-service/app-interface/file-system-interface.d.ts +0 -4
- package/dist/ai-service/app-interface/file-system-interface.d.ts.map +1 -1
- package/dist/ai-service/app-interface/file-system-interface.js +0 -21
- package/dist/ai-service/app-interface/file-system-interface.js.map +1 -1
- package/dist/ai-service/app-interface/filesystem/virtual-file-system.d.ts +11 -1
- package/dist/ai-service/app-interface/filesystem/virtual-file-system.d.ts.map +1 -1
- package/dist/ai-service/app-interface/filesystem/virtual-file-system.js +29 -7
- package/dist/ai-service/app-interface/filesystem/virtual-file-system.js.map +1 -1
- package/dist/ai-service/app-interface/shell.d.ts +6 -0
- package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
- package/dist/ai-service/app-interface/shell.js +8 -0
- package/dist/ai-service/app-interface/shell.js.map +1 -1
- package/dist/ai-service/app-skills/helpers.d.ts.map +1 -1
- package/dist/ai-service/app-skills/helpers.js +4 -2
- package/dist/ai-service/app-skills/helpers.js.map +1 -1
- package/dist/ai-service/attachments/store.d.ts +18 -2
- package/dist/ai-service/attachments/store.d.ts.map +1 -1
- package/dist/ai-service/attachments/store.js +102 -9
- package/dist/ai-service/attachments/store.js.map +1 -1
- package/dist/ai-service/attachments/uploaded-content-part.d.ts +5 -2
- package/dist/ai-service/attachments/uploaded-content-part.d.ts.map +1 -1
- package/dist/ai-service/attachments/uploaded-content-part.js +32 -0
- package/dist/ai-service/attachments/uploaded-content-part.js.map +1 -1
- package/dist/ai-service/chat/chat-session-store.d.ts +2 -2
- package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
- package/dist/ai-service/chat/chat-session-store.js +45 -243
- package/dist/ai-service/chat/chat-session-store.js.map +1 -1
- package/dist/ai-service/chat/utils.d.ts +6 -0
- package/dist/ai-service/chat/utils.d.ts.map +1 -1
- package/dist/ai-service/chat/utils.js +47 -0
- package/dist/ai-service/chat/utils.js.map +1 -1
- package/dist/ai-service/features.d.ts +4 -0
- package/dist/ai-service/features.d.ts.map +1 -1
- package/dist/ai-service/features.js +4 -0
- package/dist/ai-service/features.js.map +1 -1
- package/dist/ai-service/index.d.ts +36 -11
- package/dist/ai-service/index.d.ts.map +1 -1
- package/dist/ai-service/index.js +228 -68
- package/dist/ai-service/index.js.map +1 -1
- package/dist/ai-service/judge/tools/playwright-action.d.ts +1 -1
- package/dist/ai-service/llm/client.d.ts.map +1 -1
- package/dist/ai-service/llm/client.js +4 -2
- package/dist/ai-service/llm/client.js.map +1 -1
- package/dist/ai-service/llm/stream/observers/retry-notification.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/observers/retry-notification.js +4 -2
- package/dist/ai-service/llm/stream/observers/retry-notification.js.map +1 -1
- package/dist/ai-service/prompt-builder-service/classifiers/prompt-interpret-task.d.ts.map +1 -1
- package/dist/ai-service/prompt-builder-service/classifiers/prompt-interpret-task.js +1 -16
- package/dist/ai-service/prompt-builder-service/classifiers/prompt-interpret-task.js.map +1 -1
- package/dist/ai-service/prompt-builder-service/types.d.ts +2 -13
- package/dist/ai-service/prompt-builder-service/types.d.ts.map +1 -1
- package/dist/ai-service/prompt-builder-service/types.js.map +1 -1
- package/dist/ai-service/skills/system/_registry.generated.d.ts.map +1 -1
- package/dist/ai-service/skills/system/_registry.generated.js +6 -0
- package/dist/ai-service/skills/system/_registry.generated.js.map +1 -1
- package/dist/ai-service/skills/system/superblocks-migration/references/focused-debug.generated.d.ts +2 -0
- package/dist/ai-service/skills/system/superblocks-migration/references/focused-debug.generated.d.ts.map +1 -0
- package/dist/ai-service/skills/system/superblocks-migration/references/focused-debug.generated.js +58 -0
- package/dist/ai-service/skills/system/superblocks-migration/references/focused-debug.generated.js.map +1 -0
- package/dist/ai-service/skills/system/superblocks-migration/references/yaml-block-mapping.generated.d.ts +2 -0
- package/dist/ai-service/skills/system/superblocks-migration/references/yaml-block-mapping.generated.d.ts.map +1 -0
- package/dist/ai-service/skills/system/superblocks-migration/references/yaml-block-mapping.generated.js +107 -0
- package/dist/ai-service/skills/system/superblocks-migration/references/yaml-block-mapping.generated.js.map +1 -0
- package/dist/ai-service/skills/system/superblocks-migration/skill.generated.d.ts +2 -0
- package/dist/ai-service/skills/system/superblocks-migration/skill.generated.d.ts.map +1 -0
- package/dist/ai-service/skills/system/superblocks-migration/skill.generated.js +137 -0
- package/dist/ai-service/skills/system/superblocks-migration/skill.generated.js.map +1 -0
- package/dist/ai-service/state-machine/clark-fsm.d.ts +26 -13
- package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
- package/dist/ai-service/state-machine/clark-fsm.js +12 -7
- package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.js +76 -27
- package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/awaiting-user.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/awaiting-user.js +15 -6
- package/dist/ai-service/state-machine/handlers/awaiting-user.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/idle.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/idle.js +4 -2
- package/dist/ai-service/state-machine/handlers/idle.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.js +48 -15
- package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/post-processing.d.ts +1 -1
- package/dist/ai-service/state-machine/handlers/post-processing.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/post-processing.js +23 -151
- package/dist/ai-service/state-machine/handlers/post-processing.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/runtime-reviewing.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/runtime-reviewing.js +16 -8
- package/dist/ai-service/state-machine/handlers/runtime-reviewing.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/change-info.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/change-info.js +2 -15
- package/dist/ai-service/state-machine/helpers/change-info.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/peer.d.ts +3 -3
- package/dist/ai-service/state-machine/helpers/peer.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/peer.js +9 -23
- package/dist/ai-service/state-machine/helpers/peer.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/stable-peer.d.ts +52 -0
- package/dist/ai-service/state-machine/helpers/stable-peer.d.ts.map +1 -0
- package/dist/ai-service/state-machine/helpers/stable-peer.js +141 -0
- package/dist/ai-service/state-machine/helpers/stable-peer.js.map +1 -0
- package/dist/ai-service/state-machine/mocks.d.ts.map +1 -1
- package/dist/ai-service/state-machine/mocks.js +0 -17
- package/dist/ai-service/state-machine/mocks.js.map +1 -1
- package/dist/ai-service/types.d.ts +2 -21
- package/dist/ai-service/types.d.ts.map +1 -1
- package/dist/ai-service/types.js.map +1 -1
- package/dist/ai-service/util/archive-extractors.d.ts +52 -0
- package/dist/ai-service/util/archive-extractors.d.ts.map +1 -0
- package/dist/ai-service/util/archive-extractors.js +278 -0
- package/dist/ai-service/util/archive-extractors.js.map +1 -0
- package/dist/codegen.d.ts +1 -22
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +1 -117
- package/dist/codegen.js.map +1 -1
- package/dist/components-manager.d.ts +0 -6
- package/dist/components-manager.d.ts.map +1 -1
- package/dist/components-manager.js +0 -27
- package/dist/components-manager.js.map +1 -1
- package/dist/file-sync-vite-plugin.d.ts.map +1 -1
- package/dist/file-sync-vite-plugin.js +47 -94
- package/dist/file-sync-vite-plugin.js.map +1 -1
- package/dist/file-system-manager.d.ts +2 -15
- package/dist/file-system-manager.d.ts.map +1 -1
- package/dist/file-system-manager.js +16 -128
- package/dist/file-system-manager.js.map +1 -1
- package/dist/git-service/live-branch.d.ts.map +1 -1
- package/dist/git-service/live-branch.js +15 -1
- package/dist/git-service/live-branch.js.map +1 -1
- package/dist/lock-service/index.d.ts.map +1 -1
- package/dist/lock-service/index.js +8 -5
- package/dist/lock-service/index.js.map +1 -1
- package/dist/migration/get-fullstack-template-dir.d.ts +37 -0
- package/dist/migration/get-fullstack-template-dir.d.ts.map +1 -0
- package/dist/migration/get-fullstack-template-dir.js +99 -0
- package/dist/migration/get-fullstack-template-dir.js.map +1 -0
- package/dist/migration/migration-checklist.d.ts +60 -0
- package/dist/migration/migration-checklist.d.ts.map +1 -0
- package/dist/migration/migration-checklist.js +230 -0
- package/dist/migration/migration-checklist.js.map +1 -0
- package/dist/migration/migration-routes.d.ts +23 -0
- package/dist/migration/migration-routes.d.ts.map +1 -0
- package/dist/migration/migration-routes.js +533 -0
- package/dist/migration/migration-routes.js.map +1 -0
- package/dist/migration/restructure.d.ts +76 -0
- package/dist/migration/restructure.d.ts.map +1 -0
- package/dist/migration/restructure.js +446 -0
- package/dist/migration/restructure.js.map +1 -0
- package/dist/migration/translation-prompt.d.ts +22 -0
- package/dist/migration/translation-prompt.d.ts.map +1 -0
- package/dist/migration/translation-prompt.js +27 -0
- package/dist/migration/translation-prompt.js.map +1 -0
- package/dist/migration-templates/app-fullstack/client/App.tsx +17 -0
- package/dist/migration-templates/app-fullstack/client/components/common/sonner.tsx +20 -0
- package/dist/migration-templates/app-fullstack/client/components/hooks/use-active-page.ts +73 -0
- package/dist/migration-templates/app-fullstack/client/components/hooks/use-mobile.ts +21 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/accordion.tsx +197 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/area-chart.tsx +432 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/aspect-ratio.tsx +45 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/avatar.tsx +117 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/badge.tsx +143 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/bar-chart.tsx +390 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/breadcrumb.tsx +259 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/button.tsx +182 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/calendar.tsx +300 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/card.tsx +129 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/chart.tsx +403 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/chat.tsx +2303 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/checkbox.tsx +97 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/code-block-content.tsx +66 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/date-range-picker.tsx +396 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/dialog.tsx +223 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/dropdown-menu.tsx +284 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/file-dropzone.tsx +395 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/file-input.tsx +166 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/hover-card.tsx +162 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/icon.tsx +133 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/image.tsx +68 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/input.tsx +219 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/label.tsx +55 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/line-chart.tsx +380 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/link.tsx +139 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/navigation-menu.tsx +345 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/pagination.tsx +192 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/pie-chart.tsx +295 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/popover.tsx +162 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/progress.tsx +69 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/radar-chart.tsx +386 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/radial-chart.tsx +402 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/scroll-area.tsx +86 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/select.tsx +229 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/separator.tsx +62 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/sheet.tsx +234 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/sidebar.tsx +974 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/skeleton.tsx +13 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/slider.tsx +198 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/switch.tsx +95 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/table.tsx +145 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/tabs.tsx +87 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/textarea.tsx +148 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/toggle-group.tsx +225 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/toggle.tsx +150 -0
- package/dist/migration-templates/app-fullstack/client/components/ui/tooltip.tsx +175 -0
- package/dist/migration-templates/app-fullstack/client/hooks/useApi.ts +25 -0
- package/dist/migration-templates/app-fullstack/client/hooks/useApiData.ts +10 -0
- package/dist/migration-templates/app-fullstack/client/index.css +131 -0
- package/dist/migration-templates/app-fullstack/client/lib/executeApi.ts +9 -0
- package/dist/migration-templates/app-fullstack/client/lib/utils.ts +6 -0
- package/dist/migration-templates/app-fullstack/client/pages/Page1/index.tsx +3 -0
- package/dist/migration-templates/app-fullstack/client/root.tsx +17 -0
- package/dist/migration-templates/app-fullstack/client/router.tsx +48 -0
- package/dist/migration-templates/app-fullstack/client/types/node.d.ts +9 -0
- package/dist/migration-templates/app-fullstack/components.json +21 -0
- package/dist/migration-templates/app-fullstack/eslint.config.js +108 -0
- package/dist/migration-templates/app-fullstack/package.json +89 -0
- package/dist/migration-templates/app-fullstack/server/.gitkeep +0 -0
- package/dist/migration-templates/app-fullstack/server/apis/index.ts +22 -0
- package/dist/migration-templates/app-fullstack/server/index.ts +2 -0
- package/dist/migration-templates/app-fullstack/tsconfig.client.json +27 -0
- package/dist/migration-templates/app-fullstack/tsconfig.eslint.json +8 -0
- package/dist/migration-templates/app-fullstack/tsconfig.json +25 -0
- package/dist/migration-templates/app-fullstack/tsconfig.server.json +13 -0
- package/dist/migration-templates/app-fullstack/vite.config.ts +17 -0
- package/dist/parsing/imports.d.ts +0 -16
- package/dist/parsing/imports.d.ts.map +1 -1
- package/dist/parsing/imports.js +0 -68
- package/dist/parsing/imports.js.map +1 -1
- package/dist/parsing/jsx.d.ts +0 -2
- package/dist/parsing/jsx.d.ts.map +1 -1
- package/dist/parsing/jsx.js +0 -62
- package/dist/parsing/jsx.js.map +1 -1
- package/dist/socket-manager.d.ts.map +1 -1
- package/dist/socket-manager.js +109 -32
- package/dist/socket-manager.js.map +1 -1
- package/dist/source-tracker.d.ts +7 -85
- package/dist/source-tracker.d.ts.map +1 -1
- package/dist/source-tracker.js +19 -695
- package/dist/source-tracker.js.map +1 -1
- package/dist/sync-service/index.d.ts +79 -2
- package/dist/sync-service/index.d.ts.map +1 -1
- package/dist/sync-service/index.js +139 -10
- package/dist/sync-service/index.js.map +1 -1
- package/package.json +11 -9
- package/dist/ai-service/artifacts/bolt.d.ts +0 -8
- package/dist/ai-service/artifacts/bolt.d.ts.map +0 -1
- package/dist/ai-service/artifacts/bolt.js +0 -92
- package/dist/ai-service/artifacts/bolt.js.map +0 -1
- package/dist/ai-service/result-buffer/bolt.d.ts +0 -18
- package/dist/ai-service/result-buffer/bolt.d.ts.map +0 -1
- package/dist/ai-service/result-buffer/bolt.js +0 -100
- package/dist/ai-service/result-buffer/bolt.js.map +0 -1
- package/dist/ai-service/result-buffer/shared.d.ts +0 -17
- package/dist/ai-service/result-buffer/shared.d.ts.map +0 -1
- package/dist/ai-service/result-buffer/shared.js +0 -7
- package/dist/ai-service/result-buffer/shared.js.map +0 -1
- package/dist/inject-no-select.d.ts +0 -15
- package/dist/inject-no-select.d.ts.map +0 -1
- package/dist/inject-no-select.js +0 -175
- package/dist/inject-no-select.js.map +0 -1
package/dist/source-tracker.js
CHANGED
|
@@ -1,31 +1,19 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { parse } from "@babel/parser";
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
3
|
import { format } from "prettier";
|
|
5
4
|
import { normalizePath } from "vite";
|
|
6
|
-
import { isPropertyInfo, splitJSPath, splitJSPathAdvanced, } from "@superblocksteam/library-shared";
|
|
7
|
-
import { generateJSXAttribute, generateJSXElement, writeNestedProperty, } from "./codegen.js";
|
|
8
|
-
import { ComponentsManager } from "./components-manager.js";
|
|
9
5
|
import { generate } from "./generate.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { getRequiredImportsForProperty, EXTERNAL_LIBRARY_OPTIONS, } from "./parsing/imports.js";
|
|
13
|
-
import { getDescriptiveName, getJSXAttributeName, getVariableReferences, } from "./parsing/jsx.js";
|
|
14
|
-
import { getTagName, addImport, extractImportsFromAst, } from "./parsing/util.js";
|
|
15
|
-
import { RenameManager } from "./rename-manager.js";
|
|
6
|
+
import { supplementElementIds } from "./parsing/ids.js";
|
|
7
|
+
import { extractImportsFromAst } from "./parsing/util.js";
|
|
16
8
|
import { getScopeIdFromName } from "./util.js";
|
|
17
9
|
import { getErrorMeta, getLogger } from "./util/logger.js";
|
|
18
|
-
const ATTRIBUTE_TYPES_WITH_STATE_ACCESS = ["COMPUTED", "TEMPLATE", "EVENT"];
|
|
19
10
|
// File Explanation:
|
|
20
11
|
// This file is responsible for tracking the source code of the application.
|
|
21
12
|
// It parses the source code of the application and stores the ASTs of the files.
|
|
22
|
-
// It also tracks the location of JSX elements in the source code.
|
|
23
|
-
// This information is used by the source code editor to provide features like property editing.
|
|
13
|
+
// It also tracks the location of JSX elements in the source code for AI editing.
|
|
24
14
|
export class SourceTracker {
|
|
25
|
-
renameManager = new RenameManager();
|
|
26
15
|
elementToLocation = {};
|
|
27
16
|
elementToFilePath = {};
|
|
28
|
-
newlyAddedCount = 0;
|
|
29
17
|
fileToMeta = {};
|
|
30
18
|
changedFiles = new Set();
|
|
31
19
|
constructor(_tracer) { }
|
|
@@ -77,21 +65,6 @@ export class SourceTracker {
|
|
|
77
65
|
return this.elementToLocation;
|
|
78
66
|
return this.elementToLocation[el];
|
|
79
67
|
}
|
|
80
|
-
setElementToLocation(el, path) {
|
|
81
|
-
this.elementToLocation[el] = path;
|
|
82
|
-
}
|
|
83
|
-
setElementToFilePath(el, filePath) {
|
|
84
|
-
this.elementToFilePath[el] = filePath;
|
|
85
|
-
}
|
|
86
|
-
deleteElementToLocation(el) {
|
|
87
|
-
delete this.elementToLocation[el];
|
|
88
|
-
}
|
|
89
|
-
deleteElementToFilePath(el) {
|
|
90
|
-
delete this.elementToFilePath[el];
|
|
91
|
-
}
|
|
92
|
-
getScopeIdForPage(pageName) {
|
|
93
|
-
return getScopeIdFromName(pageName);
|
|
94
|
-
}
|
|
95
68
|
parseJsxFromEntrypoint({ files, }) {
|
|
96
69
|
const parsedAsts = {};
|
|
97
70
|
for (const { fileName, code } of files) {
|
|
@@ -112,6 +85,18 @@ export class SourceTracker {
|
|
|
112
85
|
}
|
|
113
86
|
return parsedAsts;
|
|
114
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Clears cached element mappings for a specific file so re-indexing
|
|
90
|
+
* cannot retain stale element IDs from previous AST snapshots.
|
|
91
|
+
*/
|
|
92
|
+
clearElementMappingsForFile(fileName) {
|
|
93
|
+
Object.entries(this.elementToFilePath).forEach(([id, mappedFilePath]) => {
|
|
94
|
+
if (mappedFilePath === fileName) {
|
|
95
|
+
delete this.elementToLocation[id];
|
|
96
|
+
delete this.elementToFilePath[id];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
115
100
|
initializeSourceTracker = ({ files }) => {
|
|
116
101
|
const fileContents = Object.entries(files).map(([fileName, code]) => ({
|
|
117
102
|
fileName,
|
|
@@ -129,17 +114,16 @@ export class SourceTracker {
|
|
|
129
114
|
}
|
|
130
115
|
}
|
|
131
116
|
Object.entries(parsedAsts).forEach(([file, ast]) => {
|
|
132
|
-
// we do not need to reparse code we already have but hasnt changed
|
|
133
|
-
if (file in this.fileToMeta &&
|
|
134
|
-
files[file] === this.fileToMeta[file]?.code) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
117
|
this.fileToMeta[file] = {
|
|
138
118
|
code: fileContents.find((f) => f.fileName === file).code,
|
|
139
119
|
ast,
|
|
140
120
|
imports: extractImportsFromAst(ast),
|
|
141
121
|
};
|
|
142
122
|
});
|
|
123
|
+
// Remove prior IDs for files we are about to re-index.
|
|
124
|
+
Object.keys(parsedAsts).forEach((file) => {
|
|
125
|
+
this.clearElementMappingsForFile(file);
|
|
126
|
+
});
|
|
143
127
|
// Parse JSX elements and track their locations
|
|
144
128
|
Object.entries(parsedAsts).forEach(([file, ast]) => {
|
|
145
129
|
const { idMap } = supplementElementIds({
|
|
@@ -153,53 +137,6 @@ export class SourceTracker {
|
|
|
153
137
|
});
|
|
154
138
|
});
|
|
155
139
|
};
|
|
156
|
-
handleNonVisualChangeByDeletingIds = async (fileName, fileContents) => {
|
|
157
|
-
const extension = path.extname(fileName);
|
|
158
|
-
if (extension !== ".ts" && extension !== ".tsx")
|
|
159
|
-
return;
|
|
160
|
-
try {
|
|
161
|
-
const astMap = this.parseJsxFromEntrypoint({
|
|
162
|
-
files: [{ fileName, code: fileContents }],
|
|
163
|
-
});
|
|
164
|
-
const ast = astMap[fileName];
|
|
165
|
-
if (!ast) {
|
|
166
|
-
throw new Error("Failed to parse file " + fileName);
|
|
167
|
-
}
|
|
168
|
-
this.fileToMeta[fileName] = {
|
|
169
|
-
ast: ast,
|
|
170
|
-
code: fileContents,
|
|
171
|
-
imports: extractImportsFromAst(ast),
|
|
172
|
-
};
|
|
173
|
-
// delete all existing elements from the ast cache
|
|
174
|
-
Object.entries(this.elementToLocation)
|
|
175
|
-
.filter(([id]) => {
|
|
176
|
-
const filePath = this.getElementToFilePath(id);
|
|
177
|
-
if (!filePath)
|
|
178
|
-
return false;
|
|
179
|
-
return filePath.startsWith(fileName);
|
|
180
|
-
})
|
|
181
|
-
.forEach(([key]) => {
|
|
182
|
-
delete this.elementToLocation[key];
|
|
183
|
-
delete this.elementToFilePath[key];
|
|
184
|
-
});
|
|
185
|
-
// Parse JSX elements and track their locations
|
|
186
|
-
const { idMap } = supplementElementIds({
|
|
187
|
-
fileName,
|
|
188
|
-
ast,
|
|
189
|
-
shouldModifyAst: false,
|
|
190
|
-
});
|
|
191
|
-
idMap.forEach((path, id) => {
|
|
192
|
-
this.elementToLocation[id] = path;
|
|
193
|
-
this.elementToFilePath[id] = fileName;
|
|
194
|
-
});
|
|
195
|
-
// Mark the file as changed
|
|
196
|
-
this.addChangedFile(fileName);
|
|
197
|
-
}
|
|
198
|
-
catch (e) {
|
|
199
|
-
getLogger().error("Non-visual change parsing error", getErrorMeta(e));
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
140
|
removeFile = (fileName) => {
|
|
204
141
|
delete this.fileToMeta[fileName];
|
|
205
142
|
// Clean up element mappings
|
|
@@ -226,618 +163,5 @@ export class SourceTracker {
|
|
|
226
163
|
// Return the app-level scope ID
|
|
227
164
|
return getScopeIdFromName("App");
|
|
228
165
|
};
|
|
229
|
-
addElement = ({ parentElement, tagName, properties, children, id, scopeName: _scopeName, }) => {
|
|
230
|
-
const logger = getLogger();
|
|
231
|
-
const parentOpeningElementPath = this.getElementToLocation(parentElement.source.id);
|
|
232
|
-
const parentFilepath = this.getElementToFilePath(parentElement.source.id);
|
|
233
|
-
if (!parentOpeningElementPath || !parentFilepath) {
|
|
234
|
-
logger.error(`Element not found in source tracker ${parentElement.source.id} ${parentOpeningElementPath?.toString()}`);
|
|
235
|
-
throw new Error("Element not found in source tracker " + parentElement.source.id);
|
|
236
|
-
}
|
|
237
|
-
if (!parentOpeningElementPath.isJSXOpeningElement()) {
|
|
238
|
-
logger.error(`Parent element is not a JSX element ${parentOpeningElementPath.type} ${parentOpeningElementPath.toString()}`);
|
|
239
|
-
throw new Error("Parent element is not a JSX element");
|
|
240
|
-
}
|
|
241
|
-
const parentJSXElementPath = parentOpeningElementPath.parentPath;
|
|
242
|
-
if (!parentJSXElementPath?.isJSXElement()) {
|
|
243
|
-
logger.error(`Parent element is not a JSX element ${String(parentJSXElementPath)}`);
|
|
244
|
-
throw new Error("Parent element is not a JSX element");
|
|
245
|
-
}
|
|
246
|
-
try {
|
|
247
|
-
const newElement = generateJSXElement({
|
|
248
|
-
id,
|
|
249
|
-
tagName,
|
|
250
|
-
properties,
|
|
251
|
-
children,
|
|
252
|
-
});
|
|
253
|
-
this.transformSelfClosingTagToRegularTag(parentJSXElementPath);
|
|
254
|
-
const { index = -1 } = parentElement.source;
|
|
255
|
-
const elementChildren = parentJSXElementPath
|
|
256
|
-
.get("children")
|
|
257
|
-
.filter((child) => child.isJSXElement());
|
|
258
|
-
let results = null;
|
|
259
|
-
if (index === 0) {
|
|
260
|
-
results = parentJSXElementPath.unshiftContainer("children", newElement);
|
|
261
|
-
}
|
|
262
|
-
else if (index < 0 || index >= elementChildren.length) {
|
|
263
|
-
results = parentJSXElementPath.pushContainer("children", newElement);
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
const child = elementChildren[index];
|
|
267
|
-
if (!child)
|
|
268
|
-
throw new Error("Child element not found");
|
|
269
|
-
results = child.insertBefore(newElement);
|
|
270
|
-
}
|
|
271
|
-
if (!Array.isArray(results)) {
|
|
272
|
-
throw new Error("Failed to add element to parent");
|
|
273
|
-
}
|
|
274
|
-
// You can traverse subpaths like this: https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md#paths-in-visitors
|
|
275
|
-
let sourceId;
|
|
276
|
-
results[0]?.traverse({
|
|
277
|
-
JSXOpeningElement: (path) => {
|
|
278
|
-
if (path.node.name.type !== "JSXIdentifier")
|
|
279
|
-
return;
|
|
280
|
-
const tagName = getTagName(path.node.name);
|
|
281
|
-
if (!tagName)
|
|
282
|
-
return;
|
|
283
|
-
this.newlyAddedCount++;
|
|
284
|
-
const id = getSbElementId(path.node) ??
|
|
285
|
-
`SB-${generatePredictableId(parentFilepath + this.newlyAddedCount)}`;
|
|
286
|
-
setSbElementId(path.node, id);
|
|
287
|
-
this.elementToLocation[id] = path;
|
|
288
|
-
this.elementToFilePath[id] = parentFilepath;
|
|
289
|
-
sourceId = id;
|
|
290
|
-
},
|
|
291
|
-
});
|
|
292
|
-
const manager = ComponentsManager.getInstance();
|
|
293
|
-
if (manager.isCustomComponent(tagName)) {
|
|
294
|
-
const importPath = manager.getComponentImportPath(tagName, process.cwd());
|
|
295
|
-
if (importPath) {
|
|
296
|
-
addImport({
|
|
297
|
-
path: parentOpeningElementPath,
|
|
298
|
-
importName: tagName,
|
|
299
|
-
importPath,
|
|
300
|
-
isDefaultImport: true,
|
|
301
|
-
onAdd: () => {
|
|
302
|
-
this.fileToMeta[parentFilepath].imports[tagName] = importPath;
|
|
303
|
-
},
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
addImport({
|
|
309
|
-
path: parentOpeningElementPath,
|
|
310
|
-
importName: tagName,
|
|
311
|
-
importPath: "@superblocksteam/library",
|
|
312
|
-
onAdd: () => {
|
|
313
|
-
this.fileToMeta[parentFilepath].imports[tagName] =
|
|
314
|
-
"@superblocksteam/library";
|
|
315
|
-
},
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
// We need to add the imports for the properties that are used in the new element
|
|
319
|
-
const requiredImports = this.getAddElementImports({
|
|
320
|
-
properties,
|
|
321
|
-
children,
|
|
322
|
-
});
|
|
323
|
-
requiredImports.forEach(({ importName, importPath, isDefaultImport }) => {
|
|
324
|
-
addImport({
|
|
325
|
-
path: parentOpeningElementPath,
|
|
326
|
-
importName,
|
|
327
|
-
importPath,
|
|
328
|
-
isDefaultImport,
|
|
329
|
-
onAdd: () => {
|
|
330
|
-
this.fileToMeta[parentFilepath].imports[importName] = importPath;
|
|
331
|
-
},
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
this.addChangedFile(parentFilepath);
|
|
335
|
-
return sourceId;
|
|
336
|
-
}
|
|
337
|
-
catch (e) {
|
|
338
|
-
getLogger().error("Error updating source tracker during add", getErrorMeta(e));
|
|
339
|
-
throw new Error("Error updating source tracker during add" + e.message);
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
deleteElement = ({ source, scopeName: _scopeName, }) => {
|
|
343
|
-
const logger = getLogger();
|
|
344
|
-
let openingTag = this.getElementToLocation(source.id);
|
|
345
|
-
if (!openingTag) {
|
|
346
|
-
logger.error(`Element not found in source tracker ${source.id}`);
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
if (openingTag.isJSXOpeningElement()) {
|
|
350
|
-
const parent = openingTag.parentPath;
|
|
351
|
-
if (parent?.isJSXElement()) {
|
|
352
|
-
openingTag = parent;
|
|
353
|
-
}
|
|
354
|
-
else {
|
|
355
|
-
logger.error(`JSXOpeningElement does not have a JSXElement parent ${source.id}`);
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
else if (!openingTag.isJSXElement()) {
|
|
360
|
-
logger.error(`Cannot delete a non-JSX element ${source.id}`);
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
const _componentName = getDescriptiveName(openingTag.node);
|
|
364
|
-
const children = [];
|
|
365
|
-
openingTag.traverse({
|
|
366
|
-
JSXElement: (path) => {
|
|
367
|
-
const sbElementId = getSbElementId(path.get("openingElement").node);
|
|
368
|
-
const name = getDescriptiveName(path.node);
|
|
369
|
-
if (sbElementId) {
|
|
370
|
-
children.push({ id: sbElementId, name });
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
});
|
|
374
|
-
const fileName = this.getElementToFilePath(source.id);
|
|
375
|
-
this.deleteSectionIfOnlyChild(openingTag);
|
|
376
|
-
const wasAssignedToVariable = this.tryDeleteJSXReferenceIfAssigned(openingTag);
|
|
377
|
-
if (!wasAssignedToVariable) {
|
|
378
|
-
openingTag.remove();
|
|
379
|
-
}
|
|
380
|
-
delete this.elementToLocation[source.id];
|
|
381
|
-
delete this.elementToFilePath[source.id];
|
|
382
|
-
// Clean up child element tracking
|
|
383
|
-
children.forEach(({ id }) => {
|
|
384
|
-
delete this.elementToLocation[id];
|
|
385
|
-
delete this.elementToFilePath[id];
|
|
386
|
-
});
|
|
387
|
-
this.addChangedFile(fileName);
|
|
388
|
-
};
|
|
389
|
-
tryDeleteJSXReferenceIfAssigned = (jsxElement) => {
|
|
390
|
-
try {
|
|
391
|
-
// Cases like: const card = <JSX />
|
|
392
|
-
const parentPath = jsxElement.parentPath;
|
|
393
|
-
if (parentPath?.isVariableDeclarator() &&
|
|
394
|
-
parentPath.get("init") === jsxElement) {
|
|
395
|
-
const id = parentPath.get("id");
|
|
396
|
-
if (id.isIdentifier()) {
|
|
397
|
-
const binding = jsxElement.scope.getBinding(id.node.name);
|
|
398
|
-
if (binding) {
|
|
399
|
-
this.removeReferencesUsingBinding(binding);
|
|
400
|
-
return true;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
const scopePath = jsxElement.scope.path;
|
|
405
|
-
const isFunctionParent = scopePath.isArrowFunctionExpression() ||
|
|
406
|
-
scopePath.isFunctionExpression();
|
|
407
|
-
if (!isFunctionParent) {
|
|
408
|
-
return false;
|
|
409
|
-
}
|
|
410
|
-
// Look for function wrapper assignments: const card = useMemo(() => <JSX />, [])
|
|
411
|
-
const allBindings = jsxElement.scope.getAllBindings();
|
|
412
|
-
const matchingBinding = Object.values(allBindings).find((binding) => {
|
|
413
|
-
if (!binding.path.isVariableDeclarator()) {
|
|
414
|
-
return false;
|
|
415
|
-
}
|
|
416
|
-
const init = binding.path.get("init");
|
|
417
|
-
if (init.node &&
|
|
418
|
-
this.isJSXElementInVariableInit(jsxElement, init)) {
|
|
419
|
-
return true;
|
|
420
|
-
}
|
|
421
|
-
return false;
|
|
422
|
-
});
|
|
423
|
-
if (matchingBinding) {
|
|
424
|
-
this.removeReferencesUsingBinding(matchingBinding);
|
|
425
|
-
return true;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
catch (error) {
|
|
429
|
-
console.warn("Binding-based JSX reference deletion failed:", error);
|
|
430
|
-
}
|
|
431
|
-
return false;
|
|
432
|
-
};
|
|
433
|
-
removeReferencesUsingBinding = (binding) => {
|
|
434
|
-
binding.referencePaths.forEach((referencePath) => {
|
|
435
|
-
const parent = referencePath.parentPath;
|
|
436
|
-
if (parent?.isJSXExpressionContainer()) {
|
|
437
|
-
parent.remove();
|
|
438
|
-
}
|
|
439
|
-
else if (parent?.isCallExpression() &&
|
|
440
|
-
parent.parentPath?.isJSXExpressionContainer()) {
|
|
441
|
-
parent.parentPath.remove();
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
};
|
|
445
|
-
// Check if a JSX element is contained within a variable's initializer (e.g., in useMemo, useCallback, etc.)
|
|
446
|
-
isJSXElementInVariableInit = (jsxElement, init) => {
|
|
447
|
-
let found = false;
|
|
448
|
-
// Only check for function calls (like useMemo, useCallback) or short arrow functions
|
|
449
|
-
if (init.isCallExpression()) {
|
|
450
|
-
init.traverse({
|
|
451
|
-
JSXElement(path) {
|
|
452
|
-
if (path === jsxElement) {
|
|
453
|
-
found = true;
|
|
454
|
-
path.stop();
|
|
455
|
-
}
|
|
456
|
-
},
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
else if (init.isArrowFunctionExpression() ||
|
|
460
|
-
init.isFunctionExpression()) {
|
|
461
|
-
const body = init.get("body");
|
|
462
|
-
if (!Array.isArray(body) && body.isJSXElement() && body === jsxElement) {
|
|
463
|
-
found = true;
|
|
464
|
-
}
|
|
465
|
-
else if (!Array.isArray(body) && body.isBlockStatement()) {
|
|
466
|
-
const statements = body.get("body");
|
|
467
|
-
if (Array.isArray(statements) &&
|
|
468
|
-
statements.length === 1 &&
|
|
469
|
-
statements[0]?.isReturnStatement()) {
|
|
470
|
-
const returnArg = statements[0].get("argument");
|
|
471
|
-
if (returnArg === jsxElement) {
|
|
472
|
-
found = true;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
return found;
|
|
478
|
-
};
|
|
479
|
-
// If we're deleting the only Column in an Section, remove the Section
|
|
480
|
-
deleteSectionIfOnlyChild = (openingTag) => {
|
|
481
|
-
const parentElement = openingTag.parentPath;
|
|
482
|
-
if (!parentElement)
|
|
483
|
-
return false;
|
|
484
|
-
const isColumn = getTagName(openingTag.node.openingElement.name) ===
|
|
485
|
-
"Column";
|
|
486
|
-
const isOnlyChild = parentElement.isJSXElement() &&
|
|
487
|
-
parentElement.get("children").filter((child) => child.isJSXElement())
|
|
488
|
-
.length === 1;
|
|
489
|
-
const isParentSection = parentElement.isJSXElement() &&
|
|
490
|
-
getTagName(parentElement.node.openingElement.name) ===
|
|
491
|
-
"Section";
|
|
492
|
-
if (isColumn && isOnlyChild && isParentSection) {
|
|
493
|
-
const sectionId = getSbElementId(parentElement.get("openingElement").node);
|
|
494
|
-
if (sectionId) {
|
|
495
|
-
delete this.elementToLocation[sectionId];
|
|
496
|
-
delete this.elementToFilePath[sectionId];
|
|
497
|
-
parentElement.remove();
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
};
|
|
501
|
-
/**
|
|
502
|
-
* Set's a deeply nested property on a JSX attribute. For example, if you have an attribute that is
|
|
503
|
-
* an object like:
|
|
504
|
-
* ```
|
|
505
|
-
* columns={{
|
|
506
|
-
* name: {
|
|
507
|
-
* accessor: "name",
|
|
508
|
-
* },
|
|
509
|
-
* }}
|
|
510
|
-
* ```
|
|
511
|
-
* And you want to update the `accessor` property, you can use this function to do so, passing a property path like
|
|
512
|
-
* `columns.name.accessor`, rather than the entire columns object.
|
|
513
|
-
*/
|
|
514
|
-
setNestedAttribute = ({ openingTag, property, info, }) => {
|
|
515
|
-
const [parent, ...paths] = splitJSPathAdvanced(property, []);
|
|
516
|
-
let parentAttr = openingTag
|
|
517
|
-
.get("attributes")
|
|
518
|
-
.find((attr) => attr.isJSXAttribute() && attr.node.name.name === parent);
|
|
519
|
-
// If value is undefined, we want to delete the nested property
|
|
520
|
-
if (info.value === undefined) {
|
|
521
|
-
if (!parentAttr) {
|
|
522
|
-
// Property doesn't exist anyway, nothing to delete
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
const expressionContainer = parentAttr?.get("value");
|
|
526
|
-
if (!expressionContainer ||
|
|
527
|
-
!expressionContainer.isJSXExpressionContainer()) {
|
|
528
|
-
// Can't delete from non-object, just return
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
const currentNode = expressionContainer.get("expression");
|
|
532
|
-
writeNestedProperty({
|
|
533
|
-
node: currentNode,
|
|
534
|
-
paths,
|
|
535
|
-
info,
|
|
536
|
-
isDelete: true,
|
|
537
|
-
});
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
540
|
-
if (!parentAttr && parent) {
|
|
541
|
-
const newAttr = openingTag.pushContainer("attributes", [
|
|
542
|
-
t.jsxAttribute(t.jsxIdentifier(parent), t.jSXExpressionContainer(t.objectExpression([]))),
|
|
543
|
-
]);
|
|
544
|
-
parentAttr = newAttr[0];
|
|
545
|
-
}
|
|
546
|
-
const expressionContainer = parentAttr?.get("value");
|
|
547
|
-
if (!expressionContainer ||
|
|
548
|
-
!expressionContainer.isJSXExpressionContainer()) {
|
|
549
|
-
throw new Error("Parent attribute value is not a JSXExpressionContainer");
|
|
550
|
-
}
|
|
551
|
-
const currentNode = expressionContainer.get("expression");
|
|
552
|
-
writeNestedProperty({
|
|
553
|
-
node: currentNode,
|
|
554
|
-
paths,
|
|
555
|
-
info,
|
|
556
|
-
});
|
|
557
|
-
return currentNode.node;
|
|
558
|
-
};
|
|
559
|
-
setAttribute = (openingTag, property, info) => {
|
|
560
|
-
const paths = splitJSPath(property);
|
|
561
|
-
if (Array.isArray(paths) && paths.length > 1) {
|
|
562
|
-
// Sometimes we want to set a nested attribute, like `columns.name.accessor`
|
|
563
|
-
return this.setNestedAttribute({ openingTag, property, info });
|
|
564
|
-
}
|
|
565
|
-
let attr = openingTag
|
|
566
|
-
.get("attributes")
|
|
567
|
-
.find((attr) => attr.isJSXAttribute() && attr.node.name.name === property);
|
|
568
|
-
if (!attr) {
|
|
569
|
-
attr = openingTag.pushContainer("attributes", [
|
|
570
|
-
t.jsxAttribute(t.jsxIdentifier(property), t.stringLiteral("")),
|
|
571
|
-
])[0];
|
|
572
|
-
}
|
|
573
|
-
const value = info.value;
|
|
574
|
-
// We currently delete attributes that are undefined or set to an empty string
|
|
575
|
-
if (value === undefined || (typeof value === "string" && value === "")) {
|
|
576
|
-
attr.remove();
|
|
577
|
-
return;
|
|
578
|
-
}
|
|
579
|
-
const attrName = getJSXAttributeName(attr.node);
|
|
580
|
-
if (attrName === null) {
|
|
581
|
-
throw new Error("Attribute name not found");
|
|
582
|
-
}
|
|
583
|
-
const attrValue = attr.get("value");
|
|
584
|
-
const jsxAttribute = generateJSXAttribute(property, info);
|
|
585
|
-
if (jsxAttribute.value) {
|
|
586
|
-
attrValue.replaceWith(jsxAttribute.value);
|
|
587
|
-
}
|
|
588
|
-
return jsxAttribute;
|
|
589
|
-
};
|
|
590
|
-
deleteAttribute = (openingTag, property) => {
|
|
591
|
-
const attr = openingTag
|
|
592
|
-
.get("attributes")
|
|
593
|
-
.find((attr) => attr.isJSXAttribute() && attr.node.name.name === property);
|
|
594
|
-
attr?.remove();
|
|
595
|
-
};
|
|
596
|
-
transformSelfClosingTagToRegularTag = (element) => {
|
|
597
|
-
const openingElement = element.get("openingElement");
|
|
598
|
-
if (openingElement.node.selfClosing) {
|
|
599
|
-
openingElement.node.selfClosing = false;
|
|
600
|
-
element.node.closingElement = t.jsxClosingElement(openingElement.node.name);
|
|
601
|
-
}
|
|
602
|
-
};
|
|
603
|
-
setJSXChildren = (jsxElement, info) => {
|
|
604
|
-
const logger = getLogger();
|
|
605
|
-
try {
|
|
606
|
-
// Ensure the element is not self-closing
|
|
607
|
-
this.transformSelfClosingTagToRegularTag(jsxElement);
|
|
608
|
-
// Clear existing children
|
|
609
|
-
jsxElement.node.children = [];
|
|
610
|
-
// Handle different types of children content
|
|
611
|
-
if (info.type === "STATIC" && typeof info.value === "string") {
|
|
612
|
-
// For string children, create a text node
|
|
613
|
-
if (info.value.trim() !== "") {
|
|
614
|
-
jsxElement.node.children = [t.jsxText(info.value)];
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
else {
|
|
618
|
-
console.warn("setting non-static string children is not supported");
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
catch (e) {
|
|
622
|
-
logger.error("Error setting JSX children", getErrorMeta(e));
|
|
623
|
-
}
|
|
624
|
-
};
|
|
625
|
-
setProperty = ({ source, property, info, }) => {
|
|
626
|
-
this.setProperties({
|
|
627
|
-
source,
|
|
628
|
-
changes: { [property]: info },
|
|
629
|
-
});
|
|
630
|
-
};
|
|
631
|
-
setProperties = ({ source, changes, }) => {
|
|
632
|
-
const logger = getLogger();
|
|
633
|
-
if (Object.keys(changes).length === 0)
|
|
634
|
-
return;
|
|
635
|
-
try {
|
|
636
|
-
let openingTag = this.getElementToLocation(source.id);
|
|
637
|
-
if (openingTag?.isJSXElement()) {
|
|
638
|
-
openingTag = openingTag.get("openingElement");
|
|
639
|
-
}
|
|
640
|
-
const fileName = this.getElementToFilePath(source.id);
|
|
641
|
-
if (!fileName) {
|
|
642
|
-
logger.error(`Filepath not found for element ${source.id} ${openingTag}`);
|
|
643
|
-
throw new Error(`Filepath not found for element ${source.id}`);
|
|
644
|
-
}
|
|
645
|
-
const currentFile = this.fileToMeta[fileName];
|
|
646
|
-
if (!currentFile || !openingTag) {
|
|
647
|
-
throw new Error(`Element ${source.id} not found in source tracker`);
|
|
648
|
-
}
|
|
649
|
-
if (!openingTag.isJSXOpeningElement()) {
|
|
650
|
-
throw new Error(`Element ${source.id} is not a JSXOpeningElement`);
|
|
651
|
-
}
|
|
652
|
-
// Get the JSX element to handle children
|
|
653
|
-
let jsxElement = this.getElementToLocation(source.id);
|
|
654
|
-
if (jsxElement?.isJSXOpeningElement()) {
|
|
655
|
-
jsxElement = jsxElement.parentPath;
|
|
656
|
-
}
|
|
657
|
-
// Iterate over the changes and set each attribute using the helper
|
|
658
|
-
for (const [key, info] of Object.entries(changes)) {
|
|
659
|
-
// Special handling for children property
|
|
660
|
-
if (key === "children") {
|
|
661
|
-
const childrenAttribute = openingTag
|
|
662
|
-
.get("attributes")
|
|
663
|
-
.find((attr) => attr.isJSXAttribute() && attr.node.name.name === "children");
|
|
664
|
-
const jsxChildrenExists = jsxElement.isJSXElement() && jsxElement.node.children.length > 0;
|
|
665
|
-
// We always set the jsx children UNLESS children exists as an attribute and there are no current jsx children
|
|
666
|
-
if (jsxChildrenExists || !childrenAttribute) {
|
|
667
|
-
this.setJSXChildren(jsxElement, info);
|
|
668
|
-
if (childrenAttribute) {
|
|
669
|
-
childrenAttribute.remove();
|
|
670
|
-
}
|
|
671
|
-
continue;
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
const jsxAttribute = this.setAttribute(openingTag, key, info);
|
|
675
|
-
const imports = getRequiredImportsForProperty(info);
|
|
676
|
-
if (imports.length > 0) {
|
|
677
|
-
for (const { importName, importPath } of imports) {
|
|
678
|
-
if (!this.fileToMeta[fileName].imports[importName]) {
|
|
679
|
-
addImport({
|
|
680
|
-
importPath,
|
|
681
|
-
importName,
|
|
682
|
-
path: openingTag,
|
|
683
|
-
onAdd: () => {
|
|
684
|
-
this.fileToMeta[fileName].imports[importName] = importPath;
|
|
685
|
-
},
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
if (ATTRIBUTE_TYPES_WITH_STATE_ACCESS.includes(info.type) &&
|
|
691
|
-
jsxAttribute) {
|
|
692
|
-
// Add external library imports (but not scope imports)
|
|
693
|
-
for (const externalLibrary of EXTERNAL_LIBRARY_OPTIONS) {
|
|
694
|
-
const referencedGlobalFunctions = getVariableReferences(jsxAttribute, externalLibrary.imports).map((funcName) => {
|
|
695
|
-
return {
|
|
696
|
-
importPath: externalLibrary.library,
|
|
697
|
-
importName: funcName,
|
|
698
|
-
};
|
|
699
|
-
});
|
|
700
|
-
referencedGlobalFunctions.forEach(({ importPath, importName }) => {
|
|
701
|
-
addImport({
|
|
702
|
-
importPath,
|
|
703
|
-
importName,
|
|
704
|
-
path: openingTag,
|
|
705
|
-
onAdd: () => {
|
|
706
|
-
this.fileToMeta[fileName].imports[importName] = importPath;
|
|
707
|
-
},
|
|
708
|
-
});
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
this.addChangedFile(fileName);
|
|
714
|
-
}
|
|
715
|
-
catch (e) {
|
|
716
|
-
logger.error("Error setting property", getErrorMeta(e));
|
|
717
|
-
}
|
|
718
|
-
};
|
|
719
|
-
deleteProperties = async ({ source, properties, }) => {
|
|
720
|
-
const logger = getLogger();
|
|
721
|
-
try {
|
|
722
|
-
let openingTag = this.elementToLocation[source.id];
|
|
723
|
-
if (openingTag?.isJSXElement()) {
|
|
724
|
-
openingTag = openingTag.get("openingElement");
|
|
725
|
-
}
|
|
726
|
-
const fileName = this.getElementToFilePath(source.id);
|
|
727
|
-
if (!fileName) {
|
|
728
|
-
logger.error(`Filepath not found for element ${source.id} ${openingTag}`);
|
|
729
|
-
throw new Error(`Filepath not found for element ${source.id}`);
|
|
730
|
-
}
|
|
731
|
-
const currentFile = this.fileToMeta[fileName];
|
|
732
|
-
if (!currentFile || !openingTag) {
|
|
733
|
-
throw new Error(`Element ${source.id} not found in source tracker`);
|
|
734
|
-
}
|
|
735
|
-
if (!openingTag.isJSXOpeningElement()) {
|
|
736
|
-
throw new Error(`Element ${source.id} is not a JSXOpeningElement`);
|
|
737
|
-
}
|
|
738
|
-
for (const property of properties) {
|
|
739
|
-
this.deleteAttribute(openingTag, property);
|
|
740
|
-
}
|
|
741
|
-
this.addChangedFile(fileName);
|
|
742
|
-
}
|
|
743
|
-
catch (e) {
|
|
744
|
-
logger.error("Error deleting properties", getErrorMeta(e));
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
renameComponent = async ({ widgetSourceId, newName, oldName: _oldName, renameInAst = true, }) => {
|
|
748
|
-
const filePath = this.getElementToFilePath(widgetSourceId);
|
|
749
|
-
const currentFile = this.fileToMeta[filePath];
|
|
750
|
-
if (!currentFile || !currentFile.ast) {
|
|
751
|
-
throw new Error(`File not found for element ${filePath}`);
|
|
752
|
-
}
|
|
753
|
-
let widgetNode = this.getElementToLocation(widgetSourceId);
|
|
754
|
-
if (!widgetNode) {
|
|
755
|
-
throw new Error(`Widget ${widgetSourceId} not found`);
|
|
756
|
-
}
|
|
757
|
-
if (widgetNode?.isJSXElement()) {
|
|
758
|
-
widgetNode = widgetNode.get("openingElement");
|
|
759
|
-
}
|
|
760
|
-
await this.renameManager.renameComponent({
|
|
761
|
-
widgetNode: widgetNode,
|
|
762
|
-
newName,
|
|
763
|
-
ast: currentFile.ast,
|
|
764
|
-
renameInAst,
|
|
765
|
-
});
|
|
766
|
-
this.addChangedFile(filePath);
|
|
767
|
-
};
|
|
768
|
-
renameIdentifier = ({ oldName, newName, filePath, parentBinding, }) => {
|
|
769
|
-
const currentFile = this.fileToMeta[filePath];
|
|
770
|
-
if (!currentFile || !currentFile.ast) {
|
|
771
|
-
throw new Error(`File not found for element ${filePath}`);
|
|
772
|
-
}
|
|
773
|
-
const imports = extractImportsFromAst(currentFile.ast);
|
|
774
|
-
if (newName in imports) {
|
|
775
|
-
throw new Error(`Cannot rename identifier ${oldName} to ${newName} because it has a naming collision with an existing import in file ${filePath}`);
|
|
776
|
-
}
|
|
777
|
-
this.renameManager.renameIdentifierInAST({
|
|
778
|
-
oldName,
|
|
779
|
-
newName,
|
|
780
|
-
ast: currentFile.ast,
|
|
781
|
-
parentBinding,
|
|
782
|
-
});
|
|
783
|
-
this.addChangedFile(filePath);
|
|
784
|
-
};
|
|
785
|
-
getAddElementImports = ({ properties, children, }) => {
|
|
786
|
-
const componentsManager = ComponentsManager.getInstance();
|
|
787
|
-
const getPropertyImports = (properties) => {
|
|
788
|
-
return Object.values(properties)
|
|
789
|
-
.flatMap((property) => {
|
|
790
|
-
if (property.type === "DIMENSION") {
|
|
791
|
-
return {
|
|
792
|
-
importPath: "@superblocksteam/library",
|
|
793
|
-
importName: "Dim",
|
|
794
|
-
};
|
|
795
|
-
}
|
|
796
|
-
if (property.type === "BINDING") {
|
|
797
|
-
return { importPath: "@superblocksteam/library", importName: "SB" };
|
|
798
|
-
}
|
|
799
|
-
if (property.type === "STATIC" &&
|
|
800
|
-
typeof property.value === "object" &&
|
|
801
|
-
property.value != null) {
|
|
802
|
-
// Object.entries works on arrays as well, so we dont need to special case them for just finding property values
|
|
803
|
-
const staticProperties = Object.fromEntries(Object.entries(property.value).filter(([_, value]) => isPropertyInfo(value)));
|
|
804
|
-
return getPropertyImports(staticProperties);
|
|
805
|
-
}
|
|
806
|
-
return null;
|
|
807
|
-
})
|
|
808
|
-
.filter(Boolean);
|
|
809
|
-
};
|
|
810
|
-
const getComponentImports = (children) => {
|
|
811
|
-
return children.flatMap((child) => {
|
|
812
|
-
let defaultPath = "@superblocksteam/library";
|
|
813
|
-
const isCustomComponent = componentsManager.isCustomComponent(child.tagName);
|
|
814
|
-
if (isCustomComponent) {
|
|
815
|
-
const componentPath = componentsManager.getComponentImportPath(child.tagName, process.cwd());
|
|
816
|
-
if (componentPath) {
|
|
817
|
-
defaultPath = componentPath;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
return [
|
|
821
|
-
{
|
|
822
|
-
importPath: defaultPath,
|
|
823
|
-
importName: child.tagName,
|
|
824
|
-
isDefaultImport: isCustomComponent,
|
|
825
|
-
},
|
|
826
|
-
...getPropertyImports(child.properties),
|
|
827
|
-
...getComponentImports(child.children),
|
|
828
|
-
];
|
|
829
|
-
});
|
|
830
|
-
};
|
|
831
|
-
const requiredPropertyImports = getPropertyImports(properties);
|
|
832
|
-
const requiredComponentImports = getComponentImports(children);
|
|
833
|
-
const seen = new Set();
|
|
834
|
-
return [...requiredPropertyImports, ...requiredComponentImports].filter((i) => {
|
|
835
|
-
if (seen.has(i.importName)) {
|
|
836
|
-
return false;
|
|
837
|
-
}
|
|
838
|
-
seen.add(i.importName);
|
|
839
|
-
return true;
|
|
840
|
-
});
|
|
841
|
-
};
|
|
842
166
|
}
|
|
843
167
|
//# sourceMappingURL=source-tracker.js.map
|