Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
de881845
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,体验更适合开发者的 AI 搜索 >>
提交
de881845
编写于
5月 18, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: uni-stacktracey
上级
7b82ae5c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
84 deletion
+85
-84
packages/uni-stacktracey/dist/uni-stacktracey.cjs.js
packages/uni-stacktracey/dist/uni-stacktracey.cjs.js
+38
-43
packages/uni-stacktracey/src/index.ts
packages/uni-stacktracey/src/index.ts
+43
-37
packages/uni-stacktracey/test/index.js
packages/uni-stacktracey/test/index.js
+4
-4
未找到文件。
packages/uni-stacktracey/dist/uni-stacktracey.cjs.js
浏览文件 @
de881845
...
...
@@ -5,55 +5,43 @@ Object.defineProperty(exports, '__esModule', { value: true });
var
fs
=
require
(
'
fs
'
);
var
StackTracey
=
require
(
'
stacktracey
'
);
var
sourceMap
=
require
(
'
source-map
'
);
var
axios
=
require
(
'
axios
'
);
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'
object
'
&&
'
default
'
in
e
?
e
:
{
'
default
'
:
e
};
}
var
fs__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
fs
);
var
StackTracey__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
StackTracey
);
var
axios__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
axios
);
const
isBrowser
=
typeof
globalThis
!==
'
undefined
'
&&
globalThis
.
window
===
globalThis
&&
globalThis
.
navigator
;
const
nixSlashes
=
(
x
)
=>
x
.
replace
(
/
\\
/g
,
'
/
'
);
const
sourcemapCatch
=
{};
if
(
isBrowser
)
{
// @ts-ignore
sourceMap
.
SourceMapConsumer
.
initialize
({
'
lib/mappings.wasm
'
:
'
https://unpkg.com/source-map@0.7.3/lib/mappings.wasm
'
,
});
}
function
stacktracey
(
stacktrace
,
opts
)
{
const
parseStack
=
[];
const
stack
=
opts
.
preset
.
parseStacktrace
(
stacktrace
);
stack
.
items
.
forEach
((
item
,
index
)
=>
{
const
fn
=
()
=>
{
const
{
line
=
0
,
column
=
0
,
file
,
fileName
}
=
item
;
let
sourceMapUrl
;
try
{
sourceMapUrl
=
opts
.
preset
.
parseSourceMapUrl
(
file
,
fileName
);
if
(
sourceMapUrl
)
{
return
Promise
.
resolve
(
getSourceMapContent
(
sourceMapUrl
)).
then
((
content
)
=>
{
if
(
content
)
return
sourceMap
.
SourceMapConsumer
.
with
(
content
,
null
,
(
consumer
)
=>
{
const
sourceMapContent
=
parseSourceMapContent
(
consumer
,
{
line
,
column
,
});
if
(
sourceMapContent
)
{
const
{
source
,
sourcePath
,
sourceLine
,
sourceColumn
,
fileName
=
''
,
}
=
sourceMapContent
;
stack
.
items
[
index
]
=
Object
.
assign
({},
item
,
{
file
:
source
,
line
:
sourceLine
,
column
:
sourceColumn
,
fileShort
:
sourcePath
,
fileRelative
:
sourcePath
,
fileName
,
});
}
return
opts
.
preset
.
getSourceMapContent
(
file
,
fileName
)
.
then
((
content
)
=>
{
if
(
content
)
return
sourceMap
.
SourceMapConsumer
.
with
(
content
,
null
,
(
consumer
)
=>
{
const
sourceMapContent
=
parseSourceMapContent
(
consumer
,
{
line
,
column
,
});
});
}
return
Promise
.
resolve
();
if
(
sourceMapContent
)
{
const
{
source
,
sourcePath
,
sourceLine
,
sourceColumn
,
fileName
=
''
,
}
=
sourceMapContent
;
stack
.
items
[
index
]
=
Object
.
assign
({},
item
,
{
file
:
source
,
line
:
sourceLine
,
column
:
sourceColumn
,
fileShort
:
sourcePath
,
fileRelative
:
sourcePath
,
fileName
,
});
}
});
});
}
catch
(
error
)
{
return
Promise
.
resolve
();
...
...
@@ -85,16 +73,16 @@ function getSourceMapContent(sourcemapUrl) {
(
sourcemapCatch
[
sourcemapUrl
]
=
new
Promise
((
resolve
,
reject
)
=>
{
try
{
if
(
/^
[
a-z
]
+:/i
.
test
(
sourcemapUrl
))
{
axios__default
[
"
default
"
]
.
ge
t
(
sourcemapUrl
)
.
then
((
res
)
=>
{
console
.
log
(
'
sourcemapUrl :>>
'
,
sourcemapUrl
)
;
sourcemapCatch
[
sourcemapUrl
]
=
res
.
data
;
resolve
(
sourcemapCatch
[
sourcemapUrl
])
;
})
.
catch
((
_
)
=>
{
resolve
(
''
)
;
});
/* uni
.reques
t(sourcemapUrl)
.then((res) => {
console.log('sourcemapUrl :>> ', sourcemapUrl)
sourcemapCatch[sourcemapUrl] = res.data
resolve(sourcemapCatch[sourcemapUrl])
})
.catch((_) => {
resolve('')
}) */
}
else
{
sourcemapCatch
[
sourcemapUrl
]
=
fs__default
[
"
default
"
].
readFileSync
(
sourcemapUrl
,
'
utf-8
'
);
...
...
@@ -136,6 +124,9 @@ function uniStracktraceyPreset(opts) {
// 根据 base,platform,version,filename 组合 sourceMapUrl
return
`
${
base
}
/
${
version
}
/.sourcemap/
${
platform
}
/
${
file
.
split
(
'
.
'
)[
0
]}
.js.map`
;
},
getSourceMapContent
(
file
,
fileName
)
{
return
Promise
.
resolve
(
getSourceMapContent
(
this
.
parseSourceMapUrl
(
file
,
fileName
)));
},
parseStacktrace
(
stacktrace
)
{
return
(
stack
=
new
StackTracey__default
[
"
default
"
](
stacktrace
));
},
...
...
@@ -154,6 +145,10 @@ function utsStracktraceyPreset(opts) {
// 根据 base,filename 组合 sourceMapUrl
return
`
${
opts
.
base
}
/
${
fileName
}
.map`
;
},
getSourceMapContent
(
file
,
fileName
)
{
// 根据 base,filename 组合 sourceMapUrl
return
Promise
.
resolve
(
getSourceMapContent
(
this
.
parseSourceMapUrl
(
file
,
fileName
)));
},
parseStacktrace
(
str
)
{
const
lines
=
(
str
||
''
).
split
(
'
\n
'
);
const
entries
=
lines
...
...
packages/uni-stacktracey/src/index.ts
浏览文件 @
de881845
...
...
@@ -6,7 +6,6 @@ import {
IndexedSourceMapConsumer
,
Position
,
}
from
'
source-map
'
import
axios
from
'
axios
'
const
nixSlashes
=
(
x
:
string
)
=>
x
.
replace
(
/
\\
/g
,
'
/
'
)
const
sourcemapCatch
:
Record
<
string
,
string
|
Promise
<
string
>>
=
{}
...
...
@@ -39,6 +38,7 @@ interface StacktraceyPreset {
* @param filename
*/
parseSourceMapUrl
(
file
:
string
,
fileName
:
string
):
string
getSourceMapContent
(
file
:
string
,
fileName
:
string
):
Promise
<
string
>
}
interface
StacktraceyOptions
{
...
...
@@ -56,42 +56,37 @@ export function stacktracey(
stack
.
items
.
forEach
((
item
,
index
)
=>
{
const
fn
=
()
=>
{
const
{
line
=
0
,
column
=
0
,
file
,
fileName
}
=
item
let
sourceMapUrl
try
{
sourceMapUrl
=
opts
.
preset
.
parseSourceMapUrl
(
file
,
fileName
)
if
(
sourceMapUrl
)
{
return
Promise
.
resolve
(
getSourceMapContent
(
sourceMapUrl
)).
then
(
(
content
)
=>
{
if
(
content
)
return
SourceMapConsumer
.
with
(
content
,
null
,
(
consumer
)
=>
{
const
sourceMapContent
=
parseSourceMapContent
(
consumer
,
{
line
,
column
,
})
return
opts
.
preset
.
getSourceMapContent
(
file
,
fileName
)
.
then
((
content
)
=>
{
if
(
content
)
return
SourceMapConsumer
.
with
(
content
,
null
,
(
consumer
)
=>
{
const
sourceMapContent
=
parseSourceMapContent
(
consumer
,
{
line
,
column
,
})
if
(
sourceMapContent
)
{
const
{
source
,
sourcePath
,
sourceLine
,
sourceColumn
,
fileName
=
''
,
}
=
sourceMapContent
if
(
sourceMapContent
)
{
const
{
source
,
sourcePath
,
sourceLine
,
sourceColumn
,
fileName
=
''
,
}
=
sourceMapContent
stack
.
items
[
index
]
=
Object
.
assign
({},
item
,
{
file
:
source
,
line
:
sourceLine
,
column
:
sourceColumn
,
fileShort
:
sourcePath
,
fileRelative
:
sourcePath
,
fileName
,
})
}
})
}
)
}
return
Promise
.
resolve
()
stack
.
items
[
index
]
=
Object
.
assign
({},
item
,
{
file
:
source
,
line
:
sourceLine
,
column
:
sourceColumn
,
fileShort
:
sourcePath
,
fileRelative
:
sourcePath
,
fileName
,
})
}
})
})
}
catch
(
error
)
{
return
Promise
.
resolve
()
}
...
...
@@ -125,8 +120,8 @@ function getSourceMapContent(sourcemapUrl: string) {
(
sourcemapCatch
[
sourcemapUrl
]
=
new
Promise
((
resolve
,
reject
)
=>
{
try
{
if
(
/^
[
a-z
]
+:/i
.
test
(
sourcemapUrl
))
{
axios
.
ge
t
(
sourcemapUrl
)
/* uni
.
reques
t(sourcemapUrl)
.then((res) => {
console.log('sourcemapUrl :>> ', sourcemapUrl)
sourcemapCatch[sourcemapUrl] = res.data
...
...
@@ -134,7 +129,7 @@ function getSourceMapContent(sourcemapUrl: string) {
})
.catch((_) => {
resolve('')
})
})
*/
}
else
{
sourcemapCatch
[
sourcemapUrl
]
=
fs
.
readFileSync
(
sourcemapUrl
,
...
...
@@ -207,6 +202,11 @@ export function uniStracktraceyPreset(
file
.
split
(
'
.
'
)[
0
]
}
.js.map`
},
getSourceMapContent
(
file
,
fileName
)
{
return
Promise
.
resolve
(
getSourceMapContent
(
this
.
parseSourceMapUrl
(
file
,
fileName
))
)
},
parseStacktrace
(
stacktrace
)
{
return
(
stack
=
new
StackTracey
(
stacktrace
))
},
...
...
@@ -238,6 +238,12 @@ export function utsStracktraceyPreset(
// 根据 base,filename 组合 sourceMapUrl
return
`
${
opts
.
base
}
/
${
fileName
}
.map`
},
getSourceMapContent
(
file
,
fileName
)
{
// 根据 base,filename 组合 sourceMapUrl
return
Promise
.
resolve
(
getSourceMapContent
(
this
.
parseSourceMapUrl
(
file
,
fileName
))
)
},
parseStacktrace
(
str
)
{
const
lines
=
(
str
||
''
).
split
(
'
\n
'
)
...
...
packages/uni-stacktracey/test/index.js
浏览文件 @
de881845
...
...
@@ -13,7 +13,7 @@ e: [PackagePath]/wgtRoot/__UNI__E070870/nativeplugins/DCloud-UTSPlugin/android/s
FAILURE: Build failed with an exception.`
/*
stacktracey(
stacktracey
(
`ReferenceError: Sentry is not defined
at Proxy.throwError(/vue3/assets/pages-index-index.4077a069.js:1:295)
at e(/vue3/assets/index.2be9343a.js:1:52317)
...
...
@@ -28,11 +28,11 @@ FAILURE: Build failed with an exception.`
version
:
'
1.0.0
'
,
}),
}
).then((res) => console.log(res))
*/
).
then
((
res
)
=>
console
.
log
(
res
))
stacktracey
(
utsErrorMsg
,
{
/*
stacktracey(utsErrorMsg, {
preset: utsStracktraceyPreset({
base: '/wgtRoot/__UNI__E070870/nativeplugins/DCloud-UTSPlugin/android/src/io/dcloud/uniplugin',
sourceRoot: '',
}),
}).
then
((
res
)
=>
console
.
log
(
res
))
}).then((res) => console.log(res))
*/
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录