react-intersection-observer-hook
Advanced tools
Comparing version 2.1.1 to 3.0.0-alpha.0
@@ -1,2 +0,27 @@ | ||
export { default as useIntersectionObserver, IntersectionObserverHookArgs, IntersectionObserverHookRefCallback, IntersectionObserverHookRefCallbackNode, IntersectionObserverHookResult, IntersectionObserverHookRootRefCallback, IntersectionObserverHookRootRefCallbackNode, } from './useIntersectionObserver'; | ||
export { default as useTrackVisibility, TrackVisibilityHookArgs, TrackVisibilityHookResult, } from './useTrackVisibility'; | ||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | ||
type IntersectionObserverHookArgs = Omit<IntersectionObserverInit, 'root'>; | ||
type IntersectionObserverHookRefCallbackNode = Element | null; | ||
type IntersectionObserverHookRefCallback = (node: IntersectionObserverHookRefCallbackNode) => void; | ||
type IntersectionObserverHookRootRefCallbackNode = IntersectionObserverInit['root']; | ||
type IntersectionObserverHookRootRefCallback = (node: IntersectionObserverHookRootRefCallbackNode) => void; | ||
type IntersectionObserverHookResult = [ | ||
IntersectionObserverHookRefCallback, | ||
{ | ||
entry: IntersectionObserverEntry | undefined; | ||
rootRef: IntersectionObserverHookRootRefCallback; | ||
} | ||
]; | ||
declare function useIntersectionObserver(args?: IntersectionObserverHookArgs): IntersectionObserverHookResult; | ||
type TrackVisibilityHookArgs = IntersectionObserverHookArgs; | ||
type TrackVisibilityHookResult = [ | ||
IntersectionObserverHookResult[0], | ||
IntersectionObserverHookResult[1] & { | ||
isVisible: boolean; | ||
wasEverVisible: boolean; | ||
} | ||
]; | ||
declare function useTrackVisibility(args?: IntersectionObserverHookArgs): TrackVisibilityHookResult; | ||
export { type IntersectionObserverHookArgs, type IntersectionObserverHookRefCallback, type IntersectionObserverHookRefCallbackNode, type IntersectionObserverHookResult, type IntersectionObserverHookRootRefCallback, type IntersectionObserverHookRootRefCallbackNode, type TrackVisibilityHookArgs, type TrackVisibilityHookResult, useIntersectionObserver, useTrackVisibility }; |
@@ -1,8 +0,1 @@ | ||
'use strict' | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./react-intersection-observer-hook.cjs.production.min.js') | ||
} else { | ||
module.exports = require('./react-intersection-observer-hook.cjs.development.js') | ||
} | ||
"use strict";var I=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var m=(r,e)=>{for(var t in e)I(r,t,{get:e[t],enumerable:!0})},h=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of H(e))!E.call(r,o)&&o!==t&&I(r,o,{get:()=>e[o],enumerable:!(s=d(e,o))||s.enumerable});return r};var g=r=>h(I({},"__esModule",{value:!0}),r);var M={};m(M,{useIntersectionObserver:()=>y,useTrackVisibility:()=>R});module.exports=g(M);var i=require("react");function p(){let r=new Map;function e({root:t,rootMargin:s,threshold:o}){let c=r.get(t);c||(c=new Map,r.set(t,c));let k=JSON.stringify({rootMargin:s,threshold:o}),b=c.get(k);if(!b){let n=new Map;b={observer:new IntersectionObserver(u=>{u.forEach(O=>{n.get(O.target)?.(O)})},{root:t,rootMargin:s,threshold:o}),entryCallbacks:n},c.set(k,b)}return{observe:(n,a)=>{b.entryCallbacks.set(n,a),b.observer.observe(n)},unobserve:n=>{b.entryCallbacks.delete(n),b.observer.unobserve(n)}}}return{getObserver:e}}var x="0px",V=[0],A=p();function T(r){let e=r?.rootMargin??x,t=r?.threshold??V,s=(0,i.useRef)(null),o=(0,i.useRef)(null),c=(0,i.useRef)(null),[k,b]=(0,i.useState)(),n=(0,i.useCallback)(()=>{let l=s.current;if(!l){b(void 0);return}let v=A.getObserver({root:o.current,rootMargin:e,threshold:t});v.observe(l,C=>{b(C)}),c.current=v},[e,t]),a=(0,i.useCallback)(()=>{let l=c.current,v=s.current;v&&l?.unobserve(v),c.current=null},[]),u=(0,i.useCallback)(l=>{a(),s.current=l,n()},[n,a]),O=(0,i.useCallback)(l=>{a(),o.current=l,n()},[n,a]);return[u,{entry:k,rootRef:O}]}var y=T;var f=require("react");function N(r){let[e,t]=y(r),s=!!t.entry?.isIntersecting,[o,c]=(0,f.useState)(s);return s&&!o&&c(!0),[e,{...t,isVisible:s,wasEverVisible:o}]}var R=N;0&&(module.exports={useIntersectionObserver,useTrackVisibility}); |
{ | ||
"name": "react-intersection-observer-hook", | ||
"version": "2.1.1", | ||
"license": "MIT", | ||
"author": "onderonur", | ||
"main": "dist/index.js", | ||
"module": "dist/react-intersection-observer-hook.esm.js", | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"version": "3.0.0-alpha.0", | ||
"description": "React hook to use IntersectionObserver declaratively.", | ||
"keywords": [ | ||
@@ -27,39 +20,44 @@ "react", | ||
}, | ||
"license": "MIT", | ||
"author": "onderonur", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/index.d.mts", | ||
"default": "./dist/index.mjs" | ||
}, | ||
"require": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
} | ||
} | ||
}, | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"test": "tsdx test --env=jsdom", | ||
"lint": "tsdx lint", | ||
"clean": "rimraf dist .rts2_cache_esm .rts2_cache_cjs example/.cache example/dist", | ||
"build": "tsup", | ||
"postbuild": "tsx ./scripts/postbuild.ts", | ||
"dev": "tsup --watch", | ||
"lint": "eslint src --max-warnings 0", | ||
"lint:fix": "eslint src --fix --max-warnings 0", | ||
"prepublishOnly": "npm run build", | ||
"prepare": "husky install" | ||
"typecheck": "tsc" | ||
}, | ||
"devDependencies": { | ||
"@repo/eslint-config": "*", | ||
"@repo/typescript-config": "*", | ||
"@types/node": "^20.12.5", | ||
"@types/react": "^18.2.74", | ||
"react": "^18.2.0", | ||
"tsup": "^8.0.2", | ||
"tsx": "^4.7.2", | ||
"typescript": "^5.4.4" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=16.8.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.22", | ||
"@types/react": "^17.0.3", | ||
"@types/react-dom": "^17.0.3", | ||
"@typescript-eslint/eslint-plugin": "^4.20.0", | ||
"@typescript-eslint/parser": "^4.20.0", | ||
"all-contributors-cli": "^6.20.0", | ||
"eslint": "^7.23.0", | ||
"eslint-config-airbnb": "^18.2.1", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-config-react-app": "^6.0.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-react": "^7.23.1", | ||
"eslint-plugin-react-hooks": "^4.2.0", | ||
"husky": "^6.0.0", | ||
"prettier": "^2.2.1", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"rimraf": "^3.0.2", | ||
"tsdx": "^0.14.1", | ||
"tslib": "^2.1.0", | ||
"typescript": "^4.2.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
8
0
13337
6
38
2
134
1