@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
|
@@ -1143,10 +1143,10 @@ const _AlarmAdapter = class _AlarmAdapter {
|
|
|
1143
1143
|
/**
|
|
1144
1144
|
* Initialize the Chrome Alarms listener (once)
|
|
1145
1145
|
*/
|
|
1146
|
-
this.initializeAlarmListener = () => {
|
|
1146
|
+
this.initializeAlarmListener = async () => {
|
|
1147
1147
|
if (this.listenerRegistered) return;
|
|
1148
1148
|
if (this.isChromeAlarmsAvailable()) {
|
|
1149
|
-
this.clearStaleAlarms();
|
|
1149
|
+
await this.clearStaleAlarms();
|
|
1150
1150
|
chrome.alarms.onAlarm.addListener(this.handleAlarm);
|
|
1151
1151
|
this.listenerRegistered = true;
|
|
1152
1152
|
console.log("[AlarmAdapter] \u2705 Chrome Alarms API available and listener registered");
|
|
@@ -1157,20 +1157,31 @@ const _AlarmAdapter = class _AlarmAdapter {
|
|
|
1157
1157
|
}
|
|
1158
1158
|
};
|
|
1159
1159
|
/**
|
|
1160
|
-
* Clear any stale chroma alarms from previous SW instances
|
|
1160
|
+
* Clear any stale chroma alarms from previous SW instances.
|
|
1161
|
+
* Returns a promise that resolves once all stale alarms are cleared.
|
|
1161
1162
|
*/
|
|
1162
1163
|
this.clearStaleAlarms = () => {
|
|
1163
|
-
if (!this.isChromeAlarmsAvailable()) return;
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1164
|
+
if (!this.isChromeAlarmsAvailable()) return Promise.resolve();
|
|
1165
|
+
return new Promise((resolve) => {
|
|
1166
|
+
chrome.alarms.getAll((alarms) => {
|
|
1167
|
+
const staleAlarms = alarms.filter((a) => a.name.startsWith(_AlarmAdapter.ALARM_PREFIX));
|
|
1168
|
+
if (staleAlarms.length > 0) {
|
|
1169
|
+
console.log(
|
|
1170
|
+
`[AlarmAdapter] \u{1F9F9} Clearing ${staleAlarms.length} stale alarms from previous session`
|
|
1171
|
+
);
|
|
1172
|
+
let cleared = 0;
|
|
1173
|
+
staleAlarms.forEach((alarm) => {
|
|
1174
|
+
chrome.alarms.clear(alarm.name, () => {
|
|
1175
|
+
cleared++;
|
|
1176
|
+
if (cleared === staleAlarms.length) {
|
|
1177
|
+
resolve();
|
|
1178
|
+
}
|
|
1179
|
+
});
|
|
1180
|
+
});
|
|
1181
|
+
} else {
|
|
1182
|
+
resolve();
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1174
1185
|
});
|
|
1175
1186
|
};
|
|
1176
1187
|
/**
|
|
@@ -1275,7 +1286,7 @@ const _AlarmAdapter = class _AlarmAdapter {
|
|
|
1275
1286
|
usingChromeApi: this.isChromeAlarmsAvailable()
|
|
1276
1287
|
};
|
|
1277
1288
|
};
|
|
1278
|
-
this.initializeAlarmListener();
|
|
1289
|
+
this.ready = this.initializeAlarmListener();
|
|
1279
1290
|
}
|
|
1280
1291
|
};
|
|
1281
1292
|
_AlarmAdapter.ALARM_PREFIX = "chroma_job_";
|
|
@@ -2182,6 +2193,13 @@ class Scheduler {
|
|
|
2182
2193
|
return;
|
|
2183
2194
|
}
|
|
2184
2195
|
}
|
|
2196
|
+
this.alarm.ready.then(() => this.scheduleInternal(id, options));
|
|
2197
|
+
}
|
|
2198
|
+
scheduleInternal(id, options) {
|
|
2199
|
+
const context = this.registry.getContext(id);
|
|
2200
|
+
if (!context || context.isStopped() || context.isPaused()) {
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2185
2203
|
const when = this.getScheduleTime(options);
|
|
2186
2204
|
const now = Date.now();
|
|
2187
2205
|
if (when <= now) {
|
|
@@ -2797,7 +2815,7 @@ class ApplicationBootstrap {
|
|
|
2797
2815
|
if (!container.isBound(JobClass)) {
|
|
2798
2816
|
container.bind(JobClass).toSelf().inSingletonScope();
|
|
2799
2817
|
}
|
|
2800
|
-
const id = `${jobName.toLowerCase()}:${JobClass.name.toLowerCase()}
|
|
2818
|
+
const id = `${jobName.toLowerCase()}:${JobClass.name.toLowerCase()}`;
|
|
2801
2819
|
container.bind(id).to(JobClass).inSingletonScope();
|
|
2802
2820
|
const options = Reflect.getMetadata("job:options", JobClass) || {};
|
|
2803
2821
|
jobEntries.push({ JobClass, jobName, id, options });
|
|
@@ -2923,4 +2941,4 @@ class BootstrapBuilder {
|
|
|
2923
2941
|
}
|
|
2924
2942
|
|
|
2925
2943
|
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 };
|
|
2926
|
-
//# sourceMappingURL=boot-
|
|
2944
|
+
//# sourceMappingURL=boot-DPtu_qKj.js.map
|