@superblocksteam/vite-plugin-file-sync 2.0.23 → 2.0.24-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/ai-service/index.d.ts.map +1 -1
  2. package/dist/ai-service/index.js +13 -6
  3. package/dist/ai-service/index.js.map +1 -1
  4. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ButtonPropsDocs.js +1 -1
  5. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/CheckboxPropsDocs.js +1 -1
  6. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ColumnPropsDocs.js +1 -1
  7. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ContainerPropsDocs.js +1 -1
  8. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/DatePickerPropsDocs.js +1 -1
  9. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/DropdownPropsDocs.js +1 -1
  10. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/IconPropsDocs.js +1 -1
  11. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ImagePropsDocs.js +1 -1
  12. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/InputPropsDocs.js +1 -1
  13. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ModalPropsDocs.js +1 -1
  14. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/PagePropsDocs.js +1 -1
  15. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SectionPropsDocs.js +1 -1
  16. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SlideoutPropsDocs.js +1 -1
  17. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SwitchPropsDocs.js +1 -1
  18. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/TablePropsDocs.js +1 -1
  19. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/TextPropsDocs.js +1 -1
  20. package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/Annotations.js +1 -1
  21. package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/Dim.js +1 -1
  22. package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/EventFlow.js +1 -1
  23. package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/TextStyleWithVariant.js +1 -1
  24. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/full-examples.js +1 -1
  25. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-api.js +1 -1
  26. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-components-rules.js +1 -1
  27. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-custom-components.js +1 -1
  28. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-data-filtering.js +1 -1
  29. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-event-flow.js +1 -1
  30. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-forms.js +1 -1
  31. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-layouts.js +1 -1
  32. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-page.js +1 -1
  33. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-rbac.js +1 -1
  34. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-routes.js +1 -1
  35. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-state.js +1 -1
  36. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-theming.js +1 -1
  37. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-base.js +1 -1
  38. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-incremental.js +1 -1
  39. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-specific-edit.js +1 -1
  40. package/dist/ai-service/state-machine/handlers/agent-planning.js +7 -7
  41. package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
  42. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
  43. package/dist/ai-service/state-machine/handlers/llm-generating.js +100 -92
  44. package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
  45. package/dist/ai-service/state-machine/handlers/post-processing.js +3 -3
  46. package/dist/ai-service/state-machine/handlers/post-processing.js.map +1 -1
  47. package/dist/ai-service/state-machine/handlers/runtime-reviewing.js +4 -4
  48. package/dist/ai-service/state-machine/handlers/runtime-reviewing.js.map +1 -1
  49. package/dist/ai-service/state-machine/helpers/change-info.d.ts +1 -1
  50. package/dist/ai-service/state-machine/helpers/change-info.d.ts.map +1 -1
  51. package/dist/ai-service/state-machine/helpers/peer.d.ts +3 -3
  52. package/dist/ai-service/state-machine/helpers/peer.d.ts.map +1 -1
  53. package/dist/ai-service/state-machine/helpers/peer.js +3 -3
  54. package/dist/ai-service/state-machine/helpers/peer.js.map +1 -1
  55. package/dist/ai-service/template-renderer.d.ts.map +1 -1
  56. package/dist/ai-service/template-renderer.js +2 -1
  57. package/dist/ai-service/template-renderer.js.map +1 -1
  58. package/dist/components-manager.d.ts.map +1 -1
  59. package/dist/components-manager.js +38 -31
  60. package/dist/components-manager.js.map +1 -1
  61. package/dist/file-sync-vite-plugin.d.ts.map +1 -1
  62. package/dist/file-sync-vite-plugin.js +295 -235
  63. package/dist/file-sync-vite-plugin.js.map +1 -1
  64. package/dist/file-system-manager.d.ts.map +1 -1
  65. package/dist/file-system-manager.js +7 -4
  66. package/dist/file-system-manager.js.map +1 -1
  67. package/dist/lock-service/index.js +3 -3
  68. package/dist/lock-service/index.js.map +1 -1
  69. package/dist/server-rpc/index.js +2 -2
  70. package/dist/server-rpc/index.js.map +1 -1
  71. package/dist/socket-manager.js +3 -3
  72. package/dist/socket-manager.js.map +1 -1
  73. package/dist/source-tracker.d.ts +3 -3
  74. package/dist/source-tracker.d.ts.map +1 -1
  75. package/dist/source-tracker.js +2 -2
  76. package/dist/source-tracker.js.map +1 -1
  77. package/dist/sync-service/index.d.ts.map +1 -1
  78. package/dist/sync-service/index.js +26 -24
  79. package/dist/sync-service/index.js.map +1 -1
  80. package/package.json +6 -6
