@superblocksteam/vite-plugin-file-sync 2.0.54 → 2.0.56-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
  2. package/dist/ai-service/agent/prompts/build-base-system-prompt.js +394 -2303
  3. package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
  4. package/dist/ai-service/agent/subagents/apis/examples.d.ts.map +1 -1
  5. package/dist/ai-service/agent/subagents/apis/examples.js +34 -35
  6. package/dist/ai-service/agent/subagents/apis/examples.js.map +1 -1
  7. package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts +2 -8
  8. package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts.map +1 -1
  9. package/dist/ai-service/agent/subagents/apis/generate-api-source.js +17 -46
  10. package/dist/ai-service/agent/subagents/apis/generate-api-source.js.map +1 -1
  11. package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts +0 -1
  12. package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts.map +1 -1
  13. package/dist/ai-service/agent/subagents/apis/prompt-builder.js +4 -25
  14. package/dist/ai-service/agent/subagents/apis/prompt-builder.js.map +1 -1
  15. package/dist/ai-service/agent/subagents/apis/state.js +1 -1
  16. package/dist/ai-service/agent/subagents/apis/state.js.map +1 -1
  17. package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts +1 -1
  18. package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts.map +1 -1
  19. package/dist/ai-service/agent/subagents/apis/system-prompt.js +134 -173
  20. package/dist/ai-service/agent/subagents/apis/system-prompt.js.map +1 -1
  21. package/dist/ai-service/agent/subagents/apis/types.d.ts +1 -4
  22. package/dist/ai-service/agent/subagents/apis/types.d.ts.map +1 -1
  23. package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
  24. package/dist/ai-service/agent/tool-message-utils.js +14 -31
  25. package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
  26. package/dist/ai-service/agent/tools/apis/build-api.d.ts +1 -6
  27. package/dist/ai-service/agent/tools/apis/build-api.d.ts.map +1 -1
  28. package/dist/ai-service/agent/tools/apis/build-api.js +12 -21
  29. package/dist/ai-service/agent/tools/apis/build-api.js.map +1 -1
  30. package/dist/ai-service/agent/tools/apis/finalize-api.d.ts +2 -6
  31. package/dist/ai-service/agent/tools/apis/finalize-api.d.ts.map +1 -1
  32. package/dist/ai-service/agent/tools/apis/finalize-api.js +29 -20
  33. package/dist/ai-service/agent/tools/apis/finalize-api.js.map +1 -1
  34. package/dist/ai-service/agent/tools/build-edit-file.d.ts.map +1 -1
  35. package/dist/ai-service/agent/tools/build-edit-file.js +4 -9
  36. package/dist/ai-service/agent/tools/build-edit-file.js.map +1 -1
  37. package/dist/ai-service/agent/tools/build-install-packages.d.ts +7 -1
  38. package/dist/ai-service/agent/tools/build-install-packages.d.ts.map +1 -1
  39. package/dist/ai-service/agent/tools/build-install-packages.js +43 -8
  40. package/dist/ai-service/agent/tools/build-install-packages.js.map +1 -1
  41. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +1 -1
  42. package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts.map +1 -1
  43. package/dist/ai-service/agent/tools/build-multi-edit-file.js +7 -9
  44. package/dist/ai-service/agent/tools/build-multi-edit-file.js.map +1 -1
  45. package/dist/ai-service/agent/tools/build-read-files.d.ts +2 -0
  46. package/dist/ai-service/agent/tools/build-read-files.d.ts.map +1 -1
  47. package/dist/ai-service/agent/tools/build-read-files.js +18 -18
  48. package/dist/ai-service/agent/tools/build-read-files.js.map +1 -1
  49. package/dist/ai-service/agent/tools/build-rename-file.d.ts +11 -0
  50. package/dist/ai-service/agent/tools/build-rename-file.d.ts.map +1 -0
  51. package/dist/ai-service/agent/tools/build-rename-file.js +103 -0
  52. package/dist/ai-service/agent/tools/build-rename-file.js.map +1 -0
  53. package/dist/ai-service/agent/tools/build-validate-icons.d.ts +0 -1
  54. package/dist/ai-service/agent/tools/build-validate-icons.d.ts.map +1 -1
  55. package/dist/ai-service/agent/tools/build-validate-icons.js +0 -6
  56. package/dist/ai-service/agent/tools/build-validate-icons.js.map +1 -1
  57. package/dist/ai-service/agent/tools/build-write-file.d.ts.map +1 -1
  58. package/dist/ai-service/agent/tools/build-write-file.js +5 -6
  59. package/dist/ai-service/agent/tools/build-write-file.js.map +1 -1
  60. package/dist/ai-service/agent/tools/index.d.ts +0 -10
  61. package/dist/ai-service/agent/tools/index.d.ts.map +1 -1
  62. package/dist/ai-service/agent/tools/index.js +0 -10
  63. package/dist/ai-service/agent/tools/index.js.map +1 -1
  64. package/dist/ai-service/agent/tools/shared-helpers.d.ts +1 -7
  65. package/dist/ai-service/agent/tools/shared-helpers.d.ts.map +1 -1
  66. package/dist/ai-service/agent/tools/shared-helpers.js +9 -29
  67. package/dist/ai-service/agent/tools/shared-helpers.js.map +1 -1
  68. package/dist/ai-service/agent/tools.d.ts.map +1 -1
  69. package/dist/ai-service/agent/tools.js +5 -11
  70. package/dist/ai-service/agent/tools.js.map +1 -1
  71. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts +1 -2
  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 +89 -67
  74. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -1
  75. package/dist/ai-service/agent/tools2/tools/explain-code-finalize.d.ts +4 -0
  76. package/dist/ai-service/agent/tools2/tools/explain-code-finalize.d.ts.map +1 -0
  77. package/dist/ai-service/agent/tools2/tools/explain-code-finalize.js +19 -0
  78. package/dist/ai-service/agent/tools2/tools/explain-code-finalize.js.map +1 -0
  79. package/dist/ai-service/agent/tools2/tools/glob.d.ts.map +1 -1
  80. package/dist/ai-service/agent/tools2/tools/glob.js +15 -6
  81. package/dist/ai-service/agent/tools2/tools/glob.js.map +1 -1
  82. package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts +13 -0
  83. package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts.map +1 -1
  84. package/dist/ai-service/agent/tools2/tools/grep-metadata.js +21 -0
  85. package/dist/ai-service/agent/tools2/tools/grep-metadata.js.map +1 -1
  86. package/dist/ai-service/agent/tools2/tools/index.d.ts +1 -0
  87. package/dist/ai-service/agent/tools2/tools/index.d.ts.map +1 -1
  88. package/dist/ai-service/agent/tools2/tools/index.js +1 -0
  89. package/dist/ai-service/agent/tools2/tools/index.js.map +1 -1
  90. package/dist/ai-service/agent/tools2/tools/ls.d.ts +10 -0
  91. package/dist/ai-service/agent/tools2/tools/ls.d.ts.map +1 -0
  92. package/dist/ai-service/agent/tools2/tools/ls.js +71 -0
  93. package/dist/ai-service/agent/tools2/tools/ls.js.map +1 -0
  94. package/dist/ai-service/agent/utils.d.ts +0 -35
  95. package/dist/ai-service/agent/utils.d.ts.map +1 -1
  96. package/dist/ai-service/agent/utils.js +0 -132
  97. package/dist/ai-service/agent/utils.js.map +1 -1
  98. package/dist/ai-service/app-interface/file-system-interface.d.ts +1 -1
  99. package/dist/ai-service/app-interface/file-system-interface.d.ts.map +1 -1
  100. package/dist/ai-service/app-interface/file-system-interface.js +2 -2
  101. package/dist/ai-service/app-interface/file-system-interface.js.map +1 -1
  102. package/dist/ai-service/app-interface/shell.d.ts +5 -0
  103. package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
  104. package/dist/ai-service/app-interface/shell.js +60 -0
  105. package/dist/ai-service/app-interface/shell.js.map +1 -1
  106. package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
  107. package/dist/ai-service/chat/chat-session-store.js +8 -1
  108. package/dist/ai-service/chat/chat-session-store.js.map +1 -1
  109. package/dist/ai-service/clark-provider/clark-chat-settings.d.ts +2 -1
  110. package/dist/ai-service/clark-provider/clark-chat-settings.d.ts.map +1 -1
  111. package/dist/ai-service/clark-provider/clark-chat-settings.js +1 -0
  112. package/dist/ai-service/clark-provider/clark-chat-settings.js.map +1 -1
  113. package/dist/ai-service/const.d.ts +3 -7
  114. package/dist/ai-service/const.d.ts.map +1 -1
  115. package/dist/ai-service/const.js +2 -6
  116. package/dist/ai-service/const.js.map +1 -1
  117. package/dist/ai-service/context/app-context.d.ts +2 -1
  118. package/dist/ai-service/context/app-context.d.ts.map +1 -1
  119. package/dist/ai-service/context/app-context.js +9 -15
  120. package/dist/ai-service/context/app-context.js.map +1 -1
  121. package/dist/ai-service/index.d.ts +4 -4
  122. package/dist/ai-service/index.d.ts.map +1 -1
  123. package/dist/ai-service/index.js +168 -16
  124. package/dist/ai-service/index.js.map +1 -1
  125. package/dist/ai-service/llm/impl/anthropic.d.ts.map +1 -1
  126. package/dist/ai-service/llm/impl/anthropic.js +1 -0
  127. package/dist/ai-service/llm/impl/anthropic.js.map +1 -1
  128. package/dist/ai-service/llm/impl/clark.d.ts.map +1 -1
  129. package/dist/ai-service/llm/impl/clark.js +1 -0
  130. package/dist/ai-service/llm/impl/clark.js.map +1 -1
  131. package/dist/ai-service/llm/provider.d.ts.map +1 -1
  132. package/dist/ai-service/llm/provider.js +1 -0
  133. package/dist/ai-service/llm/provider.js.map +1 -1
  134. package/dist/ai-service/llm/types.d.ts +1 -1
  135. package/dist/ai-service/llm/types.d.ts.map +1 -1
  136. package/dist/ai-service/prompt-builder-service/types.d.ts +0 -2
  137. package/dist/ai-service/prompt-builder-service/types.d.ts.map +1 -1
  138. package/dist/ai-service/prompt-builder-service/types.js.map +1 -1
  139. package/dist/ai-service/prompts/explain-code.d.ts +7 -0
  140. package/dist/ai-service/prompts/explain-code.d.ts.map +1 -0
  141. package/dist/ai-service/prompts/explain-code.js +23 -0
  142. package/dist/ai-service/prompts/explain-code.js.map +1 -0
  143. package/dist/ai-service/state-machine/clark-fsm.d.ts +0 -2
  144. package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
  145. package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
  146. package/dist/ai-service/state-machine/handlers/agent-planning.js +16 -16
  147. package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
  148. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
  149. package/dist/ai-service/state-machine/handlers/llm-generating.js +39 -4
  150. package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
  151. package/dist/ai-service/state-machine/mocks.d.ts.map +1 -1
  152. package/dist/ai-service/state-machine/mocks.js +1 -0
  153. package/dist/ai-service/state-machine/mocks.js.map +1 -1
  154. package/dist/ai-service/test-utils/app-generation-mocks/orders-app.d.ts +1 -1
  155. package/dist/ai-service/test-utils/app-generation-mocks/orders-app.d.ts.map +1 -1
  156. package/dist/ai-service/test-utils/app-generation-mocks/orders-app.js +0 -7
  157. package/dist/ai-service/test-utils/app-generation-mocks/orders-app.js.map +1 -1
  158. package/dist/ai-service/test-utils/app-generation-mocks/smoketest.d.ts +1 -1
  159. package/dist/ai-service/test-utils/app-generation-mocks/smoketest.d.ts.map +1 -1
  160. package/dist/ai-service/test-utils/app-generation-mocks/smoketest.js +0 -8
  161. package/dist/ai-service/test-utils/app-generation-mocks/smoketest.js.map +1 -1
  162. package/dist/ai-service/transform/api-builder/to-sdk-transformer.d.ts.map +1 -1
  163. package/dist/ai-service/transform/api-builder/to-sdk-transformer.js +0 -15
  164. package/dist/ai-service/transform/api-builder/to-sdk-transformer.js.map +1 -1
  165. package/dist/ai-service/transform/api-builder/to-yaml-transformer.d.ts.map +1 -1
  166. package/dist/ai-service/transform/api-builder/to-yaml-transformer.js +0 -13
  167. package/dist/ai-service/transform/api-builder/to-yaml-transformer.js.map +1 -1
  168. package/dist/ai-service/types.d.ts +2 -2
  169. package/dist/ai-service/types.d.ts.map +1 -1
  170. package/dist/ai-service/util/json-stream-parser.d.ts +20 -0
  171. package/dist/ai-service/util/json-stream-parser.d.ts.map +1 -0
  172. package/dist/ai-service/util/json-stream-parser.js +139 -0
  173. package/dist/ai-service/util/json-stream-parser.js.map +1 -0
  174. package/dist/binding-extraction/extract-identifiers.d.ts +1 -5
  175. package/dist/binding-extraction/extract-identifiers.d.ts.map +1 -1
  176. package/dist/binding-extraction/extract-identifiers.js +78 -15
  177. package/dist/binding-extraction/extract-identifiers.js.map +1 -1
  178. package/dist/binding-extraction/index.d.ts +1 -1
  179. package/dist/binding-extraction/index.d.ts.map +1 -1
  180. package/dist/binding-extraction/index.js +1 -1
  181. package/dist/binding-extraction/index.js.map +1 -1
  182. package/dist/binding-extraction/{extract-js-identifiers.d.ts → js-identifiers.d.ts} +2 -1
  183. package/dist/binding-extraction/js-identifiers.d.ts.map +1 -0
  184. package/dist/binding-extraction/{extract-js-identifiers.js → js-identifiers.js} +81 -1
  185. package/dist/binding-extraction/js-identifiers.js.map +1 -0
  186. package/dist/binding-extraction/python-identifiers.d.ts +13 -0
  187. package/dist/binding-extraction/python-identifiers.d.ts.map +1 -0
  188. package/dist/binding-extraction/{extract-py-identifiers.js → python-identifiers.js} +155 -1
  189. package/dist/binding-extraction/python-identifiers.js.map +1 -0
  190. package/dist/codegen.d.ts.map +1 -1
  191. package/dist/codegen.js +9 -15
  192. package/dist/codegen.js.map +1 -1
  193. package/dist/components-manager.d.ts +12 -13
  194. package/dist/components-manager.d.ts.map +1 -1
  195. package/dist/components-manager.js +78 -139
  196. package/dist/components-manager.js.map +1 -1
  197. package/dist/file-sync-vite-plugin.d.ts +1 -1
  198. package/dist/file-sync-vite-plugin.d.ts.map +1 -1
  199. package/dist/file-sync-vite-plugin.js +164 -326
  200. package/dist/file-sync-vite-plugin.js.map +1 -1
  201. package/dist/file-system-helpers.d.ts +2 -2
  202. package/dist/file-system-helpers.d.ts.map +1 -1
  203. package/dist/file-system-helpers.js +6 -4
  204. package/dist/file-system-helpers.js.map +1 -1
  205. package/dist/file-system-manager.d.ts +7 -33
  206. package/dist/file-system-manager.d.ts.map +1 -1
  207. package/dist/file-system-manager.js +185 -594
  208. package/dist/file-system-manager.js.map +1 -1
  209. package/dist/index.d.ts +1 -1
  210. package/dist/index.d.ts.map +1 -1
  211. package/dist/index.js +0 -1
  212. package/dist/index.js.map +1 -1
  213. package/dist/inject-no-select.d.ts +15 -0
  214. package/dist/inject-no-select.d.ts.map +1 -0
  215. package/dist/inject-no-select.js +173 -0
  216. package/dist/inject-no-select.js.map +1 -0
  217. package/dist/injected-index.d.ts +0 -1
  218. package/dist/injected-index.d.ts.map +1 -1
  219. package/dist/injected-index.js +0 -1
  220. package/dist/injected-index.js.map +1 -1
  221. package/dist/lock-service/activity-tracker.d.ts.map +1 -1
  222. package/dist/lock-service/activity-tracker.js +4 -1
  223. package/dist/lock-service/activity-tracker.js.map +1 -1
  224. package/dist/parsing/entity/to-code-entity.d.ts.map +1 -1
  225. package/dist/parsing/entity/to-code-entity.js +3 -4
  226. package/dist/parsing/entity/to-code-entity.js.map +1 -1
  227. package/dist/parsing/entity/to-value-entity.d.ts.map +1 -1
  228. package/dist/parsing/entity/to-value-entity.js +19 -13
  229. package/dist/parsing/entity/to-value-entity.js.map +1 -1
  230. package/dist/parsing/ids.d.ts +0 -1
  231. package/dist/parsing/ids.d.ts.map +1 -1
  232. package/dist/parsing/ids.js +3 -4
  233. package/dist/parsing/ids.js.map +1 -1
  234. package/dist/parsing/imports.d.ts.map +1 -1
  235. package/dist/parsing/imports.js +0 -10
  236. package/dist/parsing/imports.js.map +1 -1
  237. package/dist/parsing/index.d.ts +0 -1
  238. package/dist/parsing/index.d.ts.map +1 -1
  239. package/dist/parsing/index.js +0 -1
  240. package/dist/parsing/index.js.map +1 -1
  241. package/dist/parsing/jsx.d.ts.map +1 -1
  242. package/dist/parsing/jsx.js +50 -22
  243. package/dist/parsing/jsx.js.map +1 -1
  244. package/dist/parsing/page.d.ts +0 -1
  245. package/dist/parsing/page.d.ts.map +1 -1
  246. package/dist/parsing/page.js +55 -32
  247. package/dist/parsing/page.js.map +1 -1
  248. package/dist/parsing/properties.d.ts.map +1 -1
  249. package/dist/parsing/properties.js +45 -15
  250. package/dist/parsing/properties.js.map +1 -1
  251. package/dist/parsing/template/index.js +1 -1
  252. package/dist/parsing/template/index.js.map +1 -1
  253. package/dist/parsing/template/to-code-template.d.ts +1 -2
  254. package/dist/parsing/template/to-code-template.d.ts.map +1 -1
  255. package/dist/parsing/template/to-code-template.js +2 -3
  256. package/dist/parsing/template/to-code-template.js.map +1 -1
  257. package/dist/parsing/type-parsing-registry.d.ts +0 -1
  258. package/dist/parsing/type-parsing-registry.d.ts.map +1 -1
  259. package/dist/parsing/type-parsing-registry.js +0 -2
  260. package/dist/parsing/type-parsing-registry.js.map +1 -1
  261. package/dist/parsing/util.d.ts.map +1 -1
  262. package/dist/parsing/util.js +22 -5
  263. package/dist/parsing/util.js.map +1 -1
  264. package/dist/plugin-options.d.ts +8 -1
  265. package/dist/plugin-options.d.ts.map +1 -1
  266. package/dist/plugin-options.js.map +1 -1
  267. package/dist/refactor/javascript.js +1 -1
  268. package/dist/refactor/javascript.js.map +1 -1
  269. package/dist/rename-manager.d.ts.map +1 -1
  270. package/dist/rename-manager.js +1 -2
  271. package/dist/rename-manager.js.map +1 -1
  272. package/dist/router-parser.d.ts +35 -0
  273. package/dist/router-parser.d.ts.map +1 -0
  274. package/dist/router-parser.js +490 -0
  275. package/dist/router-parser.js.map +1 -0
  276. package/dist/socket-manager.d.ts +3 -3
  277. package/dist/socket-manager.d.ts.map +1 -1
  278. package/dist/socket-manager.js +14 -15
  279. package/dist/socket-manager.js.map +1 -1
  280. package/dist/source-tracker.d.ts +9 -77
  281. package/dist/source-tracker.d.ts.map +1 -1
  282. package/dist/source-tracker.js +83 -374
  283. package/dist/source-tracker.js.map +1 -1
  284. package/dist/util/operation-queue.d.ts +3 -0
  285. package/dist/util/operation-queue.d.ts.map +1 -1
  286. package/dist/util/operation-queue.js +5 -0
  287. package/dist/util/operation-queue.js.map +1 -1
  288. package/dist/util.d.ts +13 -1
  289. package/dist/util.d.ts.map +1 -1
  290. package/dist/util.js +49 -28
  291. package/dist/util.js.map +1 -1
  292. package/dist/vite-plugin-yaml-types.d.ts +9 -0
  293. package/dist/vite-plugin-yaml-types.d.ts.map +1 -0
  294. package/dist/vite-plugin-yaml-types.js +114 -0
  295. package/dist/vite-plugin-yaml-types.js.map +1 -0
  296. package/package.json +8 -7
  297. package/dist/ai-service/agent/tools/build-add-event.d.ts +0 -14
  298. package/dist/ai-service/agent/tools/build-add-event.d.ts.map +0 -1
  299. package/dist/ai-service/agent/tools/build-add-event.js +0 -44
  300. package/dist/ai-service/agent/tools/build-add-event.js.map +0 -1
  301. package/dist/ai-service/agent/tools/build-add-state-var.d.ts +0 -16
  302. package/dist/ai-service/agent/tools/build-add-state-var.d.ts.map +0 -1
  303. package/dist/ai-service/agent/tools/build-add-state-var.js +0 -62
  304. package/dist/ai-service/agent/tools/build-add-state-var.js.map +0 -1
  305. package/dist/ai-service/agent/tools/build-add-timer.d.ts +0 -16
  306. package/dist/ai-service/agent/tools/build-add-timer.d.ts.map +0 -1
  307. package/dist/ai-service/agent/tools/build-add-timer.js +0 -46
  308. package/dist/ai-service/agent/tools/build-add-timer.js.map +0 -1
  309. package/dist/ai-service/agent/tools/build-create-page.d.ts +0 -10
  310. package/dist/ai-service/agent/tools/build-create-page.d.ts.map +0 -1
  311. package/dist/ai-service/agent/tools/build-create-page.js +0 -57
  312. package/dist/ai-service/agent/tools/build-create-page.js.map +0 -1
  313. package/dist/ai-service/agent/tools/build-list-available-components.d.ts +0 -9
  314. package/dist/ai-service/agent/tools/build-list-available-components.d.ts.map +0 -1
  315. package/dist/ai-service/agent/tools/build-list-available-components.js +0 -55
  316. package/dist/ai-service/agent/tools/build-list-available-components.js.map +0 -1
  317. package/dist/ai-service/agent/tools/build-register-component-name.d.ts +0 -9
  318. package/dist/ai-service/agent/tools/build-register-component-name.d.ts.map +0 -1
  319. package/dist/ai-service/agent/tools/build-register-component-name.js +0 -53
  320. package/dist/ai-service/agent/tools/build-register-component-name.js.map +0 -1
  321. package/dist/ai-service/agent/tools/build-rename-page.d.ts +0 -9
  322. package/dist/ai-service/agent/tools/build-rename-page.d.ts.map +0 -1
  323. package/dist/ai-service/agent/tools/build-rename-page.js +0 -50
  324. package/dist/ai-service/agent/tools/build-rename-page.js.map +0 -1
  325. package/dist/ai-service/agent/tools/build-set-api-triggers.d.ts +0 -25
  326. package/dist/ai-service/agent/tools/build-set-api-triggers.d.ts.map +0 -1
  327. package/dist/ai-service/agent/tools/build-set-api-triggers.js +0 -266
  328. package/dist/ai-service/agent/tools/build-set-api-triggers.js.map +0 -1
  329. package/dist/ai-service/agent/tools/build-update-state-var.d.ts +0 -16
  330. package/dist/ai-service/agent/tools/build-update-state-var.d.ts.map +0 -1
  331. package/dist/ai-service/agent/tools/build-update-state-var.js +0 -67
  332. package/dist/ai-service/agent/tools/build-update-state-var.js.map +0 -1
  333. package/dist/ai-service/agent/tools/study-current-app-state.d.ts +0 -20
  334. package/dist/ai-service/agent/tools/study-current-app-state.d.ts.map +0 -1
  335. package/dist/ai-service/agent/tools/study-current-app-state.js +0 -20
  336. package/dist/ai-service/agent/tools/study-current-app-state.js.map +0 -1
  337. package/dist/binding-extraction/extract-js-identifiers.d.ts.map +0 -1
  338. package/dist/binding-extraction/extract-js-identifiers.js.map +0 -1
  339. package/dist/binding-extraction/extract-py-identifiers.d.ts +0 -4
  340. package/dist/binding-extraction/extract-py-identifiers.d.ts.map +0 -1
  341. package/dist/binding-extraction/extract-py-identifiers.js.map +0 -1
  342. package/dist/component-docs-service/index.d.ts +0 -37
  343. package/dist/component-docs-service/index.d.ts.map +0 -1
  344. package/dist/component-docs-service/index.js +0 -118
  345. package/dist/component-docs-service/index.js.map +0 -1
  346. package/dist/parsing/events/index.d.ts +0 -5
  347. package/dist/parsing/events/index.d.ts.map +0 -1
  348. package/dist/parsing/events/index.js +0 -7
  349. package/dist/parsing/events/index.js.map +0 -1
  350. package/dist/parsing/events/to-code-events.d.ts +0 -3
  351. package/dist/parsing/events/to-code-events.d.ts.map +0 -1
  352. package/dist/parsing/events/to-code-events.js +0 -147
  353. package/dist/parsing/events/to-code-events.js.map +0 -1
  354. package/dist/parsing/events/to-value-events.d.ts +0 -10
  355. package/dist/parsing/events/to-value-events.d.ts.map +0 -1
  356. package/dist/parsing/events/to-value-events.js +0 -473
  357. package/dist/parsing/events/to-value-events.js.map +0 -1
  358. package/dist/parsing/scope.d.ts +0 -103
  359. package/dist/parsing/scope.d.ts.map +0 -1
  360. package/dist/parsing/scope.js +0 -902
  361. package/dist/parsing/scope.js.map +0 -1
  362. package/dist/routing.d.ts +0 -6
  363. package/dist/routing.d.ts.map +0 -1
  364. package/dist/routing.js +0 -169
  365. package/dist/routing.js.map +0 -1
  366. package/dist/sb-scope-manager.d.ts +0 -121
  367. package/dist/sb-scope-manager.d.ts.map +0 -1
  368. package/dist/sb-scope-manager.js +0 -678
  369. package/dist/sb-scope-manager.js.map +0 -1
