Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
31337c86
U
uni-app
项目概览
Velpro187
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
31337c86
编写于
7月 30, 2021
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
d2d61ee8
9a603b05
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
4011 addition
and
1413 deletion
+4011
-1413
packages/uni-mp-alipay/dist/uni.api.esm.js
packages/uni-mp-alipay/dist/uni.api.esm.js
+522
-207
packages/uni-mp-alipay/dist/uni.mp.esm.js
packages/uni-mp-alipay/dist/uni.mp.esm.js
+187
-65
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+460
-142
packages/uni-mp-baidu/dist/uni.mp.esm.js
packages/uni-mp-baidu/dist/uni.mp.esm.js
+222
-100
packages/uni-mp-qq/dist/uni.api.esm.js
packages/uni-mp-qq/dist/uni.api.esm.js
+442
-124
packages/uni-mp-qq/dist/uni.mp.esm.js
packages/uni-mp-qq/dist/uni.mp.esm.js
+222
-100
packages/uni-mp-toutiao/dist/uni.api.esm.js
packages/uni-mp-toutiao/dist/uni.api.esm.js
+450
-135
packages/uni-mp-toutiao/dist/uni.mp.esm.js
packages/uni-mp-toutiao/dist/uni.mp.esm.js
+222
-100
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+407
-126
packages/uni-mp-weixin/dist/uni.mp.esm.js
packages/uni-mp-weixin/dist/uni.mp.esm.js
+231
-109
packages/uni-quickapp-webview/dist/uni.api.esm.js
packages/uni-quickapp-webview/dist/uni.api.esm.js
+442
-124
packages/uni-quickapp-webview/dist/uni.mp.esm.js
packages/uni-quickapp-webview/dist/uni.mp.esm.js
+203
-81
packages/vue-cli-plugin-uni/lib/chain-webpack.js
packages/vue-cli-plugin-uni/lib/chain-webpack.js
+1
-0
未找到文件。
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
31337c86
此差异已折叠。
点击以展开。
packages/uni-mp-alipay/dist/uni.mp.esm.js
浏览文件 @
31337c86
import
{
isPlainObject
,
hasOwn
,
isArray
,
toNumber
,
isObject
,
capitalize
,
isFunction
,
extend
,
NOOP
,
EMPTY_OBJ
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
isArray
,
extend
,
hyphenate
,
isObject
,
hasOwn
,
toNumber
,
capitalize
,
isFunction
,
NOOP
,
EMPTY_OBJ
,
camelize
}
from
'
@vue/shared
'
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
...
...
@@ -19,6 +19,14 @@ function stringifyQuery(obj, encodeStr = encode) {
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
function
cache
(
fn
)
{
const
cache
=
Object
.
create
(
null
);
return
(
str
)
=>
{
const
hit
=
cache
[
str
];
return
hit
||
(
cache
[
str
]
=
fn
(
str
));
};
}
const
invokeArrayFns
=
(
fns
,
arg
)
=>
{
let
ret
;
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
)
{
...
...
@@ -121,6 +129,167 @@ function getEventChannel(id) {
return
eventChannelStack
.
shift
();
}
function
initVueIds
(
vueIds
,
mpInstance
)
{
if
(
!
vueIds
)
{
return
;
}
const
ids
=
vueIds
.
split
(
'
,
'
);
const
len
=
ids
.
length
;
if
(
len
===
1
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
}
else
if
(
len
===
2
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
mpInstance
.
_$vuePid
=
ids
[
1
];
}
}
function
initWxsCallMethods
(
methods
,
wxsCallMethods
)
{
if
(
!
isArray
(
wxsCallMethods
))
{
return
;
}
wxsCallMethods
.
forEach
((
callMethod
)
=>
{
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
);
};
});
}
function
findVmByVueId
(
instance
,
vuePid
)
{
// 标准 vue3 中 没有 $children,定制了内核
const
$children
=
instance
.
$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
;
}
}
}
function
getTarget
(
obj
,
path
)
{
const
parts
=
path
.
split
(
'
.
'
);
let
key
=
parts
[
0
];
if
(
key
.
indexOf
(
'
__$n
'
)
===
0
)
{
//number index
key
=
parseInt
(
key
.
replace
(
'
__$n
'
,
''
));
}
if
(
!
obj
)
{
obj
=
{};
}
if
(
parts
.
length
===
1
)
{
return
obj
[
key
];
}
return
getTarget
(
obj
[
key
],
parts
.
slice
(
1
).
join
(
'
.
'
));
}
function
getValue
(
dataPath
,
target
)
{
return
getTarget
(
target
||
this
,
dataPath
);
}
function
getClass
(
dynamicClass
,
staticClass
)
{
return
renderClass
(
staticClass
,
dynamicClass
);
}
function
getStyle
(
dynamicStyle
,
staticStyle
)
{
if
(
!
dynamicStyle
&&
!
staticStyle
)
{
return
''
;
}
var
dynamicStyleObj
=
normalizeStyleBinding
(
dynamicStyle
);
var
styleObj
=
staticStyle
?
extend
(
staticStyle
,
dynamicStyleObj
)
:
dynamicStyleObj
;
return
Object
.
keys
(
styleObj
)
.
map
(
function
(
name
)
{
return
hyphenate
(
name
)
+
'
:
'
+
styleObj
[
name
];
})
.
join
(
'
;
'
);
}
function
toObject
(
arr
)
{
var
res
=
{};
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
])
{
extend
(
res
,
arr
[
i
]);
}
}
return
res
;
}
function
normalizeStyleBinding
(
bindingStyle
)
{
if
(
Array
.
isArray
(
bindingStyle
))
{
return
toObject
(
bindingStyle
);
}
if
(
typeof
bindingStyle
===
'
string
'
)
{
return
parseStyleText
(
bindingStyle
);
}
return
bindingStyle
;
}
var
parseStyleText
=
cache
(
function
parseStyleText
(
cssText
)
{
var
res
=
{};
var
listDelimiter
=
/;
(?![^
(
]
*
\))
/g
;
var
propertyDelimiter
=
/:
(
.+
)
/
;
cssText
.
split
(
listDelimiter
).
forEach
(
function
(
item
)
{
if
(
item
)
{
var
tmp
=
item
.
split
(
propertyDelimiter
);
tmp
.
length
>
1
&&
(
res
[
tmp
[
0
].
trim
()]
=
tmp
[
1
].
trim
());
}
});
return
res
;
});
function
isDef
(
v
)
{
return
v
!==
undefined
&&
v
!==
null
;
}
function
renderClass
(
staticClass
,
dynamicClass
)
{
if
(
isDef
(
staticClass
)
||
isDef
(
dynamicClass
))
{
return
concat
(
staticClass
,
stringifyClass
(
dynamicClass
));
}
/* istanbul ignore next */
return
''
;
}
function
concat
(
a
,
b
)
{
return
a
?
(
b
?
a
+
'
'
+
b
:
a
)
:
b
||
''
;
}
function
stringifyClass
(
value
)
{
if
(
Array
.
isArray
(
value
))
{
return
stringifyArray
(
value
);
}
if
(
isObject
(
value
))
{
return
stringifyObject
(
value
);
}
if
(
typeof
value
===
'
string
'
)
{
return
value
;
}
/* istanbul ignore next */
return
''
;
}
function
stringifyArray
(
value
)
{
var
res
=
''
;
var
stringified
;
for
(
var
i
=
0
,
l
=
value
.
length
;
i
<
l
;
i
++
)
{
if
(
isDef
((
stringified
=
stringifyClass
(
value
[
i
])))
&&
stringified
!==
''
)
{
if
(
res
)
{
res
+=
'
'
;
}
res
+=
stringified
;
}
}
return
res
;
}
function
stringifyObject
(
value
)
{
var
res
=
''
;
for
(
var
key
in
value
)
{
if
(
value
[
key
])
{
if
(
res
)
{
res
+=
'
'
;
}
res
+=
key
;
}
}
return
res
;
}
function
setModel
(
target
,
key
,
value
,
modifiers
)
{
if
(
isArray
(
modifiers
))
{
if
(
modifiers
.
indexOf
(
'
trim
'
)
!==
-
1
)
{
...
...
@@ -239,7 +408,9 @@ function initComponentInstance(instance, options) {
ctx
.
__set_sync
=
setSync
;
ctx
.
__get_orig
=
getOrig
;
// TODO
// ctx.__get_style = getStyle
ctx
.
__get_value
=
getValue
;
ctx
.
__get_class
=
getClass
;
ctx
.
__get_style
=
getStyle
;
ctx
.
__map
=
map
;
}
function
initMocks
(
instance
,
mpInstance
,
mocks
)
{
...
...
@@ -366,50 +537,6 @@ function initCreateApp(parseAppOptions) {
};
}
function
initVueIds
(
vueIds
,
mpInstance
)
{
if
(
!
vueIds
)
{
return
;
}
const
ids
=
vueIds
.
split
(
'
,
'
);
const
len
=
ids
.
length
;
if
(
len
===
1
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
}
else
if
(
len
===
2
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
mpInstance
.
_$vuePid
=
ids
[
1
];
}
}
function
initWxsCallMethods
(
methods
,
wxsCallMethods
)
{
if
(
!
isArray
(
wxsCallMethods
))
{
return
;
}
wxsCallMethods
.
forEach
((
callMethod
)
=>
{
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
);
};
});
}
function
findVmByVueId
(
instance
,
vuePid
)
{
// 标准 vue3 中 没有 $children,定制了内核
const
$children
=
instance
.
$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
;
}
}
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
parsePropType
(
key
,
type
,
defaultValue
)
{
// [String]=>String
...
...
@@ -556,18 +683,6 @@ function initBehaviors(vueOptions, initBehavior) {
return
behaviors
;
}
function
getValue
(
obj
,
path
)
{
const
parts
=
path
.
split
(
'
.
'
);
let
key
=
parts
[
0
];
if
(
key
.
indexOf
(
'
__$n
'
)
===
0
)
{
//number index
key
=
parseInt
(
key
.
replace
(
'
__$n
'
,
''
));
}
if
(
parts
.
length
===
1
)
{
return
obj
[
key
];
}
return
getValue
(
obj
[
key
],
parts
.
slice
(
1
).
join
(
'
.
'
));
}
function
getExtraValue
(
instance
,
dataPathsArray
)
{
let
context
=
instance
;
dataPathsArray
.
forEach
((
dataPathArray
)
=>
{
...
...
@@ -589,7 +704,7 @@ function getExtraValue(instance, dataPathsArray) {
vFor
=
dataPath
.
substr
(
3
);
}
else
{
vFor
=
get
Value
(
context
,
dataPath
);
vFor
=
get
Target
(
context
,
dataPath
);
}
}
if
(
Number
.
isInteger
(
vFor
))
{
...
...
@@ -601,12 +716,12 @@ function getExtraValue(instance, dataPathsArray) {
else
{
if
(
isArray
(
vFor
))
{
context
=
vFor
.
find
((
vForItem
)
=>
{
return
get
Value
(
vForItem
,
propPath
)
===
value
;
return
get
Target
(
vForItem
,
propPath
)
===
value
;
});
}
else
if
(
isPlainObject
(
vFor
))
{
context
=
Object
.
keys
(
vFor
).
find
((
vForKey
)
=>
{
return
get
Value
(
vFor
[
vForKey
],
propPath
)
===
value
;
return
get
Target
(
vFor
[
vForKey
],
propPath
)
===
value
;
});
}
else
{
...
...
@@ -614,7 +729,7 @@ function getExtraValue(instance, dataPathsArray) {
}
}
if
(
valuePath
)
{
context
=
get
Value
(
context
,
valuePath
);
context
=
get
Target
(
context
,
valuePath
);
}
}
});
...
...
@@ -655,10 +770,10 @@ function processEventExtra(instance, extra, event) {
}
else
if
(
dataPath
.
indexOf
(
'
$event.
'
)
===
0
)
{
// $event.target.value
extraObj
[
'
$
'
+
index
]
=
get
Value
(
event
,
dataPath
.
replace
(
'
$event.
'
,
''
));
extraObj
[
'
$
'
+
index
]
=
get
Target
(
event
,
dataPath
.
replace
(
'
$event.
'
,
''
));
}
else
{
extraObj
[
'
$
'
+
index
]
=
get
Value
(
instance
,
dataPath
);
extraObj
[
'
$
'
+
index
]
=
get
Target
(
instance
,
dataPath
);
}
}
}
...
...
@@ -795,7 +910,14 @@ function handleEvent(event) {
}
handler
.
once
=
true
;
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
processEventArgs
(
this
.
$vm
,
event
,
eventArray
[
1
],
eventArray
[
2
],
isCustom
,
methodName
)));
let
params
=
processEventArgs
(
this
.
$vm
,
event
,
eventArray
[
1
],
eventArray
[
2
],
isCustom
,
methodName
);
params
=
Array
.
isArray
(
params
)
?
params
:
[];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
if
(
/=
\s
*
\S
+
\.
eventParams
\s
*
\|\|\s
*
\S
+
\[[
'"
]
event-params
[
'"
]\]
/
.
test
(
handler
.
toString
()))
{
// eslint-disable-next-line no-sparse-arrays
params
=
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
]);
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
));
}
});
}
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
31337c86
此差异已折叠。
点击以展开。
packages/uni-mp-baidu/dist/uni.mp.esm.js
浏览文件 @
31337c86
import
{
isPlainObject
,
isArray
,
hasOwn
,
toNumber
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
...
...
@@ -19,6 +19,14 @@ function stringifyQuery(obj, encodeStr = encode) {
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
function
cache
(
fn
)
{
const
cache
=
Object
.
create
(
null
);
return
(
str
)
=>
{
const
hit
=
cache
[
str
];
return
hit
||
(
cache
[
str
]
=
fn
(
str
));
};
}
const
invokeArrayFns
=
(
fns
,
arg
)
=>
{
let
ret
;
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
)
{
...
...
@@ -120,6 +128,202 @@ function getEventChannel(id) {
return
eventChannelStack
.
shift
();
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
}
function
initVueIds
(
vueIds
,
mpInstance
)
{
if
(
!
vueIds
)
{
return
;
}
const
ids
=
vueIds
.
split
(
'
,
'
);
const
len
=
ids
.
length
;
if
(
len
===
1
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
}
else
if
(
len
===
2
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
mpInstance
.
_$vuePid
=
ids
[
1
];
}
}
const
EXTRAS
=
[
'
externalClasses
'
];
function
initExtraOptions
(
miniProgramComponentOptions
,
vueOptions
)
{
EXTRAS
.
forEach
((
name
)
=>
{
if
(
hasOwn
(
vueOptions
,
name
))
{
miniProgramComponentOptions
[
name
]
=
vueOptions
[
name
];
}
});
}
function
initWxsCallMethods
(
methods
,
wxsCallMethods
)
{
if
(
!
isArray
(
wxsCallMethods
))
{
return
;
}
wxsCallMethods
.
forEach
((
callMethod
)
=>
{
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
);
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
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
;
},
});
}
function
findVmByVueId
(
instance
,
vuePid
)
{
// 标准 vue3 中 没有 $children,定制了内核
const
$children
=
instance
.
$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
;
}
}
}
function
getTarget
(
obj
,
path
)
{
const
parts
=
path
.
split
(
'
.
'
);
let
key
=
parts
[
0
];
if
(
key
.
indexOf
(
'
__$n
'
)
===
0
)
{
//number index
key
=
parseInt
(
key
.
replace
(
'
__$n
'
,
''
));
}
if
(
!
obj
)
{
obj
=
{};
}
if
(
parts
.
length
===
1
)
{
return
obj
[
key
];
}
return
getTarget
(
obj
[
key
],
parts
.
slice
(
1
).
join
(
'
.
'
));
}
function
getValue
(
dataPath
,
target
)
{
return
getTarget
(
target
||
this
,
dataPath
);
}
function
getClass
(
dynamicClass
,
staticClass
)
{
return
renderClass
(
staticClass
,
dynamicClass
);
}
function
getStyle
(
dynamicStyle
,
staticStyle
)
{
if
(
!
dynamicStyle
&&
!
staticStyle
)
{
return
''
;
}
var
dynamicStyleObj
=
normalizeStyleBinding
(
dynamicStyle
);
var
styleObj
=
staticStyle
?
extend
(
staticStyle
,
dynamicStyleObj
)
:
dynamicStyleObj
;
return
Object
.
keys
(
styleObj
)
.
map
(
function
(
name
)
{
return
hyphenate
(
name
)
+
'
:
'
+
styleObj
[
name
];
})
.
join
(
'
;
'
);
}
function
toObject
(
arr
)
{
var
res
=
{};
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
])
{
extend
(
res
,
arr
[
i
]);
}
}
return
res
;
}
function
normalizeStyleBinding
(
bindingStyle
)
{
if
(
Array
.
isArray
(
bindingStyle
))
{
return
toObject
(
bindingStyle
);
}
if
(
typeof
bindingStyle
===
'
string
'
)
{
return
parseStyleText
(
bindingStyle
);
}
return
bindingStyle
;
}
var
parseStyleText
=
cache
(
function
parseStyleText
(
cssText
)
{
var
res
=
{};
var
listDelimiter
=
/;
(?![^
(
]
*
\))
/g
;
var
propertyDelimiter
=
/:
(
.+
)
/
;
cssText
.
split
(
listDelimiter
).
forEach
(
function
(
item
)
{
if
(
item
)
{
var
tmp
=
item
.
split
(
propertyDelimiter
);
tmp
.
length
>
1
&&
(
res
[
tmp
[
0
].
trim
()]
=
tmp
[
1
].
trim
());
}
});
return
res
;
});
function
isDef
(
v
)
{
return
v
!==
undefined
&&
v
!==
null
;
}
function
renderClass
(
staticClass
,
dynamicClass
)
{
if
(
isDef
(
staticClass
)
||
isDef
(
dynamicClass
))
{
return
concat
(
staticClass
,
stringifyClass
(
dynamicClass
));
}
/* istanbul ignore next */
return
''
;
}
function
concat
(
a
,
b
)
{
return
a
?
(
b
?
a
+
'
'
+
b
:
a
)
:
b
||
''
;
}
function
stringifyClass
(
value
)
{
if
(
Array
.
isArray
(
value
))
{
return
stringifyArray
(
value
);
}
if
(
isObject
(
value
))
{
return
stringifyObject
(
value
);
}
if
(
typeof
value
===
'
string
'
)
{
return
value
;
}
/* istanbul ignore next */
return
''
;
}
function
stringifyArray
(
value
)
{
var
res
=
''
;
var
stringified
;
for
(
var
i
=
0
,
l
=
value
.
length
;
i
<
l
;
i
++
)
{
if
(
isDef
((
stringified
=
stringifyClass
(
value
[
i
])))
&&
stringified
!==
''
)
{
if
(
res
)
{
res
+=
'
'
;
}
res
+=
stringified
;
}
}
return
res
;
}
function
stringifyObject
(
value
)
{
var
res
=
''
;
for
(
var
key
in
value
)
{
if
(
value
[
key
])
{
if
(
res
)
{
res
+=
'
'
;
}
res
+=
key
;
}
}
return
res
;
}
function
setModel
(
target
,
key
,
value
,
modifiers
)
{
if
(
isArray
(
modifiers
))
{
if
(
modifiers
.
indexOf
(
'
trim
'
)
!==
-
1
)
{
...
...
@@ -229,7 +433,9 @@ function initComponentInstance(instance, options) {
ctx
.
__set_sync
=
setSync
;
ctx
.
__get_orig
=
getOrig
;
// TODO
// ctx.__get_style = getStyle
ctx
.
__get_value
=
getValue
;
ctx
.
__get_class
=
getClass
;
ctx
.
__get_style
=
getStyle
;
ctx
.
__map
=
map
;
}
function
initMocks
(
instance
,
mpInstance
,
mocks
)
{
...
...
@@ -356,85 +562,6 @@ function initCreateApp(parseAppOptions) {
};
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
}
function
initVueIds
(
vueIds
,
mpInstance
)
{
if
(
!
vueIds
)
{
return
;
}
const
ids
=
vueIds
.
split
(
'
,
'
);
const
len
=
ids
.
length
;
if
(
len
===
1
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
}
else
if
(
len
===
2
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
mpInstance
.
_$vuePid
=
ids
[
1
];
}
}
const
EXTRAS
=
[
'
externalClasses
'
];
function
initExtraOptions
(
miniProgramComponentOptions
,
vueOptions
)
{
EXTRAS
.
forEach
((
name
)
=>
{
if
(
hasOwn
(
vueOptions
,
name
))
{
miniProgramComponentOptions
[
name
]
=
vueOptions
[
name
];
}
});
}
function
initWxsCallMethods
(
methods
,
wxsCallMethods
)
{
if
(
!
isArray
(
wxsCallMethods
))
{
return
;
}
wxsCallMethods
.
forEach
((
callMethod
)
=>
{
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
);
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
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
;
},
});
}
function
findVmByVueId
(
instance
,
vuePid
)
{
// 标准 vue3 中 没有 $children,定制了内核
const
$children
=
instance
.
$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
;
}
}
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
return
function
observer
(
newVal
)
{
...
...
@@ -602,18 +729,6 @@ function applyOptions(componentOptions, vueOptions, initBehavior) {
componentOptions
.
behaviors
=
initBehaviors
(
vueOptions
,
initBehavior
);
}
function
getValue
(
obj
,
path
)
{
const
parts
=
path
.
split
(
'
.
'
);
let
key
=
parts
[
0
];
if
(
key
.
indexOf
(
'
__$n
'
)
===
0
)
{
//number index
key
=
parseInt
(
key
.
replace
(
'
__$n
'
,
''
));
}
if
(
parts
.
length
===
1
)
{
return
obj
[
key
];
}
return
getValue
(
obj
[
key
],
parts
.
slice
(
1
).
join
(
'
.
'
));
}
function
getExtraValue
(
instance
,
dataPathsArray
)
{
let
context
=
instance
;
dataPathsArray
.
forEach
((
dataPathArray
)
=>
{
...
...
@@ -635,7 +750,7 @@ function getExtraValue(instance, dataPathsArray) {
vFor
=
dataPath
.
substr
(
3
);
}
else
{
vFor
=
get
Value
(
context
,
dataPath
);
vFor
=
get
Target
(
context
,
dataPath
);
}
}
if
(
Number
.
isInteger
(
vFor
))
{
...
...
@@ -647,12 +762,12 @@ function getExtraValue(instance, dataPathsArray) {
else
{
if
(
isArray
(
vFor
))
{
context
=
vFor
.
find
((
vForItem
)
=>
{
return
get
Value
(
vForItem
,
propPath
)
===
value
;
return
get
Target
(
vForItem
,
propPath
)
===
value
;
});
}
else
if
(
isPlainObject
(
vFor
))
{
context
=
Object
.
keys
(
vFor
).
find
((
vForKey
)
=>
{
return
get
Value
(
vFor
[
vForKey
],
propPath
)
===
value
;
return
get
Target
(
vFor
[
vForKey
],
propPath
)
===
value
;
});
}
else
{
...
...
@@ -660,7 +775,7 @@ function getExtraValue(instance, dataPathsArray) {
}
}
if
(
valuePath
)
{
context
=
get
Value
(
context
,
valuePath
);
context
=
get
Target
(
context
,
valuePath
);
}
}
});
...
...
@@ -701,10 +816,10 @@ function processEventExtra(instance, extra, event) {
}
else
if
(
dataPath
.
indexOf
(
'
$event.
'
)
===
0
)
{
// $event.target.value
extraObj
[
'
$
'
+
index
]
=
get
Value
(
event
,
dataPath
.
replace
(
'
$event.
'
,
''
));
extraObj
[
'
$
'
+
index
]
=
get
Target
(
event
,
dataPath
.
replace
(
'
$event.
'
,
''
));
}
else
{
extraObj
[
'
$
'
+
index
]
=
get
Value
(
instance
,
dataPath
);
extraObj
[
'
$
'
+
index
]
=
get
Target
(
instance
,
dataPath
);
}
}
}
...
...
@@ -849,7 +964,14 @@ function handleEvent(event) {
}
handler
.
once
=
true
;
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
processEventArgs
(
this
.
$vm
,
event
,
eventArray
[
1
],
eventArray
[
2
],
isCustom
,
methodName
)));
let
params
=
processEventArgs
(
this
.
$vm
,
event
,
eventArray
[
1
],
eventArray
[
2
],
isCustom
,
methodName
);
params
=
Array
.
isArray
(
params
)
?
params
:
[];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
if
(
/=
\s
*
\S
+
\.
eventParams
\s
*
\|\|\s
*
\S
+
\[[
'"
]
event-params
[
'"
]\]
/
.
test
(
handler
.
toString
()))
{
// eslint-disable-next-line no-sparse-arrays
params
=
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
]);
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
));
}
});
}
...
...
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
31337c86
此差异已折叠。
点击以展开。
packages/uni-mp-qq/dist/uni.mp.esm.js
浏览文件 @
31337c86
import
{
isPlainObject
,
isArray
,
hasOwn
,
toNumber
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
...
...
@@ -19,6 +19,14 @@ function stringifyQuery(obj, encodeStr = encode) {
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
function
cache
(
fn
)
{
const
cache
=
Object
.
create
(
null
);
return
(
str
)
=>
{
const
hit
=
cache
[
str
];
return
hit
||
(
cache
[
str
]
=
fn
(
str
));
};
}
const
invokeArrayFns
=
(
fns
,
arg
)
=>
{
let
ret
;
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
)
{
...
...
@@ -120,6 +128,202 @@ function getEventChannel(id) {
return
eventChannelStack
.
shift
();
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
}
function
initVueIds
(
vueIds
,
mpInstance
)
{
if
(
!
vueIds
)
{
return
;
}
const
ids
=
vueIds
.
split
(
'
,
'
);
const
len
=
ids
.
length
;
if
(
len
===
1
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
}
else
if
(
len
===
2
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
mpInstance
.
_$vuePid
=
ids
[
1
];
}
}
const
EXTRAS
=
[
'
externalClasses
'
];
function
initExtraOptions
(
miniProgramComponentOptions
,
vueOptions
)
{
EXTRAS
.
forEach
((
name
)
=>
{
if
(
hasOwn
(
vueOptions
,
name
))
{
miniProgramComponentOptions
[
name
]
=
vueOptions
[
name
];
}
});
}
function
initWxsCallMethods
(
methods
,
wxsCallMethods
)
{
if
(
!
isArray
(
wxsCallMethods
))
{
return
;
}
wxsCallMethods
.
forEach
((
callMethod
)
=>
{
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
);
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
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
;
},
});
}
function
findVmByVueId
(
instance
,
vuePid
)
{
// 标准 vue3 中 没有 $children,定制了内核
const
$children
=
instance
.
$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
;
}
}
}
function
getTarget
(
obj
,
path
)
{
const
parts
=
path
.
split
(
'
.
'
);
let
key
=
parts
[
0
];
if
(
key
.
indexOf
(
'
__$n
'
)
===
0
)
{
//number index
key
=
parseInt
(
key
.
replace
(
'
__$n
'
,
''
));
}
if
(
!
obj
)
{
obj
=
{};
}
if
(
parts
.
length
===
1
)
{
return
obj
[
key
];
}
return
getTarget
(
obj
[
key
],
parts
.
slice
(
1
).
join
(
'
.
'
));
}
function
getValue
(
dataPath
,
target
)
{
return
getTarget
(
target
||
this
,
dataPath
);
}
function
getClass
(
dynamicClass
,
staticClass
)
{
return
renderClass
(
staticClass
,
dynamicClass
);
}
function
getStyle
(
dynamicStyle
,
staticStyle
)
{
if
(
!
dynamicStyle
&&
!
staticStyle
)
{
return
''
;
}
var
dynamicStyleObj
=
normalizeStyleBinding
(
dynamicStyle
);
var
styleObj
=
staticStyle
?
extend
(
staticStyle
,
dynamicStyleObj
)
:
dynamicStyleObj
;
return
Object
.
keys
(
styleObj
)
.
map
(
function
(
name
)
{
return
hyphenate
(
name
)
+
'
:
'
+
styleObj
[
name
];
})
.
join
(
'
;
'
);
}
function
toObject
(
arr
)
{
var
res
=
{};
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
])
{
extend
(
res
,
arr
[
i
]);
}
}
return
res
;
}
function
normalizeStyleBinding
(
bindingStyle
)
{
if
(
Array
.
isArray
(
bindingStyle
))
{
return
toObject
(
bindingStyle
);
}
if
(
typeof
bindingStyle
===
'
string
'
)
{
return
parseStyleText
(
bindingStyle
);
}
return
bindingStyle
;
}
var
parseStyleText
=
cache
(
function
parseStyleText
(
cssText
)
{
var
res
=
{};
var
listDelimiter
=
/;
(?![^
(
]
*
\))
/g
;
var
propertyDelimiter
=
/:
(
.+
)
/
;
cssText
.
split
(
listDelimiter
).
forEach
(
function
(
item
)
{
if
(
item
)
{
var
tmp
=
item
.
split
(
propertyDelimiter
);
tmp
.
length
>
1
&&
(
res
[
tmp
[
0
].
trim
()]
=
tmp
[
1
].
trim
());
}
});
return
res
;
});
function
isDef
(
v
)
{
return
v
!==
undefined
&&
v
!==
null
;
}
function
renderClass
(
staticClass
,
dynamicClass
)
{
if
(
isDef
(
staticClass
)
||
isDef
(
dynamicClass
))
{
return
concat
(
staticClass
,
stringifyClass
(
dynamicClass
));
}
/* istanbul ignore next */
return
''
;
}
function
concat
(
a
,
b
)
{
return
a
?
(
b
?
a
+
'
'
+
b
:
a
)
:
b
||
''
;
}
function
stringifyClass
(
value
)
{
if
(
Array
.
isArray
(
value
))
{
return
stringifyArray
(
value
);
}
if
(
isObject
(
value
))
{
return
stringifyObject
(
value
);
}
if
(
typeof
value
===
'
string
'
)
{
return
value
;
}
/* istanbul ignore next */
return
''
;
}
function
stringifyArray
(
value
)
{
var
res
=
''
;
var
stringified
;
for
(
var
i
=
0
,
l
=
value
.
length
;
i
<
l
;
i
++
)
{
if
(
isDef
((
stringified
=
stringifyClass
(
value
[
i
])))
&&
stringified
!==
''
)
{
if
(
res
)
{
res
+=
'
'
;
}
res
+=
stringified
;
}
}
return
res
;
}
function
stringifyObject
(
value
)
{
var
res
=
''
;
for
(
var
key
in
value
)
{
if
(
value
[
key
])
{
if
(
res
)
{
res
+=
'
'
;
}
res
+=
key
;
}
}
return
res
;
}
function
setModel
(
target
,
key
,
value
,
modifiers
)
{
if
(
isArray
(
modifiers
))
{
if
(
modifiers
.
indexOf
(
'
trim
'
)
!==
-
1
)
{
...
...
@@ -229,7 +433,9 @@ function initComponentInstance(instance, options) {
ctx
.
__set_sync
=
setSync
;
ctx
.
__get_orig
=
getOrig
;
// TODO
// ctx.__get_style = getStyle
ctx
.
__get_value
=
getValue
;
ctx
.
__get_class
=
getClass
;
ctx
.
__get_style
=
getStyle
;
ctx
.
__map
=
map
;
}
function
initMocks
(
instance
,
mpInstance
,
mocks
)
{
...
...
@@ -356,85 +562,6 @@ function initCreateApp(parseAppOptions) {
};
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
}
function
initVueIds
(
vueIds
,
mpInstance
)
{
if
(
!
vueIds
)
{
return
;
}
const
ids
=
vueIds
.
split
(
'
,
'
);
const
len
=
ids
.
length
;
if
(
len
===
1
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
}
else
if
(
len
===
2
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
mpInstance
.
_$vuePid
=
ids
[
1
];
}
}
const
EXTRAS
=
[
'
externalClasses
'
];
function
initExtraOptions
(
miniProgramComponentOptions
,
vueOptions
)
{
EXTRAS
.
forEach
((
name
)
=>
{
if
(
hasOwn
(
vueOptions
,
name
))
{
miniProgramComponentOptions
[
name
]
=
vueOptions
[
name
];
}
});
}
function
initWxsCallMethods
(
methods
,
wxsCallMethods
)
{
if
(
!
isArray
(
wxsCallMethods
))
{
return
;
}
wxsCallMethods
.
forEach
((
callMethod
)
=>
{
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
);
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
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
;
},
});
}
function
findVmByVueId
(
instance
,
vuePid
)
{
// 标准 vue3 中 没有 $children,定制了内核
const
$children
=
instance
.
$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
;
}
}
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
return
function
observer
(
newVal
)
{
...
...
@@ -591,18 +718,6 @@ function applyOptions(componentOptions, vueOptions, initBehavior) {
componentOptions
.
behaviors
=
initBehaviors
(
vueOptions
,
initBehavior
);
}
function
getValue
(
obj
,
path
)
{
const
parts
=
path
.
split
(
'
.
'
);
let
key
=
parts
[
0
];
if
(
key
.
indexOf
(
'
__$n
'
)
===
0
)
{
//number index
key
=
parseInt
(
key
.
replace
(
'
__$n
'
,
''
));
}
if
(
parts
.
length
===
1
)
{
return
obj
[
key
];
}
return
getValue
(
obj
[
key
],
parts
.
slice
(
1
).
join
(
'
.
'
));
}
function
getExtraValue
(
instance
,
dataPathsArray
)
{
let
context
=
instance
;
dataPathsArray
.
forEach
((
dataPathArray
)
=>
{
...
...
@@ -624,7 +739,7 @@ function getExtraValue(instance, dataPathsArray) {
vFor
=
dataPath
.
substr
(
3
);
}
else
{
vFor
=
get
Value
(
context
,
dataPath
);
vFor
=
get
Target
(
context
,
dataPath
);
}
}
if
(
Number
.
isInteger
(
vFor
))
{
...
...
@@ -636,12 +751,12 @@ function getExtraValue(instance, dataPathsArray) {
else
{
if
(
isArray
(
vFor
))
{
context
=
vFor
.
find
((
vForItem
)
=>
{
return
get
Value
(
vForItem
,
propPath
)
===
value
;
return
get
Target
(
vForItem
,
propPath
)
===
value
;
});
}
else
if
(
isPlainObject
(
vFor
))
{
context
=
Object
.
keys
(
vFor
).
find
((
vForKey
)
=>
{
return
get
Value
(
vFor
[
vForKey
],
propPath
)
===
value
;
return
get
Target
(
vFor
[
vForKey
],
propPath
)
===
value
;
});
}
else
{
...
...
@@ -649,7 +764,7 @@ function getExtraValue(instance, dataPathsArray) {
}
}
if
(
valuePath
)
{
context
=
get
Value
(
context
,
valuePath
);
context
=
get
Target
(
context
,
valuePath
);
}
}
});
...
...
@@ -690,10 +805,10 @@ function processEventExtra(instance, extra, event) {
}
else
if
(
dataPath
.
indexOf
(
'
$event.
'
)
===
0
)
{
// $event.target.value
extraObj
[
'
$
'
+
index
]
=
get
Value
(
event
,
dataPath
.
replace
(
'
$event.
'
,
''
));
extraObj
[
'
$
'
+
index
]
=
get
Target
(
event
,
dataPath
.
replace
(
'
$event.
'
,
''
));
}
else
{
extraObj
[
'
$
'
+
index
]
=
get
Value
(
instance
,
dataPath
);
extraObj
[
'
$
'
+
index
]
=
get
Target
(
instance
,
dataPath
);
}
}
}
...
...
@@ -830,7 +945,14 @@ function handleEvent(event) {
}
handler
.
once
=
true
;
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
processEventArgs
(
this
.
$vm
,
event
,
eventArray
[
1
],
eventArray
[
2
],
isCustom
,
methodName
)));
let
params
=
processEventArgs
(
this
.
$vm
,
event
,
eventArray
[
1
],
eventArray
[
2
],
isCustom
,
methodName
);
params
=
Array
.
isArray
(
params
)
?
params
:
[];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
if
(
/=
\s
*
\S
+
\.
eventParams
\s
*
\|\|\s
*
\S
+
\[[
'"
]
event-params
[
'"
]\]
/
.
test
(
handler
.
toString
()))
{
// eslint-disable-next-line no-sparse-arrays
params
=
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
]);
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
));
}
});
}
...
...
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
31337c86
此差异已折叠。
点击以展开。
packages/uni-mp-toutiao/dist/uni.mp.esm.js
浏览文件 @
31337c86
此差异已折叠。
点击以展开。
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
31337c86
此差异已折叠。
点击以展开。
packages/uni-mp-weixin/dist/uni.mp.esm.js
浏览文件 @
31337c86
此差异已折叠。
点击以展开。
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
31337c86
此差异已折叠。
点击以展开。
packages/uni-quickapp-webview/dist/uni.mp.esm.js
浏览文件 @
31337c86
import
{
isPlainObject
,
isArray
,
hasOwn
,
toNumber
,
isObject
,
isFunction
,
extend
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
import
{
isPlainObject
,
hasOwn
,
isArray
,
extend
,
hyphenate
,
isObject
,
toNumber
,
isFunction
,
NOOP
,
camelize
}
from
'
@vue/shared
'
;
const
encode
=
encodeURIComponent
;
function
stringifyQuery
(
obj
,
encodeStr
=
encode
)
{
...
...
@@ -19,6 +19,14 @@ function stringifyQuery(obj, encodeStr = encode) {
:
null
;
return
res
?
`?
${
res
}
`
:
''
;
}
function
cache
(
fn
)
{
const
cache
=
Object
.
create
(
null
);
return
(
str
)
=>
{
const
hit
=
cache
[
str
];
return
hit
||
(
cache
[
str
]
=
fn
(
str
));
};
}
const
invokeArrayFns
=
(
fns
,
arg
)
=>
{
let
ret
;
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
)
{
...
...
@@ -120,6 +128,183 @@ function getEventChannel(id) {
return
eventChannelStack
.
shift
();
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
}
function
initVueIds
(
vueIds
,
mpInstance
)
{
if
(
!
vueIds
)
{
return
;
}
const
ids
=
vueIds
.
split
(
'
,
'
);
const
len
=
ids
.
length
;
if
(
len
===
1
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
}
else
if
(
len
===
2
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
mpInstance
.
_$vuePid
=
ids
[
1
];
}
}
const
EXTRAS
=
[
'
externalClasses
'
];
function
initExtraOptions
(
miniProgramComponentOptions
,
vueOptions
)
{
EXTRAS
.
forEach
((
name
)
=>
{
if
(
hasOwn
(
vueOptions
,
name
))
{
miniProgramComponentOptions
[
name
]
=
vueOptions
[
name
];
}
});
}
function
initWxsCallMethods
(
methods
,
wxsCallMethods
)
{
if
(
!
isArray
(
wxsCallMethods
))
{
return
;
}
wxsCallMethods
.
forEach
((
callMethod
)
=>
{
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
);
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
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
;
},
});
}
function
getTarget
(
obj
,
path
)
{
const
parts
=
path
.
split
(
'
.
'
);
let
key
=
parts
[
0
];
if
(
key
.
indexOf
(
'
__$n
'
)
===
0
)
{
//number index
key
=
parseInt
(
key
.
replace
(
'
__$n
'
,
''
));
}
if
(
!
obj
)
{
obj
=
{};
}
if
(
parts
.
length
===
1
)
{
return
obj
[
key
];
}
return
getTarget
(
obj
[
key
],
parts
.
slice
(
1
).
join
(
'
.
'
));
}
function
getValue
(
dataPath
,
target
)
{
return
getTarget
(
target
||
this
,
dataPath
);
}
function
getClass
(
dynamicClass
,
staticClass
)
{
return
renderClass
(
staticClass
,
dynamicClass
);
}
function
getStyle
(
dynamicStyle
,
staticStyle
)
{
if
(
!
dynamicStyle
&&
!
staticStyle
)
{
return
''
;
}
var
dynamicStyleObj
=
normalizeStyleBinding
(
dynamicStyle
);
var
styleObj
=
staticStyle
?
extend
(
staticStyle
,
dynamicStyleObj
)
:
dynamicStyleObj
;
return
Object
.
keys
(
styleObj
)
.
map
(
function
(
name
)
{
return
hyphenate
(
name
)
+
'
:
'
+
styleObj
[
name
];
})
.
join
(
'
;
'
);
}
function
toObject
(
arr
)
{
var
res
=
{};
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
])
{
extend
(
res
,
arr
[
i
]);
}
}
return
res
;
}
function
normalizeStyleBinding
(
bindingStyle
)
{
if
(
Array
.
isArray
(
bindingStyle
))
{
return
toObject
(
bindingStyle
);
}
if
(
typeof
bindingStyle
===
'
string
'
)
{
return
parseStyleText
(
bindingStyle
);
}
return
bindingStyle
;
}
var
parseStyleText
=
cache
(
function
parseStyleText
(
cssText
)
{
var
res
=
{};
var
listDelimiter
=
/;
(?![^
(
]
*
\))
/g
;
var
propertyDelimiter
=
/:
(
.+
)
/
;
cssText
.
split
(
listDelimiter
).
forEach
(
function
(
item
)
{
if
(
item
)
{
var
tmp
=
item
.
split
(
propertyDelimiter
);
tmp
.
length
>
1
&&
(
res
[
tmp
[
0
].
trim
()]
=
tmp
[
1
].
trim
());
}
});
return
res
;
});
function
isDef
(
v
)
{
return
v
!==
undefined
&&
v
!==
null
;
}
function
renderClass
(
staticClass
,
dynamicClass
)
{
if
(
isDef
(
staticClass
)
||
isDef
(
dynamicClass
))
{
return
concat
(
staticClass
,
stringifyClass
(
dynamicClass
));
}
/* istanbul ignore next */
return
''
;
}
function
concat
(
a
,
b
)
{
return
a
?
(
b
?
a
+
'
'
+
b
:
a
)
:
b
||
''
;
}
function
stringifyClass
(
value
)
{
if
(
Array
.
isArray
(
value
))
{
return
stringifyArray
(
value
);
}
if
(
isObject
(
value
))
{
return
stringifyObject
(
value
);
}
if
(
typeof
value
===
'
string
'
)
{
return
value
;
}
/* istanbul ignore next */
return
''
;
}
function
stringifyArray
(
value
)
{
var
res
=
''
;
var
stringified
;
for
(
var
i
=
0
,
l
=
value
.
length
;
i
<
l
;
i
++
)
{
if
(
isDef
((
stringified
=
stringifyClass
(
value
[
i
])))
&&
stringified
!==
''
)
{
if
(
res
)
{
res
+=
'
'
;
}
res
+=
stringified
;
}
}
return
res
;
}
function
stringifyObject
(
value
)
{
var
res
=
''
;
for
(
var
key
in
value
)
{
if
(
value
[
key
])
{
if
(
res
)
{
res
+=
'
'
;
}
res
+=
key
;
}
}
return
res
;
}
function
setModel
(
target
,
key
,
value
,
modifiers
)
{
if
(
isArray
(
modifiers
))
{
if
(
modifiers
.
indexOf
(
'
trim
'
)
!==
-
1
)
{
...
...
@@ -229,7 +414,9 @@ function initComponentInstance(instance, options) {
ctx
.
__set_sync
=
setSync
;
ctx
.
__get_orig
=
getOrig
;
// TODO
// ctx.__get_style = getStyle
ctx
.
__get_value
=
getValue
;
ctx
.
__get_class
=
getClass
;
ctx
.
__get_style
=
getStyle
;
ctx
.
__map
=
map
;
}
function
initMocks
(
instance
,
mpInstance
,
mocks
)
{
...
...
@@ -356,66 +543,6 @@ function initCreateApp(parseAppOptions) {
};
}
function
initBehavior
(
options
)
{
return
Behavior
(
options
);
}
function
initVueIds
(
vueIds
,
mpInstance
)
{
if
(
!
vueIds
)
{
return
;
}
const
ids
=
vueIds
.
split
(
'
,
'
);
const
len
=
ids
.
length
;
if
(
len
===
1
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
}
else
if
(
len
===
2
)
{
mpInstance
.
_$vueId
=
ids
[
0
];
mpInstance
.
_$vuePid
=
ids
[
1
];
}
}
const
EXTRAS
=
[
'
externalClasses
'
];
function
initExtraOptions
(
miniProgramComponentOptions
,
vueOptions
)
{
EXTRAS
.
forEach
((
name
)
=>
{
if
(
hasOwn
(
vueOptions
,
name
))
{
miniProgramComponentOptions
[
name
]
=
vueOptions
[
name
];
}
});
}
function
initWxsCallMethods
(
methods
,
wxsCallMethods
)
{
if
(
!
isArray
(
wxsCallMethods
))
{
return
;
}
wxsCallMethods
.
forEach
((
callMethod
)
=>
{
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
);
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
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
;
},
});
}
const
PROP_TYPES
=
[
String
,
Number
,
Boolean
,
Object
,
Array
,
null
];
function
createObserver
(
name
)
{
return
function
observer
(
newVal
)
{
...
...
@@ -572,18 +699,6 @@ function applyOptions(componentOptions, vueOptions, initBehavior) {
componentOptions
.
behaviors
=
initBehaviors
(
vueOptions
,
initBehavior
);
}
function
getValue
(
obj
,
path
)
{
const
parts
=
path
.
split
(
'
.
'
);
let
key
=
parts
[
0
];
if
(
key
.
indexOf
(
'
__$n
'
)
===
0
)
{
//number index
key
=
parseInt
(
key
.
replace
(
'
__$n
'
,
''
));
}
if
(
parts
.
length
===
1
)
{
return
obj
[
key
];
}
return
getValue
(
obj
[
key
],
parts
.
slice
(
1
).
join
(
'
.
'
));
}
function
getExtraValue
(
instance
,
dataPathsArray
)
{
let
context
=
instance
;
dataPathsArray
.
forEach
((
dataPathArray
)
=>
{
...
...
@@ -605,7 +720,7 @@ function getExtraValue(instance, dataPathsArray) {
vFor
=
dataPath
.
substr
(
3
);
}
else
{
vFor
=
get
Value
(
context
,
dataPath
);
vFor
=
get
Target
(
context
,
dataPath
);
}
}
if
(
Number
.
isInteger
(
vFor
))
{
...
...
@@ -617,12 +732,12 @@ function getExtraValue(instance, dataPathsArray) {
else
{
if
(
isArray
(
vFor
))
{
context
=
vFor
.
find
((
vForItem
)
=>
{
return
get
Value
(
vForItem
,
propPath
)
===
value
;
return
get
Target
(
vForItem
,
propPath
)
===
value
;
});
}
else
if
(
isPlainObject
(
vFor
))
{
context
=
Object
.
keys
(
vFor
).
find
((
vForKey
)
=>
{
return
get
Value
(
vFor
[
vForKey
],
propPath
)
===
value
;
return
get
Target
(
vFor
[
vForKey
],
propPath
)
===
value
;
});
}
else
{
...
...
@@ -630,7 +745,7 @@ function getExtraValue(instance, dataPathsArray) {
}
}
if
(
valuePath
)
{
context
=
get
Value
(
context
,
valuePath
);
context
=
get
Target
(
context
,
valuePath
);
}
}
});
...
...
@@ -671,10 +786,10 @@ function processEventExtra(instance, extra, event) {
}
else
if
(
dataPath
.
indexOf
(
'
$event.
'
)
===
0
)
{
// $event.target.value
extraObj
[
'
$
'
+
index
]
=
get
Value
(
event
,
dataPath
.
replace
(
'
$event.
'
,
''
));
extraObj
[
'
$
'
+
index
]
=
get
Target
(
event
,
dataPath
.
replace
(
'
$event.
'
,
''
));
}
else
{
extraObj
[
'
$
'
+
index
]
=
get
Value
(
instance
,
dataPath
);
extraObj
[
'
$
'
+
index
]
=
get
Target
(
instance
,
dataPath
);
}
}
}
...
...
@@ -811,7 +926,14 @@ function handleEvent(event) {
}
handler
.
once
=
true
;
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
processEventArgs
(
this
.
$vm
,
event
,
eventArray
[
1
],
eventArray
[
2
],
isCustom
,
methodName
)));
let
params
=
processEventArgs
(
this
.
$vm
,
event
,
eventArray
[
1
],
eventArray
[
2
],
isCustom
,
methodName
);
params
=
Array
.
isArray
(
params
)
?
params
:
[];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
if
(
/=
\s
*
\S
+
\.
eventParams
\s
*
\|\|\s
*
\S
+
\[[
'"
]
event-params
[
'"
]\]
/
.
test
(
handler
.
toString
()))
{
// eslint-disable-next-line no-sparse-arrays
params
=
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
]);
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
));
}
});
}
...
...
packages/vue-cli-plugin-uni/lib/chain-webpack.js
浏览文件 @
31337c86
...
...
@@ -94,6 +94,7 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
process
.
env
.
UNI_PLATFORM
===
'
quickapp-webview
'
const
defines
=
{
// UNI_ENV好像没用
__UNI_FEATURE_PROMISE__
:
JSON
.
stringify
(
false
),
'
process.env.UNI_ENV
'
:
JSON
.
stringify
(
process
.
env
.
UNI_PLATFORM
),
'
process.env.UNI_APP_ID
'
:
JSON
.
stringify
(
process
.
env
.
UNI_APP_ID
),
'
process.env.UNI_APP_NAME
'
:
JSON
.
stringify
(
process
.
env
.
UNI_APP_NAME
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录