@chromahq/core 1.0.53 → 1.0.55
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-CscXvoFf.js → boot-BMZdye6C.js} +101 -6
- package/dist/boot-BMZdye6C.js.map +1 -0
- package/dist/{boot-DrOND1Zi.js → boot-Bty0U5M4.js} +101 -6
- package/dist/boot-Bty0U5M4.js.map +1 -0
- package/dist/boot.cjs.js +1 -1
- package/dist/boot.es.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +40 -0
- package/dist/index.es.js +1 -1
- package/package.json +1 -1
- package/dist/boot-CscXvoFf.js.map +0 -1
- package/dist/boot-DrOND1Zi.js.map +0 -1
|
@@ -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?.();
|
|
@@ -1965,12 +1969,101 @@ class Scheduler {
|
|
|
1965
1969
|
this.logger.info("Scheduler initialized");
|
|
1966
1970
|
this.alarm.onTrigger(this.execute.bind(this));
|
|
1967
1971
|
this.timeout.onTrigger(this.execute.bind(this));
|
|
1972
|
+
this.setupPopupVisibilityListener();
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Setup listener for popup visibility changes.
|
|
1976
|
+
* When popup closes, pause all jobs with requiresPopup.
|
|
1977
|
+
* When popup opens, resume those jobs.
|
|
1978
|
+
*/
|
|
1979
|
+
setupPopupVisibilityListener() {
|
|
1980
|
+
const visibilityService = PopupVisibilityService.instance;
|
|
1981
|
+
this.logger.info("[Scheduler] Setting up popup visibility listener");
|
|
1982
|
+
this.popupVisibilityUnsubscribe = visibilityService.onVisibilityChange((isVisible) => {
|
|
1983
|
+
this.logger.info(`[Scheduler] Visibility changed: ${isVisible ? "visible" : "hidden"}`);
|
|
1984
|
+
if (isVisible) {
|
|
1985
|
+
this.resumePopupDependentJobs();
|
|
1986
|
+
} else {
|
|
1987
|
+
this.pausePopupDependentJobs();
|
|
1988
|
+
}
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1991
|
+
/**
|
|
1992
|
+
* Pause all jobs that have requiresPopup: true
|
|
1993
|
+
*/
|
|
1994
|
+
pausePopupDependentJobs() {
|
|
1995
|
+
const jobs = this.registry.listAll();
|
|
1996
|
+
this.logger.info(`[Scheduler] pausePopupDependentJobs called, total jobs: ${jobs.length}`);
|
|
1997
|
+
let pausedCount = 0;
|
|
1998
|
+
const pausedJobIds = [];
|
|
1999
|
+
for (const job of jobs) {
|
|
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) {
|
|
2006
|
+
this.alarm.cancel(job.id);
|
|
2007
|
+
this.timeout.cancel(job.id);
|
|
2008
|
+
this.registry.pause(job.id);
|
|
2009
|
+
pausedJobIds.push(job.id);
|
|
2010
|
+
pausedCount++;
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
if (pausedCount > 0) {
|
|
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`);
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
/**
|
|
2022
|
+
* Resume all jobs that have requiresPopup: true
|
|
2023
|
+
*/
|
|
2024
|
+
resumePopupDependentJobs() {
|
|
2025
|
+
const jobs = this.registry.listAll();
|
|
2026
|
+
this.logger.info(`[Scheduler] resumePopupDependentJobs called, total jobs: ${jobs.length}`);
|
|
2027
|
+
let resumedCount = 0;
|
|
2028
|
+
const resumedJobIds = [];
|
|
2029
|
+
for (const job of jobs) {
|
|
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) {
|
|
2036
|
+
this.registry.resume(job.id);
|
|
2037
|
+
this.schedule(job.id, job.options);
|
|
2038
|
+
resumedJobIds.push(job.id);
|
|
2039
|
+
resumedCount++;
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
if (resumedCount > 0) {
|
|
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`);
|
|
2048
|
+
}
|
|
1968
2049
|
}
|
|
1969
2050
|
schedule(id, options) {
|
|
1970
2051
|
const context = this.registry.getContext(id);
|
|
1971
2052
|
if (!context || context.isStopped()) {
|
|
1972
2053
|
return;
|
|
1973
2054
|
}
|
|
2055
|
+
if (options?.requiresPopup) {
|
|
2056
|
+
const isPopupVisible = PopupVisibilityService.instance.isPopupVisible();
|
|
2057
|
+
if (!isPopupVisible) {
|
|
2058
|
+
this.logger.debug(
|
|
2059
|
+
`Job ${id} requires popup but popup is not visible, pausing instead of scheduling`
|
|
2060
|
+
);
|
|
2061
|
+
if (!context.isPaused()) {
|
|
2062
|
+
this.registry.pause(id);
|
|
2063
|
+
}
|
|
2064
|
+
return;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
1974
2067
|
const when = this.getScheduleTime(options);
|
|
1975
2068
|
const now = Date.now();
|
|
1976
2069
|
if (when <= now) {
|
|
@@ -2033,10 +2126,8 @@ class Scheduler {
|
|
|
2033
2126
|
if (options?.requiresPopup) {
|
|
2034
2127
|
const isPopupVisible = PopupVisibilityService.instance.isPopupVisible();
|
|
2035
2128
|
if (!isPopupVisible) {
|
|
2036
|
-
this.logger.debug(`Job ${id} requires popup but popup
|
|
2037
|
-
|
|
2038
|
-
this.schedule(id, options);
|
|
2039
|
-
}
|
|
2129
|
+
this.logger.debug(`Job ${id} requires popup but popup closed, pausing job`);
|
|
2130
|
+
this.registry.pause(id);
|
|
2040
2131
|
return;
|
|
2041
2132
|
}
|
|
2042
2133
|
}
|
|
@@ -2086,6 +2177,10 @@ class Scheduler {
|
|
|
2086
2177
|
*/
|
|
2087
2178
|
shutdown() {
|
|
2088
2179
|
this.logger.info("Shutting down scheduler...");
|
|
2180
|
+
if (this.popupVisibilityUnsubscribe) {
|
|
2181
|
+
this.popupVisibilityUnsubscribe();
|
|
2182
|
+
this.popupVisibilityUnsubscribe = void 0;
|
|
2183
|
+
}
|
|
2089
2184
|
this.alarm.clear();
|
|
2090
2185
|
this.timeout.clear();
|
|
2091
2186
|
this.registry.clear();
|
|
@@ -2644,4 +2739,4 @@ exports.getNonceService = getNonceService;
|
|
|
2644
2739
|
exports.getPopupVisibilityService = getPopupVisibilityService;
|
|
2645
2740
|
exports.isEarlyListenerSetup = isEarlyListenerSetup;
|
|
2646
2741
|
exports.setupEarlyListener = setupEarlyListener;
|
|
2647
|
-
//# sourceMappingURL=boot-
|
|
2742
|
+
//# sourceMappingURL=boot-BMZdye6C.js.map
|