@@ -7,24 +7,24 @@ import { ApiTriggerType } from "@superblocksteam/shared";
7
7
  import bodyParser from "body-parser";
8
8
  import { debounce } from "lodash-es";
9
9
  import * as tar from "tar";
10
- import { extractApiDependencies, extractIdentifierPathsFromApi, } from "./binding-extraction/extract-identifiers.js";
10
+ import { extractInputsFromApi } from "./binding-extraction/extract-identifiers.js";
11
11
  import { ImportError } from "./build-errors.js";
12
- import { ComponentDocsService, } from "./component-docs-service/index.js";
13
- import { ComponentsManager, getComponentSourceCode, } from "./components-manager.js";
12
+ import { ComponentsManager, getComponentSourceCode, getComponentSiblingSourceCode, } from "./components-manager.js";
14
13
  import { makeServerError } from "./errors/make-server-error.js";
15
- import { getPageFilePath, isApiFilePath, SCOPE_FILE, ROUTES_FILE, isPageFilePath, codeModeDownloadExcludedDirectories, codeModeExcludedFiles, } from "./file-system-helpers.js";
14
+ import { isApiFilePath, SCOPE_FILE, isPageFilePath, codeModeDownloadExcludedDirectories, codeModeExcludedFiles, } from "./file-system-helpers.js";
16
15
  import { FileSystemManager } from "./file-system-manager.js";
