提交 c057441f 编写于 作者: Q qiang

Merge branch 'dev' into alpha

# Conflicts:
#	packages/uni-app-plus/dist/index.v3.js
#	packages/uni-app-plus/dist/view.umd.min.js
#	packages/uni-h5/dist/index.umd.min.js
#	packages/uni-mp-weixin/dist/index.js
#	packages/uni-quickapp-native/dist/vue.dev.js
#	packages/uni-quickapp-native/dist/vue.prod.js
#	packages/vue-cli-plugin-uni/lib/mp/index.js
#	src/platforms/app-plus/service/api/location/get-location.js
......@@ -32,6 +32,10 @@ const PLATFORMS = {
prefix: 'tt',
title: '飞书小程序'
},
'mp-jd': {
prefix: 'jd',
title: '京东小程序'
},
'quickapp-webview': {
prefix: 'qa',
title: '快应用(Webview)版'
......
......@@ -239,7 +239,8 @@ const third = [
'restoreGlobal',
'getSubNVueById',
'getCurrentSubNVue',
'setPageMeta',
'setPageMeta',
'onHostEventReceive',
'onNativeEventReceive',
'sendNativeEvent',
'preloadPage',
......
......@@ -20,11 +20,12 @@
"build:mp-toutiao": "cross-env UNI_PLATFORM=mp-toutiao rollup -c build/rollup.config.mp.js",
"build:mp-kuaishou": "cross-env UNI_PLATFORM=mp-kuaishou rollup -c build/rollup.config.mp.js",
"build:mp-lark": "cross-env UNI_PLATFORM=mp-lark rollup -c build/rollup.config.mp.js",
"build:mp-jd": "cross-env UNI_PLATFORM=mp-jd rollup -c build/rollup.config.mp.js",
"build:quickapp-webview": "cross-env UNI_PLATFORM=quickapp-webview rollup -c build/rollup.config.mp.js",
"build:mp-weixin:mp": "cross-env UNI_PLATFORM=mp-weixin UNI_MP=true rollup -c build/rollup.config.mp.js",
"build:mp-weixin:wxs": "rollup -c build/rollup.config.wxs.js",
"build:quickapp-native": "cross-env NODE_ENV=development node build/build.qa.js && cross-env NODE_ENV=production node build/build.qa.js",
"build:runtime": "npm run lint && npm run build:mp-weixin && npm run build:mp-qq && npm run build:mp-alipay && npm run build:mp-baidu && npm run build:mp-toutiao && npm run build:app-plus && npm run build:quickapp-webview && npm run build:quickapp-native && npm run build:mp-kuaishou && npm run build:mp-lark",
"build:runtime": "npm run lint && npm run build:mp-weixin && npm run build:mp-qq && npm run build:mp-alipay && npm run build:mp-baidu && npm run build:mp-toutiao && npm run build:mp-jd && npm run build:app-plus && npm run build:quickapp-webview && npm run build:quickapp-native && npm run build:mp-kuaishou && npm run build:mp-lark",
"build:stat": "npm run lint && rollup -c build/rollup.config.stat.js",
"build:web-view": "rollup -c build/rollup.config.web-view.js",
"test:cli": "cross-env NODE_ENV=test jest",
......
......@@ -726,9 +726,15 @@ const customize = cached((str) => {
function initTriggerEvent (mpInstance) {
const oldTriggerEvent = mpInstance.triggerEvent;
mpInstance.triggerEvent = function (event, ...args) {
const newTriggerEvent = function (event, ...args) {
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
};
try {
// 京东小程序 triggerEvent 为只读
mpInstance.triggerEvent = newTriggerEvent;
} catch (error) {
mpInstance._triggerEvent = newTriggerEvent;
}
}
function initHook (name, options, isComponent) {
......@@ -2128,17 +2134,17 @@ function createPlugin (vm) {
const appOptions = parseApp$1(vm);
if (isFn(appOptions.onShow) && wx.onAppShow) {
wx.onAppShow((...args) => {
appOptions.onShow.apply(vm, args);
vm.__call_hook('onShow', args);
});
}
if (isFn(appOptions.onHide) && wx.onAppHide) {
wx.onAppHide((...args) => {
appOptions.onHide.apply(vm, args);
vm.__call_hook('onHide', args);
});
}
if (isFn(appOptions.onLaunch)) {
const args = wx.getLaunchOptionsSync && wx.getLaunchOptionsSync();
appOptions.onLaunch.call(vm, args);
vm.__call_hook('onLaunch', args);
}
return vm
}
......
......@@ -250,7 +250,8 @@ var serviceContext = (function () {
'restoreGlobal',
'getSubNVueById',
'getCurrentSubNVue',
'setPageMeta',
'setPageMeta',
'onHostEventReceive',
'onNativeEventReceive',
'sendNativeEvent',
'preloadPage',
......@@ -6758,6 +6759,7 @@ var serviceContext = (function () {
type = 'wgs84',
geocode = false,
altitude = false,
isHighAccuracy = false,
highAccuracyExpireTime
} = {}, callbackId) {
const errorCallback = warpPlusErrorCallback(callbackId, 'getLocation');
......@@ -6774,7 +6776,7 @@ var serviceContext = (function () {
errorCallback(e);
}, {
geocode: geocode,
enableHighAccuracy: altitude,
enableHighAccuracy: isHighAccuracy || altitude,
timeout: highAccuracyExpireTime,
coordsType: type
}
......@@ -7541,46 +7543,59 @@ var serviceContext = (function () {
firstIpv4: firstIpv4,
tls
};
let withArrayBuffer;
if (method !== 'GET') {
options.body = typeof data === 'string' ? data : JSON.stringify(data);
if (toString.call(data) === '[object ArrayBuffer]') {
withArrayBuffer = true;
} else {
options.body = typeof data === 'string' ? data : JSON.stringify(data);
}
}
try {
stream.fetch(options, ({
ok,
status,
data,
headers,
errorMsg
}) => {
if (aborted) {
return
}
if (abortTimeout) {
clearTimeout(abortTimeout);
}
const statusCode = status;
if (statusCode > 0) {
publishStateChange$1({
requestTaskId,
state: 'success',
data: ok && responseType === 'arraybuffer' ? base64ToArrayBuffer$2(data) : data,
statusCode,
header: headers,
cookies: cookiesParse(headers)
});
} else {
let errMsg = 'abort statusCode:' + statusCode;
if (errorMsg) {
errMsg = errMsg + ' ' + errorMsg;
}
publishStateChange$1({
requestTaskId,
state: 'fail',
statusCode,
errMsg
});
const callback = ({
ok,
status,
data,
headers,
errorMsg
}) => {
if (aborted) {
return
}
if (abortTimeout) {
clearTimeout(abortTimeout);
}
const statusCode = status;
if (statusCode > 0) {
publishStateChange$1({
requestTaskId,
state: 'success',
data: ok && responseType === 'arraybuffer' ? base64ToArrayBuffer$2(data) : data,
statusCode,
header: headers,
cookies: cookiesParse(headers)
});
} else {
let errMsg = 'abort statusCode:' + statusCode;
if (errorMsg) {
errMsg = errMsg + ' ' + errorMsg;
}
});
publishStateChange$1({
requestTaskId,
state: 'fail',
statusCode,
errMsg
});
}
};
try {
if (withArrayBuffer) {
stream.fetchWithArrayBuffer({
'@type': 'binary',
base64: arrayBufferToBase64$2(data)
}, options, callback);
} else {
stream.fetch(options, callback);
}
requestTasks[requestTaskId] = {
abort () {
aborted = true;
......@@ -8587,6 +8602,10 @@ var serviceContext = (function () {
});
});
function onHostEventReceive (callbackId) {
callbacks$3.push(callbackId);
}
function onNativeEventReceive (callbackId) {
callbacks$3.push(callbackId);
}
......@@ -11956,6 +11975,7 @@ var serviceContext = (function () {
restoreGlobal: restoreGlobal,
getSubNVueById: getSubNVueById,
getCurrentSubNVue: getCurrentSubNVue,
onHostEventReceive: onHostEventReceive,
onNativeEventReceive: onNativeEventReceive,
sendNativeEvent: sendNativeEvent,
loadSubPackage: loadSubPackage$2,
......@@ -15787,7 +15807,7 @@ var serviceContext = (function () {
var zstream = ZStream;
var toString = Object.prototype.toString;
var toString$1 = Object.prototype.toString;
/* Public constants ==========================================================*/
/* ===========================================================================*/
......@@ -15951,7 +15971,7 @@ var serviceContext = (function () {
if (typeof opt.dictionary === 'string') {
// If we need to compress text, change encoding to utf8.
dict = strings.string2buf(opt.dictionary);
} else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
} else if (toString$1.call(opt.dictionary) === '[object ArrayBuffer]') {
dict = new Uint8Array(opt.dictionary);
} else {
dict = opt.dictionary;
......@@ -16009,7 +16029,7 @@ var serviceContext = (function () {
if (typeof data === 'string') {
// If we need to compress text, change encoding to utf8.
strm.input = strings.string2buf(data);
} else if (toString.call(data) === '[object ArrayBuffer]') {
} else if (toString$1.call(data) === '[object ArrayBuffer]') {
strm.input = new Uint8Array(data);
} else {
strm.input = data;
......@@ -18561,7 +18581,7 @@ var serviceContext = (function () {
var gzheader = GZheader;
var toString$1 = Object.prototype.toString;
var toString$2 = Object.prototype.toString;
/**
* class Inflate
......@@ -18702,7 +18722,7 @@ var serviceContext = (function () {
// Convert data if needed
if (typeof opt.dictionary === 'string') {
opt.dictionary = strings.string2buf(opt.dictionary);
} else if (toString$1.call(opt.dictionary) === '[object ArrayBuffer]') {
} else if (toString$2.call(opt.dictionary) === '[object ArrayBuffer]') {
opt.dictionary = new Uint8Array(opt.dictionary);
}
if (opt.raw) { //In raw mode we need to set the dictionary early
......@@ -18760,7 +18780,7 @@ var serviceContext = (function () {
if (typeof data === 'string') {
// Only binary strings can be decompressed on practice
strm.input = strings.binstring2buf(data);
} else if (toString$1.call(data) === '[object ArrayBuffer]') {
} else if (toString$2.call(data) === '[object ArrayBuffer]') {
strm.input = new Uint8Array(data);
} else {
strm.input = data;
......
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=t(require("fs")),s=t(require("debug")),i=t(require("postcss-selector-parser")),r=t(require("fs-extra")),a=t(require("licia/dateFormat")),n=require("path"),o=require("util");require("address"),require("default-gateway"),require("licia/isStr"),require("licia/getPort");s("automator:devtool");function l(t){t.walk(t=>{if("tag"===t.type){const e=t.value;t.value="page"===e?"body":"uni-"+e}})}const c=["Page.getElement","Page.getElements","Element.getElement","Element.getElements"];require("qrcode-terminal"),require("qrcode-reader");const h=/^win/.test(process.platform),u=s("automator:launcher"),d=o.promisify(e.readdir),p=o.promisify(e.stat);class m{constructor(t){this.id=t.id,this.app=t.executablePath,this.appid=t.appid||"HBuilder",this.package=t.package||"io.dcloud.HBuilder"}shouldPush(){return this.exists(this.FILE_APP_SERVICE).then(()=>(u(`${a("yyyy-mm-dd HH:MM:ss:l")} ${this.FILE_APP_SERVICE} exists`),!1)).catch(()=>(u(`${a("yyyy-mm-dd HH:MM:ss:l")} ${this.FILE_APP_SERVICE} not exists`),!0))}push(t){return async function t(e){const s=await d(e);return(await Promise.all(s.map(async s=>{const i=n.resolve(e,s);return(await p(i)).isDirectory()?t(i):i}))).reduce((t,e)=>t.concat(e),[])}(t).then(e=>{const s=e.map(e=>{const s=(t=>h?t.replace(/\\/g,"/"):t)(n.join(this.DIR_WWW,n.relative(t,e)));return u(`${a("yyyy-mm-dd HH:MM:ss:l")} push ${e} ${s}`),this.pushFile(e,s)});return Promise.all(s)}).then(t=>!0)}get FILE_APP_SERVICE(){return this.DIR_WWW+"/app-service.js"}}const y=s("automator:simctl");function f(t){const e=parseInt(t);return e>9?String(e):"0"+e}class g extends m{constructor(){super(...arguments),this.bundleVersion=""}async init(){const t=require("node-simctl").Simctl;this.tool=new t({udid:this.id});try{await this.tool.bootDevice()}catch(t){}await this.initSDCard(),y(`${a("yyyy-mm-dd HH:MM:ss:l")} init ${this.id}`)}async initSDCard(){const t=await this.tool.appInfo(this.package);y(`${a("yyyy-mm-dd HH:MM:ss:l")} appInfo ${t}`);const e=t.match(/DataContainer\s+=\s+"(.*)"/);if(!e)return Promise.resolve("");const s=t.match(/CFBundleVersion\s+=\s+(.*);/);if(!s)return Promise.resolve("");this.sdcard=e[1].replace("file:",""),this.bundleVersion=s[1],y(`${a("yyyy-mm-dd HH:MM:ss:l")} install ${this.sdcard}`)}async version(){return Promise.resolve(this.bundleVersion)}formatVersion(t){const e=t.split(".");return 3!==e.length?t:e[0]+f(e[1])+f(e[2])}async install(){return y(`${a("yyyy-mm-dd HH:MM:ss:l")} install ${this.app}`),await this.tool.installApp(this.app),await this.tool.grantPermission(this.package,"all"),await this.initSDCard(),Promise.resolve(!0)}async start(){try{await this.tool.terminateApp(this.package),await this.tool.launchApp(this.package)}catch(t){}return Promise.resolve(!0)}async exit(){return await this.tool.terminateApp(this.package),await this.tool.shutdownDevice(),Promise.resolve(!0)}async captureScreenshot(){return Promise.resolve(await this.tool.getScreenshot())}exists(t){return r.existsSync(t)?Promise.resolve(!0):Promise.reject(Error(t+" not exists"))}pushFile(t,e){return Promise.resolve(r.copySync(t,e))}get DIR_WWW(){return`${this.sdcard}/Documents/Pandora/apps/${this.appid}/www/`}}const w=require("adbkit"),M=s("automator:adb");class P extends m{async init(){if(this.tool=w.createClient(),!this.id){const t=await this.tool.listDevices();if(!t.length)throw Error("Device not found");this.id=t[0].id}this.sdcard=(await this.shell(this.COMMAND_EXTERNAL)).trim(),M(`${a("yyyy-mm-dd HH:MM:ss:l")} init ${this.id} ${this.sdcard}`)}version(){return this.shell(this.COMMAND_VERSION).then(t=>{const e=t.match(/versionName=(.*)/);return e&&e.length>1?e[1]:""})}formatVersion(t){return t}async install(){let t=!0;try{const e=(await this.tool.getProperties(this.id))["ro.build.version.release"].split(".")[0];parseInt(e)<6&&(t=!1)}catch(t){}if(M(`${a("yyyy-mm-dd HH:MM:ss:l")} install ${this.app} permission=${t}`),t){const t=require("adbkit/lib/adb/command.js"),e=t.prototype._send;t.prototype._send=function(t){return 0===t.indexOf("shell:pm install -r ")&&(t=t.replace("shell:pm install -r ","shell:pm install -r -g "),M(`${a("yyyy-mm-dd HH:MM:ss:l")} ${t} `)),e.call(this,t)}}return this.tool.install(this.id,this.app).then(()=>this.init())}start(){return this.exit().then(()=>this.shell(this.COMMAND_START))}exit(){return this.shell(this.COMMAND_STOP)}captureScreenshot(){return this.tool.screencap(this.id).then(t=>new Promise(e=>{const s=[];t.on("data",(function(t){s.push(t)})),t.on("end",(function(){e(Buffer.concat(s).toString("base64"))}))}))}exists(t){return this.tool.stat(this.id,t)}pushFile(t,e){return this.tool.push(this.id,t,e)}shell(t){return M(`${a("yyyy-mm-dd HH:MM:ss:l")} SEND ► ${t}`),this.tool.shell(this.id,t).then(w.util.readAll).then(t=>{const e=t.toString();return M(`${a("yyyy-mm-dd HH:MM:ss:l")} ◀ RECV ${e}`),e})}get DIR_WWW(){return`${this.sdcard}/Android/data/${this.package}/apps/${this.appid}/www`}get COMMAND_EXTERNAL(){return"echo $EXTERNAL_STORAGE"}get COMMAND_VERSION(){return"dumpsys package "+this.package}get COMMAND_STOP(){return"am force-stop "+this.package}get COMMAND_START(){return`am start -n ${this.package}/io.dcloud.PandoraEntry --es ${this.appid} --ez needUpdateApp false --ez reload true`}}const v=s("automator:devtool");let E,$=!1;const S={android:/android_version=(.*)/,ios:/iphone_version=(.*)/};const A={"Tool.close":{reflect:async()=>{}},"App.exit":{reflect:async()=>E.exit()},"App.enableLog":{reflect:()=>Promise.resolve()},"App.captureScreenshot":{reflect:async(t,e)=>{const s=await E.captureScreenshot(e);return v("App.captureScreenshot "+s.length),{data:s}}}};!function(t){c.forEach(e=>{t[e]=function(t){return{reflect:async(e,s)=>e(t,s,!1),params:t=>(t.selector&&(t.selector=i(l).processSync(t.selector)),t)}}(e)})}(A);const _={devtools:{name:"App",paths:[],required:["manifest.json","app-service.js"],validate:async function(t,s){t.platform=(t.platform||process.env.UNI_OS_NAME).toLocaleLowerCase(),Object.assign(t,t[t.platform]),E=function(t,e){return"ios"===t?new g(e):new P(e)}(t.platform,t),await E.init();const i=await E.version();if(i){if(t.version){const s=E.formatVersion(function(t,s){if(t.endsWith(".txt"))try{const i=e.readFileSync(t).toString().match(S[s]);if(i)return i[1]}catch(t){console.error(t)}return t}(t.version,t.platform));v("version: "+i),v("newVersion: "+s),s!==i&&($=!0)}}else $=!0;if($){if(!t.executablePath)throw Error(`app-plus->${t.platform}->executablePath is not provided`);if(!e.existsSync(t.executablePath))throw Error(t.executablePath+" not exists")}return t},create:async function(t,e,s){$&&await E.install(),($||s.compiled||await E.shouldPush())&&await E.push(t),await E.start()}},adapter:A};module.exports=_;
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=t(require("fs")),s=t(require("debug")),i=t(require("postcss-selector-parser")),r=t(require("fs-extra")),a=t(require("licia/dateFormat")),n=require("path"),o=require("util");require("address"),require("default-gateway"),require("licia/isStr"),require("licia/getPort");var l=t(require("licia/sleep"));s("automator:devtool");function c(t){t.walk(t=>{if("tag"===t.type){const e=t.value;t.value="page"===e?"body":"uni-"+e}})}const h=["Page.getElement","Page.getElements","Element.getElement","Element.getElements"];require("qrcode-terminal"),require("qrcode-reader");const u=/^win/.test(process.platform),p=s("automator:launcher"),d=o.promisify(e.readdir),m=o.promisify(e.stat);class y{constructor(t){this.id=t.id,this.app=t.executablePath,this.appid=t.appid||"HBuilder",this.package=t.package||"io.dcloud.HBuilder"}shouldPush(){return this.exists(this.FILE_APP_SERVICE).then(()=>(p(`${a("yyyy-mm-dd HH:MM:ss:l")} ${this.FILE_APP_SERVICE} exists`),!1)).catch(()=>(p(`${a("yyyy-mm-dd HH:MM:ss:l")} ${this.FILE_APP_SERVICE} not exists`),!0))}push(t){return async function t(e){const s=await d(e);return(await Promise.all(s.map(async s=>{const i=n.resolve(e,s);return(await m(i)).isDirectory()?t(i):i}))).reduce((t,e)=>t.concat(e),[])}(t).then(e=>{const s=e.map(e=>{const s=(t=>u?t.replace(/\\/g,"/"):t)(n.join(this.DIR_WWW,n.relative(t,e)));return p(`${a("yyyy-mm-dd HH:MM:ss:l")} push ${e} ${s}`),this.pushFile(e,s)});return Promise.all(s)}).then(t=>!0)}get FILE_APP_SERVICE(){return this.DIR_WWW+"/app-service.js"}}const f=s("automator:simctl");function g(t){const e=parseInt(t);return e>9?String(e):"0"+e}class w extends y{constructor(){super(...arguments),this.bundleVersion=""}async init(){const t=require("node-simctl").Simctl;this.tool=new t({udid:this.id});try{await this.tool.bootDevice()}catch(t){}await this.initSDCard(),f(`${a("yyyy-mm-dd HH:MM:ss:l")} init ${this.id}`)}async initSDCard(){const t=await this.tool.appInfo(this.package);f(`${a("yyyy-mm-dd HH:MM:ss:l")} appInfo ${t}`);const e=t.match(/DataContainer\s+=\s+"(.*)"/);if(!e)return Promise.resolve("");const s=t.match(/CFBundleVersion\s+=\s+(.*);/);if(!s)return Promise.resolve("");this.sdcard=e[1].replace("file:",""),this.bundleVersion=s[1],f(`${a("yyyy-mm-dd HH:MM:ss:l")} install ${this.sdcard}`)}async version(){return Promise.resolve(this.bundleVersion)}formatVersion(t){const e=t.split(".");return 3!==e.length?t:e[0]+g(e[1])+g(e[2])}async install(){return f(`${a("yyyy-mm-dd HH:MM:ss:l")} install ${this.app}`),await this.tool.installApp(this.app),await this.tool.grantPermission(this.package,"all"),await this.initSDCard(),Promise.resolve(!0)}async start(){try{await this.tool.terminateApp(this.package),await this.tool.launchApp(this.package)}catch(t){}return Promise.resolve(!0)}async exit(){return await this.tool.terminateApp(this.package),await this.tool.shutdownDevice(),Promise.resolve(!0)}async captureScreenshot(){return Promise.resolve(await this.tool.getScreenshot())}exists(t){return r.existsSync(t)?Promise.resolve(!0):Promise.reject(Error(t+" not exists"))}pushFile(t,e){return Promise.resolve(r.copySync(t,e))}get DIR_WWW(){return`${this.sdcard}/Documents/Pandora/apps/${this.appid}/www/`}}const M=require("adbkit"),v=s("automator:adb");class P extends y{async init(){if(this.tool=M.createClient(),!this.id){const t=await this.tool.listDevices();if(!t.length)throw Error("Device not found");this.id=t[0].id}this.sdcard=(await this.shell(this.COMMAND_EXTERNAL)).trim(),v(`${a("yyyy-mm-dd HH:MM:ss:l")} init ${this.id} ${this.sdcard}`)}version(){return this.shell(this.COMMAND_VERSION).then(t=>{const e=t.match(/versionName=(.*)/);return e&&e.length>1?e[1]:""})}formatVersion(t){return t}async install(){let t=!0;try{const e=(await this.tool.getProperties(this.id))["ro.build.version.release"].split(".")[0];parseInt(e)<6&&(t=!1)}catch(t){}if(v(`${a("yyyy-mm-dd HH:MM:ss:l")} install ${this.app} permission=${t}`),t){const t=require("adbkit/lib/adb/command.js"),e=t.prototype._send;t.prototype._send=function(t){return 0===t.indexOf("shell:pm install -r ")&&(t=t.replace("shell:pm install -r ","shell:pm install -r -g "),v(`${a("yyyy-mm-dd HH:MM:ss:l")} ${t} `)),e.call(this,t)}}return this.tool.install(this.id,this.app).then(()=>this.init())}start(){return this.exit().then(()=>this.shell(this.COMMAND_START))}exit(){return this.shell(this.COMMAND_STOP)}captureScreenshot(){return this.tool.screencap(this.id).then(t=>new Promise(e=>{const s=[];t.on("data",(function(t){s.push(t)})),t.on("end",(function(){e(Buffer.concat(s).toString("base64"))}))}))}exists(t){return this.tool.stat(this.id,t)}pushFile(t,e){return this.tool.push(this.id,t,e)}shell(t){return v(`${a("yyyy-mm-dd HH:MM:ss:l")} SEND ► ${t}`),this.tool.shell(this.id,t).then(M.util.readAll).then(t=>{const e=t.toString();return v(`${a("yyyy-mm-dd HH:MM:ss:l")} ◀ RECV ${e}`),e})}get DIR_WWW(){return`${this.sdcard}/Android/data/${this.package}/apps/${this.appid}/www`}get COMMAND_EXTERNAL(){return"echo $EXTERNAL_STORAGE"}get COMMAND_VERSION(){return"dumpsys package "+this.package}get COMMAND_STOP(){return"am force-stop "+this.package}get COMMAND_START(){return`am start -n ${this.package}/io.dcloud.PandoraEntry --es ${this.appid} --ez needUpdateApp false --ez reload true`}}const E=s("automator:devtool");let $,S=!1;const A={android:/android_version=(.*)/,ios:/iphone_version=(.*)/};const _={"Tool.close":{reflect:async()=>{}},"App.exit":{reflect:async()=>$.exit()},"App.enableLog":{reflect:()=>Promise.resolve()},"App.captureScreenshot":{reflect:async(t,e)=>{const s=await $.captureScreenshot(e);return E("App.captureScreenshot "+s.length),{data:s}}}};!function(t){h.forEach(e=>{t[e]=function(t){return{reflect:async(e,s)=>e(t,s,!1),params:t=>(t.selector&&(t.selector=i(c).processSync(t.selector)),t)}}(e)})}(_);const H={devtools:{name:"App",paths:[],required:["manifest.json","app-service.js"],validate:async function(t,s){t.platform=(t.platform||process.env.UNI_OS_NAME).toLocaleLowerCase(),Object.assign(t,t[t.platform]),$=function(t,e){return"ios"===t?new w(e):new P(e)}(t.platform,t),await $.init();const i=await $.version();if(i){if(t.version){const s=$.formatVersion(function(t,s){if(t.endsWith(".txt"))try{const i=e.readFileSync(t).toString().match(A[s]);if(i)return i[1]}catch(t){console.error(t)}return t}(t.version,t.platform));E("version: "+i),E("newVersion: "+s),s!==i&&(S=!0)}}else S=!0;if(S){if(!t.executablePath)throw Error(`app-plus->${t.platform}->executablePath is not provided`);if(!e.existsSync(t.executablePath))throw Error(t.executablePath+" not exists")}return t},create:async function(t,e,s){S&&await $.install(),(S||s.compiled||await $.shouldPush())&&(await $.push(t),await l(1e3)),await $.start()}},adapter:_};module.exports=H;
......@@ -11,6 +11,7 @@ const inlineLimit =
process.env.UNI_PLATFORM === 'mp-toutiao' ||
process.env.UNI_PLATFORM === 'mp-kuaishou' ||
process.env.UNI_PLATFORM === 'mp-lark' ||
process.env.UNI_PLATFORM === 'mp-jd' ||
process.env.UNI_PLATFORM === 'app-plus' // v2需要base64,v3需要rewriteUrl
// mp-weixin,mp-qq,app-plus 非v3(即:需要base64的平台)
......
......@@ -2930,17 +2930,17 @@ function createPlugin (vm) {
const appOptions = parseApp(vm);
if (isFn(appOptions.onShow) && my.onAppShow) {
my.onAppShow((...args) => {
appOptions.onShow.apply(vm, args);
vm.__call_hook('onShow', args);
});
}
if (isFn(appOptions.onHide) && my.onAppHide) {
my.onAppHide((...args) => {
appOptions.onHide.apply(vm, args);
vm.__call_hook('onHide', args);
});
}
if (isFn(appOptions.onLaunch)) {
const args = my.getLaunchOptionsSync && my.getLaunchOptionsSync();
appOptions.onLaunch.call(vm, args);
vm.__call_hook('onLaunch', args);
}
return vm
}
......
......@@ -1128,9 +1128,15 @@ const customize = cached((str) => {
function initTriggerEvent (mpInstance) {
const oldTriggerEvent = mpInstance.triggerEvent;
mpInstance.triggerEvent = function (event, ...args) {
const newTriggerEvent = function (event, ...args) {
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
};
try {
// 京东小程序 triggerEvent 为只读
mpInstance.triggerEvent = newTriggerEvent;
} catch (error) {
mpInstance._triggerEvent = newTriggerEvent;
}
}
function initHook (name, options, isComponent) {
......@@ -2454,17 +2460,17 @@ function createPlugin (vm) {
const appOptions = parseApp(vm);
if (isFn(appOptions.onShow) && swan.onAppShow) {
swan.onAppShow((...args) => {
appOptions.onShow.apply(vm, args);
vm.__call_hook('onShow', args);
});
}
if (isFn(appOptions.onHide) && swan.onAppHide) {
swan.onAppHide((...args) => {
appOptions.onHide.apply(vm, args);
vm.__call_hook('onHide', args);
});
}
if (isFn(appOptions.onLaunch)) {
const args = swan.getLaunchOptionsSync && swan.getLaunchOptionsSync();
appOptions.onLaunch.call(vm, args);
vm.__call_hook('onLaunch', args);
}
return vm
}
......
# `uni-mp-jd`
> TODO: description
## Usage
```
const uniMpJD = require('uni-mp-jd');
// TODO: DEMONSTRATE API
```
此差异已折叠。
const compiler = require('@dcloudio/uni-mp-weixin/lib/uni.compiler.js')
const path = require('path')
const t = require('@babel/types')
const uniI18n = require('@dcloudio/uni-cli-i18n')
function generateJsCode (properties = '{}') {
return `
jd.createComponent({
generic:true,
props: ${properties},
render: function(){}
})
`
}
function generateCssCode (filename) {
return `
@import "./${filename}"
`
}
function hasOwn (obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key)
}
module.exports = Object.assign({}, compiler, {
directive: 'jd:',
resolveScopedSlots (slotName, {
genCode,
generate,
ownerName,
parentName,
parentNode,
resourcePath,
paramExprNode,
returnExprNodes,
traverseExpr
}, state) {
if (!state.scopedSlots) {
state.scopedSlots = {}
}
const baseName = `${ownerName}-${parentName}-${slotName}`
let componentName = baseName
if (!hasOwn(state.scopedSlots, baseName)) {
state.scopedSlots[baseName] = 0
}
if (state.scopedSlots[baseName]) {
componentName = baseName + state.scopedSlots[baseName]
}
state.scopedSlots[baseName]++
parentNode.attr['generic:scoped-slots-' + slotName] = componentName
if (state.options.platform.name === 'mp-weixin') {
parentNode.attr['data-vue-generic'] = 'scoped'
}
if (!parentNode.attr.generic) {
parentNode.attr.generic = {}
}
parentNode.attr.generic[slotName] = true
// 生成 scopedSlots 文件,包括 json,js,wxml,wxss,还需要更新 owner 的 usingComponents
if (!state.files) {
state.files = {}
}
const extname = path.extname(resourcePath)
// TODO 需要存储 resourcePath 相关 json
const templateFile = resourcePath.replace(ownerName + extname, componentName + extname)
const templateContent = generate(traverseExpr(returnExprNodes, state), state)
state.files[templateFile] = templateContent
const jsFile = resourcePath.replace(ownerName + extname, componentName + '.js')
const objectProperties = []
if (t.isObjectPattern(paramExprNode)) {
paramExprNode.properties.forEach(property => {
const key = property.key
const value = property.value
const valueObjectProperties = [
t.objectProperty(t.identifier('type'), t.nullLiteral())
]
if (t.isIdentifier(value)) {
if (value.name !== key.name) {
state.errors.add(uniI18n.__('mpWeChat.slotPropNoSupportReanme', { 0: key.name, 1: value.name }))
}
} else if (t.isAssignmentPattern(value)) {
valueObjectProperties.push(t.objectProperty(t.identifier('default'), value.right))
}
objectProperties.push(t.objectProperty(key, t.objectExpression(valueObjectProperties)))
})
} else {
state.errors.add(uniI18n.__('mpWeChat.onlySupportDestructuringSlot', { 0: paramExprNode.name, 1: 'v-slot="{ user }"' }))
}
const jsContent = generateJsCode(genCode(t.objectExpression(objectProperties), true))
state.files[jsFile] = jsContent
try {
// TODO 使用 getPlatformExts 在单元测试报错,改从 state.options.platform 判断
const {
getPlatformExts
} = require('@dcloudio/uni-cli-shared')
const styleExtname = getPlatformExts().style
const styleFile = resourcePath.replace(ownerName + extname, componentName + styleExtname)
const styleContent = generateCssCode(ownerName + styleExtname)
state.files[styleFile] = styleContent
} catch (error) { }
if (!state.generic) {
state.generic = []
}
// 存储,方便后续生成 json
state.generic.push(componentName)
return ''
}
})
module.exports = {
options: {
cssVars: {
'--status-bar-height': '25px',
'--window-top': '0px',
'--window-bottom': '0px',
'--window-left': '0px',
'--window-right': '0px'
},
extnames: {
style: '.jxss',
template: '.jxml'
},
subPackages: false,
project: 'project.config.json'
},
copyWebpackOptions (platformOptions, vueOptions) {
const copyOptions = ['jdcomponents']
global.uniModules.forEach(module => {
copyOptions.push('uni_modules/' + module + '/jdcomponents')
})
return copyOptions
}
}
{
"name": "@dcloudio/uni-mp-jd",
"version": "2.0.0-32920211029001",
"description": "uni-app mp-jd",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-mp-jd"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "shixiaolei6",
"license": "Apache-2.0",
"uni-app": {
"name": "mp-jd",
"title": "京东小程序"
},
"gitHead": "9e2d0f8e244724fcd64880316c57d837d1778cf8"
}
......@@ -903,9 +903,15 @@ const customize = cached((str) => {
function initTriggerEvent (mpInstance) {
const oldTriggerEvent = mpInstance.triggerEvent;
mpInstance.triggerEvent = function (event, ...args) {
const newTriggerEvent = function (event, ...args) {
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
};
try {
// 京东小程序 triggerEvent 为只读
mpInstance.triggerEvent = newTriggerEvent;
} catch (error) {
mpInstance._triggerEvent = newTriggerEvent;
}
}
function initHook (name, options, isComponent) {
......@@ -2110,17 +2116,17 @@ function createPlugin (vm) {
const appOptions = parseApp$1(vm);
if (isFn(appOptions.onShow) && ks.onAppShow) {
ks.onAppShow((...args) => {
appOptions.onShow.apply(vm, args);
vm.__call_hook('onShow', args);
});
}
if (isFn(appOptions.onHide) && ks.onAppHide) {
ks.onAppHide((...args) => {
appOptions.onHide.apply(vm, args);
vm.__call_hook('onHide', args);
});
}
if (isFn(appOptions.onLaunch)) {
const args = ks.getLaunchOptionsSync && ks.getLaunchOptionsSync();
appOptions.onLaunch.call(vm, args);
vm.__call_hook('onLaunch', args);
}
return vm
}
......
......@@ -953,9 +953,15 @@ const customize = cached((str) => {
function initTriggerEvent (mpInstance) {
const oldTriggerEvent = mpInstance.triggerEvent;
mpInstance.triggerEvent = function (event, ...args) {
const newTriggerEvent = function (event, ...args) {
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
};
try {
// 京东小程序 triggerEvent 为只读
mpInstance.triggerEvent = newTriggerEvent;
} catch (error) {
mpInstance._triggerEvent = newTriggerEvent;
}
}
function initHook (name, options, isComponent) {
......@@ -2219,17 +2225,17 @@ function createPlugin (vm) {
const appOptions = parseApp(vm);
if (isFn(appOptions.onShow) && tt.onAppShow) {
tt.onAppShow((...args) => {
appOptions.onShow.apply(vm, args);
vm.__call_hook('onShow', args);
});
}
if (isFn(appOptions.onHide) && tt.onAppHide) {
tt.onAppHide((...args) => {
appOptions.onHide.apply(vm, args);
vm.__call_hook('onHide', args);
});
}
if (isFn(appOptions.onLaunch)) {
const args = tt.getLaunchOptionsSync && tt.getLaunchOptionsSync();
appOptions.onLaunch.call(vm, args);
vm.__call_hook('onLaunch', args);
}
return vm
}
......
......@@ -1064,9 +1064,15 @@ const customize = cached((str) => {
function initTriggerEvent (mpInstance) {
const oldTriggerEvent = mpInstance.triggerEvent;
mpInstance.triggerEvent = function (event, ...args) {
const newTriggerEvent = function (event, ...args) {
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
};
try {
// 京东小程序 triggerEvent 为只读
mpInstance.triggerEvent = newTriggerEvent;
} catch (error) {
mpInstance._triggerEvent = newTriggerEvent;
}
}
function initHook (name, options, isComponent) {
......@@ -2232,17 +2238,17 @@ function createPlugin (vm) {
const appOptions = parseApp$1(vm);
if (isFn(appOptions.onShow) && wx.onAppShow) {
wx.onAppShow((...args) => {
appOptions.onShow.apply(vm, args);
vm.__call_hook('onShow', args);
});
}
if (isFn(appOptions.onHide) && wx.onAppHide) {
wx.onAppHide((...args) => {
appOptions.onHide.apply(vm, args);
vm.__call_hook('onHide', args);
});
}
if (isFn(appOptions.onLaunch)) {
const args = wx.getLaunchOptionsSync && wx.getLaunchOptionsSync();
appOptions.onLaunch.call(vm, args);
vm.__call_hook('onLaunch', args);
}
return vm
}
......
......@@ -1156,9 +1156,15 @@ const customize = cached((str) => {
function initTriggerEvent (mpInstance) {
const oldTriggerEvent = mpInstance.triggerEvent;
mpInstance.triggerEvent = function (event, ...args) {
const newTriggerEvent = function (event, ...args) {
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
};
try {
// 京东小程序 triggerEvent 为只读
mpInstance.triggerEvent = newTriggerEvent;
} catch (error) {
mpInstance._triggerEvent = newTriggerEvent;
}
}
function initHook (name, options, isComponent) {
......@@ -2460,17 +2466,17 @@ function createPlugin (vm) {
const appOptions = parseApp(vm);
if (isFn(appOptions.onShow) && tt.onAppShow) {
tt.onAppShow((...args) => {
appOptions.onShow.apply(vm, args);
vm.__call_hook('onShow', args);
});
}
if (isFn(appOptions.onHide) && tt.onAppHide) {
tt.onAppHide((...args) => {
appOptions.onHide.apply(vm, args);
vm.__call_hook('onHide', args);
});
}
if (isFn(appOptions.onLaunch)) {
const args = tt.getLaunchOptionsSync && tt.getLaunchOptionsSync();
appOptions.onLaunch.call(vm, args);
vm.__call_hook('onLaunch', args);
}
return vm
}
......
......@@ -795,9 +795,15 @@ const customize = cached((str) => {
function initTriggerEvent (mpInstance) {
const oldTriggerEvent = mpInstance.triggerEvent;
mpInstance.triggerEvent = function (event, ...args) {
const newTriggerEvent = function (event, ...args) {
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
};
try {
// 京东小程序 triggerEvent 为只读
mpInstance.triggerEvent = newTriggerEvent;
} catch (error) {
mpInstance._triggerEvent = newTriggerEvent;
}
}
function initHook (name, options, isComponent) {
......@@ -1971,17 +1977,17 @@ function createPlugin (vm) {
const appOptions = parseApp(vm);
if (isFn(appOptions.onShow) && wx.onAppShow) {
wx.onAppShow((...args) => {
appOptions.onShow.apply(vm, args);
vm.__call_hook('onShow', args);
});
}
if (isFn(appOptions.onHide) && wx.onAppHide) {
wx.onAppHide((...args) => {
appOptions.onHide.apply(vm, args);
vm.__call_hook('onHide', args);
});
}
if (isFn(appOptions.onLaunch)) {
const args = wx.getLaunchOptionsSync && wx.getLaunchOptionsSync();
appOptions.onLaunch.call(vm, args);
vm.__call_hook('onLaunch', args);
}
return vm
}
......
......@@ -5,6 +5,7 @@ const PLATFORMS = [
'mp-qq',
'mp-baidu',
'mp-alipay',
'mp-jd',
'mp-toutiao',
'quickapp-native'
]
......@@ -62,4 +63,4 @@ module.exports = function parseDisplay(manifest, pages, globalStyle = {}) {
display.pages[key] = parseStyle(page.style)
})
manifest.display = display
}
}
......@@ -870,9 +870,15 @@ const customize = cached((str) => {
function initTriggerEvent (mpInstance) {
const oldTriggerEvent = mpInstance.triggerEvent;
mpInstance.triggerEvent = function (event, ...args) {
const newTriggerEvent = function (event, ...args) {
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
};
try {
// 京东小程序 triggerEvent 为只读
mpInstance.triggerEvent = newTriggerEvent;
} catch (error) {
mpInstance._triggerEvent = newTriggerEvent;
}
}
function initHook (name, options, isComponent) {
......@@ -2088,17 +2094,17 @@ function createPlugin (vm) {
const appOptions = parseApp(vm);
if (isFn(appOptions.onShow) && qa.onAppShow) {
qa.onAppShow((...args) => {
appOptions.onShow.apply(vm, args);
vm.__call_hook('onShow', args);
});
}
if (isFn(appOptions.onHide) && qa.onAppHide) {
qa.onAppHide((...args) => {
appOptions.onHide.apply(vm, args);
vm.__call_hook('onHide', args);
});
}
if (isFn(appOptions.onLaunch)) {
const args = qa.getLaunchOptionsSync && qa.getLaunchOptionsSync();
appOptions.onLaunch.call(vm, args);
vm.__call_hook('onLaunch', args);
}
return vm
}
......
import { version } from '../package.json';
import { version } from '../package.json';
const STAT_VERSION = version;
const STAT_URL = 'https://tongji.dcloud.io/uni/stat';
const STAT_H5_URL = 'https://tongji.dcloud.io/uni/stat.gif';
const PAGE_PVER_TIME = 1800;
const APP_PVER_TIME = 300;
const OPERATING_TIME = 10;
const DIFF_TIME = 60 * 1000 * 60 * 24;
const OPERATING_TIME = 10;
const DIFF_TIME = 60 * 1000 * 60 * 24;
const statConfig = require('uni-stat-config').default || require('uni-stat-config');
const UUID_KEY = '__DC_STAT_UUID';
const UUID_VALUE = '__DC_UUID_VALUE';
......@@ -80,6 +80,7 @@ const getPlatformName = () => {
'mp-baidu': 'bd',
'mp-toutiao': 'tt',
'mp-qq': 'qq',
'mp-jd': 'jd',
'quickapp-native': 'qn',
'mp-kuaishou': 'ks'
};
......@@ -390,8 +391,8 @@ const requestData = (done) => {
});
}
});
};
};
const PagesJson = require('uni-pages?{"type":"style"}').default;
const statConfig$1 = require('uni-stat-config').default || require('uni-stat-config');
......@@ -927,8 +928,8 @@ class Stat extends Util {
};
this.request(options);
}
}
}
const stat = Stat.getInstance();
let isHide = false;
const lifecycle = {
......@@ -981,4 +982,4 @@ function main() {
}
}
main();
main();
......@@ -78,6 +78,7 @@ export const getPlatformName = () => {
'mp-baidu': 'bd',
'mp-toutiao': 'tt',
'mp-qq': 'qq',
'mp-jd': 'jd',
'quickapp-native': 'qn',
'mp-kuaishou': 'ks',
'mp-lark': 'lark'
......
......@@ -58,7 +58,8 @@ const tags = {
'login',
'inline-payment-panel'
],
'mp-weixin': [
'mp-weixin': [
'page-container',
'page-meta',
'navigation-bar',
'match-media'
......
......@@ -231,7 +231,7 @@ function traverseDataNode (dataNode, state, node) {
let key
// 自定义组件不支持 hidden 属性
const platform = state.options.platform.name
const platforms = ['mp-weixin', 'mp-qq', 'mp-toutiao', 'mp-lark']
const platforms = ['mp-weixin', 'mp-qq', 'mp-jd', 'mp-toutiao', 'mp-lark']
if (isComponent(node.type) && platforms.includes(platform)) {
// 字节跳动|飞书小程序自定义属性不会反应在DOM上,只能使用事件格式
key = `${platform === 'mp-toutiao' || platform === 'mp-lark' ? 'bind:-' : ''}${ATTE_DATA_CUSTOM_HIDDEN}`
......
......@@ -213,15 +213,16 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
from: path.resolve(process.env.UNI_INPUT_DIR, 'static'),
to: 'static'
}]
const androidPrivacyPath = path.resolve(process.env.UNI_INPUT_DIR, 'androidPrivacy.json')
if (fs.existsSync(androidPrivacyPath)) {
array.push({
from: androidPrivacyPath,
to: 'androidPrivacy.json'
})
// 自动化测试时,不启用androidPrivacy.json
if (!process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
const androidPrivacyPath = path.resolve(process.env.UNI_INPUT_DIR, 'androidPrivacy.json')
if (fs.existsSync(androidPrivacyPath)) {
array.push({
from: androidPrivacyPath,
to: 'androidPrivacy.json'
})
}
}
const hybridHtmlPath = path.resolve(process.env.UNI_INPUT_DIR, 'hybrid/html')
if (fs.existsSync(hybridHtmlPath)) {
array.push({
......@@ -389,4 +390,4 @@ module.exports = function () {
zlib: false
}
}
}
}
......@@ -48,7 +48,7 @@ module.exports = (api, options) => {
return buildManifestJson()
}
const platforms = ['mp-weixin', 'mp-qq', 'mp-baidu', 'mp-alipay', 'mp-toutiao', 'mp-lark']
const platforms = ['mp-weixin', 'mp-qq', 'mp-jd', 'mp-baidu', 'mp-alipay', 'mp-toutiao', 'mp-lark']
if (args.subpackage && platforms.includes(process.env.UNI_PLATFORM)) {
process.env.UNI_SUBPACKGE = args.subpackage
}
......@@ -281,4 +281,4 @@ function buildManifestJson () {
done
} = require('@vue/cli-shared-utils')
done('Build complete.')
}
}
const fs = require('fs')
const path = require('path')
const { compileI18nJsonStr } = require('@dcloudio/uni-i18n')
const { initI18nOptions } = require('@dcloudio/uni-cli-shared/lib/i18n')
const {
compileI18nJsonStr
} = require('@dcloudio/uni-i18n')
const {
initI18nOptions
} = require('@dcloudio/uni-cli-shared/lib/i18n')
const assetsDir = 'static'
function getAssetsCopyOption (from, options = {}) {
if (path.isAbsolute(from)) {
if (fs.existsSync(from)) {
return Object.assign(
{
from,
to: path.resolve(process.env.UNI_OUTPUT_DIR)
},
options
return Object.assign({
from,
to: path.resolve(process.env.UNI_OUTPUT_DIR)
},
options
)
}
}
const to = from
from = path.resolve(process.env.UNI_INPUT_DIR, from)
if (fs.existsSync(from)) {
return Object.assign(
{
from,
to: path.resolve(process.env.UNI_OUTPUT_DIR, to)
},
options
return Object.assign({
from,
to: path.resolve(process.env.UNI_OUTPUT_DIR, to)
},
options
)
}
}
......@@ -50,8 +52,7 @@ function getAssetsCopyOptions (assetsDir) {
process.UNI_SUBPACKAGES &&
Object.keys(process.UNI_SUBPACKAGES).forEach(root => {
const subAssetsCopyOption = getAssetsCopyOption(
path.join(root, assetsDir),
{
path.join(root, assetsDir), {
ignore
}
)
......@@ -86,7 +87,8 @@ function getCopyWebpackPluginOptions (platformOptions, vueOptions) {
copyOption && copyOptions.push(copyOption)
})
})
if (process.env.UNI_PLATFORM === 'app-plus') {
// 自动化测试时,不启用androidPrivacy.json
if (process.env.UNI_PLATFORM === 'app-plus' && !process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
copyOptions.push({
from: path.resolve(process.env.UNI_INPUT_DIR, 'android*.json'),
to: '[name].[ext]',
......@@ -116,4 +118,4 @@ function getCopyWebpackPluginOptions (platformOptions, vueOptions) {
module.exports = {
assetsDir,
getCopyWebpackPluginOptions
}
}
......@@ -200,22 +200,23 @@ module.exports = {
// 使用外层依赖的版本
alias['regenerator-runtime'] = require.resolve('regenerator-runtime')
const optimization = {}
const output = {
pathinfo: process.env.UNI_MINIMIZE !== 'true',
filename: '[name].js',
chunkFilename: '[id].js',
globalObject: process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'global'
// sourceMapFilename: '../.sourcemap/' + process.env.UNI_PLATFORM + '/[name].js.map'
}
if (process.env.UNI_MINIMIZE === 'true' && process.env.NODE_ENV === 'development') {
optimization.namedChunks = true
output.pathinfo = false
}
return {
mode: process.env.UNI_MINIMIZE === 'true' || process.env.NODE_ENV === 'production' ? 'production'
mode: process.env.NODE_ENV === 'production' ? 'production'
: 'development',
entry () {
return process.UNI_ENTRY
},
output: {
filename: '[name].js',
chunkFilename: '[id].js',
globalObject: process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'global'
// sourceMapFilename: '../.sourcemap/' + process.env.UNI_PLATFORM + '/[name].js.map'
},
output,
performance: {
hints: false
},
......@@ -263,8 +264,7 @@ module.exports = {
}]
}]
},
plugins,
optimization
plugins
}
},
chainWebpack (webpackConfig, vueOptions, api) {
......
......@@ -19,6 +19,7 @@
"dependencies": {
"@dcloudio/uni-stat": "^2.0.1-33520211229002",
"buffer-json": "^2.0.0",
"clone-deep": "^4.0.1",
"copy-webpack-plugin": "^5.1.1",
"cross-env": "^5.2.0",
"envinfo": "^6.0.1",
......@@ -27,6 +28,7 @@
"lru-cache": "^4.1.2",
"mkdirp": "^0.5.1",
"module-alias": "^2.1.0",
"neo-async": "^2.6.1",
"postcss": "^7.0.7",
"postcss-import": "^12.0.1",
"postcss-selector-parser": "^5.0.0",
......
......@@ -5827,7 +5827,7 @@ function internalMixin(Vue) {
Vue.prototype.$emit = function(event) {
if (this.$scope && event) {
this.$scope['triggerEvent'](event, {
(this.$scope['_triggerEvent'] || this.$scope['triggerEvent'])(event, {
__args__: toArray(arguments, 1)
});
}
......
......@@ -84,6 +84,7 @@ const getPlatformName = () => {
'mp-baidu': 'bd',
'mp-toutiao': 'tt',
'mp-qq': 'qq',
'mp-jd': 'jd',
'quickapp-native': 'qn',
'mp-kuaishou': 'ks',
};
......
......@@ -82,6 +82,7 @@ const getPlatformName = () => {
'mp-baidu': 'bd',
'mp-toutiao': 'tt',
'mp-qq': 'qq',
'mp-jd': 'jd',
'quickapp-native': 'qn',
'mp-kuaishou': 'ks',
};
......
......@@ -47,7 +47,7 @@ module.exports = function generateApp (compilation) {
// 框架预设样式 用于隐藏自定义组件
// TODO 分平台 import 不同 css
const platforms = ['mp-weixin', 'mp-qq', 'mp-toutiao', 'mp-lark']
const platforms = ['mp-weixin', 'mp-qq', 'mp-jd', 'mp-toutiao', 'mp-lark']
const presetStyle = platforms.includes(process.env.UNI_PLATFORM) ? '[data-custom-hidden="true"],[bind-data-custom-hidden="true"]{display: none !important;}' : ''
if (compilation.assets[`common/main${ext}`]) { // 是否存在 main.css
......
module.exports = function (pagesJson, manifestJson) {
const {
app,
project
} = require('../mp')(pagesJson, manifestJson, require('./project.config.json'))
// 暂不支持分包,兼容引擎判断
if (app.content.subPackages && !app.content.subPackages.length) {
delete app.content.subPackages
}
return [app, project]
}
{
"setting": {
"urlCheck": true,
"es6": false,
"postcss": false,
"minified": false,
"newFeature": true
},
"appid": "testAppId",
"projectname": ""
}
......@@ -12,9 +12,16 @@ const {
updateAppJsonUsingComponents
} = require('@dcloudio/uni-cli-shared/lib/cache')
const { darkmode, hasTheme } = require('@dcloudio/uni-cli-shared/lib/theme')
const {
darkmode,
hasTheme
} = require('@dcloudio/uni-cli-shared/lib/theme')
const { hasOwn, parseStyle, trimMPJson } = require('../util')
const {
hasOwn,
parseStyle,
trimMPJson
} = require('../util')
const uniI18n = require('@dcloudio/uni-cli-i18n')
......@@ -36,7 +43,9 @@ const pagesJson2AppJson = {
if (value && value.list && value.list.length) {
if (value.list.length < 2) {
console.error(
uniI18n.__('pagesLoader.pagesTabbarMinItem2', { 0: 'tabBar.list' })
uniI18n.__('pagesLoader.pagesTabbarMinItem2', {
0: 'tabBar.list'
})
)
}
const pages = json.pages
......@@ -48,7 +57,9 @@ const pagesJson2AppJson = {
fromJson.nvue &&
fromJson.nvue.pages &&
fromJson.nvue.pages.find(
({ path }) => path === page.pagePath + '.html'
({
path
}) => path === page.pagePath + '.html'
)
)
) {
......@@ -64,7 +75,8 @@ const pagesJson2AppJson = {
json[name] = value
},
preloadRule: defaultCopy,
workers: defaultCopy
workers: defaultCopy,
plugins: defaultCopy
}
const manifestJson2AppJson = {
......@@ -250,8 +262,7 @@ module.exports = function (pagesJson, manifestJson, project = {}) {
Object.keys(platformJson).forEach(key => {
if (
!projectKeys.includes(key) &&
['usingComponents', 'optimization'].indexOf(key) === -1
!projectKeys.includes(key) && ['usingComponents', 'optimization'].indexOf(key) === -1
) {
// usingComponents 是编译模式开关,需要过滤,不能拷贝到 app
app[key] = platformJson[key]
......@@ -300,8 +311,7 @@ module.exports = function (pagesJson, manifestJson, project = {}) {
Object.keys(platformJson).forEach(key => {
if (
!projectKeys.includes(key) &&
['usingComponents', 'optimization'].indexOf(key) === -1
!projectKeys.includes(key) && ['usingComponents', 'optimization'].indexOf(key) === -1
) {
// usingComponents 是编译模式开关,需要过滤,不能拷贝到 app
app[key] = platformJson[key]
......@@ -347,4 +357,4 @@ module.exports = function (pagesJson, manifestJson, project = {}) {
}
}
}
}
}
......@@ -32,6 +32,9 @@ import {
import {
initWebviewApi as initLarkWebviewApi
} from 'uni-platforms/mp-lark/runtime/web-view'
import {
initWebviewApi as initJDWebviewApi
} from 'uni-platforms/mp-jd/runtime/web-view'
const UniAppJSBridgeReady = function () {
window.UniAppJSBridge = true
......@@ -51,6 +54,7 @@ const initWebviewApis = [
initQuickappWebviewApi,
initKuaishouWebviewApi,
initLarkWebviewApi,
initJDWebviewApi,
initH5WebviewApi
]
......
......@@ -10,17 +10,17 @@ export default function createPlugin (vm) {
const appOptions = parseApp(vm)
if (isFn(appOptions.onShow) && __GLOBAL__.onAppShow) {
__GLOBAL__.onAppShow((...args) => {
appOptions.onShow.apply(vm, args)
vm.__call_hook('onShow', args)
})
}
if (isFn(appOptions.onHide) && __GLOBAL__.onAppHide) {
__GLOBAL__.onAppHide((...args) => {
appOptions.onHide.apply(vm, args)
vm.__call_hook('onHide', args)
})
}
if (isFn(appOptions.onLaunch)) {
const args = __GLOBAL__.getLaunchOptionsSync && __GLOBAL__.getLaunchOptionsSync()
appOptions.onLaunch.call(vm, args)
vm.__call_hook('onLaunch', args)
}
return vm
}
......@@ -185,9 +185,13 @@ export default {
},
methods: {
_onKeyup ($event) {
const input = $event.target
this.$trigger('confirm', $event, {
value: $event.target.value
value: input.value
})
if (!this.confirmHold) {
input.blur()
}
},
_onInput ($event, force) {
let outOfMaxlength = false
......
......@@ -224,6 +224,8 @@ export default {
}
this.__handleTouchMove = function (event) {
if (touchStart === null) return
var x = event.touches[0].pageX
var y = event.touches[0].pageY
var main = self.$refs.main
......
......@@ -187,7 +187,7 @@ export default {
_onKeyUpEnter: function ($event) {
if (this.isDone) {
this._confirm($event)
this.$refs.textarea.blur()
!this.confirmHold && this.$refs.textarea.blur()
}
},
_onCompositionstart ($event) {
......
......@@ -62,6 +62,10 @@ export default {
selectionEnd: {
type: [Number, String],
default: -1
},
confirmHold: {
type: Boolean,
default: false
}
},
data () {
......
......@@ -49,6 +49,10 @@ function processTouches (touches) {
return []
}
function isMouseEvent (name) {
return name.startsWith('mouse') || ['contextmenu'].includes(name)
}
export function processEvent (name, $event = {}, detail = {}, target = {}, currentTarget = {}) {
if ($event._processed) {
$event.type = detail.type || name
......@@ -90,7 +94,7 @@ export function processEvent (name, $event = {}, detail = {}, target = {}, curre
stopPropagation () {}
})
if (name.startsWith('mouse')) {
if (isMouseEvent(name)) {
const {
top
} = getWindowOffset()
......
......@@ -160,6 +160,18 @@ class ComponentDescriptor {
// TODO options
return (this.$vm.$emit(eventName, detail), this)
}
setTimeout (handler, timeout) {
return window.setTimeout(handler, timeout)
}
clearTimeout (handler) {
return window.clearTimeout(handler)
}
getBoundingClientRect () {
return this.$el.getBoundingClientRect()
}
}
export function createComponentDescriptor (vm, isOwnerInstance = true) {
......@@ -174,4 +186,4 @@ export function createComponentDescriptor (vm, isOwnerInstance = true) {
}
return vm.__wxsComponentDescriptor
}
}
}
......@@ -53,6 +53,7 @@ export function getLocation ({
type = 'wgs84',
geocode = false,
altitude = false,
isHighAccuracy = false,
highAccuracyExpireTime
} = {}, callbackId) {
const errorCallback = warpPlusErrorCallback(callbackId, 'getLocation')
......@@ -69,7 +70,7 @@ export function getLocation ({
errorCallback(e)
}, {
geocode: geocode,
enableHighAccuracy: altitude,
enableHighAccuracy: isHighAccuracy || altitude,
timeout: highAccuracyExpireTime,
coordsType: type
}
......
......@@ -5,7 +5,8 @@ import {
import {
publish,
requireNativePlugin,
base64ToArrayBuffer
base64ToArrayBuffer,
arrayBufferToBase64
} from '../../bridge'
import {
......@@ -107,46 +108,59 @@ export function createRequestTaskById (requestTaskId, {
firstIpv4: firstIpv4,
tls
}
let withArrayBuffer
if (method !== 'GET') {
options.body = typeof data === 'string' ? data : JSON.stringify(data)
if (toString.call(data) === '[object ArrayBuffer]') {
withArrayBuffer = true
} else {
options.body = typeof data === 'string' ? data : JSON.stringify(data)
}
}
try {
stream.fetch(options, ({
ok,
status,
data,
headers,
errorMsg
}) => {
if (aborted) {
return
}
if (abortTimeout) {
clearTimeout(abortTimeout)
}
const statusCode = status
if (statusCode > 0) {
publishStateChange({
requestTaskId,
state: 'success',
data: ok && responseType === 'arraybuffer' ? base64ToArrayBuffer(data) : data,
statusCode,
header: headers,
cookies: cookiesParse(headers)
})
} else {
let errMsg = 'abort statusCode:' + statusCode
if (errorMsg) {
errMsg = errMsg + ' ' + errorMsg
}
publishStateChange({
requestTaskId,
state: 'fail',
statusCode,
errMsg
})
const callback = ({
ok,
status,
data,
headers,
errorMsg
}) => {
if (aborted) {
return
}
if (abortTimeout) {
clearTimeout(abortTimeout)
}
const statusCode = status
if (statusCode > 0) {
publishStateChange({
requestTaskId,
state: 'success',
data: ok && responseType === 'arraybuffer' ? base64ToArrayBuffer(data) : data,
statusCode,
header: headers,
cookies: cookiesParse(headers)
})
} else {
let errMsg = 'abort statusCode:' + statusCode
if (errorMsg) {
errMsg = errMsg + ' ' + errorMsg
}
})
publishStateChange({
requestTaskId,
state: 'fail',
statusCode,
errMsg
})
}
}
try {
if (withArrayBuffer) {
stream.fetchWithArrayBuffer({
'@type': 'binary',
base64: arrayBufferToBase64(data)
}, options, callback)
} else {
stream.fetch(options, callback)
}
requestTasks[requestTaskId] = {
abort () {
aborted = true
......
......@@ -10,6 +10,10 @@ UniServiceJSBridge.on('api.uniMPNativeEvent', function (res) {
})
})
export function onHostEventReceive (callbackId) {
callbacks.push(callbackId)
}
export function onNativeEventReceive (callbackId) {
callbacks.push(callbackId)
}
......@@ -12,7 +12,8 @@ import { NAVBAR_HEIGHT } from 'uni-helpers/constants'
let webview = false
const insertHTMLWebView = ({
htmlId
htmlId,
updateTitle
}) => {
const parentWebview = plus.webview.currentWebview()
// fixed by hxy web-view 组件所在的 webview 不注入 uni-app 框架
......@@ -32,6 +33,7 @@ const insertHTMLWebView = ({
webview = plus.webview.create('', htmlId, styles)
if (parentTitleNView) {
webview.addEventListener('titleUpdate', function () {
if (!updateTitle) return
const title = webview.getTitle()
parentWebview.setStyle({
titleNView: {
......@@ -45,7 +47,6 @@ const insertHTMLWebView = ({
}
const updateHTMLWebView = ({
htmlId,
src,
webviewStyles
}) => {
......@@ -77,6 +78,10 @@ export default {
type: String,
default: ''
},
updateTitle: {
type: Boolean,
default: true
},
webviewStyles: {
type: Object,
default () {
......@@ -95,7 +100,8 @@ export default {
mounted () {
this.htmlId = WEBVIEW_ID_PREFIX + this.$page.id
insertHTMLWebView({
htmlId: this.htmlId
htmlId: this.htmlId,
updateTitle: this.updateTitle
})
updateHTMLWebView({
src: this.$getRealPath(this.src),
......
......@@ -14,6 +14,7 @@ import {
export function getLocation ({
type,
altitude,
isHighAccuracy,
highAccuracyExpireTime
}, callbackId) {
const {
......@@ -24,7 +25,7 @@ export function getLocation ({
new Promise((resolve, reject) => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(res => resolve(res.coords), reject, {
enableHighAccuracy: altitude,
enableHighAccuracy: isHighAccuracy || altitude,
timeout: highAccuracyExpireTime || 1000 * 100
})
} else {
......
// import navigateTo from 'uni-helpers/navigate-to'
// import redirectTo from '../../../mp-weixin/helpers/redirect-to'
// import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
// import getSystemInfo from '../../../mp-weixin/helpers/system-info'
// import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
// 需要做转换的 API 列表
export const protocols = {
// navigateTo,
// redirectTo,
// previewImage,
// getSystemInfo,
// getSystemInfoSync: getSystemInfo,
// getUserProfile
}
// 不支持的 API 列表
export const todos = [
'getSelectedTextRange'
]
// 存在兼容性的 API 列表
export const canIUses = []
export default {
oauth: ['jd'],
share: ['jd'],
payment: ['jd'],
push: ['jd']
}
import '../../mp-weixin/runtime/index'
const isJD = window.jd &&
window.jd.miniProgram &&
/micromessenger/i.test(navigator.userAgent) &&
/miniProgram/i.test(navigator.userAgent)
export function initWebviewApi (readyCallback) {
if (!isJD) {
return
}
if (window.JDJSBridgeReady && window.JDJSBridgeReady.invoke) {
setTimeout(readyCallback, 0)
} else {
document.addEventListener('JDJSBridgeReady', readyCallback)
}
return window.jd.miniProgram
}
import parseBaseApp from '../../../mp-weixin/runtime/wrapper/app-parser'
export default function parseApp (vm) {
return parseBaseApp(vm)
}
import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-parser'
export default function parseComponent (vueComponentOptions) {
const componentOptions = parseBaseComponent(vueComponentOptions)
// 京东小程序 lifetimes 存在兼容问题
const lifetimes = componentOptions.lifetimes
Object.keys(lifetimes).forEach(key => {
componentOptions[key] = lifetimes[key]
})
return componentOptions
}
import parseBasePage from '../../../mp-weixin/runtime/wrapper/page-parser'
export default function parsePage (vuePageOptions) {
return parseBasePage(vuePageOptions)
}
export const mocks = ['__route__', '__wxExparserNodeId__', '__wxWebviewId__']
export function findVmByVueId (vm, vuePid) {
const $children = vm.$children
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
for (let i = $children.length - 1; i >= 0; i--) {
const childVm = $children[i]
if (childVm.$scope._$vueId === vuePid) {
return childVm
}
}
// 反向递归查找
let parentVm
for (let i = $children.length - 1; i >= 0; i--) {
parentVm = findVmByVueId($children[i], vuePid)
if (parentVm) {
return parentVm
}
}
}
export function initBehavior (options) {
return Behavior(options)
}
export function isPage () {
return !!this.route
}
export function initRelation (detail) {
this.triggerEvent('__l', detail)
}
function selectAllComponents (mpInstance, selector, $refs) {
const components = mpInstance.selectAllComponents(selector)
components.forEach(component => {
const ref = component.dataset.ref
$refs[ref] = component.$vm || component
if (__PLATFORM__ === 'mp-weixin') {
if (component.dataset.vueGeneric === 'scoped') {
component.selectAllComponents('.scoped-ref').forEach(scopedComponent => {
selectAllComponents(scopedComponent, selector, $refs)
})
}
}
})
}
export function initRefs (vm) {
const mpInstance = vm.$scope
Object.defineProperty(vm, '$refs', {
get () {
const $refs = {}
selectAllComponents(mpInstance, '.vue-ref', $refs)
// TODO 暂不考虑 for 中的 scoped
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for')
forComponents.forEach(component => {
const ref = component.dataset.ref
if (!$refs[ref]) {
$refs[ref] = []
}
$refs[ref].push(component.$vm || component)
})
return $refs
}
})
}
export function handleLink (event) {
const {
vuePid,
vueOptions
} = event.detail || event.value // detail 是微信,value 是百度(dipatch)
let parentVm
if (vuePid) {
parentVm = findVmByVueId(this.$vm, vuePid)
}
if (!parentVm) {
parentVm = this.$vm
}
vueOptions.parent = parentVm
}
......@@ -14,9 +14,15 @@ const customize = cached((str) => {
function initTriggerEvent (mpInstance) {
const oldTriggerEvent = mpInstance.triggerEvent
mpInstance.triggerEvent = function (event, ...args) {
const newTriggerEvent = function (event, ...args) {
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
}
try {
// 京东小程序 triggerEvent 为只读
mpInstance.triggerEvent = newTriggerEvent
} catch (error) {
mpInstance._triggerEvent = newTriggerEvent
}
}
function initHook (name, options, isComponent) {
......
......@@ -110,7 +110,7 @@ export default function parseBaseApp (vm, {
initRefs
}) {
initEventChannel()
if (__PLATFORM__ === 'mp-weixin' || __PLATFORM__ === 'mp-qq' || __PLATFORM__ === 'mp-toutiao' || __PLATFORM__ ===
if (__PLATFORM__ === 'mp-weixin' || __PLATFORM__ === 'mp-qq' || __PLATFORM__ === 'mp-jd' || __PLATFORM__ === 'mp-toutiao' || __PLATFORM__ ===
'mp-kuaishou' || __PLATFORM__ === 'mp-alipay' || __PLATFORM__ === 'mp-baidu' || __PLATFORM__ === 'mp-lark') {
initScopedSlotsParams()
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册