mnfst 0.5.195 → 0.5.197

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.
@@ -106,11 +106,24 @@
106
106
  for (const k of Object.keys(incoming)) if (k !== 'body' && k !== '_seq') target[k] = incoming[k];
107
107
  }
108
108
 
109
+ // own echo beating the ack: claim the pending row by meta.clientId
110
+ function claimPending(incoming) {
111
+ const cid = incoming.meta && incoming.meta.clientId;
112
+ if (cid == null || !state.me || !incoming.author || incoming.author.id !== state.me.id) return null;
113
+ return _msgs.find(m => m._optimistic && m._clientId === cid) || null;
114
+ }
115
+
109
116
  function upsert(raw) {
110
117
  const incoming = normalize(raw, ++seq);
111
118
  const prev = incoming.id != null ? _byId.get(incoming.id) : null;
119
+ const pending = prev ? null : claimPending(incoming);
112
120
  if (prev) {
113
121
  merge(prev, incoming);
122
+ } else if (pending) {
123
+ _byId.delete(pending.id);
124
+ merge(pending, incoming);
125
+ pending._optimistic = false;
126
+ if (pending.id != null) _byId.set(pending.id, pending);
114
127
  } else {
115
128
  _msgs.push(incoming);
116
129
  if (incoming.id != null) _byId.set(incoming.id, incoming);
@@ -176,11 +189,11 @@
176
189
  async function send(draft) {
177
190
  const tmp = 'tmp_' + (++seq);
178
191
  const body = draft && draft.body ? draft.body : { text: draft && draft.text != null ? draft.text : '' };
179
- const local = normalize({ id: tmp, conversationId, author: state.me, body, replyTo: draft && draft.replyTo, status: 'pending', ts: null, _optimistic: true }, ++seq);
192
+ const local = normalize({ id: tmp, conversationId, author: state.me, body, replyTo: draft && draft.replyTo, status: 'pending', ts: null, _optimistic: true, _clientId: tmp }, ++seq);
180
193
  _msgs.push(local); _byId.set(tmp, local); commit();
181
194
  if (!adapter.send) { local.status = 'failed'; local.statusReason = 'unsupported'; commit(); return; }
182
195
  try {
183
- const ack = await adapter.send(conversationId, Object.assign({}, draft, { body }));
196
+ const ack = await adapter.send(conversationId, Object.assign({}, draft, { body, clientId: tmp }));
184
197
  _byId.delete(tmp);
185
198
  // A bus that echoes our own send can beat the ack; that echo lands
186
199
  // while this row is still tmp-keyed, so it appended as its own entry.
@@ -10,13 +10,18 @@
10
10
 
11
11
  @layer base {
12
12
 
13
+ /* Animates `scale`, not `transform`. With fill mode `both` a transform
14
+ animation keeps its final value forever, which silently overrides any
15
+ transform an author put on a popover — so a menu positioned with
16
+ translate(-50%) simply would not move. The standalone property leaves
17
+ transform free. */
13
18
  @keyframes mnfst-popover-in {
14
19
  from {
15
- transform: scale(.9)
20
+ scale: .9
16
21
  }
17
22
 
18
23
  to {
19
- transform: none
24
+ scale: 1
20
25
  }
21
26
  }
22
27
 
@@ -2547,6 +2547,11 @@ function initializeColorpickerPlugin() {
2547
2547
 
2548
2548
  const isDialog = target.tagName === 'DIALOG';
2549
2549
 
2550
+ // A generated panel is appended to <body>, so manifest.dialog.css can't
2551
+ // tell from DOM position that it belongs to a swatch inside a dialog
2552
+ // rather than to the page behind it, and fades it out. Say so here.
2553
+ if (el.closest('[popover]')) target.setAttribute('data-popover-nested', '');
2554
+
2550
2555
  // Non-dialog popover targets route through x-dropdown (anchored like
2551
2556
  // a dropdown). <dialog> targets open imperatively on click instead
2552
2557
  // (modal/centered, not trigger-anchored).
@@ -2568,7 +2573,9 @@ function initializeColorpickerPlugin() {
2568
2573
  e.preventDefault();
2569
2574
  try {
2570
2575
  if (target.hasAttribute('popover')) {
2571
- if (!target.matches(':popover-open')) target.showPopover();
2576
+ // `source` names the swatch as the invoker, so opening the
2577
+ // panel can't light-dismiss a dialog or menu it sits inside.
2578
+ if (!target.matches(':popover-open')) target.showPopover({ source: el });
2572
2579
  } else {
2573
2580
  if (!target.open) target.showModal();
2574
2581
  }