@superblocksteam/vite-plugin-file-sync 2.0.6-next.19 → 2.0.6-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-service/app-interface/shell.d.ts +0 -1
- package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
- package/dist/ai-service/app-interface/shell.js +1 -8
- package/dist/ai-service/app-interface/shell.js.map +1 -1
- package/dist/ai-service/const.d.ts +0 -2
- package/dist/ai-service/const.d.ts.map +1 -1
- package/dist/ai-service/const.js +0 -2
- package/dist/ai-service/const.js.map +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbButtonPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbCheckboxPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbColumnPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbContainerPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbDatePickerPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbDropdownPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbIconPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbImagePropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbInputPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbModalPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbPagePropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbSectionPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbSlideoutPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbSwitchPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbTablePropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-components/SbTextPropsDocs.js +1 -1
- package/dist/ai-service/prompts/generated/library-typedefs/Dim.js +1 -1
- package/dist/ai-service/prompts/generated/library-typedefs/SbEventFlow.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/full-examples.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/superblocks-api.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/superblocks-components-rules.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/superblocks-custom-components.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/superblocks-data-filtering.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/superblocks-event-flow.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/superblocks-forms.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/superblocks-layouts.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/superblocks-page.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/superblocks-rbac.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/superblocks-routes.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/superblocks-state.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/superblocks-theming.js +1 -1
- package/dist/ai-service/prompts/generated/subprompts/system.js +1 -1
- package/dist/ai-service/state-machine/clark-fsm.d.ts +0 -1
- package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.js +0 -2
- package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.d.ts +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 +8 -40
- package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
- package/dist/ai-service/types.d.ts +0 -1
- package/dist/ai-service/types.d.ts.map +1 -1
- package/dist/ai-service/types.js.map +1 -1
- package/dist/file-sync-vite-plugin.d.ts.map +1 -1
- package/dist/file-sync-vite-plugin.js +3 -12
- package/dist/file-sync-vite-plugin.js.map +1 -1
- package/dist/file-system-helpers.d.ts +0 -2
- package/dist/file-system-helpers.d.ts.map +1 -1
- package/dist/file-system-helpers.js +0 -6
- package/dist/file-system-helpers.js.map +1 -1
- package/dist/file-system-manager.d.ts +2 -11
- package/dist/file-system-manager.d.ts.map +1 -1
- package/dist/file-system-manager.js +135 -207
- package/dist/file-system-manager.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/inject-index-vite-plugin.js.map +1 -1
- package/dist/injected-index.d.ts +2 -2
- package/dist/injected-index.d.ts.map +1 -1
- package/dist/injected-index.js.map +1 -1
- package/dist/lock-service/index.d.ts.map +1 -1
- package/dist/lock-service/index.js +2 -10
- package/dist/lock-service/index.js.map +1 -1
- package/dist/parsing/events/to-code-events.d.ts.map +1 -1
- package/dist/parsing/events/to-code-events.js +0 -7
- package/dist/parsing/events/to-code-events.js.map +1 -1
- package/dist/parsing/events/to-value-events.d.ts.map +1 -1
- package/dist/parsing/events/to-value-events.js +0 -28
- package/dist/parsing/events/to-value-events.js.map +1 -1
- package/dist/socket-manager.d.ts +2 -2
- package/dist/socket-manager.d.ts.map +1 -1
- package/dist/source-tracker.d.ts +20 -20
- package/dist/source-tracker.d.ts.map +1 -1
- package/dist/source-tracker.js +12 -26
- package/dist/source-tracker.js.map +1 -1
- package/package.json +6 -14
- package/dist/binding-extraction/index.d.ts +0 -2
- package/dist/binding-extraction/index.d.ts.map +0 -1
- package/dist/binding-extraction/index.js +0 -2
- package/dist/binding-extraction/index.js.map +0 -1
- package/dist/operations/operation-processor.d.ts +0 -24
- package/dist/operations/operation-processor.d.ts.map +0 -1
- package/dist/operations/operation-processor.js +0 -80
- package/dist/operations/operation-processor.js.map +0 -1
- package/dist/operations/types.d.ts +0 -8
- package/dist/operations/types.d.ts.map +0 -1
- package/dist/operations/types.js +0 -2
- package/dist/operations/types.js.map +0 -1
- package/dist/parsing/index.d.ts +0 -3
- package/dist/parsing/index.d.ts.map +0 -1
- package/dist/parsing/index.js +0 -3
- package/dist/parsing/index.js.map +0 -1
|
@@ -12,9 +12,8 @@ import { generateJSXAttribute } from "./codegen.js";
|
|
|
12
12
|
import { ComponentsManager } from "./components-manager.js";
|
|
13
13
|
import { addLegacyCustomComponentVariables, modifyLegacyCustomComponentElements, modifyLegacyCustomComponentImports, } from "./custom-components.js";
|
|
14
14
|
import { applyErrorHandling, } from "./errors/error-handler.js";
|
|
15
|
-
import { getPageFolder,
|
|
15
|
+
import { getPageFolder, PAGES_DIRECTORY, ROUTES_FILE, SCOPE_FILE, } from "./file-system-helpers.js";
|
|
16
16
|
import { generate } from "./generate.js";
|
|
17
|
-
import { OperationProcessor } from "./operations/operation-processor.js";
|
|
18
17
|
import { doesElementHaveBinding } from "./parsing/bindings.js";
|
|
19
18
|
import { getSbElementId } from "./parsing/ids.js";
|
|
20
19
|
import { makeJSXAttribute } from "./parsing/jsx.js";
|
|
@@ -48,13 +47,12 @@ const SUPPORTED_FILETYPES = [
|
|
|
48
47
|
},
|
|
49
48
|
];
|
|
50
49
|
const APP_THEME_FILE_NAME = "appTheme.ts";
|
|
51
|
-
export class
|
|
50
|
+
export class FileSyncManager extends TracedEventEmitter {
|
|
52
51
|
rootDir;
|
|
53
52
|
tsFiles = {};
|
|
54
53
|
apiFiles = {};
|
|
55
54
|
sourceTracker;
|
|
56
55
|
fsOperationQueue;
|
|
57
|
-
operationProcessor;
|
|
58
56
|
generationNumberSequence;
|
|
59
57
|
routes = {};
|
|
60
58
|
watcher;
|
|
@@ -67,12 +65,6 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
67
65
|
this.fsOperationQueue = fsOperationQueue;
|
|
68
66
|
this.generationNumberSequence = generationNumberSequence;
|
|
69
67
|
this._tracer = tracer;
|
|
70
|
-
// intentionally a new queue here, we don't want to share the queue with the fsOperationQueue
|
|
71
|
-
this.operationProcessor = new OperationProcessor({
|
|
72
|
-
batchWindowMs: 50,
|
|
73
|
-
maxBatchSize: 100,
|
|
74
|
-
});
|
|
75
|
-
this.operationProcessor.disable();
|
|
76
68
|
applyErrorHandling(this, {
|
|
77
69
|
watch: { operation: "editing from code" },
|
|
78
70
|
handleCreatePage: { operation: "creating a page" },
|
|
@@ -227,203 +219,139 @@ export class FileSystemManager extends TracedEventEmitter {
|
|
|
227
219
|
this.updateApi(content, path);
|
|
228
220
|
}
|
|
229
221
|
});
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return;
|
|
264
|
-
const isPage = isPageFilePath(filePath);
|
|
265
|
-
if (isPage) {
|
|
266
|
-
void this.operationProcessor.addOperation({
|
|
267
|
-
metadata: {
|
|
268
|
-
filePath,
|
|
269
|
-
},
|
|
270
|
-
execute: async () => {
|
|
271
|
-
const file = await readFile(filePath);
|
|
272
|
-
if (!file) {
|
|
273
|
-
logger.error(`Failed to read file: ${filePath}`);
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
if (!(filePath in this.tsFiles)) {
|
|
277
|
-
this.tsFiles[filePath] = file;
|
|
278
|
-
this.handleNonVisualChangeByDeletingIds(filePath, file);
|
|
279
|
-
this.emit("addPage", filePath);
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
});
|
|
222
|
+
const handleFileChange = async (event, filePath) => {
|
|
223
|
+
logger.info(`File changed: ${filePath}, event: ${event}`);
|
|
224
|
+
switch (event) {
|
|
225
|
+
case "add": {
|
|
226
|
+
const fileType = SUPPORTED_FILETYPES.find((f) => filePath.endsWith(f.extension));
|
|
227
|
+
if (!fileType || !filePath.startsWith(rootPath)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const data = await readFile(filePath);
|
|
231
|
+
if (typeof data !== "string")
|
|
232
|
+
return;
|
|
233
|
+
// if we match pages/*/index.tsx, we want to emit an addPage event
|
|
234
|
+
if (/pages\/.*\/index\.tsx/.test(filePath)) {
|
|
235
|
+
const file = await readFile(filePath);
|
|
236
|
+
if (!file) {
|
|
237
|
+
logger.error(`Failed to read file: ${filePath}`);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (!(filePath in this.tsFiles)) {
|
|
241
|
+
this.tsFiles[filePath] = file;
|
|
242
|
+
this.handleNonVisualChangeByDeletingIds(filePath, file);
|
|
243
|
+
this.emit("addPage", filePath);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
switch (fileType.type) {
|
|
247
|
+
case "api":
|
|
248
|
+
case "python-api-step":
|
|
249
|
+
case "js-api-step": {
|
|
250
|
+
await this.processApiUpdates(filePath, fileType);
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
break;
|
|
283
255
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
256
|
+
case "change": {
|
|
257
|
+
// Special routes file handling
|
|
258
|
+
if (filePath === routePath) {
|
|
259
|
+
const data = await readFile(filePath);
|
|
260
|
+
try {
|
|
261
|
+
this.routes = JSON.parse(data);
|
|
262
|
+
this.emit("routesChanged", this.routes);
|
|
263
|
+
}
|
|
264
|
+
catch (e) {
|
|
265
|
+
logger.error("Error parsing routes file", getErrorMeta(e));
|
|
266
|
+
}
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const fileType = SUPPORTED_FILETYPES.find((f) => filePath.endsWith(f.extension));
|
|
270
|
+
if (!fileType || !filePath.startsWith(rootPath)) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const data = await readFile(filePath);
|
|
274
|
+
if (typeof data !== "string")
|
|
275
|
+
return;
|
|
276
|
+
switch (fileType.type) {
|
|
277
|
+
case "tsx":
|
|
278
|
+
case "scope":
|
|
279
|
+
{
|
|
280
|
+
if (!(filePath in this.tsFiles && this.tsFiles[filePath] === data)) {
|
|
281
|
+
logger.info(`File changed: ${filePath} updating AST tracker`);
|
|
282
|
+
this.tsFiles[filePath] = data;
|
|
283
|
+
// only update the source tracker if the file is different
|
|
284
|
+
this.handleNonVisualChangeByDeletingIds(filePath, data);
|
|
285
|
+
this.emit("fileChanged", filePath, data, true);
|
|
296
286
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
case "change": {
|
|
304
|
-
if (filePath === routePath) {
|
|
305
|
-
void this.operationProcessor.addOperation({
|
|
306
|
-
metadata: {
|
|
307
|
-
filePath,
|
|
308
|
-
},
|
|
309
|
-
priority: true,
|
|
310
|
-
execute: async () => {
|
|
311
|
-
try {
|
|
312
|
-
const data = JSON.parse((await readFile(filePath)) ?? "{}");
|
|
313
|
-
if (!isEqual(this.routes, data)) {
|
|
314
|
-
this.routes = data;
|
|
315
|
-
this.emit("routesChanged", this.routes);
|
|
287
|
+
else {
|
|
288
|
+
logger.info(`File unchanged from last tracked state: ${filePath}`);
|
|
289
|
+
this.emit("fileChanged", filePath, data, false);
|
|
316
290
|
}
|
|
317
291
|
}
|
|
318
|
-
|
|
319
|
-
|
|
292
|
+
break;
|
|
293
|
+
case "api":
|
|
294
|
+
case "python-api-step":
|
|
295
|
+
case "js-api-step":
|
|
296
|
+
{
|
|
297
|
+
await this.processApiUpdates(filePath, fileType);
|
|
320
298
|
}
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
324
302
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
break;
|
|
356
|
-
case "api":
|
|
357
|
-
case "python-api-step":
|
|
358
|
-
case "js-api-step":
|
|
359
|
-
{
|
|
360
|
-
await this.processApiUpdates(filePath, fileType);
|
|
361
|
-
}
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
});
|
|
303
|
+
case "unlink": {
|
|
304
|
+
if (filePath in this.apiFiles) {
|
|
305
|
+
const api = this.apiFiles[filePath];
|
|
306
|
+
delete this.apiFiles[filePath];
|
|
307
|
+
if (!api || !this.sourceTracker)
|
|
308
|
+
break;
|
|
309
|
+
const scopeId = await this.sourceTracker.deleteApi({
|
|
310
|
+
pageName: api.pageName,
|
|
311
|
+
apiName: api.apiPb.metadata.name,
|
|
312
|
+
});
|
|
313
|
+
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
314
|
+
await this.writeChanges(changes);
|
|
315
|
+
this.emit("apiManualDelete", {
|
|
316
|
+
api: {
|
|
317
|
+
id: getClientApiId(api.apiPb.metadata.name, api.pageName),
|
|
318
|
+
apiName: api.apiPb.metadata.name,
|
|
319
|
+
// TODO(saksham): get pagename more defensively
|
|
320
|
+
pageName: getPageName(filePath),
|
|
321
|
+
scopeId,
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
if (filePath in this.tsFiles) {
|
|
326
|
+
delete this.tsFiles[filePath];
|
|
327
|
+
this.sourceTracker?.removeFile(filePath);
|
|
328
|
+
this.emit("deletePage", filePath);
|
|
329
|
+
}
|
|
330
|
+
break;
|
|
366
331
|
}
|
|
367
|
-
break;
|
|
368
332
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
333
|
+
};
|
|
334
|
+
watcher.on("all", async (event, filePath) => {
|
|
335
|
+
const fileType = SUPPORTED_FILETYPES.find((f) => filePath.endsWith(f.extension));
|
|
336
|
+
switch (fileType?.type) {
|
|
337
|
+
case "tsx":
|
|
338
|
+
case "scope":
|
|
339
|
+
// these can be awaited to ensure sequential execution
|
|
340
|
+
this.fsOperationQueue.enqueue(async () => {
|
|
341
|
+
return await handleFileChange(event, filePath);
|
|
378
342
|
});
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
},
|
|
385
|
-
execute: async () => {
|
|
386
|
-
await this.deleteApiFile(filePath);
|
|
387
|
-
},
|
|
343
|
+
break;
|
|
344
|
+
default:
|
|
345
|
+
// some files including APIs cannot be awaited currently
|
|
346
|
+
this.fsOperationQueue.enqueue(async () => {
|
|
347
|
+
void handleFileChange(event, filePath);
|
|
388
348
|
});
|
|
389
|
-
}
|
|
390
|
-
break;
|
|
391
349
|
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
350
|
+
});
|
|
351
|
+
}
|
|
394
352
|
getApiFiles() {
|
|
395
353
|
return this.formatApisToClientApis(this.apiFiles);
|
|
396
354
|
}
|
|
397
|
-
async deleteTsFile(filePath) {
|
|
398
|
-
delete this.tsFiles[filePath];
|
|
399
|
-
this.sourceTracker?.removeFile(filePath);
|
|
400
|
-
if (isPageFilePath(filePath)) {
|
|
401
|
-
this.emit("deletePage", filePath);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
async deleteApiFile(filePath) {
|
|
405
|
-
const api = this.apiFiles[filePath];
|
|
406
|
-
if (!api) {
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
delete this.apiFiles[filePath];
|
|
410
|
-
this.sourceTracker?.deleteApi({
|
|
411
|
-
pageName: api.pageName,
|
|
412
|
-
apiName: api.apiPb.metadata.name,
|
|
413
|
-
});
|
|
414
|
-
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
415
|
-
await this.writeChanges(changes);
|
|
416
|
-
const scopeId = this.sourceTracker?.getScopeDefinitionForPage(api.pageName)?.id;
|
|
417
|
-
this.emit("apiManualDelete", {
|
|
418
|
-
api: {
|
|
419
|
-
id: getClientApiId(api.apiPb.metadata.name, api.pageName),
|
|
420
|
-
apiName: api.apiPb.metadata.name,
|
|
421
|
-
// TODO(saksham): get pagename more defensively
|
|
422
|
-
pageName: getPageName(filePath),
|
|
423
|
-
scopeId,
|
|
424
|
-
},
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
355
|
getTsFilePaths() {
|
|
428
356
|
return Object.keys(this.tsFiles);
|
|
429
357
|
}
|
|
@@ -640,11 +568,11 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
640
568
|
handleReparent = async (payload, writeFile = true) => {
|
|
641
569
|
const { from, to, changedProps, transaction } = payload;
|
|
642
570
|
this.trackTransaction(transaction?.id);
|
|
643
|
-
this.sourceTracker?.setProperties({
|
|
571
|
+
await this.sourceTracker?.setProperties({
|
|
644
572
|
source: from.source,
|
|
645
573
|
changes: changedProps ?? {},
|
|
646
574
|
});
|
|
647
|
-
this.sourceTracker?.moveElement({
|
|
575
|
+
await this.sourceTracker?.moveElement({
|
|
648
576
|
from,
|
|
649
577
|
to,
|
|
650
578
|
});
|
|
@@ -658,7 +586,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
658
586
|
};
|
|
659
587
|
handleCreateComponent = async (payload, writeFile = true) => {
|
|
660
588
|
this.trackTransaction(payload.transaction?.id);
|
|
661
|
-
const sourceId = this.sourceTracker?.addElement(payload);
|
|
589
|
+
const sourceId = await this.sourceTracker?.addElement(payload);
|
|
662
590
|
if (writeFile) {
|
|
663
591
|
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
664
592
|
await this.writeChanges(changes ?? [], (fileName) => {
|
|
@@ -672,7 +600,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
672
600
|
const { elements, transaction } = payload;
|
|
673
601
|
this.trackTransaction(transaction?.id);
|
|
674
602
|
for (const element of elements) {
|
|
675
|
-
this.sourceTracker?.deleteElement({
|
|
603
|
+
await this.sourceTracker?.deleteElement({
|
|
676
604
|
source: element.source,
|
|
677
605
|
scopeName: element.scopeName,
|
|
678
606
|
});
|
|
@@ -688,7 +616,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
688
616
|
handleSetProperty = async (payload, writeFile = true) => {
|
|
689
617
|
const { element: { source }, property, value, transaction, } = payload;
|
|
690
618
|
this.trackTransaction(transaction?.id);
|
|
691
|
-
this.sourceTracker?.setProperty({
|
|
619
|
+
await this.sourceTracker?.setProperty({
|
|
692
620
|
source,
|
|
693
621
|
property,
|
|
694
622
|
info: value,
|
|
@@ -703,7 +631,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
703
631
|
handleSetProperties = async (payload, writeFile = true) => {
|
|
704
632
|
const { element: { source }, properties, transaction, } = payload;
|
|
705
633
|
this.trackTransaction(transaction?.id);
|
|
706
|
-
this.sourceTracker?.setProperties({
|
|
634
|
+
await this.sourceTracker?.setProperties({
|
|
707
635
|
source,
|
|
708
636
|
changes: properties,
|
|
709
637
|
});
|
|
@@ -837,7 +765,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
837
765
|
await fs.rmdir(apiDir, { recursive: true });
|
|
838
766
|
}
|
|
839
767
|
delete this.apiFiles[apiFilePath];
|
|
840
|
-
const scopeId = this.sourceTracker.deleteApi({
|
|
768
|
+
const scopeId = await this.sourceTracker.deleteApi({
|
|
841
769
|
pageName,
|
|
842
770
|
apiName,
|
|
843
771
|
});
|
|
@@ -936,7 +864,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
936
864
|
}));
|
|
937
865
|
};
|
|
938
866
|
handleAddEntity = async (payload) => {
|
|
939
|
-
this.sourceTracker?.addEntity({
|
|
867
|
+
await this.sourceTracker?.addEntity({
|
|
940
868
|
scopeId: payload.scopeId,
|
|
941
869
|
entity: {
|
|
942
870
|
type: payload.type,
|
|
@@ -950,7 +878,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
950
878
|
});
|
|
951
879
|
};
|
|
952
880
|
handleUpdateEntity = async (payload) => {
|
|
953
|
-
this.sourceTracker?.updateEntity({
|
|
881
|
+
await this.sourceTracker?.updateEntity({
|
|
954
882
|
entityId: payload.entityId,
|
|
955
883
|
updates: payload.updates,
|
|
956
884
|
});
|
|
@@ -960,7 +888,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
960
888
|
});
|
|
961
889
|
};
|
|
962
890
|
handleDeleteEntity = async (payload) => {
|
|
963
|
-
const deletedEntityName = this.sourceTracker?.deleteEntity({
|
|
891
|
+
const deletedEntityName = await this.sourceTracker?.deleteEntity({
|
|
964
892
|
entityId: payload.entityId,
|
|
965
893
|
});
|
|
966
894
|
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
@@ -976,7 +904,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
976
904
|
throw new Error("Root directory not set");
|
|
977
905
|
}
|
|
978
906
|
const filePath = path.join(this.rootDir, APP_THEME_FILE_NAME);
|
|
979
|
-
this.sourceTracker?.updateTheme({
|
|
907
|
+
await this.sourceTracker?.updateTheme({
|
|
980
908
|
themeFilePath: filePath,
|
|
981
909
|
theme,
|
|
982
910
|
});
|
|
@@ -1014,7 +942,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
1014
942
|
};
|
|
1015
943
|
handleRenameEntity = async (payload) => {
|
|
1016
944
|
const { elementId, newName, oldName, scopeName } = payload;
|
|
1017
|
-
this.sourceTracker?.renameEntity({
|
|
945
|
+
await this.sourceTracker?.renameEntity({
|
|
1018
946
|
entityId: elementId,
|
|
1019
947
|
oldName,
|
|
1020
948
|
newName,
|
|
@@ -1233,7 +1161,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
1233
1161
|
}
|
|
1234
1162
|
}
|
|
1235
1163
|
// Add new mock implementation
|
|
1236
|
-
export class MockFileSyncManager extends
|
|
1164
|
+
export class MockFileSyncManager extends FileSyncManager {
|
|
1237
1165
|
tsFiles = {};
|
|
1238
1166
|
apiFiles = {};
|
|
1239
1167
|
async watch(_watcher, _path) {
|
|
@@ -1309,7 +1237,7 @@ async function readFiles(dir) {
|
|
|
1309
1237
|
const getMergedApiContent = async (path) => {
|
|
1310
1238
|
return readAppApiYamlFile(path.split("/").slice(0, -1).join("/"));
|
|
1311
1239
|
};
|
|
1312
|
-
|
|
1240
|
+
const getPageName = (path) => {
|
|
1313
1241
|
const parts = path.split("/");
|
|
1314
1242
|
const pagesIndex = parts.findIndex((part) => part === "pages");
|
|
1315
1243
|
if (pagesIndex !== -1 && parts[pagesIndex + 1]) {
|