@superblocksteam/vite-plugin-file-sync 2.0.6-next.2 → 2.0.6-next.21
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 +1 -0
- package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
- package/dist/ai-service/app-interface/shell.js +8 -1
- package/dist/ai-service/app-interface/shell.js.map +1 -1
- package/dist/ai-service/const.d.ts +2 -0
- package/dist/ai-service/const.d.ts.map +1 -1
- package/dist/ai-service/const.js +2 -0
- 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 +1 -0
- 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 +2 -0
- 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 +40 -8
- package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
- package/dist/ai-service/types.d.ts +1 -0
- package/dist/ai-service/types.d.ts.map +1 -1
- package/dist/ai-service/types.js.map +1 -1
- package/dist/binding-extraction/index.d.ts +2 -0
- package/dist/binding-extraction/index.d.ts.map +1 -0
- package/dist/binding-extraction/index.js +2 -0
- package/dist/binding-extraction/index.js.map +1 -0
- package/dist/file-sync-vite-plugin.d.ts.map +1 -1
- package/dist/file-sync-vite-plugin.js +12 -3
- package/dist/file-sync-vite-plugin.js.map +1 -1
- package/dist/file-system-helpers.d.ts +2 -0
- package/dist/file-system-helpers.d.ts.map +1 -1
- package/dist/file-system-helpers.js +6 -0
- package/dist/file-system-helpers.js.map +1 -1
- package/dist/file-system-manager.d.ts +11 -2
- package/dist/file-system-manager.d.ts.map +1 -1
- package/dist/file-system-manager.js +207 -135
- package/dist/file-system-manager.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- 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 +10 -2
- package/dist/lock-service/index.js.map +1 -1
- package/dist/operations/operation-processor.d.ts +24 -0
- package/dist/operations/operation-processor.d.ts.map +1 -0
- package/dist/operations/operation-processor.js +80 -0
- package/dist/operations/operation-processor.js.map +1 -0
- package/dist/operations/types.d.ts +8 -0
- package/dist/operations/types.d.ts.map +1 -0
- package/dist/operations/types.js +2 -0
- package/dist/operations/types.js.map +1 -0
- package/dist/parsing/events/to-code-events.d.ts.map +1 -1
- package/dist/parsing/events/to-code-events.js +7 -0
- 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 +28 -0
- package/dist/parsing/events/to-value-events.js.map +1 -1
- package/dist/parsing/index.d.ts +3 -0
- package/dist/parsing/index.d.ts.map +1 -0
- package/dist/parsing/index.js +3 -0
- package/dist/parsing/index.js.map +1 -0
- 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 +26 -12
- package/dist/source-tracker.js.map +1 -1
- package/package.json +14 -6
|
@@ -12,8 +12,9 @@ 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, PAGES_DIRECTORY, ROUTES_FILE, SCOPE_FILE, } from "./file-system-helpers.js";
|
|
15
|
+
import { getPageFolder, isPageFilePath, 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";
|
|
17
18
|
import { doesElementHaveBinding } from "./parsing/bindings.js";
|
|
18
19
|
import { getSbElementId } from "./parsing/ids.js";
|
|
19
20
|
import { makeJSXAttribute } from "./parsing/jsx.js";
|
|
@@ -47,12 +48,13 @@ const SUPPORTED_FILETYPES = [
|
|
|
47
48
|
},
|
|
48
49
|
];
|
|
49
50
|
const APP_THEME_FILE_NAME = "appTheme.ts";
|
|
50
|
-
export class
|
|
51
|
+
export class FileSystemManager extends TracedEventEmitter {
|
|
51
52
|
rootDir;
|
|
52
53
|
tsFiles = {};
|
|
53
54
|
apiFiles = {};
|
|
54
55
|
sourceTracker;
|
|
55
56
|
fsOperationQueue;
|
|
57
|
+
operationProcessor;
|
|
56
58
|
generationNumberSequence;
|
|
57
59
|
routes = {};
|
|
58
60
|
watcher;
|
|
@@ -65,6 +67,12 @@ export class FileSyncManager extends TracedEventEmitter {
|
|
|
65
67
|
this.fsOperationQueue = fsOperationQueue;
|
|
66
68
|
this.generationNumberSequence = generationNumberSequence;
|
|
67
69
|
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();
|
|
68
76
|
applyErrorHandling(this, {
|
|
69
77
|
watch: { operation: "editing from code" },
|
|
70
78
|
handleCreatePage: { operation: "creating a page" },
|
|
@@ -219,139 +227,203 @@ export class FileSyncManager extends TracedEventEmitter {
|
|
|
219
227
|
this.updateApi(content, path);
|
|
220
228
|
}
|
|
221
229
|
});
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
230
|
+
watcher.on("all", this.handleFileChange);
|
|
231
|
+
}
|
|
232
|
+
enableOperationsQueue() {
|
|
233
|
+
this.operationProcessor.enable();
|
|
234
|
+
}
|
|
235
|
+
disableOperationsQueue() {
|
|
236
|
+
this.operationProcessor.disable();
|
|
237
|
+
}
|
|
238
|
+
async flushOperations() {
|
|
239
|
+
await this.operationProcessor.flush();
|
|
240
|
+
}
|
|
241
|
+
handleFileChange = async (event, filePath) => {
|
|
242
|
+
const logger = getLogger();
|
|
243
|
+
logger.info(`File changed: ${filePath}, event: ${event}`);
|
|
244
|
+
const rootPath = this.rootDir;
|
|
245
|
+
if (!rootPath) {
|
|
246
|
+
throw new Error("Root directory not set");
|
|
247
|
+
}
|
|
248
|
+
// Skip directory events
|
|
249
|
+
if (event === "addDir" || event === "unlinkDir") {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const routePath = path.join(rootPath, ROUTES_FILE);
|
|
253
|
+
const fileType = SUPPORTED_FILETYPES.find((f) => filePath.endsWith(f.extension));
|
|
254
|
+
// Only handle files we care about and that are in our root path
|
|
255
|
+
if (!fileType || !filePath.startsWith(rootPath)) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
// Queue the operation based on the event type
|
|
259
|
+
switch (event) {
|
|
260
|
+
case "add": {
|
|
261
|
+
const data = await readFile(filePath);
|
|
262
|
+
if (typeof data !== "string")
|
|
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
|
+
});
|
|
255
283
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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);
|
|
284
|
+
else {
|
|
285
|
+
void this.operationProcessor.addOperation({
|
|
286
|
+
metadata: {
|
|
287
|
+
filePath,
|
|
288
|
+
},
|
|
289
|
+
execute: async () => {
|
|
290
|
+
switch (fileType.type) {
|
|
291
|
+
case "api":
|
|
292
|
+
case "python-api-step":
|
|
293
|
+
case "js-api-step": {
|
|
294
|
+
await this.processApiUpdates(filePath, fileType);
|
|
295
|
+
break;
|
|
286
296
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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);
|
|
290
316
|
}
|
|
291
317
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
case "python-api-step":
|
|
295
|
-
case "js-api-step":
|
|
296
|
-
{
|
|
297
|
-
await this.processApiUpdates(filePath, fileType);
|
|
318
|
+
catch (e) {
|
|
319
|
+
logger.error("Error parsing routes file", getErrorMeta(e));
|
|
298
320
|
}
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
return;
|
|
302
324
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
325
|
+
else {
|
|
326
|
+
void this.operationProcessor.addOperation({
|
|
327
|
+
metadata: {
|
|
328
|
+
filePath,
|
|
329
|
+
},
|
|
330
|
+
execute: async () => {
|
|
331
|
+
const fileType = SUPPORTED_FILETYPES.find((f) => filePath.endsWith(f.extension));
|
|
332
|
+
if (!fileType || !filePath.startsWith(rootPath)) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const data = await readFile(filePath);
|
|
336
|
+
if (typeof data !== "string")
|
|
337
|
+
return;
|
|
338
|
+
switch (fileType.type) {
|
|
339
|
+
case "tsx":
|
|
340
|
+
case "scope":
|
|
341
|
+
{
|
|
342
|
+
if (!(filePath in this.tsFiles &&
|
|
343
|
+
this.tsFiles[filePath] === data)) {
|
|
344
|
+
logger.info(`File changed: ${filePath} updating AST tracker`);
|
|
345
|
+
this.tsFiles[filePath] = data;
|
|
346
|
+
// only update the source tracker if the file is different
|
|
347
|
+
this.handleNonVisualChangeByDeletingIds(filePath, data);
|
|
348
|
+
this.emit("fileChanged", filePath, data, true);
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
logger.info(`File unchanged from last tracked state: ${filePath}`);
|
|
352
|
+
this.emit("fileChanged", filePath, data, false);
|
|
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
|
+
});
|
|
331
366
|
}
|
|
367
|
+
break;
|
|
332
368
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
369
|
+
case "unlink": {
|
|
370
|
+
if (filePath in this.tsFiles) {
|
|
371
|
+
void this.operationProcessor.addOperation({
|
|
372
|
+
metadata: {
|
|
373
|
+
filePath,
|
|
374
|
+
},
|
|
375
|
+
execute: async () => {
|
|
376
|
+
await this.deleteTsFile(filePath);
|
|
377
|
+
},
|
|
342
378
|
});
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
379
|
+
}
|
|
380
|
+
else if (filePath in this.apiFiles) {
|
|
381
|
+
void this.operationProcessor.addOperation({
|
|
382
|
+
metadata: {
|
|
383
|
+
filePath,
|
|
384
|
+
},
|
|
385
|
+
execute: async () => {
|
|
386
|
+
await this.deleteApiFile(filePath);
|
|
387
|
+
},
|
|
348
388
|
});
|
|
389
|
+
}
|
|
390
|
+
break;
|
|
349
391
|
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
392
|
+
}
|
|
393
|
+
};
|
|
352
394
|
getApiFiles() {
|
|
353
395
|
return this.formatApisToClientApis(this.apiFiles);
|
|
354
396
|
}
|
|
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
|
+
}
|
|
355
427
|
getTsFilePaths() {
|
|
356
428
|
return Object.keys(this.tsFiles);
|
|
357
429
|
}
|
|
@@ -568,11 +640,11 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
568
640
|
handleReparent = async (payload, writeFile = true) => {
|
|
569
641
|
const { from, to, changedProps, transaction } = payload;
|
|
570
642
|
this.trackTransaction(transaction?.id);
|
|
571
|
-
|
|
643
|
+
this.sourceTracker?.setProperties({
|
|
572
644
|
source: from.source,
|
|
573
645
|
changes: changedProps ?? {},
|
|
574
646
|
});
|
|
575
|
-
|
|
647
|
+
this.sourceTracker?.moveElement({
|
|
576
648
|
from,
|
|
577
649
|
to,
|
|
578
650
|
});
|
|
@@ -586,7 +658,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
586
658
|
};
|
|
587
659
|
handleCreateComponent = async (payload, writeFile = true) => {
|
|
588
660
|
this.trackTransaction(payload.transaction?.id);
|
|
589
|
-
const sourceId =
|
|
661
|
+
const sourceId = this.sourceTracker?.addElement(payload);
|
|
590
662
|
if (writeFile) {
|
|
591
663
|
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
592
664
|
await this.writeChanges(changes ?? [], (fileName) => {
|
|
@@ -600,7 +672,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
600
672
|
const { elements, transaction } = payload;
|
|
601
673
|
this.trackTransaction(transaction?.id);
|
|
602
674
|
for (const element of elements) {
|
|
603
|
-
|
|
675
|
+
this.sourceTracker?.deleteElement({
|
|
604
676
|
source: element.source,
|
|
605
677
|
scopeName: element.scopeName,
|
|
606
678
|
});
|
|
@@ -616,7 +688,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
616
688
|
handleSetProperty = async (payload, writeFile = true) => {
|
|
617
689
|
const { element: { source }, property, value, transaction, } = payload;
|
|
618
690
|
this.trackTransaction(transaction?.id);
|
|
619
|
-
|
|
691
|
+
this.sourceTracker?.setProperty({
|
|
620
692
|
source,
|
|
621
693
|
property,
|
|
622
694
|
info: value,
|
|
@@ -631,7 +703,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
631
703
|
handleSetProperties = async (payload, writeFile = true) => {
|
|
632
704
|
const { element: { source }, properties, transaction, } = payload;
|
|
633
705
|
this.trackTransaction(transaction?.id);
|
|
634
|
-
|
|
706
|
+
this.sourceTracker?.setProperties({
|
|
635
707
|
source,
|
|
636
708
|
changes: properties,
|
|
637
709
|
});
|
|
@@ -765,7 +837,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
765
837
|
await fs.rmdir(apiDir, { recursive: true });
|
|
766
838
|
}
|
|
767
839
|
delete this.apiFiles[apiFilePath];
|
|
768
|
-
const scopeId =
|
|
840
|
+
const scopeId = this.sourceTracker.deleteApi({
|
|
769
841
|
pageName,
|
|
770
842
|
apiName,
|
|
771
843
|
});
|
|
@@ -864,7 +936,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
864
936
|
}));
|
|
865
937
|
};
|
|
866
938
|
handleAddEntity = async (payload) => {
|
|
867
|
-
|
|
939
|
+
this.sourceTracker?.addEntity({
|
|
868
940
|
scopeId: payload.scopeId,
|
|
869
941
|
entity: {
|
|
870
942
|
type: payload.type,
|
|
@@ -878,7 +950,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
878
950
|
});
|
|
879
951
|
};
|
|
880
952
|
handleUpdateEntity = async (payload) => {
|
|
881
|
-
|
|
953
|
+
this.sourceTracker?.updateEntity({
|
|
882
954
|
entityId: payload.entityId,
|
|
883
955
|
updates: payload.updates,
|
|
884
956
|
});
|
|
@@ -888,7 +960,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
888
960
|
});
|
|
889
961
|
};
|
|
890
962
|
handleDeleteEntity = async (payload) => {
|
|
891
|
-
const deletedEntityName =
|
|
963
|
+
const deletedEntityName = this.sourceTracker?.deleteEntity({
|
|
892
964
|
entityId: payload.entityId,
|
|
893
965
|
});
|
|
894
966
|
const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
|
|
@@ -904,7 +976,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
904
976
|
throw new Error("Root directory not set");
|
|
905
977
|
}
|
|
906
978
|
const filePath = path.join(this.rootDir, APP_THEME_FILE_NAME);
|
|
907
|
-
|
|
979
|
+
this.sourceTracker?.updateTheme({
|
|
908
980
|
themeFilePath: filePath,
|
|
909
981
|
theme,
|
|
910
982
|
});
|
|
@@ -942,7 +1014,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
942
1014
|
};
|
|
943
1015
|
handleRenameEntity = async (payload) => {
|
|
944
1016
|
const { elementId, newName, oldName, scopeName } = payload;
|
|
945
|
-
|
|
1017
|
+
this.sourceTracker?.renameEntity({
|
|
946
1018
|
entityId: elementId,
|
|
947
1019
|
oldName,
|
|
948
1020
|
newName,
|
|
@@ -1161,7 +1233,7 @@ export default registerPage(Page, { name: "${name}" });
|
|
|
1161
1233
|
}
|
|
1162
1234
|
}
|
|
1163
1235
|
// Add new mock implementation
|
|
1164
|
-
export class MockFileSyncManager extends
|
|
1236
|
+
export class MockFileSyncManager extends FileSystemManager {
|
|
1165
1237
|
tsFiles = {};
|
|
1166
1238
|
apiFiles = {};
|
|
1167
1239
|
async watch(_watcher, _path) {
|
|
@@ -1237,7 +1309,7 @@ async function readFiles(dir) {
|
|
|
1237
1309
|
const getMergedApiContent = async (path) => {
|
|
1238
1310
|
return readAppApiYamlFile(path.split("/").slice(0, -1).join("/"));
|
|
1239
1311
|
};
|
|
1240
|
-
const getPageName = (path) => {
|
|
1312
|
+
export const getPageName = (path) => {
|
|
1241
1313
|
const parts = path.split("/");
|
|
1242
1314
|
const pagesIndex = parts.findIndex((part) => part === "pages");
|
|
1243
1315
|
if (pagesIndex !== -1 && parts[pagesIndex + 1]) {
|