@steve31415/baselib 3.33.2 → 3.34.0
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/email.d.ts +4 -0
- package/dist/email.js +1 -0
- package/dist/sync-browser/client.d.ts +0 -6
- package/dist/sync-browser/client.js +9 -23
- package/package.json +1 -1
package/dist/email.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ export interface EmailMessage {
|
|
|
15
15
|
text?: string;
|
|
16
16
|
html?: string;
|
|
17
17
|
attachments?: EmailAttachment[];
|
|
18
|
+
/** Extra message headers (`X-Coder-Task`, `In-Reply-To`, …), passed to
|
|
19
|
+
* Resend's `headers` field as given. Coder uses them so Radar can
|
|
20
|
+
* recognise and thread its task mail (2026-10-11). */
|
|
21
|
+
headers?: Record<string, string>;
|
|
18
22
|
}
|
|
19
23
|
export interface SendEmailResult {
|
|
20
24
|
ok: boolean;
|
package/dist/email.js
CHANGED
|
@@ -54,6 +54,7 @@ export async function sendEmail(msg, deps) {
|
|
|
54
54
|
subject: msg.subject,
|
|
55
55
|
...(msg.text !== undefined ? { text: msg.text } : {}),
|
|
56
56
|
...(msg.html !== undefined ? { html: msg.html } : {}),
|
|
57
|
+
...(msg.headers && Object.keys(msg.headers).length ? { headers: msg.headers } : {}),
|
|
57
58
|
...(msg.attachments?.length
|
|
58
59
|
? {
|
|
59
60
|
attachments: msg.attachments.map((attachment) => ({
|
|
@@ -217,12 +217,6 @@ export declare class SyncClient<B, C extends EventBody, S extends EventBody, Sum
|
|
|
217
217
|
* the page counted as visible is counted (hidden pages are throttled by
|
|
218
218
|
* design and their time is `hiddenMs`). */
|
|
219
219
|
private observeStall;
|
|
220
|
-
/** The sleep half of `observeStall`, also run by every event-driven entry
|
|
221
|
-
* that starts, ends or splits the accounting (outage start and end, an
|
|
222
|
-
* `online` event, a hide): a wake can reach the page as one of those
|
|
223
|
-
* events before any timer runs, and the sleep must land on the right side
|
|
224
|
-
* of it (reader, 2026-10-11). */
|
|
225
|
-
private observeClockJump;
|
|
226
220
|
private setTimer;
|
|
227
221
|
private setRepeating;
|
|
228
222
|
private isHidden;
|
|
@@ -382,27 +382,20 @@ export class SyncClient {
|
|
|
382
382
|
* the page counted as visible is counted (hidden pages are throttled by
|
|
383
383
|
* design and their time is `hiddenMs`). */
|
|
384
384
|
observeStall(dueMono) {
|
|
385
|
-
this.observeClockJump();
|
|
386
385
|
const mono = this.monoNow();
|
|
387
|
-
|
|
386
|
+
const offset = this.now() - mono;
|
|
387
|
+
const visible = !this.isHidden();
|
|
388
|
+
if (visible && this.clockOffset !== null && offset - this.clockOffset >= STALL_MIN_MS) {
|
|
389
|
+
this.counters.stalledMs += offset - this.clockOffset;
|
|
390
|
+
}
|
|
391
|
+
this.clockOffset = offset;
|
|
392
|
+
if (visible && mono - dueMono >= STALL_MIN_MS) {
|
|
388
393
|
const from = Math.max(dueMono, this.stallCoveredUntil, this.visibleSinceMono);
|
|
389
394
|
if (mono > from)
|
|
390
395
|
this.counters.stalledMs += mono - from;
|
|
391
396
|
this.stallCoveredUntil = mono;
|
|
392
397
|
}
|
|
393
398
|
}
|
|
394
|
-
/** The sleep half of `observeStall`, also run by every event-driven entry
|
|
395
|
-
* that starts, ends or splits the accounting (outage start and end, an
|
|
396
|
-
* `online` event, a hide): a wake can reach the page as one of those
|
|
397
|
-
* events before any timer runs, and the sleep must land on the right side
|
|
398
|
-
* of it (reader, 2026-10-11). */
|
|
399
|
-
observeClockJump() {
|
|
400
|
-
const offset = this.now() - this.monoNow();
|
|
401
|
-
if (!this.isHidden() && this.clockOffset !== null && offset - this.clockOffset >= STALL_MIN_MS) {
|
|
402
|
-
this.counters.stalledMs += offset - this.clockOffset;
|
|
403
|
-
}
|
|
404
|
-
this.clockOffset = offset;
|
|
405
|
-
}
|
|
406
399
|
setTimer(callback, delayMs) {
|
|
407
400
|
const dueMono = this.monoNow() + delayMs;
|
|
408
401
|
return this.options.runtime.setTimeout(() => {
|
|
@@ -446,9 +439,8 @@ export class SyncClient {
|
|
|
446
439
|
if (this.halted || this.disposed || this.hiddenSince !== null)
|
|
447
440
|
return;
|
|
448
441
|
this.finishReturnWindow();
|
|
449
|
-
// A device that slept
|
|
450
|
-
|
|
451
|
-
this.observeClockJump();
|
|
442
|
+
// A device that slept and then hid the page: the sleep counts as hidden.
|
|
443
|
+
this.rebaselineClocks();
|
|
452
444
|
this.hiddenSince = this.now();
|
|
453
445
|
this.spellCounters = this.snapshot();
|
|
454
446
|
this.hiddenSocketFailed = false;
|
|
@@ -491,7 +483,6 @@ export class SyncClient {
|
|
|
491
483
|
onOnline() {
|
|
492
484
|
if (this.halted || this.disposed)
|
|
493
485
|
return;
|
|
494
|
-
this.observeClockJump();
|
|
495
486
|
if (this.isHidden()) {
|
|
496
487
|
if (this.socket === null) {
|
|
497
488
|
this.cancelBackgroundTick();
|
|
@@ -975,10 +966,6 @@ export class SyncClient {
|
|
|
975
966
|
startOutage(closeCode, wasClean = false) {
|
|
976
967
|
if (this.outageStartedAt !== null)
|
|
977
968
|
return;
|
|
978
|
-
// A sleep or freeze that ended in this close happened before the outage
|
|
979
|
-
// began (durationMs starts now): keep it out of the outage's stalledMs.
|
|
980
|
-
this.observeClockJump();
|
|
981
|
-
this.stallCoveredUntil = Math.max(this.stallCoveredUntil, this.monoNow());
|
|
982
969
|
this.outageStartedAt = this.options.runtime.now();
|
|
983
970
|
this.outageEscalated = false;
|
|
984
971
|
this.outageCloseCode = closeCode;
|
|
@@ -1313,7 +1300,6 @@ export class SyncClient {
|
|
|
1313
1300
|
}
|
|
1314
1301
|
onSyncEstablished() {
|
|
1315
1302
|
if (this.outageStartedAt !== null) {
|
|
1316
|
-
this.observeClockJump();
|
|
1317
1303
|
const durationMs = Math.max(0, this.options.runtime.now() - this.outageStartedAt);
|
|
1318
1304
|
// Failures are only counted (and the ladder only runs) while visible,
|
|
1319
1305
|
// and the count restarts on each return, so `attempts` is what the
|
package/package.json
CHANGED