neo-cmp-cli 1.8.7 → 1.8.8

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.
Files changed (124) hide show
  1. package/bin/index.js +2 -2
  2. package/dist/_virtual/_commonjsHelpers.js +12 -0
  3. package/dist/_virtual/array-set.js +7 -0
  4. package/dist/_virtual/base64-vlq.js +7 -0
  5. package/dist/_virtual/base64.js +7 -0
  6. package/dist/_virtual/binary-search.js +7 -0
  7. package/dist/_virtual/mapping-list.js +7 -0
  8. package/dist/_virtual/quick-sort.js +7 -0
  9. package/dist/_virtual/source-map-consumer.js +7 -0
  10. package/dist/_virtual/source-map-generator.js +7 -0
  11. package/dist/_virtual/source-map-support.js +7 -0
  12. package/dist/_virtual/source-map.js +7 -0
  13. package/dist/_virtual/source-node.js +7 -0
  14. package/dist/_virtual/typescript.js +7 -0
  15. package/dist/_virtual/util.js +7 -0
  16. package/dist/config/auth.config.js +43 -0
  17. package/dist/config/default.config.js +192 -0
  18. package/dist/config/index.js +26 -0
  19. package/dist/main.js +9 -0
  20. package/dist/main2.js +259 -0
  21. package/dist/module/inspect.js +63 -0
  22. package/dist/module/neoInit.js +75 -0
  23. package/dist/module/neoInitByCopy.js +83 -0
  24. package/dist/neo/neoLogin.js +590 -0
  25. package/dist/neo/neoRequire.js +123 -0
  26. package/dist/neo/neoService.js +898 -0
  27. package/dist/node_modules/buffer-from/index.js +86 -0
  28. package/dist/node_modules/source-map/lib/array-set.js +138 -0
  29. package/dist/node_modules/source-map/lib/base64-vlq.js +157 -0
  30. package/dist/node_modules/source-map/lib/base64.js +83 -0
  31. package/dist/node_modules/source-map/lib/binary-search.js +129 -0
  32. package/dist/node_modules/source-map/lib/mapping-list.js +96 -0
  33. package/dist/node_modules/source-map/lib/quick-sort.js +130 -0
  34. package/dist/node_modules/source-map/lib/source-map-consumer.js +1166 -0
  35. package/dist/node_modules/source-map/lib/source-map-generator.js +445 -0
  36. package/dist/node_modules/source-map/lib/source-node.js +431 -0
  37. package/dist/node_modules/source-map/lib/util.js +506 -0
  38. package/dist/node_modules/source-map/source-map.js +27 -0
  39. package/dist/node_modules/source-map-support/source-map-support.js +646 -0
  40. package/dist/node_modules/typescript/lib/typescript.js +174130 -0
  41. package/dist/oss/publish2oss.js +331 -0
  42. package/dist/plugins/AddNeoRequirePlugin.js +195 -0
  43. package/dist/utils/autoEntryRootDir.js +103 -0
  44. package/dist/utils/cmpUtils/createCmpByTemplate.js +82 -0
  45. package/dist/utils/cmpUtils/createCmpByZip.js +433 -0
  46. package/dist/utils/cmpUtils/createCommonModulesCode.js +139 -0
  47. package/dist/utils/cmpUtils/deleteCmp.js +81 -0
  48. package/dist/utils/cmpUtils/getCmpModelRegisterCode.js +47 -0
  49. package/dist/utils/cmpUtils/getCmpPreviewCode.js +60 -0
  50. package/dist/utils/cmpUtils/getCmpRegisterCode.js +47 -0
  51. package/dist/utils/cmpUtils/getCmpTypeByDir.js +59 -0
  52. package/dist/utils/cmpUtils/hasCmpTypeByDir.js +27 -0
  53. package/dist/utils/cmpUtils/previewCmp.js +75 -0
  54. package/dist/utils/cmpUtils/pullCmp.js +126 -0
  55. package/dist/utils/cmpUtils/pushCmp.js +254 -0
  56. package/dist/utils/common.js +125 -0
  57. package/dist/utils/configureNeoBuild.js +129 -0
  58. package/dist/utils/generateEntries.js +80 -0
  59. package/dist/utils/neoConfigInit.js +30 -0
  60. package/dist/utils/neoParams.js +26 -0
  61. package/dist/utils/pathUtils.js +40 -0
  62. package/dist/utils/projectNameValidator.js +90 -0
  63. package/dist/utils/projectUtils/createCmpProjectByTemplate.js +81 -0
  64. package/dist/utils/projectUtils/createCmpProjectZip.js +141 -0
  65. package/dist/utils/projectUtils/getEntries.js +99 -0
  66. package/dist/utils/projectUtils/getEntriesWithAutoRegister.js +129 -0
  67. package/dist/utils/projectUtils/hasNeoProject.js +34 -0
  68. package/dist/utils/projectUtils/openProject.js +117 -0
  69. package/dist/utils/projectUtils/updatePublishLog.js +47 -0
  70. package/dist/utils/replaceInFilesByMap.js +71 -0
  71. package/dist/utils/replaceInPackage.js +151 -0
  72. package/dist/utils/resetPackageVersion.js +132 -0
  73. package/package.json +6 -8
  74. package/test/demo.js +0 -2
  75. package/src/config/auth.config.js +0 -27
  76. package/src/config/default.config.js +0 -176
  77. package/src/config/index.js +0 -9
  78. package/src/initData/defaultTemplate.html +0 -13
  79. package/src/initData/neo.config.js +0 -138
  80. package/src/main.js +0 -221
  81. package/src/module/inspect.js +0 -41
  82. package/src/module/neoInit.js +0 -55
  83. package/src/module/neoInitByCopy.js +0 -61
  84. package/src/neo/NeoUMDContent.js +0 -30
  85. package/src/neo/neoLogin.js +0 -565
  86. package/src/neo/neoRequire.js +0 -125
  87. package/src/neo/neoService.js +0 -874
  88. package/src/neo/webpack.mf.js +0 -60
  89. package/src/neo/wrapperContent.js +0 -16
  90. package/src/oss/publish2oss.js +0 -348
  91. package/src/plugins/AddNeoRequirePlugin-v1.js +0 -47
  92. package/src/plugins/AddNeoRequirePlugin.js +0 -179
  93. package/src/plugins/README.md +0 -109
  94. package/src/utils/autoEntryRootDir.js +0 -85
  95. package/src/utils/cmpUtils/createCmpByTemplate.js +0 -60
  96. package/src/utils/cmpUtils/createCmpByZip.js +0 -408
  97. package/src/utils/cmpUtils/createCommonModulesCode.js +0 -121
  98. package/src/utils/cmpUtils/deleteCmp.js +0 -63
  99. package/src/utils/cmpUtils/getCmpModelRegisterCode.js +0 -31
  100. package/src/utils/cmpUtils/getCmpPreviewCode.js +0 -43
  101. package/src/utils/cmpUtils/getCmpRegisterCode.js +0 -31
  102. package/src/utils/cmpUtils/getCmpTypeByDir.js +0 -41
  103. package/src/utils/cmpUtils/hasCmpTypeByDir.js +0 -11
  104. package/src/utils/cmpUtils/previewCmp.js +0 -55
  105. package/src/utils/cmpUtils/pullCmp.js +0 -104
  106. package/src/utils/cmpUtils/pushCmp.js +0 -230
  107. package/src/utils/common.js +0 -107
  108. package/src/utils/configureNeoBuild.js +0 -109
  109. package/src/utils/generateEntries.js +0 -63
  110. package/src/utils/neoConfigInit.js +0 -13
  111. package/src/utils/neoParams.js +0 -12
  112. package/src/utils/pathUtils.js +0 -23
  113. package/src/utils/projectNameValidator.js +0 -76
  114. package/src/utils/projectUtils/createCmpProjectByTemplate.js +0 -59
  115. package/src/utils/projectUtils/createCmpProjectZip.js +0 -120
  116. package/src/utils/projectUtils/getEntries.js +0 -80
  117. package/src/utils/projectUtils/getEntriesWithAutoRegister.js +0 -108
  118. package/src/utils/projectUtils/hasNeoProject.js +0 -17
  119. package/src/utils/projectUtils/openProject.js +0 -96
  120. package/src/utils/projectUtils/updatePublishLog.js +0 -30
  121. package/src/utils/replaceInFiles.js +0 -47
  122. package/src/utils/replaceInFilesByMap.js +0 -54
  123. package/src/utils/replaceInPackage.js +0 -134
  124. package/src/utils/resetPackageVersion.js +0 -115
@@ -0,0 +1,646 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const sourceMapSupport = require('../../_virtual/source-map-support.js');
6
+ const sourceMap = require('../source-map/source-map.js');
7
+ const require$$1 = require('node:path');
8
+ const index = require('../buffer-from/index.js');
9
+
10
+ sourceMapSupport.__module.exports;
11
+
12
+ var hasRequiredSourceMapSupport;
13
+
14
+ function requireSourceMapSupport () {
15
+ if (hasRequiredSourceMapSupport) return sourceMapSupport.__module.exports;
16
+ hasRequiredSourceMapSupport = 1;
17
+ (function (module, exports$1) {
18
+ var SourceMapConsumer = sourceMap.__require().SourceMapConsumer;
19
+ var path = require$$1;
20
+
21
+ var fs;
22
+ try {
23
+ fs = require('fs');
24
+ if (!fs.existsSync || !fs.readFileSync) {
25
+ // fs doesn't have all methods we need
26
+ fs = null;
27
+ }
28
+ } catch (err) {
29
+ /* nop */
30
+ }
31
+
32
+ var bufferFrom = index.__require();
33
+
34
+ /**
35
+ * Requires a module which is protected against bundler minification.
36
+ *
37
+ * @param {NodeModule} mod
38
+ * @param {string} request
39
+ */
40
+ function dynamicRequire(mod, request) {
41
+ return mod.require(request);
42
+ }
43
+
44
+ // Only install once if called multiple times
45
+ var errorFormatterInstalled = false;
46
+ var uncaughtShimInstalled = false;
47
+
48
+ // If true, the caches are reset before a stack trace formatting operation
49
+ var emptyCacheBetweenOperations = false;
50
+
51
+ // Supports {browser, node, auto}
52
+ var environment = "auto";
53
+
54
+ // Maps a file path to a string containing the file contents
55
+ var fileContentsCache = {};
56
+
57
+ // Maps a file path to a source map for that file
58
+ var sourceMapCache = {};
59
+
60
+ // Regex for detecting source maps
61
+ var reSourceMap = /^data:application\/json[^,]+base64,/;
62
+
63
+ // Priority list of retrieve handlers
64
+ var retrieveFileHandlers = [];
65
+ var retrieveMapHandlers = [];
66
+
67
+ function isInBrowser() {
68
+ if (environment === "browser")
69
+ return true;
70
+ if (environment === "node")
71
+ return false;
72
+ return ((typeof window !== 'undefined') && (typeof XMLHttpRequest === 'function') && !(window.require && window.module && window.process && window.process.type === "renderer"));
73
+ }
74
+
75
+ function hasGlobalProcessEventEmitter() {
76
+ return ((typeof process === 'object') && (process !== null) && (typeof process.on === 'function'));
77
+ }
78
+
79
+ function globalProcessVersion() {
80
+ if ((typeof process === 'object') && (process !== null)) {
81
+ return process.version;
82
+ } else {
83
+ return '';
84
+ }
85
+ }
86
+
87
+ function globalProcessStderr() {
88
+ if ((typeof process === 'object') && (process !== null)) {
89
+ return process.stderr;
90
+ }
91
+ }
92
+
93
+ function globalProcessExit(code) {
94
+ if ((typeof process === 'object') && (process !== null) && (typeof process.exit === 'function')) {
95
+ return process.exit(code);
96
+ }
97
+ }
98
+
99
+ function handlerExec(list) {
100
+ return function(arg) {
101
+ for (var i = 0; i < list.length; i++) {
102
+ var ret = list[i](arg);
103
+ if (ret) {
104
+ return ret;
105
+ }
106
+ }
107
+ return null;
108
+ };
109
+ }
110
+
111
+ var retrieveFile = handlerExec(retrieveFileHandlers);
112
+
113
+ retrieveFileHandlers.push(function(path) {
114
+ // Trim the path to make sure there is no extra whitespace.
115
+ path = path.trim();
116
+ if (/^file:/.test(path)) {
117
+ // existsSync/readFileSync can't handle file protocol, but once stripped, it works
118
+ path = path.replace(/file:\/\/\/(\w:)?/, function(protocol, drive) {
119
+ return drive ?
120
+ '' : // file:///C:/dir/file -> C:/dir/file
121
+ '/'; // file:///root-dir/file -> /root-dir/file
122
+ });
123
+ }
124
+ if (path in fileContentsCache) {
125
+ return fileContentsCache[path];
126
+ }
127
+
128
+ var contents = '';
129
+ try {
130
+ if (!fs) {
131
+ // Use SJAX if we are in the browser
132
+ var xhr = new XMLHttpRequest();
133
+ xhr.open('GET', path, /** async */ false);
134
+ xhr.send(null);
135
+ if (xhr.readyState === 4 && xhr.status === 200) {
136
+ contents = xhr.responseText;
137
+ }
138
+ } else if (fs.existsSync(path)) {
139
+ // Otherwise, use the filesystem
140
+ contents = fs.readFileSync(path, 'utf8');
141
+ }
142
+ } catch (er) {
143
+ /* ignore any errors */
144
+ }
145
+
146
+ return fileContentsCache[path] = contents;
147
+ });
148
+
149
+ // Support URLs relative to a directory, but be careful about a protocol prefix
150
+ // in case we are in the browser (i.e. directories may start with "http://" or "file:///")
151
+ function supportRelativeURL(file, url) {
152
+ if (!file) return url;
153
+ var dir = path.dirname(file);
154
+ var match = /^\w+:\/\/[^\/]*/.exec(dir);
155
+ var protocol = match ? match[0] : '';
156
+ var startPath = dir.slice(protocol.length);
157
+ if (protocol && /^\/\w\:/.test(startPath)) {
158
+ // handle file:///C:/ paths
159
+ protocol += '/';
160
+ return protocol + path.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/');
161
+ }
162
+ return protocol + path.resolve(dir.slice(protocol.length), url);
163
+ }
164
+
165
+ function retrieveSourceMapURL(source) {
166
+ var fileData;
167
+
168
+ if (isInBrowser()) {
169
+ try {
170
+ var xhr = new XMLHttpRequest();
171
+ xhr.open('GET', source, false);
172
+ xhr.send(null);
173
+ fileData = xhr.readyState === 4 ? xhr.responseText : null;
174
+
175
+ // Support providing a sourceMappingURL via the SourceMap header
176
+ var sourceMapHeader = xhr.getResponseHeader("SourceMap") ||
177
+ xhr.getResponseHeader("X-SourceMap");
178
+ if (sourceMapHeader) {
179
+ return sourceMapHeader;
180
+ }
181
+ } catch (e) {
182
+ }
183
+ }
184
+
185
+ // Get the URL of the source map
186
+ fileData = retrieveFile(source);
187
+ var re = /(?:\/\/[@#][\s]*sourceMappingURL=([^\s'"]+)[\s]*$)|(?:\/\*[@#][\s]*sourceMappingURL=([^\s*'"]+)[\s]*(?:\*\/)[\s]*$)/mg;
188
+ // Keep executing the search to find the *last* sourceMappingURL to avoid
189
+ // picking up sourceMappingURLs from comments, strings, etc.
190
+ var lastMatch, match;
191
+ while (match = re.exec(fileData)) lastMatch = match;
192
+ if (!lastMatch) return null;
193
+ return lastMatch[1];
194
+ }
195
+ // Can be overridden by the retrieveSourceMap option to install. Takes a
196
+ // generated source filename; returns a {map, optional url} object, or null if
197
+ // there is no source map. The map field may be either a string or the parsed
198
+ // JSON object (ie, it must be a valid argument to the SourceMapConsumer
199
+ // constructor).
200
+ var retrieveSourceMap = handlerExec(retrieveMapHandlers);
201
+ retrieveMapHandlers.push(function(source) {
202
+ var sourceMappingURL = retrieveSourceMapURL(source);
203
+ if (!sourceMappingURL) return null;
204
+
205
+ // Read the contents of the source map
206
+ var sourceMapData;
207
+ if (reSourceMap.test(sourceMappingURL)) {
208
+ // Support source map URL as a data url
209
+ var rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(',') + 1);
210
+ sourceMapData = bufferFrom(rawData, "base64").toString();
211
+ sourceMappingURL = source;
212
+ } else {
213
+ // Support source map URLs relative to the source URL
214
+ sourceMappingURL = supportRelativeURL(source, sourceMappingURL);
215
+ sourceMapData = retrieveFile(sourceMappingURL);
216
+ }
217
+
218
+ if (!sourceMapData) {
219
+ return null;
220
+ }
221
+
222
+ return {
223
+ url: sourceMappingURL,
224
+ map: sourceMapData
225
+ };
226
+ });
227
+
228
+ function mapSourcePosition(position) {
229
+ var sourceMap = sourceMapCache[position.source];
230
+ if (!sourceMap) {
231
+ // Call the (overrideable) retrieveSourceMap function to get the source map.
232
+ var urlAndMap = retrieveSourceMap(position.source);
233
+ if (urlAndMap) {
234
+ sourceMap = sourceMapCache[position.source] = {
235
+ url: urlAndMap.url,
236
+ map: new SourceMapConsumer(urlAndMap.map)
237
+ };
238
+
239
+ // Load all sources stored inline with the source map into the file cache
240
+ // to pretend like they are already loaded. They may not exist on disk.
241
+ if (sourceMap.map.sourcesContent) {
242
+ sourceMap.map.sources.forEach(function(source, i) {
243
+ var contents = sourceMap.map.sourcesContent[i];
244
+ if (contents) {
245
+ var url = supportRelativeURL(sourceMap.url, source);
246
+ fileContentsCache[url] = contents;
247
+ }
248
+ });
249
+ }
250
+ } else {
251
+ sourceMap = sourceMapCache[position.source] = {
252
+ url: null,
253
+ map: null
254
+ };
255
+ }
256
+ }
257
+
258
+ // Resolve the source URL relative to the URL of the source map
259
+ if (sourceMap && sourceMap.map && typeof sourceMap.map.originalPositionFor === 'function') {
260
+ var originalPosition = sourceMap.map.originalPositionFor(position);
261
+
262
+ // Only return the original position if a matching line was found. If no
263
+ // matching line is found then we return position instead, which will cause
264
+ // the stack trace to print the path and line for the compiled file. It is
265
+ // better to give a precise location in the compiled file than a vague
266
+ // location in the original file.
267
+ if (originalPosition.source !== null) {
268
+ originalPosition.source = supportRelativeURL(
269
+ sourceMap.url, originalPosition.source);
270
+ return originalPosition;
271
+ }
272
+ }
273
+
274
+ return position;
275
+ }
276
+
277
+ // Parses code generated by FormatEvalOrigin(), a function inside V8:
278
+ // https://code.google.com/p/v8/source/browse/trunk/src/messages.js
279
+ function mapEvalOrigin(origin) {
280
+ // Most eval() calls are in this format
281
+ var match = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(origin);
282
+ if (match) {
283
+ var position = mapSourcePosition({
284
+ source: match[2],
285
+ line: +match[3],
286
+ column: match[4] - 1
287
+ });
288
+ return 'eval at ' + match[1] + ' (' + position.source + ':' +
289
+ position.line + ':' + (position.column + 1) + ')';
290
+ }
291
+
292
+ // Parse nested eval() calls using recursion
293
+ match = /^eval at ([^(]+) \((.+)\)$/.exec(origin);
294
+ if (match) {
295
+ return 'eval at ' + match[1] + ' (' + mapEvalOrigin(match[2]) + ')';
296
+ }
297
+
298
+ // Make sure we still return useful information if we didn't find anything
299
+ return origin;
300
+ }
301
+
302
+ // This is copied almost verbatim from the V8 source code at
303
+ // https://code.google.com/p/v8/source/browse/trunk/src/messages.js. The
304
+ // implementation of wrapCallSite() used to just forward to the actual source
305
+ // code of CallSite.prototype.toString but unfortunately a new release of V8
306
+ // did something to the prototype chain and broke the shim. The only fix I
307
+ // could find was copy/paste.
308
+ function CallSiteToString() {
309
+ var fileName;
310
+ var fileLocation = "";
311
+ if (this.isNative()) {
312
+ fileLocation = "native";
313
+ } else {
314
+ fileName = this.getScriptNameOrSourceURL();
315
+ if (!fileName && this.isEval()) {
316
+ fileLocation = this.getEvalOrigin();
317
+ fileLocation += ", "; // Expecting source position to follow.
318
+ }
319
+
320
+ if (fileName) {
321
+ fileLocation += fileName;
322
+ } else {
323
+ // Source code does not originate from a file and is not native, but we
324
+ // can still get the source position inside the source string, e.g. in
325
+ // an eval string.
326
+ fileLocation += "<anonymous>";
327
+ }
328
+ var lineNumber = this.getLineNumber();
329
+ if (lineNumber != null) {
330
+ fileLocation += ":" + lineNumber;
331
+ var columnNumber = this.getColumnNumber();
332
+ if (columnNumber) {
333
+ fileLocation += ":" + columnNumber;
334
+ }
335
+ }
336
+ }
337
+
338
+ var line = "";
339
+ var functionName = this.getFunctionName();
340
+ var addSuffix = true;
341
+ var isConstructor = this.isConstructor();
342
+ var isMethodCall = !(this.isToplevel() || isConstructor);
343
+ if (isMethodCall) {
344
+ var typeName = this.getTypeName();
345
+ // Fixes shim to be backward compatable with Node v0 to v4
346
+ if (typeName === "[object Object]") {
347
+ typeName = "null";
348
+ }
349
+ var methodName = this.getMethodName();
350
+ if (functionName) {
351
+ if (typeName && functionName.indexOf(typeName) != 0) {
352
+ line += typeName + ".";
353
+ }
354
+ line += functionName;
355
+ if (methodName && functionName.indexOf("." + methodName) != functionName.length - methodName.length - 1) {
356
+ line += " [as " + methodName + "]";
357
+ }
358
+ } else {
359
+ line += typeName + "." + (methodName || "<anonymous>");
360
+ }
361
+ } else if (isConstructor) {
362
+ line += "new " + (functionName || "<anonymous>");
363
+ } else if (functionName) {
364
+ line += functionName;
365
+ } else {
366
+ line += fileLocation;
367
+ addSuffix = false;
368
+ }
369
+ if (addSuffix) {
370
+ line += " (" + fileLocation + ")";
371
+ }
372
+ return line;
373
+ }
374
+
375
+ function cloneCallSite(frame) {
376
+ var object = {};
377
+ Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach(function(name) {
378
+ object[name] = /^(?:is|get)/.test(name) ? function() { return frame[name].call(frame); } : frame[name];
379
+ });
380
+ object.toString = CallSiteToString;
381
+ return object;
382
+ }
383
+
384
+ function wrapCallSite(frame, state) {
385
+ // provides interface backward compatibility
386
+ if (state === undefined) {
387
+ state = { nextPosition: null, curPosition: null };
388
+ }
389
+ if(frame.isNative()) {
390
+ state.curPosition = null;
391
+ return frame;
392
+ }
393
+
394
+ // Most call sites will return the source file from getFileName(), but code
395
+ // passed to eval() ending in "//# sourceURL=..." will return the source file
396
+ // from getScriptNameOrSourceURL() instead
397
+ var source = frame.getFileName() || frame.getScriptNameOrSourceURL();
398
+ if (source) {
399
+ var line = frame.getLineNumber();
400
+ var column = frame.getColumnNumber() - 1;
401
+
402
+ // Fix position in Node where some (internal) code is prepended.
403
+ // See https://github.com/evanw/node-source-map-support/issues/36
404
+ // Header removed in node at ^10.16 || >=11.11.0
405
+ // v11 is not an LTS candidate, we can just test the one version with it.
406
+ // Test node versions for: 10.16-19, 10.20+, 12-19, 20-99, 100+, or 11.11
407
+ var noHeader = /^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;
408
+ var headerLength = noHeader.test(globalProcessVersion()) ? 0 : 62;
409
+ if (line === 1 && column > headerLength && !isInBrowser() && !frame.isEval()) {
410
+ column -= headerLength;
411
+ }
412
+
413
+ var position = mapSourcePosition({
414
+ source: source,
415
+ line: line,
416
+ column: column
417
+ });
418
+ state.curPosition = position;
419
+ frame = cloneCallSite(frame);
420
+ var originalFunctionName = frame.getFunctionName;
421
+ frame.getFunctionName = function() {
422
+ if (state.nextPosition == null) {
423
+ return originalFunctionName();
424
+ }
425
+ return state.nextPosition.name || originalFunctionName();
426
+ };
427
+ frame.getFileName = function() { return position.source; };
428
+ frame.getLineNumber = function() { return position.line; };
429
+ frame.getColumnNumber = function() { return position.column + 1; };
430
+ frame.getScriptNameOrSourceURL = function() { return position.source; };
431
+ return frame;
432
+ }
433
+
434
+ // Code called using eval() needs special handling
435
+ var origin = frame.isEval() && frame.getEvalOrigin();
436
+ if (origin) {
437
+ origin = mapEvalOrigin(origin);
438
+ frame = cloneCallSite(frame);
439
+ frame.getEvalOrigin = function() { return origin; };
440
+ return frame;
441
+ }
442
+
443
+ // If we get here then we were unable to change the source position
444
+ return frame;
445
+ }
446
+
447
+ // This function is part of the V8 stack trace API, for more info see:
448
+ // https://v8.dev/docs/stack-trace-api
449
+ function prepareStackTrace(error, stack) {
450
+ if (emptyCacheBetweenOperations) {
451
+ fileContentsCache = {};
452
+ sourceMapCache = {};
453
+ }
454
+
455
+ var name = error.name || 'Error';
456
+ var message = error.message || '';
457
+ var errorString = name + ": " + message;
458
+
459
+ var state = { nextPosition: null, curPosition: null };
460
+ var processedStack = [];
461
+ for (var i = stack.length - 1; i >= 0; i--) {
462
+ processedStack.push('\n at ' + wrapCallSite(stack[i], state));
463
+ state.nextPosition = state.curPosition;
464
+ }
465
+ state.curPosition = state.nextPosition = null;
466
+ return errorString + processedStack.reverse().join('');
467
+ }
468
+
469
+ // Generate position and snippet of original source with pointer
470
+ function getErrorSource(error) {
471
+ var match = /\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(error.stack);
472
+ if (match) {
473
+ var source = match[1];
474
+ var line = +match[2];
475
+ var column = +match[3];
476
+
477
+ // Support the inline sourceContents inside the source map
478
+ var contents = fileContentsCache[source];
479
+
480
+ // Support files on disk
481
+ if (!contents && fs && fs.existsSync(source)) {
482
+ try {
483
+ contents = fs.readFileSync(source, 'utf8');
484
+ } catch (er) {
485
+ contents = '';
486
+ }
487
+ }
488
+
489
+ // Format the line from the original source code like node does
490
+ if (contents) {
491
+ var code = contents.split(/(?:\r\n|\r|\n)/)[line - 1];
492
+ if (code) {
493
+ return source + ':' + line + '\n' + code + '\n' +
494
+ new Array(column).join(' ') + '^';
495
+ }
496
+ }
497
+ }
498
+ return null;
499
+ }
500
+
501
+ function printErrorAndExit (error) {
502
+ var source = getErrorSource(error);
503
+
504
+ // Ensure error is printed synchronously and not truncated
505
+ var stderr = globalProcessStderr();
506
+ if (stderr && stderr._handle && stderr._handle.setBlocking) {
507
+ stderr._handle.setBlocking(true);
508
+ }
509
+
510
+ if (source) {
511
+ console.error();
512
+ console.error(source);
513
+ }
514
+
515
+ console.error(error.stack);
516
+ globalProcessExit(1);
517
+ }
518
+
519
+ function shimEmitUncaughtException () {
520
+ var origEmit = process.emit;
521
+
522
+ process.emit = function (type) {
523
+ if (type === 'uncaughtException') {
524
+ var hasStack = (arguments[1] && arguments[1].stack);
525
+ var hasListeners = (this.listeners(type).length > 0);
526
+
527
+ if (hasStack && !hasListeners) {
528
+ return printErrorAndExit(arguments[1]);
529
+ }
530
+ }
531
+
532
+ return origEmit.apply(this, arguments);
533
+ };
534
+ }
535
+
536
+ var originalRetrieveFileHandlers = retrieveFileHandlers.slice(0);
537
+ var originalRetrieveMapHandlers = retrieveMapHandlers.slice(0);
538
+
539
+ exports$1.wrapCallSite = wrapCallSite;
540
+ exports$1.getErrorSource = getErrorSource;
541
+ exports$1.mapSourcePosition = mapSourcePosition;
542
+ exports$1.retrieveSourceMap = retrieveSourceMap;
543
+
544
+ exports$1.install = function(options) {
545
+ options = options || {};
546
+
547
+ if (options.environment) {
548
+ environment = options.environment;
549
+ if (["node", "browser", "auto"].indexOf(environment) === -1) {
550
+ throw new Error("environment " + environment + " was unknown. Available options are {auto, browser, node}")
551
+ }
552
+ }
553
+
554
+ // Allow sources to be found by methods other than reading the files
555
+ // directly from disk.
556
+ if (options.retrieveFile) {
557
+ if (options.overrideRetrieveFile) {
558
+ retrieveFileHandlers.length = 0;
559
+ }
560
+
561
+ retrieveFileHandlers.unshift(options.retrieveFile);
562
+ }
563
+
564
+ // Allow source maps to be found by methods other than reading the files
565
+ // directly from disk.
566
+ if (options.retrieveSourceMap) {
567
+ if (options.overrideRetrieveSourceMap) {
568
+ retrieveMapHandlers.length = 0;
569
+ }
570
+
571
+ retrieveMapHandlers.unshift(options.retrieveSourceMap);
572
+ }
573
+
574
+ // Support runtime transpilers that include inline source maps
575
+ if (options.hookRequire && !isInBrowser()) {
576
+ // Use dynamicRequire to avoid including in browser bundles
577
+ var Module = dynamicRequire(module, 'module');
578
+ var $compile = Module.prototype._compile;
579
+
580
+ if (!$compile.__sourceMapSupport) {
581
+ Module.prototype._compile = function(content, filename) {
582
+ fileContentsCache[filename] = content;
583
+ sourceMapCache[filename] = undefined;
584
+ return $compile.call(this, content, filename);
585
+ };
586
+
587
+ Module.prototype._compile.__sourceMapSupport = true;
588
+ }
589
+ }
590
+
591
+ // Configure options
592
+ if (!emptyCacheBetweenOperations) {
593
+ emptyCacheBetweenOperations = 'emptyCacheBetweenOperations' in options ?
594
+ options.emptyCacheBetweenOperations : false;
595
+ }
596
+
597
+ // Install the error reformatter
598
+ if (!errorFormatterInstalled) {
599
+ errorFormatterInstalled = true;
600
+ Error.prepareStackTrace = prepareStackTrace;
601
+ }
602
+
603
+ if (!uncaughtShimInstalled) {
604
+ var installHandler = 'handleUncaughtExceptions' in options ?
605
+ options.handleUncaughtExceptions : true;
606
+
607
+ // Do not override 'uncaughtException' with our own handler in Node.js
608
+ // Worker threads. Workers pass the error to the main thread as an event,
609
+ // rather than printing something to stderr and exiting.
610
+ try {
611
+ // We need to use `dynamicRequire` because `require` on it's own will be optimized by WebPack/Browserify.
612
+ var worker_threads = dynamicRequire(module, 'worker_threads');
613
+ if (worker_threads.isMainThread === false) {
614
+ installHandler = false;
615
+ }
616
+ } catch(e) {}
617
+
618
+ // Provide the option to not install the uncaught exception handler. This is
619
+ // to support other uncaught exception handlers (in test frameworks, for
620
+ // example). If this handler is not installed and there are no other uncaught
621
+ // exception handlers, uncaught exceptions will be caught by node's built-in
622
+ // exception handler and the process will still be terminated. However, the
623
+ // generated JavaScript code will be shown above the stack trace instead of
624
+ // the original source code.
625
+ if (installHandler && hasGlobalProcessEventEmitter()) {
626
+ uncaughtShimInstalled = true;
627
+ shimEmitUncaughtException();
628
+ }
629
+ }
630
+ };
631
+
632
+ exports$1.resetRetrieveHandlers = function() {
633
+ retrieveFileHandlers.length = 0;
634
+ retrieveMapHandlers.length = 0;
635
+
636
+ retrieveFileHandlers = originalRetrieveFileHandlers.slice(0);
637
+ retrieveMapHandlers = originalRetrieveMapHandlers.slice(0);
638
+
639
+ retrieveSourceMap = handlerExec(retrieveMapHandlers);
640
+ retrieveFile = handlerExec(retrieveFileHandlers);
641
+ };
642
+ } (sourceMapSupport.__module, sourceMapSupport.__module.exports));
643
+ return sourceMapSupport.__module.exports;
644
+ }
645
+
646
+ exports.__require = requireSourceMapSupport;