Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
菜鸟程序猿_c
uni-app
提交
71e7790e
U
uni-app
项目概览
菜鸟程序猿_c
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
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,发现更多精彩内容 >>
提交
71e7790e
编写于
10月 09, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): compiler
上级
c846862c
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
899 addition
and
9 deletion
+899
-9
jest.config.js
jest.config.js
+2
-0
packages/uni-components/dist/components.js
packages/uni-components/dist/components.js
+4
-2
packages/uni-stacktracey/__tests__/__snapshots__/codeFrame.spec.ts.snap
...tacktracey/__tests__/__snapshots__/codeFrame.spec.ts.snap
+353
-0
packages/uni-stacktracey/__tests__/codeFrame.spec.ts
packages/uni-stacktracey/__tests__/codeFrame.spec.ts
+127
-0
packages/uni-stacktracey/__tests__/index.kt.map
packages/uni-stacktracey/__tests__/index.kt.map
+1
-0
packages/uni-stacktracey/dist/uni-stacktracey.cjs.js
packages/uni-stacktracey/dist/uni-stacktracey.cjs.js
+120
-4
packages/uni-stacktracey/dist/uni-stacktracey.es.js
packages/uni-stacktracey/dist/uni-stacktracey.es.js
+114
-3
packages/uni-stacktracey/src/index.ts
packages/uni-stacktracey/src/index.ts
+7
-0
packages/uni-stacktracey/src/utils.ts
packages/uni-stacktracey/src/utils.ts
+159
-0
packages/uni-uts-vite/src/utils/compiler/kotlin.ts
packages/uni-uts-vite/src/utils/compiler/kotlin.ts
+12
-0
未找到文件。
jest.config.js
浏览文件 @
71e7790e
...
@@ -10,6 +10,8 @@ module.exports = {
...
@@ -10,6 +10,8 @@ module.exports = {
__GLOBAL__
:
false
,
__GLOBAL__
:
false
,
__VUE_OPTIONS_API__
:
true
,
__VUE_OPTIONS_API__
:
true
,
__VUE_PROD_DEVTOOLS__
:
false
,
__VUE_PROD_DEVTOOLS__
:
false
,
// source-map
__PLATFORM_WEB__
:
false
,
},
},
coverageDirectory
:
'
coverage
'
,
coverageDirectory
:
'
coverage
'
,
coverageReporters
:
[
'
html
'
,
'
lcov
'
,
'
text
'
],
coverageReporters
:
[
'
html
'
,
'
lcov
'
,
'
text
'
],
...
...
packages/uni-components/dist/components.js
浏览文件 @
71e7790e
...
@@ -3272,7 +3272,8 @@ const Switch = defineComponent({
...
@@ -3272,7 +3272,8 @@ const Switch = defineComponent({
return
()
=>
{
return
()
=>
{
const
{
const
{
color
,
color
,
type
type
,
disabled
}
=
props2
;
}
=
props2
;
return
createVNode
(
"
div
"
,
{
return
createVNode
(
"
div
"
,
{
"
ref
"
:
rootRef
"
ref
"
:
rootRef
...
@@ -3280,7 +3281,8 @@ const Switch = defineComponent({
...
@@ -3280,7 +3281,8 @@ const Switch = defineComponent({
dataUncType
:
"
uni-switch
"
dataUncType
:
"
uni-switch
"
},
listeners
,
{
},
listeners
,
{
checked
:
switchChecked
.
value
,
checked
:
switchChecked
.
value
,
color
color
,
disabled
},
{
},
{
"
style
"
:
DCSwitchSize
"
style
"
:
DCSwitchSize
}),
null
)
:
null
,
type
===
SwitchType
.
checkbox
?
createVNode
(
resolveComponent
(
"
checkbox
"
),
mergeProps
({
}),
null
)
:
null
,
type
===
SwitchType
.
checkbox
?
createVNode
(
resolveComponent
(
"
checkbox
"
),
mergeProps
({
...
...
packages/uni-stacktracey/__tests__/__snapshots__/codeFrame.spec.ts.snap
0 → 100644
浏览文件 @
71e7790e
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`code-frame generateCodeFrame 1`] = `
Object {
"column": 33,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 38,
"message": "'DATA: String' is deprecated. Deprecated in Java
36 | */
37 | const MEDIA_PROJECTIONS_API_16 = arrayOf(
38 | MediaStore.Images.ImageColumns.DATA,
| ^
39 | MediaStore.Images.ImageColumns.DATE_TAKEN,
40 | MediaStore.Images.ImageColumns.WIDTH,",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrame 2`] = `
Object {
"column": 6,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 78,
"message": "Unnecessary non-null assertion (!!) on a non-null receiver of type onImageCatchOptions
76 | }
77 | lastFileObserverTime = System.currentTimeMillis()
78 | listenOption!.onImageCatchChange(newPath)
| ^
79 | }
80 | }",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrame 3`] = `
Object {
"column": 8,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 126,
"message": "Condition 'cursor == null' is always 'false'
124|
125|
126| if (cursor == null) {
| ^
127| return
128| }",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrame 4`] = `
Object {
"column": 73,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 135,
"message": "'DATA: String' is deprecated. Deprecated in Java
133|
134| // 获取各列的索引
135| let dataIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA)
| ^
136| let dateTakenIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATE_TAKEN)
137| let widthIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.WIDTH)",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrame 5`] = `
Object {
"column": 17,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 143,
"message": "Variable 'width' initializer is redundant
141| let data = cursor.getString(dataIndex)
142| let dateTaken = cursor.getLong(dateTakenIndex)
143| let width = 0;
| ^
144| let height = 0;
145| if (widthIndex >= 0 && heightIndex >= 0) {",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrame 6`] = `
Object {
"column": 18,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 144,
"message": "Variable 'height' initializer is redundant
142| let dateTaken = cursor.getLong(dateTakenIndex)
143| let width = 0;
144| let height = 0;
| ^
145| if (widthIndex >= 0 && heightIndex >= 0) {
146| width = cursor.getInt(widthIndex)",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrame 7`] = `
Object {
"column": 6,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 182,
"message": "Unnecessary non-null assertion (!!) on a non-null receiver of type onImageCatchOptions
180| if (checkScreenShot(data, dateTaken, width, height)) {
181| if (!checkCallback(data)) {
182| listenOption!.onImageCatchChange(data)
| ^
183| }
184| } else {",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrame 8`] = `
Object {
"column": 39,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 250,
"message": "'getter for defaultDisplay: Display!' is deprecated. Deprecated in Java
248| try {
249| let windowManager = getUniActivity()!.getSystemService(Context.WINDOW_SERVICE) as WindowManager
250| let defaultDisplay = windowManager.defaultDisplay
| ^
251| defaultDisplay.getRealSize(screenSize)
252| } catch (e) {",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrame 9`] = `
Object {
"column": 19,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 251,
"message": "'getRealSize(Point!): Unit' is deprecated. Deprecated in Java
249| let windowManager = getUniActivity()!.getSystemService(Context.WINDOW_SERVICE) as WindowManager
250| let defaultDisplay = windowManager.defaultDisplay
251| defaultDisplay.getRealSize(screenSize)
| ^
252| } catch (e) {
253| e.printStackTrace()",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrame 10`] = `
Object {
"column": 46,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 310,
"message": "'getExternalStorageDirectory(): File!' is deprecated. Deprecated in Java
308| var directory_screenshot: File;
309|
310| var directory_pictures = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_PICTURES);
| ^
311| var directory_dcim = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DCIM);
312| ",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrame 11`] = `
Object {
"column": 42,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 311,
"message": "'getExternalStorageDirectory(): File!' is deprecated. Deprecated in Java
309|
310| var directory_pictures = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_PICTURES);
311| var directory_dcim = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DCIM);
| ^
312|
313| if (Build.MANUFACTURER.equals(\\"Xiaomi\\", true)) {",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrameWithSourceMapPath 1`] = `
Object {
"column": 33,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 38,
"message": "'DATA: String' is deprecated. Deprecated in Java
36 | */
37 | const MEDIA_PROJECTIONS_API_16 = arrayOf(
38 | MediaStore.Images.ImageColumns.DATA,
| ^
39 | MediaStore.Images.ImageColumns.DATE_TAKEN,
40 | MediaStore.Images.ImageColumns.WIDTH,",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrameWithSourceMapPath 2`] = `
Object {
"column": 6,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 78,
"message": "Unnecessary non-null assertion (!!) on a non-null receiver of type onImageCatchOptions
76 | }
77 | lastFileObserverTime = System.currentTimeMillis()
78 | listenOption!.onImageCatchChange(newPath)
| ^
79 | }
80 | }",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrameWithSourceMapPath 3`] = `
Object {
"column": 8,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 126,
"message": "Condition 'cursor == null' is always 'false'
124|
125|
126| if (cursor == null) {
| ^
127| return
128| }",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrameWithSourceMapPath 4`] = `
Object {
"column": 73,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 135,
"message": "'DATA: String' is deprecated. Deprecated in Java
133|
134| // 获取各列的索引
135| let dataIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA)
| ^
136| let dateTakenIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATE_TAKEN)
137| let widthIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.WIDTH)",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrameWithSourceMapPath 5`] = `
Object {
"column": 17,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 143,
"message": "Variable 'width' initializer is redundant
141| let data = cursor.getString(dataIndex)
142| let dateTaken = cursor.getLong(dateTakenIndex)
143| let width = 0;
| ^
144| let height = 0;
145| if (widthIndex >= 0 && heightIndex >= 0) {",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrameWithSourceMapPath 6`] = `
Object {
"column": 18,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 144,
"message": "Variable 'height' initializer is redundant
142| let dateTaken = cursor.getLong(dateTakenIndex)
143| let width = 0;
144| let height = 0;
| ^
145| if (widthIndex >= 0 && heightIndex >= 0) {
146| width = cursor.getInt(widthIndex)",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrameWithSourceMapPath 7`] = `
Object {
"column": 6,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 182,
"message": "Unnecessary non-null assertion (!!) on a non-null receiver of type onImageCatchOptions
180| if (checkScreenShot(data, dateTaken, width, height)) {
181| if (!checkCallback(data)) {
182| listenOption!.onImageCatchChange(data)
| ^
183| }
184| } else {",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrameWithSourceMapPath 8`] = `
Object {
"column": 39,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 250,
"message": "'getter for defaultDisplay: Display!' is deprecated. Deprecated in Java
248| try {
249| let windowManager = getUniActivity()!.getSystemService(Context.WINDOW_SERVICE) as WindowManager
250| let defaultDisplay = windowManager.defaultDisplay
| ^
251| defaultDisplay.getRealSize(screenSize)
252| } catch (e) {",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrameWithSourceMapPath 9`] = `
Object {
"column": 19,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 251,
"message": "'getRealSize(Point!): Unit' is deprecated. Deprecated in Java
249| let windowManager = getUniActivity()!.getSystemService(Context.WINDOW_SERVICE) as WindowManager
250| let defaultDisplay = windowManager.defaultDisplay
251| defaultDisplay.getRealSize(screenSize)
| ^
252| } catch (e) {
253| e.printStackTrace()",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrameWithSourceMapPath 10`] = `
Object {
"column": 46,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 310,
"message": "'getExternalStorageDirectory(): File!' is deprecated. Deprecated in Java
308| var directory_screenshot: File;
309|
310| var directory_pictures = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_PICTURES);
| ^
311| var directory_dcim = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DCIM);
312| ",
"type": "warning",
}
`;
exports[`code-frame generateCodeFrameWithSourceMapPath 11`] = `
Object {
"column": 42,
"file": "/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts",
"line": 311,
"message": "'getExternalStorageDirectory(): File!' is deprecated. Deprecated in Java
309|
310| var directory_pictures = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_PICTURES);
311| var directory_dcim = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DCIM);
| ^
312|
313| if (Build.MANUFACTURER.equals(\\"Xiaomi\\", true)) {",
"type": "warning",
}
`;
packages/uni-stacktracey/__tests__/codeFrame.spec.ts
0 → 100644
浏览文件 @
71e7790e
import
fs
from
'
fs
'
import
path
from
'
path
'
const
{
SourceMapConsumer
,
generateCodeFrameSourceMapConsumer
,
generateCodeFrameWithSourceMapPath
,
}
=
require
(
'
../dist/uni-stacktracey.cjs.js
'
)
import
type
{
BasicSourceMapConsumer
,
IndexedSourceMapConsumer
,
}
from
'
../lib/source-map
'
const
warnings
=
[
{
type
:
'
warning
'
,
message
:
"
'DATA: String' is deprecated. Deprecated in Java
"
,
file
:
'
index.kt
'
,
line
:
27
,
column
:
71
,
},
{
type
:
'
warning
'
,
message
:
'
Unnecessary non-null assertion (!!) on a non-null receiver of type onImageCatchOptions
'
,
file
:
'
index.kt
'
,
line
:
41
,
column
:
25
,
},
{
type
:
'
warning
'
,
message
:
"
Condition 'cursor == null' is always 'false'
"
,
file
:
'
index.kt
'
,
line
:
61
,
column
:
13
,
},
{
type
:
'
warning
'
,
message
:
"
'DATA: String' is deprecated. Deprecated in Java
"
,
file
:
'
index.kt
'
,
line
:
63
,
column
:
78
,
},
{
type
:
'
warning
'
,
message
:
"
Variable 'width' initializer is redundant
"
,
file
:
'
index.kt
'
,
line
:
69
,
column
:
21
,
},
{
type
:
'
warning
'
,
message
:
"
Variable 'height' initializer is redundant
"
,
file
:
'
index.kt
'
,
line
:
70
,
column
:
22
,
},
{
type
:
'
warning
'
,
message
:
'
Unnecessary non-null assertion (!!) on a non-null receiver of type onImageCatchOptions
'
,
file
:
'
index.kt
'
,
line
:
97
,
column
:
47
,
},
{
type
:
'
warning
'
,
message
:
"
'getter for defaultDisplay: Display!' is deprecated. Deprecated in Java
"
,
file
:
'
index.kt
'
,
line
:
122
,
column
:
44
,
},
{
type
:
'
warning
'
,
message
:
"
'getRealSize(Point!): Unit' is deprecated. Deprecated in Java
"
,
file
:
'
index.kt
'
,
line
:
123
,
column
:
24
,
},
{
type
:
'
warning
'
,
message
:
"
'getExternalStorageDirectory(): File!' is deprecated. Deprecated in Java
"
,
file
:
'
index.kt
'
,
line
:
152
,
column
:
51
,
},
{
type
:
'
warning
'
,
message
:
"
'getExternalStorageDirectory(): File!' is deprecated. Deprecated in Java
"
,
file
:
'
index.kt
'
,
line
:
153
,
column
:
47
,
},
]
const
filename
=
path
.
resolve
(
__dirname
,
'
index.kt.map
'
)
describe
(
'
code-frame
'
,
()
=>
{
let
consumer
:
BasicSourceMapConsumer
|
IndexedSourceMapConsumer
async
function
initConsumer
()
{
if
(
!
consumer
)
{
consumer
=
await
new
SourceMapConsumer
(
fs
.
readFileSync
(
filename
,
'
utf8
'
))
}
return
consumer
}
test
(
'
generateCodeFrame
'
,
async
()
=>
{
const
consumer
=
await
initConsumer
()
warnings
.
forEach
((
w
)
=>
{
expect
(
generateCodeFrameSourceMapConsumer
(
consumer
,
w
)).
toMatchSnapshot
()
})
})
test
(
'
generateCodeFrameWithSourceMapPath
'
,
async
()
=>
{
;(
await
generateCodeFrameWithSourceMapPath
(
filename
,
JSON
.
stringify
(
warnings
)
)
).
forEach
((
m
:
unknown
)
=>
{
expect
(
m
).
toMatchSnapshot
()
})
})
})
packages/uni-stacktracey/__tests__/index.kt.map
0 → 100644
浏览文件 @
71e7790e
{"version":3,"sourceRoot":"/Users/fxy/Projects/Gitcode/hello-uts","sources":["/Users/fxy/Projects/Gitcode/hello-uts/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts"],"sourcesContent":["\n\nimport {\n onAppActivityDestroy,\n onAppActivityPause,\n onAppActivityResume,\n onAppActivityBack,\n getUniActivity,\n getAppContext\n} from \"io.dcloud.uts.android\";\n\n\nimport ActivityCompat from \"androidx.core.app.ActivityCompat\";\nimport Manifest from \"android.Manifest\";\nimport PackageManager from \"android.content.pm.PackageManager\";\nimport Context from \"android.content.Context\";\nimport Point from \"android.graphics.Point\";\nimport Build from \"android.os.Build\";\nimport Handler from \"android.os.Handler\";\nimport MediaStore from \"android.provider.MediaStore\";\nimport Looper from \"android.os.Looper\";\nimport Cursor from \"android.database.Cursor\";\nimport ContentObserver from \"android.database.ContentObserver\";\nimport Uri from \"android.net.Uri\";\nimport BitmapFactory from \"android.graphics.BitmapFactory\";\nimport Display from \"android.view.Display\";\nimport Locale from \"java.util.Locale\";\nimport WindowManager from \"android.view.WindowManager\";\nimport FileObserver from \"android.os.FileObserver\";\nimport File from \"java.io.File\";\nimport RequiresApi from \"androidx.annotation.RequiresApi\";\nimport Environment from \"android.os.Environment\";\n\n/**\n * 读取媒体数据库时需要读取的列,其中 width、height 字段在 API 16 之后才有\n */\nconst MEDIA_PROJECTIONS_API_16 = arrayOf(\n MediaStore.Images.ImageColumns.DATA,\n MediaStore.Images.ImageColumns.DATE_TAKEN,\n MediaStore.Images.ImageColumns.WIDTH,\n MediaStore.Images.ImageColumns.HEIGHT\n)\n\n/**\n * 截屏路径判断的关键字\n */\nconst KEYWORDS = arrayOf(\n \"screenshot\", \"screen_shot\", \"screen-shot\", \"screen shot\",\n \"screencapture\", \"screen_capture\", \"screen-capture\", \"screen capture\",\n \"screencap\", \"screen_cap\", \"screen-cap\", \"screen cap\"\n)\n\n\n\n/**\n * android 10版本以上通过文件监听实现\n */\n@RequiresApi(Build.VERSION_CODES.Q)\nclass ScreenFileObserver extends FileObserver {\n\n allScreen: File;\n\n constructor(screenFile: File) {\n super(screenFile)\n this.allScreen = screenFile;\n }\n\n override onEvent(event: Int, path?: String): void {\n if (event == FileObserver.CREATE) {\n var newPath: string = new File(allScreen, path).path;\n let currentTime = System.currentTimeMillis();\n\n if ((currentTime - lastFileObserverTime) < 1000) {\n // 本地截屏行为比上一次超过1000ms,才认为是一个有效的时间\n return;\n }\n lastFileObserverTime = System.currentTimeMillis()\n listenOption!.onImageCatchChange(newPath)\n }\n }\n}\n\n\n/**\n * 屏幕尺寸\n */\nlet mScreenRealSize: Point | null = getRealScreenSize();\nlet mHasCallbackPaths: ArrayList<string> = new ArrayList()\nlet mStartListenTime: number = 0;\nlet mUiHandler: Handler = Handler(Looper.getMainLooper())\n/**\n * 内部媒体文件监听器\n */\nlet mInternalObserver: MediaContentObserver | null = null;\n/**\n * 外部媒体文件监听器\n */\nlet mExternalObserver: MediaContentObserver | null = null;\n/**\n * android 10 版本使用的文件监听器\n */\nlet screenOB: ScreenFileObserver | null = null;\n\ntype onImageCatchOptions = {\n onImageCatchChange: (res: string) => void;\n};\n\nlet listenOption: onImageCatchOptions = new onImageCatchOptions();\n\nlet lastFileObserverTime: number = 0;\n\n/**\n * 处理媒体数据库的内容改变\n */\nfunction handleMediaContentChange(contentUri: Uri) {\n let cursor: Cursor | null = null;\n try {\n cursor = getUniActivity()!.contentResolver.query(\n contentUri,\n MEDIA_PROJECTIONS_API_16,\n null, null,\n MediaStore.Images.ImageColumns.DATE_ADDED + \" desc limit 1\"\n )!\n\n\n if (cursor == null) {\n return\n }\n\n if (!cursor.moveToFirst()) {\n return\n }\n\n // 获取各列的索引\n let dataIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA)\n let dateTakenIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATE_TAKEN)\n let widthIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.WIDTH)\n let heightIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.HEIGHT)\n\n // 获取行数据\n let data = cursor.getString(dataIndex)\n let dateTaken = cursor.getLong(dateTakenIndex)\n let width = 0;\n let height = 0;\n if (widthIndex >= 0 && heightIndex >= 0) {\n width = cursor.getInt(widthIndex)\n height = cursor.getInt(heightIndex)\n } else {\n let size = getImageSize(data)\n width = size.x\n height = size.y\n }\n\n // 处理获取到的第一行数据\n handleMediaRowData(data, dateTaken, width, height)\n } catch (e) {\n e.printStackTrace()\n } finally {\n if (cursor != null && !cursor.isClosed) {\n cursor.close()\n }\n }\n}\n\n/**\n * 获取媒体库内置图像的大小\n */\nfunction getImageSize(imagePath: string): Point {\n let options = BitmapFactory.Options()\n options.inJustDecodeBounds = true\n BitmapFactory.decodeFile(imagePath, options)\n return Point(options.outWidth, options.outHeight)\n}\n\n/**\n * 处理获取到的一行数据\n */\nfunction handleMediaRowData(data: String, dateTaken: Long, width: Int, height: Int) {\n\n if (checkScreenShot(data, dateTaken, width, height)) {\n if (!checkCallback(data)) {\n listenOption!.onImageCatchChange(data)\n }\n } else {\n // 如果在观察区间媒体数据库有数据改变,又不符合截屏规则\n }\n}\n\n/**\n * 判断指定的数据行是否符合截屏条件\n */\nfunction checkScreenShot(data?: string, dateTaken: Long, width: Int, height: Int): boolean {\n // 判断依据一: 时间判断\n // 如果加入数据库的时间在开始监听之前, 或者与当前时间相差大于10秒, 则认为当前没有截屏\n if (dateTaken < mStartListenTime || System.currentTimeMillis() - dateTaken > 10 * 1000) {\n return false\n }\n\n // 判断依据二: 尺寸判断\n if (mScreenRealSize != null) {\n // 如果图片尺寸超出屏幕, 则认为当前没有截屏\n if (!(width <= mScreenRealSize!.x && height <= mScreenRealSize!.y)\n || (height <= mScreenRealSize!.x && width <= mScreenRealSize!.y)\n ) {\n return false\n }\n }\n\n // 判断依据三: 路径判断\n if (data == null) {\n return false\n }\n\n let lowerData = data.lowercase(Locale.getDefault())\n // 判断图片路径是否含有指定的关键字之一, 如果有, 则认为当前截屏了\n for (keyWork in KEYWORDS) {\n if (lowerData.contains(keyWork)) {\n return true\n }\n }\n return false\n}\n\n/**\n * 判断是否已回调过, 某些手机ROM截屏一次会发出多次内容改变的通知; <br></br>\n * 删除一个图片也会发通知, 同时防止删除图片时误将上一张符合截屏规则的图片当做是当前截屏.\n */\nfunction checkCallback(imagePath: String): boolean {\n\n if (mHasCallbackPaths.contains(imagePath)) {\n return true\n }\n // 大概缓存15~20条记录便可\n if (mHasCallbackPaths.size >= 20) {\n // for (i of 4) {\n // \tmHasCallbackPaths.removeAt(0)\n // }\n }\n mHasCallbackPaths.add(imagePath)\n return false\n}\n\n/**\n * 获取屏幕分辨率\n */\nfunction getRealScreenSize(): Point | null {\n let screenSize: Point = Point();\n try {\n let windowManager = getUniActivity()!.getSystemService(Context.WINDOW_SERVICE) as WindowManager\n let defaultDisplay = windowManager.defaultDisplay\n defaultDisplay.getRealSize(screenSize)\n } catch (e) {\n e.printStackTrace()\n }\n\n return screenSize\n}\n\n\n\n/**\n * 媒体内容观察者\n */\nclass MediaContentObserver extends ContentObserver {\n\n contentUri: Uri;\n handler: Handler;\n\n constructor(contentUri: Uri, handler: Handler) {\n super(handler)\n this.contentUri = contentUri\n this.handler = handler\n }\n\n override onChange(selfChange: Boolean) {\n super.onChange(selfChange)\n handleMediaContentChange(contentUri)\n }\n}\n\n\n\n/**\n * 请求权限\n */\nexport function requestPremission() {\n\n // 注册一个请求回调\n // 发起权限申请\n if (ActivityCompat.checkSelfPermission(getUniActivity()!, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {\n ActivityCompat.requestPermissions(getUniActivity()!, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), 1001)\n }\n\n // 请求权限\n return { name: \"requestPremission\" };\n}\n\n\n\n/**\n * 开启截图监听\n */\nexport function onUserCaptureScreen(success: (res: string) => void) {\n listenOption.onImageCatchChange = success;\n\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {\n // android 10 以上版本,使用监听文件的方式,更加可靠\n var directory_screenshot: File;\n\n var directory_pictures = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_PICTURES);\n var directory_dcim = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DCIM);\n\n if (Build.MANUFACTURER.equals(\"Xiaomi\", true)) {\n directory_screenshot = File(directory_dcim, \"Screenshots\");\n } else {\n directory_screenshot = File(directory_pictures, \"Screenshots\");\n }\n if (screenOB != null) {\n screenOB!.stopWatching()\n }\n screenOB = new ScreenFileObserver(directory_screenshot)\n screenOB!.startWatching()\n } else {\n // android 10 以下版本,采用监听系统媒体库的方式\n mStartListenTime = System.currentTimeMillis()\n\n // 创建内容观察者\n mInternalObserver =\n new MediaContentObserver(MediaStore.Images.Media.INTERNAL_CONTENT_URI, mUiHandler)\n mExternalObserver =\n new MediaContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, mUiHandler)\n\n // 注册内容观察者\n getUniActivity()!.getContentResolver()!.registerContentObserver(\n MediaStore.Images.Media.INTERNAL_CONTENT_URI,\n false,\n mInternalObserver!\n )\n getUniActivity()!.getContentResolver()!.registerContentObserver(\n MediaStore.Images.Media.EXTERNAL_CONTENT_URI,\n false,\n mExternalObserver!\n )\n }\n\n}\n\n/**\n * 关闭截屏监听\n */\nexport function offUserCaptureScreen(success: (res: string) => void) {\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {\n // android 10以上,关闭监听通过移除文件监听器实现\n if (screenOB != null) {\n screenOB!.stopWatching()\n screenOB = null\n }\n lastFileObserverTime = 0;\n } else {\n // android 10以下,注销内容观察者\n if (mInternalObserver != null) {\n try {\n getUniActivity()!.contentResolver.unregisterContentObserver(mInternalObserver!)\n } catch (e) {\n e.printStackTrace()\n }\n mInternalObserver = null\n }\n if (mExternalObserver != null) {\n try {\n getUniActivity()!.contentResolver.unregisterContentObserver(mExternalObserver!)\n } catch (e) {\n e.printStackTrace()\n }\n mExternalObserver = null\n }\n\n // 清空数据\n mStartListenTime = 0\n }\n success(\"\");\n}\n\n\n\n\n\n\n\n\n\n"],"names":[],"mappings":";;;;;;AAEA;AAUA,OAA2B,gCAAkC,CAAC;AAC9D,OAAqB,gBAAkB,CAAC;AACxC,OAA2B,iCAAmC,CAAC;AAC/D,OAAoB,uBAAyB,CAAC;AAC9C,OAAkB,sBAAwB,CAAC;AAC3C,OAAkB,gBAAkB,CAAC;AACrC,OAAoB,kBAAoB,CAAC;AACzC,OAAuB,2BAA6B,CAAC;AACrD,OAAmB,iBAAmB,CAAC;AACvC,OAAmB,uBAAyB,CAAC;AAC7C,OAA4B,gCAAkC,CAAC;AAC/D,OAAgB,eAAiB,CAAC;AAClC,OAA0B,8BAAgC,CAAC;AAE3D,OAAmB,gBAAkB,CAAC;AACtC,OAA0B,0BAA4B,CAAC;AACvD,OAAyB,uBAAyB,CAAC;AACnD,OAAiB,YAAc,CAAC;AAChC,OAAwB,+BAAiC,CAAC;AAC1D,OAAwB,sBAAwB,CAAC;AAKjD,IAAM,2BAA2B,QAC/B,WAAW,MAAM,CAAC,YAAY,CAAC,IAAI,EACnC,WAAW,MAAM,CAAC,YAAY,CAAC,UAAU,EACzC,WAAW,MAAM,CAAC,YAAY,CAAC,KAAK,EACpC,WAAW,MAAM,CAAC,YAAY,CAAC,MAAM;AAMvC,IAAM,WAAW,QACf,cAAc,eAAe,eAAe,eAC5C,iBAAiB,kBAAkB,kBAAkB,kBACrD,aAAa,cAAc,cAAc;AAQ3C,CAAC,YAAY,MAAM,aAAa,CAAC,CAAC;AAAC,WAC7B,qBAA2B;IAE/B,SAAA,WAAW,KAAK;IAEhB,YAAY,YAAY,IAAI,IAC1B,KAAK,CAAC,YADsB;QAE5B,IAAI,CAAC,SAAS,GAAG;IACnB;IAEA,aAAS,QAAQ,OAAO,G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YAC7B,IAAI;gBACF,mBAAkB,eAAe,CAAC,yBAAyB,CAAC;YAC9D;aAAE,OAAO,WAAG;gBACV,GAAE,eAAe;YACnB;YACA,oBAAoB,IAAI;QAC1B;QAGA,mBAAmB,CAAC;IACtB;IACA,QAAQ;AACV"}
\ No newline at end of file
packages/uni-stacktracey/dist/uni-stacktracey.cjs.js
浏览文件 @
71e7790e
...
@@ -2,13 +2,15 @@
...
@@ -2,13 +2,15 @@
Object
.
defineProperty
(
exports
,
'
__esModule
'
,
{
value
:
true
});
Object
.
defineProperty
(
exports
,
'
__esModule
'
,
{
value
:
true
});
var
require$$0$2
=
require
(
'
fs
'
);
var
fs
=
require
(
'
fs
'
);
var
path
=
require
(
'
path
'
);
var
path
=
require
(
'
path
'
);
var
os
=
require
(
'
os
'
);
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'
object
'
&&
'
default
'
in
e
?
e
:
{
'
default
'
:
e
};
}
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'
object
'
&&
'
default
'
in
e
?
e
:
{
'
default
'
:
e
};
}
var
require$$0__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
require$$0$2
);
var
fs__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
fs
);
var
path__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
path
);
var
path__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
path
);
var
os__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
os
);
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
const
O
=
Object
,
isBrowser
=
const
O
=
Object
,
isBrowser
=
...
@@ -1662,7 +1664,7 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
...
@@ -1662,7 +1664,7 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
var
readWasm$1
=
createCommonjsModule
(
function
(
module
)
{
var
readWasm$1
=
createCommonjsModule
(
function
(
module
)
{
{
{
// Node version of reading a wasm file into an array buffer.
// Node version of reading a wasm file into an array buffer.
const
fs
=
require$$0
__default
[
"
default
"
];
const
fs
=
fs
__default
[
"
default
"
];
const
path
=
path__default
[
"
default
"
];
const
path
=
path__default
[
"
default
"
];
module
.
exports
=
function
readWasm
()
{
module
.
exports
=
function
readWasm
()
{
...
@@ -3597,6 +3599,116 @@ var SourceMapConsumer =
...
@@ -3597,6 +3599,116 @@ var SourceMapConsumer =
require$$1
.
SourceMapConsumer
;
require$$1
.
SourceMapConsumer
;
require$$2
.
SourceNode
;
require$$2
.
SourceNode
;
const
splitRE
=
/
\r?\n
/
;
const
range
=
2
;
function
posToNumber
(
source
,
pos
)
{
if
(
typeof
pos
===
'
number
'
)
return
pos
;
const
lines
=
source
.
split
(
splitRE
);
const
{
line
,
column
}
=
pos
;
let
start
=
0
;
for
(
let
i
=
0
;
i
<
line
-
1
;
i
++
)
{
start
+=
lines
[
i
].
length
+
1
;
}
return
start
+
column
;
}
function
generateCodeFrame
(
source
,
start
=
0
,
end
)
{
start
=
posToNumber
(
source
,
start
);
end
=
end
||
start
;
const
lines
=
source
.
split
(
splitRE
);
let
count
=
0
;
const
res
=
[];
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
count
+=
lines
[
i
].
length
+
1
;
if
(
count
>=
start
)
{
for
(
let
j
=
i
-
range
;
j
<=
i
+
range
||
end
>
count
;
j
++
)
{
if
(
j
<
0
||
j
>=
lines
.
length
)
continue
;
const
line
=
j
+
1
;
res
.
push
(
`
${
line
}${
'
'
.
repeat
(
Math
.
max
(
3
-
String
(
line
).
length
,
0
))}
|
${
lines
[
j
]}
`
);
const
lineLength
=
lines
[
j
].
length
;
if
(
j
===
i
)
{
// push underline
const
pad
=
start
-
(
count
-
lineLength
)
+
1
;
const
length
=
Math
.
max
(
1
,
end
>
count
?
lineLength
-
pad
:
end
-
start
);
res
.
push
(
` | `
+
'
'
.
repeat
(
pad
)
+
'
^
'
.
repeat
(
length
));
}
else
if
(
j
>
i
)
{
if
(
end
>
count
)
{
const
length
=
Math
.
max
(
Math
.
min
(
end
-
count
,
lineLength
),
1
);
res
.
push
(
` | `
+
'
^
'
.
repeat
(
length
));
}
count
+=
lineLength
+
1
;
}
}
break
;
}
}
return
res
.
join
(
'
\n
'
);
}
const
isWindows
=
os__default
[
"
default
"
].
platform
()
===
'
win32
'
;
function
normalizePath
(
id
)
{
return
isWindows
?
id
.
replace
(
/
\\
/g
,
'
/
'
)
:
id
;
}
function
generateCodeFrameSourceMapConsumer
(
consumer
,
m
,
options
=
{})
{
if
(
m
.
file
)
{
const
res
=
consumer
.
originalPositionFor
({
line
:
m
.
line
,
column
:
m
.
column
,
});
if
(
res
.
source
!=
null
&&
res
.
line
!=
null
&&
res
.
column
!=
null
)
{
const
code
=
consumer
.
sourceContentFor
(
res
.
source
,
true
);
if
(
code
)
{
return
{
type
:
m
.
type
,
file
:
options
.
sourceRoot
?
normalizePath
(
path__default
[
"
default
"
].
relative
(
options
.
sourceRoot
,
res
.
source
))
:
res
.
source
,
line
:
res
.
line
,
column
:
res
.
column
,
message
:
`
${
m
.
message
}
${
generateCodeFrame
(
code
,
{
line
:
res
.
line
,
column
:
res
.
column
})}
`
,
};
}
}
}
}
function
initConsumer
(
filename
)
{
if
(
fs__default
[
"
default
"
].
existsSync
(
filename
))
{
return
new
SourceMapConsumer
(
fs__default
[
"
default
"
].
readFileSync
(
filename
,
'
utf8
'
));
}
return
Promise
.
resolve
(
undefined
);
}
function
generateCodeFrameWithSourceMapPath
(
filename
,
messages
,
options
=
{})
{
if
(
typeof
messages
===
'
string
'
)
{
try
{
messages
=
JSON
.
parse
(
messages
);
}
catch
(
e
)
{
}
}
if
(
Array
.
isArray
(
messages
)
&&
messages
.
length
)
{
return
new
Promise
((
resolve
)
=>
{
initConsumer
(
filename
).
then
((
consumer
)
=>
{
resolve
(
messages
.
map
((
m
)
=>
{
if
(
m
.
file
&&
consumer
)
{
const
message
=
generateCodeFrameSourceMapConsumer
(
consumer
,
m
,
options
);
if
(
message
)
{
return
message
;
}
}
if
(
!
m
.
file
)
{
m
.
file
=
''
;
}
return
m
;
})
.
filter
(
Boolean
));
});
});
}
return
Promise
.
resolve
([]);
}
const
nixSlashes
=
(
x
)
=>
x
.
replace
(
/
\\
/g
,
'
/
'
);
const
nixSlashes
=
(
x
)
=>
x
.
replace
(
/
\\
/g
,
'
/
'
);
const
sourcemapCatch
=
{};
const
sourcemapCatch
=
{};
function
stacktracey
(
stacktrace
,
opts
)
{
function
stacktracey
(
stacktrace
,
opts
)
{
...
@@ -3727,7 +3839,7 @@ function getSourceMapContent(sourcemapUrl) {
...
@@ -3727,7 +3839,7 @@ function getSourceMapContent(sourcemapUrl) {
});
});
}
}
else
{
else
{
sourcemapCatch
[
sourcemapUrl
]
=
require$$0
__default
[
"
default
"
].
readFileSync
(
sourcemapUrl
,
'
utf-8
'
);
sourcemapCatch
[
sourcemapUrl
]
=
fs
__default
[
"
default
"
].
readFileSync
(
sourcemapUrl
,
'
utf-8
'
);
resolve
(
sourcemapCatch
[
sourcemapUrl
]);
resolve
(
sourcemapCatch
[
sourcemapUrl
]);
}
}
}
}
...
@@ -3919,6 +4031,10 @@ ${_stack.errMsg}`;
...
@@ -3919,6 +4031,10 @@ ${_stack.errMsg}`;
};
};
}
}
exports
.
SourceMapConsumer
=
SourceMapConsumer
;
exports
.
generateCodeFrame
=
generateCodeFrame
;
exports
.
generateCodeFrameSourceMapConsumer
=
generateCodeFrameSourceMapConsumer
;
exports
.
generateCodeFrameWithSourceMapPath
=
generateCodeFrameWithSourceMapPath
;
exports
.
stacktracey
=
stacktracey
;
exports
.
stacktracey
=
stacktracey
;
exports
.
uniStracktraceyPreset
=
uniStracktraceyPreset
;
exports
.
uniStracktraceyPreset
=
uniStracktraceyPreset
;
exports
.
utsStracktraceyPreset
=
utsStracktraceyPreset
;
exports
.
utsStracktraceyPreset
=
utsStracktraceyPreset
;
packages/uni-stacktracey/dist/uni-stacktracey.es.js
浏览文件 @
71e7790e
import
require$$0$2
from
'
fs
'
;
import
fs
from
'
fs
'
;
import
path
from
'
path
'
;
import
path
from
'
path
'
;
import
os
from
'
os
'
;
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
const
O
=
Object
,
isBrowser
=
const
O
=
Object
,
isBrowser
=
...
@@ -3581,6 +3582,116 @@ var SourceMapConsumer =
...
@@ -3581,6 +3582,116 @@ var SourceMapConsumer =
require$$1
.
SourceMapConsumer
;
require$$1
.
SourceMapConsumer
;
require$$2
.
SourceNode
;
require$$2
.
SourceNode
;
const
splitRE
=
/
\r?\n
/
;
const
range
=
2
;
function
posToNumber
(
source
,
pos
)
{
if
(
typeof
pos
===
'
number
'
)
return
pos
;
const
lines
=
source
.
split
(
splitRE
);
const
{
line
,
column
}
=
pos
;
let
start
=
0
;
for
(
let
i
=
0
;
i
<
line
-
1
;
i
++
)
{
start
+=
lines
[
i
].
length
+
1
;
}
return
start
+
column
;
}
function
generateCodeFrame
(
source
,
start
=
0
,
end
)
{
start
=
posToNumber
(
source
,
start
);
end
=
end
||
start
;
const
lines
=
source
.
split
(
splitRE
);
let
count
=
0
;
const
res
=
[];
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
count
+=
lines
[
i
].
length
+
1
;
if
(
count
>=
start
)
{
for
(
let
j
=
i
-
range
;
j
<=
i
+
range
||
end
>
count
;
j
++
)
{
if
(
j
<
0
||
j
>=
lines
.
length
)
continue
;
const
line
=
j
+
1
;
res
.
push
(
`
${
line
}${
'
'
.
repeat
(
Math
.
max
(
3
-
String
(
line
).
length
,
0
))}
|
${
lines
[
j
]}
`
);
const
lineLength
=
lines
[
j
].
length
;
if
(
j
===
i
)
{
// push underline
const
pad
=
start
-
(
count
-
lineLength
)
+
1
;
const
length
=
Math
.
max
(
1
,
end
>
count
?
lineLength
-
pad
:
end
-
start
);
res
.
push
(
` | `
+
'
'
.
repeat
(
pad
)
+
'
^
'
.
repeat
(
length
));
}
else
if
(
j
>
i
)
{
if
(
end
>
count
)
{
const
length
=
Math
.
max
(
Math
.
min
(
end
-
count
,
lineLength
),
1
);
res
.
push
(
` | `
+
'
^
'
.
repeat
(
length
));
}
count
+=
lineLength
+
1
;
}
}
break
;
}
}
return
res
.
join
(
'
\n
'
);
}
const
isWindows
=
os
.
platform
()
===
'
win32
'
;
function
normalizePath
(
id
)
{
return
isWindows
?
id
.
replace
(
/
\\
/g
,
'
/
'
)
:
id
;
}
function
generateCodeFrameSourceMapConsumer
(
consumer
,
m
,
options
=
{})
{
if
(
m
.
file
)
{
const
res
=
consumer
.
originalPositionFor
({
line
:
m
.
line
,
column
:
m
.
column
,
});
if
(
res
.
source
!=
null
&&
res
.
line
!=
null
&&
res
.
column
!=
null
)
{
const
code
=
consumer
.
sourceContentFor
(
res
.
source
,
true
);
if
(
code
)
{
return
{
type
:
m
.
type
,
file
:
options
.
sourceRoot
?
normalizePath
(
path
.
relative
(
options
.
sourceRoot
,
res
.
source
))
:
res
.
source
,
line
:
res
.
line
,
column
:
res
.
column
,
message
:
`
${
m
.
message
}
${
generateCodeFrame
(
code
,
{
line
:
res
.
line
,
column
:
res
.
column
})}
`
,
};
}
}
}
}
function
initConsumer
(
filename
)
{
if
(
fs
.
existsSync
(
filename
))
{
return
new
SourceMapConsumer
(
fs
.
readFileSync
(
filename
,
'
utf8
'
));
}
return
Promise
.
resolve
(
undefined
);
}
function
generateCodeFrameWithSourceMapPath
(
filename
,
messages
,
options
=
{})
{
if
(
typeof
messages
===
'
string
'
)
{
try
{
messages
=
JSON
.
parse
(
messages
);
}
catch
(
e
)
{
}
}
if
(
Array
.
isArray
(
messages
)
&&
messages
.
length
)
{
return
new
Promise
((
resolve
)
=>
{
initConsumer
(
filename
).
then
((
consumer
)
=>
{
resolve
(
messages
.
map
((
m
)
=>
{
if
(
m
.
file
&&
consumer
)
{
const
message
=
generateCodeFrameSourceMapConsumer
(
consumer
,
m
,
options
);
if
(
message
)
{
return
message
;
}
}
if
(
!
m
.
file
)
{
m
.
file
=
''
;
}
return
m
;
})
.
filter
(
Boolean
));
});
});
}
return
Promise
.
resolve
([]);
}
// @ts-ignore
// @ts-ignore
{
{
// @ts-ignore
// @ts-ignore
...
@@ -3721,7 +3832,7 @@ function getSourceMapContent(sourcemapUrl) {
...
@@ -3721,7 +3832,7 @@ function getSourceMapContent(sourcemapUrl) {
});
});
}
}
else
{
else
{
sourcemapCatch
[
sourcemapUrl
]
=
require$$0$2
.
readFileSync
(
sourcemapUrl
,
'
utf-8
'
);
sourcemapCatch
[
sourcemapUrl
]
=
fs
.
readFileSync
(
sourcemapUrl
,
'
utf-8
'
);
resolve
(
sourcemapCatch
[
sourcemapUrl
]);
resolve
(
sourcemapCatch
[
sourcemapUrl
]);
}
}
}
}
...
@@ -3913,4 +4024,4 @@ ${_stack.errMsg}`;
...
@@ -3913,4 +4024,4 @@ ${_stack.errMsg}`;
};
};
}
}
export
{
stacktracey
,
uniStracktraceyPreset
,
utsStracktraceyPreset
};
export
{
SourceMapConsumer
,
generateCodeFrame
,
generateCodeFrameSourceMapConsumer
,
generateCodeFrameWithSourceMapPath
,
stacktracey
,
uniStracktraceyPreset
,
utsStracktraceyPreset
};
packages/uni-stacktracey/src/index.ts
浏览文件 @
71e7790e
...
@@ -8,6 +8,13 @@ import {
...
@@ -8,6 +8,13 @@ import {
}
from
'
../lib/source-map/source-map
'
}
from
'
../lib/source-map/source-map
'
import
path
from
'
path
'
import
path
from
'
path
'
export
{
SourceMapConsumer
}
from
'
../lib/source-map/source-map
'
export
{
generateCodeFrame
,
generateCodeFrameSourceMapConsumer
,
generateCodeFrameWithSourceMapPath
,
}
from
'
./utils
'
// @ts-ignore
// @ts-ignore
if
(
__PLATFORM_WEB__
)
{
if
(
__PLATFORM_WEB__
)
{
// @ts-ignore
// @ts-ignore
...
...
packages/uni-stacktracey/src/utils.ts
0 → 100644
浏览文件 @
71e7790e
import
fs
from
'
fs
'
import
os
from
'
os
'
import
path
from
'
path
'
import
{
BasicSourceMapConsumer
,
IndexedSourceMapConsumer
,
SourceMapConsumer
,
}
from
'
../lib/source-map/source-map
'
const
splitRE
=
/
\r?\n
/
const
range
:
number
=
2
function
posToNumber
(
source
:
string
,
pos
:
number
|
{
line
:
number
;
column
:
number
}
):
number
{
if
(
typeof
pos
===
'
number
'
)
return
pos
const
lines
=
source
.
split
(
splitRE
)
const
{
line
,
column
}
=
pos
let
start
=
0
for
(
let
i
=
0
;
i
<
line
-
1
;
i
++
)
{
start
+=
lines
[
i
].
length
+
1
}
return
start
+
column
}
export
function
generateCodeFrame
(
source
:
string
,
start
:
number
|
{
line
:
number
;
column
:
number
}
=
0
,
end
?:
number
):
string
{
start
=
posToNumber
(
source
,
start
)
end
=
end
||
start
const
lines
=
source
.
split
(
splitRE
)
let
count
=
0
const
res
:
string
[]
=
[]
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
count
+=
lines
[
i
].
length
+
1
if
(
count
>=
start
)
{
for
(
let
j
=
i
-
range
;
j
<=
i
+
range
||
end
>
count
;
j
++
)
{
if
(
j
<
0
||
j
>=
lines
.
length
)
continue
const
line
=
j
+
1
res
.
push
(
`
${
line
}${
'
'
.
repeat
(
Math
.
max
(
3
-
String
(
line
).
length
,
0
))}
|
${
lines
[
j
]
}
`
)
const
lineLength
=
lines
[
j
].
length
if
(
j
===
i
)
{
// push underline
const
pad
=
start
-
(
count
-
lineLength
)
+
1
const
length
=
Math
.
max
(
1
,
end
>
count
?
lineLength
-
pad
:
end
-
start
)
res
.
push
(
` | `
+
'
'
.
repeat
(
pad
)
+
'
^
'
.
repeat
(
length
))
}
else
if
(
j
>
i
)
{
if
(
end
>
count
)
{
const
length
=
Math
.
max
(
Math
.
min
(
end
-
count
,
lineLength
),
1
)
res
.
push
(
` | `
+
'
^
'
.
repeat
(
length
))
}
count
+=
lineLength
+
1
}
}
break
}
}
return
res
.
join
(
'
\n
'
)
}
interface
MessageSourceLocation
{
type
:
'
exception
'
|
'
error
'
|
'
warning
'
|
'
info
'
|
'
logging
'
|
'
output
'
message
:
string
file
?:
string
line
:
number
column
:
number
}
interface
GenerateCodeFrameOptions
{
sourceRoot
?:
string
}
const
isWindows
=
os
.
platform
()
===
'
win32
'
function
normalizePath
(
id
:
string
):
string
{
return
isWindows
?
id
.
replace
(
/
\\
/g
,
'
/
'
)
:
id
}
export
function
generateCodeFrameSourceMapConsumer
(
consumer
:
BasicSourceMapConsumer
|
IndexedSourceMapConsumer
,
m
:
MessageSourceLocation
,
options
:
GenerateCodeFrameOptions
=
{}
):
Required
<
MessageSourceLocation
>
|
undefined
{
if
(
m
.
file
)
{
const
res
=
consumer
.
originalPositionFor
({
line
:
m
.
line
,
column
:
m
.
column
,
})
if
(
res
.
source
!=
null
&&
res
.
line
!=
null
&&
res
.
column
!=
null
)
{
const
code
=
consumer
.
sourceContentFor
(
res
.
source
,
true
)
if
(
code
)
{
return
{
type
:
m
.
type
,
file
:
options
.
sourceRoot
?
normalizePath
(
path
.
relative
(
options
.
sourceRoot
,
res
.
source
))
:
res
.
source
,
line
:
res
.
line
,
column
:
res
.
column
,
message
:
`
${
m
.
message
}
${
generateCodeFrame
(
code
,
{
line
:
res
.
line
,
column
:
res
.
column
})}
`
,
}
}
}
}
}
function
initConsumer
(
filename
:
string
)
{
if
(
fs
.
existsSync
(
filename
))
{
return
new
SourceMapConsumer
(
fs
.
readFileSync
(
filename
,
'
utf8
'
))
}
return
Promise
.
resolve
(
undefined
)
}
export
function
generateCodeFrameWithSourceMapPath
(
filename
:
string
,
messages
:
MessageSourceLocation
[]
|
string
,
options
:
GenerateCodeFrameOptions
=
{}
):
Promise
<
Required
<
MessageSourceLocation
>
[]
>
{
if
(
typeof
messages
===
'
string
'
)
{
try
{
messages
=
JSON
.
parse
(
messages
)
}
catch
(
e
)
{}
}
if
(
Array
.
isArray
(
messages
)
&&
messages
.
length
)
{
return
new
Promise
((
resolve
)
=>
{
initConsumer
(
filename
).
then
((
consumer
)
=>
{
resolve
(
(
messages
as
MessageSourceLocation
[])
.
map
((
m
)
=>
{
if
(
m
.
file
&&
consumer
)
{
const
message
=
generateCodeFrameSourceMapConsumer
(
consumer
,
m
,
options
)
if
(
message
)
{
return
message
}
}
if
(
!
m
.
file
)
{
m
.
file
=
''
}
return
m
as
Required
<
MessageSourceLocation
>
})
.
filter
(
Boolean
)
)
})
})
}
return
Promise
.
resolve
([])
}
packages/uni-uts-vite/src/utils/compiler/kotlin.ts
浏览文件 @
71e7790e
...
@@ -78,6 +78,11 @@ export async function runKotlinDev(filename: string) {
...
@@ -78,6 +78,11 @@ export async function runKotlinDev(filename: string) {
getDefaultJar
().
concat
(
resolveLibs
(
filename
))
getDefaultJar
().
concat
(
resolveLibs
(
filename
))
),
),
d8
:
resolveD8Args
(
jarFile
),
d8
:
resolveD8Args
(
jarFile
),
sourceRoot
:
process
.
env
.
UNI_INPUT_DIR
,
sourceMapPath
:
resolveSourceMapFile
(
process
.
env
.
UNI_OUTPUT_DIR
,
kotlinFile
),
}
}
const
res
=
await
compile
(
options
,
process
.
env
.
UNI_INPUT_DIR
)
const
res
=
await
compile
(
options
,
process
.
env
.
UNI_INPUT_DIR
)
// console.log('dex compile time: ' + (Date.now() - time) + 'ms')
// console.log('dex compile time: ' + (Date.now() - time) + 'ms')
...
@@ -95,6 +100,13 @@ export async function runKotlinDev(filename: string) {
...
@@ -95,6 +100,13 @@ export async function runKotlinDev(filename: string) {
}
}
}
}
function
resolveSourceMapFile
(
outputDir
:
string
,
kotlinFile
:
string
)
{
return
(
path
.
resolve
(
resolveSourceMapPath
(),
path
.
relative
(
outputDir
,
kotlinFile
))
+
'
.map
'
)
}
async
function
compile
(
filename
:
string
)
{
async
function
compile
(
filename
:
string
)
{
if
(
!
process
.
env
.
UNI_HBUILDERX_PLUGINS
)
{
if
(
!
process
.
env
.
UNI_HBUILDERX_PLUGINS
)
{
return
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录