@chromahq/core 1.0.54 → 1.0.56

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.
@@ -343,8 +343,10 @@ const _PopupVisibilityService = class _PopupVisibilityService {
343
343
  onPortConnected() {
344
344
  const wasVisible = this.isPopupVisible();
345
345
  this.connectedPortCount++;
346
+ console.log(`[PopupVisibilityService] Port connected, count: ${this.connectedPortCount}`);
346
347
  if (!wasVisible && this.isPopupVisible()) {
347
348
  this.lastVisibilityChangeAt = Date.now();
349
+ console.log("[PopupVisibilityService] Popup became visible, notifying listeners");
348
350
  this.notifyListeners(true);
349
351
  }
350
352
  }
@@ -355,8 +357,10 @@ const _PopupVisibilityService = class _PopupVisibilityService {
355
357
  onPortDisconnected() {
356
358
  const wasVisible = this.isPopupVisible();
357
359
  this.connectedPortCount = Math.max(0, this.connectedPortCount - 1);
360
+ console.log(`[PopupVisibilityService] Port disconnected, count: ${this.connectedPortCount}`);
358
361
  if (wasVisible && !this.isPopupVisible()) {
359
362
  this.lastVisibilityChangeAt = Date.now();
363
+ console.log("[PopupVisibilityService] Popup became hidden, notifying listeners");
360
364
  this.notifyListeners(false);
361
365
  }
362
366
  }
@@ -1309,7 +1313,7 @@ class JobRegistry {
1309
1313
  }
1310
1314
  pause(id) {
1311
1315
  const entry = this.jobs.get(id);
1312
- if (entry && entry.context.state === JobState.RUNNING) {
1316
+ if (entry && (entry.context.state === JobState.RUNNING || entry.context.state === JobState.SCHEDULED)) {
1313
1317
  this.updateState(id, JobState.PAUSED);
1314
1318
  this.clearTimers(id);
1315
1319
  entry.job.pause?.();
@@ -1974,7 +1978,9 @@ class Scheduler {
1974
1978
  */
1975
1979
  setupPopupVisibilityListener() {
1976
1980
  const visibilityService = PopupVisibilityService.instance;
1981
+ this.logger.info("[Scheduler] Setting up popup visibility listener");
1977
1982
  this.popupVisibilityUnsubscribe = visibilityService.onVisibilityChange((isVisible) => {
1983
+ this.logger.info(`[Scheduler] Visibility changed: ${isVisible ? "visible" : "hidden"}`);
1978
1984
  if (isVisible) {
1979
1985
  this.resumePopupDependentJobs();
1980
1986
  } else {
@@ -1987,18 +1993,29 @@ class Scheduler {
1987
1993
  */
1988
1994
  pausePopupDependentJobs() {
1989
1995
  const jobs = this.registry.listAll();
1996
+ this.logger.info(`[Scheduler] pausePopupDependentJobs called, total jobs: ${jobs.length}`);
1990
1997
  let pausedCount = 0;
1998
+ const pausedJobIds = [];
1991
1999
  for (const job of jobs) {
1992
- if (job.options?.requiresPopup && !this.registry.getContext(job.id)?.isPaused()) {
1993
- this.logger.debug(`Pausing popup-dependent job: ${job.id}`);
2000
+ const hasRequiresPopup = job.options?.requiresPopup;
2001
+ const isPaused = this.registry.getContext(job.id)?.isPaused();
2002
+ this.logger.debug(
2003
+ `[Scheduler] Job ${job.id}: requiresPopup=${hasRequiresPopup}, isPaused=${isPaused}`
2004
+ );
2005
+ if (hasRequiresPopup && !isPaused) {
1994
2006
  this.alarm.cancel(job.id);
1995
2007
  this.timeout.cancel(job.id);
1996
2008
  this.registry.pause(job.id);
2009
+ pausedJobIds.push(job.id);
1997
2010
  pausedCount++;
1998
2011
  }
1999
2012
  }
2000
2013
  if (pausedCount > 0) {
2001
- this.logger.info(`Paused ${pausedCount} popup-dependent jobs (popup closed)`);
2014
+ this.logger.info(
2015
+ `[Scheduler] Paused ${pausedCount} popup-dependent jobs (popup closed): ${pausedJobIds.join(", ")}`
2016
+ );
2017
+ } else {
2018
+ this.logger.info(`[Scheduler] No popup-dependent jobs to pause`);
2002
2019
  }
2003
2020
  }
2004
2021
  /**
@@ -2006,17 +2023,28 @@ class Scheduler {
2006
2023
  */
2007
2024
  resumePopupDependentJobs() {
2008
2025
  const jobs = this.registry.listAll();
2026
+ this.logger.info(`[Scheduler] resumePopupDependentJobs called, total jobs: ${jobs.length}`);
2009
2027
  let resumedCount = 0;
2028
+ const resumedJobIds = [];
2010
2029
  for (const job of jobs) {
2011
- if (job.options?.requiresPopup && this.registry.getContext(job.id)?.isPaused()) {
2012
- this.logger.debug(`Resuming popup-dependent job: ${job.id}`);
2030
+ const hasRequiresPopup = job.options?.requiresPopup;
2031
+ const isPaused = this.registry.getContext(job.id)?.isPaused();
2032
+ this.logger.debug(
2033
+ `[Scheduler] Job ${job.id}: requiresPopup=${hasRequiresPopup}, isPaused=${isPaused}`
2034
+ );
2035
+ if (hasRequiresPopup && isPaused) {
2013
2036
  this.registry.resume(job.id);
2014
2037
  this.schedule(job.id, job.options);
2038
+ resumedJobIds.push(job.id);
2015
2039
  resumedCount++;
2016
2040
  }
2017
2041
  }
2018
2042
  if (resumedCount > 0) {
2019
- this.logger.info(`Resumed ${resumedCount} popup-dependent jobs (popup opened)`);
2043
+ this.logger.info(
2044
+ `[Scheduler] Resumed ${resumedCount} popup-dependent jobs (popup opened): ${resumedJobIds.join(", ")}`
2045
+ );
2046
+ } else {
2047
+ this.logger.info(`[Scheduler] No popup-dependent jobs to resume`);
2020
2048
  }
2021
2049
  }
2022
2050
  schedule(id, options) {
@@ -2204,7 +2232,7 @@ class ApplicationBootstrap {
2204
2232
  }) {
2205
2233
  try {
2206
2234
  this.logger = new BootstrapLogger(enableLogs);
2207
- this.logger.info("\u{1F680} Starting Chroma application bootstrap...");
2235
+ this.logger.info("Starting Chroma application bootstrap...");
2208
2236
  await this.discoverAndInitializeStores();
2209
2237
  await this.discoverServices();
2210
2238
  const store = this.storeDefinitions[0].store;
@@ -2225,9 +2253,9 @@ class ApplicationBootstrap {
2225
2253
  await this.bootMessages();
2226
2254
  await this.bootServices();
2227
2255
  }
2228
- this.logger.success("\u{1F389} Chroma application initialization complete!");
2256
+ this.logger.success("Chroma application initialization complete");
2229
2257
  } catch (error) {
2230
- this.logger.error("\u{1F4A5} Application bootstrap failed:", error);
2258
+ this.logger.error("Application bootstrap failed:", error);
2231
2259
  throw error;
2232
2260
  }
2233
2261
  }
@@ -2235,7 +2263,7 @@ class ApplicationBootstrap {
2235
2263
  * Boot all registered services by calling their onBoot method if present
2236
2264
  */
2237
2265
  async bootServices() {
2238
- this.logger.info("\u{1F680} Booting services...");
2266
+ this.logger.info("Booting services...");
2239
2267
  const bootPromises = Array.from(this.serviceRegistry.entries()).map(
2240
2268
  async ([serviceName, ServiceClass]) => {
2241
2269
  try {
@@ -2258,7 +2286,7 @@ class ApplicationBootstrap {
2258
2286
  * Discover all services in the application directory
2259
2287
  */
2260
2288
  async discoverServices() {
2261
- this.logger.info("\u{1F50D} Discovering services...");
2289
+ this.logger.info("Discovering services...");
2262
2290
  const serviceModules = undefined(
2263
2291
  "/src/app/services/**/*.service.{ts,js}",
2264
2292
  { eager: true }
@@ -2273,7 +2301,7 @@ class ApplicationBootstrap {
2273
2301
  }
2274
2302
  const circularDepsResult = this.detectCircularDependencies(serviceClasses);
2275
2303
  if (circularDepsResult.hasCircularDependencies) {
2276
- this.logger.error("\u{1F4A5} Circular dependencies detected!");
2304
+ this.logger.error("Circular dependencies detected!");
2277
2305
  circularDepsResult.cycles.forEach((cycle, index) => {
2278
2306
  this.logger.error(`Cycle ${index + 1}: ${cycle.cycle.join(" \u2192 ")} \u2192 ${cycle.cycle[0]}`);
2279
2307
  });
@@ -2281,10 +2309,10 @@ class ApplicationBootstrap {
2281
2309
  }
2282
2310
  for (const ServiceClass of serviceClasses) {
2283
2311
  container.bind(ServiceClass).toSelf().inSingletonScope();
2284
- this.logger.debug(`\u{1F4E6} Discovered service: ${ServiceClass.name}`);
2312
+ this.logger.debug(`Discovered service: ${ServiceClass.name}`);
2285
2313
  }
2286
2314
  this.logger.success(
2287
- `\u2705 Registered ${serviceClasses.length} services without circular dependencies`
2315
+ `Registered ${serviceClasses.length} services without circular dependencies`
2288
2316
  );
2289
2317
  }
2290
2318
  /**
@@ -2416,17 +2444,17 @@ class ApplicationBootstrap {
2416
2444
  analyzeDependencies() {
2417
2445
  const serviceClasses = Array.from(this.serviceRegistry.values());
2418
2446
  const result = this.detectCircularDependencies(serviceClasses);
2419
- this.logger.info("\u{1F4CA} Dependency Analysis Report:");
2447
+ this.logger.info("Dependency Analysis Report:");
2420
2448
  this.logger.info(`Total Services: ${result.dependencyGraph.size}`);
2421
2449
  if (result.hasCircularDependencies) {
2422
- this.logger.error(`\u{1F504} Circular Dependencies Found: ${result.cycles.length}`);
2450
+ this.logger.error(`Circular Dependencies Found: ${result.cycles.length}`);
2423
2451
  result.cycles.forEach((cycle, index) => {
2424
2452
  this.logger.error(` Cycle ${index + 1}: ${cycle.cycle.join(" \u2192 ")} \u2192 ${cycle.cycle[0]}`);
2425
2453
  });
2426
2454
  } else {
2427
- this.logger.success("\u2705 No circular dependencies detected");
2455
+ this.logger.success("No circular dependencies detected");
2428
2456
  }
2429
- this.logger.info("\u{1F333} Service Dependency Tree:");
2457
+ this.logger.info("Service Dependency Tree:");
2430
2458
  for (const [serviceName, node] of result.dependencyGraph) {
2431
2459
  if (node.dependencies.length > 0) {
2432
2460
  this.logger.info(` ${serviceName} depends on:`);
@@ -2444,7 +2472,7 @@ class ApplicationBootstrap {
2444
2472
  async discoverAndInitializeStores() {
2445
2473
  try {
2446
2474
  if (this.storeDefinitions.length === 0) {
2447
- this.logger.debug("\u{1F4ED} No store definitions provided");
2475
+ this.logger.debug("No store definitions provided");
2448
2476
  return;
2449
2477
  }
2450
2478
  this.logger.info(`Initializing ${this.storeDefinitions.length} store(s)...`);
@@ -2455,7 +2483,7 @@ class ApplicationBootstrap {
2455
2483
  const classes = store.classes;
2456
2484
  container.bind(diKey).toConstantValue(storeInstance);
2457
2485
  if (isFirstStore) {
2458
- container.bind(Symbol.for("Store")).toConstantValue(storeInstance);
2486
+ container.bind(/* @__PURE__ */ Symbol.for("Store")).toConstantValue(storeInstance);
2459
2487
  isFirstStore = false;
2460
2488
  }
2461
2489
  await this.registerMessageClass(
@@ -2472,18 +2500,18 @@ class ApplicationBootstrap {
2472
2500
  `store:${store.def.name}:reset`
2473
2501
  );
2474
2502
  }
2475
- this.logger.debug(`\u2705 Initialized store: ${store.def.name}`);
2503
+ this.logger.debug(`Initialized store: ${store.def.name}`);
2476
2504
  }
2477
- this.logger.success(`\u2705 Initialized ${this.storeDefinitions.length} store(s)`);
2505
+ this.logger.success(`Initialized ${this.storeDefinitions.length} store(s)`);
2478
2506
  } catch (error) {
2479
- this.logger.error("\u274C Failed to initialize stores:", error);
2507
+ this.logger.error("Failed to initialize stores:", error);
2480
2508
  }
2481
2509
  }
2482
2510
  /**
2483
2511
  * Register message handlers
2484
2512
  */
2485
2513
  async registerMessages() {
2486
- this.logger.info("\u{1F4E8} Registering messages...");
2514
+ this.logger.info("Registering messages...");
2487
2515
  const messageModules = undefined(
2488
2516
  "/src/app/messages/**/*.message.{ts,js}",
2489
2517
  { eager: true }
@@ -2496,7 +2524,7 @@ class ApplicationBootstrap {
2496
2524
  if (messageClasses.length > 0) {
2497
2525
  const circularDepsResult = this.detectCircularDependencies(messageClasses);
2498
2526
  if (circularDepsResult.hasCircularDependencies) {
2499
- this.logger.error("\u{1F4A5} Circular dependencies detected in messages!");
2527
+ this.logger.error("Circular dependencies detected in messages!");
2500
2528
  circularDepsResult.cycles.forEach((cycle, index) => {
2501
2529
  this.logger.error(
2502
2530
  `Message Cycle ${index + 1}: ${cycle.cycle.join(" \u2192 ")} \u2192 ${cycle.cycle[0]}`
@@ -2511,30 +2539,30 @@ class ApplicationBootstrap {
2511
2539
  try {
2512
2540
  for (const [name, ServiceClass] of this.serviceRegistry) {
2513
2541
  if (!ServiceClass) {
2514
- this.logger.warn(`\u26A0\uFE0F Service not found in registry: ${name}`);
2542
+ this.logger.warn(`Service not found in registry: ${name}`);
2515
2543
  }
2516
2544
  if (!container.isBound(ServiceClass)) {
2517
- this.logger.warn(`\u26A0\uFE0F Service not bound in container: ${name}`);
2545
+ this.logger.warn(`Service not bound in container: ${name}`);
2518
2546
  }
2519
2547
  }
2520
2548
  const messageMetadata = Reflect.getMetadata("name", MessageClass);
2521
2549
  const messageName = messageMetadata || MessageClass.name;
2522
2550
  container.bind(messageName).to(MessageClass).inSingletonScope();
2523
- this.logger.success(`\u2705 Registered message: ${messageName}`);
2551
+ this.logger.success(`Registered message: ${messageName}`);
2524
2552
  } catch (error) {
2525
- this.logger.error(`\u274C Failed to register message ${MessageClass.name}:`, error);
2553
+ this.logger.error(`Failed to register message ${MessageClass.name}:`, error);
2526
2554
  }
2527
2555
  }
2528
2556
  }
2529
2557
  async registerMessageClass(MessageClass, name) {
2530
2558
  container.bind(name).to(MessageClass).inSingletonScope();
2531
- this.logger.success(`\u2705 Registered message: ${name}`);
2559
+ this.logger.success(`Registered message: ${name}`);
2532
2560
  }
2533
2561
  /**
2534
2562
  * Boot all registered messages
2535
2563
  */
2536
2564
  async bootMessages() {
2537
- this.logger.info("\u{1F680} Booting messages...");
2565
+ this.logger.info("Booting messages...");
2538
2566
  const messageModules = undefined(
2539
2567
  "/src/app/messages/**/*.message.{ts,js}",
2540
2568
  { eager: true }
@@ -2549,10 +2577,10 @@ class ApplicationBootstrap {
2549
2577
  const messageName = messageMetadata || MessageClass.name;
2550
2578
  const messageInstance = container.get(messageName);
2551
2579
  await messageInstance.boot();
2552
- this.logger.success(`\u2705 Booted message: ${messageName}`);
2580
+ this.logger.success(`Booted message: ${messageName}`);
2553
2581
  return { messageName, success: true };
2554
2582
  } catch (error) {
2555
- this.logger.error(`\u274C Failed to boot message ${MessageClass.name}:`, error);
2583
+ this.logger.error(`Failed to boot message ${MessageClass.name}:`, error);
2556
2584
  return { messageName: MessageClass.name, success: false, error };
2557
2585
  }
2558
2586
  });
@@ -2562,7 +2590,7 @@ class ApplicationBootstrap {
2562
2590
  * Register jobs for scheduled execution
2563
2591
  */
2564
2592
  async registerJobs() {
2565
- this.logger.info("\u{1F552} Registering jobs...");
2593
+ this.logger.info("Registering jobs...");
2566
2594
  const jobModules = undefined(
2567
2595
  "/src/app/jobs/**/*.job.{ts,js}",
2568
2596
  { eager: true }
@@ -2573,10 +2601,10 @@ class ApplicationBootstrap {
2573
2601
  this.logger.debug("container isBound(Scheduler)", { isBound: container.isBound(Scheduler) });
2574
2602
  for (const [name, ServiceClass] of this.serviceRegistry) {
2575
2603
  if (!ServiceClass) {
2576
- this.logger.warn(`\u26A0\uFE0F Service not found in registry: ${name}`);
2604
+ this.logger.warn(`Service not found in registry: ${name}`);
2577
2605
  }
2578
2606
  if (!container.isBound(ServiceClass)) {
2579
- this.logger.warn(`\u26A0\uFE0F Service not bound in container: ${name}`);
2607
+ this.logger.warn(`Service not bound in container: ${name}`);
2580
2608
  } else {
2581
2609
  container.get(ServiceClass);
2582
2610
  }
@@ -2596,23 +2624,42 @@ class ApplicationBootstrap {
2596
2624
  container.bind(id).to(JobClass).inSingletonScope();
2597
2625
  const options = Reflect.getMetadata("job:options", JobClass) || {};
2598
2626
  jobEntries.push({ JobClass, jobName, id, options });
2599
- this.logger.debug(`\u{1F4E6} Bound job: ${jobName}`);
2627
+ this.logger.debug(`Bound job: ${jobName}`);
2600
2628
  } catch (error) {
2601
- this.logger.error(`\u274C Failed to bind job ${JobClass.name}:`, error);
2629
+ this.logger.error(`Failed to bind job ${JobClass.name}:`, error);
2602
2630
  }
2603
2631
  }
2604
2632
  for (const { JobClass, jobName, id, options } of jobEntries) {
2605
2633
  try {
2606
2634
  const instance = container.get(JobClass);
2607
2635
  JobRegistry.instance.register(id, instance, options);
2636
+ if (typeof instance.onBoot === "function") {
2637
+ this.logger.info(`Executing onBoot for job: ${jobName}`);
2638
+ try {
2639
+ if (options.requiresPopup) {
2640
+ const isPopupVisible = PopupVisibilityService.instance.isPopupVisible();
2641
+ if (!isPopupVisible) {
2642
+ this.logger.debug(`Skipping onBoot for job ${jobName} - popup not visible`);
2643
+ } else {
2644
+ await instance.onBoot();
2645
+ this.logger.debug(`Executed onBoot for job: ${jobName}`);
2646
+ }
2647
+ } else {
2648
+ await instance.onBoot();
2649
+ this.logger.debug(`Executed onBoot for job: ${jobName}`);
2650
+ }
2651
+ } catch (error) {
2652
+ this.logger.error(`Failed to execute onBoot for job ${jobName}:`, error);
2653
+ }
2654
+ }
2608
2655
  if (!options.startPaused) {
2609
2656
  this.scheduler.schedule(id, options);
2610
2657
  } else {
2611
- this.logger.info(`\u23F8\uFE0F Job ${jobName} registered but paused (startPaused: true)`);
2658
+ this.logger.info(`Job ${jobName} registered but paused (startPaused: true)`);
2612
2659
  }
2613
- this.logger.success(`\u2705 Registered job: ${jobName}`);
2660
+ this.logger.success(`Registered job: ${jobName}`);
2614
2661
  } catch (error) {
2615
- this.logger.error(`\u274C Failed to register job ${JobClass.name}:`, error);
2662
+ this.logger.error(`Failed to register job ${JobClass.name}:`, error);
2616
2663
  }
2617
2664
  }
2618
2665
  }
@@ -2711,4 +2758,4 @@ exports.getNonceService = getNonceService;
2711
2758
  exports.getPopupVisibilityService = getPopupVisibilityService;
2712
2759
  exports.isEarlyListenerSetup = isEarlyListenerSetup;
2713
2760
  exports.setupEarlyListener = setupEarlyListener;
2714
- //# sourceMappingURL=boot-CcvC3GTE.js.map
2761
+ //# sourceMappingURL=boot-CUFlC4bu.js.map