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