@chromahq/core 1.0.58 → 1.0.61

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.
@@ -535,11 +535,11 @@ function setupEarlyListener(portName = DEFAULT_PORT_NAME$1) {
535
535
  if (portsClaimed && onPortConnectCallback) {
536
536
  onPortConnectCallback(port);
537
537
  } else {
538
- console.log(`[EarlyListener] Captured early port connection: ${port.name}`);
538
+ console.debug(`[EarlyListener] Captured early port connection: ${port.name}`);
539
539
  earlyPorts.push(port);
540
540
  }
541
541
  });
542
- console.log(`[EarlyListener] Early connection listener registered for port: ${portName}`);
542
+ console.debug(`[EarlyListener] Early connection listener registered for port: ${portName}`);
543
543
  }
544
544
  function claimEarlyPorts(onConnect) {
545
545
  if (portsClaimed) {
@@ -551,7 +551,7 @@ function claimEarlyPorts(onConnect) {
551
551
  const captured = [...earlyPorts];
552
552
  earlyPorts.length = 0;
553
553
  if (captured.length > 0) {
554
- console.log(`[EarlyListener] Claimed ${captured.length} early port(s)`);
554
+ console.debug(`[EarlyListener] Claimed ${captured.length} early port(s)`);
555
555
  }
556
556
  return captured;
557
557
  }
@@ -667,7 +667,7 @@ const _BridgeRuntimeManager = class _BridgeRuntimeManager {
667
667
  if (!this.isValidPort(port)) {
668
668
  return;
669
669
  }
670
- this.logger.info(`\u{1F4E1} Port connected: ${port.name}`);
670
+ this.logger.debug(`\u{1F4E1} Port connected: ${port.name}`);
671
671
  this.setupMessageHandler(port);
672
672
  if (chrome.runtime.lastError) {
673
673
  this.logger.warn(`Runtime error during port setup: ${chrome.runtime.lastError.message}`);
@@ -684,7 +684,7 @@ const _BridgeRuntimeManager = class _BridgeRuntimeManager {
684
684
  if (isEarlyListenerSetup()) {
685
685
  const earlyPorts = claimEarlyPorts(handlePort);
686
686
  if (earlyPorts.length > 0) {
687
- this.logger.info(
687
+ this.logger.debug(
688
688
  `\u{1F4E1} Processing ${earlyPorts.length} early port(s) captured during bootstrap`
689
689
  );
690
690
  earlyPorts.forEach(handlePort);
@@ -738,7 +738,7 @@ const _BridgeRuntimeManager = class _BridgeRuntimeManager {
738
738
  });
739
739
  chrome.alarms.onAlarm.addListener(this.handleKeepAliveAlarm);
740
740
  this.keepAliveAlarmRegistered = true;
741
- this.logger.info("Registered keep-alive alarm for background wakeups");
741
+ this.logger.debug("Registered keep-alive alarm for background wakeups");
742
742
  }
743
743
  recordKeepAlivePing(source) {
744
744
  const timestamp = Date.now();
@@ -815,7 +815,7 @@ const _BridgeRuntimeManager = class _BridgeRuntimeManager {
815
815
  void chrome.runtime.lastError;
816
816
  this.diagnostics.lastPortDisconnectError = runtimeErrorMessage;
817
817
  } else {
818
- this.logger.info(`\u{1F4F4} Port disconnected: ${port.name}`);
818
+ this.logger.debug(`\u{1F4F4} Port disconnected: ${port.name}`);
819
819
  }
820
820
  this.diagnostics.portDisconnects++;
821
821
  this.diagnostics.lastPortDisconnectAt = Date.now();
@@ -1073,7 +1073,7 @@ const _BridgeRuntimeManager = class _BridgeRuntimeManager {
1073
1073
  */
1074
1074
  startKeepAlive() {
1075
1075
  if (this.keepAliveTimer) return;
1076
- this.logger.info("Starting keep-alive timer to keep service worker alive");
1076
+ this.logger.debug("Starting keep-alive timer to keep service worker alive");
1077
1077
  this.keepAliveTimer = setInterval(() => {
1078
1078
  chrome.runtime.getPlatformInfo(() => {
1079
1079
  this.recordKeepAlivePing("interval");
@@ -1093,7 +1093,7 @@ const _BridgeRuntimeManager = class _BridgeRuntimeManager {
1093
1093
  if (this.keepAliveTimer) {
1094
1094
  clearInterval(this.keepAliveTimer);
1095
1095
  this.keepAliveTimer = null;
1096
- this.logger.info("Stopped keep-alive timer");
1096
+ this.logger.debug("Stopped keep-alive timer");
1097
1097
  }
1098
1098
  }
1099
1099
  };
@@ -2095,11 +2095,32 @@ class Scheduler {
2095
2095
  error: console.error,
2096
2096
  debug: console.debug
2097
2097
  };
2098
- this.logger.info("Scheduler initialized");
2098
+ this.logger.debug("Scheduler initialized");
2099
2099
  this.alarm.onTrigger(this.execute.bind(this));
2100
2100
  this.timeout.onTrigger(this.execute.bind(this));
2101
2101
  this.setupPopupVisibilityListener();
2102
2102
  }
2103
+ /**
2104
+ * When `options.schedulerDebug` is true, log at info so diagnostics show without
2105
+ * enabling global debug. Otherwise logs at debug.
2106
+ */
2107
+ logJobDiagnostics(options, message, context) {
2108
+ const ctx = context;
2109
+ if (options?.schedulerDebug) {
2110
+ this.logger.info(message, ctx);
2111
+ } else {
2112
+ this.logger.debug(message, ctx);
2113
+ }
2114
+ }
2115
+ /** Batch summary visible at info if any involved job has `schedulerDebug`. */
2116
+ logBatchIfAnyJobDebug(jobIds, message) {
2117
+ const anyDebug = jobIds.some((jid) => this.registry.meta(jid)?.schedulerDebug);
2118
+ if (anyDebug) {
2119
+ this.logger.info(message);
2120
+ } else {
2121
+ this.logger.debug(message);
2122
+ }
2123
+ }
2103
2124
  /**
2104
2125
  * Setup listener for popup visibility changes.
2105
2126
  * When popup closes, pause all jobs with requiresPopup.
@@ -2107,9 +2128,9 @@ class Scheduler {
2107
2128
  */
2108
2129
  setupPopupVisibilityListener() {
2109
2130
  const visibilityService = PopupVisibilityService.instance;
2110
- this.logger.info("[Scheduler] Setting up popup visibility listener");
2131
+ this.logger.debug("[Scheduler] Setting up popup visibility listener");
2111
2132
  this.popupVisibilityUnsubscribe = visibilityService.onVisibilityChange((isVisible) => {
2112
- this.logger.info(`[Scheduler] Visibility changed: ${isVisible ? "visible" : "hidden"}`);
2133
+ this.logger.debug(`[Scheduler] Visibility changed: ${isVisible ? "visible" : "hidden"}`);
2113
2134
  if (isVisible) {
2114
2135
  this.resumePopupDependentJobs();
2115
2136
  } else {
@@ -2122,13 +2143,14 @@ class Scheduler {
2122
2143
  */
2123
2144
  pausePopupDependentJobs() {
2124
2145
  const jobs = this.registry.listAll();
2125
- this.logger.info(`[Scheduler] pausePopupDependentJobs called, total jobs: ${jobs.length}`);
2146
+ this.logger.debug(`[Scheduler] pausePopupDependentJobs called, total jobs: ${jobs.length}`);
2126
2147
  let pausedCount = 0;
2127
2148
  const pausedJobIds = [];
2128
2149
  for (const job of jobs) {
2129
2150
  const hasRequiresPopup = job.options?.requiresPopup;
2130
2151
  const isPaused = this.registry.getContext(job.id)?.isPaused();
2131
- this.logger.debug(
2152
+ this.logJobDiagnostics(
2153
+ job.options,
2132
2154
  `[Scheduler] Job ${job.id}: requiresPopup=${hasRequiresPopup}, isPaused=${isPaused}`
2133
2155
  );
2134
2156
  if (hasRequiresPopup && !isPaused) {
@@ -2140,11 +2162,12 @@ class Scheduler {
2140
2162
  }
2141
2163
  }
2142
2164
  if (pausedCount > 0) {
2143
- this.logger.info(
2165
+ this.logBatchIfAnyJobDebug(
2166
+ pausedJobIds,
2144
2167
  `[Scheduler] Paused ${pausedCount} popup-dependent jobs (popup closed): ${pausedJobIds.join(", ")}`
2145
2168
  );
2146
2169
  } else {
2147
- this.logger.info(`[Scheduler] No popup-dependent jobs to pause`);
2170
+ this.logger.debug(`[Scheduler] No popup-dependent jobs to pause`);
2148
2171
  }
2149
2172
  }
2150
2173
  /**
@@ -2152,13 +2175,14 @@ class Scheduler {
2152
2175
  */
2153
2176
  resumePopupDependentJobs() {
2154
2177
  const jobs = this.registry.listAll();
2155
- this.logger.info(`[Scheduler] resumePopupDependentJobs called, total jobs: ${jobs.length}`);
2178
+ this.logger.debug(`[Scheduler] resumePopupDependentJobs called, total jobs: ${jobs.length}`);
2156
2179
  let resumedCount = 0;
2157
2180
  const resumedJobIds = [];
2158
2181
  for (const job of jobs) {
2159
2182
  const hasRequiresPopup = job.options?.requiresPopup;
2160
2183
  const isPaused = this.registry.getContext(job.id)?.isPaused();
2161
- this.logger.debug(
2184
+ this.logJobDiagnostics(
2185
+ job.options,
2162
2186
  `[Scheduler] Job ${job.id}: requiresPopup=${hasRequiresPopup}, isPaused=${isPaused}`
2163
2187
  );
2164
2188
  if (hasRequiresPopup && isPaused) {
@@ -2169,11 +2193,12 @@ class Scheduler {
2169
2193
  }
2170
2194
  }
2171
2195
  if (resumedCount > 0) {
2172
- this.logger.info(
2196
+ this.logBatchIfAnyJobDebug(
2197
+ resumedJobIds,
2173
2198
  `[Scheduler] Resumed ${resumedCount} popup-dependent jobs (popup opened): ${resumedJobIds.join(", ")}`
2174
2199
  );
2175
2200
  } else {
2176
- this.logger.info(`[Scheduler] No popup-dependent jobs to resume`);
2201
+ this.logger.debug(`[Scheduler] No popup-dependent jobs to resume`);
2177
2202
  }
2178
2203
  }
2179
2204
  schedule(id, options) {
@@ -2184,7 +2209,8 @@ class Scheduler {
2184
2209
  if (options?.requiresPopup) {
2185
2210
  const isPopupVisible = PopupVisibilityService.instance.isPopupVisible();
2186
2211
  if (!isPopupVisible) {
2187
- this.logger.debug(
2212
+ this.logJobDiagnostics(
2213
+ options,
2188
2214
  `Job ${id} requires popup but popup is not visible, pausing instead of scheduling`
2189
2215
  );
2190
2216
  if (!context.isPaused()) {
@@ -2223,26 +2249,27 @@ class Scheduler {
2223
2249
  if (adapter === this.timeout && timerId) {
2224
2250
  this.registry.setTimeoutId(id, timerId);
2225
2251
  }
2226
- this.logger.info(
2252
+ this.logJobDiagnostics(
2253
+ options,
2227
2254
  `[Scheduler] Job "${id}" scheduled for ${new Date(when).toISOString()} (in ${Math.round(delayMs / 1e3)}s) \u2192 ${adapter === this.alarm ? "\u23F0 AlarmAdapter" : "\u23F1\uFE0F TimeoutAdapter"}`
2228
2255
  );
2229
2256
  }
2230
2257
  pause(id) {
2231
- this.logger.info(`Pausing job ${id}`);
2258
+ this.logJobDiagnostics(this.registry.meta(id), `Pausing job ${id}`);
2232
2259
  this.alarm.cancel(id);
2233
2260
  this.timeout.cancel(id);
2234
2261
  this.registry.pause(id);
2235
2262
  }
2236
2263
  resume(id) {
2237
- this.logger.info(`Resuming job ${id}`);
2238
- this.registry.resume(id);
2239
2264
  const options = this.registry.meta(id);
2265
+ this.logJobDiagnostics(options, `Resuming job ${id}`);
2266
+ this.registry.resume(id);
2240
2267
  if (options) {
2241
2268
  this.schedule(id, options);
2242
2269
  }
2243
2270
  }
2244
2271
  stop(id) {
2245
- this.logger.info(`Stopping job ${id}`);
2272
+ this.logJobDiagnostics(this.registry.meta(id), `Stopping job ${id}`);
2246
2273
  this.alarm.cancel(id);
2247
2274
  this.timeout.cancel(id);
2248
2275
  this.registry.stop(id);
@@ -2252,26 +2279,25 @@ class Scheduler {
2252
2279
  const context = this.registry.getContext(id);
2253
2280
  const options = this.registry.meta(id);
2254
2281
  if (!job || !context) {
2255
- this.logger.debug(`Job ${id} not found or no context`);
2282
+ this.logJobDiagnostics(options, `Job ${id} not found or no context`);
2256
2283
  return;
2257
2284
  }
2258
2285
  if (context.isPaused() || context.isStopped()) {
2259
- this.logger.debug(`Job ${id} is paused or stopped, skipping execution`);
2286
+ this.logJobDiagnostics(options, `Job ${id} is paused or stopped, skipping execution`);
2260
2287
  return;
2261
2288
  }
2262
2289
  if (options?.requiresPopup) {
2263
2290
  const isPopupVisible = PopupVisibilityService.instance.isPopupVisible();
2264
2291
  if (!isPopupVisible) {
2265
- this.logger.debug(`Job ${id} requires popup but popup closed, pausing job`);
2292
+ this.logJobDiagnostics(options, `Job ${id} requires popup but popup closed, pausing job`);
2266
2293
  this.registry.pause(id);
2267
2294
  return;
2268
2295
  }
2269
2296
  }
2270
2297
  try {
2271
2298
  this.registry.updateState(id, JobState.RUNNING);
2272
- this.logger.info(`Executing job ${id}`);
2299
+ this.logJobDiagnostics(options, `Executing job ${id}`);
2273
2300
  const jobInstance = container.get(id);
2274
- this.logger.debug("Job instance:", { jobInstance });
2275
2301
  await jobInstance.handle.bind(jobInstance).call(jobInstance, context);
2276
2302
  if (!context.isStopped() && !context.isPaused()) {
2277
2303
  this.registry.updateState(id, JobState.COMPLETED);
@@ -2284,7 +2310,7 @@ class Scheduler {
2284
2310
  this.logger.error(`Job ${id} execution failed:`, error);
2285
2311
  context.fail(error);
2286
2312
  if (options?.cron || options?.recurring) {
2287
- this.logger.info(`Rescheduling failed recurring job ${id}`);
2313
+ this.logJobDiagnostics(options, `Rescheduling failed recurring job ${id}`);
2288
2314
  this.registry.updateState(id, JobState.SCHEDULED);
2289
2315
  this.schedule(id, options);
2290
2316
  }
@@ -2312,7 +2338,7 @@ class Scheduler {
2312
2338
  * Gracefully shutdown the scheduler, clearing all timers
2313
2339
  */
2314
2340
  shutdown() {
2315
- this.logger.info("Shutting down scheduler...");
2341
+ this.logger.debug("Shutting down scheduler...");
2316
2342
  if (this.popupVisibilityUnsubscribe) {
2317
2343
  this.popupVisibilityUnsubscribe();
2318
2344
  this.popupVisibilityUnsubscribe = void 0;
@@ -2320,7 +2346,7 @@ class Scheduler {
2320
2346
  this.alarm.clear();
2321
2347
  this.timeout.clear();
2322
2348
  this.registry.clear();
2323
- this.logger.info("Scheduler shutdown complete");
2349
+ this.logger.debug("Scheduler shutdown complete");
2324
2350
  }
2325
2351
  /**
2326
2352
  * Get scheduler stats for monitoring
@@ -2941,4 +2967,4 @@ class BootstrapBuilder {
2941
2967
  }
2942
2968
 
2943
2969
  export { AppEventBus as A, EventBusToken as E, JobRegistry as J, NonceService as N, PopupVisibilityService as P, Subscribe as S, SUBSCRIBE_METADATA_KEY as a, getNonceService as b, getPopupVisibilityService as c, claimEarlyPorts as d, arePortsClaimed as e, container as f, getSubscribeMetadata as g, create as h, isEarlyListenerSetup as i, bootstrap as j, Scheduler as k, JobState as l, setupEarlyListener as s };
2944
- //# sourceMappingURL=boot-DPtu_qKj.js.map
2970
+ //# sourceMappingURL=boot-yaI0mE0N.js.map