neo-cmp-cli 1.8.6-beta.6 → 1.8.7

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