Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
2ed7adc2
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,体验更适合开发者的 AI 搜索 >>
提交
2ed7adc2
编写于
6月 28, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore(uni-stacktracey): fix path parse
上级
8bc4df01
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
108 addition
and
47 deletion
+108
-47
packages/uni-stacktracey/dist/uni-stacktracey.cjs.js
packages/uni-stacktracey/dist/uni-stacktracey.cjs.js
+35
-16
packages/uni-stacktracey/dist/uni-stacktracey.es.js
packages/uni-stacktracey/dist/uni-stacktracey.es.js
+35
-16
packages/uni-stacktracey/src/index.ts
packages/uni-stacktracey/src/index.ts
+30
-11
packages/uni-stacktracey/src/stacktracey.ts
packages/uni-stacktracey/src/stacktracey.ts
+8
-4
未找到文件。
packages/uni-stacktracey/dist/uni-stacktracey.cjs.js
浏览文件 @
2ed7adc2
...
...
@@ -20,7 +20,7 @@ typeof window !== 'undefined' &&
lastOf
=
(
x
)
=>
x
[
x
.
length
-
1
],
nixSlashes$1
=
(
x
)
=>
x
.
replace
(
/
\\
/g
,
'
/
'
),
pathRoot
=
isBrowser
?
window
.
location
.
href
:
nixSlashes$1
(
process
.
cwd
())
+
'
/
'
;
/* ------------------------------------------------------------------------ */
class
StackTracey
{
constructor
(
input
,
offset
)
{
constructor
(
input
,
uniPlatform
,
offset
)
{
this
.
itemsHeader
=
[];
this
.
isMP
=
false
;
const
originalInput
=
input
,
isParseableSyntaxError
=
input
&&
input
instanceof
SyntaxError
&&
!
isBrowser
;
...
...
@@ -35,7 +35,7 @@ class StackTracey {
}
/* new StackTracey (string) */
if
(
typeof
input
===
'
string
'
)
{
this
.
isMP
=
input
.
indexOf
(
'
MiniProgramError
'
)
!==
-
1
;
this
.
isMP
=
uniPlatform
===
'
mp-weixin
'
;
input
=
this
.
rawParse
(
input
)
.
slice
(
offset
)
.
map
((
x
)
=>
this
.
extractEntryMetadata
(
x
));
...
...
@@ -86,13 +86,12 @@ class StackTracey {
let
result
=
fullPath
;
if
(
isBrowser
)
result
=
result
.
replace
(
pathRoot
,
''
);
const
externalDomainMatch
=
result
.
match
(
/^
(
http|https
)\:\/\/?([^\/]
+
)\/(
.*
)
/
);
const
externalDomainMatch
=
result
.
match
(
/^
(
http|https
)\:\/\/?([^\/]
+
)\/
{1,}
(
.*
)
/
);
const
externalDomain
=
externalDomainMatch
?
externalDomainMatch
[
2
]
:
undefined
;
result
=
externalDomainMatch
?
externalDomainMatch
[
3
]
:
result
;
if
(
!
isBrowser
)
result
=
nodeRequire
(
'
path
'
).
relative
(
pathRoot
,
result
);
// if (!isBrowser) result = nodeRequire!('path').relative(pathRoot, result)
return
[
nixSlashes$1
(
result
).
replace
(
/^.*
\:\/\/?\/?
/
,
''
),
externalDomain
,
...
...
@@ -288,14 +287,20 @@ function isThirdParty(relativePath) {
}
function
getConsumer
(
content
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
sourceMap
.
SourceMapConsumer
.
with
)
{
sourceMap
.
SourceMapConsumer
.
with
(
content
,
null
,
(
consumer
)
=>
{
try
{
if
(
sourceMap
.
SourceMapConsumer
.
with
)
{
sourceMap
.
SourceMapConsumer
.
with
(
content
,
null
,
(
consumer
)
=>
{
resolve
(
consumer
);
});
}
else
{
// @ts-ignore
const
consumer
=
sourceMap
.
SourceMapConsumer
(
content
);
resolve
(
consumer
);
}
);
}
}
else
{
// @ts-ignore
resolve
(
sourceMap
.
SourceMapConsumer
(
content
));
catch
(
error
)
{
reject
();
}
});
}
...
...
@@ -308,8 +313,16 @@ function getSourceMapContent(sourcemapUrl) {
uni
.
request
({
url
:
sourcemapUrl
,
success
:
(
res
)
=>
{
sourcemapCatch
[
sourcemapUrl
]
=
res
.
data
;
resolve
(
sourcemapCatch
[
sourcemapUrl
]);
if
(
res
.
statusCode
===
200
)
{
sourcemapCatch
[
sourcemapUrl
]
=
res
.
data
;
resolve
(
sourcemapCatch
[
sourcemapUrl
]);
}
else
{
resolve
((
sourcemapCatch
[
sourcemapUrl
]
=
''
));
}
},
fail
()
{
resolve
((
sourcemapCatch
[
sourcemapUrl
]
=
''
));
},
});
}
...
...
@@ -350,7 +363,7 @@ function joinItem(item) {
return
`
${
a
}${
b
}${
c
}
`
;
}
function
uniStracktraceyPreset
(
opts
)
{
const
{
base
,
sourceRoot
,
splitThirdParty
}
=
opts
;
const
{
base
,
sourceRoot
,
splitThirdParty
,
uniPlatform
}
=
opts
;
let
stack
;
return
{
/**
...
...
@@ -373,7 +386,7 @@ function uniStracktraceyPreset(opts) {
let
baseAfter
=
''
;
if
(
stack
.
isMP
)
{
if
(
fileRelative
.
indexOf
(
'
app-service.js
'
)
!==
-
1
)
{
baseAfter
=
(
base
.
match
(
/
\w
$/
)
?
'
/
'
:
''
)
+
'
weixin
'
;
baseAfter
=
(
base
.
match
(
/
\w
$/
)
?
'
/
'
:
''
)
+
'
__WEIXIN__
'
;
if
(
fileRelative
===
fileName
)
{
baseAfter
+=
'
/__APP__
'
;
}
...
...
@@ -392,7 +405,7 @@ function uniStracktraceyPreset(opts) {
return
Promise
.
resolve
(
getSourceMapContent
(
sourcemapUrl
));
},
parseStacktrace
(
stacktrace
)
{
stack
=
new
StackTracey$1
(
stacktrace
);
stack
=
new
StackTracey$1
(
stacktrace
,
uniPlatform
);
return
stack
;
},
asTableStacktrace
({
maxColumnWidths
,
stacktrace
,
stack
})
{
...
...
@@ -424,6 +437,12 @@ function uniStracktraceyPreset(opts) {
return
userError
+
'
\n
'
+
thirdParty
;
}
else
{
if
(
splitThirdParty
)
{
return
{
userError
:
errorName
,
thirdParty
:
''
,
};
}
return
errorName
;
}
},
...
...
packages/uni-stacktracey/dist/uni-stacktracey.es.js
浏览文件 @
2ed7adc2
...
...
@@ -12,7 +12,7 @@ typeof window !== 'undefined' &&
lastOf
=
(
x
)
=>
x
[
x
.
length
-
1
],
nixSlashes$1
=
(
x
)
=>
x
.
replace
(
/
\\
/g
,
'
/
'
),
pathRoot
=
isBrowser
?
window
.
location
.
href
:
nixSlashes$1
(
process
.
cwd
())
+
'
/
'
;
/* ------------------------------------------------------------------------ */
class
StackTracey
{
constructor
(
input
,
offset
)
{
constructor
(
input
,
uniPlatform
,
offset
)
{
this
.
itemsHeader
=
[];
this
.
isMP
=
false
;
const
originalInput
=
input
,
isParseableSyntaxError
=
input
&&
input
instanceof
SyntaxError
&&
!
isBrowser
;
...
...
@@ -27,7 +27,7 @@ class StackTracey {
}
/* new StackTracey (string) */
if
(
typeof
input
===
'
string
'
)
{
this
.
isMP
=
input
.
indexOf
(
'
MiniProgramError
'
)
!==
-
1
;
this
.
isMP
=
uniPlatform
===
'
mp-weixin
'
;
input
=
this
.
rawParse
(
input
)
.
slice
(
offset
)
.
map
((
x
)
=>
this
.
extractEntryMetadata
(
x
));
...
...
@@ -78,13 +78,12 @@ class StackTracey {
let
result
=
fullPath
;
if
(
isBrowser
)
result
=
result
.
replace
(
pathRoot
,
''
);
const
externalDomainMatch
=
result
.
match
(
/^
(
http|https
)\:\/\/?([^\/]
+
)\/(
.*
)
/
);
const
externalDomainMatch
=
result
.
match
(
/^
(
http|https
)\:\/\/?([^\/]
+
)\/
{1,}
(
.*
)
/
);
const
externalDomain
=
externalDomainMatch
?
externalDomainMatch
[
2
]
:
undefined
;
result
=
externalDomainMatch
?
externalDomainMatch
[
3
]
:
result
;
if
(
!
isBrowser
)
result
=
nodeRequire
(
'
path
'
).
relative
(
pathRoot
,
result
);
// if (!isBrowser) result = nodeRequire!('path').relative(pathRoot, result)
return
[
nixSlashes$1
(
result
).
replace
(
/^.*
\:\/\/?\/?
/
,
''
),
externalDomain
,
...
...
@@ -290,14 +289,20 @@ function isThirdParty(relativePath) {
}
function
getConsumer
(
content
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
SourceMapConsumer
.
with
)
{
SourceMapConsumer
.
with
(
content
,
null
,
(
consumer
)
=>
{
try
{
if
(
SourceMapConsumer
.
with
)
{
SourceMapConsumer
.
with
(
content
,
null
,
(
consumer
)
=>
{
resolve
(
consumer
);
});
}
else
{
// @ts-ignore
const
consumer
=
SourceMapConsumer
(
content
);
resolve
(
consumer
);
}
);
}
}
else
{
// @ts-ignore
resolve
(
SourceMapConsumer
(
content
));
catch
(
error
)
{
reject
();
}
});
}
...
...
@@ -310,8 +315,16 @@ function getSourceMapContent(sourcemapUrl) {
uni
.
request
({
url
:
sourcemapUrl
,
success
:
(
res
)
=>
{
sourcemapCatch
[
sourcemapUrl
]
=
res
.
data
;
resolve
(
sourcemapCatch
[
sourcemapUrl
]);
if
(
res
.
statusCode
===
200
)
{
sourcemapCatch
[
sourcemapUrl
]
=
res
.
data
;
resolve
(
sourcemapCatch
[
sourcemapUrl
]);
}
else
{
resolve
((
sourcemapCatch
[
sourcemapUrl
]
=
''
));
}
},
fail
()
{
resolve
((
sourcemapCatch
[
sourcemapUrl
]
=
''
));
},
});
}
...
...
@@ -352,7 +365,7 @@ function joinItem(item) {
return
`
${
a
}${
b
}${
c
}
`
;
}
function
uniStracktraceyPreset
(
opts
)
{
const
{
base
,
sourceRoot
,
splitThirdParty
}
=
opts
;
const
{
base
,
sourceRoot
,
splitThirdParty
,
uniPlatform
}
=
opts
;
let
stack
;
return
{
/**
...
...
@@ -375,7 +388,7 @@ function uniStracktraceyPreset(opts) {
let
baseAfter
=
''
;
if
(
stack
.
isMP
)
{
if
(
fileRelative
.
indexOf
(
'
app-service.js
'
)
!==
-
1
)
{
baseAfter
=
(
base
.
match
(
/
\w
$/
)
?
'
/
'
:
''
)
+
'
weixin
'
;
baseAfter
=
(
base
.
match
(
/
\w
$/
)
?
'
/
'
:
''
)
+
'
__WEIXIN__
'
;
if
(
fileRelative
===
fileName
)
{
baseAfter
+=
'
/__APP__
'
;
}
...
...
@@ -394,7 +407,7 @@ function uniStracktraceyPreset(opts) {
return
Promise
.
resolve
(
getSourceMapContent
(
sourcemapUrl
));
},
parseStacktrace
(
stacktrace
)
{
stack
=
new
StackTracey$1
(
stacktrace
);
stack
=
new
StackTracey$1
(
stacktrace
,
uniPlatform
);
return
stack
;
},
asTableStacktrace
({
maxColumnWidths
,
stacktrace
,
stack
})
{
...
...
@@ -426,6 +439,12 @@ function uniStracktraceyPreset(opts) {
return
userError
+
'
\n
'
+
thirdParty
;
}
else
{
if
(
splitThirdParty
)
{
return
{
userError
:
errorName
,
thirdParty
:
''
,
};
}
return
errorName
;
}
},
...
...
packages/uni-stacktracey/src/index.ts
浏览文件 @
2ed7adc2
...
...
@@ -197,13 +197,18 @@ function getConsumer(
content
:
string
):
Promise
<
BasicSourceMapConsumer
|
IndexedSourceMapConsumer
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
SourceMapConsumer
.
with
)
{
SourceMapConsumer
.
with
(
content
,
null
,
(
consumer
)
=>
{
try
{
if
(
SourceMapConsumer
.
with
)
{
SourceMapConsumer
.
with
(
content
,
null
,
(
consumer
)
=>
{
resolve
(
consumer
)
})
}
else
{
// @ts-ignore
const
consumer
=
SourceMapConsumer
(
content
)
resolve
(
consumer
)
})
}
else
{
// @ts-ignore
resolve
(
SourceMapConsumer
(
content
))
}
}
catch
(
error
)
{
reject
()
}
})
}
...
...
@@ -218,8 +223,15 @@ function getSourceMapContent(sourcemapUrl: string) {
uni
.
request
({
url
:
sourcemapUrl
,
success
:
(
res
)
=>
{
sourcemapCatch
[
sourcemapUrl
]
=
res
.
data
as
string
resolve
(
sourcemapCatch
[
sourcemapUrl
])
if
(
res
.
statusCode
===
200
)
{
sourcemapCatch
[
sourcemapUrl
]
=
res
.
data
as
string
resolve
(
sourcemapCatch
[
sourcemapUrl
])
}
else
{
resolve
((
sourcemapCatch
[
sourcemapUrl
]
=
''
))
}
},
fail
()
{
resolve
((
sourcemapCatch
[
sourcemapUrl
]
=
''
))
},
})
}
else
{
...
...
@@ -275,6 +287,7 @@ interface UniStracktraceyPresetOptions {
base
:
string
sourceRoot
:
string
splitThirdParty
?:
boolean
uniPlatform
?:
string
}
function
joinItem
(
item
:
string
[])
{
...
...
@@ -287,7 +300,7 @@ function joinItem(item: string[]) {
export
function
uniStracktraceyPreset
(
opts
:
UniStracktraceyPresetOptions
):
StacktraceyPreset
{
const
{
base
,
sourceRoot
,
splitThirdParty
}
=
opts
const
{
base
,
sourceRoot
,
splitThirdParty
,
uniPlatform
}
=
opts
let
stack
:
StackTracey
...
...
@@ -311,7 +324,7 @@ export function uniStracktraceyPreset(
let
baseAfter
=
''
if
(
stack
.
isMP
)
{
if
(
fileRelative
.
indexOf
(
'
app-service.js
'
)
!==
-
1
)
{
baseAfter
=
(
base
.
match
(
/
\w
$/
)
?
'
/
'
:
''
)
+
'
weixin
'
baseAfter
=
(
base
.
match
(
/
\w
$/
)
?
'
/
'
:
''
)
+
'
__WEIXIN__
'
if
(
fileRelative
===
fileName
)
{
baseAfter
+=
'
/__APP__
'
}
...
...
@@ -329,7 +342,7 @@ export function uniStracktraceyPreset(
return
Promise
.
resolve
(
getSourceMapContent
(
sourcemapUrl
))
},
parseStacktrace
(
stacktrace
)
{
stack
=
new
StackTracey
(
stacktrace
)
stack
=
new
StackTracey
(
stacktrace
,
uniPlatform
)
return
stack
},
asTableStacktrace
({
maxColumnWidths
,
stacktrace
,
stack
})
{
...
...
@@ -365,6 +378,12 @@ export function uniStracktraceyPreset(
return
userError
+
'
\n
'
+
thirdParty
}
else
{
if
(
splitThirdParty
)
{
return
{
userError
:
errorName
,
thirdParty
:
''
,
}
}
return
errorName
}
},
...
...
packages/uni-stacktracey/src/stacktracey.ts
浏览文件 @
2ed7adc2
...
...
@@ -33,7 +33,11 @@ class StackTracey {
itemsHeader
:
string
[]
=
[]
isMP
:
boolean
=
false
constructor
(
input
:
string
|
Error
|
any
,
offset
?:
number
)
{
constructor
(
input
:
string
|
Error
|
any
,
uniPlatform
?:
string
,
offset
?:
number
)
{
const
originalInput
=
input
,
isParseableSyntaxError
=
input
&&
input
instanceof
SyntaxError
&&
!
isBrowser
...
...
@@ -54,7 +58,7 @@ class StackTracey {
/* new StackTracey (string) */
if
(
typeof
input
===
'
string
'
)
{
this
.
isMP
=
input
.
indexOf
(
'
MiniProgramError
'
)
!==
-
1
this
.
isMP
=
uniPlatform
===
'
mp-weixin
'
input
=
(
this
.
rawParse
(
input
)
as
EntryMetadata
[])
.
slice
(
offset
)
.
map
((
x
:
EntryMetadata
)
=>
this
.
extractEntryMetadata
(
x
))
...
...
@@ -117,14 +121,14 @@ class StackTracey {
if
(
isBrowser
)
result
=
result
.
replace
(
pathRoot
,
''
)
const
externalDomainMatch
=
result
.
match
(
/^
(
http|https
)\:\/\/?([^\/]
+
)\/(
.*
)
/
/^
(
http|https
)\:\/\/?([^\/]
+
)\/
{1,}
(
.*
)
/
)
const
externalDomain
=
externalDomainMatch
?
externalDomainMatch
[
2
]
:
undefined
result
=
externalDomainMatch
?
externalDomainMatch
[
3
]
:
result
if
(
!
isBrowser
)
result
=
nodeRequire
!
(
'
path
'
).
relative
(
pathRoot
,
result
)
//
if (!isBrowser) result = nodeRequire!('path').relative(pathRoot, result)
return
[
nixSlashes
(
result
).
replace
(
/^.*
\:\/\/?\/?
/
,
''
),
// cut webpack:/// and webpack:/ things
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录