New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@solid-primitives/selection

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/selection - npm Package Compare versions

Comparing version
0.0.4
to
0.0.5
+16
-16
dist/dev.cjs

@@ -6,10 +6,10 @@ 'use strict';

// src/index.ts
exports.getTextNodes = (node) => {
exports.getTextNodes = (startNode) => {
const textNodes = [];
const walkNodes = (node2) => {
node2 instanceof Text && textNodes.push(node2);
node2.firstChild && walkNodes(node2.firstChild);
node2.nextSibling && walkNodes(node2.nextSibling);
const walkNodes = (node) => {
node instanceof Text && textNodes.push(node);
node.firstChild && walkNodes(node.firstChild);
node.nextSibling && walkNodes(node.nextSibling);
};
walkNodes(node);
walkNodes(startNode);
return textNodes;

@@ -22,3 +22,3 @@ };

};
var getParent = (node) => node === null || node?.contentEditable === "true" ? node : getParent(node.parentNode || null);
var getParent = (node) => node === null || node.contentEditable === "true" ? node : getParent(node.parentNode || null);
var getRangeArgs = (offset, texts) => texts.reduce(

@@ -29,3 +29,3 @@ ([node, pos], text) => node ? [node, pos] : pos <= text.data.length ? [text, pos] : [null, pos - text.data.length],

exports.createSelection = () => {
const [selection, setSelection] = solidJs.createSignal([null, NaN, NaN]);
const [getSelection, setSelection] = solidJs.createSignal([null, NaN, NaN]);
const [selected, setSelected] = solidJs.createSignal([null, NaN, NaN]);

@@ -37,7 +37,7 @@ const selectionHandler = () => {

}
const selection2 = window.getSelection();
if (!selection2?.rangeCount) {
const selection = window.getSelection();
if (!selection?.rangeCount) {
return setSelection([null, NaN, NaN]);
}
const range = selection2.getRangeAt(0);
const range = selection.getRangeAt(0);
const parent = getParent(range.commonAncestorContainer);

@@ -65,5 +65,5 @@ if (!parent) {

const [node, start, end] = selected();
const selection2 = window.getSelection();
const selection = window.getSelection();
if (node === null) {
selection2?.rangeCount && selection2.removeAllRanges();
selection?.rangeCount && selection.removeAllRanges();
} else if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement) {

@@ -73,3 +73,3 @@ document.activeElement !== node && node.focus();

} else {
selection2?.removeAllRanges();
selection?.removeAllRanges();
const range = document.createRange();

@@ -82,7 +82,7 @@ const texts = exports.getTextNodes(node);

range.setEnd(endNode, endPos);
selection2?.addRange(range);
selection?.addRange(range);
}
}
});
return [selection, setSelected];
return [getSelection, setSelected];
};
import { createSignal, createEffect, onCleanup } from 'solid-js';
// src/index.ts
var getTextNodes = (node) => {
var getTextNodes = (startNode) => {
const textNodes = [];
const walkNodes = (node2) => {
node2 instanceof Text && textNodes.push(node2);
node2.firstChild && walkNodes(node2.firstChild);
node2.nextSibling && walkNodes(node2.nextSibling);
const walkNodes = (node) => {
node instanceof Text && textNodes.push(node);
node.firstChild && walkNodes(node.firstChild);
node.nextSibling && walkNodes(node.nextSibling);
};
walkNodes(node);
walkNodes(startNode);
return textNodes;

@@ -19,3 +19,3 @@ };

};
var getParent = (node) => node === null || node?.contentEditable === "true" ? node : getParent(node.parentNode || null);
var getParent = (node) => node === null || node.contentEditable === "true" ? node : getParent(node.parentNode || null);
var getRangeArgs = (offset, texts) => texts.reduce(

@@ -26,3 +26,3 @@ ([node, pos], text) => node ? [node, pos] : pos <= text.data.length ? [text, pos] : [null, pos - text.data.length],

var createSelection = () => {
const [selection, setSelection] = createSignal([null, NaN, NaN]);
const [getSelection, setSelection] = createSignal([null, NaN, NaN]);
const [selected, setSelected] = createSignal([null, NaN, NaN]);

@@ -34,7 +34,7 @@ const selectionHandler = () => {

}
const selection2 = window.getSelection();
if (!selection2?.rangeCount) {
const selection = window.getSelection();
if (!selection?.rangeCount) {
return setSelection([null, NaN, NaN]);
}
const range = selection2.getRangeAt(0);
const range = selection.getRangeAt(0);
const parent = getParent(range.commonAncestorContainer);

@@ -62,5 +62,5 @@ if (!parent) {

const [node, start, end] = selected();
const selection2 = window.getSelection();
const selection = window.getSelection();
if (node === null) {
selection2?.rangeCount && selection2.removeAllRanges();
selection?.rangeCount && selection.removeAllRanges();
} else if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement) {

@@ -70,3 +70,3 @@ document.activeElement !== node && node.focus();

} else {
selection2?.removeAllRanges();
selection?.removeAllRanges();
const range = document.createRange();

@@ -79,9 +79,9 @@ const texts = getTextNodes(node);

range.setEnd(endNode, endPos);
selection2?.addRange(range);
selection?.addRange(range);
}
}
});
return [selection, setSelected];
return [getSelection, setSelected];
};
export { createSelection, getTextNodes };

