New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

creepyface

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

creepyface - npm Package Compare versions

Comparing version 4.3.0-beta.0 to 4.3.0

4

dist/creepyface.d.ts
import { UserOptions } from './util/options';
import { Cancel } from './util/types';
import { Observable } from './observables/util/observable';
import { Vector } from './util/algebra';
import { Point } from './util/algebra';
declare const creepyface: {
(img: HTMLImageElement, options?: UserOptions | undefined): Cancel;
cancel(img: HTMLImageElement): void;
registerPointSource(name: string, observable: Observable<Vector>): void;
registerObservable(name: string, observable: Observable<Point>): void;
};
export default creepyface;

@@ -22,3 +22,3 @@ import attach from './util/attach';

};
creepyface.registerPointSource = (name, observable) => {
creepyface.registerObservable = (name, observable) => {
observableStore.register(name, observable);

@@ -25,0 +25,0 @@ };

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).creepyface=e()}(this,function(){"use strict";var s=function(o,c){var u=[];o.forEach(function(t){var e,n,r;e=t,n=function(t){u.push(t),u.length===o.length&&c(u)},(r=new Image).src=e,r.onload=r.onerror=function(){r.naturalWidth||console.error("Creepyface was unable to load ".concat(e)),delete r.onload,delete r.onerror,n(r)}})};function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var u=function(){},t=function(e){return{subscribe:function(t){return{unsubscribe:e({next:t})}}}},r=[];document.addEventListener("mousemove",function(e){return r.forEach(function(t){return t.next([e.clientX,e.clientY])})},!0);var e=t(function(t){return r.push(t),function(){r.splice(r.indexOf(t),1)}}),i=function(t,n){return t.map(function(t,e){return t+n[e]})},a=function(t){return t*Math.PI/180},f=function(t){return e=Math.atan2(t[1],t[0]),n=2*Math.PI,180*((n+e%n)%n)/Math.PI;var e,n},c=[];document.addEventListener("touchmove",function(o){return c.forEach(function(t){for(var e=[0,0],n=0;n<o.touches.length;n++){var r=o.touches[n];e=i(e,[r.clientX,r.clientY])}t.next(e)})},!0);var o,l=t(function(t){return c.push(t),function(){c.splice(c.indexOf(t),1)}}),d={pointer:(o=[e,l],t(function(e){var t=o.map(function(t){return t.subscribe(e.next)});return function(){return t.forEach(function(t){return t.unsubscribe()})}}))},v=function(t){var e=t?parseFloat(t):NaN;return isNaN(e)?void 0:e},b=function(t){return{hover:t.getAttribute("data-src-hover")||void 0,looks:function(t){for(var e=/data-src-look-(\d+)/i,n=[],r=0;r<t.attributes.length;r++){var o=t.attributes[r],c=e.exec(o.name);c&&n.push({angle:parseFloat(c[1]),src:o.value})}return n.length?n:void 0}(t),points:t.getAttribute("data-points")||void 0,timeToDefault:v(t.getAttribute("data-timetodefault")),throttle:v(t.getAttribute("data-throttle")),fieldOfVision:v(t.getAttribute("data-fieldofvision")),resetOnCancel:!("false"===t.getAttribute("data-resetoncancel"))}},h=function(t){return"object"===n(t.points)?t.points:(e=t.points||"pointer",d[e]?d[e]:(console.error("No observable registered as '".concat(e,"', defaulting to pointer.")),d.pointer));var e};function p(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=function(o){for(var t=1;t<arguments.length;t++){var c=null!=arguments[t]?arguments[t]:{},e=Object.keys(c);"function"==typeof Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(c).filter(function(t){return Object.getOwnPropertyDescriptor(c,t).enumerable}))),e.forEach(function(t){var e,n,r;e=o,r=c[n=t],n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r})}return o}({},b(t),e),r=t.getAttribute("src");if(!r)throw new Error("A default URL must be specified");return{fieldOfVision:n.fieldOfVision||150,src:r,hover:n.hover||"",points:h(n),looks:n.looks||[],timeToDefault:n.timeToDefault||1e3,resetOnCancel:!(!1===n.resetOnCancel),throttle:n.throttle||100,onDebug:n.onDebug||u,onAttach:n.onAttach||u,onDetach:n.onDetach||u}}var m=function(t){var e=t.getBoundingClientRect(),n=e.top+window.pageYOffset+e.height/2,r=e.left+window.pageXOffset+e.width/2;return{y:n,x:r}};var g=function(t,e){return f((o=i([window.scrollX,window.scrollY],e),u=m(t),c=[u.x,u.y],n=o.map(function(t,e){return t-c[e]}),r=90,[n[0]*Math.cos(a(r))-n[1]*Math.sin(a(r)),n[0]*Math.sin(a(r))+n[1]*Math.cos(a(r))]));var n,r,o,c,u},y=function(t){return 180<Math.abs(t)?t-360*((e=t)?e<0?-1:1:0):t;var e},O=function(t,e){return e.slice(0).sort((n=t,function(t,e){return Math.abs(y(t.angle-n))-Math.abs(y(e.angle-n))}))[0];var n},w=function(t,e,n){return e<=t&&t<=n},M=function(t,e){return document.elementFromPoint?document.elementFromPoint(e[0],e[1])===t:(n=t.getBoundingClientRect(),r=[e[0],e[1]],o=n.left,c=n.top,u=n.right,i=n.bottom,w(r[0],o,u)&&w(r[1],c,i));var n,r,o,c,u,i},D=function(b,h){return t(function(r){var t,e,n,o,c,u,i,a,f,s,l,d=(t=function(){return r.next({src:h.src,options:h})},e=h.timeToDefault,(o=function(){n&&clearTimeout(n),n=setTimeout(function(){n=null,t()},e)}).clear=function(){n&&(clearTimeout(n),n=null)},o),v=h.points.subscribe((c=function(t){var e=g(b,t),n=function(t,e,n,r){var o=r.looks,c=r.hover,u=r.fieldOfVision,i=r.src;if(c&&M(t,e))i=c;else{var a=O(n,o);Math.abs(y(a.angle-n))<u/2&&(i=a.src)}return i}(b,t,e,h);r.next({point:t,angle:e,src:n,options:h}),d()},u=h.throttle,f=0,s=function(){f=Date.now(),i=null,c(a)},(l=function(t){var e=Date.now(),n=u-(e-f);a=t,n<=0||u<n?(i&&(clearTimeout(i),i=null),f=e,c(t)):i||(i=setTimeout(s,n))}).clear=function(){i&&clearTimeout(i),f=0,i=null},l));return function(){d.clear(),v.unsubscribe()}})},x=function(n,t){var e,r,o,c,u=p(n,t),i=function(t){n.src=t},a=!1,f=function(){a=!0};return e=n,r=function(t){if(!a){u.onAttach();var e=D(n,u).subscribe(function(t){i(t.src),u.onDebug(t)});f=function(){e.unsubscribe(),u.resetOnCancel&&i(u.src),u.onDetach(),t()}}},s((c=(o=u).looks.map(function(t){return t.src}),o.src&&c.push(o.src),o.hover&&c.push(o.hover),c),function(t){e.creepyfaceReachableImages=t,r(function(){delete e.creepyfaceReachableImages})}),function(){return f()}},A=function t(e,n){t.cancel(e);var r=u,o=function(n,e,r){var o=function(t){return t?e():r()};if(MutationObserver){var c=document.body.contains(n);c&&o(!0);var t=new MutationObserver(function(t){var e=document.body.contains(n);!e&&c?(o(!1),c=!1):e&&!c&&(o(!0),c=!0)});return t.observe(document,{childList:!0,subtree:!0}),function(){return t.disconnect()}}return document.body.contains(n)&&o(!0),n.addEventListener("DOMNodeInserted",function(){return o(!0)},!1),n.addEventListener("DOMNodeRemoved",function(){return o(!1)},!1),u}(e,function(){r=x(e,n)},function(){return t.cancel(e)});return e.creepyfaceCancel=function(){o(),r(),delete e.creepyfaceCancel}};return A.cancel=function(t){var e=t.creepyfaceCancel;e&&e()},A.registerPointSource=function(t,e){var n;n=e,d[t]=n},document.addEventListener("DOMContentLoaded",function(){for(var t=document.querySelectorAll("img[data-creepy],img[data-creepyface]"),e=0;e<t.length;e++){var n=t[e];n instanceof HTMLImageElement&&A(n)}}),A});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).creepyface=n()}(this,function(){"use strict";var s=function(o,u){var c=[];o.forEach(function(t){var n,e,r;n=t,e=function(t){c.push(t),c.length===o.length&&u(c)},(r=new Image).src=n,r.onload=r.onerror=function(){r.naturalWidth||console.error("Creepyface was unable to load ".concat(n)),delete r.onload,delete r.onerror,e(r)}})};function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var c=function(){},t=function(n){return{subscribe:function(t){return{unsubscribe:n({next:t})}}}},r=[];document.addEventListener("mousemove",function(n){return r.forEach(function(t){return t.next([n.clientX,n.clientY])})},!0);var n=t(function(t){return r.push(t),function(){r.splice(r.indexOf(t),1)}}),i=function(t,n){return[t[0]+n[0],t[1]+n[1]]},a=function(t){return t*Math.PI/180},f=function(t){return n=Math.atan2(t[1],t[0]),e=2*Math.PI,180*((e+n%e)%e)/Math.PI;var n,e},u=[];document.addEventListener("touchmove",function(o){return u.forEach(function(t){for(var n=[0,0],e=0;e<o.touches.length;e++){var r=o.touches[e];n=i(n,[r.clientX,r.clientY])}t.next(n)})},!0);var o,l=t(function(t){return u.push(t),function(){u.splice(u.indexOf(t),1)}}),d={pointer:(o=[n,l],t(function(n){var t=o.map(function(t){return t.subscribe(n.next)});return function(){return t.forEach(function(t){return t.unsubscribe()})}}))},v=function(t){var n=t?parseFloat(t):NaN;return isNaN(n)?void 0:n},b=function(t){return{hover:t.getAttribute("data-src-hover")||void 0,looks:function(t){for(var n=/data-src-look-(\d+)/i,e=[],r=0;r<t.attributes.length;r++){var o=t.attributes[r],u=n.exec(o.name);u&&e.push({angle:parseFloat(u[1]),src:o.value})}return e.length?e:void 0}(t),points:t.getAttribute("data-points")||void 0,timeToDefault:v(t.getAttribute("data-timetodefault")),throttle:v(t.getAttribute("data-throttle")),fieldOfVision:v(t.getAttribute("data-fieldofvision"))}},h=function(t){return"object"===e(t.points)?t.points:(n=t.points||"pointer",d[n]?d[n]:(console.error("No observable registered as '".concat(n,"', defaulting to pointer.")),d.pointer));var n};function p(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=function(o){for(var t=1;t<arguments.length;t++){var u=null!=arguments[t]?arguments[t]:{},n=Object.keys(u);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(u).filter(function(t){return Object.getOwnPropertyDescriptor(u,t).enumerable}))),n.forEach(function(t){var n,e,r;n=o,r=u[e=t],e in n?Object.defineProperty(n,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[e]=r})}return o}({},b(t),n),r=t.getAttribute("src");if(!r)throw new Error("A default URL must be specified");return{fieldOfVision:e.fieldOfVision||150,src:r,hover:e.hover||"",points:h(e),looks:e.looks||[],timeToDefault:e.timeToDefault||1e3,throttle:e.throttle||100,onDebug:e.onDebug||c,onAttach:e.onAttach||c,onDetach:e.onDetach||c}}var m=function(t){var n=t.getBoundingClientRect(),e=n.top+window.pageYOffset+n.height/2,r=n.left+window.pageXOffset+n.width/2;return{y:e,x:r}};var g=function(t,n){return f((o=i([window.scrollX,window.scrollY],n),c=m(t),u=[c.x,c.y],e=[o[0]-u[0],o[1]-u[1]],r=90,[e[0]*Math.cos(a(r))-e[1]*Math.sin(a(r)),e[0]*Math.sin(a(r))+e[1]*Math.cos(a(r))]));var e,r,o,u,c},y=function(t){return 180<Math.abs(t)?t-360*((n=t)?n<0?-1:1:0):t;var n},O=function(t,n){return n.slice(0).sort((e=t,function(t,n){return Math.abs(y(t.angle-e))-Math.abs(y(n.angle-e))}))[0];var e},w=function(t,n,e){return n<=t&&t<=e},M=function(t,n){return document.elementFromPoint?document.elementFromPoint(n[0],n[1])===t:(e=t.getBoundingClientRect(),r=[n[0],n[1]],o=e.left,u=e.top,c=e.right,i=e.bottom,w(r[0],o,c)&&w(r[1],u,i));var e,r,o,u,c,i},D=function(b,h){return t(function(r){var t,n,e,o,u,c,i,a,f,s,l,d=(t=function(){return r.next({src:h.src,options:h})},n=h.timeToDefault,(o=function(){e&&clearTimeout(e),e=setTimeout(function(){e=null,t()},n)}).clear=function(){e&&(clearTimeout(e),e=null)},o),v=h.points.subscribe((u=function(t){var n=g(b,t),e=function(t,n,e,r){var o=r.looks,u=r.hover,c=r.fieldOfVision,i=r.src;if(u&&M(t,n))i=u;else{var a=O(e,o);Math.abs(y(a.angle-e))<c/2&&(i=a.src)}return i}(b,t,n,h);r.next({point:t,angle:n,src:e,options:h}),d()},c=h.throttle,f=0,s=function(){f=Date.now(),i=null,u(a)},(l=function(t){var n=Date.now(),e=c-(n-f);a=t,e<=0||c<e?(i&&(clearTimeout(i),i=null),f=n,u(t)):i||(i=setTimeout(s,e))}).clear=function(){i&&clearTimeout(i),f=0,i=null},l));return function(){d.clear(),v.unsubscribe()}})},x=function(e,t){var n,r,o,u,c=p(e,t),i=function(t){e.src=t},a=!1,f=function(){a=!0};return n=e,r=function(t){if(!a){c.onAttach();var n=D(e,c).subscribe(function(t){i(t.src),c.onDebug(t)});f=function(){n.unsubscribe(),i(c.src),c.onDetach(),t()}}},s((u=(o=c).looks.map(function(t){return t.src}),o.src&&u.push(o.src),o.hover&&u.push(o.hover),u),function(t){n.creepyfaceReachableImages=t,r(function(){delete n.creepyfaceReachableImages})}),function(){return f()}},E=function t(n,e){t.cancel(n);var r=c,o=function(e,n,r){var o=function(t){return t?n():r()};if(MutationObserver){var u=document.body.contains(e);u&&o(!0);var t=new MutationObserver(function(t){var n=document.body.contains(e);!n&&u?(o(!1),u=!1):n&&!u&&(o(!0),u=!0)});return t.observe(document,{childList:!0,subtree:!0}),function(){return t.disconnect()}}return document.body.contains(e)&&o(!0),e.addEventListener("DOMNodeInserted",function(){return o(!0)},!1),e.addEventListener("DOMNodeRemoved",function(){return o(!1)},!1),c}(n,function(){r=x(n,e)},function(){return t.cancel(n)});return n.creepyfaceCancel=function(){o(),r(),delete n.creepyfaceCancel}};return E.cancel=function(t){var n=t.creepyfaceCancel;n&&n()},E.registerObservable=function(t,n){var e;e=n,d[t]=e},document.addEventListener("DOMContentLoaded",function(){for(var t=document.querySelectorAll("img[data-creepy],img[data-creepyface]"),n=0;n<t.length;n++){var e=t[n];e instanceof HTMLImageElement&&E(e)}}),E});
import { Observable } from './util/observable';
import { Vector } from '../util/algebra';
declare const _default: (observables: Observable<Vector>[]) => Observable<Vector>;
import { Point } from '../util/algebra';
declare const _default: (observables: Observable<Point>[]) => Observable<Point>;
export default _default;

