@ctx-core/source-map 0.1.3 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,56 +1,57 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
2
|
+
"name": "@ctx-core/source-map",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Extensions to source-map...like sourcemap_writable_stream_",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"ctx-core",
|
|
8
|
+
"source-map"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/ctx-core/source-map#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/ctx-core/source-map/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/ctx-core/source-map.git"
|
|
17
|
+
},
|
|
18
|
+
"license": "Apache-2.0",
|
|
19
|
+
"author": "Brian Takita",
|
|
20
|
+
"files": [
|
|
21
|
+
"*.d.ts",
|
|
22
|
+
"*.js",
|
|
23
|
+
"*.json",
|
|
24
|
+
"sourcemap_writable_stream"
|
|
25
|
+
],
|
|
26
|
+
"types": "./index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": "./index.js",
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": ":",
|
|
33
|
+
"clean": ":",
|
|
34
|
+
"exec": "$@",
|
|
35
|
+
"prepublishOnly": "pnpm clean && pnpm build && pnpm test",
|
|
36
|
+
"test": "pnpm test:unit && pnpm test:types",
|
|
37
|
+
"test:types": "check-dts",
|
|
38
|
+
"test:unit": "tsx node_modules/uvu/bin.js . '\\.test\\.(ts|js)$'",
|
|
39
|
+
"test:unit:coverage": "c8 pnpm test:unit"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"ctx-core": "^5.19.1",
|
|
43
|
+
"source-map": "^0.7.4"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"c8": "^9.1.0",
|
|
47
|
+
"check-dts": "^0.7.2",
|
|
48
|
+
"tsx": "^4.7.0",
|
|
49
|
+
"typescript": "next",
|
|
50
|
+
"uvu": "^0.5.6"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public",
|
|
54
|
+
"cache": "~/.npm"
|
|
55
|
+
},
|
|
56
|
+
"sideEffects": false
|
|
57
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export function sourcemap_writable_stream_(
|
|
3
|
+
write:(str:string)=>(unknown|Promise<unknown>)
|
|
4
|
+
):WritableStream
|
|
@@ -3,7 +3,12 @@ import { TextDecoderStream } from 'ctx-core/stream'
|
|
|
3
3
|
import { line__transform_stream_ } from 'ctx-core/string'
|
|
4
4
|
import { readFile } from 'node:fs/promises'
|
|
5
5
|
import { SourceMapConsumer } from 'source-map'
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @param {(str:string)=>(unknown|Promise<unknown>)}write
|
|
8
|
+
* @returns {WritableStream<any>}
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
export function sourcemap_writable_stream_(write) {
|
|
7
12
|
let outstream_controller
|
|
8
13
|
const path_R_SourceMapConsumer = {}
|
|
9
14
|
new ReadableStream({
|
|
@@ -18,7 +23,7 @@ export function sourcemap_writable_stream_(write_stream) {
|
|
|
18
23
|
const match =
|
|
19
24
|
stream_line.match(/^\s+at ([^(]+ )?\(?(.*):(.*):([^)]*)\)?/)
|
|
20
25
|
if (!match) {
|
|
21
|
-
|
|
26
|
+
await write(stream_line + '\n')
|
|
22
27
|
return
|
|
23
28
|
}
|
|
24
29
|
const [
|
|
@@ -29,7 +34,7 @@ export function sourcemap_writable_stream_(write_stream) {
|
|
|
29
34
|
column_str
|
|
30
35
|
] = match
|
|
31
36
|
if (!path || !await file_exists_(path + '.map')) {
|
|
32
|
-
|
|
37
|
+
await write(stream_line + '\n')
|
|
33
38
|
return
|
|
34
39
|
}
|
|
35
40
|
const methodName = methodName_match ? methodName_match.trim() : ''
|
|
@@ -41,12 +46,12 @@ export function sourcemap_writable_stream_(write_stream) {
|
|
|
41
46
|
JSON.parse(
|
|
42
47
|
await readFile(path + '.map').then(buf=>'' + buf)))
|
|
43
48
|
if (line == null || line < 1) {
|
|
44
|
-
|
|
49
|
+
await write(' ' + (methodName || '[unknown]') + '\n')
|
|
45
50
|
} else {
|
|
46
51
|
const pos =
|
|
47
52
|
smc.originalPositionFor({ line, column })
|
|
48
53
|
if (pos && pos.line != null) {
|
|
49
|
-
|
|
54
|
+
await write(
|
|
50
55
|
' at '
|
|
51
56
|
+ (pos.name || methodName || '[unknown]')
|
|
52
57
|
+ ' (' + pos.source + ':' + pos.line + ':' + pos.column + ')\n')
|
|
@@ -54,7 +59,7 @@ export function sourcemap_writable_stream_(write_stream) {
|
|
|
54
59
|
}
|
|
55
60
|
} catch (err) {
|
|
56
61
|
console.error(err)
|
|
57
|
-
|
|
62
|
+
await write(' at FAILED_TO_PARSE_LINE\n')
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
}))
|
|
@@ -25,11 +25,6 @@ error: test error
|
|
|
25
25
|
|
|
26
26
|
`.trim()
|
|
27
27
|
const write_stream_out_a:string[] = []
|
|
28
|
-
const write_stream = new Writable()
|
|
29
|
-
write_stream.write = (str:string)=>{
|
|
30
|
-
write_stream_out_a.push(str)
|
|
31
|
-
return true
|
|
32
|
-
}
|
|
33
28
|
await new ReadableStream({
|
|
34
29
|
start(controller) {
|
|
35
30
|
controller.enqueue(stderr_text)
|
|
@@ -37,7 +32,8 @@ error: test error
|
|
|
37
32
|
}
|
|
38
33
|
})
|
|
39
34
|
.pipeThrough(new TextEncoderStream())
|
|
40
|
-
.pipeTo(sourcemap_writable_stream_(
|
|
35
|
+
.pipeTo(sourcemap_writable_stream_(
|
|
36
|
+
str=>write_stream_out_a.push(str)))
|
|
41
37
|
await sleep(100)
|
|
42
38
|
equal(write_stream_out_a.join(''), `
|
|
43
39
|
server__build|watch
|