@@ -6,10 +6,10 @@ 'use strict';

// src/index.ts
exports.getTextNodes = (node) => {
exports.getTextNodes = (startNode) => {
const textNodes = [];
const walkNodes = (node2) => {
node2 instanceof Text && textNodes.push(node2);
node2.firstChild && walkNodes(node2.firstChild);
node2.nextSibling && walkNodes(node2.nextSibling);
const walkNodes = (node) => {
node instanceof Text && textNodes.push(node);
node.firstChild && walkNodes(node.firstChild);
node.nextSibling && walkNodes(node.nextSibling);
};
walkNodes(node);
walkNodes(startNode);
return textNodes;

@@ -22,3 +22,3 @@ };

};
var getParent = (node) => node === null || node?.contentEditable === "true" ? node : getParent(node.parentNode || null);
var getParent = (node) => node === null || node.contentEditable === "true" ? node : getParent(node.parentNode || null);
var getRangeArgs = (offset, texts) => texts.reduce(

@@ -29,3 +29,3 @@ ([node, pos], text) => node ? [node, pos] : pos <= text.data.length ? [text, pos] : [null, pos - text.data.length],

exports.createSelection = () => {
const [selection, setSelection] = solidJs.createSignal([null, NaN, NaN]);
const [getSelection, setSelection] = solidJs.createSignal([null, NaN, NaN]);
const [selected, setSelected] = solidJs.createSignal([null, NaN, NaN]);

@@ -37,7 +37,7 @@ const selectionHandler = () => {

}
const selection2 = window.getSelection();
if (!selection2?.rangeCount) {
const selection = window.getSelection();
if (!selection?.rangeCount) {
return setSelection([null, NaN, NaN]);
}
const range = selection2.getRangeAt(0);
const range = selection.getRangeAt(0);
const parent = getParent(range.commonAncestorContainer);

@@ -65,5 +65,5 @@ if (!parent) {

const [node, start, end] = selected();
const selection2 = window.getSelection();
const selection = window.getSelection();
if (node === null) {
selection2?.rangeCount && selection2.removeAllRanges();
selection?.rangeCount && selection.removeAllRanges();
} else if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement) {

@@ -73,3 +73,3 @@ document.activeElement !== node && node.focus();

} else {
selection2?.removeAllRanges();
selection?.removeAllRanges();
const range = document.createRange();

@@ -82,7 +82,7 @@ const texts = exports.getTextNodes(node);

range.setEnd(endNode, endPos);
selection2?.addRange(range);
selection?.addRange(range);
}
}
});
return [selection, setSelected];
return [getSelection, setSelected];
};
import { Accessor, Setter } from 'solid-js';
type HTMLSelection = [node: HTMLElement | null, start: number, end: number];
declare const getTextNodes: (node: Node) => Node[];
declare const getTextNodes: (startNode: Node) => Node[];
declare const createSelection: () => [Accessor<HTMLSelection>, Setter<HTMLSelection>];
export { HTMLSelection, createSelection, getTextNodes };
import { createSignal, createEffect, onCleanup } from 'solid-js';
// src/index.ts
var getTextNodes = (node) => {
var getTextNodes = (startNode) => {
const textNodes = [];
const walkNodes = (node2) => {
node2 instanceof Text && textNodes.push(node2);
node2.firstChild && walkNodes(node2.firstChild);
node2.nextSibling && walkNodes(node2.nextSibling);
const walkNodes = (node) => {
node instanceof Text && textNodes.push(node);
node.firstChild && walkNodes(node.firstChild);
node.nextSibling && walkNodes(node.nextSibling);
};
walkNodes(node);
walkNodes(startNode);
return textNodes;

@@ -19,3 +19,3 @@ };

};
var getParent = (node) => node === null || node?.contentEditable === "true" ? node : getParent(node.parentNode || null);
var getParent = (node) => node === null || node.contentEditable === "true" ? node : getParent(node.parentNode || null);
var getRangeArgs = (offset, texts) => texts.reduce(

@@ -26,3 +26,3 @@ ([node, pos], text) => node ? [node, pos] : pos <= text.data.length ? [text, pos] : [null, pos - text.data.length],

var createSelection = () => {
const [selection, setSelection] = createSignal([null, NaN, NaN]);
const [getSelection, setSelection] = createSignal([null, NaN, NaN]);
const [selected, setSelected] = createSignal([null, NaN, NaN]);

@@ -34,7 +34,7 @@ const selectionHandler = () => {

}
const selection2 = window.getSelection();
if (!selection2?.rangeCount) {
const selection = window.getSelection();
if (!selection?.rangeCount) {
return setSelection([null, NaN, NaN]);
}
const range = selection2.getRangeAt(0);
const range = selection.getRangeAt(0);
const parent = getParent(range.commonAncestorContainer);

@@ -62,5 +62,5 @@ if (!parent) {

const [node, start, end] = selected();
const selection2 = window.getSelection();
const selection = window.getSelection();
if (node === null) {
selection2?.rangeCount && selection2.removeAllRanges();
selection?.rangeCount && selection.removeAllRanges();
} else if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement) {

@@ -70,3 +70,3 @@ document.activeElement !== node && node.focus();

} else {
selection2?.removeAllRanges();
selection?.removeAllRanges();
const range = document.createRange();

@@ -79,9 +79,9 @@ const texts = getTextNodes(node);

range.setEnd(endNode, endPos);
selection2?.addRange(range);
selection?.addRange(range);
}
}
});
return [selection, setSelected];
return [getSelection, setSelected];
};
export { createSelection, getTextNodes };

