Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tencentcloud/universal-api

Package Overview
Dependencies
Maintainers
0
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tencentcloud/universal-api - npm Package Compare versions

Comparing version 2.2.4 to 2.2.6

2

index.js

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

const e="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),t="undefined"!=typeof uni&&"undefined"==typeof window,n=e||t,o="undefined"!=typeof uni,r=("undefined"!=typeof uni||"undefined"!=typeof window)&&!n,i=e?wx:o?uni:window,c=r&&window&&window.navigator&&window.navigator.userAgent||"",s=/Android/i.test(c),l=/(?:Windows Phone)/.test(c),u=/(?:SymbianOS)/.test(c),d=/iPad/i.test(c)||/iPhone/i.test(c)||/iPod/i.test(c),f=e,a=s||l||u||d,g=r&&!a,m=t&&!e;function w(){let e="";return g?e="pc":a?e="h5":f?e="wechat":m&&(e="app"),e}function h(t){const{count:n=1,sourceType:r=["album"],mediaType:c,dom:s}=t;return new Promise(((t,l)=>{o?e&&i.chooseMedia?i.chooseMedia({count:n,sourceType:r,mediaType:c,success:e=>{t({files:e})},error:e=>{l(e)}}):i.chooseVideo({count:n,sourceType:r,success:e=>{t({files:e})},error:e=>{l(e)}}):((null==s?void 0:s.click)&&s.click(),s.value="",null==s||s.addEventListener("change",(e=>{var n;(null===(n=e.target.files)||void 0===n?void 0:n.length)<=0||t({files:e.target.files[0]})}),!1))}))}function p(e){return h(Object.assign({mediaType:["image"]},e))}function y(e){return h(Object.assign({mediaType:["video"]},e))}const S=new Map;function v(e,t){S.set(e,t)}function E(e,t){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(o){if(!t)return Promise.reject(new Error("getBoundingClientRect need instanceName in params."));const n=uni.createSelectorQuery().in(S.get(t));return new Promise(((t,o)=>{n.select(e).boundingClientRect((e=>{e&&t(e)})).exec(),setTimeout((()=>o(new Error(`getBoundingClientRect ${e} timeout.`))),500)}))}return Promise.reject(new Error("getBoundingClientRect occur error"))}function b(e){if(o)throw new Error("getBoundingClientRectSync can not use in uni-app.");if(window||document){const t="object"==typeof e?e:document.querySelector(e);if(!t)throw new Error(`getBoundingClientRectSync can't find ${e} dom.`);const n=t.getBoundingClientRect();return{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}}throw new Error("getBoundingClientRectSync occur error.")}function P(e,t){if(!e)return Promise.reject(new Error(`getScrollInfo get error selector ${typeof e}.`));if(!o&&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(o){if(!t)return Promise.reject(new Error("getScrollInfo need instanceName in params."));const n=uni.createSelectorQuery().in(S.get(t));return new Promise(((t,o)=>{n.select(e).scrollOffset((e=>{e&&t(e)})).exec(),setTimeout((()=>o(new Error(`getScrollInfo ${e} timeout.`))),500)}))}return Promise.reject(new Error("getScrollInfo occur error"))}function T(e){if(o)throw new Error("getScrollInfoSync can not use in uni-app.");if(!o&&window){const t="object"==typeof e?e:document.querySelector(e);if(!t)throw new Error(`getScrollInfoSync can't find ${e} dom.`);return{id:t.id,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight}}throw new Error("getScrollInfoSync() occur error.")}function j(e,t){if(o){if(!t)return Promise.reject(new Error("getFields need instanceName in params."));const n=uni.createSelectorQuery().in(S.get(t));return new Promise(((t,o)=>{n.select(e).fields({rect:!0,size:!0,scrollOffset:!0},(e=>{e&&t(e)})).exec(),setTimeout((()=>o(new Error(`get ${e} fields timeout.`))),500)}))}return Promise.reject(new Error("getFields occur error"))}class L{constructor(){if(L.instance)return L.instance;L.instance=this,this.eventCallback=null,this.listener=null,this.button=0,this.init()}init(){r&&(this.eventCallback=e=>{this.listener&&this.listener(e)},document.addEventListener("mousedown",this.eventCallback))}listen(e){if(r){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 C(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 c;function s(){clearTimeout(c),u()}function l(){clearTimeout(c),u()}function u(){t.removeEventListener("pointerup",s),t.removeEventListener("pointermove",l)}t.addEventListener("pointerdown",(e=>{const o=e.target,u=(null==i?void 0:i.subSelector)?o.closest(i.subSelector)||void 0:o,d=e.currentTarget;c=setTimeout((()=>n(e,u,d)),r),t.addEventListener("pointerup",s),t.addEventListener("pointermove",l)}))}console.log("UniversalAPI.VERSION:2.2.4");const I=new L;export{i as TUIGlobal,C as addLongPressListener,p as chooseImage,y as chooseVideo,E as getBoundingClientRect,b as getBoundingClientRectSync,j as getFields,w as getPlatform,P as getScrollInfo,T as getScrollInfoSync,d as isIOS,I as outsideClick,v as setInstanceMapping};
const e="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),t="undefined"!=typeof uni&&"undefined"==typeof window,n=e||t,o="undefined"!=typeof uni,r=("undefined"!=typeof uni||"undefined"!=typeof window)&&!n,i=e?wx:o?uni:"undefined"!=typeof window?window:{},c=r&&window&&window.navigator&&window.navigator.userAgent||"",s=/Android/i.test(c),l=/(?:Windows Phone)/.test(c),u=/(?:SymbianOS)/.test(c),d=r&&("ontouchstart"in window||navigator.maxTouchPoints>0)&&function(){if(r)return!!/Tablet|Pad/i.test(c)||(window.matchMedia("(orientation: portrait)").matches?window.innerWidth>=768&&window.innerHeight>=1024:window.innerWidth>=1024&&window.innerHeight>=768);return!1}(),f=/iPhone/i.test(c)||/iPod/i.test(c),a=e,w=s||l||u||f||d,g=r&&!w,m=t&&!e;function h(){let e="";return g?e="pc":w?e="h5":a?e="wechat":m&&(e="app"),e}function p(t){const{count:n=1,sourceType:r=["album"],mediaType:c,dom:s}=t;return new Promise(((t,l)=>{o?e&&i.chooseMedia?i.chooseMedia({count:n,sourceType:r,mediaType:c,success:e=>{t({files:e})},error:e=>{l(e)}}):i.chooseVideo({count:n,sourceType:r,success:e=>{t({files:e})},error:e=>{l(e)}}):((null==s?void 0:s.click)&&s.click(),s.value="",null==s||s.addEventListener("change",(e=>{var n;(null===(n=e.target.files)||void 0===n?void 0:n.length)<=0||t({files:e.target.files[0]})}),!1))}))}function y(e){return p(Object.assign({mediaType:["image"]},e))}function S(e){return p(Object.assign({mediaType:["video"]},e))}const v=new Map;function E(e,t){v.set(e,t)}function b(e,t){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(o){if(!t)return Promise.reject(new Error("getBoundingClientRect need instanceName in params."));const n=uni.createSelectorQuery().in(v.get(t));return new Promise(((t,o)=>{n.select(e).boundingClientRect((e=>{e&&t(e)})).exec(),setTimeout((()=>o(new Error(`getBoundingClientRect ${e} timeout.`))),500)}))}return Promise.reject(new Error("getBoundingClientRect occur error"))}function P(e){if(o)throw new Error("getBoundingClientRectSync can not use in uni-app.");if(window||document){const t="object"==typeof e?e:document.querySelector(e);if(!t)throw new Error(`getBoundingClientRectSync can't find ${e} dom.`);const n=t.getBoundingClientRect();return{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}}throw new Error("getBoundingClientRectSync occur error.")}function T(e,t){if(!e)return Promise.reject(new Error(`getScrollInfo get error selector ${typeof e}.`));if(!o&&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(o){if(!t)return Promise.reject(new Error("getScrollInfo need instanceName in params."));const n=uni.createSelectorQuery().in(v.get(t));return new Promise(((t,o)=>{n.select(e).scrollOffset((e=>{e&&t(e)})).exec(),setTimeout((()=>o(new Error(`getScrollInfo ${e} timeout.`))),500)}))}return Promise.reject(new Error("getScrollInfo occur error"))}function j(e){if(o)throw new Error("getScrollInfoSync can not use in uni-app.");if(!o&&window){const t="object"==typeof e?e:document.querySelector(e);if(!t)throw new Error(`getScrollInfoSync can't find ${e} dom.`);return{id:t.id,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight}}throw new Error("getScrollInfoSync() occur error.")}function L(e,t){if(o){if(!t)return Promise.reject(new Error("getFields need instanceName in params."));const n=uni.createSelectorQuery().in(v.get(t));return new Promise(((t,o)=>{n.select(e).fields({rect:!0,size:!0,scrollOffset:!0},(e=>{e&&t(e)})).exec(),setTimeout((()=>o(new Error(`get ${e} fields timeout.`))),500)}))}return Promise.reject(new Error("getFields occur error"))}class C{constructor(){if(C.instance)return C.instance;C.instance=this,this.eventCallback=null,this.listener=null,this.button=0,this.init()}init(){r&&(this.eventCallback=e=>{this.listener&&this.listener(e)},document.addEventListener("mousedown",this.eventCallback))}listen(e){if(r){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 I(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 c;function s(){clearTimeout(c),u()}function l(){clearTimeout(c),u()}function u(){t.removeEventListener("pointerup",s),t.removeEventListener("pointermove",l)}t.addEventListener("pointerdown",(e=>{const o=e.target,u=(null==i?void 0:i.subSelector)?o.closest(i.subSelector)||void 0:o,d=e.currentTarget;c=setTimeout((()=>n(e,u,d)),r),t.addEventListener("pointerup",s),t.addEventListener("pointermove",l)}))}console.log("UniversalAPI.VERSION:2.2.6");const R=new C;export{i as TUIGlobal,I as addLongPressListener,y as chooseImage,S as chooseVideo,b as getBoundingClientRect,P as getBoundingClientRectSync,L as getFields,h as getPlatform,T as getScrollInfo,j as getScrollInfoSync,f as isIOS,R as outsideClick,E as setInstanceMapping};
{
"name": "@tencentcloud/universal-api",
"version": "2.2.4",
"version": "2.2.6",
"description": "Tencent Cloud Universal API SDK for TUIKit",

@@ -5,0 +5,0 @@ "main": "index.js",

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