@chromahq/core 1.0.57 → 1.0.58
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-DIMyFZvd.js → boot--zb14Gg3.js} +35 -17
- package/dist/boot--zb14Gg3.js.map +1 -0
- package/dist/{boot-C2Rq9czO.js → boot-DPtu_qKj.js} +35 -17
- package/dist/boot-DPtu_qKj.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 +1 -0
- package/dist/index.es.js +1 -1
- package/package.json +1 -1
- package/dist/boot-C2Rq9czO.js.map +0 -1
- package/dist/boot-DIMyFZvd.js.map +0 -1
|
@@ -1145,10 +1145,10 @@ const _AlarmAdapter = class _AlarmAdapter {
|
|
|
1145
1145
|
/**
|
|
1146
1146
|
* Initialize the Chrome Alarms listener (once)
|
|
1147
1147
|
*/
|
|
1148
|
-
this.initializeAlarmListener = () => {
|
|
1148
|
+
this.initializeAlarmListener = async () => {
|
|
1149
1149
|
if (this.listenerRegistered) return;
|
|
1150
1150
|
if (this.isChromeAlarmsAvailable()) {
|
|
1151
|
-
this.clearStaleAlarms();
|
|
1151
|
+
await this.clearStaleAlarms();
|
|
1152
1152
|
chrome.alarms.onAlarm.addListener(this.handleAlarm);
|
|
1153
1153
|
this.listenerRegistered = true;
|
|
1154
1154
|
console.log("[AlarmAdapter] \u2705 Chrome Alarms API available and listener registered");
|
|
@@ -1159,20 +1159,31 @@ const _AlarmAdapter = class _AlarmAdapter {
|
|
|
1159
1159
|
}
|
|
1160
1160
|
};
|
|
1161
1161
|
/**
|
|
1162
|
-
* Clear any stale chroma alarms from previous SW instances
|
|
1162
|
+
* Clear any stale chroma alarms from previous SW instances.
|
|
1163
|
+
* Returns a promise that resolves once all stale alarms are cleared.
|
|
1163
1164
|
*/
|
|
1164
1165
|
this.clearStaleAlarms = () => {
|
|
1165
|
-
if (!this.isChromeAlarmsAvailable()) return;
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1166
|
+
if (!this.isChromeAlarmsAvailable()) return Promise.resolve();
|
|
1167
|
+
return new Promise((resolve) => {
|
|
1168
|
+
chrome.alarms.getAll((alarms) => {
|
|
1169
|
+
const staleAlarms = alarms.filter((a) => a.name.startsWith(_AlarmAdapter.ALARM_PREFIX));
|
|
1170
|
+
if (staleAlarms.length > 0) {
|
|
1171
|
+
console.log(
|
|
1172
|
+
`[AlarmAdapter] \u{1F9F9} Clearing ${staleAlarms.length} stale alarms from previous session`
|
|
1173
|
+
);
|
|
1174
|
+
let cleared = 0;
|
|
1175
|
+
staleAlarms.forEach((alarm) => {
|
|
1176
|
+
chrome.alarms.clear(alarm.name, () => {
|
|
1177
|
+
cleared++;
|
|
1178
|
+
if (cleared === staleAlarms.length) {
|
|
1179
|
+
resolve();
|
|
1180
|
+
}
|
|
1181
|
+
});
|
|
1182
|
+
});
|
|
1183
|
+
} else {
|
|
1184
|
+
resolve();
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1176
1187
|
});
|
|
1177
1188
|
};
|
|
1178
1189
|
/**
|
|
@@ -1277,7 +1288,7 @@ const _AlarmAdapter = class _AlarmAdapter {
|
|
|
1277
1288
|
usingChromeApi: this.isChromeAlarmsAvailable()
|
|
1278
1289
|
};
|
|
1279
1290
|
};
|
|
1280
|
-
this.initializeAlarmListener();
|
|
1291
|
+
this.ready = this.initializeAlarmListener();
|
|
1281
1292
|
}
|
|
1282
1293
|
};
|
|
1283
1294
|
_AlarmAdapter.ALARM_PREFIX = "chroma_job_";
|
|
@@ -2184,6 +2195,13 @@ class Scheduler {
|
|
|
2184
2195
|
return;
|
|
2185
2196
|
}
|
|
2186
2197
|
}
|
|
2198
|
+
this.alarm.ready.then(() => this.scheduleInternal(id, options));
|
|
2199
|
+
}
|
|
2200
|
+
scheduleInternal(id, options) {
|
|
2201
|
+
const context = this.registry.getContext(id);
|
|
2202
|
+
if (!context || context.isStopped() || context.isPaused()) {
|
|
2203
|
+
return;
|
|
2204
|
+
}
|
|
2187
2205
|
const when = this.getScheduleTime(options);
|
|
2188
2206
|
const now = Date.now();
|
|
2189
2207
|
if (when <= now) {
|
|
@@ -2799,7 +2817,7 @@ class ApplicationBootstrap {
|
|
|
2799
2817
|
if (!container.isBound(JobClass)) {
|
|
2800
2818
|
container.bind(JobClass).toSelf().inSingletonScope();
|
|
2801
2819
|
}
|
|
2802
|
-
const id = `${jobName.toLowerCase()}:${JobClass.name.toLowerCase()}
|
|
2820
|
+
const id = `${jobName.toLowerCase()}:${JobClass.name.toLowerCase()}`;
|
|
2803
2821
|
container.bind(id).to(JobClass).inSingletonScope();
|
|
2804
2822
|
const options = Reflect.getMetadata("job:options", JobClass) || {};
|
|
2805
2823
|
jobEntries.push({ JobClass, jobName, id, options });
|
|
@@ -2942,4 +2960,4 @@ exports.getPopupVisibilityService = getPopupVisibilityService;
|
|
|
2942
2960
|
exports.getSubscribeMetadata = getSubscribeMetadata;
|
|
2943
2961
|
exports.isEarlyListenerSetup = isEarlyListenerSetup;
|
|
2944
2962
|
exports.setupEarlyListener = setupEarlyListener;
|
|
2945
|
-
//# sourceMappingURL=boot
|
|
2963
|
+
//# sourceMappingURL=boot--zb14Gg3.js.map
|