@ctx-core/source-map 0.1.0 → 0.1.2

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctx-core/source-map",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Extensions to source-map...like sourcemap_writable_stream_",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -1,4 +1,5 @@
1
1
  import { file_exists_ } from 'ctx-core/fs'
2
+ import { TextDecoderStream } from 'ctx-core/stream'
2
3
  import { line__transform_stream_ } from 'ctx-core/string'
3
4
  import { readFile } from 'node:fs/promises'
4
5
  import { SourceMapConsumer } from 'source-map'
@@ -17,7 +18,7 @@ export function sourcemap_writable_stream_(write_stream) {
17
18
  const match =
18
19
  stream_line.match(/^\s+at ([^(]+ )?\(?(.*):(.*):([^)]*)\)?/)
19
20
  if (!match) {
20
- write_stream.write(stream_line)
21
+ write_stream.write(stream_line + '\n')
21
22
  return
22
23
  }
23
24
  const [
@@ -28,7 +29,7 @@ export function sourcemap_writable_stream_(write_stream) {
28
29
  column_str
29
30
  ] = match
30
31
  if (!path || !await file_exists_(path + '.map')) {
31
- write_stream.write(stream_line)
32
+ write_stream.write(stream_line + '\n')
32
33
  return
33
34
  }
34
35
  const methodName = methodName_match ? methodName_match.trim() : ''
@@ -40,7 +41,7 @@ export function sourcemap_writable_stream_(write_stream) {
40
41
  JSON.parse(
41
42
  await readFile(path + '.map').then(buf=>'' + buf)))
42
43
  if (line == null || line < 1) {
43
- write_stream.write(' ' + (methodName || '[unknown]'))
44
+ write_stream.write(' ' + (methodName || '[unknown]') + '\n')
44
45
  } else {
45
46
  const pos =
46
47
  smc.originalPositionFor({ line, column })
@@ -48,12 +49,12 @@ export function sourcemap_writable_stream_(write_stream) {
48
49
  write_stream.write(
49
50
  ' at '
50
51
  + (pos.name || methodName || '[unknown]')
51
- + ' (' + pos.source + ':' + pos.line + ':' + pos.column + ')')
52
+ + ' (' + pos.source + ':' + pos.line + ':' + pos.column + ')\n')
52
53
  }
53
54
  }
54
55
  } catch (err) {
55
56
  console.error(err)
56
- write_stream.write(' at FAILED_TO_PARSE_LINE')
57
+ write_stream.write(' at FAILED_TO_PARSE_LINE\n')
57
58
  }
58
59
  }
59
60
  }))
@@ -39,7 +39,7 @@ error: test error
39
39
  .pipeThrough(new TextEncoderStream())
40
40
  .pipeTo(sourcemap_writable_stream_(write_stream))
41
41
  await sleep(100)
42
- equal(write_stream_out_a.join('\n'), `
42
+ equal(write_stream_out_a.join(''), `
43
43
  server__build|watch
44
44
  browser__build|watch
45
45
  server started on port 3000
@@ -54,6 +54,6 @@ http://localhost:3000/
54
54
  error: test error
55
55
  at [unknown] (../../src/app/index.server.ts:8:9)
56
56
  at processTicksAndRejections (:61:77)
57
- `.trim())
57
+ `.trim() + '\n')
58
58
  })
59
59
  test.run()