@chromahq/core 1.0.53 → 1.0.54
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-CcvC3GTE.js} +72 -5
- package/dist/boot-CcvC3GTE.js.map +1 -0
- package/dist/{boot-DrOND1Zi.js → boot-DRsz4LpW.js} +72 -5
- package/dist/boot-DRsz4LpW.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
|
@@ -1965,12 +1965,77 @@ class Scheduler {
|
|
|
1965
1965
|
this.logger.info("Scheduler initialized");
|
|
1966
1966
|
this.alarm.onTrigger(this.execute.bind(this));
|
|
1967
1967
|
this.timeout.onTrigger(this.execute.bind(this));
|
|
1968
|
+
this.setupPopupVisibilityListener();
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* Setup listener for popup visibility changes.
|
|
1972
|
+
* When popup closes, pause all jobs with requiresPopup.
|
|
1973
|
+
* When popup opens, resume those jobs.
|
|
1974
|
+
*/
|
|
1975
|
+
setupPopupVisibilityListener() {
|
|
1976
|
+
const visibilityService = PopupVisibilityService.instance;
|
|
1977
|
+
this.popupVisibilityUnsubscribe = visibilityService.onVisibilityChange((isVisible) => {
|
|
1978
|
+
if (isVisible) {
|
|
1979
|
+
this.resumePopupDependentJobs();
|
|
1980
|
+
} else {
|
|
1981
|
+
this.pausePopupDependentJobs();
|
|
1982
|
+
}
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
/**
|
|
1986
|
+
* Pause all jobs that have requiresPopup: true
|
|
1987
|
+
*/
|
|
1988
|
+
pausePopupDependentJobs() {
|
|
1989
|
+
const jobs = this.registry.listAll();
|
|
1990
|
+
let pausedCount = 0;
|
|
1991
|
+
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}`);
|
|
1994
|
+
this.alarm.cancel(job.id);
|
|
1995
|
+
this.timeout.cancel(job.id);
|
|
1996
|
+
this.registry.pause(job.id);
|
|
1997
|
+
pausedCount++;
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
if (pausedCount > 0) {
|
|
2001
|
+
this.logger.info(`Paused ${pausedCount} popup-dependent jobs (popup closed)`);
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Resume all jobs that have requiresPopup: true
|
|
2006
|
+
*/
|
|
2007
|
+
resumePopupDependentJobs() {
|
|
2008
|
+
const jobs = this.registry.listAll();
|
|
2009
|
+
let resumedCount = 0;
|
|
2010
|
+
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}`);
|
|
2013
|
+
this.registry.resume(job.id);
|
|
2014
|
+
this.schedule(job.id, job.options);
|
|
2015
|
+
resumedCount++;
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
if (resumedCount > 0) {
|
|
2019
|
+
this.logger.info(`Resumed ${resumedCount} popup-dependent jobs (popup opened)`);
|
|
2020
|
+
}
|
|
1968
2021
|
}
|
|
1969
2022
|
schedule(id, options) {
|
|
1970
2023
|
const context = this.registry.getContext(id);
|
|
1971
2024
|
if (!context || context.isStopped()) {
|
|
1972
2025
|
return;
|
|
1973
2026
|
}
|
|
2027
|
+
if (options?.requiresPopup) {
|
|
2028
|
+
const isPopupVisible = PopupVisibilityService.instance.isPopupVisible();
|
|
2029
|
+
if (!isPopupVisible) {
|
|
2030
|
+
this.logger.debug(
|
|
2031
|
+
`Job ${id} requires popup but popup is not visible, pausing instead of scheduling`
|
|
2032
|
+
);
|
|
2033
|
+
if (!context.isPaused()) {
|
|
2034
|
+
this.registry.pause(id);
|
|
2035
|
+
}
|
|
2036
|
+
return;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
1974
2039
|
const when = this.getScheduleTime(options);
|
|
1975
2040
|
const now = Date.now();
|
|
1976
2041
|
if (when <= now) {
|
|
@@ -2033,10 +2098,8 @@ class Scheduler {
|
|
|
2033
2098
|
if (options?.requiresPopup) {
|
|
2034
2099
|
const isPopupVisible = PopupVisibilityService.instance.isPopupVisible();
|
|
2035
2100
|
if (!isPopupVisible) {
|
|
2036
|
-
this.logger.debug(`Job ${id} requires popup but popup
|
|
2037
|
-
|
|
2038
|
-
this.schedule(id, options);
|
|
2039
|
-
}
|
|
2101
|
+
this.logger.debug(`Job ${id} requires popup but popup closed, pausing job`);
|
|
2102
|
+
this.registry.pause(id);
|
|
2040
2103
|
return;
|
|
2041
2104
|
}
|
|
2042
2105
|
}
|
|
@@ -2086,6 +2149,10 @@ class Scheduler {
|
|
|
2086
2149
|
*/
|
|
2087
2150
|
shutdown() {
|
|
2088
2151
|
this.logger.info("Shutting down scheduler...");
|
|
2152
|
+
if (this.popupVisibilityUnsubscribe) {
|
|
2153
|
+
this.popupVisibilityUnsubscribe();
|
|
2154
|
+
this.popupVisibilityUnsubscribe = void 0;
|
|
2155
|
+
}
|
|
2089
2156
|
this.alarm.clear();
|
|
2090
2157
|
this.timeout.clear();
|
|
2091
2158
|
this.registry.clear();
|
|
@@ -2644,4 +2711,4 @@ exports.getNonceService = getNonceService;
|
|
|
2644
2711
|
exports.getPopupVisibilityService = getPopupVisibilityService;
|
|
2645
2712
|
exports.isEarlyListenerSetup = isEarlyListenerSetup;
|
|
2646
2713
|
exports.setupEarlyListener = setupEarlyListener;
|
|
2647
|
-
//# sourceMappingURL=boot-
|
|
2714
|
+
//# sourceMappingURL=boot-CcvC3GTE.js.map
|