17
16
  import { indexHtmlMiddleware } from "./injected-index.js";
18
17
  import { LockServiceStatus } from "./lock-service/index.js";
19
18
  import { getImports } from "./parsing/imports.js";
20
19
  import { getLegacyComponentsFolder, isCustomBuildEnabled, setOptions, } from "./plugin-options.js";
21
20
  import { createIdResolver, getFullImportPath } from "./resolver.js";
22
- import { generateRootSource } from "./routing.js";
21
+ import { parseRouterFile } from "./router-parser.js";
23
22
  import { createSocketManager, disposeSocketManager } from "./socket-manager.js";
24
23
  import { GenerationNumberSequence } from "./util/generation-number-sequence.js";
25
24
  import { getErrorMeta, getLogger, setDefaultLogger } from "./util/logger.js";
26
- import { getAllApiDefinitions, getAllPages } from "./util.js";
25
+ import { getAllPages } from "./util.js";
27
26
  import { resolvedVirtualRegisteredComponentsId, virtualLegacyId, resolvedVirtualLegacyId, virtualRegisteredComponentsId, } from "./virtual-modules.js";
27
+ import { yamlApiTypesPlugin } from "./vite-plugin-yaml-types.js";
28
28
  let hasStarted = false;
29
29
  let isInitialized = false;
