Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
mouse-presence
Advanced tools
Centralizes handling of mouse appearance/disappearance events in the browser
Centralizes handling of mouse appearance/disappearance events in the browser.
npm: npm install --save mouse-presence
Yarn: yarn add mouse-presence
MousePresence.onDisappear(cb)
cb
: A callback function that takes no arguments and returns nothing.
returns: A deregisterer for cb
.
Registers a callback to be called whenever a mouse cursor disappearance is dispatched.
MousePresence.onAppear(cb)
cb
: A callback function that takes no arguments and returns nothing.
returns: A deregisterer for cb
.
Registers a callback to be called whenever the mouse is moved after a disappearance was dispatched. (Moving the mouse after the cursor disappeared will cause it to reappear.)
MousePresence.unregisterCallback(cb)
cb
: The callback reference to be unregistered.
returns: Nothing.
Unregisters a previously-registered callback from either onDisappear or onAppear (or both). If no such callback is found, nothing happens.
MousePresence.dispatchDisappear()
returns: Nothing.
Dispatches a mouse disappearance event, which will call all registered onDisappear callbacks (will only do this once - subsequent calls will have no effect until the next onAppear event occurs). It will also register a one-time mousemove listener on the document, which when triggered, will call all registered onAppear callbacks.
MousePresence.isPresent()
returns: Boolean indicating whether the mouse cursor is present.
Determine if the mouse cursor is present or not (according to the last reported appearance/disappearance event).
MousePresence.dispatchDisappearOnKeydown(el)
el
: The HTMLElement for which the keydown listener should be added to.
returns: A deregisterer for the keydown listener that will be added.
Adds a keydown listener to the provided HTMLElement, which will trigger a dispatchDisappear call when triggered (since typing will cause the mouse cursor to disappear). This is a convenience function for any text-based input elements, to be used instead of explicitly attaching a listener and calling dispatchDisappear yourself.
Component A:
import MousePresence from 'mouse-presence';
// Gets called on every onDisappear event
MousePresence.onDisappear(() => {
// Take actions...
});
// Gets called on every onAppear event
MousePresence.onAppear(() => {
// Take actions...
});
Component B:
import MousePresence from 'mouse-presence';
// Only gets called for one onDisappear event, then unregisters itself
let disappearCb = MousePresence.onDisappear(() => {
MousePresence.unregisterCallback(disappearCb);
});
Component C:
import MousePresence from 'mouse-presence';
// Mouse cursor disappears when typing
this.element.addEventListener('keydown', () => {
MousePresence.dispatchDisappear();
// Will immediately dispatch onDisappear
// Will automatically attach a mousemove listener, upon which onAppear will be dispatched
// Will not redispatch onDisappear until the onAppear event occurs
});
FAQs
Centralizes handling of mouse appearance/disappearance events in the browser
The npm package mouse-presence receives a total of 1,468 weekly downloads. As such, mouse-presence popularity was classified as popular.
We found that mouse-presence demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.