@bigmistqke/minni 0.0.7 → 0.0.9

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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var m=(t,c)=>new Promise(i=>{if("touches"in t){let n={x:t.touches[0].clientX,y:t.touches[0].clientY},o=e=>({x:e.touches[0].clientX-n.x,y:n.y-e.touches[0].clientY}),s=e=>_optionalChain([c, 'optionalCall', _ => _(o(e),e)]),u=e=>{window.removeEventListener("touchmove",s),window.removeEventListener("touchend",u),i(o(e))};window.addEventListener("touchmove",s),window.addEventListener("touchend",u)}else{let n={x:t.clientX,y:t.clientY},o=e=>({x:e.clientX-n.x,y:n.y-e.clientY}),s=e=>_optionalChain([c, 'optionalCall', _2 => _2(o(e),e)]),u=e=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",u),i(o(e))};window.addEventListener("mousemove",s),window.addEventListener("mouseup",u)}});exports.minni = m;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var e=t=>t instanceof TouchEvent,l=t=>t instanceof PointerEvent,m= exports.minni =(t,o)=>new Promise(E=>{let s=e(t)?{x:t.touches[0].clientX,y:t.touches[0].clientY}:{x:t.clientX,y:t.clientY},[v,a]=e(t)?["touchmove","touchend"]:l(t)?["pointermove","pointerup"]:["mousemove","mouseup"],y=n=>e(n)?{x:n.touches[0].clientX,y:n.touches[0].clientY}:{x:n.clientX,y:n.clientY},i=n=>{let u=y(n);return{x:u.x-s.x,y:s.y-u.y}},c=new AbortController,{signal:r}=c;o&&window.addEventListener(v,n=>{o(i(n),n)},{signal:r}),window.addEventListener(a,n=>{c.abort(),E(i(n))},{signal:r})});exports.minni = m;
package/dist/index.d.ts CHANGED
@@ -1,14 +1,7 @@
1
- type CustomMouseEvent = {
2
- clientX: number;
3
- clientY: number;
4
- };
5
- type CustomTouchEvent = {
6
- touches: TouchList;
7
- };
8
- declare const minni: <TEvent extends CustomMouseEvent | CustomTouchEvent>(event: TEvent, callback?: ((delta: {
1
+ declare const minni: <TEvent extends TouchEvent | PointerEvent | MouseEvent>(event: TEvent, callback?: ((delta: {
9
2
  x: number;
10
3
  y: number;
11
- }, event: TEvent extends CustomTouchEvent ? TouchEvent : MouseEvent) => void) | undefined) => Promise<{
4
+ }, event: TEvent) => void) | undefined) => Promise<{
12
5
  x: number;
13
6
  y: number;
14
7
  }>;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var m=(t,c)=>new Promise(i=>{if("touches"in t){let n={x:t.touches[0].clientX,y:t.touches[0].clientY},o=e=>({x:e.touches[0].clientX-n.x,y:n.y-e.touches[0].clientY}),s=e=>c?.(o(e),e),u=e=>{window.removeEventListener("touchmove",s),window.removeEventListener("touchend",u),i(o(e))};window.addEventListener("touchmove",s),window.addEventListener("touchend",u)}else{let n={x:t.clientX,y:t.clientY},o=e=>({x:e.clientX-n.x,y:n.y-e.clientY}),s=e=>c?.(o(e),e),u=e=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",u),i(o(e))};window.addEventListener("mousemove",s),window.addEventListener("mouseup",u)}});export{m as minni};
1
+ var e=t=>t instanceof TouchEvent,l=t=>t instanceof PointerEvent,m=(t,o)=>new Promise(E=>{let s=e(t)?{x:t.touches[0].clientX,y:t.touches[0].clientY}:{x:t.clientX,y:t.clientY},[v,a]=e(t)?["touchmove","touchend"]:l(t)?["pointermove","pointerup"]:["mousemove","mouseup"],y=n=>e(n)?{x:n.touches[0].clientX,y:n.touches[0].clientY}:{x:n.clientX,y:n.clientY},i=n=>{let u=y(n);return{x:u.x-s.x,y:s.y-u.y}},c=new AbortController,{signal:r}=c;o&&window.addEventListener(v,n=>{o(i(n),n)},{signal:r}),window.addEventListener(a,n=>{c.abort(),E(i(n))},{signal:r})});export{m as minni};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigmistqke/minni",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "minimal drag utility",
5
5
  "author": "bigmistqke",
6
6
  "license": "MIT",
@@ -17,6 +17,7 @@
17
17
  "types": "dist/index.d.ts",
18
18
  "type": "module",
19
19
  "dependencies": {
20
+ "bumpp": "^10.4.1",
20
21
  "typescript": "^4.7.2"
21
22
  },
22
23
  "files": [
@@ -28,12 +29,14 @@
28
29
  },
29
30
  "keywords": [],
30
31
  "scripts": {
31
- "ts-types": "tsc",
32
+ "bump": "bumpp",
33
+ "types": "tsc --no-emit",
32
34
  "build:dev": "rimraf lib && tsup --watch",
33
35
  "build:prod": "rimraf dist && env NODE_ENV=production tsup",
34
36
  "build:watch": "tsup --watch",
35
37
  "lint:fix": "eslint ./src --ext .ts,.tsx --quiet --fix --ignore-path ./.gitignore",
36
38
  "lint:format": "prettier --loglevel warn --write \"./**/*.{ts,tsx,css,md,json}\" ",
37
- "lint": "yarn lint:format && yarn lint:fix "
39
+ "lint": "yarn lint:format && yarn lint:fix",
40
+ "prepublish": "pnpm build:prod"
38
41
  }
39
42
  }