30
30
  let config;
@@ -44,7 +44,6 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
44
44
  const aiService = pluginParams.aiService;
45
45
  const fsOperationQueue = pluginParams.fsOperationQueue;
46
46
  const httpServer = pluginParams.httpServer;
47
- let componentDocsService;
48
47
  let socketManager;
49
48
  const fileSyncManager = new FileSystemManager(fsOperationQueue, generationNumberSequence, pluginParams.tracer);
50
49
  if (syncService) {
@@ -63,8 +62,9 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
63
62
  await aiService.waitUntilGenerationComplete();
64
63
  });
65
64
  }
66
- const componentsManager = ComponentsManager.setInstance(pluginParams.tracer, pluginParams.features);
65
+ const componentsManager = ComponentsManager.setInstance(pluginParams.tracer);
67
66
  const lastImportErrorFiles = new Set();
67
+ const debouncedRootUpdateByPath = new Map();
68
68
  const addFileTransformError = (filePath, error) => {
69
69
  const fileTransformError = makeServerError(error, {
70
70
  critical: false,
@@ -88,7 +88,6 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
88
88
  enforce: "pre",
89
89
  async configureServer(server) {
90
90
  config = server.config;
91
- componentDocsService = new ComponentDocsService(server.config.root);
92
91
  // Set up Vite module invalidation callback for SyncService
93
92
  // This ensures that when Clark writes files, Vite's module cache is invalidated
94
93
  if (syncService) {
@@ -137,46 +136,11 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
137
136
  ]);
138
137
  if (aiService) {
139
138
  aiService.setSourceTracker(fileSyncManager.getSourceTracker());
140
- aiService.setComponentDocsService(componentDocsService);
141
139
  aiService.setFileSystemManager(fileSyncManager);
142
140
  }
143
141
  server.middlewares.use((req, res, next) => {
144
142
  void indexHtmlMiddleware(server, pluginParams?.features)(req, res, next);
145
143
  });
146
- server.middlewares.use("/sb-init", bodyParser.json({ strict: true }));
147
- server.middlewares.use("/sb-init", (req, res, next) => {
148
- void (async () => {
149
- if (!isInitialized) {
150
- return next();
151
- }
152
- if (req.method !== "GET" && req.method !== "OPTIONS") {
153
- res.statusCode = 405;
154
- res.end("Method not allowed");
155
- return res.end();
156
- }
157
- res.setHeader("Access-Control-Allow-Origin", "*");
158
- res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
159
- res.setHeader("Access-Control-Allow-Headers", "Content-Type");
160
- if (req.method === "OPTIONS") {
161
- res.statusCode = 204;
162
- res.end();
163
- return;
164
- }
165
- const fullUrl = new URL(req.url ?? "/", "http://localhost:5173");
166
- if (!fullUrl.searchParams.get("route")) {
167
- res.statusCode = 400;
168
- res.end("Missing route, use ?route=/route");
169
- return res.end();
170
- }
171
- const actualUrl = new URL(fullUrl.searchParams.get("route") ?? "/", fullUrl);
172
- const files = await getAllApiDefinitions({
173
- rootDir: config.root,
174
- currentUrl: actualUrl.toString(),
175
- });
176
- res.setHeader("Content-Type", "application/json");
177
- return res.end(JSON.stringify(files));
178
- })();
179
- });
180
144
  server.middlewares.use("/sb-scopes", bodyParser.json({ strict: true }));
181
145
  server.middlewares.use("/sb-scopes", (req, res, next) => {
182
146
  void (async () => {
@@ -275,7 +239,7 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
275
239
  lockService,
276
240
  syncService,
277
241
  aiService,
278
- componentDocsService,
242
+ checkAuthorization: pluginParams.checkAuthorization,
279
243
  tracer: pluginParams.tracer,
280
244
  path: "/sb-updates",
281
245
  });
@@ -312,59 +276,10 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
312
276
  });
313
277
  })();
314
278
  });
