提交 f9ad49cf 编写于 作者: fxy060608's avatar fxy060608

build uni-app-plus-nvue

上级 e5f05663
......@@ -26,6 +26,81 @@ var serviceContext = (function () {
return callHook(vm, hook, params)
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var base64Arraybuffer = createCommonjsModule(function (module, exports) {
/*
* base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer
*
* Copyright (c) 2012 Niklas von Hertzen
* Licensed under the MIT license.
*/
(function(){
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
// Use a lookup table to find the index.
var lookup = new Uint8Array(256);
for (var i = 0; i < chars.length; i++) {
lookup[chars.charCodeAt(i)] = i;
}
exports.encode = function(arraybuffer) {
var bytes = new Uint8Array(arraybuffer),
i, len = bytes.length, base64 = "";
for (i = 0; i < len; i+=3) {
base64 += chars[bytes[i] >> 2];
base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
base64 += chars[bytes[i + 2] & 63];
}
if ((len % 3) === 2) {
base64 = base64.substring(0, base64.length - 1) + "=";
} else if (len % 3 === 1) {
base64 = base64.substring(0, base64.length - 2) + "==";
}
return base64;
};
exports.decode = function(base64) {
var bufferLength = base64.length * 0.75,
len = base64.length, i, p = 0,
encoded1, encoded2, encoded3, encoded4;
if (base64[base64.length - 1] === "=") {
bufferLength--;
if (base64[base64.length - 2] === "=") {
bufferLength--;
}
}
var arraybuffer = new ArrayBuffer(bufferLength),
bytes = new Uint8Array(arraybuffer);
for (i = 0; i < len; i+=4) {
encoded1 = lookup[base64.charCodeAt(i)];
encoded2 = lookup[base64.charCodeAt(i+1)];
encoded3 = lookup[base64.charCodeAt(i+2)];
encoded4 = lookup[base64.charCodeAt(i+3)];
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
}
return arraybuffer;
};
})();
});
var base64Arraybuffer_1 = base64Arraybuffer.encode;
var base64Arraybuffer_2 = base64Arraybuffer.decode;
function pack (args) {
return args
}
......@@ -69,8 +144,8 @@ var serviceContext = (function () {
lastStatusBarStyle = statusBarStyle;
plus.navigator.setStatusBarStyle(statusBarStyle);
}
}
function isTabBarPage (path = '') {
if (!(__uniConfig.tabBar && Array.isArray(__uniConfig.tabBar.list))) {
return false
......@@ -94,6 +169,10 @@ var serviceContext = (function () {
}
}
return false
}
function base64ToArrayBuffer (data) {
return base64Arraybuffer_2(data)
}
function callApiSync (api, args, name, alias) {
......@@ -1896,7 +1975,7 @@ var serviceContext = (function () {
}
}
const base64ToArrayBuffer = [{
const base64ToArrayBuffer$1 = [{
name: 'base64',
type: String,
required: true
......@@ -1909,7 +1988,7 @@ var serviceContext = (function () {
}];
var require_context_module_0_0 = /*#__PURE__*/Object.freeze({
base64ToArrayBuffer: base64ToArrayBuffer,
base64ToArrayBuffer: base64ToArrayBuffer$1,
arrayBufferToBase64: arrayBufferToBase64
});
......@@ -2456,11 +2535,11 @@ var serviceContext = (function () {
CONNECT: 'CONNECT'
};
const dataType = {
JSON: 'JSON'
JSON: 'json'
};
const responseType = {
TEXT: 'TEXT',
ARRAYBUFFER: 'ARRAYBUFFER'
TEXT: 'text',
ARRAYBUFFER: 'arraybuffer'
};
const encode = encodeURIComponent;
......@@ -2526,13 +2605,13 @@ var serviceContext = (function () {
dataType: {
type: String,
validator (value, params) {
params.dataType = (value || dataType.JSON).toUpperCase();
params.dataType = (value || dataType.JSON).toLowerCase();
}
},
responseType: {
type: String,
validator (value, params) {
value = (value || '').toUpperCase();
value = (value || '').toLowerCase();
params.responseType = Object.values(responseType).indexOf(value) < 0 ? responseType.TEXT : value;
}
}
......@@ -3585,82 +3664,7 @@ var serviceContext = (function () {
}
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var base64Arraybuffer = createCommonjsModule(function (module, exports) {
/*
* base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer
*
* Copyright (c) 2012 Niklas von Hertzen
* Licensed under the MIT license.
*/
(function(){
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
// Use a lookup table to find the index.
var lookup = new Uint8Array(256);
for (var i = 0; i < chars.length; i++) {
lookup[chars.charCodeAt(i)] = i;
}
exports.encode = function(arraybuffer) {
var bytes = new Uint8Array(arraybuffer),
i, len = bytes.length, base64 = "";
for (i = 0; i < len; i+=3) {
base64 += chars[bytes[i] >> 2];
base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
base64 += chars[bytes[i + 2] & 63];
}
if ((len % 3) === 2) {
base64 = base64.substring(0, base64.length - 1) + "=";
} else if (len % 3 === 1) {
base64 = base64.substring(0, base64.length - 2) + "==";
}
return base64;
};
exports.decode = function(base64) {
var bufferLength = base64.length * 0.75,
len = base64.length, i, p = 0,
encoded1, encoded2, encoded3, encoded4;
if (base64[base64.length - 1] === "=") {
bufferLength--;
if (base64[base64.length - 2] === "=") {
bufferLength--;
}
}
var arraybuffer = new ArrayBuffer(bufferLength),
bytes = new Uint8Array(arraybuffer);
for (i = 0; i < len; i+=4) {
encoded1 = lookup[base64.charCodeAt(i)];
encoded2 = lookup[base64.charCodeAt(i+1)];
encoded3 = lookup[base64.charCodeAt(i+2)];
encoded4 = lookup[base64.charCodeAt(i+3)];
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
}
return arraybuffer;
};
})();
});
var base64Arraybuffer_1 = base64Arraybuffer.encode;
var base64Arraybuffer_2 = base64Arraybuffer.decode;
function base64ToArrayBuffer$1 (str) {
function base64ToArrayBuffer$2 (str) {
return base64Arraybuffer_2(str)
}
......@@ -3669,7 +3673,7 @@ var serviceContext = (function () {
}
var require_context_module_1_0 = /*#__PURE__*/Object.freeze({
base64ToArrayBuffer: base64ToArrayBuffer$1,
base64ToArrayBuffer: base64ToArrayBuffer$2,
arrayBufferToBase64: arrayBufferToBase64$1
});
......@@ -5863,26 +5867,27 @@ var serviceContext = (function () {
return createDownloadTaskById(++downloadTaskId, args)
}
let requestTaskId = 0;
const requestTasks = {};
const publishStateChange$1 = res => {
publish('onRequestTaskStateChange', res);
delete requestTasks[requestTaskId];
};
function createRequestTaskById (requestTaskId, {
url,
data,
header,
method = 'GET'
let requestTaskId = 0;
const requestTasks = {};
const publishStateChange$1 = res => {
publish('onRequestTaskStateChange', res);
delete requestTasks[requestTaskId];
};
function createRequestTaskById (requestTaskId, {
url,
data,
header,
method = 'GET',
responseType
} = {}) {
const stream = requireNativePlugin('stream');
const headers = {};
let abortTimeout;
let aborted;
let hasContentType = false;
let aborted;
let hasContentType = false;
for (const name in header) {
if (!hasContentType && name.toLowerCase() === 'content-type') {
hasContentType = true;
......@@ -5891,37 +5896,38 @@ var serviceContext = (function () {
headers[name] = header[name];
}
}
if (!hasContentType && method === 'POST') {
headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
}
headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
}
const timeout = __uniConfig.networkTimeout.request;
if (timeout) {
const timeout = __uniConfig.networkTimeout.request;
if (timeout) {
abortTimeout = setTimeout(() => {
aborted = true;
publishStateChange$1({
requestTaskId,
state: 'fail',
statusCode: 0,
errMsg: 'timeout'
});
}, timeout);
}
aborted = true;
publishStateChange$1({
requestTaskId,
state: 'fail',
statusCode: 0,
errMsg: 'timeout'
});
}, timeout);
}
const options = {
method,
url: url.trim(),
// weex 官方文档有误,headers 类型实际 object,用 string 类型会无响应
headers,
type: 'text',
type: responseType === 'arraybuffer' ? 'base64' : 'text',
// weex 官方文档未说明实际支持 timeout,单位:ms
timeout: timeout || 6e5
};
if (method !== 'GET') {
options.body = data;
}
try {
}
try {
stream.fetch(options, ({
ok,
status,
data,
headers
......@@ -5937,7 +5943,7 @@ var serviceContext = (function () {
publishStateChange$1({
requestTaskId,
state: 'success',
data,
data: ok && responseType === 'arraybuffer' ? base64ToArrayBuffer(data) : data,
statusCode,
header: headers
});
......@@ -5949,7 +5955,7 @@ var serviceContext = (function () {
errMsg: 'abort'
});
}
});
});
requestTasks[requestTaskId] = {
abort () {
aborted = true;
......@@ -5963,37 +5969,37 @@ var serviceContext = (function () {
errMsg: 'abort'
});
}
};
} catch (e) {
return {
requestTaskId,
errMsg: 'createRequestTask:fail'
}
}
return {
requestTaskId,
errMsg: 'createRequestTask:ok'
}
}
function createRequestTask (args) {
return createRequestTaskById(++requestTaskId, args)
}
function operateRequestTask ({
requestTaskId,
operationType
} = {}) {
const requestTask = requestTasks[requestTaskId];
if (requestTask && operationType === 'abort') {
requestTask.abort();
return {
errMsg: 'operateRequestTask:ok'
}
}
return {
errMsg: 'operateRequestTask:fail'
}
};
} catch (e) {
return {
requestTaskId,
errMsg: 'createRequestTask:fail'
}
}
return {
requestTaskId,
errMsg: 'createRequestTask:ok'
}
}
function createRequestTask (args) {
return createRequestTaskById(++requestTaskId, args)
}
function operateRequestTask ({
requestTaskId,
operationType
} = {}) {
const requestTask = requestTasks[requestTaskId];
if (requestTask && operationType === 'abort') {
requestTask.abort();
return {
errMsg: 'operateRequestTask:ok'
}
}
return {
errMsg: 'operateRequestTask:fail'
}
}
let socketTaskId = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册