@@ -1,3 +0,3 @@

import { Vector } from '../util/algebra';
declare const _default: import("./util/observable").Observable<Vector>;
import { Point } from '../util/algebra';
declare const _default: import("./util/observable").Observable<Point>;
export default _default;

@@ -1,3 +0,3 @@

import { Vector } from '../util/algebra';
declare const _default: import("./util/observable").Observable<Vector>;
import { Point } from '../util/algebra';
declare const _default: import("./util/observable").Observable<Point>;
export default _default;

@@ -1,3 +0,3 @@

import { Vector } from '../../util/algebra';
declare const _default: (img: HTMLImageElement, point: Vector) => number;
import { Point } from '../../util/algebra';
declare const _default: (img: HTMLImageElement, point: Point) => number;
export default _default;

@@ -1,4 +0,4 @@

import { Vector } from '../../util/algebra';
import { Point } from '../../util/algebra';
import { Options } from '../../util/options';
declare const _default: (img: HTMLImageElement, point: Vector, angle: number, options: Options) => string;
declare const _default: (img: HTMLImageElement, point: Point, angle: number, options: Options) => string;
export default _default;
import { Observable } from './observable';
import { Vector } from '../../util/algebra';
export declare const register: (name: string, observable: Observable<Vector>) => void;
export declare const retrieve: (name: string) => Observable<Vector>;
import { Point } from '../../util/algebra';
export declare const register: (name: string, observable: Observable<Point>) => void;
export declare const retrieve: (name: string) => Observable<Point>;