@@ -76,60 +76,66 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
76
76
  if (aiService) {
77
77
  aiService.setSourceTracker(fileSyncManager.getSourceTracker());
78
78
  }
79
- server.middlewares.use(indexHtmlMiddleware(server));
79
+ server.middlewares.use((req, res, next) => {
80
+ void indexHtmlMiddleware(server)(req, res, next);
81
+ });
80
82
  server.middlewares.use("/sb-init", bodyParser.json({ strict: true }));
81
- server.middlewares.use("/sb-init", async (req, res, next) => {
82
- if (!isInitialized) {
83
- return next();
84
- }
85
- if (req.method !== "GET" && req.method !== "OPTIONS") {
86
- res.statusCode = 405;
87
- res.end("Method not allowed");
88
- return res.end();
89
- }
90
- res.setHeader("Access-Control-Allow-Origin", "*");
91
- res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
92
- res.setHeader("Access-Control-Allow-Headers", "Content-Type");
93
- if (req.method === "OPTIONS") {
94
- res.statusCode = 204;
95
- res.end();
96
- return;
97
- }
98
- const fullUrl = new URL(req.url ?? "/", "http://localhost:5173");
99
- if (!fullUrl.searchParams.get("route")) {
100
- res.statusCode = 400;
101
- res.end("Missing route, use ?route=/route");
102
- return res.end();
103
- }
104
- const actualUrl = new URL(fullUrl.searchParams.get("route") ?? "/", fullUrl);
105
- const files = await getAllApiDefinitions({
106
- rootDir: config.root,
107
- currentUrl: actualUrl.toString(),
108
- });
109
- res.setHeader("Content-Type", "application/json");
110
- return res.end(JSON.stringify(files));
83
+ server.middlewares.use("/sb-init", (req, res, next) => {
84
+ void (async () => {
85
+ if (!isInitialized) {
86
+ return next();
87
+ }
88
+ if (req.method !== "GET" && req.method !== "OPTIONS") {
89
+ res.statusCode = 405;
90
+ res.end("Method not allowed");
91
+ return res.end();
92
+ }
93
+ res.setHeader("Access-Control-Allow-Origin", "*");
94
+ res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
95
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
96
+ if (req.method === "OPTIONS") {
97
+ res.statusCode = 204;
98
+ res.end();
99
+ return;
100
+ }
101
+ const fullUrl = new URL(req.url ?? "/", "http://localhost:5173");
102
+ if (!fullUrl.searchParams.get("route")) {
103
+ res.statusCode = 400;
104
+ res.end("Missing route, use ?route=/route");
105
+ return res.end();
106
+ }
107
+ const actualUrl = new URL(fullUrl.searchParams.get("route") ?? "/", fullUrl);
108
+ const files = await getAllApiDefinitions({
109
+ rootDir: config.root,
110
+ currentUrl: actualUrl.toString(),
111
+ });
112
+ res.setHeader("Content-Type", "application/json");
113
+ return res.end(JSON.stringify(files));
114
+ })();
111
115
  });
112
116
  server.middlewares.use("/sb-scopes", bodyParser.json({ strict: true }));
113
- server.middlewares.use("/sb-scopes", async (req, res, next) => {
114
- if (!isInitialized) {
115
- return next();
116
- }
117
- if (req.method !== "GET" && req.method !== "OPTIONS") {
118
- res.statusCode = 405;
119
- res.end("Method not allowed");
120
- return res.end();
121
- }
122
- res.setHeader("Access-Control-Allow-Origin", "*");
123
- res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
124
- res.setHeader("Access-Control-Allow-Headers", "Content-Type");
125
- if (req.method === "OPTIONS") {
126
- res.statusCode = 204;
127
- res.end();
128
- return;
129
- }
130
- const appScope = await getAppScope(fileSyncManager);
131
- res.setHeader("Content-Type", "application/json");
132
- return res.end(JSON.stringify(appScope));
117
+ server.middlewares.use("/sb-scopes", (req, res, next) => {
118
+ void (async () => {
119
+ if (!isInitialized) {
120
+ return next();
121
+ }
122
+ if (req.method !== "GET" && req.method !== "OPTIONS") {
123
+ res.statusCode = 405;
124
+ res.end("Method not allowed");
125
+ return res.end();
126
+ }
127
+ res.setHeader("Access-Control-Allow-Origin", "*");
128
+ res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
129
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
130
+ if (req.method === "OPTIONS") {
131
+ res.statusCode = 204;
132
+ res.end();
133
+ return;
134
+ }
135
+ const appScope = await getAppScope(fileSyncManager);
136
+ res.setHeader("Content-Type", "application/json");
137
+ return res.end(JSON.stringify(appScope));
138
+ })();
133
139
  });
134
140
  const socketManager = createSocketManager(pluginParams.tracer);
135
141
  socketManager.startSocketServer({
@@ -143,7 +149,7 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
143
149
  });
144
150
  socketManager.removeAllListeners();
145
151
  const sendError = (errorEvent) => {
146
- socketManager.callEditorClients((socket) => socket.call.error(errorEvent));
152
+ void socketManager.callEditorClients((socket) => socket.call.error(errorEvent));
147
153
  };
148
154
  // Add some process error handling to ensure to notify the user of
149
155
  // any uncaught exceptions or rejections
@@ -164,16 +170,18 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
164
170
  lockService?.removeListener?.("error", sendError);
165
171
  lockService?.on?.("error", sendError);
166
172
  syncService?.on?.("degradedModeChange", (degradedMode) => {
167
- socketManager.callEditorClients((socket) => {
168
- return socket.call.setDegradedMode({ degradedMode });
169
- });
173
+ void (async () => {
174
+ void socketManager.callEditorClients((socket) => {
175
+ return socket.call.setDegradedMode({ degradedMode });
176
+ });
177
+ })();
170
178
  });
171
179
  const extractApiParamsAndDependencies = (socket) => {
172
180
  const allApis = fileSyncManager.getApiFiles();
173
181
  // If we do not have any APIs, we can mark the apis as loaded immediately
174
182
  // to trigger side effects like page load events
175
183
  if (Object.keys(allApis).length === 0) {
176
- socket.call.setApisLoaded();
184
+ void socket.call.setApisLoaded();
177
185
  return;
178
186
  }
179
187
  const allApiNames = Object.values(allApis).map(({ api }) => api.apiPb.metadata.name);
@@ -196,22 +204,24 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
196
204
  });
197
205
  }),
198
206
  ]).then(() => {
199
- socketManager.callEditorClients((editorClientSocket) => {
207
+ void socketManager.callEditorClients((editorClientSocket) => {
200
208
  return editorClientSocket.call.setApiDependencies({
201
209
  apiDependencies: apiDependencyMap,
202
210
  });
203
211
  });
204
212
  });
205
213
  };
206
- socketManager.on("connect:library", async (socket) => {
207
- const allApis = fileSyncManager.getApiFiles();
208
- socket.call
209
- .setApiDefinitions(allApis)
210
- .then(() => extractApiParamsAndDependencies(socket));
211
- const tsFilePaths = fileSyncManager.getTsFilePaths();
212
- return socket.call.updateLocalBindingEntities({
213
- entities: Array.from(new Set(tsFilePaths.flatMap((file) => fileSyncManager.getLocalBindingEntities(file)))),
214
- });
214
+ socketManager.on("connect:library", (socket) => {
215
+ void (async () => {
216
+ const allApis = fileSyncManager.getApiFiles();
217
+ void socket.call
218
+ .setApiDefinitions(allApis)
219
+ .then(() => extractApiParamsAndDependencies(socket));
220
+ const tsFilePaths = fileSyncManager.getTsFilePaths();
221
+ void socket.call.updateLocalBindingEntities({
222
+ entities: Array.from(new Set(tsFilePaths.flatMap((file) => fileSyncManager.getLocalBindingEntities(file)))),
223
+ });
224
+ })();
215
225
  });
216
226
  const sendRootUpdate = async (path, sync = false) => {
217
227
  const roots = fileSyncManager.getPageRoots(path);
@@ -221,7 +231,7 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
221
231
  return;
222
232
  }
223
233
  const { scopeId } = scope;
224
- socketManager.callEditorClients((socket) => {
234
+ void socketManager.callEditorClients((socket) => {
225
235
  return socket.call.updateScope({
226
236
  scopeId,
227
237
  updates: { roots },
@@ -236,7 +246,7 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
236
246
  update.type !== "editor:setProperties");
237
247
  if (shouldSendRootUpdate) {
238
248
  paths.forEach((path) => {
239
- sendRootUpdate(path);
249
+ void sendRootUpdate(path);
240
250
  });
241
251
  }
242
252
  if (syncService) {
@@ -245,7 +255,7 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
245
255
  };
246
256
  const sendRootReset = async (sync = false) => {
247
257
  const appScope = await getAppScope(fileSyncManager);
248
- socketManager.callEditorClients((socket) => {
258
+ void socketManager.callEditorClients((socket) => {
249
259
  return socket.call.resetScope({
250
260
  appScope,
251
261
  });
@@ -260,7 +270,7 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
260
270
  const entities = scope?.entities ?? {};
261
271
  const scopeId = scope?.scopeId ?? "";
262
272
  const roots = fileSyncManager.getPageRoots(path);
263
- socketManager.callEditorClients((socket) => socket.call.updateScope({
273
+ void socketManager.callEditorClients((socket) => socket.call.updateScope({
264
274
  scopeId,
265
275
  updates: { entities, roots: roots ?? undefined },
266
276
  }));
@@ -272,7 +282,7 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
272
282
  return;
273
283
  }
274
284
  await sendRootUpdate(path);
275
- socketManager.callLibraryClients((socket) => {
285
+ void socketManager.callLibraryClients((socket) => {
276
286
  return socket.call.deleteEntities(sourceIds.map((sourceId) => ({
277
287
  scopeId: scope.scopeId,
278
288
  sourceId,
@@ -287,7 +297,7 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
287
297
  }
288
298
  const { scopeId } = scope;
289
299
  sendEntityUpdate(path, undefined, true);
290
- socketManager.callLibraryClients((socket) => {
300
+ void socketManager.callLibraryClients((socket) => {
291
301
  return socket.call.deleteEntities([
292
302
  {
293
303
  scopeId,
@@ -337,97 +347,131 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
337
347
  // configured twice otherwise, always remove all listeners
338
348
  fileSyncManager.removeAllListeners();
339
349
  fileSyncManager.on("error", sendError);
340
- fileSyncManager.on("reparent", sendRootUpdate);
341
- fileSyncManager.on("batchUpdate", sendMultiRootUpdate);
342
- fileSyncManager.on("createComponent", sendRootUpdate);
343
- fileSyncManager.on("deleteComponents", sendDeleteComponentsUpdate);
344
- fileSyncManager.on("addEntity", sendEntityUpdate);
345
- fileSyncManager.on("updateEntity", sendEntityUpdate);
346
- fileSyncManager.on("deleteEntity", sendDeleteEntityUpdate);
347
- fileSyncManager.on("renameComponent", sendFileUpdate);
348
- fileSyncManager.on("renameEntity", sendFileUpdate);
349
- fileSyncManager.on("addPage", () => sendRootReset(true));
350
- fileSyncManager.on("deletePage", () => sendRootReset(true));
351
- fileSyncManager.on("renamePage", () => sendRootReset(true));
350
+ fileSyncManager.on("reparent", (path) => {
351
+ void sendRootUpdate(path);
352
+ });
353
+ fileSyncManager.on("batchUpdate", (paths, payload) => {
354
+ void sendMultiRootUpdate(paths, payload);
355
+ });
356
+ fileSyncManager.on("createComponent", (path) => {
357
+ void sendRootUpdate(path);
358
+ });
359
+ fileSyncManager.on("deleteComponents", (path, sourceIds) => {
360
+ void sendDeleteComponentsUpdate(path, sourceIds);
361
+ });
362
+ fileSyncManager.on("addEntity", (path, request) => {
363
+ void sendEntityUpdate(path, request);
364
+ });
365
+ fileSyncManager.on("updateEntity", (path, request) => {
366
+ void sendEntityUpdate(path, request);
367
+ });
368
+ fileSyncManager.on("deleteEntity", (path, entityName) => {
369
+ void sendDeleteEntityUpdate(path, entityName);
370
+ });
371
+ fileSyncManager.on("renameComponent", (path) => {
372
+ void sendFileUpdate(path);
373
+ });
374
+ fileSyncManager.on("renameEntity", (path) => {
375
+ void sendFileUpdate(path);
376
+ });
377
+ fileSyncManager.on("addPage", () => {
378
+ void sendRootReset(true);
379
+ });
380
+ fileSyncManager.on("deletePage", () => {
381
+ void sendRootReset(true);
382
+ });
383
+ fileSyncManager.on("renamePage", () => {
384
+ void sendRootReset(true);
385
+ });
352
386
  if (aiService) {
353
- fileSyncManager.on("fileChanged", debounce(async () => {
354
- const appScope = await getAppScope(fileSyncManager);
355
- aiService.appContext.handleAppScopeReset(appScope);
387
+ fileSyncManager.on("fileChanged", debounce(() => {
388
+ void (async () => {
389
+ const appScope = await getAppScope(fileSyncManager);
390
+ void aiService.appContext.handleAppScopeReset(appScope);
391
+ })();
356
392
  }, 1000));
357
393
  }
358
- fileSyncManager.on("fileChanged", async (path, _content, isNonVisualEdit) => {
359
- socketManager.callLibraryClients((socket) => {
360
- return socket.call.updateLocalBindingEntities({
361
- entities: fileSyncManager.getLocalBindingEntities(path),
362
- });
363
- });
364
- if (isNonVisualEdit) {
365
- sendFileUpdate(path);
366
- socketManager.callLibraryClients((socket) => {
367
- return socket.call.nonVisualEdit();
394
+ fileSyncManager.on("fileChanged", (path, _content, isNonVisualEdit) => {
395
+ void (async () => {
396
+ void socketManager.callLibraryClients((socket) => {
397
+ return socket.call.updateLocalBindingEntities({
398
+ entities: fileSyncManager.getLocalBindingEntities(path),
399
+ });
368
400
  });
369
- }
370
- if (syncService) {
371
- await syncService.uploadDirectory();
372
- }
401
+ if (isNonVisualEdit) {
402
+ void sendFileUpdate(path);
403
+ void socketManager.callLibraryClients((socket) => {
404
+ return socket.call.nonVisualEdit();
405
+ });
406
+ }
407
+ if (syncService) {
408
+ await syncService.uploadDirectory();
409
+ }
410
+ })();
373
411
  });
374
- fileSyncManager.on("apiUpdate", async (payload) => {
375
- socketManager.callLibraryClients(async (socket) => {
376
- Promise.all([
377
- socket.call.updateApi(payload),
378
- extractApiParamsAndDependencies(socket),
379
- ]);
380
- });
381
- if (payload.api.pageName) {
382
- const pagePath = getPageFilePath(config.root, payload.api.pageName);
383
- sendEntityUpdate(pagePath);
384
- }
385
- if (syncService) {
386
- await syncService.uploadDirectory();
387
- }
388
- if (aiService) {
389
- aiService.appContext.handleApiUpdate(toApiV3Dto(payload.api));
390
- }
412
+ fileSyncManager.on("apiUpdate", (payload) => {
413
+ void (async () => {
414
+ void socketManager.callLibraryClients(async (socket) => {
415
+ void Promise.all([
416
+ socket.call.updateApi(payload),
417
+ extractApiParamsAndDependencies(socket),
418
+ ]);
419
+ });
420
+ if (payload.api.pageName) {
421
+ const pagePath = getPageFilePath(config.root, payload.api.pageName);
422
+ void sendEntityUpdate(pagePath);
423
+ }
424
+ if (syncService) {
425
+ await syncService.uploadDirectory();
426
+ }
427
+ if (aiService) {
428
+ void aiService.appContext.handleApiUpdate(toApiV3Dto(payload.api));
429
+ }
430
+ })();
391
431
  });
392
- fileSyncManager.on("apiManualUpdate", async (payload, sendScopeUpdates = false) => {
393
- socketManager.callLibraryClients(async (socket) => {
394
- Promise.all([
395
- socket.call.updateApi(payload),
396
- extractApiParamsAndDependencies(socket),
397
- ]);
398
- });
399
- if (sendScopeUpdates) {
400
- sendFileUpdate(getPageFilePath(config.root, payload.api.pageName));
401
- }
402
- if (syncService) {
403
- await syncService.uploadDirectory();
404
- }
405
- socketManager.callEditorClients((socket) => {
406
- return socket.call.manualUpdateApi({
407
- api: payload.api,
432
+ fileSyncManager.on("apiManualUpdate", (payload, sendScopeUpdates = false) => {
433
+ void (async () => {
434
+ void socketManager.callLibraryClients(async (socket) => {
435
+ void Promise.all([
436
+ socket.call.updateApi(payload),
437
+ extractApiParamsAndDependencies(socket),
438
+ ]);
408
439
  });
409
- });
410
- if (aiService) {
411
- aiService.appContext.handleApiUpdate(toApiV3Dto(payload.api));
412
- }
440
+ if (sendScopeUpdates) {
441
+ void sendFileUpdate(getPageFilePath(config.root, payload.api.pageName));
442
+ }
443
+ if (syncService) {
444
+ await syncService.uploadDirectory();
445
+ }
446
+ void socketManager.callEditorClients((socket) => {
447
+ return socket.call.manualUpdateApi({
448
+ api: payload.api,
449
+ });
450
+ });
451
+ if (aiService) {
452
+ void aiService.appContext.handleApiUpdate(toApiV3Dto(payload.api));
453
+ }
454
+ })();
413
455
  });
414
456
  if (syncService) {
415
- syncService.on("synchronizationStatusChange", async (status, generationNumber) => {
416
- socketManager.callEditorClients(async (socket) => {
417
- try {
418
- await socket.call.syncStatus({ status, generationNumber });
419
- }
420
- catch (err) {
421
- logger.error("Failed to send syncStatus", getErrorMeta(err));
422
- }
423
- });
457
+ syncService.on("synchronizationStatusChange", (status, generationNumber) => {
458
+ void (async () => {
459
+ void socketManager.callEditorClients(async (socket) => {
460
+ try {
461
+ await socket.call.syncStatus({ status, generationNumber });
462
+ }
463
+ catch (err) {
464
+ logger.error("Failed to send syncStatus", getErrorMeta(err));
465
+ }
466
+ });
467
+ })();
424
468
  });
425
469
  }
426
470
  if (lockService) {
427
471
  lockService.on("statusChange", (status) => {
428
472
  if (status === LockServiceStatus.RELEASING ||
429
473
  status === LockServiceStatus.LOCK_INVALID) {
430
- socketManager.callEditorClients(async (socket) => {
474
+ void socketManager.callEditorClients(async (socket) => {
431
475
  try {
432
476
  await socket.call.releasingLock();
433
477
  }
@@ -438,7 +482,7 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
438
482
  }
439
483
  });
440
484
  lockService.on("closedByServer", (data) => {
441
- socketManager.callEditorClients(async (socket) => {
485
+ void socketManager.callEditorClients(async (socket) => {
442
486
  try {
443
487
  await socket.call.closedByServer(data);
444
488
  }
@@ -448,96 +492,110 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
448
492
  });
449
493
  });
450
494
  }
451
- fileSyncManager.on("routesChanged", async () => {
452
- const rootId = normalizePath(path.join(config.root, "root.tsx"));
453
- const module = server.moduleGraph.getModuleById(rootId);
454
- // for root.tsx
455
- if (module) {
456
- // trigger transform() hook
457
- server.moduleGraph.invalidateModule(module);
458
- // trigger hot module reload
459
- await server.reloadModule(module);
460
- }
495
+ fileSyncManager.on("routesChanged", () => {
496
+ void (async () => {
497
+ const rootId = normalizePath(path.join(config.root, "root.tsx"));
498
+ const module = server.moduleGraph.getModuleById(rootId);
499
+ // for root.tsx
500
+ if (module) {
501
+ // trigger transform() hook
502
+ server.moduleGraph.invalidateModule(module);
503
+ // trigger hot module reload
504
+ await server.reloadModule(module);
505
+ }
506
+ })();
461
507
  });
462
- fileSyncManager.on("apiDelete", async (payload) => {
463
- socketManager.callLibraryClients(async (socket) => {
464
- Promise.all([
465
- socket.call.deleteApis(payload.apis.map((api) => ({
466
- apiName: api.apiName,
467
- scopeId: api.scopeId,
468
- }))),
469
- extractApiParamsAndDependencies(socket),
470
- ]);
471
- // All APIs should belong to the same page but to be consistant we iterate over all APIs
472
- const pageNames = new Set(payload.apis.map((api) => api.pageName));
473
- if (pageNames.size > 0) {
474
- pageNames.forEach((pageName) => {
475
- const pagePath = getPageFilePath(config.root, pageName);
476
- sendFileUpdate(pagePath);
477
- });
508
+ fileSyncManager.on("apiDelete", (payload) => {
509
+ void (async () => {
510
+ void socketManager.callLibraryClients(async (socket) => {
511
+ void Promise.all([
512
+ socket.call.deleteApis(payload.apis.map((api) => ({
513
+ apiName: api.apiName,
514
+ scopeId: api.scopeId,
515
+ }))),
516
+ extractApiParamsAndDependencies(socket),
517
+ ]);
518
+ // All APIs should belong to the same page but to be consistant we iterate over all APIs
519
+ const pageNames = new Set(payload.apis.map((api) => api.pageName));
520
+ if (pageNames.size > 0) {
521
+ pageNames.forEach((pageName) => {
522
+ const pagePath = getPageFilePath(config.root, pageName);
523
+ void sendFileUpdate(pagePath);
524
+ });
525
+ }
526
+ if (syncService) {
527
+ await syncService.uploadDirectory();
528
+ }
529
+ });
530
+ if (aiService) {
531
+ for (const api of payload.apis) {
532
+ void aiService.appContext.handleApiDelete(api.apiName);
533
+ }
478
534
  }
535
+ })();
536
+ });
537
+ fileSyncManager.on("apiManualDelete", (payload) => {
538
+ void (async () => {
539
+ void socketManager.callLibraryClients(async (socket) => {
540
+ void Promise.all([
541
+ socket.call.deleteApis([
542
+ {
543
+ apiName: payload.api.apiName,
544
+ scopeId: payload.api.scopeId,
545
+ },
546
+ ]),
547
+ extractApiParamsAndDependencies(socket),
548
+ ]);
549
+ const pagePath = getPageFilePath(config.root, payload.api.pageName);
550
+ void sendFileUpdate(pagePath);
551
+ });
552
+ void socketManager.callEditorClients((socket) => {
553
+ return socket.call.manualDeleteApi({
554
+ id: payload.api.id,
555
+ });
556
+ });
479
557
  if (syncService) {
480
558
  await syncService.uploadDirectory();
481
559
  }
482
- });
483
- if (aiService) {
484
- for (const api of payload.apis) {
485
- aiService.appContext.handleApiDelete(api.apiName);
560
+ if (aiService) {
561
+ void aiService.appContext.handleApiDelete(payload.api.apiName);
486
562
  }
487
- }
488
- });
489
- fileSyncManager.on("apiManualDelete", async (payload) => {
490
- socketManager.callLibraryClients(async (socket) => {
491
- Promise.all([
492
- socket.call.deleteApis([
493
- {
494
- apiName: payload.api.apiName,
495
- scopeId: payload.api.scopeId,
496
- },
497
- ]),
498
- extractApiParamsAndDependencies(socket),
499
- ]);
500
- const pagePath = getPageFilePath(config.root, payload.api.pageName);
501
- sendFileUpdate(pagePath);
502
- });
503
- socketManager.callEditorClients((socket) => {
504
- return socket.call.manualDeleteApi({
505
- id: payload.api.id,
506
- });
507
- });
508
- if (syncService) {
509
- await syncService.uploadDirectory();
510
- }
511
- if (aiService) {
512
- aiService.appContext.handleApiDelete(payload.api.apiName);
513
- }
563
+ })();
514
564
  });
515
565
  if (syncService && aiService) {
516
- socketManager.on("connect:editor", async (socket) => {
517
- const hasDraft = await syncService.hasLocalDraftChanges();
518
- return socket.call.aiSetDraftState({ hasDraft });
566
+ socketManager.on("connect:editor", (socket) => {
567
+ void (async () => {
568
+ const hasDraft = await syncService.hasLocalDraftChanges();
569
+ return socket.call.aiSetDraftState({ hasDraft });
570
+ })();
519
571
  });
520
572
  syncService.on("draftStateChanged", (hasDraft) => {
521
- socketManager.callEditorClients((socket) => {
522
- return socket.call.aiSetDraftState({ hasDraft });
523
- });
573
+ void (async () => {
574
+ void socketManager.callEditorClients((socket) => {
575
+ return socket.call.aiSetDraftState({ hasDraft });
576
+ });
577
+ })();
524
578
  });
525
579
  aiService.on("generationStarted", () => {
526
580
  fileSyncManager.enableOperationsQueue();
527
581
  });
528
- aiService.on("generationCompleted", async (hasDraft, useFullReload) => {
529
- fileSyncManager.disableOperationsQueue();
530
- await fileSyncManager.flushOperations();
531
- if (hasDraft && useFullReload) {
532
- // we have been deferring hot updates; trigger a reload to render the ai draft
533
- logger.info("Requesting full reload to render AI draft");
534
- server.ws.send({
535
- type: "full-reload",
536
- });
537
- }
582
+ aiService.on("generationCompleted", (hasDraft, useFullReload) => {
583
+ void (async () => {
584
+ fileSyncManager.disableOperationsQueue();
585
+ await fileSyncManager.flushOperations();
586
+ if (hasDraft && useFullReload) {
587
+ // we have been deferring hot updates; trigger a reload to render the ai draft
588
+ logger.info("Requesting full reload to render AI draft");
589
+ server.ws.send({
590
+ type: "full-reload",
591
+ });
592
+ }
593
+ })();
538
594
  });
539
595
  const appScope = await getAppScope(fileSyncManager);
540
- aiService.appContext.handleAppScopeReset(appScope);
596
+ void (async () => {
597
+ void aiService.appContext.handleAppScopeReset(appScope);
598
+ })();
541
599
  // capture vite error logging
542
600
  const originalErrorLogger = config.logger.error;
543
601
  config.logger.error = (...args) => {
@@ -554,7 +612,7 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
554
612
  else {
555
613
  error = new Error(message);
556
614
  }
557
- aiService.handleBuildSystemError(error);
615
+ void aiService.handleBuildSystemError(error);
558
616
  }
559
617
  return originalErrorLogger.apply(config.logger, args);
560
618
  };
@@ -562,29 +620,31 @@ export const fileSyncVitePlugin = (pluginParams, options) => {
562
620
  const triggerRegisteredComponentUpdate = () => {
563
621
  const module = server.moduleGraph.getModuleById(resolvedVirtualRegisteredComponentsId);
564
622
  if (module) {
565
- server.reloadModule(module);
623
+ void server.reloadModule(module);
566
624
  }
567
625
  };
568
626
  componentsManager.on("error", sendError);
569
627
  componentsManager.on("registeredComponentAdded", triggerRegisteredComponentUpdate);
570
628
  componentsManager.on("registeredComponentRemoved", (name) => {
571
629
  triggerRegisteredComponentUpdate();
572
- socketManager.callLibraryClients((socket) => {
630
+ void socketManager.callLibraryClients((socket) => {
573
631
  return socket.call.removeRegisteredComponent({
574
632
  name,
575
633
  });
576
634
  });
577
635
  });
578
- componentsManager.on("registeredComponentChanged", async (name, oldName) => {
579
- triggerRegisteredComponentUpdate();
580
- if (oldName) {
581
- socketManager.callLibraryClients(async (socket) => {
582
- await socket.call.renameRegisteredComponent({
583
- name,
584
- oldName,
636
+ componentsManager.on("registeredComponentChanged", (name, oldName) => {
637
+ void (async () => {
638
+ triggerRegisteredComponentUpdate();
639
+ if (oldName) {
640
+ void socketManager.callLibraryClients(async (socket) => {
641
+ await socket.call.renameRegisteredComponent({
642
+ name,
643
+ oldName,
644
+ });
585
645
  });
586
- });
587
- }
646
+ }
647
+ })();
588
648
  });
589
649
  },
590
650
  async transform(code, id) {