@palbase/web 1.6.0 → 1.6.1

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/index.cjs CHANGED
@@ -3590,24 +3590,38 @@ var Chat = class {
3590
3590
  resolvedReplyTo = resolveReply(replyRef, (id) => this.byClientMsgId.get(id) ?? null);
3591
3591
  }
3592
3592
  const bodyRanges = opts?.mentions ?? null;
3593
- const start = opts?.expiresIn?.start ?? "send";
3594
- const expiry = opts?.expiresIn ? {
3595
- v: 1,
3596
- ttlSeconds: opts.expiresIn.ttlSeconds,
3597
- start,
3598
- senderSendTs: start === "send" ? Math.floor(Date.now() / 1e3) : null
3599
- } : null;
3593
+ const effectiveExpiry = this.composeExpiry(opts?.expiresIn);
3600
3594
  const { receipt, clientMsgId } = await this.backend.sendText(
3601
3595
  group,
3602
3596
  text,
3603
3597
  replyRef,
3604
3598
  bodyRanges,
3605
- expiry
3599
+ effectiveExpiry
3606
3600
  );
3607
- this.appendOwnSend(text, receipt, clientMsgId, resolvedReplyTo, bodyRanges);
3608
- if (expiry) void this.armPurge(expiry, receipt.serverSeq, clientMsgId);
3601
+ this.appendOwnSend(text, receipt, clientMsgId, resolvedReplyTo, bodyRanges, effectiveExpiry);
3602
+ if (effectiveExpiry) void this.armPurge(effectiveExpiry, receipt.serverSeq, clientMsgId);
3609
3603
  return receipt;
3610
3604
  }
3605
+ /** Resolve a send's effective per-message expiry at COMPOSE TIME: the caller's explicit
3606
+ * `expiresIn` if present, ELSE the chat's active default timer stamped onto the message
3607
+ * NOW (the durable record per spec §"Compose-time stamping"). A `send`-anchored expiry
3608
+ * (explicit or default-inherited) stamps `senderSendTs` = the sender's compose epoch
3609
+ * seconds; a `read`-anchored one carries none (the deadline is the recipient's local
3610
+ * first-read). Returns null when there is neither an explicit expiry nor an active
3611
+ * default (a plain, non-disappearing send). Mirrors the iOS compose-time stamping. */
3612
+ composeExpiry(explicit) {
3613
+ const base = explicit ? {
3614
+ v: 1,
3615
+ ttlSeconds: explicit.ttlSeconds,
3616
+ start: explicit.start ?? "send",
3617
+ senderSendTs: null
3618
+ } : this.defaultExpiry();
3619
+ if (!base) return null;
3620
+ return {
3621
+ ...base,
3622
+ senderSendTs: base.start === "send" ? Math.floor(Date.now() / 1e3) : null
3623
+ };
3624
+ }
3611
3625
  /** Set (or DISABLE) this chat's DEFAULT disappearing timer. Emits a `timer_set` control
3612
3626
  * envelope (server-blind — an opaque application message, NEVER a bubble) and folds the
3613
3627
  * own-set locally so the default applies immediately to subsequent sends that carry no
@@ -3632,7 +3646,7 @@ var Chat = class {
3632
3646
  eventClientMsgId: clientMsgId
3633
3647
  });
3634
3648
  }
3635
- appendOwnSend(text, receipt, clientMsgId, resolvedReplyTo, bodyRanges) {
3649
+ appendOwnSend(text, receipt, clientMsgId, resolvedReplyTo, bodyRanges, expiry) {
3636
3650
  if (receipt.serverSeq <= 0) return;
3637
3651
  const key = this.internalKey(receipt.serverSeq);
3638
3652
  if (this.seenKeys.has(key)) return;
@@ -3661,9 +3675,11 @@ var Chat = class {
3661
3675
  // Mentions T6: resolve the own-sent bubble's mentions for its own render (the
3662
3676
  // sender never gets a wire echo of its own message — this is the only local copy).
3663
3677
  mentions: this.resolveMentions(text, bodyRanges),
3664
- // Disappearing T10: the surfaced deadline is set by armPurge (own-send with a TTL)
3665
- // via the messageList overlay; default null here (a plain own-send has no deadline).
3666
- expiresAt: null
3678
+ // Disappearing T10: the surfaced deadline reflects the message's effective expiry
3679
+ // (explicit `expiresIn` OR the chat default stamped at compose time). null only when
3680
+ // this send is non-disappearing. armPurge re-derives the durable monotonic deadline;
3681
+ // this is the immediate UI countdown baseline (own sender and receiver are symmetric).
3682
+ expiresAt: this.deadlineFor(expiry ?? null)
3667
3683
  });
3668
3684
  this.messageList.sort((a, b) => a.serverSeq - b.serverSeq);
3669
3685
  this.emit();
@@ -7403,7 +7419,7 @@ function localStorageSessionStorage(key = DEFAULT_KEY) {
7403
7419
  }
7404
7420
 
7405
7421
  // src/version.ts
7406
- var VERSION = "1.6.0";
7422
+ var VERSION = "1.6.1";
7407
7423
 
7408
7424
  // src/internal.ts
7409
7425
  function getRuntime() {