@mmstack/primitives 22.10.0 → 22.10.2

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.
@@ -3589,7 +3589,7 @@ function createPointerDrag(opt) {
3589
3589
  return base;
3590
3590
  }
3591
3591
  const hostRef = inject((ElementRef), { optional: true });
3592
- const { target = hostRef?.nativeElement, coordinateSpace = 'client', activationThreshold = 3, throttle = 16, handleSelector, buttons = [0], stopPropagation = false, debugName = 'pointerDrag', } = opt ?? {};
3592
+ const { target = hostRef?.nativeElement, coordinateSpace = 'client', activationThreshold = 3, throttle = 16, handleSelector, buttons = [0], stopPropagation = false, capture = false, debugName = 'pointerDrag', } = opt ?? {};
3593
3593
  const resolve = (t) => {
3594
3594
  if (!t)
3595
3595
  return null;
@@ -3721,6 +3721,7 @@ function createPointerDrag(opt) {
3721
3721
  const controller = new AbortController();
3722
3722
  el.addEventListener('pointerdown', onDown(el), {
3723
3723
  signal: controller.signal,
3724
+ capture,
3724
3725
  });
3725
3726
  return () => {
3726
3727
  controller.abort();
@@ -6916,14 +6917,27 @@ function storeTabSync(sig, opt, bus, injector) {
6916
6917
  case 'hello': {
6917
6918
  if (phase !== 'live' || msg.from === sync.origin)
6918
6919
  return;
6919
- // first responder wins: jittered answer, cancelled when someone else answers first
6920
- const timer = setTimeout(() => {
6921
- responseTimers.delete(msg.from);
6920
+ const respond = () => {
6922
6921
  const snap = sync.snapshot();
6923
6922
  const covered = Object.entries(snap.wm).every(([origin, v]) => (msg.wm[origin] ?? 0) >= v);
6924
6923
  post(covered
6925
6924
  ? { t: 'uptodate', proto: OP_PROTO_VERSION, to: msg.from }
6926
6925
  : { t: 'state', proto: OP_PROTO_VERSION, to: msg.from, state: snap });
6926
+ };
6927
+ // `jitterMs: 0` answers HERE, in the message handler, with no timer at all. This is the
6928
+ // difference between "as fast as possible" and "possible": a hidden tab's timers are
6929
+ // aligned to ≥1s, so even setTimeout(0) from a backgrounded responder routinely outlives
6930
+ // the joiner's hello window — while message events are not throttled. A channel whose
6931
+ // typical population is one hidden responder (a builder answering its preview tab) opts
6932
+ // in; the jittered path stays the default for many-peer channels.
6933
+ if (jitterMs === 0) {
6934
+ respond();
6935
+ return;
6936
+ }
6937
+ // first responder wins: jittered answer, cancelled when someone else answers first
6938
+ const timer = setTimeout(() => {
6939
+ responseTimers.delete(msg.from);
6940
+ respond();
6927
6941
  }, Math.random() * jitterMs);
6928
6942
  responseTimers.set(msg.from, timer);
6929
6943
  return;