@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.
- package/dist/ai-service/index.d.ts.map +1 -1
- package/dist/ai-service/index.js +13 -6
- package/dist/ai-service/index.js.map +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ButtonPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/CheckboxPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ColumnPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ContainerPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/DatePickerPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/DropdownPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/IconPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ImagePropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/InputPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ModalPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/PagePropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SectionPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SlideoutPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SwitchPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/TablePropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-components/TextPropsDocs.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/Annotations.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/Dim.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/EventFlow.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/TextStyleWithVariant.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/full-examples.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-api.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-components-rules.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-custom-components.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-data-filtering.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-event-flow.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-forms.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-layouts.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-page.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-rbac.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-routes.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-state.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-theming.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-base.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-incremental.js +1 -1
- package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-specific-edit.js +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.js +7 -7
- package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.js +100 -92
- package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/post-processing.js +3 -3
- package/dist/ai-service/state-machine/handlers/post-processing.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/runtime-reviewing.js +4 -4
- package/dist/ai-service/state-machine/handlers/runtime-reviewing.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/change-info.d.ts +1 -1
- package/dist/ai-service/state-machine/helpers/change-info.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/peer.d.ts +3 -3
- package/dist/ai-service/state-machine/helpers/peer.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/peer.js +3 -3
- package/dist/ai-service/state-machine/helpers/peer.js.map +1 -1
- package/dist/ai-service/template-renderer.d.ts.map +1 -1
- package/dist/ai-service/template-renderer.js +2 -1
- package/dist/ai-service/template-renderer.js.map +1 -1
- package/dist/components-manager.d.ts.map +1 -1
- package/dist/components-manager.js +38 -31
- package/dist/components-manager.js.map +1 -1
- package/dist/file-sync-vite-plugin.d.ts.map +1 -1
- package/dist/file-sync-vite-plugin.js +295 -235
- package/dist/file-sync-vite-plugin.js.map +1 -1
- package/dist/file-system-manager.d.ts.map +1 -1
- package/dist/file-system-manager.js +7 -4
- package/dist/file-system-manager.js.map +1 -1
- package/dist/lock-service/index.js +3 -3
- package/dist/lock-service/index.js.map +1 -1
- package/dist/server-rpc/index.js +2 -2
- package/dist/server-rpc/index.js.map +1 -1
- package/dist/socket-manager.js +3 -3
- package/dist/socket-manager.js.map +1 -1
- package/dist/source-tracker.d.ts +3 -3
- package/dist/source-tracker.d.ts.map +1 -1
- package/dist/source-tracker.js +2 -2
- package/dist/source-tracker.js.map +1 -1
- package/dist/sync-service/index.d.ts.map +1 -1
- package/dist/sync-service/index.js +26 -24
- package/dist/sync-service/index.js.map +1 -1
- 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(
|
|
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",
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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",
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
168
|
-
|
|
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",
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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",
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
fileSyncManager.on("
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
fileSyncManager.on("
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
fileSyncManager.on("
|
|
350
|
-
|
|
351
|
-
|
|
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(
|
|
354
|
-
|
|
355
|
-
|
|
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",
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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
|
-
|
|
371
|
-
|
|
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",
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
aiService
|
|
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",
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
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
|
-
|
|
411
|
-
|
|
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",
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
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",
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
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",
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
pageNames.
|
|
475
|
-
|
|
476
|
-
|
|
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
|
-
|
|
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",
|
|
517
|
-
|
|
518
|
-
|
|
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
|
-
|
|
522
|
-
|
|
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",
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
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
|
-
|
|
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",
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
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) {
|