@sanmid/flux 0.1.1 → 0.1.3

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/README.md CHANGED
@@ -14,15 +14,7 @@ npm install @sanmid/flux -D
14
14
 
15
15
  Or: `pnpm add -D @sanmid/flux` · `yarn add -D @sanmid/flux`
16
16
 
17
- **Why another line?** Some tools document a single install line because everything ships inside the package. Flux declares **peer dependencies** small shared libraries your app installs next to Flux (npm does not add peers automatically):
18
-
19
- ```bash
20
- npm install lucide-react clsx tailwind-merge framer-motion
21
- ```
22
-
23
- (`pnpm add …` / `yarn add …` with the same names.) You already have `react` and `react-dom` (18+) in a React app.
24
-
25
- **Peers:** `react`, `react-dom` (18+), `lucide-react`, `clsx`, `tailwind-merge`, `framer-motion`.
17
+ Icons, `clsx`, `tailwind-merge`, and `framer-motion` are **dependencies of Flux** you do not install them separately. You only need **`react` and `react-dom` (18+)** in your app (Flux lists them as peer dependencies so one React instance is shared with your UI).
26
18
 
27
19
  ---
28
20
 
package/SECURITY.md CHANGED
@@ -16,7 +16,7 @@ Flux is a **client-side React library** that runs in the browser alongside your
16
16
  | **Clipboard** | Copy uses the browser **Clipboard API** / `execCommand('copy')` **after a user gesture** (e.g. clicking Copy). Prompt text reflects DOM and styles under the user’s control. |
17
17
  | **Storage** | Preview state may be persisted to **`localStorage`** (namespaced keys) so edits survive reloads during development. Treat stored data as **sensitive as your page content**; clear site data if needed. |
18
18
  | **DOM** | The editor injects UI (overlay, panel, drag layers) and may set temporary inline styles during drag/reposition. It applies preview CSS via a stylesheet; review `PreviewEngine` if you extend integration. |
19
- | **Dependencies** | Runtime deps are limited (see `package.json`). Run `pnpm audit` / `npm audit` in your app and keep peers updated. |
19
+ | **Dependencies** | Runtime deps are limited (see `package.json`). Run `pnpm audit` / `npm audit` in your app and keep dependencies updated. |
20
20
 
21
21
  ## Production use
22
22
 
package/dist/index.d.ts CHANGED
@@ -87,10 +87,9 @@ declare function getUniqueSelector(el: Element): string;
87
87
  declare function getDirectChildSelector(parent: Element, child: Element): string;
88
88
  /**
89
89
  * Selector used for {@link PreviewEngine} rules. Verifies each candidate with
90
- * `document.querySelector(sel) === el` so previews (e.g. background) hit the
91
- * intended node; @medv/finder can occasionally produce a selector that matches
92
- * a different element. Last resort: a temporary `data-flux-preview-target` id
93
- * on the element — call {@link removePreviewTargetAttribute} when deselecting.
90
+ * `querySelectorAll(sel).length === 1` and that node is `el`, so injected rules
91
+ * cannot hit multiple elements (e.g. all `button`s). Last resort: a temporary
92
+ * `data-flux-preview-target` id — call {@link removePreviewTargetAttribute} when deselecting.
94
93
  */
95
94
  declare function getReliableSelectorForPreview(el: Element): {
96
95
  selector: string;
package/dist/index.js CHANGED
@@ -2578,9 +2578,10 @@ function getDirectChildSelector(parent, child) {
2578
2578
  return getUniqueSelector(child);
2579
2579
  }
2580
2580
  var PREVIEW_TARGET_ATTR = "data-flux-preview-target";
2581
- function selectorMatchesElement(sel, el) {
2581
+ function selectorUniquelyTargetsElement(sel, el) {
2582
2582
  try {
2583
- return document.querySelector(sel) === el;
2583
+ const all = document.querySelectorAll(sel);
2584
+ return all.length === 1 && all[0] === el;
2584
2585
  } catch {
2585
2586
  return false;
2586
2587
  }
@@ -2605,7 +2606,7 @@ function getReliableSelectorForPreview(el) {
2605
2606
  push(getDirectChildSelector(p, el));
2606
2607
  }
2607
2608
  for (const s of candidates) {
2608
- if (selectorMatchesElement(s, el)) {
2609
+ if (selectorUniquelyTargetsElement(s, el)) {
2609
2610
  return { selector: s, usedAttrFallback: false };
2610
2611
  }
2611
2612
  }