From 6aaf8783caa2c6c3360d9fa0928399711a6f89d9 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Sat, 19 Sep 2020 16:43:43 +0800 Subject: [PATCH] feat(mp): remove @dcloudio/uni-shared --- packages/uni-api/src/helpers/api.ts | 7 +++++-- packages/uni-h5/dist/uni-h5.esm.js | 5 ++--- packages/uni-mp-alipay/dist/uni.api.esm.js | 5 ++--- packages/uni-mp-alipay/dist/uni.mp.esm.js | 21 ++++++++++++++++++- packages/uni-mp-baidu/dist/uni.api.esm.js | 5 ++--- packages/uni-mp-baidu/dist/uni.mp.esm.js | 21 ++++++++++++++++++- packages/uni-mp-qq/dist/uni.api.esm.js | 5 ++--- packages/uni-mp-qq/dist/uni.mp.esm.js | 21 ++++++++++++++++++- packages/uni-mp-toutiao/dist/uni.api.esm.js | 5 ++--- packages/uni-mp-toutiao/dist/uni.mp.esm.js | 21 ++++++++++++++++++- packages/uni-mp-weixin/dist/uni.api.esm.js | 5 ++--- packages/uni-mp-weixin/dist/uni.mp.esm.js | 21 ++++++++++++++++++- .../uni-quickapp-webview/dist/uni.api.esm.js | 5 ++--- .../uni-quickapp-webview/dist/uni.mp.esm.js | 21 ++++++++++++++++++- rollup.config.js | 1 - 15 files changed, 139 insertions(+), 30 deletions(-) diff --git a/packages/uni-api/src/helpers/api.ts b/packages/uni-api/src/helpers/api.ts index 507e4e0a8..e4534f7ac 100644 --- a/packages/uni-api/src/helpers/api.ts +++ b/packages/uni-api/src/helpers/api.ts @@ -19,8 +19,11 @@ type API_TYPES = | typeof API_TYPE_ASYNC | typeof API_TYPE_RETURN -function validateProtocol(name: string, args: any[], protocol: ApiProtocols) { - console.log(name, args, protocol) +function validateProtocol( + _name: string, + _args: any[], + _protocol: ApiProtocols +) { return true } diff --git a/packages/uni-h5/dist/uni-h5.esm.js b/packages/uni-h5/dist/uni-h5.esm.js index 2dacd616c..506610fb4 100644 --- a/packages/uni-h5/dist/uni-h5.esm.js +++ b/packages/uni-h5/dist/uni-h5.esm.js @@ -1250,8 +1250,7 @@ var decode = function(base64) { const API_TYPE_SYNC = 1; const API_TYPE_ASYNC = 2; const API_TYPE_RETURN = 3; -function validateProtocol(name, args, protocol) { - console.log(name, args, protocol); +function validateProtocol(_name, _args, _protocol) { return true; } function formatApiArgs(args, options) { @@ -1262,7 +1261,7 @@ function formatApiArgs(args, options) { function createApi({type: type2, name, options}, fn, protocol) { return function(...args) { if (type2 === API_TYPE_SYNC) { - if (!(process.env.NODE_ENV !== "production" && protocol && !validateProtocol(name, args, protocol))) { + if (!(process.env.NODE_ENV !== "production" && protocol && !validateProtocol())) { return fn.apply(null, formatApiArgs(args, options)); } } diff --git a/packages/uni-mp-alipay/dist/uni.api.esm.js b/packages/uni-mp-alipay/dist/uni.api.esm.js index d1ffce34a..28f3b6713 100644 --- a/packages/uni-mp-alipay/dist/uni.api.esm.js +++ b/packages/uni-mp-alipay/dist/uni.api.esm.js @@ -1,8 +1,7 @@ import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared'; const API_TYPE_SYNC = 1; -function validateProtocol(name, args, protocol) { - console.log(name, args, protocol); +function validateProtocol(_name, _args, _protocol) { return true; } function formatApiArgs(args, options) { @@ -13,7 +12,7 @@ function formatApiArgs(args, options) { function createApi({ type, name, options }, fn, protocol) { return function (...args) { if (type === API_TYPE_SYNC) { - if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol(name, args, protocol))) { + if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) { return fn.apply(null, formatApiArgs(args, options)); } } diff --git a/packages/uni-mp-alipay/dist/uni.mp.esm.js b/packages/uni-mp-alipay/dist/uni.mp.esm.js index dc1ddedf1..ad5532f09 100644 --- a/packages/uni-mp-alipay/dist/uni.mp.esm.js +++ b/packages/uni-mp-alipay/dist/uni.mp.esm.js @@ -1,5 +1,4 @@ import { capitalize, hasOwn, isArray, toNumber, isPlainObject, isObject, isFunction, extend, NOOP, EMPTY_OBJ, camelize } from '@vue/shared'; -import { stringifyQuery } from '@dcloudio/uni-shared'; function setModel(target, key, value, modifiers) { if (isArray(modifiers)) { @@ -218,6 +217,26 @@ function initCreateApp(parseAppOptions) { }; } +const encode = encodeURIComponent; +function stringifyQuery(obj, encodeStr = encode) { + const res = obj + ? Object.keys(obj) + .map(key => { + let val = obj[key]; + if (typeof val === undefined || val === null) { + val = ''; + } + else if (isPlainObject(val)) { + val = JSON.stringify(val); + } + return encodeStr(key) + '=' + encodeStr(val); + }) + .filter(x => x.length > 0) + .join('&') + : null; + return res ? `?${res}` : ''; +} + function initVueIds(vueIds, mpInstance) { if (!vueIds) { return; diff --git a/packages/uni-mp-baidu/dist/uni.api.esm.js b/packages/uni-mp-baidu/dist/uni.api.esm.js index 508f23874..5801e1d58 100644 --- a/packages/uni-mp-baidu/dist/uni.api.esm.js +++ b/packages/uni-mp-baidu/dist/uni.api.esm.js @@ -1,8 +1,7 @@ import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared'; const API_TYPE_SYNC = 1; -function validateProtocol(name, args, protocol) { - console.log(name, args, protocol); +function validateProtocol(_name, _args, _protocol) { return true; } function formatApiArgs(args, options) { @@ -13,7 +12,7 @@ function formatApiArgs(args, options) { function createApi({ type, name, options }, fn, protocol) { return function (...args) { if (type === API_TYPE_SYNC) { - if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol(name, args, protocol))) { + if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) { return fn.apply(null, formatApiArgs(args, options)); } } diff --git a/packages/uni-mp-baidu/dist/uni.mp.esm.js b/packages/uni-mp-baidu/dist/uni.mp.esm.js index 7de4fd51d..c2b202cdf 100644 --- a/packages/uni-mp-baidu/dist/uni.mp.esm.js +++ b/packages/uni-mp-baidu/dist/uni.mp.esm.js @@ -1,5 +1,4 @@ import { isArray, hasOwn, toNumber, isPlainObject, isObject, isFunction, extend, NOOP, camelize } from '@vue/shared'; -import { stringifyQuery } from '@dcloudio/uni-shared'; function setModel(target, key, value, modifiers) { if (isArray(modifiers)) { @@ -209,6 +208,26 @@ function initCreateApp(parseAppOptions) { }; } +const encode = encodeURIComponent; +function stringifyQuery(obj, encodeStr = encode) { + const res = obj + ? Object.keys(obj) + .map(key => { + let val = obj[key]; + if (typeof val === undefined || val === null) { + val = ''; + } + else if (isPlainObject(val)) { + val = JSON.stringify(val); + } + return encodeStr(key) + '=' + encodeStr(val); + }) + .filter(x => x.length > 0) + .join('&') + : null; + return res ? `?${res}` : ''; +} + function initBehavior(options) { return Behavior(options); } diff --git a/packages/uni-mp-qq/dist/uni.api.esm.js b/packages/uni-mp-qq/dist/uni.api.esm.js index 9a0d8877a..ef851c825 100644 --- a/packages/uni-mp-qq/dist/uni.api.esm.js +++ b/packages/uni-mp-qq/dist/uni.api.esm.js @@ -1,8 +1,7 @@ import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared'; const API_TYPE_SYNC = 1; -function validateProtocol(name, args, protocol) { - console.log(name, args, protocol); +function validateProtocol(_name, _args, _protocol) { return true; } function formatApiArgs(args, options) { @@ -13,7 +12,7 @@ function formatApiArgs(args, options) { function createApi({ type, name, options }, fn, protocol) { return function (...args) { if (type === API_TYPE_SYNC) { - if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol(name, args, protocol))) { + if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) { return fn.apply(null, formatApiArgs(args, options)); } } diff --git a/packages/uni-mp-qq/dist/uni.mp.esm.js b/packages/uni-mp-qq/dist/uni.mp.esm.js index 42b01cfbf..64d1d3b87 100644 --- a/packages/uni-mp-qq/dist/uni.mp.esm.js +++ b/packages/uni-mp-qq/dist/uni.mp.esm.js @@ -1,5 +1,4 @@ import { isArray, hasOwn, toNumber, isPlainObject, isObject, isFunction, extend, NOOP, camelize } from '@vue/shared'; -import { stringifyQuery } from '@dcloudio/uni-shared'; function setModel(target, key, value, modifiers) { if (isArray(modifiers)) { @@ -209,6 +208,26 @@ function initCreateApp(parseAppOptions) { }; } +const encode = encodeURIComponent; +function stringifyQuery(obj, encodeStr = encode) { + const res = obj + ? Object.keys(obj) + .map(key => { + let val = obj[key]; + if (typeof val === undefined || val === null) { + val = ''; + } + else if (isPlainObject(val)) { + val = JSON.stringify(val); + } + return encodeStr(key) + '=' + encodeStr(val); + }) + .filter(x => x.length > 0) + .join('&') + : null; + return res ? `?${res}` : ''; +} + function initBehavior(options) { return Behavior(options); } diff --git a/packages/uni-mp-toutiao/dist/uni.api.esm.js b/packages/uni-mp-toutiao/dist/uni.api.esm.js index e60a89cf6..9d0ce5b12 100644 --- a/packages/uni-mp-toutiao/dist/uni.api.esm.js +++ b/packages/uni-mp-toutiao/dist/uni.api.esm.js @@ -1,8 +1,7 @@ import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared'; const API_TYPE_SYNC = 1; -function validateProtocol(name, args, protocol) { - console.log(name, args, protocol); +function validateProtocol(_name, _args, _protocol) { return true; } function formatApiArgs(args, options) { @@ -13,7 +12,7 @@ function formatApiArgs(args, options) { function createApi({ type, name, options }, fn, protocol) { return function (...args) { if (type === API_TYPE_SYNC) { - if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol(name, args, protocol))) { + if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) { return fn.apply(null, formatApiArgs(args, options)); } } diff --git a/packages/uni-mp-toutiao/dist/uni.mp.esm.js b/packages/uni-mp-toutiao/dist/uni.mp.esm.js index 64e05e1bb..e88b77fbe 100644 --- a/packages/uni-mp-toutiao/dist/uni.mp.esm.js +++ b/packages/uni-mp-toutiao/dist/uni.mp.esm.js @@ -1,5 +1,4 @@ import { isArray, hasOwn, toNumber, isPlainObject, isObject, isFunction, extend, NOOP, camelize } from '@vue/shared'; -import { stringifyQuery } from '@dcloudio/uni-shared'; function setModel(target, key, value, modifiers) { if (isArray(modifiers)) { @@ -212,6 +211,26 @@ function initCreateApp(parseAppOptions) { }; } +const encode = encodeURIComponent; +function stringifyQuery(obj, encodeStr = encode) { + const res = obj + ? Object.keys(obj) + .map(key => { + let val = obj[key]; + if (typeof val === undefined || val === null) { + val = ''; + } + else if (isPlainObject(val)) { + val = JSON.stringify(val); + } + return encodeStr(key) + '=' + encodeStr(val); + }) + .filter(x => x.length > 0) + .join('&') + : null; + return res ? `?${res}` : ''; +} + function initBehavior(options) { return Behavior(options); } diff --git a/packages/uni-mp-weixin/dist/uni.api.esm.js b/packages/uni-mp-weixin/dist/uni.api.esm.js index eb50c7707..ea7871836 100644 --- a/packages/uni-mp-weixin/dist/uni.api.esm.js +++ b/packages/uni-mp-weixin/dist/uni.api.esm.js @@ -1,8 +1,7 @@ import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared'; const API_TYPE_SYNC = 1; -function validateProtocol(name, args, protocol) { - console.log(name, args, protocol); +function validateProtocol(_name, _args, _protocol) { return true; } function formatApiArgs(args, options) { @@ -13,7 +12,7 @@ function formatApiArgs(args, options) { function createApi({ type, name, options }, fn, protocol) { return function (...args) { if (type === API_TYPE_SYNC) { - if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol(name, args, protocol))) { + if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) { return fn.apply(null, formatApiArgs(args, options)); } } diff --git a/packages/uni-mp-weixin/dist/uni.mp.esm.js b/packages/uni-mp-weixin/dist/uni.mp.esm.js index 42b01cfbf..64d1d3b87 100644 --- a/packages/uni-mp-weixin/dist/uni.mp.esm.js +++ b/packages/uni-mp-weixin/dist/uni.mp.esm.js @@ -1,5 +1,4 @@ import { isArray, hasOwn, toNumber, isPlainObject, isObject, isFunction, extend, NOOP, camelize } from '@vue/shared'; -import { stringifyQuery } from '@dcloudio/uni-shared'; function setModel(target, key, value, modifiers) { if (isArray(modifiers)) { @@ -209,6 +208,26 @@ function initCreateApp(parseAppOptions) { }; } +const encode = encodeURIComponent; +function stringifyQuery(obj, encodeStr = encode) { + const res = obj + ? Object.keys(obj) + .map(key => { + let val = obj[key]; + if (typeof val === undefined || val === null) { + val = ''; + } + else if (isPlainObject(val)) { + val = JSON.stringify(val); + } + return encodeStr(key) + '=' + encodeStr(val); + }) + .filter(x => x.length > 0) + .join('&') + : null; + return res ? `?${res}` : ''; +} + function initBehavior(options) { return Behavior(options); } diff --git a/packages/uni-quickapp-webview/dist/uni.api.esm.js b/packages/uni-quickapp-webview/dist/uni.api.esm.js index ac85e0913..09c73991a 100644 --- a/packages/uni-quickapp-webview/dist/uni.api.esm.js +++ b/packages/uni-quickapp-webview/dist/uni.api.esm.js @@ -1,8 +1,7 @@ import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared'; const API_TYPE_SYNC = 1; -function validateProtocol(name, args, protocol) { - console.log(name, args, protocol); +function validateProtocol(_name, _args, _protocol) { return true; } function formatApiArgs(args, options) { @@ -13,7 +12,7 @@ function formatApiArgs(args, options) { function createApi({ type, name, options }, fn, protocol) { return function (...args) { if (type === API_TYPE_SYNC) { - if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol(name, args, protocol))) { + if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) { return fn.apply(null, formatApiArgs(args, options)); } } diff --git a/packages/uni-quickapp-webview/dist/uni.mp.esm.js b/packages/uni-quickapp-webview/dist/uni.mp.esm.js index d3ebb3784..2888e94ce 100644 --- a/packages/uni-quickapp-webview/dist/uni.mp.esm.js +++ b/packages/uni-quickapp-webview/dist/uni.mp.esm.js @@ -1,5 +1,4 @@ import { isArray, hasOwn, toNumber, isPlainObject, isObject, isFunction, extend, NOOP, camelize } from '@vue/shared'; -import { stringifyQuery } from '@dcloudio/uni-shared'; function setModel(target, key, value, modifiers) { if (isArray(modifiers)) { @@ -209,6 +208,26 @@ function initCreateApp(parseAppOptions) { }; } +const encode = encodeURIComponent; +function stringifyQuery(obj, encodeStr = encode) { + const res = obj + ? Object.keys(obj) + .map(key => { + let val = obj[key]; + if (typeof val === undefined || val === null) { + val = ''; + } + else if (isPlainObject(val)) { + val = JSON.stringify(val); + } + return encodeStr(key) + '=' + encodeStr(val); + }) + .filter(x => x.length > 0) + .join('&') + : null; + return res ? `?${res}` : ''; +} + function initBehavior(options) { return Behavior(options); } diff --git a/rollup.config.js b/rollup.config.js index e20f7d32f..1cc836a01 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -46,7 +46,6 @@ function createConfig(entryFile, output, plugins = []) { const external = [ '@vue/shared', - '@dcloudio/uni-shared', ...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {}) ] -- GitLab