315
- const extractApiParamsAndDependencies = (socket) => {
316
- const allApis = fileSyncManager.getApiFiles();
317
- // If we do not have any APIs, we can mark the apis as loaded immediately
318
- // to trigger side effects like page load events
319
- if (Object.keys(allApis).length === 0) {
320
- void socket.call.setApisLoaded();
321
- return;
322
- }
323
- const allApiNames = Object.values(allApis).map(({ api }) => api.apiPb.metadata.name);
324
- // TODO: This logic is copied in the getApiDependencies function in the
325
- // generateBuildManifestPlugin plugin.
326
- //
327
- // This logic should be refactored so that it can be shared between the two plugins.
328
- const apiDependencyMap = {};
329
- return Promise.all([
330
- ...Object.values(allApis).map(async ({ api, scopeId }) => {
331
- const bindings = await extractIdentifierPathsFromApi(api);
332
- const apiDependencies = extractApiDependencies(allApiNames, bindings);
333
- apiDependencyMap[api.apiPb.metadata.name] = apiDependencies;
334
- // We don't need to explicitly call setApisLoaded here because the
335
- // updateApiParams call will trigger that if its not already marked as loaded
336
- return socket.call.updateApiParams({
337
- apiName: api.apiPb.metadata.name,
338
- scopeId,
339
- params: bindings,
340
- apiDependencies,
341
- });
342
- }),
343
- ]).then(() => {
344
- void socketManager.callEditorClients((editorClientSocket) => {
345
- return editorClientSocket.call.setApiDependencies({
346
- apiDependencies: apiDependencyMap,
347
- });
348
- });
349
- });
350
- };
351
- socketManager.on("connect:library", (socket) => {
352
- void (async () => {
353
- const allApis = fileSyncManager.getApiFiles();
354
- void socket.call
355
- .setApiDefinitions(allApis)
356
- .then(() => extractApiParamsAndDependencies(socket));
357
- const tsFilePaths = fileSyncManager.getTsFilePaths();
358
- void socket.call.updateLocalBindingEntities({
359
- entities: Array.from(new Set(tsFilePaths.flatMap((file) => fileSyncManager.getLocalBindingEntities(file)))),
360
- });
361
- })();
362
- });
363
279
  const sendRootUpdate = async (path, sync = false) => {
364
280
  const roots = await fileSyncManager.getPageRootNodes(path);
365
281
  const scope = fileSyncManager.getScope(path);
366
282
  if (!roots || !scope) {
367
- logger?.error(`sendRootUpdate: no roots or scope ${path}`);
368
283
  return;
369
284
  }
370
285
  const { scopeId } = scope;
@@ -404,6 +319,13 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
404
319
  scopeId: api.scopeId,
405
320
  },