@@ -1,7 +0,7 @@

export declare type Vector = Array<number>;
export declare type Point = [number, number];
export declare type Degrees = number;
export declare type Radians = number;
export declare type Angle = Degrees;
export declare const diff: (v1: Vector, v2: Vector) => Vector;
export declare const add: (v1: Vector, v2: Vector) => Vector;
export declare const diff: (v1: Point, v2: Point) => Point;
export declare const add: (v1: Point, v2: Point) => Point;
export declare const sign: (n: number) => 1 | 0 | -1;

@@ -11,3 +11,3 @@ export declare const rad: (deg: number) => number;

export declare const mod: (n: number, m: number) => number;
export declare const getAngle: (v: Vector) => number;
export declare const rotate: (v: Vector, deg: number) => number[];
export declare const getAngle: (v: Point) => number;
export declare const rotate: (v: Point, deg: number) => Point;

@@ -1,3 +0,9 @@

export const diff = (v1, v2) => v1.map((x, i) => x - v2[i]);
export const add = (v1, v2) => v1.map((x, i) => x + v2[i]);
export const diff = (v1, v2) => [
v1[0] - v2[0],
v1[1] - v2[1]
];
export const add = (v1, v2) => [
v1[0] + v2[0],
v1[1] + v2[1]
];
export const sign = (n) => (n ? (n < 0 ? -1 : 1) : 0);

