@base44-preview/cli 0.0.37-pr.364.24d182e → 0.0.37-pr.364.45ad860

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/cli/index.js CHANGED
@@ -246241,20 +246241,23 @@ var WATCH_QUEUE_DELAY_MS = 500;
246241
246241
  class WatchBase44 extends EventEmitter4 {
246242
246242
  itemsToWatch;
246243
246243
  logger;
246244
+ entryNames;
246244
246245
  watchers = new Map;
246245
246246
  queueWaitForCreationTimeout = null;
246246
246247
  constructor(itemsToWatch, logger) {
246247
246248
  super();
246248
246249
  this.itemsToWatch = itemsToWatch;
246249
246250
  this.logger = logger;
246251
+ this.entryNames = Object.keys(itemsToWatch);
246250
246252
  }
246251
246253
  async start() {
246252
246254
  if (this.watchers.size > 0) {
246253
246255
  return;
246254
246256
  }
246255
- for (const item of Object.values(this.itemsToWatch)) {
246256
- if (await pathExists(item.path)) {
246257
- this.watchers.set(item.name, this.watchTarget(item));
246257
+ for (const name2 of this.entryNames) {
246258
+ const targetPath = this.itemsToWatch[name2];
246259
+ if (await pathExists(targetPath)) {
246260
+ this.watchers.set(name2, this.watchTarget(name2, targetPath));
246258
246261
  }
246259
246262
  }
246260
246263
  this.watchEntries();
@@ -246274,19 +246277,20 @@ class WatchBase44 extends EventEmitter4 {
246274
246277
  clearTimeout(this.queueWaitForCreationTimeout);
246275
246278
  }
246276
246279
  this.queueWaitForCreationTimeout = setTimeout(async () => {
246277
- for (const item of Object.values(this.itemsToWatch)) {
246278
- const watchItem = this.watchers.get(item.name);
246279
- const exists = await pathExists(item.path);
246280
+ for (const name2 of this.entryNames) {
246281
+ const path19 = this.itemsToWatch[name2];
246282
+ const watchItem = this.watchers.get(name2);
246283
+ const exists = await pathExists(path19);
246280
246284
  if (!watchItem && exists) {
246281
- await this.createChangeHandler(item)("", item.path);
246282
- this.watchers.set(item.name, this.watchTarget(item));
246285
+ this.emit("change", name2, path19);
246286
+ this.watchers.set(name2, this.watchTarget(name2, path19));
246283
246287
  } else if (watchItem && !exists) {
246284
246288
  await watchItem.close();
246285
- await this.createChangeHandler(item)("", item.path);
246289
+ this.emit("change", name2, path19);
246286
246290
  setTimeout(() => {
246287
- this.watchers.forEach((watcher, name2) => {
246291
+ this.watchers.forEach((watcher, watcherName) => {
246288
246292
  if (watcher.closed) {
246289
- this.watchers.delete(name2);
246293
+ this.watchers.delete(watcherName);
246290
246294
  }
246291
246295
  });
246292
246296
  });
@@ -246296,18 +246300,15 @@ class WatchBase44 extends EventEmitter4 {
246296
246300
  this.watchEntries();
246297
246301
  }, WATCH_QUEUE_DELAY_MS);
246298
246302
  }
246299
- createChangeHandler = (item) => {
246300
- return import_debounce.default(async (_event, path19) => {
246301
- this.emit("change", item.name, relative4(item.path, path19));
246302
- }, WATCH_DEBOUNCE_MS);
246303
- };
246304
- watchTarget(item) {
246305
- const watcher = watch(item.path, {
246303
+ watchTarget(name2, targetPath) {
246304
+ const watcher = watch(targetPath, {
246306
246305
  ignoreInitial: true
246307
246306
  });
246308
- watcher.on("all", this.createChangeHandler(item));
246307
+ watcher.on("all", import_debounce.default(async (_event, path19) => {
246308
+ this.emit("change", name2, relative4(targetPath, path19));
246309
+ }, WATCH_DEBOUNCE_MS));
246309
246310
  watcher.on("error", (err) => {
246310
- this.logger.error(`[dev-server] Watch handler failed for ${item.path}`, err instanceof Error ? err : undefined);
246311
+ this.logger.error(`Watch handler failed for ${targetPath}`, err instanceof Error ? err : undefined);
246311
246312
  });
246312
246313
  return watcher;
246313
246314
  }
@@ -246381,19 +246382,13 @@ async function createDevServer(options8) {
246381
246382
  broadcastEntityEvent(io6, appId, entityName, event);
246382
246383
  };
246383
246384
  const base44ConfigWatcher = new WatchBase44({
246384
- functions: {
246385
- name: "functions",
246386
- path: join18(dirname14(project2.configPath), project2.functionsDir)
246387
- },
246388
- entities: {
246389
- name: "entities",
246390
- path: join18(dirname14(project2.configPath), project2.entitiesDir)
246391
- }
246385
+ functions: join18(dirname14(project2.configPath), project2.functionsDir),
246386
+ entities: join18(dirname14(project2.configPath), project2.entitiesDir)
246392
246387
  }, devLogger);
246393
246388
  base44ConfigWatcher.on("change", async (name2) => {
246394
246389
  try {
246390
+ const { functions: functions2, entities: entities2 } = await options8.loadResources();
246395
246391
  if (name2 === "functions") {
246396
- const { functions: functions2 } = await options8.loadResources();
246397
246392
  const previousFunctionCount = functionManager.getFunctionNames().length;
246398
246393
  functionManager.reload(functions2);
246399
246394
  const names = functionManager.getFunctionNames();
@@ -246405,7 +246400,6 @@ async function createDevServer(options8) {
246405
246400
  }
246406
246401
  if (name2 === "entities") {
246407
246402
  const previousEntityCount = db2.getCollectionNames().length;
246408
- const { entities: entities2 } = await options8.loadResources();
246409
246403
  db2.dropAll();
246410
246404
  if (previousEntityCount > 0) {
246411
246405
  devLogger.log("Entities directory changed, clearing data...");
@@ -250805,4 +250799,4 @@ export {
250805
250799
  CLIExitError
250806
250800
  };
250807
250801
 
250808
- //# debugId=B55811FFD223347464756E2164756E21
250802
+ //# debugId=1F612090E5DA7F5064756E2164756E21