406
321
  });
322
+ if (api.api.apiPb?.metadata?.id) {
323
+ const inputs = await extractInputsFromApi(api.api);
324
+ void socket.call.updateApiInputs({
325
+ apiId: api.api.apiPb.metadata.id,
326
+ inputs,
327
+ });
328
+ }
407
329
  }
408
330
  });
409
331
  if (!skipLibrary) {
@@ -418,21 +340,12 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
418
340
  await syncService.uploadDirectory("rootReset");
419
341
  }
420
342
  };
421
- // TODO: @damian - Check if we need both sendFileUpdate and sendEntityUpdate
422
- const sendFileUpdate = async (path) => {
423
- const scope = fileSyncManager.getScope(path);
424
- const entities = scope?.entities ?? {};
425
- const scopeId = scope?.scopeId ?? "";
426
- // Check if this is an app-level file (App.tsx or root scope.ts)
427
- const isAppFile = path === fileSyncManager.appFilePath;
428
- const isRootScope = path === fileSyncManager.rootScopeFilePath;
429
- const roots = isAppFile || isRootScope
430
- ? await fileSyncManager.getAppRootNodes()
431
- : await fileSyncManager.getPageRootNodes(path);
432
- void socketManager.callEditorClients((socket) => socket.call.updateScope({
433
- scopeId,
434
- updates: { entities, roots: roots ?? undefined },
435
- }));
343
+ fileSyncManager.on("routerChange", () => {
344
+ void sendRootReset(true);
345
+ });
346
+ const sendFileUpdate = async (_path) => {
347
+ const appScope = await getAppScope(fileSyncManager);
348
+ void socketManager.callEditorClients((socket) => socket.call.resetScope({ appScope }));
436
349
  };
437
350
  const sendDeleteComponentsUpdate = async (path, sourceIds) => {
438
351
  const scope = fileSyncManager.getScope(path);
@@ -448,50 +361,6 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
448
361
  })));
449
362
  });
450
363
  };
