@llblab/pi-telegram 0.56.0 → 0.56.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/lib/updates.ts CHANGED
@@ -547,6 +547,7 @@ interface TelegramUpdateAdmissionBinding {
547
547
  inspectSource?: () => TelegramDeferredSourceEvidence | undefined;
548
548
  inspectSourceSnapshot?: () => TelegramDeferredSourceSnapshot | undefined;
549
549
  inspectCompletion?: () => TelegramDeferredSourceEvidence | undefined;
550
+ subscribeCompletion?: (notify: () => void) => () => void;
550
551
  isSourceUnsettled?: () => boolean;
551
552
  prepareLiveInput?: (
552
553
  sourceUpdateIds: readonly number[],
@@ -615,6 +616,7 @@ export function bindTelegramUpdateAdmissionSource<
615
616
  | "inspectSource"
616
617
  | "inspectSourceSnapshot"
617
618
  | "inspectCompletion"
619
+ | "subscribeCompletion"
618
620
  | "isSourceUnsettled"
619
621
  | "acknowledgeTransferred"
620
622
  | "prepareLiveInput"
@@ -743,6 +745,15 @@ export function inspectTelegramDeferredSourceCompletion(
743
745
  return execution.isCurrent() && source ? { ...source } : undefined;
744
746
  }
745
747
 
748
+ /** Warm ACK notification only; subscribers must independently recheck exact completion and recipient authority. */
749
+ export function subscribeTelegramDeferredSourceCompletion(value: unknown, notify: () => void): (() => void) | undefined {
750
+ const execution = getTelegramUpdateExecutionFence(value);
751
+ if (execution?.isCurrent() !== true) return undefined;
752
+ return getTelegramUpdateAdmissionBinding(value)?.subscribeCompletion?.(() => {
753
+ if (execution.isCurrent()) notify();
754
+ });
755
+ }
756
+
746
757
  /** Reuse only live bound deferred originals; raw IDs or cold/adopted input cannot mint this carrier. */
747
758
  export function prepareTelegramLiveDeferredInput(
748
759
  values: readonly unknown[],
@@ -8721,6 +8732,7 @@ function createTelegramUpdateSourceAdmissionHandle<
8721
8732
  let outcome: TelegramUpdateAdmissionOutcome | undefined;
8722
8733
  let completionAttempted = false;
8723
8734
  let completedSource: TelegramDeferredSourceCompletion | undefined;
8735
+ const completionObservers = new Set<() => void>();
8724
8736
  const boundUpdate = bindTelegramUpdateExecutionFence(
8725
8737
  bindTelegramUpdateAdmissionSource(
8726
8738
  update,
@@ -8777,11 +8789,12 @@ function createTelegramUpdateSourceAdmissionHandle<
8777
8789
  execution.isCurrent() &&
8778
8790
  completion.isCurrent() &&
8779
8791
  isDeepStrictEqual(completion.source, expectedSource)
8780
- )
8781
- completedSource = {
8782
- ...completion,
8783
- source: { ...expectedSource },
8784
- };
8792
+ ) {
8793
+ completedSource = { ...completion, source: { ...expectedSource } };
8794
+ for (const notify of completionObservers) {
8795
+ try { notify(); } catch { /* Observation cannot invalidate an exact removal ACK. */ }
8796
+ }
8797
+ }
8785
8798
  })
8786
8799
  .catch((error) => {
8787
8800
  try {
@@ -8842,6 +8855,10 @@ function createTelegramUpdateSourceAdmissionHandle<
8842
8855
  signal,
8843
8856
  })
8844
8857
  : undefined,
8858
+ subscribeCompletion: (notify) => {
8859
+ completionObservers.add(notify);
8860
+ return () => { completionObservers.delete(notify); };
8861
+ },
8845
8862
  inspectCompletion: () =>
8846
8863
  execution.isCurrent() && completedSource?.isCurrent()
8847
8864
  ? { ...completedSource.source }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-telegram",
3
- "version": "0.56.0",
3
+ "version": "0.56.1",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"