Socket
Socket
Sign inDemoInstall

@tencentcloud/universal-api

Package Overview
Dependencies
Maintainers
9
Versions
18
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.0.6 to 2.0.7

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,r="undefined"!=typeof uni,o=("undefined"!=typeof uni||"undefined"!=typeof window)&&!n,i=e?wx:r?uni:window,c=o&&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=o&&!a,w=t&&!e;function m(){let e="";return g?e="pc":a?e="h5":f?e="wechat":w&&(e="app"),e}function h(t){const{count:n=1,sourceType:o=["album"],mediaType:c,dom:s}=t;return new Promise(((t,l)=>{r?e&&i.chooseMedia?i.chooseMedia({count:n,sourceType:o,mediaType:c,success:e=>{t({files:e})},error:e=>{l(e)}}):i.chooseVideo({count:n,sourceType:o,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 h(Object.assign({mediaType:["image"]},e))}function p(e){return h(Object.assign({mediaType:["video"]},e))}const S=new Map;function b(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(r){if(!t)return Promise.reject(new Error("getBoundingClientRect need instanceName in params."));const n=uni.createSelectorQuery().in(S.get(t));return new Promise(((t,r)=>{n.select(e).boundingClientRect((e=>{e&&t(e)})).exec(),setTimeout((()=>r(new Error(`getBoundingClientRect ${e} timeout.`))),500)}))}return Promise.reject(new Error("getBoundingClientRect occur error"))}function P(e){if(r)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 v(e,t){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(!t)return Promise.reject(new Error("getScrollInfo need instanceName in params."));const n=uni.createSelectorQuery().in(S.get(t));return new Promise(((t,r)=>{n.select(e).scrollOffset((e=>{e&&t(e)})).exec(),setTimeout((()=>r(new Error(`getScrollInfo ${e} timeout.`))),500)}))}return Promise.reject(new Error("getScrollInfo occur error"))}function j(e){if(r)throw new Error("getScrollInfoSync can not use in uni-app.");if(!r&&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 T(e,t){if(r){if(!t)return Promise.reject(new Error("getFields need instanceName in params."));const n=uni.createSelectorQuery().in(S.get(t));return new Promise(((t,r)=>{n.select(e).fields({rect:!0,size:!0,scrollOffset:!0},(e=>{e&&t(e)})).exec(),setTimeout((()=>r(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(){o&&(this.eventCallback=e=>{this.listener&&this.listener(e)},document.addEventListener("mousedown",this.eventCallback))}listen(e){if(o){const{domRefs:t,ignoreDomRefs:n,handler:r,button:o=0}=e;this.button=o,this.listener=e=>{const o=Array.isArray(n)?n:[n];for(const t of o)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;r(e),this.remove()}}}remove(){this.listener=null,this.button=-1}}console.log("UniversalAPI.VERSION:2.0.6");const R=new C;export{i as TUIGlobal,y as chooseImage,p as chooseVideo,E as getBoundingClientRect,P as getBoundingClientRectSync,T as getFields,m as getPlatform,v as getScrollInfo,j as getScrollInfoSync,R as outsideClick,b 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,r="undefined"!=typeof uni,o=("undefined"!=typeof uni||"undefined"!=typeof window)&&!n,i=e?wx:r?uni:window,c=o&&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=o&&!a,w=t&&!e;function m(){let e="";return g?e="pc":a?e="h5":f?e="wechat":w&&(e="app"),e}function h(t){const{count:n=1,sourceType:o=["album"],mediaType:c,dom:s}=t;return new Promise(((t,l)=>{r?e&&i.chooseMedia?i.chooseMedia({count:n,sourceType:o,mediaType:c,success:e=>{t({files:e})},error:e=>{l(e)}}):i.chooseVideo({count:n,sourceType:o,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 h(Object.assign({mediaType:["image"]},e))}function p(e){return h(Object.assign({mediaType:["video"]},e))}const S=new Map;function b(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(r){if(!t)return Promise.reject(new Error("getBoundingClientRect need instanceName in params."));const n=uni.createSelectorQuery().in(S.get(t));return new Promise(((t,r)=>{n.select(e).boundingClientRect((e=>{e&&t(e)})).exec(),setTimeout((()=>r(new Error(`getBoundingClientRect ${e} timeout.`))),500)}))}return Promise.reject(new Error("getBoundingClientRect occur error"))}function P(e){if(r)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 v(e,t){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(!t)return Promise.reject(new Error("getScrollInfo need instanceName in params."));const n=uni.createSelectorQuery().in(S.get(t));return new Promise(((t,r)=>{n.select(e).scrollOffset((e=>{e&&t(e)})).exec(),setTimeout((()=>r(new Error(`getScrollInfo ${e} timeout.`))),500)}))}return Promise.reject(new Error("getScrollInfo occur error"))}function j(e){if(r)throw new Error("getScrollInfoSync can not use in uni-app.");if(!r&&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 T(e,t){if(r){if(!t)return Promise.reject(new Error("getFields need instanceName in params."));const n=uni.createSelectorQuery().in(S.get(t));return new Promise(((t,r)=>{n.select(e).fields({rect:!0,size:!0,scrollOffset:!0},(e=>{e&&t(e)})).exec(),setTimeout((()=>r(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(){o&&(this.eventCallback=e=>{this.listener&&this.listener(e)},document.addEventListener("mousedown",this.eventCallback))}listen(e){if(o){const{domRefs:t,ignoreDomRefs:n,handler:r,button:o=0}=e;this.button=o,this.listener=e=>{const o=Array.isArray(n)?n:[n];for(const t of o)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;r(e),this.remove()}}}remove(){this.listener=null,this.button=-1}}console.log("UniversalAPI.VERSION:2.0.7");const R=new C;export{i as TUIGlobal,y as chooseImage,p as chooseVideo,E as getBoundingClientRect,P as getBoundingClientRectSync,T as getFields,m as getPlatform,v as getScrollInfo,j as getScrollInfoSync,R as outsideClick,b as setInstanceMapping};
{
"name": "@tencentcloud/universal-api",
"version": "2.0.6",
"version": "2.0.7",
"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