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

@mpxjs/api-proxy

Package Overview
Dependencies
Maintainers
11
Versions
168
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mpxjs/api-proxy - npm Package Compare versions

Comparing version 2.7.52 to 2.8.0-beta.0

src/mini/platform/wxToTt.js

4

package.json
{
"name": "@mpxjs/api-proxy",
"version": "2.7.52",
"version": "2.8.0-beta.0",
"description": "convert miniprogram API at each end",

@@ -42,3 +42,3 @@ "module": "src/index.js",

},
"gitHead": "187abad504151455e045c0adf2fe7f81412e0fef"
"gitHead": "bce2bb22d8990ad02879f45fc95c02ead43ba0e4"
}

@@ -6,2 +6,3 @@ class ToPromise {

}
toPromiseInitPromise () {

@@ -13,5 +14,7 @@ return new Promise((resolve, reject) => {

}
toPromiseResolve (res) {
this._resolve(res)
}
toPromiseReject (err) {

@@ -18,0 +21,0 @@ this._reject(err)

@@ -15,3 +15,8 @@ /**

*/
const hasOwnProperty = Object.prototype.hasOwnProperty
function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
function changeOpts (options, updateOrRemoveOpt = {}, extraOpt = {}) {

@@ -21,3 +26,3 @@ let opts = {}

Object.keys(options).forEach(key => {
let myKey = updateOrRemoveOpt.hasOwnProperty(key) ? updateOrRemoveOpt[key] : key
const myKey = hasOwn(updateOrRemoveOpt, key) ? updateOrRemoveOpt[key] : key
if (myKey !== '') {

@@ -36,2 +41,3 @@ opts[myKey] = options[key]

* @param {Function} getOptions 获取 success 回调修改后的参数
* @param {Object} thisObj this对象
*/

@@ -98,3 +104,3 @@ const handleSuccess = (opts, getOptions = noop, thisObj) => {

const inBrowser = typeof window !== 'undefined'
const isBrowser = typeof window !== 'undefined'

@@ -110,3 +116,4 @@ export {

makeMap,
inBrowser
isBrowser,
hasOwn
}

@@ -74,5 +74,5 @@ import transformApi from './mini/transform'

export function getProxy (options = {}) {
let apiProxy = {}
const apiProxy = {}
install(apiProxy, options)
return apiProxy
}

@@ -24,5 +24,5 @@ import * as allApi from './web/api'

export function getProxy () {
let apiProxy = {}
const apiProxy = {}
install(apiProxy)
return apiProxy
}

@@ -41,3 +41,3 @@ import { changeOpts, handleSuccess, getEnvObj, error, warn, noop } from '../../common/js'

let res = ALI_OBJ.getSystemInfoSync() || {}
const res = ALI_OBJ.getSystemInfoSync() || {}

@@ -58,3 +58,3 @@ res.system = `${res.platform} ${res.system}`

nextTick (fn) {
setTimeout(fn)
Promise.resolve().then(fn)
},

@@ -91,3 +91,3 @@

handleSuccess(opts, res => {
return changeOpts(res, undefined, { 'cancel': !res.confirm })
return changeOpts(res, undefined, { cancel: !res.confirm })
})

@@ -128,3 +128,3 @@

opts.success = function (res) {
let sucRes = changeOpts(res, {
const sucRes = changeOpts(res, {
index: 'tapIndex'

@@ -242,3 +242,3 @@ })

if (opts.current) {
let idx = options.urls.indexOf(opts.current)
const idx = options.urls.indexOf(opts.current)
opts.current = idx !== -1 ? idx : 0

@@ -336,3 +336,3 @@ }

res.fileList.forEach(file => {
let resFile = changeOpts(file, {
const resFile = changeOpts(file, {
apFilePath: 'filePath'

@@ -499,6 +499,6 @@ })

let opts = changeOpts(options)
const opts = changeOpts(options)
handleSuccess(opts, res => {
let userInfo = changeOpts(res, { avatar: 'avatarUrl' }, { gender: 0 })
const userInfo = changeOpts(res, { avatar: 'avatarUrl' }, { gender: 0 })
const params = ['country', 'province', 'city', 'language']

@@ -528,3 +528,3 @@

let opts = changeOpts(options, {
const opts = changeOpts(options, {
timeStamp: '',

@@ -567,3 +567,3 @@ nonceStr: '',

createCanvasContext (canvasId = {}) {
let ctx = ALI_OBJ.createCanvasContext(canvasId)
const ctx = ALI_OBJ.createCanvasContext(canvasId)

@@ -632,2 +632,3 @@ CANVAS_MAP[canvasId] = ctx

// todo 支付宝基础库升级至2.7.4以上可去除
createSelectorQuery (options = {}) {

@@ -649,3 +650,3 @@ const selectorQuery = ALI_OBJ.createSelectorQuery(options)

results.forEach((item, index) => {
cbs[index] && cbs[index](item)
cbs[index](item)
})

@@ -652,0 +653,0 @@ originalCb(results)

@@ -5,3 +5,3 @@ import { changeOpts, getEnvObj } from '../../common/js'

const getWxToQqApi = ({ optimize = false }) => {
const getWxToQqApi = () => {
return {

@@ -8,0 +8,0 @@ /**

import { error, getEnvObj, genFromMap, makeMap } from '../common/js'
import getWxToAliApi from './platform/wxToAli'
import getWxToQqApi from './platform/wxToQq'
import getWxToTtApi from './platform/wxToTt'

@@ -17,13 +18,15 @@ const fromMap = genFromMap()

const wxToAliApi = getWxToAliApi({ optimize: options.optimize })
const wxToQqApi = getWxToQqApi({ optimize: options.optimize })
const wxToQqApi = getWxToQqApi()
const wxToTtApi = getWxToTtApi()
const platformMap = {
'wx_ali': wxToAliApi,
'wx_qq': wxToQqApi
wx_ali: wxToAliApi,
wx_qq: wxToQqApi,
wx_tt: wxToTtApi
}
const needProxy = Object.create(null)
const excludeMap = makeMap(options.exclude)
const transedApi = platformMap[fromTo] || {}
Object.keys(envObj).concat(Object.keys(transedApi)).forEach((key) => {
const platformApi = platformMap[fromTo] || {}
Object.keys(envObj).concat(Object.keys(platformApi)).forEach((key) => {
if (!excludeMap[key]) {
needProxy[key] = envObj[key] || transedApi[key]
needProxy[key] = envObj[key] || platformApi[key]
}

@@ -30,0 +33,0 @@ })

// fork base64-js@1.3.1
var lookup = []
var revLookup = []
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
const lookup = []
const revLookup = []
const Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
for (var i = 0, len = code.length; i < len; ++i) {
const code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
for (let i = 0, len = code.length; i < len; ++i) {
lookup[i] = code[i]

@@ -18,3 +18,3 @@ revLookup[code.charCodeAt(i)] = i

function getLens (b64) {
var len = b64.length
const len = b64.length

@@ -27,6 +27,6 @@ if (len % 4 > 0) {

// See: https://github.com/beatgammit/base64-js/issues/42
var validLen = b64.indexOf('=')
let validLen = b64.indexOf('=')
if (validLen === -1) validLen = len
var placeHoldersLen = validLen === len
const placeHoldersLen = validLen === len
? 0

@@ -40,5 +40,5 @@ : 4 - (validLen % 4)

function byteLength (b64) {
var lens = getLens(b64)
var validLen = lens[0]
var placeHoldersLen = lens[1]
const lens = getLens(b64)
const validLen = lens[0]
const placeHoldersLen = lens[1]
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen

@@ -52,17 +52,17 @@ }

function toByteArray (b64) {
var tmp
var lens = getLens(b64)
var validLen = lens[0]
var placeHoldersLen = lens[1]
let tmp
const lens = getLens(b64)
const validLen = lens[0]
const placeHoldersLen = lens[1]
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
const arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
var curByte = 0
let curByte = 0
// if there are placeholders, only get up to the last complete 4 chars
var len = placeHoldersLen > 0
const len = placeHoldersLen > 0
? validLen - 4
: validLen
var i
let i
for (i = 0; i < len; i += 4) {

@@ -106,5 +106,5 @@ tmp =

function encodeChunk (uint8, start, end) {
var tmp
var output = []
for (var i = start; i < end; i += 3) {
let tmp
const output = []
for (let i = start; i < end; i += 3) {
tmp =

@@ -120,10 +120,10 @@ ((uint8[i] << 16) & 0xFF0000) +

function fromByteArray (uint8) {
var tmp
var len = uint8.length
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
var parts = []
var maxChunkLength = 16383 // must be multiple of 3
let tmp
const len = uint8.length
const extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
const parts = []
const maxChunkLength = 16383 // must be multiple of 3
// go through the array every three bytes, we'll deal with trailing stuff later
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
for (let i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
parts.push(encodeChunk(

@@ -130,0 +130,0 @@ uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)

@@ -50,2 +50,3 @@ class NodesRef {

}
// 获取Node节点实例

@@ -52,0 +53,0 @@ node (callback) {

@@ -170,2 +170,3 @@ import NodesRef from './NodesRef'

}
_isEl (selector) {

@@ -172,0 +173,0 @@ if (Array.isArray(selector)) return this._isEl(selector[0])

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

import { inBrowser } from '../../../../common/js/utils'
import { isBrowser } from '../../../../common/js/utils'
const fnMap = new Map()

@@ -6,3 +6,3 @@

if (inBrowser) {
if (isBrowser) {
window.addEventListener('offline', () => {

@@ -18,3 +18,3 @@ oldObserveList.forEach(fn => fn({ isConnected: false, type: 'none' }))

if (navigator.connection) {
let proxyCallback = evt => {
const proxyCallback = evt => {
const isConnected = navigator.onLine

@@ -21,0 +21,0 @@ callbackFn({

@@ -5,6 +5,7 @@ class EventChannel {

}
emit (eventName, ...args) {
const cbs = this.listener[eventName]
if (cbs) {
cbs.map((item, index) => {
cbs.forEach((item, index) => {
try {

@@ -21,2 +22,3 @@ item.fn.apply(this, args)

}
off (eventName, EventCallback) {

@@ -27,3 +29,3 @@ if (EventCallback) {

if (cbs) {
cbs.map((item, index) => {
cbs.forEach((item) => {
if (item.fn !== EventCallback) {

@@ -39,14 +41,18 @@ copyCbs.push(item)

}
on (eventName, EventCallback) {
(this.listener[eventName] || (this.listener[eventName] = [])).push({ fn: EventCallback, type: 'on' })
}
once (eventName, EventCallback) {
(this.listener[eventName] || (this.listener[eventName] = [])).push({ fn: EventCallback, type: 'once' })
}
_addListener (eventName, EventCallback, type) {
(this.listener[eventName] || (this.listener[eventName] = [])).push({ fn: EventCallback, type })
}
_addListeners (events) {
if (Object.prototype.toString.call(events) === '[object Object]') {
Object.keys(events).map((eventName) => {
Object.keys(events).forEach((eventName) => {
(this.listener[eventName] || (this.listener[eventName] = [])).push({ fn: events[eventName], type: 'on' })

@@ -53,0 +59,0 @@ })

@@ -5,3 +5,3 @@ import { ToPromise, webHandleSuccess } from '../../../common/js'

// 汉字为两个字符,字母/数字为一个字符
let _getLength = (t) => {
const _getLength = (t) => {
let len = 0

@@ -76,2 +76,3 @@ for (let i = 0; i < t.length; i++) {

}
show (options = {}) {

@@ -131,2 +132,3 @@ if (options.confirmText && _getLength(options.confirmText) > 8) {

}
hide () {

@@ -133,0 +135,0 @@ if (this.hideTimer) {

@@ -23,19 +23,19 @@ import { webHandleSuccess, webHandleFail } from '../../../common/js'

get CONNECTING () {
return this._socket['CONNECTING'] || 0
return this._socket.CONNECTING || 0
}
get OPEN () {
return this._socket['OPEN'] || 1
return this._socket.OPEN || 1
}
get CLOSING () {
return this._socket['CLOSING'] || 2
return this._socket.CLOSING || 2
}
get CLOSED () {
return this._socket['CLOSED'] || 3
return this._socket.CLOSED || 3
}
get readyState () {
return this._socket['readyState']
return this._socket.readyState
}

@@ -42,0 +42,0 @@

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

import { webHandleSuccess, webHandleFail } from '../../../common/js'
import { webHandleSuccess, webHandleFail, hasOwn } from '../../../common/js'

@@ -46,3 +46,3 @@ function setStorage (options = {}) {

function getStorageSync (key) {
let res = getItem(key)
const res = getItem(key)
if (res.result) return res.data

@@ -57,5 +57,6 @@

item = JSON.parse(window.localStorage.getItem(key))
} catch (e) {}
} catch (e) {
}
if (item && typeof item === 'object' && item.hasOwnProperty('data')) {
if (item && typeof item === 'object' && hasOwn(item, 'data')) {
return { result: true, data: item.data }

@@ -62,0 +63,0 @@ } else {

@@ -22,3 +22,3 @@ import { webHandleSuccess } from '../../../common/js'

for (let item of phones.entries()) {
for (const item of phones.entries()) {
if (item[1].test(ua)) {

@@ -25,0 +25,0 @@ brand = item[0]

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

import { webHandleSuccess, webHandleFail } from '../../../common/js'
import { webHandleSuccess, webHandleFail, hasOwn } from '../../../common/js'
import Vue from 'vue'

@@ -12,3 +12,3 @@

'color|selectedColor|backgroundColor|borderStyle'.split('|').forEach((key) => {
if (options.hasOwnProperty(key)) {
if (hasOwn(options, key)) {
Vue.set(tabBar, key, options[key])

@@ -41,3 +41,3 @@ }

'text|iconPath|selectedIconPath'.split('|').forEach((key) => {
if (options.hasOwnProperty(key)) {
if (hasOwn(options, key)) {
Vue.set(item, key, options[key])

@@ -44,0 +44,0 @@ }

@@ -6,3 +6,3 @@ import { webHandleSuccess } from '../../../common/js'

function createDom (tag, attrs = {}, children = []) {
let dom = document.createElement(tag)
const dom = document.createElement(tag)
Object.keys(attrs).forEach(k => dom.setAttribute(k, attrs[k]))

@@ -9,0 +9,0 @@ children.length && children.forEach(child => dom.appendChild(child))

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

import { inBrowser } from '../../../common/js/utils'
import { isBrowser } from '../../../common/js/utils'
const callbacks = []
if (inBrowser) {
if (isBrowser) {
window.addEventListener('resize', () => {

@@ -7,0 +7,0 @@ const result = {

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