@@ -6,10 +6,10 @@ 'use strict';

// src/index.ts
exports.getTextNodes = (node) => {
exports.getTextNodes = (startNode) => {
const textNodes = [];
const walkNodes = (node2) => {
node2 instanceof Text && textNodes.push(node2);
node2.firstChild && walkNodes(node2.firstChild);
node2.nextSibling && walkNodes(node2.nextSibling);
const walkNodes = (node) => {
node instanceof Text && textNodes.push(node);
node.firstChild && walkNodes(node.firstChild);
node.nextSibling && walkNodes(node.nextSibling);
};
walkNodes(node);
walkNodes(startNode);
return textNodes;

@@ -16,0 +16,0 @@ };

import 'solid-js';
// src/index.ts
var getTextNodes = (node) => {
var getTextNodes = (startNode) => {
const textNodes = [];
const walkNodes = (node2) => {
node2 instanceof Text && textNodes.push(node2);
node2.firstChild && walkNodes(node2.firstChild);
node2.nextSibling && walkNodes(node2.nextSibling);
const walkNodes = (node) => {
node instanceof Text && textNodes.push(node);
node.firstChild && walkNodes(node.firstChild);
node.nextSibling && walkNodes(node.nextSibling);
};
walkNodes(node);
walkNodes(startNode);
return textNodes;

@@ -13,0 +13,0 @@ };

{
"name": "@solid-primitives/selection",
"version": "0.0.4",
"version": "0.0.5",
"description": "selection primitive.",

@@ -5,0 +5,0 @@ "author": "Alex Lohr <alex.lohr@logmein.com>",