-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
472d437
commit 05c049d
Showing
5 changed files
with
76 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "canyon-sdk", | ||
"version": "2.0.0-beta.3", | ||
"version": "2.0.0-beta.5", | ||
"files": [ | ||
"dist" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export function assemblyData (__coverage__: Window['__coverage__']) { | ||
// 组装数据,确保最小 | ||
|
||
const cov = Object.entries(__coverage__).map(([path, { b, f, s }]) => ({ | ||
path, | ||
b, | ||
f, | ||
s, | ||
})).reduce((acc, { path, b, f, s }) => { | ||
acc[path] = { b, f, s } | ||
return acc | ||
},{}) | ||
|
||
// 获取meta参数 | ||
const { projectID, sha, instrumentCwd,dsn } = Object.values(__coverage__)[0] | ||
return { | ||
coverage: cov, | ||
projectID, | ||
sha, | ||
instrumentCwd, | ||
dsn | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export async function compressDataWithStream (data) { | ||
const textEncoder = new TextEncoder() | ||
const input = textEncoder.encode(data) | ||
|
||
const compressionStream = new CompressionStream('gzip') | ||
const writer = compressionStream.writable.getWriter() | ||
writer.write(input) | ||
writer.close() | ||
|
||
const compressedData = [] | ||
const reader = compressionStream.readable.getReader() | ||
let result | ||
while (!(result = await reader.read()).done) { | ||
compressedData.push(result.value) | ||
} | ||
return new Blob(compressedData) // 压缩后的数据为 Blob | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// window-extensions.d.ts | ||
// 首先定义一些可能用到的子类型 | ||
|
||
// 表示对象中类似 "s"、"f"、"b" 这种键对应的值的类型 | ||
type CoverageObjectValues = { | ||
[key: string]: number | number[]; | ||
}; | ||
|
||
// 定义 window.__coverage__ 的类型 | ||
interface WindowCoverage { | ||
path: string; | ||
s: CoverageObjectValues; | ||
f: CoverageObjectValues; | ||
b: CoverageObjectValues; | ||
_coverageSchema: string; | ||
hash: string; | ||
sha: string; | ||
projectID: string; | ||
instrumentCwd: string; | ||
dsn: string; | ||
} | ||
|
||
// 扩展Window接口 | ||
interface Window { | ||
__coverage__: { | ||
[key: string]: WindowCoverage; | ||
} | ||
} |