@ohhwells/bridge 0.1.147 → 0.1.148

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.js CHANGED
@@ -1476,7 +1476,19 @@ function brandTrackedFontFamily(doc, stack) {
1476
1476
  }
1477
1477
  var paintLockByEl = /* @__PURE__ */ new WeakMap();
1478
1478
  var paintObserverByEl = /* @__PURE__ */ new WeakMap();
1479
- var paintingButton = false;
1479
+ var PAINT_GUARD_ATTRS = {
1480
+ attributes: true,
1481
+ attributeFilter: ["style", "class"]
1482
+ };
1483
+ function paintGuarded(el, assignment, tokens) {
1484
+ const observer = paintObserverByEl.get(el);
1485
+ observer?.disconnect();
1486
+ try {
1487
+ paintButtonChrome(el, assignment, tokens);
1488
+ } finally {
1489
+ observer?.observe(el, PAINT_GUARD_ATTRS);
1490
+ }
1491
+ }
1480
1492
  function paintButtonChrome(el, assignment, tokens) {
1481
1493
  const origin = captureButtonOrigin(el);
1482
1494
  const chrome = tokens.variants[assignment.variant];
@@ -1515,14 +1527,11 @@ function paintButtonChrome(el, assignment, tokens) {
1515
1527
  function guardTemplateHover(el) {
1516
1528
  if (paintObserverByEl.has(el)) return;
1517
1529
  const observer = new MutationObserver(() => {
1518
- if (paintingButton) return;
1519
1530
  const lock = paintLockByEl.get(el);
1520
1531
  if (!lock) return;
1521
- paintingButton = true;
1522
- paintButtonChrome(el, lock.assignment, lock.tokens);
1523
- paintingButton = false;
1532
+ paintGuarded(el, lock.assignment, lock.tokens);
1524
1533
  });
1525
- observer.observe(el, { attributes: true, attributeFilter: ["style", "class"] });
1534
+ observer.observe(el, PAINT_GUARD_ATTRS);
1526
1535
  paintObserverByEl.set(el, observer);
1527
1536
  }
1528
1537
  function paintedTokensOf(el) {
@@ -1539,10 +1548,8 @@ function applyButtonStyle(el, assignment, tokens) {
1539
1548
  }
1540
1549
  };
1541
1550
  paintLockByEl.set(el, { assignment, tokens: tracked });
1542
- paintingButton = true;
1543
- paintButtonChrome(el, assignment, tracked);
1544
- paintingButton = false;
1545
1551
  guardTemplateHover(el);
1552
+ paintGuarded(el, assignment, tracked);
1546
1553
  }
1547
1554
  function applyButtonStylesFromContent(doc, content) {
1548
1555
  const assignments = readAssignments(content);
@@ -31561,7 +31568,7 @@ function OhhwellsBridge() {
31561
31568
  postToParent2({
31562
31569
  type: "ow:ready",
31563
31570
  version: "1",
31564
- bridgeVersion: "0.1.146",
31571
+ bridgeVersion: "0.1.147",
31565
31572
  path: pathname,
31566
31573
  nodes: collectEditableNodes(editContentRef.current),
31567
31574
  sections