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

chore: build

上级 ec1f6be4
......@@ -39,118 +39,6 @@ const capitalize = cacheStringFunction((str) => {
return str.charAt(0).toUpperCase() + str.slice(1);
});
const LINEFEED = '\n';
const ON_READY = 'onReady';
const ON_UNLOAD = 'onUnload';
let lastLogTime = 0;
function formatLog(module, ...args) {
const now = Date.now();
const diff = lastLogTime ? now - lastLogTime : 0;
lastLogTime = now;
return `[${now}][${diff}ms][${module}]:${args
.map((arg) => JSON.stringify(arg))
.join(' ')}`;
}
const invokeArrayFns = (fns, arg) => {
let ret;
for (let i = 0; i < fns.length; i++) {
ret = fns[i](arg);
}
return ret;
};
function once(fn, ctx = null) {
let res;
return ((...args) => {
if (fn) {
res = fn.apply(ctx, args);
fn = null;
}
return res;
});
}
class EventChannel {
id;
listener;
emitCache;
constructor(id, events) {
this.id = id;
this.listener = {};
this.emitCache = [];
if (events) {
Object.keys(events).forEach((name) => {
this.on(name, events[name]);
});
}
}
emit(eventName, ...args) {
const fns = this.listener[eventName];
if (!fns) {
return this.emitCache.push({
eventName,
args,
});
}
fns.forEach((opt) => {
opt.fn.apply(opt.fn, args);
});
this.listener[eventName] = fns.filter((opt) => opt.type !== 'once');
}
on(eventName, fn) {
this._addListener(eventName, 'on', fn);
this._clearCache(eventName);
}
once(eventName, fn) {
this._addListener(eventName, 'once', fn);
this._clearCache(eventName);
}
off(eventName, fn) {
const fns = this.listener[eventName];
if (!fns) {
return;
}
if (fn) {
for (let i = 0; i < fns.length;) {
if (fns[i].fn === fn) {
fns.splice(i, 1);
i--;
}
i++;
}
}
else {
delete this.listener[eventName];
}
}
_clearCache(eventName) {
for (let index = 0; index < this.emitCache.length; index++) {
const cache = this.emitCache[index];
const _name = eventName
? cache.eventName === eventName
? eventName
: null
: cache.eventName;
if (!_name)
continue;
const location = this.emit.apply(this, [_name, ...cache.args]);
if (typeof location === 'number') {
this.emitCache.pop();
continue;
}
this.emitCache.splice(index, 1);
index--;
}
}
_addListener(eventName, type, fn) {
(this.listener[eventName] || (this.listener[eventName] = [])).push({
fn,
type,
});
}
}
const CHOOSE_SIZE_TYPES = ['original', 'compressed'];
const CHOOSE_SOURCE_TYPES = ['album', 'camera'];
function elemsInArray(strArr, optionalVal) {
......@@ -562,7 +450,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + '\n' + errMsg.stack);
return errMsg.message;
}
return errMsg;
......@@ -599,6 +487,117 @@ function getBaseSystemInfo() {
};
}
const ON_READY = 'onReady';
const ON_UNLOAD = 'onUnload';
let lastLogTime = 0;
function formatLog(module, ...args) {
const now = Date.now();
const diff = lastLogTime ? now - lastLogTime : 0;
lastLogTime = now;
return `[${now}][${diff}ms][${module}]:${args
.map((arg) => JSON.stringify(arg))
.join(' ')}`;
}
const invokeArrayFns = (fns, arg) => {
let ret;
for (let i = 0; i < fns.length; i++) {
ret = fns[i](arg);
}
return ret;
};
function once(fn, ctx = null) {
let res;
return ((...args) => {
if (fn) {
res = fn.apply(ctx, args);
fn = null;
}
return res;
});
}
class EventChannel {
id;
listener;
emitCache;
constructor(id, events) {
this.id = id;
this.listener = {};
this.emitCache = [];
if (events) {
Object.keys(events).forEach((name) => {
this.on(name, events[name]);
});
}
}
emit(eventName, ...args) {
const fns = this.listener[eventName];
if (!fns) {
return this.emitCache.push({
eventName,
args,
});
}
fns.forEach((opt) => {
opt.fn.apply(opt.fn, args);
});
this.listener[eventName] = fns.filter((opt) => opt.type !== 'once');
}
on(eventName, fn) {
this._addListener(eventName, 'on', fn);
this._clearCache(eventName);
}
once(eventName, fn) {
this._addListener(eventName, 'once', fn);
this._clearCache(eventName);
}
off(eventName, fn) {
const fns = this.listener[eventName];
if (!fns) {
return;
}
if (fn) {
for (let i = 0; i < fns.length;) {
if (fns[i].fn === fn) {
fns.splice(i, 1);
i--;
}
i++;
}
}
else {
delete this.listener[eventName];
}
}
_clearCache(eventName) {
for (let index = 0; index < this.emitCache.length; index++) {
const cache = this.emitCache[index];
const _name = eventName
? cache.eventName === eventName
? eventName
: null
: cache.eventName;
if (!_name)
continue;
const location = this.emit.apply(this, [_name, ...cache.args]);
if (typeof location === 'number') {
this.emitCache.pop();
continue;
}
this.emitCache.splice(index, 1);
index--;
}
}
_addListener(eventName, type, fn) {
(this.listener[eventName] || (this.listener[eventName] = [])).push({
fn,
type,
});
}
}
const isObject = (val) => val !== null && typeof val === 'object';
const defaultDelimiters = ['{', '}'];
class BaseFormatter {
......
import { isArray, hasOwn as hasOwn$1, isString, isPlainObject, isObject as isObject$1, toRawType, capitalize, makeMap, isFunction, isPromise, extend, remove, toTypeString } from '@vue/shared';
import { LINEFEED, parseNVueDataset, once, I18N_JSON_DELIMITERS, Emitter, normalizeStyles, addLeadingSlash, resolveComponentInstance, invokeArrayFns, removeLeadingSlash, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, SCHEME_RE, DATA_RE, cacheStringFunction, formatLog, parseQuery, ON_ERROR, callOptions, ON_UNHANDLE_REJECTION, ON_PAGE_NOT_FOUND, PRIMARY_COLOR, getLen, ON_THEME_CHANGE, TABBAR_HEIGHT, NAVBAR_HEIGHT, sortObject, OFF_THEME_CHANGE, ON_KEYBOARD_HEIGHT_CHANGE, normalizeTabBarStyles, ON_NAVIGATION_BAR_BUTTON_TAP, stringifyQuery as stringifyQuery$1, debounce, ON_PULL_DOWN_REFRESH, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_BACK_PRESS, UniNode, NODE_TYPE_PAGE, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_PAGE_SCROLL, ACTION_TYPE_INSERT, ACTION_TYPE_CREATE, ACTION_TYPE_REMOVE, ACTION_TYPE_ADD_EVENT, ACTION_TYPE_ADD_WXS_EVENT, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_SET_TEXT, ON_READY, ON_UNLOAD, EventChannel, ON_REACH_BOTTOM_DISTANCE, parseUrl, onCreateVueApp, ON_TAB_ITEM_TAP, ON_LAUNCH, ACTION_TYPE_EVENT, createUniEvent, ON_WXS_INVOKE_CALL_METHOD, WEB_INVOKE_APPSERVICE } from '@dcloudio/uni-shared';
import { parseNVueDataset, once, I18N_JSON_DELIMITERS, Emitter, normalizeStyles, addLeadingSlash, resolveComponentInstance, invokeArrayFns, removeLeadingSlash, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, SCHEME_RE, DATA_RE, cacheStringFunction, formatLog, parseQuery, ON_ERROR, callOptions, ON_UNHANDLE_REJECTION, ON_PAGE_NOT_FOUND, PRIMARY_COLOR, getLen, ON_THEME_CHANGE, TABBAR_HEIGHT, NAVBAR_HEIGHT, sortObject, OFF_THEME_CHANGE, ON_KEYBOARD_HEIGHT_CHANGE, normalizeTabBarStyles, ON_NAVIGATION_BAR_BUTTON_TAP, stringifyQuery as stringifyQuery$1, debounce, ON_PULL_DOWN_REFRESH, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_BACK_PRESS, UniNode, NODE_TYPE_PAGE, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_PAGE_SCROLL, ACTION_TYPE_INSERT, ACTION_TYPE_CREATE, ACTION_TYPE_REMOVE, ACTION_TYPE_ADD_EVENT, ACTION_TYPE_ADD_WXS_EVENT, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_SET_TEXT, ON_READY, ON_UNLOAD, EventChannel, ON_REACH_BOTTOM_DISTANCE, parseUrl, onCreateVueApp, ON_TAB_ITEM_TAP, ON_LAUNCH, ACTION_TYPE_EVENT, createUniEvent, ON_WXS_INVOKE_CALL_METHOD, WEB_INVOKE_APPSERVICE } from '@dcloudio/uni-shared';
import { ref, createVNode, render, injectHook, queuePostFlushCb, getCurrentInstance, onMounted, nextTick, onBeforeUnmount } from 'vue';
/*
......@@ -577,7 +577,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + '\n' + errMsg.stack);
return errMsg.message;
}
return errMsg;
......
import { normalizeStyles, addLeadingSlash, invokeArrayFns, LINEFEED, SCHEME_RE, DATA_RE, cacheStringFunction, parseQuery, Emitter, ON_UNHANDLE_REJECTION, ON_PAGE_NOT_FOUND, ON_ERROR, ON_SHOW, ON_HIDE, removeLeadingSlash, getLen, EventChannel, once, ON_UNLOAD, ON_READY, ON_PAGE_SCROLL, ON_PULL_DOWN_REFRESH, ON_REACH_BOTTOM, ON_RESIZE, parseUrl, ON_BACK_PRESS, ON_LAUNCH } from "@dcloudio/uni-shared";
import { normalizeStyles, addLeadingSlash, invokeArrayFns, SCHEME_RE, DATA_RE, cacheStringFunction, parseQuery, Emitter, ON_UNHANDLE_REJECTION, ON_PAGE_NOT_FOUND, ON_ERROR, ON_SHOW, ON_HIDE, removeLeadingSlash, getLen, EventChannel, once, ON_UNLOAD, ON_READY, ON_PAGE_SCROLL, ON_PULL_DOWN_REFRESH, ON_REACH_BOTTOM, ON_RESIZE, parseUrl, ON_BACK_PRESS, ON_LAUNCH } from "@dcloudio/uni-shared";
import { extend, isString, isPlainObject, isFunction as isFunction$1, isArray, isPromise, hasOwn, remove, capitalize, toTypeString, toRawType, parseStringStyle } from "@vue/shared";
import { createVNode, render, injectHook, getCurrentInstance, defineComponent, warn, isInSSRComponentSetup, ref, watchEffect, watch, computed, onMounted, camelize, onUnmounted, reactive, nextTick } from "vue";
function getCurrentPage() {
......@@ -420,7 +420,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + "\n" + errMsg.stack);
return errMsg.message;
}
return errMsg;
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend, remove } from '@vue/shared';
import { LINEFEED, Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
import { Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
import { normalizeLocale, LOCALE_EN } from '@dcloudio/uni-i18n';
function getBaseSystemInfo() {
......@@ -407,7 +407,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + '\n' + errMsg.stack);
return errMsg.message;
}
return errMsg;
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend, remove } from '@vue/shared';
import { normalizeLocale, LOCALE_EN } from '@dcloudio/uni-i18n';
import { LINEFEED, Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
import { Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
function getBaseSystemInfo() {
return swan.getSystemInfoSync();
......@@ -407,7 +407,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + '\n' + errMsg.stack);
return errMsg.message;
}
return errMsg;
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend, remove } from '@vue/shared';
import { normalizeLocale, LOCALE_EN } from '@dcloudio/uni-i18n';
import { LINEFEED, Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
import { Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
function getBaseSystemInfo() {
return jd.getSystemInfoSync();
......@@ -407,7 +407,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + '\n' + errMsg.stack);
return errMsg.message;
}
return errMsg;
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend, remove } from '@vue/shared';
import { normalizeLocale, LOCALE_EN } from '@dcloudio/uni-i18n';
import { LINEFEED, Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
import { Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
function getBaseSystemInfo() {
return ks.getSystemInfoSync();
......@@ -407,7 +407,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + '\n' + errMsg.stack);
return errMsg.message;
}
return errMsg;
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend, remove } from '@vue/shared';
import { normalizeLocale, LOCALE_EN } from '@dcloudio/uni-i18n';
import { LINEFEED, Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
import { Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
function getBaseSystemInfo() {
return tt.getSystemInfoSync();
......@@ -407,7 +407,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + '\n' + errMsg.stack);
return errMsg.message;
}
return errMsg;
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend, remove } from '@vue/shared';
import { normalizeLocale, LOCALE_EN } from '@dcloudio/uni-i18n';
import { LINEFEED, Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
import { Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
function getBaseSystemInfo() {
return qq.getSystemInfoSync();
......@@ -407,7 +407,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + '\n' + errMsg.stack);
return errMsg.message;
}
return errMsg;
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend, remove } from '@vue/shared';
import { normalizeLocale, LOCALE_EN } from '@dcloudio/uni-i18n';
import { LINEFEED, Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
import { Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
function getBaseSystemInfo() {
return tt.getSystemInfoSync();
......@@ -407,7 +407,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + '\n' + errMsg.stack);
return errMsg.message;
}
return errMsg;
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend, remove } from '@vue/shared';
import { normalizeLocale, LOCALE_EN } from '@dcloudio/uni-i18n';
import { LINEFEED, Emitter, sortObject, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
import { Emitter, sortObject, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
function getBaseSystemInfo() {
return wx.getSystemInfoSync();
......@@ -407,7 +407,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + '\n' + errMsg.stack);
return errMsg.message;
}
return errMsg;
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend, remove } from '@vue/shared';
import { normalizeLocale, LOCALE_EN } from '@dcloudio/uni-i18n';
import { LINEFEED, Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
import { Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
function getBaseSystemInfo() {
return xhs.getSystemInfoSync();
......@@ -407,7 +407,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + '\n' + errMsg.stack);
return errMsg.message;
}
return errMsg;
......
import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isFunction, isPromise, extend, remove } from '@vue/shared';
import { normalizeLocale, LOCALE_EN } from '@dcloudio/uni-i18n';
import { LINEFEED, Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
import { Emitter, onCreateVueApp, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
function getBaseSystemInfo() {
return qa.getSystemInfoSync();
......@@ -407,7 +407,7 @@ function normalizeErrMsg(errMsg) {
return errMsg;
}
if (errMsg.stack) {
console.error(errMsg.message + LINEFEED + errMsg.stack);
console.error(errMsg.message + '\n' + errMsg.stack);
return errMsg.message;
}
return errMsg;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册