@@ -4,0 +10,0 @@ export const rad = (deg) => (deg * Math.PI) / 180;

@@ -23,4 +23,3 @@ import preload from './preload';

subscription.unsubscribe();
if (options.resetOnCancel)
setSrc(options.src);
setSrc(options.src);
options.onDetach();

@@ -27,0 +26,0 @@ unload();

import { Observable } from '../observables/util/observable';
import { Angle, Vector } from './algebra';
import { Angle, Point } from './algebra';
export declare type Millis = number;

@@ -11,3 +11,3 @@ export declare type Time = Millis;

export declare type CreepyData = {
point?: Vector;
point?: Point;
angle?: Angle;

@@ -24,5 +24,4 @@ src: string;

looks: Array<Look>;
points: Observable<Vector>;
points: Observable<Point>;
timeToDefault: Time;
resetOnCancel: boolean;
throttle: Time;

@@ -37,5 +36,4 @@ onDebug: Debug;

looks?: Array<Look>;
points?: Observable<Vector> | string;
points?: Observable<Point> | string;
timeToDefault?: Time;
resetOnCancel?: boolean;
throttle?: Time;

@@ -42,0 +40,0 @@ onDebug?: Debug;

@@ -25,4 +25,3 @@ import noop from './noop';

throttle: getFloat(img.getAttribute('data-throttle')),
fieldOfVision: getFloat(img.getAttribute('data-fieldofvision')),
resetOnCancel: !(img.getAttribute('data-resetoncancel') === 'false')
fieldOfVision: getFloat(img.getAttribute('data-fieldofvision'))
});

@@ -47,3 +46,2 @@ const getPoints = (userOptions) => {

timeToDefault: userOptions.timeToDefault || 1000,
resetOnCancel: !(userOptions.resetOnCancel === false),
throttle: userOptions.throttle || 100,

@@ -50,0 +48,0 @@ onDebug: userOptions.onDebug || noop,

{
"name": "creepyface",
"version": "4.3.0-beta.0",
"version": "4.3.0",
"keywords": [

@@ -5,0 +5,0 @@ "face",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc