nodexh 3.1.0 → 4.0.0

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/bin/nodexh CHANGED
@@ -16,13 +16,14 @@ realpath() {
16
16
 
17
17
  node \
18
18
  --require "$(realpath "$0")"/../../lib/main.js \
19
+ --no-warnings=ExperimentalWarning \
19
20
  --trace-warnings \
20
- --disable-warning='ExperimentalWarning' \
21
- --experimental-require-module \
22
21
  --enable-source-maps \
23
22
  --stack-trace-limit=100 \
24
23
  --expose-gc \
25
24
  "$@"
25
+ # --disable-warning='ExperimentalWarning' \
26
+ # --experimental-require-module \
26
27
  # --nouse_idle_notification \
27
28
  # --trace_gc \
28
29
 
package/lib/main.js CHANGED
@@ -1,190 +1,23 @@
1
1
  (function() {
2
2
  'use strict';
3
- var FS, GUY, PATH, _exit_handler, _get_context, alert, blue, bold, cyan, debug, echo, exit_handler, fetch_mapped_location, get_context, get_error_callsites, gold, green, grey, inspect, lime, load_source_map, log, orange, other_path_color, own_path_color, red, reverse, rpr, show_error_with_source_context, steel, underline, white, write_to_stderr, yellow;
3
+ var SFMODULES, exit_handler, format_stack, write_to_stderr;
4
4
 
5
5
  //###########################################################################################################
6
- GUY = require('guy');
6
+ // blue # Слава Україні
7
+ // yellow # Слава Україні
8
+ SFMODULES = require('bricabrac-single-file-modules');
7
9
 
8
- ({alert, debug} = GUY.trm.get_loggers('NODEXH'));
9
-
10
- ({rpr, inspect, echo, log} = GUY.trm);
11
-
12
- get_error_callsites = require('error-callsites');
13
-
14
- load_source_map = (require('util')).promisify(require('load-source-map'));
15
-
16
- FS = require('fs');
17
-
18
- PATH = require('path');
19
-
20
- ({red, green, steel, grey, cyan, bold, lime, gold, white, orange, blue, yellow, reverse, underline, bold} = GUY.trm); // Слава Україні // Слава Україні
21
-
22
- //-----------------------------------------------------------------------------------------------------------
23
- other_path_color = function(...P) {
24
- return reverse(bold(orange('', ...P, '')));
25
- };
26
-
27
- own_path_color = function(...P) {
28
- return reverse(bold(lime('', ...P, '')));
29
- };
30
-
31
- //-----------------------------------------------------------------------------------------------------------
32
- write_to_stderr = function(...P) {
33
- return process.stderr.write(' ' + (GUY.trm.pen(...P)) + '\n');
34
- };
10
+ ({format_stack} = SFMODULES.unstable.require_format_stack());
35
11
 
36
12
  //-----------------------------------------------------------------------------------------------------------
37
- fetch_mapped_location = async function(path, linenr, colnr) {
38
- var error, mapped_path, smp, sourcemap;
39
- try {
40
- sourcemap = (await load_source_map(path));
41
- smp = sourcemap.originalPositionFor({
42
- line: linenr,
43
- column: colnr
44
- });
45
- } catch (error1) {
46
- error = error1;
47
- return {path, linenr, colnr};
48
- }
49
- //.........................................................................................................
50
- if ((smp != null) && (smp.source != null) && (smp.source !== '') && (smp.line != null) && (smp.column != null)) {
51
- mapped_path = PATH.join(PATH.dirname(path), smp.source);
52
- return {
53
- path: mapped_path,
54
- linenr: smp.line,
55
- colnr: smp.column
56
- };
57
- }
58
- //.........................................................................................................
59
- return {path, linenr, colnr};
60
- };
61
-
62
- //-----------------------------------------------------------------------------------------------------------
63
- get_context = function(path, linenr, colnr, width) {
64
- var error;
65
- try {
66
- return _get_context(path, linenr, colnr, width);
67
- } catch (error1) {
68
- error = error1;
69
- if (error.code !== 'ENOENT') {
70
- throw error;
71
- }
72
- }
73
- return [];
74
- };
75
-
76
- //-----------------------------------------------------------------------------------------------------------
77
- _get_context = function(path, linenr, colnr, width) {
78
- /* TAINT perform line length adjustment, hiliting in dedicated method */
79
- var R, c0, c1, coldelta, delta, effect, first_idx, hilite, i, idx, last_idx, len, line, lines, ref, this_linenr, this_linenr_txt, width2;
80
- lines = (FS.readFileSync(path, {
81
- encoding: 'utf-8'
82
- })).split('\n');
83
- delta = 1;
84
- coldelta = 5;
85
- effect = reverse;
86
- first_idx = Math.max(0, linenr - 1 - delta);
87
- last_idx = Math.min(lines.length - 1, linenr - 1 + delta);
88
- R = [];
89
- ref = lines.slice(first_idx, +last_idx + 1 || 9e9);
90
- for (idx = i = 0, len = ref.length; i < len; idx = ++i) {
91
- line = ref[idx];
92
- this_linenr = first_idx + idx + 1;
93
- this_linenr_txt = (this_linenr.toString().padStart(4)) + '│ ';
94
- if (this_linenr !== linenr) {
95
- /* TAINT should adjust overlong context lines as well */
96
- R.push(`${grey(this_linenr_txt)}${grey(line)}`);
97
- continue;
98
- }
99
- c0 = colnr - 1;
100
- c1 = colnr + coldelta;
101
- hilite = effect(line.slice(c0, c1));
102
- line = line.slice(0, c0) + hilite + line.slice(c1);
103
- if (c1 > width) {
104
- width2 = Math.floor(width / 2);
105
- line = '... ' + line.slice(c1 - width2, +(c1 + hilite.length - (c1 - c0) + width2) + 1 || 9e9) + ' ...';
106
- } else {
107
- line = line.slice(0, +width + 1 || 9e9);
108
- }
109
- R.push(`${grey(this_linenr_txt)}${cyan(line)}`);
110
- }
111
- return R;
112
- };
113
-
114
- //-----------------------------------------------------------------------------------------------------------
115
- show_error_with_source_context = async function(error, headline) {
116
- /* TAINT use proper methods to format with multiple colors */
117
- var arrowhead, arrowshaft, callsite, callsites, colnr, context_line, fname, fname_txt, i, j, len, len1, linenr, path, path_color, ref, ref1, ref2, relpath, width, width1;
118
- alert('^77765-1^', reverse(bold(headline)));
119
- arrowhead = white('▲');
120
- arrowshaft = white('│');
121
- width = process.stdout.columns;
122
- callsites = get_error_callsites(error);
123
- //.........................................................................................................
124
- if ((callsites == null) || (callsites.length === 0)) {
125
- write_to_stderr(red(reverse("^455756^ error has no associated callsites:")));
126
- write_to_stderr(red(reverse(rpr(error))));
127
- return null;
128
- }
129
- //.........................................................................................................
130
- callsites.reverse();
131
- //.........................................................................................................
132
- for (i = 0, len = callsites.length; i < len; i++) {
133
- callsite = callsites[i];
134
- path = callsite.getFileName();
135
- //.......................................................................................................
136
- if (path == null) {
137
- write_to_stderr(grey('—'.repeat(108)));
138
- continue;
139
- }
140
- //.......................................................................................................
141
- linenr = callsite.getLineNumber();
142
- colnr = callsite.getColumnNumber();
143
- //.......................................................................................................
144
- if ((path.startsWith('node:internal/')) || (path.startsWith('internal/'))) {
145
- write_to_stderr(arrowhead, grey(`${path} @ ${linenr},${colnr}`));
146
- continue;
147
- }
148
- //.......................................................................................................
149
- if (/\/node_modules\//.test(path)) {
150
- path_color = other_path_color;
151
- } else {
152
- path_color = own_path_color;
153
- }
154
- //.......................................................................................................
155
- fname = (ref = (ref1 = callsite.getFunctionName()) != null ? ref1 : callsite.getMethodName()) != null ? ref : null;
156
- ({path, linenr, colnr} = (await fetch_mapped_location(path, linenr, colnr)));
157
- relpath = PATH.relative(process.cwd(), path);
158
- if (fname != null) {
159
- fname_txt = steel(fname);
160
- width1 = width + (fname_txt.length - fname.length);
161
- write_to_stderr(arrowhead, path_color(`${relpath} @ ${linenr},${colnr}: ${fname_txt}() \x1b[38;05;234m`.padEnd(width1, '—')));
162
- } else {
163
- write_to_stderr(arrowhead, path_color(`${relpath} @ ${linenr},${colnr}: \x1b[38;05;234m`.padEnd(width, '—')));
164
- }
165
- ref2 = (await get_context(path, linenr, colnr, width));
166
- for (j = 0, len1 = ref2.length; j < len1; j++) {
167
- context_line = ref2[j];
168
- write_to_stderr(arrowshaft, context_line);
169
- }
170
- }
171
- alert('^77765-2^', reverse(bold(headline)));
172
- return null;
173
- };
174
-
175
- //-----------------------------------------------------------------------------------------------------------
176
- _exit_handler = async function(error, origin) {
177
- /* TAINT origin never used */
178
- var message, ref, ref1, ref2, type;
179
- type = (ref = (ref1 = error.code) != null ? ref1 : error.name) != null ? ref : 'EXCEPTION';
180
- message = ` ${type}: ` + ((ref2 = error != null ? error.message : void 0) != null ? ref2 : "an unrecoverable condition occurred");
181
- await show_error_with_source_context(error, message);
182
- return null;
13
+ write_to_stderr = function(text) {
14
+ return process.stderr.write(text + '\n');
183
15
  };
184
16
 
185
17
  //-----------------------------------------------------------------------------------------------------------
186
- exit_handler = async function(error, origin) {
187
- await _exit_handler(error, origin);
18
+ exit_handler = function(error, origin) {
19
+ // _exit_handler error, origin
20
+ write_to_stderr(format_stack(error));
188
21
  setImmediate((function() {
189
22
  return process.exit(111);
190
23
  }));
@@ -200,8 +33,8 @@
200
33
  }
201
34
 
202
35
  //###########################################################################################################
203
- module.exports = {exit_handler, _exit_handler};
36
+ module.exports = {exit_handler};
204
37
 
205
38
  }).call(this);
206
39
 
207
- //# sourceMappingURL=main.js.map
40
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL21haW4uY29mZmVlIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBO0VBQUE7QUFBQSxNQUFBLFNBQUEsRUFBQSxZQUFBLEVBQUEsWUFBQSxFQUFBLGVBQUE7Ozs7O0VBTUEsU0FBQSxHQUE0QixPQUFBLENBQVEsK0JBQVI7O0VBQzVCLENBQUEsQ0FBRSxZQUFGLENBQUEsR0FBNEIsU0FBUyxDQUFDLFFBQVEsQ0FBQyxvQkFBbkIsQ0FBQSxDQUE1QixFQVBBOzs7RUFVQSxlQUFBLEdBQWtCLFFBQUEsQ0FBRSxJQUFGLENBQUE7V0FBWSxPQUFPLENBQUMsTUFBTSxDQUFDLEtBQWYsQ0FBcUIsSUFBQSxHQUFPLElBQTVCO0VBQVosRUFWbEI7OztFQWFBLFlBQUEsR0FBZSxRQUFBLENBQUUsS0FBRixFQUFTLE1BQVQsQ0FBQSxFQUFBOztJQUViLGVBQUEsQ0FBZ0IsWUFBQSxDQUFhLEtBQWIsQ0FBaEI7SUFDQSxZQUFBLENBQWEsQ0FBRSxRQUFBLENBQUEsQ0FBQTthQUFHLE9BQU8sQ0FBQyxJQUFSLENBQWEsR0FBYjtJQUFILENBQUYsQ0FBYjtBQUNBLFdBQU87RUFKTSxFQWJmOzs7RUFzQkEsSUFBTyxtREFBUDtJQUNFO0lBQ0EsTUFBTSxDQUFFLE1BQU0sQ0FBQyxHQUFQLENBQVcsdUJBQVgsQ0FBRixDQUFOLEdBQStD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S0tLS1cbmV4aXRfaGFuZGxlciA9ICggZXJyb3IsIG9yaWdpbiApIC0+XG4gICMgX2V4aXRfaGFuZGxlciBlcnJvciwgb3JpZ2luXG4gIHdyaXRlX3RvX3N0ZGVyciBmb3JtYXRfc3RhY2sgZXJyb3JcbiAgc2V0SW1tZWRpYXRlICggLT4gcHJvY2Vzcy5leGl0IDExMSApXG4gIHJldHVybiBudWxsXG5cblxuXG4jIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyNcbnVubGVzcyBnbG9iYWxbIFN5bWJvbC5mb3IgJ2NuZC1leGNlcHRpb24taGFuZGxlcicgXT9cbiAgbnVsbFxuICBnbG9iYWxbIFN5bWJvbC5mb3IgJ2NuZC1leGNlcHRpb24taGFuZGxlcicgXSA9IHRydWVcbiAgcHJvY2Vzcy5vbmNlICd1bmNhdWdodEV4Y2VwdGlvbicsICBleGl0X2hhbmRsZXJcbiAgcHJvY2Vzcy5vbmNlICd1bmhhbmRsZWRSZWplY3Rpb24nLCBleGl0X2hhbmRsZXJcblxuXG4jIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyNcbm1vZHVsZS5leHBvcnRzID0geyBleGl0X2hhbmRsZXIsIH1cblxuIl19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodexh",
3
- "version": "3.1.0",
3
+ "version": "4.0.0",
4
4
  "description": "a wrapper around the `node` executable for better stacktraces with sourcemaps, sourcecode excerpts",
5
5
  "main": "lib/main.js",
6
6
  "bin": {
@@ -23,9 +23,7 @@
23
23
  },
24
24
  "homepage": "https://github.com/loveencounterflow/nodexh",
25
25
  "dependencies": {
26
- "error-callsites": "^2.0.3",
27
- "guy": "^13.7.1",
28
- "load-source-map": "3.0.1"
26
+ "bricabrac-single-file-modules": "^0.5.0"
29
27
  },
30
28
  "scripts": {
31
29
  "build": "coffee --map -o lib -c src"
package/src/main.coffee CHANGED
@@ -3,149 +3,18 @@
3
3
 
4
4
 
5
5
  ############################################################################################################
6
- GUY = require 'guy'
7
- { alert
8
- debug } = GUY.trm.get_loggers 'NODEXH'
9
- { rpr
10
- inspect
11
- echo
12
- log } = GUY.trm
13
- get_error_callsites = require 'error-callsites'
14
- load_source_map = ( require 'util' ).promisify ( require 'load-source-map' )
15
- FS = require 'fs'
16
- PATH = require 'path'
17
- { red
18
- green
19
- steel
20
- grey
21
- cyan
22
- bold
23
- lime
24
- gold
25
- white
26
- orange
27
- blue # Слава Україні
28
- yellow # Слава Україні
29
- reverse
30
- underline
31
- bold } = GUY.trm
6
+ # blue # Слава Україні
7
+ # yellow # Слава Україні
8
+ SFMODULES = require 'bricabrac-single-file-modules'
9
+ { format_stack, } = SFMODULES.unstable.require_format_stack()
32
10
 
33
11
  #-----------------------------------------------------------------------------------------------------------
34
- other_path_color = ( P... ) -> reverse bold orange '', P..., ''
35
- own_path_color = ( P... ) -> reverse bold lime '', P..., ''
36
-
37
- #-----------------------------------------------------------------------------------------------------------
38
- write_to_stderr = ( P... ) -> process.stderr.write ' ' + ( GUY.trm.pen P... ) + '\n'
39
-
40
- #-----------------------------------------------------------------------------------------------------------
41
- fetch_mapped_location = ( path, linenr, colnr ) ->
42
- try
43
- sourcemap = await load_source_map path
44
- smp = sourcemap.originalPositionFor { line: linenr, column: colnr, }
45
- catch error
46
- return { path, linenr, colnr, }
47
- #.........................................................................................................
48
- if ( smp? ) and ( smp.source? ) and ( smp.source isnt '' ) and ( smp.line? ) and ( smp.column? )
49
- mapped_path = PATH.join ( PATH.dirname path ), smp.source
50
- return { path: mapped_path, linenr: smp.line, colnr: smp.column, }
51
- #.........................................................................................................
52
- return { path, linenr, colnr, }
53
-
54
- #-----------------------------------------------------------------------------------------------------------
55
- get_context = ( path, linenr, colnr, width ) ->
56
- try return ( _get_context path, linenr, colnr, width ) catch error
57
- throw error unless error.code is 'ENOENT'
58
- return []
59
-
60
- #-----------------------------------------------------------------------------------------------------------
61
- _get_context = ( path, linenr, colnr, width ) ->
62
- lines = ( FS.readFileSync path, { encoding: 'utf-8' } ).split '\n'
63
- delta = 1
64
- coldelta = 5
65
- effect = reverse
66
- first_idx = Math.max 0, linenr - 1 - delta
67
- last_idx = Math.min lines.length - 1, linenr - 1 + delta
68
- R = []
69
- for line, idx in lines[ first_idx .. last_idx ]
70
- this_linenr = first_idx + idx + 1
71
- this_linenr_txt = ( this_linenr.toString().padStart 4 ) + '│ '
72
- if this_linenr isnt linenr
73
- ### TAINT should adjust overlong context lines as well ###
74
- R.push "#{grey this_linenr_txt}#{grey line}"
75
- continue
76
- ### TAINT perform line length adjustment, hiliting in dedicated method ###
77
- c0 = colnr - 1
78
- c1 = colnr + coldelta
79
- hilite = effect line[ c0 ... c1 ]
80
- line = line[ ... c0 ] + hilite + line[ c1 .. ]
81
- if c1 > width
82
- width2 = Math.floor width / 2
83
- line = '... ' + line[ c1 - width2 .. c1 + hilite.length - ( c1 - c0 ) + width2 ] + ' ...'
84
- else
85
- line = line[ .. width ]
86
- R.push "#{grey this_linenr_txt}#{cyan line}"
87
- return R
88
-
89
- #-----------------------------------------------------------------------------------------------------------
90
- show_error_with_source_context = ( error, headline ) ->
91
- alert '^77765-1^', reverse bold headline
92
- arrowhead = white '▲'
93
- arrowshaft = white '│'
94
- width = process.stdout.columns
95
- callsites = get_error_callsites error
96
- #.........................................................................................................
97
- if ( not callsites? ) or ( callsites.length is 0 )
98
- write_to_stderr red reverse "^455756^ error has no associated callsites:"
99
- write_to_stderr red reverse rpr error
100
- return null
101
- #.........................................................................................................
102
- callsites.reverse()
103
- #.........................................................................................................
104
- for callsite in callsites
105
- path = callsite.getFileName()
106
- #.......................................................................................................
107
- unless path?
108
- write_to_stderr grey '—'.repeat 108
109
- continue
110
- #.......................................................................................................
111
- linenr = callsite.getLineNumber()
112
- colnr = callsite.getColumnNumber()
113
- #.......................................................................................................
114
- if ( path.startsWith 'node:internal/' ) or ( path.startsWith 'internal/' )
115
- write_to_stderr arrowhead, grey "#{path} @ #{linenr},#{colnr}"
116
- continue
117
- #.......................................................................................................
118
- if ( /\/node_modules\//.test path ) then path_color = other_path_color
119
- else path_color = own_path_color
120
- #.......................................................................................................
121
- fname = callsite.getFunctionName() ? callsite.getMethodName() ? null
122
- { path
123
- linenr
124
- colnr } = await fetch_mapped_location path, linenr, colnr
125
- relpath = PATH.relative process.cwd(), path
126
- if fname?
127
- ### TAINT use proper methods to format with multiple colors ###
128
- fname_txt = steel fname
129
- width1 = width + ( fname_txt.length - fname.length )
130
- write_to_stderr arrowhead, path_color ( "#{relpath} @ #{linenr},#{colnr}: #{fname_txt}() \x1b[38;05;234m".padEnd width1, '—' )
131
- else
132
- write_to_stderr arrowhead, path_color ( "#{relpath} @ #{linenr},#{colnr}: \x1b[38;05;234m".padEnd width, '—' )
133
- for context_line in await get_context path, linenr, colnr, width
134
- write_to_stderr arrowshaft, context_line
135
- alert '^77765-2^', reverse bold headline
136
- return null
137
-
138
- #-----------------------------------------------------------------------------------------------------------
139
- _exit_handler = ( error, origin ) ->
140
- ### TAINT origin never used ###
141
- type = error.code ? error.name ? 'EXCEPTION'
142
- message = " #{type}: " + ( error?.message ? "an unrecoverable condition occurred" )
143
- await show_error_with_source_context error, message
144
- return null
12
+ write_to_stderr = ( text ) -> process.stderr.write text + '\n'
145
13
 
146
14
  #-----------------------------------------------------------------------------------------------------------
147
15
  exit_handler = ( error, origin ) ->
148
- await _exit_handler error, origin
16
+ # _exit_handler error, origin
17
+ write_to_stderr format_stack error
149
18
  setImmediate ( -> process.exit 111 )
150
19
  return null
151
20
 
@@ -160,5 +29,5 @@ unless global[ Symbol.for 'cnd-exception-handler' ]?
160
29
 
161
30
 
162
31
  ############################################################################################################
163
- module.exports = { exit_handler, _exit_handler, }
32
+ module.exports = { exit_handler, }
164
33
 
package/lib/main.js.map DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "version": 3,
3
- "file": "",
4
- "sourceRoot": "",
5
- "sources": [
6
- "../src/main.coffee"
7
- ],
8
- "names": [],
9
- "mappings": "AACA;EAAA;AAAA,MAAA,EAAA,EAAA,GAAA,EAAA,IAAA,EAAA,aAAA,EAAA,YAAA,EAAA,KAAA,EAAA,IAAA,EAAA,IAAA,EAAA,IAAA,EAAA,KAAA,EAAA,IAAA,EAAA,YAAA,EAAA,qBAAA,EAAA,WAAA,EAAA,mBAAA,EAAA,IAAA,EAAA,KAAA,EAAA,IAAA,EAAA,OAAA,EAAA,IAAA,EAAA,eAAA,EAAA,GAAA,EAAA,MAAA,EAAA,gBAAA,EAAA,cAAA,EAAA,GAAA,EAAA,OAAA,EAAA,GAAA,EAAA,8BAAA,EAAA,KAAA,EAAA,SAAA,EAAA,KAAA,EAAA,eAAA,EAAA,MAAA;;;EAIA,GAAA,GAA4B,OAAA,CAAQ,KAAR;;EAC5B,CAAA,CAAE,KAAF,EACE,KADF,CAAA,GAC4B,GAAG,CAAC,GAAG,CAAC,WAAR,CAAoB,QAApB,CAD5B;;EAEA,CAAA,CAAE,GAAF,EACE,OADF,EAEE,IAFF,EAGE,GAHF,CAAA,GAG4B,GAAG,CAAC,GAHhC;;EAIA,mBAAA,GAA4B,OAAA,CAAQ,iBAAR;;EAC5B,eAAA,GAA4B,CAAE,OAAA,CAAQ,MAAR,CAAF,CAAkB,CAAC,SAAnB,CAA+B,OAAA,CAAQ,iBAAR,CAA/B;;EAC5B,EAAA,GAA4B,OAAA,CAAQ,IAAR;;EAC5B,IAAA,GAA4B,OAAA,CAAQ,MAAR;;EAC5B,CAAA,CAAE,GAAF,EACE,KADF,EAEE,KAFF,EAGE,IAHF,EAIE,IAJF,EAKE,IALF,EAME,IANF,EAO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AA,CAAA,GAAe,kEAAmB,qCAAnB;IACzB,MAAM,8BAAA,CAA+B,KAA/B,EAAsC,OAAtC;AACN,WAAO;EALO,EAzIhB;;;EAiJA,YAAA,GAAe,MAAA,QAAA,CAAE,KAAF,EAAS,MAAT,CAAA;IACb,MAAM,aAAA,CAAc,KAAd,EAAqB,MAArB;IACN,YAAA,CAAa,CAAE,QAAA,CAAA,CAAA;aAAG,OAAO,CAAC,IAAR,CAAa,GAAb;IAAH,CAAF,CAAb;AACA,WAAO;EAHM,EAjJf;;;EAyJA,IAAO,mDAAP;IACE;IACA,MAAM,CAAE,MAAM,CAAC,GAAP,CAAW,uBAAX,CAAF,CAAN,GAA+C;IAC/C,OAAO,CAAC,IAAR,CAAa,mBAAb,EAAmC,YAAnC;IACA,OAAO,CAAC,IAAR,CAAa,oBAAb,EAAmC,YAAnC,EAJF;GAzJA;;;EAiKA,MAAM,CAAC,OAAP,GAAiB,CAAE,YAAF,EAAgB,aAAhB;AAjKjB",
10
- "sourcesContent": [
11
- "\n'use strict'\n\n\n############################################################################################################\nGUY = require 'guy'\n{ alert\n debug } = GUY.trm.get_loggers 'NODEXH'\n{ rpr\n inspect\n echo\n log } = GUY.trm\nget_error_callsites = require 'error-callsites'\nload_source_map = ( require 'util' ).promisify ( require 'load-source-map' )\nFS = require 'fs'\nPATH = require 'path'\n{ red\n green\n steel\n grey\n cyan\n bold\n lime\n gold\n white\n orange\n blue # Слава Україні\n yellow # Слава Україні\n reverse\n underline\n bold } = GUY.trm\n\n#-----------------------------------------------------------------------------------------------------------\nother_path_color = ( P... ) -> reverse bold orange '', P..., ''\nown_path_color = ( P... ) -> reverse bold lime '', P..., ''\n\n#-----------------------------------------------------------------------------------------------------------\nwrite_to_stderr = ( P... ) -> process.stderr.write ' ' + ( GUY.trm.pen P... ) + '\\n'\n\n#-----------------------------------------------------------------------------------------------------------\nfetch_mapped_location = ( path, linenr, colnr ) ->\n try\n sourcemap = await load_source_map path\n smp = sourcemap.originalPositionFor { line: linenr, column: colnr, }\n catch error\n return { path, linenr, colnr, }\n #.........................................................................................................\n if ( smp? ) and ( smp.source? ) and ( smp.source isnt '' ) and ( smp.line? ) and ( smp.column? )\n mapped_path = PATH.join ( PATH.dirname path ), smp.source\n return { path: mapped_path, linenr: smp.line, colnr: smp.column, }\n #.........................................................................................................\n return { path, linenr, colnr, }\n\n#-----------------------------------------------------------------------------------------------------------\nget_context = ( path, linenr, colnr, width ) ->\n try return ( _get_context path, linenr, colnr, width ) catch error\n throw error unless error.code is 'ENOENT'\n return []\n\n#-----------------------------------------------------------------------------------------------------------\n_get_context = ( path, linenr, colnr, width ) ->\n lines = ( FS.readFileSync path, { encoding: 'utf-8' } ).split '\\n'\n delta = 1\n coldelta = 5\n effect = reverse\n first_idx = Math.max 0, linenr - 1 - delta\n last_idx = Math.min lines.length - 1, linenr - 1 + delta\n R = []\n for line, idx in lines[ first_idx .. last_idx ]\n this_linenr = first_idx + idx + 1\n this_linenr_txt = ( this_linenr.toString().padStart 4 ) + '│ '\n if this_linenr isnt linenr\n ### TAINT should adjust overlong context lines as well ###\n R.push \"#{grey this_linenr_txt}#{grey line}\"\n continue\n ### TAINT perform line length adjustment, hiliting in dedicated method ###\n c0 = colnr - 1\n c1 = colnr + coldelta\n hilite = effect line[ c0 ... c1 ]\n line = line[ ... c0 ] + hilite + line[ c1 .. ]\n if c1 > width\n width2 = Math.floor width / 2\n line = '... ' + line[ c1 - width2 .. c1 + hilite.length - ( c1 - c0 ) + width2 ] + ' ...'\n else\n line = line[ .. width ]\n R.push \"#{grey this_linenr_txt}#{cyan line}\"\n return R\n\n#-----------------------------------------------------------------------------------------------------------\nshow_error_with_source_context = ( error, headline ) ->\n alert '^77765-1^', reverse bold headline\n arrowhead = white '▲'\n arrowshaft = white '│'\n width = process.stdout.columns\n callsites = get_error_callsites error\n #.........................................................................................................\n if ( not callsites? ) or ( callsites.length is 0 )\n write_to_stderr red reverse \"^455756^ error has no associated callsites:\"\n write_to_stderr red reverse rpr error\n return null\n #.........................................................................................................\n callsites.reverse()\n #.........................................................................................................\n for callsite in callsites\n path = callsite.getFileName()\n #.......................................................................................................\n unless path?\n write_to_stderr grey '—'.repeat 108\n continue\n #.......................................................................................................\n linenr = callsite.getLineNumber()\n colnr = callsite.getColumnNumber()\n #.......................................................................................................\n if ( path.startsWith 'node:internal/' ) or ( path.startsWith 'internal/' )\n write_to_stderr arrowhead, grey \"#{path} @ #{linenr},#{colnr}\"\n continue\n #.......................................................................................................\n if ( /\\/node_modules\\//.test path ) then path_color = other_path_color\n else path_color = own_path_color\n #.......................................................................................................\n fname = callsite.getFunctionName() ? callsite.getMethodName() ? null\n { path\n linenr\n colnr } = await fetch_mapped_location path, linenr, colnr\n relpath = PATH.relative process.cwd(), path\n if fname?\n ### TAINT use proper methods to format with multiple colors ###\n fname_txt = steel fname\n width1 = width + ( fname_txt.length - fname.length )\n write_to_stderr arrowhead, path_color ( \"#{relpath} @ #{linenr},#{colnr}: #{fname_txt}() \\x1b[38;05;234m\".padEnd width1, '—' )\n else\n write_to_stderr arrowhead, path_color ( \"#{relpath} @ #{linenr},#{colnr}: \\x1b[38;05;234m\".padEnd width, '—' )\n for context_line in await get_context path, linenr, colnr, width\n write_to_stderr arrowshaft, context_line\n alert '^77765-2^', reverse bold headline\n return null\n\n#-----------------------------------------------------------------------------------------------------------\n_exit_handler = ( error, origin ) ->\n ### TAINT origin never used ###\n type = error.code ? error.name ? 'EXCEPTION'\n message = \" #{type}: \" + ( error?.message ? \"an unrecoverable condition occurred\" )\n await show_error_with_source_context error, message\n return null\n\n#-----------------------------------------------------------------------------------------------------------\nexit_handler = ( error, origin ) ->\n await _exit_handler error, origin\n setImmediate ( -> process.exit 111 )\n return null\n\n\n\n############################################################################################################\nunless global[ Symbol.for 'cnd-exception-handler' ]?\n null\n global[ Symbol.for 'cnd-exception-handler' ] = true\n process.once 'uncaughtException', exit_handler\n process.once 'unhandledRejection', exit_handler\n\n\n############################################################################################################\nmodule.exports = { exit_handler, _exit_handler, }\n\n"
12
- ]
13
- }