Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
71080cf1
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
71080cf1
编写于
5月 23, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(push): normalize message
上级
51fd8186
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
487 addition
and
247 deletion
+487
-247
packages/uni-api/src/service/plugin/push.ts
packages/uni-api/src/service/plugin/push.ts
+25
-4
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+26
-4
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+25
-4
packages/uni-mp-alipay/dist/uni.api.esm.js
packages/uni-mp-alipay/dist/uni.api.esm.js
+26
-4
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+26
-4
packages/uni-mp-kuaishou/dist/uni.api.esm.js
packages/uni-mp-kuaishou/dist/uni.api.esm.js
+26
-4
packages/uni-mp-lark/dist/uni.api.esm.js
packages/uni-mp-lark/dist/uni.api.esm.js
+26
-4
packages/uni-mp-qq/dist/uni.api.esm.js
packages/uni-mp-qq/dist/uni.api.esm.js
+26
-4
packages/uni-mp-toutiao/dist/uni.api.esm.js
packages/uni-mp-toutiao/dist/uni.api.esm.js
+26
-4
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+26
-4
packages/uni-quickapp-webview/dist/uni.api.esm.js
packages/uni-quickapp-webview/dist/uni.api.esm.js
+26
-4
packages/uni-stacktracey/dist/uni-stacktracey.es.js
packages/uni-stacktracey/dist/uni-stacktracey.es.js
+203
-203
未找到文件。
packages/uni-api/src/service/plugin/push.ts
浏览文件 @
71080cf1
...
@@ -24,9 +24,24 @@ interface OnPushClickCallback {
...
@@ -24,9 +24,24 @@ interface OnPushClickCallback {
let
cid
:
string
|
undefined
let
cid
:
string
|
undefined
let
cidErrMsg
:
string
|
undefined
let
cidErrMsg
:
string
|
undefined
function
normalizePushMessage
(
message
:
unknown
)
{
function
normalizePushMessage
(
type
:
'
receive
'
|
'
click
'
,
message
:
unknown
)
{
try
{
try
{
return
JSON
.
parse
(
message
as
string
)
const
res
=
JSON
.
parse
(
message
as
string
)
as
Record
<
string
,
any
>
if
(
type
===
'
receive
'
)
{
if
(
res
.
payload
)
{
if
(
res
.
aps
)
{
res
.
payload
.
aps
=
res
.
aps
}
return
res
.
payload
}
}
else
if
(
type
===
'
click
'
)
{
delete
res
.
type
delete
res
.
__UUID__
delete
res
.
appid
if
(
res
.
aps
&&
res
.
aps
.
alert
)
{
res
.
title
=
res
.
aps
.
alert
.
title
}
}
}
catch
(
e
:
any
)
{}
}
catch
(
e
:
any
)
{}
return
message
return
message
}
}
...
@@ -47,11 +62,17 @@ export function invokePushCallback(
...
@@ -47,11 +62,17 @@ export function invokePushCallback(
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
)
invokeGetPushCidCallbacks
(
cid
,
args
.
errMsg
)
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
})
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
'
receive
'
,
args
.
message
),
})
})
})
}
else
if
(
args
.
type
===
'
click
'
)
{
}
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
})
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
'
click
'
,
args
.
message
),
})
})
})
}
}
}
}
...
...
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
71080cf1
...
@@ -11057,9 +11057,25 @@ const getLaunchOptionsSync = defineSyncApi(API_GET_LAUNCH_OPTIONS_SYNC, () => {
...
@@ -11057,9 +11057,25 @@ const getLaunchOptionsSync = defineSyncApi(API_GET_LAUNCH_OPTIONS_SYNC, () => {
let cid;
let cid;
let cidErrMsg;
let cidErrMsg;
function normalizePushMessage(message) {
function normalizePushMessage(
type,
message) {
try {
try {
return JSON.parse(message);
const res = JSON.parse(message);
if (type === 'receive') {
if (res.payload) {
if (res.aps) {
res.payload.aps = res.aps;
}
return res.payload;
}
}
else if (type === 'click') {
delete res.type;
delete res.__UUID__;
delete res.appid;
if (res.aps && res.aps.alert) {
res.title = res.aps.alert.title;
}
}
}
}
catch (e) { }
catch (e) { }
return message;
return message;
...
@@ -11076,12 +11092,18 @@ function invokePushCallback(args) {
...
@@ -11076,12 +11092,18 @@ function invokePushCallback(args) {
}
}
else if (args.type === 'pushMsg') {
else if (args.type === 'pushMsg') {
onPushMessageCallbacks.forEach((callback) => {
onPushMessageCallbacks.forEach((callback) => {
callback({ type: 'receive', data: normalizePushMessage(args.message) });
callback({
type: 'receive',
data: normalizePushMessage('receive', args.message),
});
});
});
}
}
else if (args.type === 'click') {
else if (args.type === 'click') {
onPushMessageCallbacks.forEach((callback) => {
onPushMessageCallbacks.forEach((callback) => {
callback({ type: 'click', data: normalizePushMessage(args.message) });
callback({
type: 'click',
data: normalizePushMessage('click', args.message),
});
});
});
}
}
}
}
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
71080cf1
...
@@ -4564,9 +4564,24 @@ const getLaunchOptionsSync = /* @__PURE__ */ defineSyncApi(API_GET_LAUNCH_OPTION
...
@@ -4564,9 +4564,24 @@ const getLaunchOptionsSync = /* @__PURE__ */ defineSyncApi(API_GET_LAUNCH_OPTION
});
});
let cid;
let cid;
let cidErrMsg;
let cidErrMsg;
function normalizePushMessage(message) {
function normalizePushMessage(
type,
message) {
try {
try {
return JSON.parse(message);
const res = JSON.parse(message);
if (type === "receive") {
if (res.payload) {
if (res.aps) {
res.payload.aps = res.aps;
}
return res.payload;
}
} else if (type === "click") {
delete res.type;
delete res.__UUID__;
delete res.appid;
if (res.aps && res.aps.alert) {
res.title = res.aps.alert.title;
}
}
} catch (e2) {
} catch (e2) {
}
}
return message;
return message;
...
@@ -4578,11 +4593,17 @@ function invokePushCallback(args) {
...
@@ -4578,11 +4593,17 @@ function invokePushCallback(args) {
invokeGetPushCidCallbacks(cid, args.errMsg);
invokeGetPushCidCallbacks(cid, args.errMsg);
} else if (args.type === "pushMsg") {
} else if (args.type === "pushMsg") {
onPushMessageCallbacks.forEach((callback) => {
onPushMessageCallbacks.forEach((callback) => {
callback({ type: "receive", data: normalizePushMessage(args.message) });
callback({
type: "receive",
data: normalizePushMessage("receive", args.message)
});
});
});
} else if (args.type === "click") {
} else if (args.type === "click") {
onPushMessageCallbacks.forEach((callback) => {
onPushMessageCallbacks.forEach((callback) => {
callback({ type: "click", data: normalizePushMessage(args.message) });
callback({
type: "click",
data: normalizePushMessage("click", args.message)
});
});
});
}
}
}
}
...
...
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
71080cf1
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
let
cid
;
let
cid
;
let
cidErrMsg
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
function
normalizePushMessage
(
type
,
message
)
{
try
{
try
{
return
JSON
.
parse
(
message
);
const
res
=
JSON
.
parse
(
message
);
if
(
type
===
'
receive
'
)
{
if
(
res
.
payload
)
{
if
(
res
.
aps
)
{
res
.
payload
.
aps
=
res
.
aps
;
}
return
res
.
payload
;
}
}
else
if
(
type
===
'
click
'
)
{
delete
res
.
type
;
delete
res
.
__UUID__
;
delete
res
.
appid
;
if
(
res
.
aps
&&
res
.
aps
.
alert
)
{
res
.
title
=
res
.
aps
.
alert
.
title
;
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
}
return
message
;
return
message
;
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
}
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
'
receive
'
,
args
.
message
),
});
});
});
}
}
else
if
(
args
.
type
===
'
click
'
)
{
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
'
click
'
,
args
.
message
),
});
});
});
}
}
}
}
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
71080cf1
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
let
cid
;
let
cid
;
let
cidErrMsg
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
function
normalizePushMessage
(
type
,
message
)
{
try
{
try
{
return
JSON
.
parse
(
message
);
const
res
=
JSON
.
parse
(
message
);
if
(
type
===
'
receive
'
)
{
if
(
res
.
payload
)
{
if
(
res
.
aps
)
{
res
.
payload
.
aps
=
res
.
aps
;
}
return
res
.
payload
;
}
}
else
if
(
type
===
'
click
'
)
{
delete
res
.
type
;
delete
res
.
__UUID__
;
delete
res
.
appid
;
if
(
res
.
aps
&&
res
.
aps
.
alert
)
{
res
.
title
=
res
.
aps
.
alert
.
title
;
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
}
return
message
;
return
message
;
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
}
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
'
receive
'
,
args
.
message
),
});
});
});
}
}
else
if
(
args
.
type
===
'
click
'
)
{
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
'
click
'
,
args
.
message
),
});
});
});
}
}
}
}
...
...
packages/uni-mp-kuaishou/dist/uni.api.esm.js
浏览文件 @
71080cf1
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
let
cid
;
let
cid
;
let
cidErrMsg
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
function
normalizePushMessage
(
type
,
message
)
{
try
{
try
{
return
JSON
.
parse
(
message
);
const
res
=
JSON
.
parse
(
message
);
if
(
type
===
'
receive
'
)
{
if
(
res
.
payload
)
{
if
(
res
.
aps
)
{
res
.
payload
.
aps
=
res
.
aps
;
}
return
res
.
payload
;
}
}
else
if
(
type
===
'
click
'
)
{
delete
res
.
type
;
delete
res
.
__UUID__
;
delete
res
.
appid
;
if
(
res
.
aps
&&
res
.
aps
.
alert
)
{
res
.
title
=
res
.
aps
.
alert
.
title
;
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
}
return
message
;
return
message
;
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
}
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
'
receive
'
,
args
.
message
),
});
});
});
}
}
else
if
(
args
.
type
===
'
click
'
)
{
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
'
click
'
,
args
.
message
),
});
});
});
}
}
}
}
...
...
packages/uni-mp-lark/dist/uni.api.esm.js
浏览文件 @
71080cf1
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
let
cid
;
let
cid
;
let
cidErrMsg
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
function
normalizePushMessage
(
type
,
message
)
{
try
{
try
{
return
JSON
.
parse
(
message
);
const
res
=
JSON
.
parse
(
message
);
if
(
type
===
'
receive
'
)
{
if
(
res
.
payload
)
{
if
(
res
.
aps
)
{
res
.
payload
.
aps
=
res
.
aps
;
}
return
res
.
payload
;
}
}
else
if
(
type
===
'
click
'
)
{
delete
res
.
type
;
delete
res
.
__UUID__
;
delete
res
.
appid
;
if
(
res
.
aps
&&
res
.
aps
.
alert
)
{
res
.
title
=
res
.
aps
.
alert
.
title
;
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
}
return
message
;
return
message
;
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
}
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
'
receive
'
,
args
.
message
),
});
});
});
}
}
else
if
(
args
.
type
===
'
click
'
)
{
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
'
click
'
,
args
.
message
),
});
});
});
}
}
}
}
...
...
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
71080cf1
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
let
cid
;
let
cid
;
let
cidErrMsg
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
function
normalizePushMessage
(
type
,
message
)
{
try
{
try
{
return
JSON
.
parse
(
message
);
const
res
=
JSON
.
parse
(
message
);
if
(
type
===
'
receive
'
)
{
if
(
res
.
payload
)
{
if
(
res
.
aps
)
{
res
.
payload
.
aps
=
res
.
aps
;
}
return
res
.
payload
;
}
}
else
if
(
type
===
'
click
'
)
{
delete
res
.
type
;
delete
res
.
__UUID__
;
delete
res
.
appid
;
if
(
res
.
aps
&&
res
.
aps
.
alert
)
{
res
.
title
=
res
.
aps
.
alert
.
title
;
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
}
return
message
;
return
message
;
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
}
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
'
receive
'
,
args
.
message
),
});
});
});
}
}
else
if
(
args
.
type
===
'
click
'
)
{
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
'
click
'
,
args
.
message
),
});
});
});
}
}
}
}
...
...
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
71080cf1
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
let
cid
;
let
cid
;
let
cidErrMsg
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
function
normalizePushMessage
(
type
,
message
)
{
try
{
try
{
return
JSON
.
parse
(
message
);
const
res
=
JSON
.
parse
(
message
);
if
(
type
===
'
receive
'
)
{
if
(
res
.
payload
)
{
if
(
res
.
aps
)
{
res
.
payload
.
aps
=
res
.
aps
;
}
return
res
.
payload
;
}
}
else
if
(
type
===
'
click
'
)
{
delete
res
.
type
;
delete
res
.
__UUID__
;
delete
res
.
appid
;
if
(
res
.
aps
&&
res
.
aps
.
alert
)
{
res
.
title
=
res
.
aps
.
alert
.
title
;
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
}
return
message
;
return
message
;
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
}
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
'
receive
'
,
args
.
message
),
});
});
});
}
}
else
if
(
args
.
type
===
'
click
'
)
{
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
'
click
'
,
args
.
message
),
});
});
});
}
}
}
}
...
...
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
71080cf1
...
@@ -504,9 +504,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -504,9 +504,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
let
cid
;
let
cid
;
let
cidErrMsg
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
function
normalizePushMessage
(
type
,
message
)
{
try
{
try
{
return
JSON
.
parse
(
message
);
const
res
=
JSON
.
parse
(
message
);
if
(
type
===
'
receive
'
)
{
if
(
res
.
payload
)
{
if
(
res
.
aps
)
{
res
.
payload
.
aps
=
res
.
aps
;
}
return
res
.
payload
;
}
}
else
if
(
type
===
'
click
'
)
{
delete
res
.
type
;
delete
res
.
__UUID__
;
delete
res
.
appid
;
if
(
res
.
aps
&&
res
.
aps
.
alert
)
{
res
.
title
=
res
.
aps
.
alert
.
title
;
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
}
return
message
;
return
message
;
...
@@ -523,12 +539,18 @@ function invokePushCallback(args) {
...
@@ -523,12 +539,18 @@ function invokePushCallback(args) {
}
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
'
receive
'
,
args
.
message
),
});
});
});
}
}
else
if
(
args
.
type
===
'
click
'
)
{
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
'
click
'
,
args
.
message
),
});
});
});
}
}
}
}
...
...
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
71080cf1
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
...
@@ -540,9 +540,25 @@ const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
let
cid
;
let
cid
;
let
cidErrMsg
;
let
cidErrMsg
;
function
normalizePushMessage
(
message
)
{
function
normalizePushMessage
(
type
,
message
)
{
try
{
try
{
return
JSON
.
parse
(
message
);
const
res
=
JSON
.
parse
(
message
);
if
(
type
===
'
receive
'
)
{
if
(
res
.
payload
)
{
if
(
res
.
aps
)
{
res
.
payload
.
aps
=
res
.
aps
;
}
return
res
.
payload
;
}
}
else
if
(
type
===
'
click
'
)
{
delete
res
.
type
;
delete
res
.
__UUID__
;
delete
res
.
appid
;
if
(
res
.
aps
&&
res
.
aps
.
alert
)
{
res
.
title
=
res
.
aps
.
alert
.
title
;
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
}
return
message
;
return
message
;
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
...
@@ -559,12 +575,18 @@ function invokePushCallback(args) {
}
}
else
if
(
args
.
type
===
'
pushMsg
'
)
{
else
if
(
args
.
type
===
'
pushMsg
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
receive
'
,
data
:
normalizePushMessage
(
'
receive
'
,
args
.
message
),
});
});
});
}
}
else
if
(
args
.
type
===
'
click
'
)
{
else
if
(
args
.
type
===
'
click
'
)
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
onPushMessageCallbacks
.
forEach
((
callback
)
=>
{
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
args
.
message
)
});
callback
({
type
:
'
click
'
,
data
:
normalizePushMessage
(
'
click
'
,
args
.
message
),
});
});
});
}
}
}
}
...
...
packages/uni-stacktracey/dist/uni-stacktracey.es.js
浏览文件 @
71080cf1
...
@@ -2,209 +2,209 @@ import fs from 'fs';
...
@@ -2,209 +2,209 @@ import fs from 'fs';
import
StackTracey
from
'
stacktracey
'
;
import
StackTracey
from
'
stacktracey
'
;
import
{
SourceMapConsumer
}
from
'
source-map
'
;
import
{
SourceMapConsumer
}
from
'
source-map
'
;
// @ts-ignore
// @ts-ignore
{
{
// @ts-ignore
// @ts-ignore
SourceMapConsumer
.
initialize
({
SourceMapConsumer
.
initialize
({
'
lib/mappings.wasm
'
:
'
https://unpkg.com/source-map@0.7.3/lib/mappings.wasm
'
,
'
lib/mappings.wasm
'
:
'
https://unpkg.com/source-map@0.7.3/lib/mappings.wasm
'
,
});
});
}
}
const
nixSlashes
=
(
x
)
=>
x
.
replace
(
/
\\
/g
,
'
/
'
);
const
nixSlashes
=
(
x
)
=>
x
.
replace
(
/
\\
/g
,
'
/
'
);
const
sourcemapCatch
=
{};
const
sourcemapCatch
=
{};
function
stacktracey
(
stacktrace
,
opts
)
{
function
stacktracey
(
stacktrace
,
opts
)
{
const
parseStack
=
[];
const
parseStack
=
[];
const
stack
=
opts
.
preset
.
parseStacktrace
(
stacktrace
);
const
stack
=
opts
.
preset
.
parseStacktrace
(
stacktrace
);
stack
.
items
.
forEach
((
item
,
index
)
=>
{
stack
.
items
.
forEach
((
item
,
index
)
=>
{
const
fn
=
()
=>
{
const
fn
=
()
=>
{
const
{
line
=
0
,
column
=
0
,
file
,
fileName
}
=
item
;
const
{
line
=
0
,
column
=
0
,
file
,
fileName
}
=
item
;
try
{
try
{
return
opts
.
preset
return
opts
.
preset
.
getSourceMapContent
(
file
,
fileName
)
.
getSourceMapContent
(
file
,
fileName
)
.
then
((
content
)
=>
{
.
then
((
content
)
=>
{
if
(
content
)
if
(
content
)
return
SourceMapConsumer
.
with
(
content
,
null
,
(
consumer
)
=>
{
return
SourceMapConsumer
.
with
(
content
,
null
,
(
consumer
)
=>
{
const
sourceMapContent
=
parseSourceMapContent
(
consumer
,
{
const
sourceMapContent
=
parseSourceMapContent
(
consumer
,
{
line
,
line
,
column
,
column
,
});
});
if
(
sourceMapContent
)
{
if
(
sourceMapContent
)
{
const
{
source
,
sourcePath
,
sourceLine
,
sourceColumn
,
fileName
=
''
,
}
=
sourceMapContent
;
const
{
source
,
sourcePath
,
sourceLine
,
sourceColumn
,
fileName
=
''
,
}
=
sourceMapContent
;
stack
.
items
[
index
]
=
Object
.
assign
({},
item
,
{
stack
.
items
[
index
]
=
Object
.
assign
({},
item
,
{
file
:
source
,
file
:
source
,
line
:
sourceLine
,
line
:
sourceLine
,
column
:
sourceColumn
,
column
:
sourceColumn
,
fileShort
:
sourcePath
,
fileShort
:
sourcePath
,
fileRelative
:
sourcePath
,
fileRelative
:
sourcePath
,
fileName
,
fileName
,
});
});
}
}
});
});
});
});
}
}
catch
(
error
)
{
catch
(
error
)
{
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
};
};
parseStack
.
push
(
fn
());
parseStack
.
push
(
fn
());
});
});
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
Promise
.
all
(
parseStack
)
Promise
.
all
(
parseStack
)
.
then
(()
=>
{
.
then
(()
=>
{
const
parseError
=
opts
.
preset
.
asTableStacktrace
({
const
parseError
=
opts
.
preset
.
asTableStacktrace
({
stack
,
stack
,
maxColumnWidths
:
{
maxColumnWidths
:
{
callee
:
999
,
callee
:
999
,
file
:
999
,
file
:
999
,
sourceLine
:
999
,
sourceLine
:
999
,
},
},
stacktrace
,
stacktrace
,
});
});
resolve
(
parseError
);
resolve
(
parseError
);
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
resolve
(
stacktrace
);
resolve
(
stacktrace
);
});
});
});
});
}
}
function
getSourceMapContent
(
sourcemapUrl
)
{
function
getSourceMapContent
(
sourcemapUrl
)
{
try
{
try
{
return
(
sourcemapCatch
[
sourcemapUrl
]
||
return
(
sourcemapCatch
[
sourcemapUrl
]
||
(
sourcemapCatch
[
sourcemapUrl
]
=
new
Promise
((
resolve
,
reject
)
=>
{
(
sourcemapCatch
[
sourcemapUrl
]
=
new
Promise
((
resolve
,
reject
)
=>
{
try
{
try
{
if
(
/^
[
http|https
]
+:/i
.
test
(
sourcemapUrl
))
{
if
(
/^
[
http|https
]
+:/i
.
test
(
sourcemapUrl
))
{
uni
.
request
({
uni
.
request
({
url
:
sourcemapUrl
,
url
:
sourcemapUrl
,
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
sourcemapCatch
[
sourcemapUrl
]
=
res
.
data
;
sourcemapCatch
[
sourcemapUrl
]
=
res
.
data
;
resolve
(
sourcemapCatch
[
sourcemapUrl
]);
resolve
(
sourcemapCatch
[
sourcemapUrl
]);
},
},
});
});
}
}
else
{
else
{
sourcemapCatch
[
sourcemapUrl
]
=
fs
.
readFileSync
(
sourcemapUrl
,
'
utf-8
'
);
sourcemapCatch
[
sourcemapUrl
]
=
fs
.
readFileSync
(
sourcemapUrl
,
'
utf-8
'
);
resolve
(
sourcemapCatch
[
sourcemapUrl
]);
resolve
(
sourcemapCatch
[
sourcemapUrl
]);
}
}
}
}
catch
(
error
)
{
catch
(
error
)
{
resolve
(
''
);
resolve
(
''
);
}
}
})));
})));
}
}
catch
(
error
)
{
catch
(
error
)
{
return
''
;
return
''
;
}
}
}
}
function
parseSourceMapContent
(
consumer
,
obj
)
{
function
parseSourceMapContent
(
consumer
,
obj
)
{
// source -> 'uni-app:///node_modules/@sentry/browser/esm/helpers.js'
// source -> 'uni-app:///node_modules/@sentry/browser/esm/helpers.js'
const
{
source
,
line
:
sourceLine
,
column
:
sourceColumn
,
}
=
consumer
.
originalPositionFor
(
obj
);
const
{
source
,
line
:
sourceLine
,
column
:
sourceColumn
,
}
=
consumer
.
originalPositionFor
(
obj
);
if
(
source
)
{
if
(
source
)
{
const
sourcePathSplit
=
source
.
split
(
'
/
'
);
const
sourcePathSplit
=
source
.
split
(
'
/
'
);
const
sourcePath
=
sourcePathSplit
.
slice
(
3
).
join
(
'
/
'
);
const
sourcePath
=
sourcePathSplit
.
slice
(
3
).
join
(
'
/
'
);
const
fileName
=
sourcePathSplit
.
pop
();
const
fileName
=
sourcePathSplit
.
pop
();
return
{
return
{
source
,
source
,
sourcePath
,
sourcePath
,
sourceLine
:
sourceLine
===
null
?
0
:
sourceLine
,
sourceLine
:
sourceLine
===
null
?
0
:
sourceLine
,
sourceColumn
:
sourceColumn
===
null
?
0
:
sourceColumn
,
sourceColumn
:
sourceColumn
===
null
?
0
:
sourceColumn
,
fileName
,
fileName
,
};
};
}
}
}
}
function
uniStracktraceyPreset
(
opts
)
{
function
uniStracktraceyPreset
(
opts
)
{
const
{
base
,
sourceRoot
}
=
opts
;
const
{
base
,
sourceRoot
}
=
opts
;
return
{
return
{
parseSourceMapUrl
(
file
,
fileName
)
{
parseSourceMapUrl
(
file
,
fileName
)
{
// 组合 sourceMapUrl
// 组合 sourceMapUrl
if
(
!
base
)
if
(
!
base
)
return
''
;
return
''
;
file
=
(
file
.
match
(
/
(\/
.*
)
/
)
||
[])[
1
];
file
=
(
file
.
match
(
/
(\/
.*
)
/
)
||
[])[
1
];
if
(
!
file
)
if
(
!
file
)
return
''
;
return
''
;
if
(
sourceRoot
)
{
if
(
sourceRoot
)
{
return
`
${
file
.
replace
(
sourceRoot
,
base
+
'
/
'
)}
.map`
;
return
`
${
file
.
replace
(
sourceRoot
,
base
+
'
/
'
)}
.map`
;
}
}
return
`
${
base
}
/
${
file
}
.map`
;
return
`
${
base
}
/
${
file
}
.map`
;
},
},
getSourceMapContent
(
file
,
fileName
)
{
getSourceMapContent
(
file
,
fileName
)
{
return
Promise
.
resolve
(
getSourceMapContent
(
this
.
parseSourceMapUrl
(
file
,
fileName
)));
return
Promise
.
resolve
(
getSourceMapContent
(
this
.
parseSourceMapUrl
(
file
,
fileName
)));
},
},
parseStacktrace
(
stacktrace
)
{
parseStacktrace
(
stacktrace
)
{
return
new
StackTracey
(
stacktrace
);
return
new
StackTracey
(
stacktrace
);
},
},
asTableStacktrace
({
maxColumnWidths
,
stacktrace
,
stack
})
{
asTableStacktrace
({
maxColumnWidths
,
stacktrace
,
stack
})
{
const
errorName
=
stacktrace
.
split
(
'
\n
'
)[
0
];
const
errorName
=
stacktrace
.
split
(
'
\n
'
)[
0
];
return
((
errorName
.
indexOf
(
'
at
'
)
===
-
1
?
`
${
errorName
}
\n`
:
''
)
+
return
((
errorName
.
indexOf
(
'
at
'
)
===
-
1
?
`
${
errorName
}
\n`
:
''
)
+
(
stack
.
asTable
?
stack
.
asTable
({
maxColumnWidths
})
:
''
));
(
stack
.
asTable
?
stack
.
asTable
({
maxColumnWidths
})
:
''
));
},
},
};
};
}
}
function
utsStracktraceyPreset
(
opts
)
{
function
utsStracktraceyPreset
(
opts
)
{
const
{
base
,
sourceRoot
}
=
opts
;
const
{
base
,
sourceRoot
}
=
opts
;
let
errStack
=
[];
let
errStack
=
[];
return
{
return
{
parseSourceMapUrl
(
file
,
fileName
)
{
parseSourceMapUrl
(
file
,
fileName
)
{
// 组合 sourceMapUrl
// 组合 sourceMapUrl
if
(
sourceRoot
)
{
if
(
sourceRoot
)
{
return
`
${
file
.
replace
(
sourceRoot
,
base
+
'
/
'
)}
.map`
;
return
`
${
file
.
replace
(
sourceRoot
,
base
+
'
/
'
)}
.map`
;
}
}
return
`
${
base
}
/
${
file
}
.map`
;
return
`
${
base
}
/
${
file
}
.map`
;
},
},
getSourceMapContent
(
file
,
fileName
)
{
getSourceMapContent
(
file
,
fileName
)
{
// 根据 base,filename 组合 sourceMapUrl
// 根据 base,filename 组合 sourceMapUrl
return
Promise
.
resolve
(
getSourceMapContent
(
this
.
parseSourceMapUrl
(
file
,
fileName
)));
return
Promise
.
resolve
(
getSourceMapContent
(
this
.
parseSourceMapUrl
(
file
,
fileName
)));
},
},
parseStacktrace
(
str
)
{
parseStacktrace
(
str
)
{
const
lines
=
(
str
||
''
).
split
(
'
\n
'
);
const
lines
=
(
str
||
''
).
split
(
'
\n
'
);
const
entries
=
lines
const
entries
=
lines
.
map
((
line
,
index
)
=>
{
.
map
((
line
,
index
)
=>
{
line
=
line
.
trim
();
line
=
line
.
trim
();
let
callee
,
fileLineColumn
=
[],
planA
,
planB
;
let
callee
,
fileLineColumn
=
[],
planA
,
planB
;
if
((
planA
=
line
.
match
(
/e:
(
.+
\.
kt
)(
.+
\))
*:
\s
*
(
.+
)
*/
)))
{
if
((
planA
=
line
.
match
(
/e:
(
.+
\.
kt
)(
.+
\))
*:
\s
*
(
.+
)
*/
)))
{
errStack
.
push
(
'
%StacktraceyItem%
'
);
errStack
.
push
(
'
%StacktraceyItem%
'
);
callee
=
'
e:
'
;
callee
=
'
e:
'
;
fileLineColumn
=
(
planA
[
2
].
match
(
/.*:.*
\((\d
+
)
.+
?(\d
+
)\)
/
)
||
[]).
slice
(
1
);
fileLineColumn
=
(
planA
[
2
].
match
(
/.*:.*
\((\d
+
)
.+
?(\d
+
)\)
/
)
||
[]).
slice
(
1
);
}
}
else
{
else
{
errStack
.
push
(
line
);
errStack
.
push
(
line
);
return
undefined
;
return
undefined
;
}
}
const
fileName
=
planA
[
1
]
const
fileName
=
planA
[
1
]
?
(
planB
=
planA
[
1
].
match
(
/
(
.*
)
*
\/(
.+
)
/
)
||
[])[
2
]
||
''
?
(
planB
=
planA
[
1
].
match
(
/
(
.*
)
*
\/(
.+
)
/
)
||
[])[
2
]
||
''
:
''
;
:
''
;
return
{
return
{
beforeParse
:
line
,
beforeParse
:
line
,
callee
:
callee
||
''
,
callee
:
callee
||
''
,
index
:
false
,
index
:
false
,
native
:
false
,
native
:
false
,
file
:
nixSlashes
(
planA
[
1
]
||
''
),
file
:
nixSlashes
(
planA
[
1
]
||
''
),
line
:
parseInt
(
fileLineColumn
[
0
]
||
''
,
10
)
||
undefined
,
line
:
parseInt
(
fileLineColumn
[
0
]
||
''
,
10
)
||
undefined
,
column
:
parseInt
(
fileLineColumn
[
1
]
||
''
,
10
)
||
undefined
,
column
:
parseInt
(
fileLineColumn
[
1
]
||
''
,
10
)
||
undefined
,
fileName
,
fileName
,
fileShort
:
planB
?
planB
[
1
]
:
''
,
fileShort
:
planB
?
planB
[
1
]
:
''
,
errMsg
:
planA
[
3
]
||
''
,
errMsg
:
planA
[
3
]
||
''
,
calleeShort
:
''
,
calleeShort
:
''
,
fileRelative
:
''
,
fileRelative
:
''
,
thirdParty
:
false
,
thirdParty
:
false
,
};
};
})
})
.
filter
((
x
)
=>
x
!==
undefined
);
.
filter
((
x
)
=>
x
!==
undefined
);
return
{
return
{
items
:
entries
,
items
:
entries
,
};
};
},
},
asTableStacktrace
({
maxColumnWidths
,
stacktrace
,
stack
})
{
asTableStacktrace
({
maxColumnWidths
,
stacktrace
,
stack
})
{
return
errStack
return
errStack
.
map
((
item
)
=>
{
.
map
((
item
)
=>
{
if
(
item
===
'
%StacktraceyItem%
'
)
{
if
(
item
===
'
%StacktraceyItem%
'
)
{
const
_stack
=
stack
.
items
.
shift
();
const
_stack
=
stack
.
items
.
shift
();
if
(
_stack
)
if
(
_stack
)
return
`
${
_stack
.
callee
}${
_stack
.
file
}
: (
${
_stack
.
line
}
,
${
_stack
.
column
}
):
${
_stack
.
errMsg
}
`
;
return
`
${
_stack
.
callee
}${
_stack
.
file
}
: (
${
_stack
.
line
}
,
${
_stack
.
column
}
):
${
_stack
.
errMsg
}
`
;
}
}
return
item
;
return
item
;
})
})
.
join
(
'
\n
'
);
.
join
(
'
\n
'
);
},
},
};
};
}
}
export
{
stacktracey
,
uniStracktraceyPreset
,
utsStracktraceyPreset
};
export
{
stacktracey
,
uniStracktraceyPreset
,
utsStracktraceyPreset
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录