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

chore: Array.isArray => isArray

上级 4ce56f57
......@@ -13,6 +13,9 @@
"bugs": {
"url": "https://github.com/dcloudio/uni-app/issues"
},
"dependencies": {
"@vue/shared": "3.2.37"
},
"devDependencies": {
"@dcloudio/uni-shared": "3.0.0-alpha-3041320220531001"
}
......
import { isArray } from '@vue/shared'
import { Emitter } from '@dcloudio/uni-shared'
import { defineSyncApi } from '../../helpers/api'
import {
......@@ -44,7 +45,7 @@ export const $off = defineSyncApi<API_TYPE_OFF>(
emitter.e = {}
return
}
if (!Array.isArray(name)) name = [name]
if (!isArray(name)) name = [name]
name.forEach((n) => emitter.off(n, callback))
},
OffProtocol
......
import { ComponentInternalInstance, ComponentPublicInstance } from 'vue'
import { isArray } from '@vue/shared'
import { resolveComponentInstance } from '@dcloudio/uni-shared'
import { getCurrentPageVm, getPageIdByVm } from '@dcloudio/uni-core'
import { requestComponentInfo } from '@dcloudio/uni-platform'
......@@ -139,7 +140,7 @@ class SelectorQuery implements UniApp.SelectorQuery {
(res: Array<SelectorQueryNodeInfo | null>) => {
const queueCbs = this._queueCb
res.forEach((result, index) => {
if (Array.isArray(result)) {
if (isArray(result)) {
result.forEach(convertContext)
} else {
convertContext(result)
......
import { isArray as isArray$1, hasOwn as hasOwn$1, isString, isPlainObject, isObject as isObject$1, toRawType, capitalize, makeMap, isFunction, isPromise, extend, remove, toTypeString } from '@vue/shared';
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, 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, parseQuery, ON_ERROR, callOptions, ON_UNHANDLE_REJECTION, ON_PAGE_NOT_FOUND, PRIMARY_COLOR, getLen, formatLog, TABBAR_HEIGHT, NAVBAR_HEIGHT, sortObject, ON_THEME_CHANGE, ON_KEYBOARD_HEIGHT_CHANGE, BACKGROUND_COLOR, 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, injectHook, createVNode, render, queuePostFlushCb, getCurrentInstance, onMounted, nextTick, onBeforeUnmount } from 'vue';
......@@ -97,7 +97,7 @@ function elemInArray(str, arr) {
return str;
}
function elemsInArray(strArr, optionalVal) {
if (!isArray$1(strArr) ||
if (!isArray(strArr) ||
strArr.length === 0 ||
strArr.find((val) => optionalVal.indexOf(val) === -1)) {
return optionalVal;
......@@ -122,7 +122,7 @@ function validateProtocols(name, args, protocol, onFail) {
if (!protocol) {
return;
}
if (!isArray$1(protocol)) {
if (!isArray(protocol)) {
return validateProtocol(name, args[0] || Object.create(null), protocol, onFail);
}
const len = protocol.length;
......@@ -152,7 +152,7 @@ function validateProp(name, value, prop, isAbsent) {
// type check
if (type != null) {
let isValid = false;
const types = isArray$1(type) ? type : [type];
const types = isArray(type) ? type : [type];
const expectedTypes = [];
// value is valid as long as one of the specified types match
for (let i = 0; i < types.length && !isValid; i++) {
......@@ -185,7 +185,7 @@ function assertType(value, type) {
valid = isObject$1(value);
}
else if (expectedType === 'Array') {
valid = isArray$1(value);
valid = isArray(value);
}
else {
{
......@@ -393,7 +393,7 @@ function queue(hooks, data) {
function wrapperOptions(interceptors, options = {}) {
[HOOK_SUCCESS, HOOK_FAIL, HOOK_COMPLETE].forEach((name) => {
const hooks = interceptors[name];
if (!isArray$1(hooks)) {
if (!isArray(hooks)) {
return;
}
const oldCallback = options[name];
......@@ -407,11 +407,11 @@ function wrapperOptions(interceptors, options = {}) {
}
function wrapperReturnValue(method, returnValue) {
const returnValueHooks = [];
if (isArray$1(globalInterceptors.returnValue)) {
if (isArray(globalInterceptors.returnValue)) {
returnValueHooks.push(...globalInterceptors.returnValue);
}
const interceptor = scopedInterceptors[method];
if (interceptor && isArray$1(interceptor.returnValue)) {
if (interceptor && isArray(interceptor.returnValue)) {
returnValueHooks.push(...interceptor.returnValue);
}
returnValueHooks.forEach((hook) => {
......@@ -439,7 +439,7 @@ function getApiInterceptorHooks(method) {
function invokeApi(method, api, options, params) {
const interceptor = getApiInterceptorHooks(method);
if (interceptor && Object.keys(interceptor).length) {
if (isArray$1(interceptor.invoke)) {
if (isArray(interceptor.invoke)) {
const res = queue(interceptor.invoke, options);
return res.then((options) => {
return api(wrapperOptions(interceptor, options), ...params);
......@@ -698,7 +698,7 @@ function findNVueElementIds(reqs) {
}
function findNVueElementInfos(ids, elm, infos) {
const nodes = elm.children;
if (!isArray$1(nodes)) {
if (!isArray(nodes)) {
return false;
}
for (let i = 0; i < nodes.length; i++) {
......@@ -741,7 +741,6 @@ function setCurrentPageMeta(page, options) {
UniServiceJSBridge.invokeViewMethod('setPageMeta', options, page.$page.id);
}
const isArray = Array.isArray;
const isObject = (val) => val !== null && typeof val === 'object';
const defaultDelimiters = ['{', '}'];
class BaseFormatter {
......@@ -803,7 +802,7 @@ function parse(format, [startDelimiter, endDelimiter]) {
function compile(tokens, values) {
const compiled = [];
let index = 0;
const mode = isArray(values)
const mode = Array.isArray(values)
? 'list'
: isObject(values)
? 'named'
......@@ -1558,7 +1557,7 @@ function initPageInternalInstance(openType, url, pageQuery, meta, eventChannel)
function removeHook(vm, name, hook) {
const hooks = vm.$[name];
if (!isArray$1(hooks)) {
if (!isArray(hooks)) {
return;
}
if (hook.__weh) {
......@@ -9225,7 +9224,7 @@ function removeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach((name) => {
const hooks = interceptors[name];
const hook = interceptor[name];
if (isArray$1(hooks) && isFunction(hook)) {
if (isArray(hooks) && isFunction(hook)) {
remove(hooks, hook);
}
});
......@@ -9234,7 +9233,7 @@ function mergeHook(parentVal, childVal) {
const res = childVal
? parentVal
? parentVal.concat(childVal)
: isArray$1(childVal)
: isArray(childVal)
? childVal
: [childVal]
: parentVal;
......@@ -9321,7 +9320,7 @@ const $off = defineSyncApi(API_OFF, (name, callback) => {
emitter.e = {};
return;
}
if (!Array.isArray(name))
if (!isArray(name))
name = [name];
name.forEach((n) => emitter.off(n, callback));
}, OffProtocol);
......@@ -10747,7 +10746,7 @@ class SelectorQuery {
requestComponentInfo(this._page, this._queue, (res) => {
const queueCbs = this._queueCb;
res.forEach((result, index) => {
if (Array.isArray(result)) {
if (isArray(result)) {
result.forEach(convertContext);
}
else {
......@@ -12714,8 +12713,8 @@ function warpPlusMethod(plusObject, before, after) {
}));
};
}
function isTabBarPage$1(path = '') {
if (!(__uniConfig.tabBar && Array.isArray(__uniConfig.tabBar.list))) {
function isTabBarPage(path = '') {
if (!(__uniConfig.tabBar && isArray(__uniConfig.tabBar.list))) {
return false;
}
try {
......@@ -13237,35 +13236,6 @@ function getPullDownRefreshWebview() {
}
function setPullDownRefreshWebview(webview) {
pullDownRefreshWebview = webview;
}
function isTabBarPage(path = '') {
if (!(__uniConfig.tabBar && Array.isArray(__uniConfig.tabBar.list))) {
return false;
}
try {
if (!path) {
const pages = getCurrentPages();
if (!pages.length) {
return false;
}
const page = pages[pages.length - 1];
if (!page) {
return false;
}
return page.$page.meta.isTabBar;
}
if (!/^\//.test(path)) {
path = addLeadingSlash(path);
}
const route = __uniRoutes.find((route) => route.path === path);
return route && route.meta.isTabBar;
}
catch (e) {
if (process.env.NODE_ENV !== 'production') {
console.log('getCurrentPages is not ready');
}
}
return false;
}
function getStatusbarHeight() {
......@@ -13328,7 +13298,7 @@ const getWindowInfo = defineSyncApi('getWindowInfo', () => {
height: 0,
cover: false,
};
if (isTabBarPage$1()) {
if (isTabBarPage()) {
tabBarView.height = tabBarInstance.visible ? tabBarInstance.height : 0;
tabBarView.cover = tabBarInstance.cover;
}
......@@ -14610,7 +14580,7 @@ function formatResponse(res, args) {
if (isPlainObject(res.header)) {
res.header = Object.keys(res.header).reduce(function (ret, key) {
const value = res.header[key];
if (Array.isArray(value)) {
if (isArray(value)) {
ret[key] = value.join(',');
}
else if (typeof value === 'string') {
......@@ -14792,7 +14762,7 @@ function createSocketTask(args) {
socket.WebSocket({
id: socketId,
url: args.url,
protocol: Array.isArray(args.protocols)
protocol: isArray(args.protocols)
? args.protocols.join(',')
: args.protocols,
header: args.header,
......@@ -17496,7 +17466,7 @@ function initTitleNView(webviewStyle, routeMeta) {
else if (name === 'titleImage' && value) {
titleNView.tags = createTitleImageTags(value);
}
else if (name === 'buttons' && isArray$1(value)) {
else if (name === 'buttons' && isArray(value)) {
titleNView.buttons = value.map((button, index) => {
button.onclick = createTitleNViewBtnClick(index);
return button;
......@@ -17858,7 +17828,7 @@ function initSubNVues(webview, path, routeMeta) {
}
else if (isPopup) {
style.position = 'absolute';
if (isTabBarPage$1(path)) {
if (isTabBarPage(path)) {
maskWebview = tabBarInstance;
}
else {
......@@ -19243,7 +19213,7 @@ function publishHandler(event, args, pageIds) {
if ((process.env.NODE_ENV !== 'production')) {
console.log(formatLog('publishHandler', event, args, pageIds));
}
if (!isArray$1(pageIds)) {
if (!isArray(pageIds)) {
pageIds = [pageIds];
}
const evalJSCode = `typeof UniViewJSBridge !== 'undefined' && UniViewJSBridge.subscribeHandler("${event}",${args},__PAGE_ID__)`;
......
import { extend } from '@vue/shared'
import { extend, isArray } from '@vue/shared'
import { addLeadingSlash, formatLog } from '@dcloudio/uni-shared'
import { getRouteOptions } from '@dcloudio/uni-core'
interface PlusResult extends Record<string, any> {
......@@ -67,7 +67,7 @@ export function warpPlusMethod(
}
export function isTabBarPage(path = '') {
if (!(__uniConfig.tabBar && Array.isArray(__uniConfig.tabBar.list))) {
if (!(__uniConfig.tabBar && isArray(__uniConfig.tabBar.list))) {
return false
}
try {
......
import { hasOwn, isPlainObject } from '@vue/shared'
import { hasOwn, isArray, isPlainObject } from '@vue/shared'
import {
API_REQUEST,
API_TYPE_REQUEST,
......@@ -62,7 +62,7 @@ function formatResponse(res: RequestTaskState, args: UniApp.RequestOptions) {
if (isPlainObject(res.header)) {
res.header = Object.keys(res.header).reduce(function (ret, key) {
const value = res.header[key]
if (Array.isArray(value)) {
if (isArray(value)) {
;(ret as any)[key] = value.join(',')
} else if (typeof value === 'string') {
;(ret as any)[key] = value
......
......@@ -15,7 +15,7 @@ import {
} from '@dcloudio/uni-api'
import { requireNativePlugin } from '../plugin/requireNativePlugin'
import { base64ToArrayBuffer, arrayBufferToBase64 } from '@dcloudio/uni-api'
import { extend, capitalize } from '@vue/shared'
import { extend, capitalize, isArray } from '@vue/shared'
import { callOptions } from '@dcloudio/uni-shared'
type Socket = {
......@@ -73,7 +73,7 @@ function createSocketTask(args: UniApp.ConnectSocketOption) {
socket.WebSocket({
id: socketId,
url: args.url,
protocol: Array.isArray(args.protocols)
protocol: isArray(args.protocols)
? args.protocols.join(',')
: args.protocols,
header: args.header,
......
......@@ -31,10 +31,10 @@ import {
ShowTabBarRedDotOptions,
ShowTabBarRedDotProtocol,
} from '@dcloudio/uni-api'
import { isTabBarPage } from '../../utils'
import tabBar from '../../framework/app/tabBar'
import { removeLeadingSlash } from '@dcloudio/uni-shared'
import { normalizeTabBarRoute } from '@dcloudio/uni-core'
import { isTabBarPage } from '../../../helpers/plus'
export const setTabBarBadge = defineAsyncApi<API_TYPE_SET_TAB_BAR_BADGE>(
API_SET_TAB_BAR_BADGE,
......
import { getCurrentPage } from '@dcloudio/uni-core'
import { addLeadingSlash } from '@dcloudio/uni-shared'
import { ComponentPublicInstance } from 'vue'
export function getCurrentWebview() {
......@@ -28,32 +27,3 @@ export function setPullDownRefreshWebview(
) {
pullDownRefreshWebview = webview
}
export function isTabBarPage(path = '') {
if (!(__uniConfig.tabBar && Array.isArray(__uniConfig.tabBar.list))) {
return false
}
try {
if (!path) {
const pages = getCurrentPages()
if (!pages.length) {
return false
}
const page = pages[pages.length - 1]
if (!page) {
return false
}
return page.$page.meta.isTabBar
}
if (!/^\//.test(path)) {
path = addLeadingSlash(path)
}
const route = __uniRoutes.find((route) => route.path === path)
return route && route.meta.isTabBar
} catch (e) {
if (process.env.NODE_ENV !== 'production') {
console.log('getCurrentPages is not ready')
}
}
return false
}
import { Ref, ref, watch, onBeforeUnmount, ExtractPropTypes, inject } from 'vue'
import { isArray } from '@vue/shared'
import {
defineBuiltInComponent,
useCustomEvent,
......@@ -156,10 +157,10 @@ export default /*#__PURE__*/ defineBuiltInComponent({
switch (props.mode) {
case mode.MULTISELECTOR:
{
if (!Array.isArray(val)) {
if (!isArray(val)) {
val = []
}
if (!Array.isArray(valueSync.value)) {
if (!isArray(valueSync.value)) {
valueSync.value = []
}
const length = (valueSync.value.length = Math.max(
......@@ -300,7 +301,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
valueSync.value = 0
break
case mode.MULTISELECTOR:
Array.isArray(props.value) &&
isArray(props.value) &&
(valueSync.value = props.value.map((val) => 0))
break
case mode.DATE:
......
......@@ -116,7 +116,7 @@ export function normalizePagesJson(
}
export function validatePages(pagesJson: Record<string, any>, jsonStr: string) {
if (!Array.isArray(pagesJson.pages)) {
if (!isArray(pagesJson.pages)) {
pagesJson.pages = []
throw new Error(`[uni-app] Error: pages.json->pages parse failed.`)
} else if (!pagesJson.pages.length) {
......@@ -160,7 +160,7 @@ function normalizeSubpackages(
subpackages?: UniApp.PagesJsonSubpackagesOptions[]
) {
const pages: UniApp.PagesJsonPageOptions[] = []
if (Array.isArray(subpackages)) {
if (isArray(subpackages)) {
subpackages.forEach(({ root, pages: subPages }) => {
if (root && subPages.length) {
subPages.forEach((subPage) => {
......
......@@ -13,7 +13,7 @@ import {
import { AcornNode } from 'rollup'
import { walk } from 'estree-walker'
import { extend } from '@vue/shared'
import { extend, isArray } from '@vue/shared'
import MagicString from 'magic-string'
import {
......@@ -119,7 +119,7 @@ export function uniViteInjectPlugin(
if (mods.length === 2) {
mod = namespaceModulesMap.get(mods[0] + '.')
if (mod) {
if (Array.isArray(mod)) {
if (isArray(mod)) {
const testFn = mod[1] as unknown as (method: string) => boolean
if (testFn(mods[1])) {
mod = [mod[0], mods[1]]
......@@ -257,7 +257,7 @@ function normalizeModulesMap(
modulesMap.forEach((mod, key) => {
modulesMap.set(
key,
Array.isArray(mod)
isArray(mod)
? [mod[0].split(sep).join('/'), mod[1]]
: mod.split(sep).join('/')
)
......
......@@ -40,6 +40,7 @@ import { transform, formatMessages } from 'esbuild'
import { preCss, preNVueCss } from '../../../../preprocess'
import { PAGES_JSON_JS } from '../../../../constants'
import { emptyCssComments } from '../cleanString'
import { isArray } from '@vue/shared'
// const debug = createDebugger('vite:css')
export interface CSSOptions {
......@@ -1032,7 +1033,7 @@ const scss: SassStylePreprocessor = async (
}
const importer = [internalImporter]
if (options.importer) {
Array.isArray(options.importer)
isArray(options.importer)
? importer.push(...options.importer)
: importer.push(options.importer)
}
......
import type { Plugin, ResolvedConfig } from 'vite'
import { extend } from '@vue/shared'
import { extend, isArray } from '@vue/shared'
import { assetPlugin } from '../plugins/vitejs/plugins/asset'
import { cssPlugin } from '../plugins/vitejs/plugins/css'
......@@ -47,7 +47,7 @@ export function removePlugins(
plugins: string | string[],
config: ResolvedConfig
) {
if (!Array.isArray(plugins)) {
if (!isArray(plugins)) {
plugins = [plugins]
}
plugins.forEach((name) => {
......
import fs from 'fs-extra'
import path from 'path'
import { FSWatcher, watch, WatchOptions } from 'chokidar'
import { isArray } from '@vue/shared'
type FileTransform = (source: Buffer, filename: string) => void | string
export interface FileWatcherOptions {
src: string | string[]
......@@ -16,7 +17,7 @@ export class FileWatcher {
private watcher!: FSWatcher
private onChange?: () => void
constructor({ src, dest, transform, verbose }: FileWatcherOptions) {
this.src = !Array.isArray(src) ? [src] : src
this.src = !isArray(src) ? [src] : src
this.dest = dest
this.transform = transform
this.verbose = verbose
......
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const shared_1 = require("@vue/shared");
const uni_shared_1 = require("@dcloudio/uni-shared");
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
const validateFunction_1 = require("./validateFunction");
......@@ -66,7 +67,7 @@ function initUniCloudEnv() {
}
try {
const spaces = JSON.parse(process.env.UNI_CLOUD_SPACES);
if (!Array.isArray(spaces)) {
if (!(0, shared_1.isArray)(spaces)) {
return;
}
spaces.forEach((s) => uniCloudSpaces.push(s));
......
......@@ -22,6 +22,7 @@
"dependencies": {
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3041320220531001",
"@dcloudio/uni-i18n": "3.0.0-alpha-3041320220531001",
"@dcloudio/uni-shared": "3.0.0-alpha-3041320220531001"
"@dcloudio/uni-shared": "3.0.0-alpha-3041320220531001",
"@vue/shared": "3.2.37"
}
}
import { isArray } from '@vue/shared'
import { once } from '@dcloudio/uni-shared'
import {
COMMON_EXCLUDE,
......@@ -92,7 +93,7 @@ function initUniCloudEnv() {
}
try {
const spaces = JSON.parse(process.env.UNI_CLOUD_SPACES)
if (!Array.isArray(spaces)) {
if (!isArray(spaces)) {
return
}
spaces.forEach((s) => uniCloudSpaces.push(s))
......
import { createElementVNode, defineComponent, createVNode, mergeProps, getCurrentInstance, provide, watch, onUnmounted, shallowRef, reactive, watchEffect, ref, inject, onBeforeUnmount, computed, Text as Text$1, isVNode, Fragment, onMounted, resolveComponent, parseClassList } from "vue";
import { extend, hasOwn, isPlainObject } from "@vue/shared";
import { extend, hasOwn, isPlainObject, isArray } from "@vue/shared";
import { cacheStringFunction, PRIMARY_COLOR } from "@dcloudio/uni-shared";
const OPEN_TYPES = [
"navigate",
......@@ -841,7 +841,7 @@ const movableAreaProps = {
};
function flatVNode(nodes) {
const array = [];
if (Array.isArray(nodes)) {
if (isArray(nodes)) {
nodes.forEach((vnode) => {
if (isVNode(vnode)) {
if (vnode.type === Fragment) {
......@@ -849,7 +849,7 @@ function flatVNode(nodes) {
} else {
array.push(vnode);
}
} else if (Array.isArray(vnode)) {
} else if (isArray(vnode)) {
array.push(...flatVNode(vnode));
}
});
......@@ -2221,7 +2221,7 @@ const pickerViewProps = {
return [];
},
validator: function(val) {
return Array.isArray(val) && val.filter((val2) => typeof val2 === "number").length === val.length;
return isArray(val) && val.filter((val2) => typeof val2 === "number").length === val.length;
}
},
indicatorStyle: {
......@@ -2686,10 +2686,10 @@ var Picker = /* @__PURE__ */ defineComponent({
switch (props2.mode) {
case mode.MULTISELECTOR:
{
if (!Array.isArray(val)) {
if (!isArray(val)) {
val = [];
}
if (!Array.isArray(valueSync.value)) {
if (!isArray(valueSync.value)) {
valueSync.value = [];
}
const length = valueSync.value.length = Math.max(val.length, props2.range.length);
......@@ -2792,7 +2792,7 @@ var Picker = /* @__PURE__ */ defineComponent({
valueSync.value = 0;
break;
case mode.MULTISELECTOR:
Array.isArray(props2.value) && (valueSync.value = props2.value.map((val) => 0));
isArray(props2.value) && (valueSync.value = props2.value.map((val) => 0));
break;
case mode.DATE:
case mode.TIME:
......@@ -3812,7 +3812,7 @@ function useResetNative(children) {
node.el.setValue("");
}
}
if (Array.isArray(node.children) && node.children && node.children.length) {
if (isArray(node.children) && node.children && node.children.length) {
getOrClearNativeValue(outResult, node.children);
}
});
......@@ -4539,7 +4539,7 @@ function normalizeNodes(nodes, instance, options) {
return nvueNode;
}
function normalizeNodes2(nodes2) {
if (Array.isArray(nodes2)) {
if (isArray(nodes2)) {
return nodes2.map((node) => normalizeNode(node));
}
return [];
......
......@@ -17,6 +17,8 @@ import { ssrRef, shallowSsrRef } from '@dcloudio/uni-app'
import { initVueI18n } from '@dcloudio/uni-i18n'
import messages from './i18n/index'
const isArray = Array.isArray
const { t } = initVueI18n(messages)
const events = {
......@@ -184,10 +186,10 @@ export default {
},
computed: {
collectionArgs () {
return Array.isArray(this.collection) ? this.collection : [this.collection]
return isArray(this.collection) ? this.collection : [this.collection]
},
isLookup () {
return (Array.isArray(this.collection) && this.collection.length > 1) || (typeof this.collection === 'string' && this.collection.indexOf(',') > -1)
return (isArray(this.collection) && this.collection.length > 1) || (typeof this.collection === 'string' && this.collection.indexOf(',') > -1)
},
mainCollection () {
if (typeof this.collection === 'string') {
......@@ -563,7 +565,7 @@ export default {
return
}
const ids = Array.isArray(id) ? id : [id]
const ids = isArray(id) ? id : [id]
if (!ids.length) {
return
}
......
......@@ -4,6 +4,7 @@ import {
ComponentInternalInstance,
WritableComputedRef,
} from 'vue'
import { isArray } from '@vue/shared'
export const pickerViewProps = {
value: {
......@@ -13,7 +14,7 @@ export const pickerViewProps = {
},
validator: function (val: any) {
return (
Array.isArray(val) &&
isArray(val) &&
val.filter((val) => typeof val === 'number').length === val.length
)
},
......
import { Fragment, VNode, isVNode } from 'vue'
import { isArray } from '@vue/shared'
export function flatVNode(nodes: any): VNode[] {
const array: VNode[] = []
if (Array.isArray(nodes)) {
if (isArray(nodes)) {
nodes.forEach((vnode) => {
if (isVNode(vnode)) {
if (vnode.type === Fragment) {
......@@ -10,7 +11,7 @@ export function flatVNode(nodes: any): VNode[] {
} else {
array.push(vnode)
}
} else if (Array.isArray(vnode)) {
} else if (isArray(vnode)) {
array.push(...flatVNode(vnode))
}
})
......
import { defineComponent, provide, ref, VNode } from 'vue'
import { isArray } from '@vue/shared'
import { useCustomEvent, EmitEvent } from '../../helpers/useNVueEvent'
import { uniFormKey, UniFormCtx, UniFormFieldCtx } from '../../components/form'
......@@ -73,11 +74,7 @@ function useResetNative(children?: VNode[]) {
node.el.setValue('')
}
}
if (
Array.isArray(node.children) &&
node.children &&
node.children.length
) {
if (isArray(node.children) && node.children && node.children.length) {
getOrClearNativeValue(outResult, node.children as VNode[])
}
})
......
import { extend } from '@vue/shared'
import { extend, isArray } from '@vue/shared'
import {
Ref,
ref,
......@@ -155,10 +155,10 @@ export default /*#__PURE__*/ defineComponent({
switch (props.mode) {
case mode.MULTISELECTOR:
{
if (!Array.isArray(val)) {
if (!isArray(val)) {
val = []
}
if (!Array.isArray(valueSync.value)) {
if (!isArray(valueSync.value)) {
valueSync.value = []
}
const length = (valueSync.value.length = Math.max(
......@@ -285,7 +285,7 @@ export default /*#__PURE__*/ defineComponent({
valueSync.value = 0
break
case mode.MULTISELECTOR:
Array.isArray(props.value) &&
isArray(props.value) &&
(valueSync.value = props.value.map((val) => 0))
break
case mode.DATE:
......
......@@ -6,6 +6,7 @@ import {
// @ts-ignore
parseClassList,
} from 'vue'
import { isArray } from '@vue/shared'
import { props, parseHtml } from '../../components/rich-text'
import { parseStyleText } from '../helpers'
......@@ -238,7 +239,7 @@ function normalizeNodes(
}
function normalizeNodes(nodes?: NvueNode[]) {
if (Array.isArray(nodes)) {
if (isArray(nodes)) {
return nodes.map((node) => normalizeNode(node))
}
return []
......
import { hasOwn, extend, isPlainObject } from '@vue/shared'
import { hasOwn, extend, isPlainObject, isArray } from '@vue/shared'
import { getRealPath } from '@dcloudio/uni-platform'
import { createTextVNode, h, VNode } from 'vue'
......@@ -142,7 +142,7 @@ export const nodeList2VNode = /*#__PURE__*/ (
triggerItemClick: Function,
nodeList?: Node[]
): Array<VNode | undefined> => {
if (!nodeList || (Array.isArray(nodeList) && !nodeList.length)) return []
if (!nodeList || (isArray(nodeList) && !nodeList.length)) return []
return nodeList.map((node) => {
if (!isPlainObject(node)) {
......
......@@ -3307,7 +3307,7 @@ const useAttrs = (params = {}) => {
};
function flatVNode(nodes) {
const array = [];
if (Array.isArray(nodes)) {
if (shared.isArray(nodes)) {
nodes.forEach((vnode) => {
if (vue.isVNode(vnode)) {
if (vnode.type === vue.Fragment) {
......@@ -3315,7 +3315,7 @@ function flatVNode(nodes) {
} else {
array.push(vnode);
}
} else if (Array.isArray(vnode)) {
} else if (shared.isArray(vnode)) {
array.push(...flatVNode(vnode));
}
});
......@@ -4407,7 +4407,7 @@ const pickerViewProps = {
return [];
},
validator: function(val) {
return Array.isArray(val) && val.filter((val2) => typeof val2 === "number").length === val.length;
return shared.isArray(val) && val.filter((val2) => typeof val2 === "number").length === val.length;
}
},
indicatorStyle: {
......@@ -5066,7 +5066,7 @@ function normalizeAttrs(tagName, attrs) {
}
}
const nodeList2VNode = (scopeId, triggerItemClick, nodeList) => {
if (!nodeList || Array.isArray(nodeList) && !nodeList.length)
if (!nodeList || shared.isArray(nodeList) && !nodeList.length)
return [];
return nodeList.map((node) => {
if (!shared.isPlainObject(node)) {
......@@ -7463,7 +7463,7 @@ function useDanmu(props2, videoState) {
time: 0,
index: -1
};
const danmuList = Array.isArray(props2.danmuList) ? JSON.parse(JSON.stringify(props2.danmuList)) : [];
const danmuList = shared.isArray(props2.danmuList) ? JSON.parse(JSON.stringify(props2.danmuList)) : [];
danmuList.sort(function(a, b) {
return (a.time || 0) - (b.time || 0);
});
......@@ -7961,7 +7961,7 @@ var MapMarker = /* @__PURE__ */ defineSystemComponent({
name: "MapMarker",
props: props$7,
setup(props2) {
const id = String(Number(props2.id) !== NaN ? props2.id : "");
const id = String(!isNaN(Number(props2.id)) ? props2.id : "");
const onMapReady = vue.inject("onMapReady");
const updateMarkerLabelStyle = useMarkerLabelStyle(id);
let marker;
......@@ -8691,7 +8691,7 @@ const props$2 = {
};
function getPoints(points) {
const newPoints = [];
if (Array.isArray(points)) {
if (shared.isArray(points)) {
points.forEach((point) => {
if (point && point.latitude && point.longitude) {
newPoints.push({
......@@ -9492,10 +9492,10 @@ function usePickerMethods(props2, state, trigger, rootRef, pickerRef, selectRef,
switch (props2.mode) {
case mode.MULTISELECTOR:
{
if (!Array.isArray(val)) {
if (!shared.isArray(val)) {
val = state.valueArray;
}
if (!Array.isArray(state.valueSync)) {
if (!shared.isArray(state.valueSync)) {
state.valueSync = [];
}
const length = state.valueSync.length = Math.max(val.length, props2.range.length);
......@@ -9560,7 +9560,7 @@ function usePickerMethods(props2, state, trigger, rootRef, pickerRef, selectRef,
_close();
state.valueChangeSource = "click";
const value = _getValue();
state.valueSync = Array.isArray(value) ? value.map((val) => val) : value;
state.valueSync = shared.isArray(value) ? value.map((val) => val) : value;
trigger("change", {}, {
value
});
......
......@@ -2137,7 +2137,7 @@ function getNodeInfo(el, fields2) {
info.height = rect.height;
}
}
if (Array.isArray(fields2.properties)) {
if (isArray(fields2.properties)) {
fields2.properties.forEach((prop) => {
prop = prop.replace(/-([a-z])/g, function(e2, t2) {
return t2.toUpperCase();
......@@ -2158,7 +2158,7 @@ function getNodeInfo(el, fields2) {
info.scrollWidth = 0;
}
}
if (Array.isArray(fields2.computedStyle)) {
if (isArray(fields2.computedStyle)) {
const sytle = getComputedStyle(el);
fields2.computedStyle.forEach((name) => {
info[name] = sytle[name];
......@@ -2977,7 +2977,7 @@ const $off = /* @__PURE__ */ defineSyncApi(API_OFF, (name, callback) => {
emitter.e = {};
return;
}
if (!Array.isArray(name))
if (!isArray(name))
name = [name];
name.forEach((n) => emitter.off(n, callback));
}, OffProtocol);
......@@ -4307,7 +4307,7 @@ class SelectorQuery {
requestComponentInfo(this._page, this._queue, (res) => {
const queueCbs = this._queueCb;
res.forEach((result, index2) => {
if (Array.isArray(result)) {
if (isArray(result)) {
result.forEach(convertContext);
} else {
convertContext(result);
......@@ -8892,7 +8892,7 @@ const useAttrs = (params = {}) => {
};
function flatVNode(nodes) {
const array = [];
if (Array.isArray(nodes)) {
if (isArray(nodes)) {
nodes.forEach((vnode) => {
if (isVNode(vnode)) {
if (vnode.type === Fragment) {
......@@ -8900,7 +8900,7 @@ function flatVNode(nodes) {
} else {
array.push(vnode);
}
} else if (Array.isArray(vnode)) {
} else if (isArray(vnode)) {
array.push(...flatVNode(vnode));
}
});
......@@ -10322,7 +10322,7 @@ const pickerViewProps = {
return [];
},
validator: function(val) {
return Array.isArray(val) && val.filter((val2) => typeof val2 === "number").length === val.length;
return isArray(val) && val.filter((val2) => typeof val2 === "number").length === val.length;
}
},
indicatorStyle: {
......@@ -11773,7 +11773,7 @@ function normalizeAttrs(tagName, attrs2) {
}
}
const nodeList2VNode = (scopeId, triggerItemClick, nodeList) => {
if (!nodeList || Array.isArray(nodeList) && !nodeList.length)
if (!nodeList || isArray(nodeList) && !nodeList.length)
return [];
return nodeList.map((node) => {
if (!isPlainObject(node)) {
......@@ -14846,7 +14846,7 @@ function useDanmu(props2, videoState) {
time: 0,
index: -1
};
const danmuList = Array.isArray(props2.danmuList) ? JSON.parse(JSON.stringify(props2.danmuList)) : [];
const danmuList = isArray(props2.danmuList) ? JSON.parse(JSON.stringify(props2.danmuList)) : [];
danmuList.sort(function(a2, b) {
return (a2.time || 0) - (b.time || 0);
});
......@@ -15594,7 +15594,7 @@ var MapMarker = /* @__PURE__ */ defineSystemComponent({
name: "MapMarker",
props: props$e,
setup(props2) {
const id2 = String(Number(props2.id) !== NaN ? props2.id : "");
const id2 = String(!isNaN(Number(props2.id)) ? props2.id : "");
const onMapReady = inject("onMapReady");
const updateMarkerLabelStyle = useMarkerLabelStyle(id2);
let marker;
......@@ -17894,7 +17894,7 @@ const uploadFile = /* @__PURE__ */ defineTaskApi(API_UPLOAD_FILE, ({
timeout = __uniConfig.networkTimeout.uploadFile
}, { resolve, reject }) => {
var uploadTask = new UploadTask();
if (!Array.isArray(files2) || !files2.length) {
if (!isArray(files2) || !files2.length) {
files2 = [
{
name,
......@@ -20619,7 +20619,7 @@ const props$2 = {
};
function getPoints(points) {
const newPoints = [];
if (Array.isArray(points)) {
if (isArray(points)) {
points.forEach((point) => {
if (point && point.latitude && point.longitude) {
newPoints.push({
......@@ -21487,10 +21487,10 @@ function usePickerMethods(props2, state2, trigger, rootRef, pickerRef, selectRef
switch (props2.mode) {
case mode.MULTISELECTOR:
{
if (!Array.isArray(val)) {
if (!isArray(val)) {
val = state2.valueArray;
}
if (!Array.isArray(state2.valueSync)) {
if (!isArray(state2.valueSync)) {
state2.valueSync = [];
}
const length = state2.valueSync.length = Math.max(val.length, props2.range.length);
......@@ -21555,7 +21555,7 @@ function usePickerMethods(props2, state2, trigger, rootRef, pickerRef, selectRef
_close();
state2.valueChangeSource = "click";
const value = _getValue();
state2.valueSync = Array.isArray(value) ? value.map((val) => val) : value;
state2.valueSync = isArray(value) ? value.map((val) => val) : value;
trigger("change", {}, {
value
});
......
import { urlToFile, blobToFile } from '../../../helpers/file'
import { isArray } from '@vue/shared'
import {
defineTaskApi,
API_UPLOAD_FILE,
......@@ -6,6 +7,7 @@ import {
UploadFileProtocol,
UploadFileOptions,
} from '@dcloudio/uni-api'
import { urlToFile, blobToFile } from '../../../helpers/file'
/**
* 上传任务
*/
......@@ -69,7 +71,7 @@ export const uploadFile = defineTaskApi<API_TYPE_UPLOAD_FILE>(
{ resolve, reject }
) => {
var uploadTask = new UploadTask()
if (!Array.isArray(files) || !files.length) {
if (!isArray(files) || !files.length) {
files = [
{
name,
......
import { ComponentPublicInstance } from 'vue'
import { isArray } from '@vue/shared'
import { getCustomDataset } from '@dcloudio/uni-shared'
import { getWindowOffset } from '@dcloudio/uni-core'
import { getContextInfo } from '@dcloudio/uni-components'
......@@ -61,7 +62,7 @@ function getNodeInfo(
}
}
// TODO 组件 props
if (Array.isArray(fields.properties)) {
if (isArray(fields.properties)) {
fields.properties.forEach((prop) => {
prop = prop.replace(/-([a-z])/g, function (e, t) {
return t.toUpperCase()
......@@ -83,7 +84,7 @@ function getNodeInfo(
info.scrollWidth = 0
}
}
if (Array.isArray(fields.computedStyle)) {
if (isArray(fields.computedStyle)) {
const sytle = getComputedStyle(el)
fields.computedStyle.forEach((name) => {
info[name as keyof CSSStyleDeclaration] =
......
import { extend } from '@vue/shared'
import { extend, isArray } from '@vue/shared'
import {
onMounted,
reactive,
......@@ -104,7 +104,7 @@ interface MapState {
function getPoints(points: Point[]): Point[] {
const newPoints: Point[] = []
if (Array.isArray(points)) {
if (isArray(points)) {
points.forEach((point) => {
if (point && point.latitude && point.longitude) {
newPoints.push({
......
......@@ -14,6 +14,7 @@ import {
onMounted,
StyleValue,
} from 'vue'
import { isArray } from '@vue/shared'
import {
useBooleanAttr,
useCustomEvent,
......@@ -619,10 +620,10 @@ function usePickerMethods(
switch (props.mode) {
case mode.MULTISELECTOR:
{
if (!Array.isArray(val)) {
if (!isArray(val)) {
val = state.valueArray
}
if (!Array.isArray(state.valueSync)) {
if (!isArray(state.valueSync)) {
state.valueSync = []
}
const length = (state.valueSync.length = Math.max(
......@@ -710,7 +711,7 @@ function usePickerMethods(
_close()
state.valueChangeSource = 'click'
const value = _getValue()
state.valueSync = Array.isArray(value) ? value.map((val) => val) : value
state.valueSync = isArray(value) ? value.map((val) => val) : value
trigger('change', {} as Event, {
value,
})
......
......@@ -9,6 +9,7 @@ import {
renderList,
onBeforeUnmount,
} from 'vue'
import { isArray } from '@vue/shared'
import { passive } from '@dcloudio/uni-shared'
import { useI18n, initI18nVideoMsgsOnce } from '@dcloudio/uni-core'
import { getRealPath } from '@dcloudio/uni-platform'
......@@ -588,7 +589,7 @@ function useDanmu(
color?: string
time?: number
}
const danmuList: Danmu[] = Array.isArray(props.danmuList)
const danmuList: Danmu[] = isArray(props.danmuList)
? JSON.parse(JSON.stringify(props.danmuList))
: []
danmuList.sort(function (a: Danmu, b: Danmu) {
......
......@@ -2,7 +2,6 @@
Object.defineProperty(exports, '__esModule', { value: true });
const isArray = Array.isArray;
const isObject = (val) => val !== null && typeof val === 'object';
const defaultDelimiters = ['{', '}'];
class BaseFormatter {
......@@ -64,7 +63,7 @@ function parse(format, [startDelimiter, endDelimiter]) {
function compile(tokens, values) {
const compiled = [];
let index = 0;
const mode = isArray(values)
const mode = Array.isArray(values)
? 'list'
: isObject(values)
? 'named'
......@@ -423,7 +422,7 @@ function compileJsonObj(jsonObj, localeValues, delimiters) {
return jsonObj;
}
function walkJsonObj(jsonObj, walk) {
if (isArray(jsonObj)) {
if (Array.isArray(jsonObj)) {
for (let i = 0; i < jsonObj.length; i++) {
if (walk(jsonObj, i)) {
return true;
......
const isArray = Array.isArray;
const isObject = (val) => val !== null && typeof val === 'object';
const defaultDelimiters = ['{', '}'];
class BaseFormatter {
......@@ -60,7 +59,7 @@ function parse(format, [startDelimiter, endDelimiter]) {
function compile(tokens, values) {
const compiled = [];
let index = 0;
const mode = isArray(values)
const mode = Array.isArray(values)
? 'list'
: isObject(values)
? 'named'
......@@ -419,7 +418,7 @@ function compileJsonObj(jsonObj, localeValues, delimiters) {
return jsonObj;
}
function walkJsonObj(jsonObj, walk) {
if (isArray(jsonObj)) {
if (Array.isArray(jsonObj)) {
for (let i = 0; i < jsonObj.length; i++) {
if (walk(jsonObj, i)) {
return true;
......
export const isArray = Array.isArray
export const isObject = (val: unknown): val is Record<any, any> =>
val !== null && typeof val === 'object'
......@@ -89,7 +88,7 @@ export function compile(
const compiled: Array<unknown> = []
let index: number = 0
const mode: string = isArray(values)
const mode: string = Array.isArray(values)
? 'list'
: isObject(values)
? 'named'
......
import { isArray, isObject, default as BaseFormatter } from './format'
import { isObject, default as BaseFormatter } from './format'
import { Formatter } from './I18n'
export const isString = (val: unknown): val is string => typeof val === 'string'
......@@ -157,7 +157,7 @@ type WalkJson = (
) => void | boolean
function walkJsonObj(jsonObj: unknown, walk: WalkJson) {
if (isArray(jsonObj)) {
if (Array.isArray(jsonObj)) {
for (let i = 0; i < jsonObj.length; i++) {
if (walk(jsonObj, i)) {
return true
......
......@@ -531,7 +531,7 @@ const $off = defineSyncApi(API_OFF, (name, callback) => {
emitter.e = {};
return;
}
if (!Array.isArray(name))
if (!isArray(name))
name = [name];
name.forEach((n) => emitter.off(n, callback));
}, OffProtocol);
......
......@@ -531,7 +531,7 @@ const $off = defineSyncApi(API_OFF, (name, callback) => {
emitter.e = {};
return;
}
if (!Array.isArray(name))
if (!isArray(name))
name = [name];
name.forEach((n) => emitter.off(n, callback));
}, OffProtocol);
......
......@@ -531,7 +531,7 @@ const $off = defineSyncApi(API_OFF, (name, callback) => {
emitter.e = {};
return;
}
if (!Array.isArray(name))
if (!isArray(name))
name = [name];
name.forEach((n) => emitter.off(n, callback));
}, OffProtocol);
......
......@@ -531,7 +531,7 @@ const $off = defineSyncApi(API_OFF, (name, callback) => {
emitter.e = {};
return;
}
if (!Array.isArray(name))
if (!isArray(name))
name = [name];
name.forEach((n) => emitter.off(n, callback));
}, OffProtocol);
......
......@@ -531,7 +531,7 @@ const $off = defineSyncApi(API_OFF, (name, callback) => {
emitter.e = {};
return;
}
if (!Array.isArray(name))
if (!isArray(name))
name = [name];
name.forEach((n) => emitter.off(n, callback));
}, OffProtocol);
......
......@@ -531,7 +531,7 @@ const $off = defineSyncApi(API_OFF, (name, callback) => {
emitter.e = {};
return;
}
if (!Array.isArray(name))
if (!isArray(name))
name = [name];
name.forEach((n) => emitter.off(n, callback));
}, OffProtocol);
......
......@@ -495,7 +495,7 @@ const $off = defineSyncApi(API_OFF, (name, callback) => {
emitter.e = {};
return;
}
if (!Array.isArray(name))
if (!isArray(name))
name = [name];
name.forEach((n) => emitter.off(n, callback));
}, OffProtocol);
......
......@@ -531,7 +531,7 @@ const $off = defineSyncApi(API_OFF, (name, callback) => {
emitter.e = {};
return;
}
if (!Array.isArray(name))
if (!isArray(name))
name = [name];
name.forEach((n) => emitter.off(n, callback));
}, OffProtocol);
......
......@@ -157,6 +157,9 @@ importers:
packages/uni-api:
specifiers:
'@dcloudio/uni-shared': 3.0.0-alpha-3041320220531001
'@vue/shared': 3.2.37
dependencies:
'@vue/shared': 3.2.37
devDependencies:
'@dcloudio/uni-shared': link:../uni-shared
......@@ -405,10 +408,12 @@ importers:
'@dcloudio/uni-cli-shared': 3.0.0-alpha-3041320220531001
'@dcloudio/uni-i18n': 3.0.0-alpha-3041320220531001
'@dcloudio/uni-shared': 3.0.0-alpha-3041320220531001
'@vue/shared': 3.2.37
dependencies:
'@dcloudio/uni-cli-shared': link:../uni-cli-shared
'@dcloudio/uni-i18n': link:../uni-i18n
'@dcloudio/uni-shared': link:../uni-shared
'@vue/shared': 3.2.37
packages/uni-components:
specifiers:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册