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