jiuyiUniapp/jiuyi/unpackage/dist/build/web/assets/index.DzsMB11z.js

2 lines
3.6 KiB
JavaScript

import{j as e,D as t}from"./index-CH9-aFWw.js";const n="undefined"!=typeof wx&&"function"==typeof e&&Boolean(e().fontSizeSetting),o="undefined"!=typeof uni&&"undefined"==typeof window,r="undefined"!=typeof uni,i=("undefined"!=typeof uni||"undefined"!=typeof window)&&!(n||o),s=n?wx:r?uni:"undefined"!=typeof window?window:{},c=i&&window&&window.navigator&&window.navigator.userAgent||"",l=/Android/i.test(c),d=/(?:Windows Phone)/.test(c),u=/(?:SymbianOS)/.test(c),a=i&&("ontouchstart"in window||navigator.maxTouchPoints>0)&&!!i&&(!!/Tablet|Pad/i.test(c)||(window.matchMedia("(orientation: portrait)").matches?window.innerWidth>=768&&window.innerHeight>=1024:window.innerWidth>=1024&&window.innerHeight>=768)),f=/iPhone/i.test(c)||/iPod/i.test(c),w=n,m=l||d||u||f||a,g=i&&!m,h=o&&!n;function p(){let e="";return g?e="pc":m?e="h5":w?e="wechat":h&&(e="app"),e}const v=new Map;function y(e,t){v.set(e,t)}function P(e,n){if(!e)return Promise.reject(new Error(`getBoundingClientRect get error selector ${typeof e}.`));if(window||document){const t="object"==typeof e?e:document.querySelector(e);if(!t)return Promise.reject(new Error(`getBoundingClientRect can't find ${e} dom.`));const n=t.getBoundingClientRect();return Promise.resolve({id:t.id,top:n.top,left:n.left,right:n.right,bottom:n.bottom,width:n.width,height:n.height,x:n.x,y:n.y})}if(r){if(!n)return Promise.reject(new Error("getBoundingClientRect need instanceName in params."));const o=t().in(v.get(n));return new Promise(((t,n)=>{o.select(e).boundingClientRect((e=>{e&&t(e)})).exec(),setTimeout((()=>n(new Error(`getBoundingClientRect ${e} timeout.`))),500)}))}return Promise.reject(new Error("getBoundingClientRect occur error"))}function E(e,n){if(!e)return Promise.reject(new Error(`getScrollInfo get error selector ${typeof e}.`));if(!r&&window){const t="object"==typeof e?e:document.querySelector(e);return t?Promise.resolve({id:t.id,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight}):Promise.reject(new Error(`getScrollInfo can't find ${e} dom.`))}if(r){if(!n)return Promise.reject(new Error("getScrollInfo need instanceName in params."));const o=t().in(v.get(n));return new Promise(((t,n)=>{o.select(e).scrollOffset((e=>{e&&t(e)})).exec(),setTimeout((()=>n(new Error(`getScrollInfo ${e} timeout.`))),500)}))}return Promise.reject(new Error("getScrollInfo occur error"))}class b{constructor(){if(b.instance)return b.instance;b.instance=this,this.eventCallback=null,this.listener=null,this.button=0,this.init()}init(){i&&(this.eventCallback=e=>{this.listener&&this.listener(e)},document.addEventListener("mousedown",this.eventCallback))}listen(e){if(i){const{domRefs:t,ignoreDomRefs:n,handler:o,button:r=0}=e;this.button=r,this.listener=e=>{const r=Array.isArray(n)?n:[n];for(const t of r)if(t&&t.contains(e.target))return;const i=Array.isArray(t)?t:[t];for(const t of i)if(t&&t.contains(e.target)&&this.button===e.button)return;o(e),this.remove()}}}remove(){this.listener=null,this.button=-1}}function S(e){const{element:t,onLongPress:n,options:o={}}=e;if(!t||!n)throw new Error("addLongPressEventListener missing arguments");const{duration:r=800,eventDelegation:i}=o;let s;function c(){clearTimeout(s),d()}function l(){clearTimeout(s),d()}function d(){t.removeEventListener("pointerup",c),t.removeEventListener("pointermove",l)}t.addEventListener("pointerdown",(e=>{const o=e.target,d=(null==i?void 0:i.subSelector)?o.closest(i.subSelector)||void 0:o,u=e.currentTarget;s=setTimeout((()=>n(e,d,u)),r),t.addEventListener("pointerup",c),t.addEventListener("pointermove",l)}))}console.log("UniversalAPI.VERSION:2.2.9");const j=new b;export{y as E,S as I,j as R,E as T,P as b,f,p as h,s as i};