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 0.0.1 to 2.0.6

31

index.d.ts

@@ -17,2 +17,3 @@ declare const GLOBAL: any;

domRefs: any;
ignoreDomRefs?: any;
handler: (evt: MouseEvent) => void;

@@ -25,2 +26,30 @@ button?: number;

interface IDomRect {
id: string;
top: number;
left: number;
right: number;
width: number;
bottom: number;
height: number;
x?: number;
y?: number;
}
interface IScrollInfo {
scrollHeight: number;
scrollLeft: number;
scrollTop: number;
scrollWidth: number;
id: string;
}
interface IFields {
[key: string]: any;
}
declare function setInstanceMapping(instanceName: string, instance: any): void;
declare function getBoundingClientRect(selector: string | HTMLElement, instanceName?: string): Promise<IDomRect>;
declare function getBoundingClientRectSync(selector: string | HTMLElement): IDomRect;
declare function getScrollInfo(selector: string | HTMLElement, instanceName?: string): Promise<IScrollInfo>;
declare function getScrollInfoSync(selector: string | HTMLElement): IScrollInfo;
declare function getFields(selector: string | HTMLElement, instanceName?: string): Promise<IFields>;
declare class OutsideClick {

@@ -39,2 +68,2 @@ static instance: any;

export { GLOBAL as TUIGlobal, chooseImage, chooseVideo, getPlatform, outsideClick };
export { GLOBAL as TUIGlobal, chooseImage, chooseVideo, getBoundingClientRect, getBoundingClientRectSync, getFields, getPlatform, getScrollInfo, getScrollInfoSync, outsideClick, setInstanceMapping };

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,i="undefined"!=typeof uni,o=("undefined"!=typeof uni||"undefined"!=typeof window)&&!n,s=e?wx:i?uni:window,u=o&&window&&window.navigator&&window.navigator.userAgent||"",r=/Android/i.test(u),c=/(?:Windows Phone)/.test(u),a=/(?:SymbianOS)/.test(u),d=/iPad/i.test(u)||/iPhone/i.test(u)||/iPod/i.test(u),l=e,f=r||c||a||d,h=o&&!f,w=t&&!e;function y(){let e="";return h?e="pc":f?e="h5":l?e="wechat":w&&(e="app"),e}function p(t){const{count:n=1,sourceType:o=["album"],mediaType:u,dom:r}=t;return new Promise(((t,c)=>{i?e&&s.chooseMedia?s.chooseMedia({count:n,sourceType:o,mediaType:u,success:e=>{t({files:e})},error:e=>{c(e)}}):s.chooseVideo({count:n,sourceType:o,success:e=>{t({files:e})},error:e=>{c(e)}}):((null==r?void 0:r.click)&&r.click(),r.value="",null==r||r.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 b(e){return p(Object.assign({mediaType:["image"]},e))}function m(e){return p(Object.assign({mediaType:["video"]},e))}class v{constructor(){if(v.instance)return v.instance;v.instance=this,this.eventCallback=null,this.listener=null,this.button=0,this.init()}init(){o&&(this.eventCallback=e=>{-1===this.button&&(this.button=e.button),this.listener&&this.listener(e)},document.addEventListener("mousedown",this.eventCallback))}listen(e){if(o){const{domRefs:t,handler:n,button:i=0}=e;this.button=i,this.listener=e=>{const i=Array.isArray(t)?t:[t];for(const t of i)if(t&&t.contains(e.target)&&this.button===e.button)return;n(e),this.remove()}}}remove(){this.listener=null,this.button=-1}}console.log("UniversalAPI.VERSION:0.0.1");const g=new v;export{s as TUIGlobal,b as chooseImage,m as chooseVideo,y as getPlatform,g as outsideClick};
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};
{
"name": "@tencentcloud/universal-api",
"version": "0.0.1",
"version": "2.0.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