@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.
Files changed (355) hide show
  1. package/dist/ai-service/agent/middleware.d.ts.map +1 -1
  2. package/dist/ai-service/agent/middleware.js +19 -0
  3. package/dist/ai-service/agent/middleware.js.map +1 -1
  4. package/dist/ai-service/agent/prompts/api-prompts.d.ts.map +1 -1
  5. package/dist/ai-service/agent/prompts/api-prompts.js +13 -17
  6. package/dist/ai-service/agent/prompts/api-prompts.js.map +1 -1
  7. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
  8. package/dist/ai-service/agent/prompts/build-base-system-prompt.js +22 -3
  9. package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
  10. package/dist/ai-service/agent/subagents/coding/prompt-builder.d.ts +16 -0
  11. package/dist/ai-service/agent/subagents/coding/prompt-builder.d.ts.map +1 -0
  12. package/dist/ai-service/agent/subagents/coding/prompt-builder.js +30 -0
  13. package/dist/ai-service/agent/subagents/coding/prompt-builder.js.map +1 -0
  14. package/dist/ai-service/agent/subagents/coding/run-coding-subagent.d.ts +29 -0
  15. package/dist/ai-service/agent/subagents/coding/run-coding-subagent.d.ts.map +1 -0
  16. package/dist/ai-service/agent/subagents/coding/run-coding-subagent.js +108 -0
  17. package/dist/ai-service/agent/subagents/coding/run-coding-subagent.js.map +1 -0
  18. package/dist/ai-service/agent/subagents/types.d.ts +9 -1
  19. package/dist/ai-service/agent/subagents/types.d.ts.map +1 -1
  20. package/dist/ai-service/agent/subagents/types.js +8 -0
  21. package/dist/ai-service/agent/subagents/types.js.map +1 -1
  22. package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
  23. package/dist/ai-service/agent/tool-message-utils.js +5 -0
  24. package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
  25. package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.d.ts.map +1 -1
  26. package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js +2 -1
  27. package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js.map +1 -1
  28. package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.d.ts +6 -0
  29. package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.d.ts.map +1 -0
  30. package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.js +138 -0
  31. package/dist/ai-service/agent/tools/apis/get-sdk-api-docs.js.map +1 -0
  32. package/dist/ai-service/agent/tools/build-finalize.d.ts.map +1 -1
  33. package/dist/ai-service/agent/tools/build-finalize.js +39 -15
  34. package/dist/ai-service/agent/tools/build-finalize.js.map +1 -1
  35. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +6 -3
  36. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts.map +1 -1
  37. package/dist/ai-service/agent/tools/build-manage-checklist.js +116 -49
  38. package/dist/ai-service/agent/tools/build-manage-checklist.js.map +1 -1
  39. package/dist/ai-service/agent/tools/index.d.ts +2 -0
  40. package/dist/ai-service/agent/tools/index.d.ts.map +1 -1
  41. package/dist/ai-service/agent/tools/index.js +2 -0
  42. package/dist/ai-service/agent/tools/index.js.map +1 -1
  43. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +3 -0
  44. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts.map +1 -1
  45. package/dist/ai-service/agent/tools/integrations/execute-request.js +330 -204
  46. package/dist/ai-service/agent/tools/integrations/execute-request.js.map +1 -1
  47. package/dist/ai-service/agent/tools.d.ts.map +1 -1
  48. package/dist/ai-service/agent/tools.js +40 -2
  49. package/dist/ai-service/agent/tools.js.map +1 -1
  50. package/dist/ai-service/agent/tools2/access-control.d.ts +1 -1
  51. package/dist/ai-service/agent/tools2/access-control.d.ts.map +1 -1
  52. package/dist/ai-service/agent/tools2/access-control.js +15 -4
  53. package/dist/ai-service/agent/tools2/access-control.js.map +1 -1
  54. package/dist/ai-service/agent/tools2/registry.d.ts +3 -0
  55. package/dist/ai-service/agent/tools2/registry.d.ts.map +1 -1
  56. package/dist/ai-service/agent/tools2/registry.js +50 -8
  57. package/dist/ai-service/agent/tools2/registry.js.map +1 -1
  58. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.d.ts.map +1 -1
  59. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.js +3 -2
  60. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.js.map +1 -1
  61. package/dist/ai-service/agent/tools2/tools/ask-searchable-dropdown.d.ts.map +1 -1
  62. package/dist/ai-service/agent/tools2/tools/ask-searchable-dropdown.js +2 -1
  63. package/dist/ai-service/agent/tools2/tools/ask-searchable-dropdown.js.map +1 -1
  64. package/dist/ai-service/agent/tools2/tools/deploy-service.d.ts +16 -0
  65. package/dist/ai-service/agent/tools2/tools/deploy-service.d.ts.map +1 -0
  66. package/dist/ai-service/agent/tools2/tools/deploy-service.js +135 -0
  67. package/dist/ai-service/agent/tools2/tools/deploy-service.js.map +1 -0
  68. package/dist/ai-service/agent/tools2/tools/download-attachments.d.ts +33 -0
  69. package/dist/ai-service/agent/tools2/tools/download-attachments.d.ts.map +1 -0
  70. package/dist/ai-service/agent/tools2/tools/download-attachments.js +308 -0
  71. package/dist/ai-service/agent/tools2/tools/download-attachments.js.map +1 -0
  72. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -1
  73. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +8 -4
  74. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -1
  75. package/dist/ai-service/agent/tools2/tools/git.d.ts +57 -1
  76. package/dist/ai-service/agent/tools2/tools/git.d.ts.map +1 -1
  77. package/dist/ai-service/agent/tools2/tools/git.js +275 -8
  78. package/dist/ai-service/agent/tools2/tools/git.js.map +1 -1
  79. package/dist/ai-service/agent/tools2/tools/index.d.ts +2 -1
  80. package/dist/ai-service/agent/tools2/tools/index.d.ts.map +1 -1
  81. package/dist/ai-service/agent/tools2/tools/index.js +2 -1
  82. package/dist/ai-service/agent/tools2/tools/index.js.map +1 -1
  83. package/dist/ai-service/agent/tools2/tools/list-attachments.d.ts +4 -1
  84. package/dist/ai-service/agent/tools2/tools/list-attachments.d.ts.map +1 -1
  85. package/dist/ai-service/agent/tools2/tools/list-attachments.js +20 -4
  86. package/dist/ai-service/agent/tools2/tools/list-attachments.js.map +1 -1
  87. package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.d.ts +28 -0
  88. package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.d.ts.map +1 -0
  89. package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.js +152 -0
  90. package/dist/ai-service/agent/tools2/tools/spawn-coding-subagents.js.map +1 -0
  91. package/dist/ai-service/agent/tools2/types.d.ts +1 -18
  92. package/dist/ai-service/agent/tools2/types.d.ts.map +1 -1
  93. package/dist/ai-service/agent/tools2/types.js.map +1 -1
  94. package/dist/ai-service/agent/utils.d.ts.map +1 -1
  95. package/dist/ai-service/agent/utils.js +22 -5
  96. package/dist/ai-service/agent/utils.js.map +1 -1
  97. package/dist/ai-service/app-interface/file-system-interface.d.ts +0 -4
  98. package/dist/ai-service/app-interface/file-system-interface.d.ts.map +1 -1
  99. package/dist/ai-service/app-interface/file-system-interface.js +0 -21
  100. package/dist/ai-service/app-interface/file-system-interface.js.map +1 -1
  101. package/dist/ai-service/app-interface/filesystem/virtual-file-system.d.ts +11 -1
  102. package/dist/ai-service/app-interface/filesystem/virtual-file-system.d.ts.map +1 -1
  103. package/dist/ai-service/app-interface/filesystem/virtual-file-system.js +29 -7
  104. package/dist/ai-service/app-interface/filesystem/virtual-file-system.js.map +1 -1
  105. package/dist/ai-service/app-interface/shell.d.ts +6 -0
  106. package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
  107. package/dist/ai-service/app-interface/shell.js +8 -0
  108. package/dist/ai-service/app-interface/shell.js.map +1 -1
  109. package/dist/ai-service/app-skills/helpers.d.ts.map +1 -1
  110. package/dist/ai-service/app-skills/helpers.js +4 -2
  111. package/dist/ai-service/app-skills/helpers.js.map +1 -1
  112. package/dist/ai-service/attachments/store.d.ts +18 -2
  113. package/dist/ai-service/attachments/store.d.ts.map +1 -1
  114. package/dist/ai-service/attachments/store.js +102 -9
  115. package/dist/ai-service/attachments/store.js.map +1 -1
  116. package/dist/ai-service/attachments/uploaded-content-part.d.ts +5 -2
  117. package/dist/ai-service/attachments/uploaded-content-part.d.ts.map +1 -1
  118. package/dist/ai-service/attachments/uploaded-content-part.js +32 -0
  119. package/dist/ai-service/attachments/uploaded-content-part.js.map +1 -1
  120. package/dist/ai-service/chat/chat-session-store.d.ts +2 -2
  121. package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
  122. package/dist/ai-service/chat/chat-session-store.js +45 -243
  123. package/dist/ai-service/chat/chat-session-store.js.map +1 -1
  124. package/dist/ai-service/chat/utils.d.ts +6 -0
  125. package/dist/ai-service/chat/utils.d.ts.map +1 -1
  126. package/dist/ai-service/chat/utils.js +47 -0
  127. package/dist/ai-service/chat/utils.js.map +1 -1
  128. package/dist/ai-service/features.d.ts +4 -0
  129. package/dist/ai-service/features.d.ts.map +1 -1
  130. package/dist/ai-service/features.js +4 -0
  131. package/dist/ai-service/features.js.map +1 -1
  132. package/dist/ai-service/index.d.ts +36 -11
  133. package/dist/ai-service/index.d.ts.map +1 -1
  134. package/dist/ai-service/index.js +228 -68
  135. package/dist/ai-service/index.js.map +1 -1
  136. package/dist/ai-service/judge/tools/playwright-action.d.ts +1 -1
  137. package/dist/ai-service/llm/client.d.ts.map +1 -1
  138. package/dist/ai-service/llm/client.js +4 -2
  139. package/dist/ai-service/llm/client.js.map +1 -1
  140. package/dist/ai-service/llm/stream/observers/retry-notification.d.ts.map +1 -1
  141. package/dist/ai-service/llm/stream/observers/retry-notification.js +4 -2
  142. package/dist/ai-service/llm/stream/observers/retry-notification.js.map +1 -1
  143. package/dist/ai-service/prompt-builder-service/classifiers/prompt-interpret-task.d.ts.map +1 -1
  144. package/dist/ai-service/prompt-builder-service/classifiers/prompt-interpret-task.js +1 -16
  145. package/dist/ai-service/prompt-builder-service/classifiers/prompt-interpret-task.js.map +1 -1
  146. package/dist/ai-service/prompt-builder-service/types.d.ts +2 -13
  147. package/dist/ai-service/prompt-builder-service/types.d.ts.map +1 -1
  148. package/dist/ai-service/prompt-builder-service/types.js.map +1 -1
  149. package/dist/ai-service/skills/system/_registry.generated.d.ts.map +1 -1
  150. package/dist/ai-service/skills/system/_registry.generated.js +6 -0
  151. package/dist/ai-service/skills/system/_registry.generated.js.map +1 -1
  152. package/dist/ai-service/skills/system/superblocks-migration/references/focused-debug.generated.d.ts +2 -0
  153. package/dist/ai-service/skills/system/superblocks-migration/references/focused-debug.generated.d.ts.map +1 -0
  154. package/dist/ai-service/skills/system/superblocks-migration/references/focused-debug.generated.js +58 -0
  155. package/dist/ai-service/skills/system/superblocks-migration/references/focused-debug.generated.js.map +1 -0
  156. package/dist/ai-service/skills/system/superblocks-migration/references/yaml-block-mapping.generated.d.ts +2 -0
  157. package/dist/ai-service/skills/system/superblocks-migration/references/yaml-block-mapping.generated.d.ts.map +1 -0
  158. package/dist/ai-service/skills/system/superblocks-migration/references/yaml-block-mapping.generated.js +107 -0
  159. package/dist/ai-service/skills/system/superblocks-migration/references/yaml-block-mapping.generated.js.map +1 -0
  160. package/dist/ai-service/skills/system/superblocks-migration/skill.generated.d.ts +2 -0
  161. package/dist/ai-service/skills/system/superblocks-migration/skill.generated.d.ts.map +1 -0
  162. package/dist/ai-service/skills/system/superblocks-migration/skill.generated.js +137 -0
  163. package/dist/ai-service/skills/system/superblocks-migration/skill.generated.js.map +1 -0
  164. package/dist/ai-service/state-machine/clark-fsm.d.ts +26 -13
  165. package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
  166. package/dist/ai-service/state-machine/clark-fsm.js +12 -7
  167. package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
  168. package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
  169. package/dist/ai-service/state-machine/handlers/agent-planning.js +76 -27
  170. package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
  171. package/dist/ai-service/state-machine/handlers/awaiting-user.d.ts.map +1 -1
  172. package/dist/ai-service/state-machine/handlers/awaiting-user.js +15 -6
  173. package/dist/ai-service/state-machine/handlers/awaiting-user.js.map +1 -1
  174. package/dist/ai-service/state-machine/handlers/idle.d.ts.map +1 -1
  175. package/dist/ai-service/state-machine/handlers/idle.js +4 -2
  176. package/dist/ai-service/state-machine/handlers/idle.js.map +1 -1
  177. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
  178. package/dist/ai-service/state-machine/handlers/llm-generating.js +48 -15
  179. package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
  180. package/dist/ai-service/state-machine/handlers/post-processing.d.ts +1 -1
  181. package/dist/ai-service/state-machine/handlers/post-processing.d.ts.map +1 -1
  182. package/dist/ai-service/state-machine/handlers/post-processing.js +23 -151
  183. package/dist/ai-service/state-machine/handlers/post-processing.js.map +1 -1
  184. package/dist/ai-service/state-machine/handlers/runtime-reviewing.d.ts.map +1 -1
  185. package/dist/ai-service/state-machine/handlers/runtime-reviewing.js +16 -8
  186. package/dist/ai-service/state-machine/handlers/runtime-reviewing.js.map +1 -1
  187. package/dist/ai-service/state-machine/helpers/change-info.d.ts.map +1 -1
  188. package/dist/ai-service/state-machine/helpers/change-info.js +2 -15
  189. package/dist/ai-service/state-machine/helpers/change-info.js.map +1 -1
  190. package/dist/ai-service/state-machine/helpers/peer.d.ts +3 -3
  191. package/dist/ai-service/state-machine/helpers/peer.d.ts.map +1 -1
  192. package/dist/ai-service/state-machine/helpers/peer.js +9 -23
  193. package/dist/ai-service/state-machine/helpers/peer.js.map +1 -1
  194. package/dist/ai-service/state-machine/helpers/stable-peer.d.ts +52 -0
  195. package/dist/ai-service/state-machine/helpers/stable-peer.d.ts.map +1 -0
  196. package/dist/ai-service/state-machine/helpers/stable-peer.js +141 -0
  197. package/dist/ai-service/state-machine/helpers/stable-peer.js.map +1 -0
  198. package/dist/ai-service/state-machine/mocks.d.ts.map +1 -1
  199. package/dist/ai-service/state-machine/mocks.js +0 -17
  200. package/dist/ai-service/state-machine/mocks.js.map +1 -1
  201. package/dist/ai-service/types.d.ts +2 -21
  202. package/dist/ai-service/types.d.ts.map +1 -1
  203. package/dist/ai-service/types.js.map +1 -1
  204. package/dist/ai-service/util/archive-extractors.d.ts +52 -0
  205. package/dist/ai-service/util/archive-extractors.d.ts.map +1 -0
  206. package/dist/ai-service/util/archive-extractors.js +278 -0
  207. package/dist/ai-service/util/archive-extractors.js.map +1 -0
  208. package/dist/codegen.d.ts +1 -22
  209. package/dist/codegen.d.ts.map +1 -1
  210. package/dist/codegen.js +1 -117
  211. package/dist/codegen.js.map +1 -1
  212. package/dist/components-manager.d.ts +0 -6
  213. package/dist/components-manager.d.ts.map +1 -1
  214. package/dist/components-manager.js +0 -27
  215. package/dist/components-manager.js.map +1 -1
  216. package/dist/file-sync-vite-plugin.d.ts.map +1 -1
  217. package/dist/file-sync-vite-plugin.js +47 -94
  218. package/dist/file-sync-vite-plugin.js.map +1 -1
  219. package/dist/file-system-manager.d.ts +2 -15
  220. package/dist/file-system-manager.d.ts.map +1 -1
  221. package/dist/file-system-manager.js +16 -128
  222. package/dist/file-system-manager.js.map +1 -1
  223. package/dist/git-service/live-branch.d.ts.map +1 -1
  224. package/dist/git-service/live-branch.js +15 -1
  225. package/dist/git-service/live-branch.js.map +1 -1
  226. package/dist/lock-service/index.d.ts.map +1 -1
  227. package/dist/lock-service/index.js +8 -5
  228. package/dist/lock-service/index.js.map +1 -1
  229. package/dist/migration/get-fullstack-template-dir.d.ts +37 -0
  230. package/dist/migration/get-fullstack-template-dir.d.ts.map +1 -0
  231. package/dist/migration/get-fullstack-template-dir.js +99 -0
  232. package/dist/migration/get-fullstack-template-dir.js.map +1 -0
  233. package/dist/migration/migration-checklist.d.ts +60 -0
  234. package/dist/migration/migration-checklist.d.ts.map +1 -0
  235. package/dist/migration/migration-checklist.js +230 -0
  236. package/dist/migration/migration-checklist.js.map +1 -0
  237. package/dist/migration/migration-routes.d.ts +23 -0
  238. package/dist/migration/migration-routes.d.ts.map +1 -0
  239. package/dist/migration/migration-routes.js +533 -0
  240. package/dist/migration/migration-routes.js.map +1 -0
  241. package/dist/migration/restructure.d.ts +76 -0
  242. package/dist/migration/restructure.d.ts.map +1 -0
  243. package/dist/migration/restructure.js +446 -0
  244. package/dist/migration/restructure.js.map +1 -0
  245. package/dist/migration/translation-prompt.d.ts +22 -0
  246. package/dist/migration/translation-prompt.d.ts.map +1 -0
  247. package/dist/migration/translation-prompt.js +27 -0
  248. package/dist/migration/translation-prompt.js.map +1 -0
  249. package/dist/migration-templates/app-fullstack/client/App.tsx +17 -0
  250. package/dist/migration-templates/app-fullstack/client/components/common/sonner.tsx +20 -0
  251. package/dist/migration-templates/app-fullstack/client/components/hooks/use-active-page.ts +73 -0
  252. package/dist/migration-templates/app-fullstack/client/components/hooks/use-mobile.ts +21 -0
  253. package/dist/migration-templates/app-fullstack/client/components/ui/accordion.tsx +197 -0
  254. package/dist/migration-templates/app-fullstack/client/components/ui/area-chart.tsx +432 -0
  255. package/dist/migration-templates/app-fullstack/client/components/ui/aspect-ratio.tsx +45 -0
  256. package/dist/migration-templates/app-fullstack/client/components/ui/avatar.tsx +117 -0
  257. package/dist/migration-templates/app-fullstack/client/components/ui/badge.tsx +143 -0
  258. package/dist/migration-templates/app-fullstack/client/components/ui/bar-chart.tsx +390 -0
  259. package/dist/migration-templates/app-fullstack/client/components/ui/breadcrumb.tsx +259 -0
  260. package/dist/migration-templates/app-fullstack/client/components/ui/button.tsx +182 -0
  261. package/dist/migration-templates/app-fullstack/client/components/ui/calendar.tsx +300 -0
  262. package/dist/migration-templates/app-fullstack/client/components/ui/card.tsx +129 -0
  263. package/dist/migration-templates/app-fullstack/client/components/ui/chart.tsx +403 -0
  264. package/dist/migration-templates/app-fullstack/client/components/ui/chat.tsx +2303 -0
  265. package/dist/migration-templates/app-fullstack/client/components/ui/checkbox.tsx +97 -0
  266. package/dist/migration-templates/app-fullstack/client/components/ui/code-block-content.tsx +66 -0
  267. package/dist/migration-templates/app-fullstack/client/components/ui/date-range-picker.tsx +396 -0
  268. package/dist/migration-templates/app-fullstack/client/components/ui/dialog.tsx +223 -0
  269. package/dist/migration-templates/app-fullstack/client/components/ui/dropdown-menu.tsx +284 -0
  270. package/dist/migration-templates/app-fullstack/client/components/ui/file-dropzone.tsx +395 -0
  271. package/dist/migration-templates/app-fullstack/client/components/ui/file-input.tsx +166 -0
  272. package/dist/migration-templates/app-fullstack/client/components/ui/hover-card.tsx +162 -0
  273. package/dist/migration-templates/app-fullstack/client/components/ui/icon.tsx +133 -0
  274. package/dist/migration-templates/app-fullstack/client/components/ui/image.tsx +68 -0
  275. package/dist/migration-templates/app-fullstack/client/components/ui/input.tsx +219 -0
  276. package/dist/migration-templates/app-fullstack/client/components/ui/label.tsx +55 -0
  277. package/dist/migration-templates/app-fullstack/client/components/ui/line-chart.tsx +380 -0
  278. package/dist/migration-templates/app-fullstack/client/components/ui/link.tsx +139 -0
  279. package/dist/migration-templates/app-fullstack/client/components/ui/navigation-menu.tsx +345 -0
  280. package/dist/migration-templates/app-fullstack/client/components/ui/pagination.tsx +192 -0
  281. package/dist/migration-templates/app-fullstack/client/components/ui/pie-chart.tsx +295 -0
  282. package/dist/migration-templates/app-fullstack/client/components/ui/popover.tsx +162 -0
  283. package/dist/migration-templates/app-fullstack/client/components/ui/progress.tsx +69 -0
  284. package/dist/migration-templates/app-fullstack/client/components/ui/radar-chart.tsx +386 -0
  285. package/dist/migration-templates/app-fullstack/client/components/ui/radial-chart.tsx +402 -0
  286. package/dist/migration-templates/app-fullstack/client/components/ui/scroll-area.tsx +86 -0
  287. package/dist/migration-templates/app-fullstack/client/components/ui/select.tsx +229 -0
  288. package/dist/migration-templates/app-fullstack/client/components/ui/separator.tsx +62 -0
  289. package/dist/migration-templates/app-fullstack/client/components/ui/sheet.tsx +234 -0
  290. package/dist/migration-templates/app-fullstack/client/components/ui/sidebar.tsx +974 -0
  291. package/dist/migration-templates/app-fullstack/client/components/ui/skeleton.tsx +13 -0
  292. package/dist/migration-templates/app-fullstack/client/components/ui/slider.tsx +198 -0
  293. package/dist/migration-templates/app-fullstack/client/components/ui/switch.tsx +95 -0
  294. package/dist/migration-templates/app-fullstack/client/components/ui/table.tsx +145 -0
  295. package/dist/migration-templates/app-fullstack/client/components/ui/tabs.tsx +87 -0
  296. package/dist/migration-templates/app-fullstack/client/components/ui/textarea.tsx +148 -0
  297. package/dist/migration-templates/app-fullstack/client/components/ui/toggle-group.tsx +225 -0
  298. package/dist/migration-templates/app-fullstack/client/components/ui/toggle.tsx +150 -0
  299. package/dist/migration-templates/app-fullstack/client/components/ui/tooltip.tsx +175 -0
  300. package/dist/migration-templates/app-fullstack/client/hooks/useApi.ts +25 -0
  301. package/dist/migration-templates/app-fullstack/client/hooks/useApiData.ts +10 -0
  302. package/dist/migration-templates/app-fullstack/client/index.css +131 -0
  303. package/dist/migration-templates/app-fullstack/client/lib/executeApi.ts +9 -0
  304. package/dist/migration-templates/app-fullstack/client/lib/utils.ts +6 -0
  305. package/dist/migration-templates/app-fullstack/client/pages/Page1/index.tsx +3 -0
  306. package/dist/migration-templates/app-fullstack/client/root.tsx +17 -0
  307. package/dist/migration-templates/app-fullstack/client/router.tsx +48 -0
  308. package/dist/migration-templates/app-fullstack/client/types/node.d.ts +9 -0
  309. package/dist/migration-templates/app-fullstack/components.json +21 -0
  310. package/dist/migration-templates/app-fullstack/eslint.config.js +108 -0
  311. package/dist/migration-templates/app-fullstack/package.json +89 -0
  312. package/dist/migration-templates/app-fullstack/server/.gitkeep +0 -0
  313. package/dist/migration-templates/app-fullstack/server/apis/index.ts +22 -0
  314. package/dist/migration-templates/app-fullstack/server/index.ts +2 -0
  315. package/dist/migration-templates/app-fullstack/tsconfig.client.json +27 -0
  316. package/dist/migration-templates/app-fullstack/tsconfig.eslint.json +8 -0
  317. package/dist/migration-templates/app-fullstack/tsconfig.json +25 -0
  318. package/dist/migration-templates/app-fullstack/tsconfig.server.json +13 -0
  319. package/dist/migration-templates/app-fullstack/vite.config.ts +17 -0
  320. package/dist/parsing/imports.d.ts +0 -16
  321. package/dist/parsing/imports.d.ts.map +1 -1
  322. package/dist/parsing/imports.js +0 -68
  323. package/dist/parsing/imports.js.map +1 -1
  324. package/dist/parsing/jsx.d.ts +0 -2
  325. package/dist/parsing/jsx.d.ts.map +1 -1
  326. package/dist/parsing/jsx.js +0 -62
  327. package/dist/parsing/jsx.js.map +1 -1
  328. package/dist/socket-manager.d.ts.map +1 -1
  329. package/dist/socket-manager.js +109 -32
  330. package/dist/socket-manager.js.map +1 -1
  331. package/dist/source-tracker.d.ts +7 -85
  332. package/dist/source-tracker.d.ts.map +1 -1
  333. package/dist/source-tracker.js +19 -695
  334. package/dist/source-tracker.js.map +1 -1
  335. package/dist/sync-service/index.d.ts +79 -2
  336. package/dist/sync-service/index.d.ts.map +1 -1
  337. package/dist/sync-service/index.js +139 -10
  338. package/dist/sync-service/index.js.map +1 -1
  339. package/package.json +11 -9
  340. package/dist/ai-service/artifacts/bolt.d.ts +0 -8
  341. package/dist/ai-service/artifacts/bolt.d.ts.map +0 -1
  342. package/dist/ai-service/artifacts/bolt.js +0 -92
  343. package/dist/ai-service/artifacts/bolt.js.map +0 -1
  344. package/dist/ai-service/result-buffer/bolt.d.ts +0 -18
  345. package/dist/ai-service/result-buffer/bolt.d.ts.map +0 -1
  346. package/dist/ai-service/result-buffer/bolt.js +0 -100
  347. package/dist/ai-service/result-buffer/bolt.js.map +0 -1
  348. package/dist/ai-service/result-buffer/shared.d.ts +0 -17
  349. package/dist/ai-service/result-buffer/shared.d.ts.map +0 -1
  350. package/dist/ai-service/result-buffer/shared.js +0 -7
  351. package/dist/ai-service/result-buffer/shared.js.map +0 -1
  352. package/dist/inject-no-select.d.ts +0 -15
  353. package/dist/inject-no-select.d.ts.map +0 -1
  354. package/dist/inject-no-select.js +0 -175
  355. package/dist/inject-no-select.js.map +0 -1
@@ -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 { generatePredictableId } from "./ids.js";
11
- import { getSbElementId, setSbElementId, supplementElementIds, } from "./parsing/ids.js";
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