aptechka 0.4.11 → 0.4.12

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.
@@ -1 +1 @@
1
- "use strict";var o=(s,t,r)=>{if(!t.has(s))throw TypeError("Cannot "+r)};var e=(s,t,r)=>(o(s,t,"read from private field"),r?r.call(s):t.get(s)),h=(s,t,r)=>{if(t.has(s))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(s):t.set(s,r)};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../dom-JBOkFLTh.cjs");var l,i;class c{constructor(){h(this,l,new Set);h(this,i,new WeakMap)}register(t){e(this,i).set(t,{axis:"y",value:0,element:t}),e(this,l).add(t)}unregister(t){e(this,i).delete(t),e(this,l).delete(t)}update(t,r,a){const n=e(this,i).get(t);n.axis=r,n.value=a}hasEntry(t){return e(this,i).has(t)}getEntry(t){return e(this,i).get(t)}getAll(t){const r=u.getAllParentElements(t).filter(n=>e(this,l).has(n)),a=[];return r.forEach(n=>{e(this,i).has(n)&&a.push(e(this,i).get(n))}),a}}l=new WeakMap,i=new WeakMap;const g=new c;exports.scrollEntries=g;
1
+ "use strict";var u=(s,t,i)=>{if(!t.has(s))throw TypeError("Cannot "+i)};var e=(s,t,i)=>(u(s,t,"read from private field"),i?i.call(s):t.get(s)),a=(s,t,i)=>{if(t.has(s))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(s):t.set(s,i)};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../notifier/index.cjs"),g=require("../dom-JBOkFLTh.cjs");var o,r,h;class f{constructor(){a(this,o,new Set);a(this,r,new WeakMap);a(this,h,new c.Notifier)}get notifier(){return e(this,h)}register(t){e(this,r).set(t,{axis:"y",value:0,element:t}),e(this,o).add(t),e(this,h).notify()}unregister(t){e(this,r).delete(t),e(this,o).delete(t),e(this,h).notify()}update(t,i,l){const n=e(this,r).get(t);n.axis=i,n.value=l}hasEntry(t){return e(this,r).has(t)}getEntry(t){return e(this,r).get(t)}getAll(t){const i=g.getAllParentElements(t).filter(n=>e(this,o).has(n)),l=[];return i.forEach(n=>{e(this,r).has(n)&&l.push(e(this,r).get(n))}),l}}o=new WeakMap,r=new WeakMap,h=new WeakMap;const d=new f;exports.scrollEntries=d;
@@ -1,12 +1,15 @@
1
1
  import { Axes2D } from '../utils';
2
+ import { Notifier } from '../notifier';
2
3
 
3
4
  export interface ScrollEntry {
4
5
  axis: Axes2D;
5
6
  value: number;
6
7
  element: HTMLElement;
7
8
  }
