vite-plugin-specter 0.3.2 → 0.3.4

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/client.js CHANGED
@@ -273,17 +273,11 @@
273
273
  return { hex: toHex(m[1], m[2], m[3]), alpha: m[4] !== undefined ? parseFloat(m[4]) : 1 };
274
274
  }
275
275
 
276
- function colorLabel(str) {
277
- var c = parseColor(str);
278
- if (!c) return null;
279
- if (c.alpha < 1) return c.hex + ' (' + Math.round(c.alpha * 100) + '% opacity)';
280
- return c.hex;
281
- }
282
-
283
276
  function colorObj(str) {
284
277
  var c = parseColor(str);
285
278
  if (!c) return null;
286
- return { raw: str, hex: c.hex, alpha: c.alpha, label: colorLabel(str) };
279
+ var label = c.alpha < 1 ? c.hex + ' (' + Math.round(c.alpha * 100) + '% opacity)' : c.hex;
280
+ return { raw: str, hex: c.hex, alpha: c.alpha, label: label };
287
281
  }
288
282
 
289
283
  function edge(t, r, b, l) {
@@ -485,6 +479,7 @@
485
479
  function clearHoverOutline() {
486
480
  if (outlinedEl) {
487
481
  outlinedEl.style.outline = prevOutline;
482
+ outlinedEl.style.outlineOffset = '';
488
483
  outlinedEl = null;
489
484
  }
490
485
  }
@@ -561,7 +556,7 @@
561
556
  }
562
557
 
563
558
  function clearSelection() {
564
- selectedEls.forEach(function (el) { el.style.outline = ''; });
559
+ selectedEls.forEach(function (el) { el.style.outline = ''; el.style.outlineOffset = ''; });
565
560
  selectedEls.length = 0;
566
561
  selectedBadges.forEach(function (b) { b.remove(); });
567
562
  selectedBadges.length = 0;
@@ -926,7 +921,7 @@
926
921
  if (isInputFocused()) return;
927
922
 
928
923
  if (e.key === 'p' || e.key === 'P') {
929
- if (measureMode || !lastHovered) return;
924
+ if (!lastHovered) return;
930
925
  clearHoverOutline();
931
926
  toggleSelection(lastHovered);
932
927
  return;
@@ -945,11 +940,12 @@
945
940
  }
946
941
 
947
942
  if (e.key === 'Escape') {
948
- if (pinEl) {
943
+ if (pinEl || selectedEls.length > 0) {
949
944
  clearPin();
945
+ clearSelection();
950
946
  clearMeasureOverlay();
951
947
  hideTooltip();
952
- updatePillForSelection();
948
+ collapsePill();
953
949
  } else {
954
950
  deactivate();
955
951
  }
@@ -975,8 +971,9 @@
975
971
 
976
972
  window.__specterToggle = function() { if (fiActive) deactivate(); else activate(); };
977
973
 
978
- if (typeof browser !== 'undefined' && browser.runtime && browser.runtime.onMessage) {
979
- browser.runtime.onMessage.addListener(function(msg) {
974
+ var _rt = (typeof browser !== 'undefined' && browser.runtime) || (typeof chrome !== 'undefined' && chrome.runtime);
975
+ if (_rt && _rt.onMessage) {
976
+ _rt.onMessage.addListener(function(msg) {
980
977
  if (msg && msg.type === 'specter-toggle') window.__specterToggle();
981
978
  });
982
979
  }
@@ -0,0 +1,4 @@
1
+ // Chrome MV3 service worker
2
+ chrome.action.onClicked.addListener((tab) => {
3
+ chrome.tabs.sendMessage(tab.id, { type: 'specter-toggle' });
4
+ });