451
- const sendDeleteEntityUpdate = async (path, entityName) => {
452
- const scope = fileSyncManager.getScope(path);
453
- if (!scope) {
454
- console.error("No scope found for", path);
455
- return;
456
- }
457
- const { scopeId } = scope;
458
- await sendEntityUpdate(path, undefined, true);
459
- void socketManager.callLibraryClients((socket) => {
460
- return socket.call.deleteEntities([
461
- {
462
- scopeId,
463
- entityName,
464
- },
465
- ]);
466
- });
467
- };
468
- const sendEntityUpdate = async (path, _request, includeRootsUpdate = false) => {
469
- const scope = fileSyncManager.getScope(path);
470
- if (!scope) {
471
- console.error("No scope found for", path);
472
- return;
473
- }
474
- const { entities, scopeId } = scope;
475
- let roots = undefined;
476
- if (includeRootsUpdate) {
477
- // Check if this is an app-level file (App.tsx or root scope.ts)
478
- const isAppFile = path === fileSyncManager.appFilePath;
479
- const isRootScope = path === fileSyncManager.rootScopeFilePath;
480
- const newRoots = isAppFile || isRootScope
481
- ? await fileSyncManager.getAppRootNodes()
482
- : await fileSyncManager.getPageRootNodes(path);
483
- if (newRoots) {
484
- roots = newRoots;
485
- }
486
- }
487
- socketManager.callEditorClients((socket) => socket.call.updateScope({
488
- scopeId,
489
- updates: {
490
- entities,
491
- roots,
492
- },
493
- }));
494
- };
495
364
  const toApiV3Dto = (api) => {
496
365
  const { apiPb } = api;
497
366
  return {
@@ -523,55 +392,38 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
523
392
  fileSyncManager.on("deleteComponents", (path, sourceIds) => {
524
393
  void sendDeleteComponentsUpdate(path, sourceIds);
525
394
  });
526
- fileSyncManager.on("addEntity", (path, request) => {
527
- void sendEntityUpdate(path, request);
528
- });
529
- fileSyncManager.on("updateEntity", (path, request) => {
530
- void sendEntityUpdate(path, request);
531
- });
532
- fileSyncManager.on("deleteEntity", (path, entityName) => {
533
- void sendDeleteEntityUpdate(path, entityName);
534
- });
535
395
  fileSyncManager.on("renameComponent", (path) => {
536
396
  void sendFileUpdate(path);
537
397
  });
538
398
  fileSyncManager.on("renameEntity", (path) => {
539
399
  void sendFileUpdate(path);
540
400
  });
541
- fileSyncManager.on("addPage", (_, navigateTo) => {
542
- void sendRootReset();
543
- // Send HMR message to update routes without touching root.tsx
544
- server.ws.send({
545
- type: "custom",
546
- event: ViteMessageKind.ROUTES_UPDATE,
547
- data: {
548
- routes: fileSyncManager.getRoutes(),
549
- navigateTo,
550
- },
551
- });
552
- });
553
- fileSyncManager.on("deletePage", () => {
554
- void sendRootReset();
555
- // Send HMR message to update routes without touching root.tsx
556
- server.ws.send({
557
- type: "custom",
558
- event: ViteMessageKind.ROUTES_UPDATE,
559
- data: {
560
- routes: fileSyncManager.getRoutes(),
561
- navigateTo: "/",
562
- },
563
- });
564
- });
565
- fileSyncManager.on("renamePage", () => {
566
- void sendRootReset();
567
- // Send HMR message to update routes without touching root.tsx
568
- server.ws.send({
569
- type: "custom",
570
- event: ViteMessageKind.ROUTES_UPDATE,
571
- data: {
572
- routes: fileSyncManager.getRoutes(),
573
- },
574
- });
401
+ fileSyncManager.on("routerChange", (routerFilePath) => {
402
+ void (async () => {
403
+ try {
404
+ logger.info("Router file changed, re-parsing routes");
405
+ const routes = await parseRouterFile(routerFilePath, config.root);
406
+ // Send HMR message to update routes in the library
407
+ server.ws.send({
408
+ type: "custom",
409
+ event: ViteMessageKind.ROUTES_UPDATE,
410
+ data: {
411
+ routes,
412
+ },
413
+ });
414
+ // Update editor clients with new app scope
415
+ const appScope = await getAppScope(fileSyncManager);
416
+ void socketManager.callEditorClients(async (socket) => {
417
+ await socket.call.resetScope({
418
+ appScope,
419
+ });
420
+ });
421
+ logger.info(`Routes updated: ${routes.length} routes found`);
422
+ }
423
+ catch (e) {
424
+ logger.error("Error parsing router file", getErrorMeta(e));
425
+ }
426
+ })();
575
427
  });
576
428
  if (aiService) {
577
429
  fileSyncManager.on("fileChanged", debounce(() => {
@@ -587,15 +439,22 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
587
439
  })();
588
440
  });
589
441
  }
442
+ const scheduleDebouncedRootUpdate = (filePath) => {
443
+ let fn = debouncedRootUpdateByPath.get(filePath);
444
+ if (!fn) {
445
+ fn = debounce(() => {
446
+ void sendRootUpdate(filePath);
447
+ debouncedRootUpdateByPath.delete(filePath);
448
+ }, 700, { leading: true, trailing: false });
449
+ debouncedRootUpdateByPath.set(filePath, fn);
450
+ }
451
+ fn();
452
+ };
590
453
  fileSyncManager.on("fileChanged", (path, _content, isNonVisualEdit) => {
591
454
  void (async () => {
592
- void socketManager.callLibraryClients((socket) => {
593
- return socket.call.updateLocalBindingEntities({
594
- entities: fileSyncManager.getLocalBindingEntities(path),
595
- });
596
- });
597
455
  if (isNonVisualEdit) {
598
456
  void sendFileUpdate(path);
457
+ scheduleDebouncedRootUpdate(path);
599
458
  void socketManager.callLibraryClients((socket) => {
600
459
  return socket.call.nonVisualEdit();
601
460
  });
@@ -612,15 +471,23 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
612
471
  fileSyncManager.on("apiUpdate", (payload) => {
613
472
  void (async () => {
614
473
  void socketManager.callLibraryClients(async (socket) => {
615
- void Promise.all([
616
- socket.call.updateApis([payload]),
617
- extractApiParamsAndDependencies(socket),
618
- ]);
474
+ void socket.call.updateApis([payload]);
475
+ });
476
+ void socketManager.callEditorClients(async (socket) => {
477
+ if (payload.api.apiPb?.metadata?.id) {
478
+ const inputs = await extractInputsFromApi(payload.api);
479
+ void socket.call.updateApiInputs({
480
+ apiId: payload.api.apiPb.metadata.id,
481
+ inputs,
482
+ });
483
+ }
484
+ return socket.call.manualUpdateApi({
485
+ api: {
486
+ ...payload.api,
487
+ scopeId: payload.scopeId ?? "",
488
+ },
489
+ });
619
490
  });
620
- if (payload.api.pageName) {
621
- const pagePath = getPageFilePath(config.root, payload.api.pageName);
622
- void sendEntityUpdate(pagePath);
623
- }
624
491
  if (syncService) {
625
492
  await syncService.uploadDirectory("apiUpdate");
626
493
  }
@@ -629,50 +496,35 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
629
496
  }
630
497
  })();
631
498
  });
632
- // Debounce the library client update calls to prevent multiple rapid API invocations
633
- // which can occur during AI generation when the API is set to execute on page load
634
- const DEBOUNCE_WINDOW_MS = 300;
635
- const debouncedLibraryApiUpdates = new Map();
636
- const getOrCreateDebouncedLibraryApiUpdate = (apiName) => {
637
- if (!debouncedLibraryApiUpdates.has(apiName)) {
638
- debouncedLibraryApiUpdates.set(apiName, debounce(async (payload) => {
639
- void socketManager.callLibraryClients(async (socket) => {
640
- void Promise.all([
641
- socket.call.updateApis([payload]),
642
- extractApiParamsAndDependencies(socket),
643
- ]);
644
- });
645
- }, DEBOUNCE_WINDOW_MS, { leading: false, trailing: true }));
646
- }
647
- return debouncedLibraryApiUpdates.get(apiName);
648
- };
649
499
  fileSyncManager.on("apiManualUpdate", (payload, sendScopeUpdates = false) => {
650
- const apiName = payload.api.apiPb.metadata.name;
651
- // Debounce only the library client update to prevent duplicate auto-executions
652
- const debouncedUpdate = getOrCreateDebouncedLibraryApiUpdate(apiName);
653
- void debouncedUpdate(payload);
654
- // Execute these immediately without debouncing
655
- if (sendScopeUpdates) {
656
- void sendFileUpdate(getPageFilePath(config.root, payload.api.pageName));
657
- }
658
- if (syncService) {
659
- // Use different source during AI generation to prevent individual draft commits
660
- const source = aiService && aiService.isBusy()
661
- ? "ai:generate:interim"
662
- : "apiManualUpdate";
663
- void syncService.uploadDirectory(source);
664
- }
665
- void socketManager.callEditorClients((socket) => {
666
- return socket.call.manualUpdateApi({
667
- api: {
668
- ...payload.api,
669
- scopeId: payload.scopeId ?? "",
670
- },
500
+ void (async () => {
501
+ if (sendScopeUpdates) {
502
+ void sendFileUpdate(path.join(config.root, "App.tsx"));
503
+ }
504
+ if (syncService) {
505
+ // Use different source during AI generation to prevent individual draft commits
506
+ const source = aiService && aiService.isBusy()
507
+ ? "ai:generate:interim"
508
+ : "apiManualUpdate";
509
+ void syncService.uploadDirectory(source);
510
+ }
511
+ void socketManager.callEditorClients(async (socket) => {
512
+ const inputs = await extractInputsFromApi(payload.api);
513
+ void socket.call.updateApiInputs({
514
+ apiId: payload.api.apiPb.metadata.id,
515
+ inputs,
516
+ });
517
+ return socket.call.manualUpdateApi({
518
+ api: {
519
+ ...payload.api,
520
+ scopeId: payload.scopeId ?? "",
521
+ },
522
+ });
671
523
  });
672
- });
673
- if (aiService) {
674
- void aiService.appContext.handleApiUpdate(toApiV3Dto(payload.api));
675
- }
524
+ if (aiService) {
525
+ void aiService.appContext.handleApiUpdate(toApiV3Dto(payload.api));
526
+ }
527
+ })();
676
528
  });
677
529
  if (syncService) {
678
530
  syncService.on("synchronizationStatusChange", (status, generationNumber) => {
@@ -713,38 +565,13 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
713
565
  });
714
566
  });
715
567
  }
716
- fileSyncManager.on("routesChanged", () => {
717
- const rootModule = server.moduleGraph.getModuleById(path.join(config.root, "root.tsx"));
718
- if (rootModule) {
719
- server.moduleGraph.invalidateModule(rootModule);
720
- }
721
- // Send HMR message to update routes without touching root.tsx
722
- server.ws.send({
723
- type: "custom",
724
- event: ViteMessageKind.ROUTES_UPDATE,
725
- data: {
726
- routes: fileSyncManager.getRoutes(),
727
- },
728
- });
729
- });
730
568
  fileSyncManager.on("apiDelete", (payload) => {
731
569
  void (async () => {
732
570
  void socketManager.callLibraryClients(async (socket) => {
733
- void Promise.all([
734
- socket.call.deleteApis(payload.apis.map((api) => ({
735
- apiName: api.apiName,
736
- scopeId: api.scopeId,
737
- }))),
738
- extractApiParamsAndDependencies(socket),
739
- ]);
740
- // All APIs should belong to the same page but to be consistant we iterate over all APIs
741
- const pageNames = new Set(payload.apis.map((api) => api.pageName));
742
- if (pageNames.size > 0) {
743
- pageNames.forEach((pageName) => {
744
- const pagePath = getPageFilePath(config.root, pageName);
745
- void sendFileUpdate(pagePath);
746
- });
747
- }
571
+ void socket.call.deleteApis(payload.apis.map((api) => ({
572
+ apiName: api.apiName,
573
+ scopeId: api.scopeId,
574
+ })));
748
575
  if (syncService) {
749
576
  await syncService.uploadDirectory("apiDelete");
750
577
  }
@@ -759,17 +586,12 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
759
586
  fileSyncManager.on("apiManualDelete", (payload) => {
760
587
  void (async () => {
761
588
  void socketManager.callLibraryClients(async (socket) => {
762
- void Promise.all([
763
- socket.call.deleteApis([
764
- {
765
- apiName: payload.api.apiName,
766
- scopeId: payload.api.scopeId,
767
- },
768
- ]),
769
- extractApiParamsAndDependencies(socket),
589
+ void socket.call.deleteApis([
590
+ {
591
+ apiName: payload.api.apiName,
592
+ scopeId: payload.api.scopeId,
593
+ },
770
594
  ]);
771
- const pagePath = getPageFilePath(config.root, payload.api.pageName);
772
- void sendFileUpdate(pagePath);
773
595
  });
774
596
  void socketManager.callEditorClients((socket) => {
775
597
  return socket.call.manualDeleteApi({
@@ -794,6 +616,16 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
794
616
  if (aiService.isBusy()) {
795
617
  aiService.handleUserConnected(socket, peerId);
796
618
  }
619
+ const allApis = fileSyncManager.getApiFiles();
620
+ for (const api of Object.values(allApis)) {
621
+ if (api.api.apiPb?.metadata?.id) {
622
+ const inputs = await extractInputsFromApi(api.api);
623
+ void socket.call.updateApiInputs({
624
+ apiId: api.api.apiPb.metadata.id,
625
+ inputs,
626
+ });
627
+ }
628
+ }
797
629
  // Send any pending file transform error
798
630
  if (pendingFileTransformError) {
799
631
  const { filePath, error } = pendingFileTransformError;
@@ -826,18 +658,6 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
826
658
  });
827
659
  aiService.on("generationCompleted", (hasDraft) => {
828
660
  void (async () => {
829
- logger.info("Updating routes");
830
- server.ws.send({
831
- type: "custom",
832
- event: ViteMessageKind.ROUTES_UPDATE,
833
- data: {
834
- routes: fileSyncManager.getRoutes(),
835
- },
836
- });
837
- logger.info("Triggering APIs");
838
- socketManager.callLibraryClients(async (socket) => {
839
- await socket.call.setApisLoaded();
840
- });
841
661
  aiService.handleClearBuildSystemErrors();
842
662
  aiService.handleClearAllRuntimeErrors();
843
663
  // Upload directory after successful AI generation
@@ -887,21 +707,13 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
887
707
  });
888
708
  },
889
709
  async transform(code, id) {
890
- if (id.includes("/node_modules/")) {
710
+ if (id.includes("/node_modules/") || id.endsWith(".d.ts")) {
891
711
  return;
892
712
  }
893
713
  const relativePath = path.relative(config.root, id);
894
714
  if (!this.meta.watchMode)
895
715
  return;
896
- if (relativePath === "root.tsx") {
897
- const source = generateRootSource(code, fileSyncManager.getRoutes(), fileSyncManager.routeChange);
898
- return {
899
- code: source,
900
- map: null,
901
- };
902
- }
903
- else if (id.endsWith(".tsx") &&
904
- !id.includes(`${getLegacyComponentsFolder()}/`)) {
716
+ if (id.endsWith(".tsx")) {
905
717
  try {
906
718
  if (!fileSyncManager.readFile(id)) {
907
719
  return { code, map: null };
@@ -910,10 +722,31 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
910
722
  if (!fileContents) {
911
723
  throw new Error("File not found in file sync manager " + id);
912
724
  }
725
+ if (id === fileSyncManager.routerFilePath) {
726
+ return;
727
+ }
913
728
  if (componentsManager.isCustomComponentFile(id)) {
914
- const code = getComponentSourceCode(fileContents);
729
+ const componentName = componentsManager.getComponentName(id);
730
+ if (!componentName) {
731
+ return {
732
+ code,
733
+ map: null,
734
+ };
735
+ }
736
+ const transformedCode = getComponentSourceCode(fileContents, componentName);
915
737
  return {
916
- code,
738
+ code: transformedCode,
739
+ map: null,
740
+ };
741
+ }
742
+ const isComponentFile = id.endsWith(".tsx") ||
743
+ id.endsWith(".jsx") ||
744
+ id.endsWith(".ts") ||
745
+ id.endsWith(".js");
746
+ if (isComponentFile && componentsManager.isInComponentDirectory(id)) {
747
+ const transformedCode = getComponentSiblingSourceCode(fileContents, path.basename(id));
748
+ return {
749
+ code: transformedCode,
917
750
  map: null,
918
751
  };
919
752
  }
@@ -1040,10 +873,6 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
1040
873
  if (isApiFilePath(ctx.file)) {
1041
874
  return [];
1042
875
  }
1043
- // We do not want route changes to trigger full page reloads, we handle those internally
1044
- if (ctx.file.endsWith(ROUTES_FILE)) {
1045
- return [];
1046
- }
1047
876
  // if this HMR call reloads a file that an error was thrown about before,
1048
877
  // perform a full-reload and clear the error.
1049
878
  if (loggedViteErrors.length > 0) {
@@ -1152,8 +981,11 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
1152
981
  },
1153
982
  };
1154
983
  return {
1155
- plugin,
984
+ plugin: [plugin, yamlApiTypesPlugin(syncService, aiService)],
1156
985
  dispose: () => {
986
+ // Cancel all pending debounced root updates
987
+ debouncedRootUpdateByPath.forEach((fn) => fn.cancel());
988
+ debouncedRootUpdateByPath.clear();
1157
989
  disposeSocketManager();
1158
990
  },
1159
991
  };
@@ -1166,14 +998,20 @@ async function getAppScope(fileSyncManager) {
1166
998
  for (const { name, route, fileName } of pageContents) {
1167
999
  const roots = await fileSyncManager.getPageRootNodes(fileName);
1168
1000
  const pageScopeDef = fileSyncManager.getScope(fileName);
1169
- if (roots && pageScopeDef) {
1170
- pages[name] = {
1171
- name,
1172
- ...pageScopeDef,
1173
- route,
1174
- roots,
1175
- };
1001
+ if (!roots || !pageScopeDef)
1002
+ continue;
1003
+ if (pages[name]) {
1004
+ // Page already exists, add this route to its routes array
1005
+ pages[name].routes.push(route);
1006
+ continue;
1176
1007
  }
1008
+ // New page, initialize with routes array
1009
+ pages[name] = {
1010
+ name,
1011
+ ...pageScopeDef,
1012
+ routes: [route],
1013
+ roots,
1014
+ };
1177
1015
  }
1178
1016
  const appScopeDef = fileSyncManager.getScope(fileSyncManager.appFilePath);
1179
1017
  const appRoots = await fileSyncManager.getAppRootNodes();