9
+ export type ScrollEntriesRegisterCallback = () => void;
8
10
  declare class ScrollEntries {
9
11
  #private;
12
+ get notifier(): Notifier<ScrollEntriesRegisterCallback>;
10
13
  register(element: HTMLElement): void;
11
14
  unregister(element: HTMLElement): void;
12
15
  update(element: HTMLElement, axis: Axes2D, value: number): void;
@@ -1,32 +1,37 @@
1
- var o = (s, t, r) => {
1
+ var f = (s, t, r) => {
2
2
  if (!t.has(s))
3
3
  throw TypeError("Cannot " + r);
4
4
  };
5
- var e = (s, t, r) => (o(s, t, "read from private field"), r ? r.call(s) : t.get(s)), l = (s, t, r) => {
5
+ var e = (s, t, r) => (f(s, t, "read from private field"), r ? r.call(s) : t.get(s)), l = (s, t, r) => {
6
6
  if (t.has(s))
7
7
  throw TypeError("Cannot add the same private member more than once");
8
8
  t instanceof WeakSet ? t.add(s) : t.set(s, r);
9
9
  };
10
- import { a as u } from "../dom-0S_WDL4g.js";
11
- var a, i;
10
+ import { Notifier as u } from "../notifier/index.js";
11
+ import { a as g } from "../dom-0S_WDL4g.js";
12
+ var h, i, a;
12
13
  class c {
13
14
  constructor() {
14
- l(this, a, /* @__PURE__ */ new Set());
15
+ l(this, h, /* @__PURE__ */ new Set());
15
16
  l(this, i, /* @__PURE__ */ new WeakMap());
17
+ l(this, a, new u());
18
+ }
19
+ get notifier() {
20
+ return e(this, a);
16
21
  }
17
22
  register(t) {
18
23
  e(this, i).set(t, {
19
24
  axis: "y",
20
25
  value: 0,
21
26
  element: t
22
- }), e(this, a).add(t);
27
+ }), e(this, h).add(t), e(this, a).notify();
23
28
  }
24
29
  unregister(t) {
25
- e(this, i).delete(t), e(this, a).delete(t);
30
+ e(this, i).delete(t), e(this, h).delete(t), e(this, a).notify();
26
31
  }
27
- update(t, r, h) {
32
+ update(t, r, o) {
28
33
  const n = e(this, i).get(t);
29
- n.axis = r, n.value = h;
34
+ n.axis = r, n.value = o;
30
35
  }
31
36
  hasEntry(t) {
32
37
  return e(this, i).has(t);
@@ -35,13 +40,13 @@ class c {
35
40
  return e(this, i).get(t);
36
41
  }
37
42
  getAll(t) {
38
- const r = u(t).filter((n) => e(this, a).has(n)), h = [];
43
+ const r = g(t).filter((n) => e(this, h).has(n)), o = [];
39
44
  return r.forEach((n) => {
40
- e(this, i).has(n) && h.push(e(this, i).get(n));
41
- }), h;
45
+ e(this, i).has(n) && o.push(e(this, i).get(n));
46
+ }), o;
42
47
  }
43
48
  }
44
- a = new WeakMap(), i = new WeakMap();
49
+ h = new WeakMap(), i = new WeakMap(), a = new WeakMap();
45
50
  const d = new c();
46
51
  export {
47
52
  d as scrollEntries
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"
@@ -1 +0,0 @@
1
- "use strict";var P=(h,n,e)=>{if(!n.has(h))throw TypeError("Cannot "+e)};var t=(h,n,e)=>(P(h,n,"read from private field"),e?e.call(h):n.get(h)),r=(h,n,e)=>{if(n.has(h))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(h):n.set(h,e)},i=(h,n,e,a)=>(P(h,n,"write to private field"),a?a.call(h,e):n.set(h,e),e);const f=require("./browser-CpzFX2xg.cjs"),A=require("./dom-JBOkFLTh.cjs"),T=require("./gestures-DHLrn6Q8.cjs"),W=require("./number-yVpzMdbQ.cjs"),X=require("./notifier/index.cjs"),B=require("./ticker/index.cjs"),Y=require("./order/index.cjs");var q;class v{constructor(){r(this,q,new X.Notifier)}get changeEvent(){return t(this,q)}}q=new WeakMap;var u,l,c,L;class K extends v{constructor(e){super();r(this,u,null);r(this,l,null);r(this,c,"offsetHeight");r(this,L,e=>{const a=e.shiftKey?-1:1;let s;e.code==="Space"?s=a*t(this,l)[t(this,c)]*.4:e.code==="ArrowLeft"?s=-1*t(this,l)[t(this,c)]*.2:e.code==="ArrowRight"?s=1*t(this,l)[t(this,c)]*.2:e.code==="ArrowUp"?s=-1*t(this,l)[t(this,c)]*.2:e.code==="ArrowDown"?s=1*t(this,l)[t(this,c)]*.2:e.code==="PageUp"?s=-1*t(this,l)[t(this,c)]:e.code==="PageDown"?s=1*t(this,l)[t(this,c)]:e.code==="Home"?s=0:e.code==="End"&&(s=t(this,c)==="offsetWidth"?t(this,l).scrollWidth:t(this,l).scrollHeight),s&&(e.stopPropagation(),this.changeEvent.notify("keyboard",s))});f.isBrowser&&(i(this,u,e!=null&&e.element&&A.getElement(e.element)||window),i(this,l,t(this,u)instanceof HTMLElement?t(this,u):document.documentElement),this.dimension=e==null?void 0:e.dimension)}set dimension(e){i(this,c,e==="width"?"offsetWidth":"offsetHeight")}connect(){f.isBrowser&&t(this,u).addEventListener("keydown",t(this,L))}disconnect(){f.isBrowser&&t(this,u).removeEventListener("keydown",t(this,L))}}u=new WeakMap,l=new WeakMap,c=new WeakMap,L=new WeakMap;var g,o,E,M;class R extends v{constructor(e){super();r(this,g,null);r(this,o,void 0);r(this,E,void 0);r(this,M,e=>{let a=0;if(!(this.axis==="x"&&Math.abs(e.deltaY)>Math.abs(e.deltaX)||this.axis==="y"&&Math.abs(e.deltaX)>Math.abs(e.deltaY)))if(a=(this.axis==="max"?Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.deltaY:this.axis==="x"?e.deltaX:e.deltaY)*this.speed,e.stopPropagation(),e.preventDefault(),this.debounce){const s=Date.now();if(s-t(this,E)>40&&(a=100*Math.sign(a)),i(this,E,s),Math.abs(a)<100||t(this,o))return;this.changeEvent.notify("wheel",a),i(this,o,setTimeout(()=>{i(this,o,void 0)},80))}else this.changeEvent.notify("wheel",a)});this.axis=(e==null?void 0:e.axis)||"y",this.speed=(e==null?void 0:e.speed)||1,this.debounce=(e==null?void 0:e.debounce)||!1,i(this,E,Date.now()),f.isBrowser&&i(this,g,e!=null&&e.element&&A.getElement(e.element)||window)}connect(){f.isBrowser&&t(this,g).addEventListener("wheel",t(this,M),{passive:!1})}disconnect(){f.isBrowser&&(t(this,g).removeEventListener("wheel",t(this,M)),clearTimeout(t(this,o)))}}g=new WeakMap,o=new WeakMap,E=new WeakMap,M=new WeakMap;var b,w,y,d,k,x;const m=class m extends v{constructor(e){super();r(this,w,null);r(this,y,!1);r(this,d,0);r(this,k,e=>{if(e.composedPath().find(s=>s instanceof HTMLElement&&s.hasAttribute("drag-dead-zone")))return;this.swipe||B.ticker.unsubscribe(t(this,x));let a=e;i(this,d,0),T.setupDrag(s=>{if(t(this,y)||t(m,b)&&t(m,b)!==t(this,w))return;this.swipe&&i(this,y,!0);const C=a.x-s.x,D=a.y-s.y;this.axis==="x"?i(this,d,C):i(this,d,D),a=s,this.changeEvent.notify("drag",t(this,d)),(this.axis==="x"&&Math.abs(C)>Math.abs(D)||this.axis==="y"&&Math.abs(C)<Math.abs(D))&&i(m,b,t(this,w))},()=>{i(m,b,null),this.swipe||(i(this,d,t(this,d)*3),B.ticker.subscribe(t(this,x),{order:Y.TICK_ORDER.SCROLL-1})),i(this,y,!1)})});r(this,x,()=>{t(this,d)||B.ticker.unsubscribe(t(this,x)),i(this,d,t(this,d)*.95),i(this,d,W.preciseNumber(t(this,d),3)),this.changeEvent.notify("drag",t(this,d))});this.axis=(e==null?void 0:e.axis)||"y",this.swipe=(e==null?void 0:e.swipe)||!1,f.isBrowser&&i(this,w,e!=null&&e.element&&A.getElement(e.element)||document.documentElement)}connect(){f.isBrowser&&t(this,w).addEventListener("pointerdown",t(this,k))}disconnect(){f.isBrowser&&(t(this,w).removeEventListener("pointerdown",t(this,k)),B.ticker.unsubscribe(t(this,x)))}};b=new WeakMap,w=new WeakMap,y=new WeakMap,d=new WeakMap,k=new WeakMap,x=new WeakMap,r(m,b,null);let H=m;exports.Controls=v;exports.DragControls=H;exports.KeyboardControls=K;exports.WheelControls=R;