@dcloudio/uni-stacktracey 3.0.0-alpha-3050020220623003 → 3.0.0-alpha-3050020220623004

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.
@@ -20,7 +20,7 @@ typeof window !== 'undefined' &&
20
20
  lastOf = (x) => x[x.length - 1], nixSlashes$1 = (x) => x.replace(/\\/g, '/'), pathRoot = isBrowser ? window.location.href : nixSlashes$1(process.cwd()) + '/';
21
21
  /* ------------------------------------------------------------------------ */
22
22
  class StackTracey {
23
- constructor(input, offset) {
23
+ constructor(input, uniPlatform, offset) {
24
24
  this.itemsHeader = [];
25
25
  this.isMP = false;
26
26
  const originalInput = input, isParseableSyntaxError = input && input instanceof SyntaxError && !isBrowser;
@@ -35,7 +35,7 @@ class StackTracey {
35
35
  }
36
36
  /* new StackTracey (string) */
37
37
  if (typeof input === 'string') {
38
- this.isMP = input.indexOf('MiniProgramError') !== -1;
38
+ this.isMP = uniPlatform === 'mp-weixin';
39
39
  input = this.rawParse(input)
40
40
  .slice(offset)
41
41
  .map((x) => this.extractEntryMetadata(x));
@@ -86,7 +86,7 @@ class StackTracey {
86
86
  let result = fullPath;
87
87
  if (isBrowser)
88
88
  result = result.replace(pathRoot, '');
89
- const externalDomainMatch = result.match(/^(http|https)\:\/\/?([^\/]+)\/(.*)/);
89
+ const externalDomainMatch = result.match(/^(http|https)\:\/\/?([^\/]+)\/{1,}(.*)/);
90
90
  const externalDomain = externalDomainMatch
91
91
  ? externalDomainMatch[2]
92
92
  : undefined;
@@ -103,8 +103,10 @@ class StackTracey {
103
103
  return false;
104
104
  return externalDomain !== 'usr';
105
105
  }
106
- return (externalDomain ||
107
- relativePath[0] === '~' || // webpack-specific heuristic
106
+ return (
107
+ // 由于 hello-uniapp web 端报错携带 hellouniapp.dcloud.net.cn
108
+ // externalDomain ||
109
+ relativePath[0] === '~' || // webpack-specific heuristic
108
110
  relativePath[0] === '/' || // external source
109
111
  relativePath.indexOf('@dcloudio') !== -1 ||
110
112
  relativePath.indexOf('webpack/bootstrap') === 0);
@@ -200,8 +202,8 @@ var StackTracey$1 = StackTracey;
200
202
  const nixSlashes = (x) => x.replace(/\\/g, '/');
201
203
  const sourcemapCatch = {};
202
204
  function stacktracey(stacktrace, opts) {
203
- const parseStack = [];
204
205
  const stack = opts.preset.parseStacktrace(stacktrace);
206
+ let parseStack = Promise.resolve();
205
207
  stack.items.forEach((item, index) => {
206
208
  const fn = (item, index) => {
207
209
  const { line = 0, column = 0, file, fileName, fileRelative } = item;
@@ -252,10 +254,16 @@ function stacktracey(stacktrace, opts) {
252
254
  return Promise.resolve();
253
255
  }
254
256
  };
255
- parseStack.push(fn(item, index));
257
+ parseStack = parseStack.then(() => {
258
+ return new Promise((resolve, reject) => {
259
+ setTimeout(() => {
260
+ fn(item, index).then(resolve);
261
+ }, 0);
262
+ });
263
+ });
256
264
  });
257
- return new Promise((resolve, reject) => {
258
- Promise.all(parseStack)
265
+ const _promise = new Promise((resolve, reject) => {
266
+ parseStack
259
267
  .then(() => {
260
268
  const parseError = opts.preset.asTableStacktrace({
261
269
  stack,
@@ -272,20 +280,27 @@ function stacktracey(stacktrace, opts) {
272
280
  resolve(stacktrace);
273
281
  });
274
282
  });
283
+ return _promise;
275
284
  }
276
285
  function isThirdParty(relativePath) {
277
286
  return relativePath.indexOf('@dcloudio') !== -1;
278
287
  }
279
288
  function getConsumer(content) {
280
289
  return new Promise((resolve, reject) => {
281
- if (sourceMap.SourceMapConsumer.with) {
282
- sourceMap.SourceMapConsumer.with(content, null, (consumer) => {
290
+ try {
291
+ if (sourceMap.SourceMapConsumer.with) {
292
+ sourceMap.SourceMapConsumer.with(content, null, (consumer) => {
293
+ resolve(consumer);
294
+ });
295
+ }
296
+ else {
297
+ // @ts-ignore
298
+ const consumer = sourceMap.SourceMapConsumer(content);
283
299
  resolve(consumer);
284
- });
300
+ }
285
301
  }
286
- else {
287
- // @ts-ignore
288
- resolve(sourceMap.SourceMapConsumer(content));
302
+ catch (error) {
303
+ reject();
289
304
  }
290
305
  });
291
306
  }
@@ -298,8 +313,16 @@ function getSourceMapContent(sourcemapUrl) {
298
313
  uni.request({
299
314
  url: sourcemapUrl,
300
315
  success: (res) => {
301
- sourcemapCatch[sourcemapUrl] = res.data;
302
- resolve(sourcemapCatch[sourcemapUrl]);
316
+ if (res.statusCode === 200) {
317
+ sourcemapCatch[sourcemapUrl] = res.data;
318
+ resolve(sourcemapCatch[sourcemapUrl]);
319
+ }
320
+ else {
321
+ resolve((sourcemapCatch[sourcemapUrl] = ''));
322
+ }
323
+ },
324
+ fail() {
325
+ resolve((sourcemapCatch[sourcemapUrl] = ''));
303
326
  },
304
327
  });
305
328
  }
@@ -340,7 +363,7 @@ function joinItem(item) {
340
363
  return `${a}${b}${c}`;
341
364
  }
342
365
  function uniStracktraceyPreset(opts) {
343
- const { base, sourceRoot, splitThirdParty } = opts;
366
+ const { base, sourceRoot, splitThirdParty, uniPlatform } = opts;
344
367
  let stack;
345
368
  return {
346
369
  /**
@@ -363,7 +386,7 @@ function uniStracktraceyPreset(opts) {
363
386
  let baseAfter = '';
364
387
  if (stack.isMP) {
365
388
  if (fileRelative.indexOf('app-service.js') !== -1) {
366
- baseAfter = (base.match(/\w$/) ? '/' : '') + 'weixin';
389
+ baseAfter = (base.match(/\w$/) ? '/' : '') + '__WEIXIN__';
367
390
  if (fileRelative === fileName) {
368
391
  baseAfter += '/__APP__';
369
392
  }
@@ -382,7 +405,7 @@ function uniStracktraceyPreset(opts) {
382
405
  return Promise.resolve(getSourceMapContent(sourcemapUrl));
383
406
  },
384
407
  parseStacktrace(stacktrace) {
385
- stack = new StackTracey$1(stacktrace);
408
+ stack = new StackTracey$1(stacktrace, uniPlatform);
386
409
  return stack;
387
410
  },
388
411
  asTableStacktrace({ maxColumnWidths, stacktrace, stack }) {
@@ -414,6 +437,12 @@ function uniStracktraceyPreset(opts) {
414
437
  return userError + '\n' + thirdParty;
415
438
  }
416
439
  else {
440
+ if (splitThirdParty) {
441
+ return {
442
+ userError: errorName,
443
+ thirdParty: '',
444
+ };
445
+ }
417
446
  return errorName;
418
447
  }
419
448
  },
@@ -12,7 +12,7 @@ typeof window !== 'undefined' &&
12
12
  lastOf = (x) => x[x.length - 1], nixSlashes$1 = (x) => x.replace(/\\/g, '/'), pathRoot = isBrowser ? window.location.href : nixSlashes$1(process.cwd()) + '/';
13
13
  /* ------------------------------------------------------------------------ */
14
14
  class StackTracey {
15
- constructor(input, offset) {
15
+ constructor(input, uniPlatform, offset) {
16
16
  this.itemsHeader = [];
17
17
  this.isMP = false;
18
18
  const originalInput = input, isParseableSyntaxError = input && input instanceof SyntaxError && !isBrowser;
@@ -27,7 +27,7 @@ class StackTracey {
27
27
  }
28
28
  /* new StackTracey (string) */
29
29
  if (typeof input === 'string') {
30
- this.isMP = input.indexOf('MiniProgramError') !== -1;
30
+ this.isMP = uniPlatform === 'mp-weixin';
31
31
  input = this.rawParse(input)
32
32
  .slice(offset)
33
33
  .map((x) => this.extractEntryMetadata(x));
@@ -78,7 +78,7 @@ class StackTracey {
78
78
  let result = fullPath;
79
79
  if (isBrowser)
80
80
  result = result.replace(pathRoot, '');
81
- const externalDomainMatch = result.match(/^(http|https)\:\/\/?([^\/]+)\/(.*)/);
81
+ const externalDomainMatch = result.match(/^(http|https)\:\/\/?([^\/]+)\/{1,}(.*)/);
82
82
  const externalDomain = externalDomainMatch
83
83
  ? externalDomainMatch[2]
84
84
  : undefined;
@@ -95,8 +95,10 @@ class StackTracey {
95
95
  return false;
96
96
  return externalDomain !== 'usr';
97
97
  }
98
- return (externalDomain ||
99
- relativePath[0] === '~' || // webpack-specific heuristic
98
+ return (
99
+ // 由于 hello-uniapp web 端报错携带 hellouniapp.dcloud.net.cn
100
+ // externalDomain ||
101
+ relativePath[0] === '~' || // webpack-specific heuristic
100
102
  relativePath[0] === '/' || // external source
101
103
  relativePath.indexOf('@dcloudio') !== -1 ||
102
104
  relativePath.indexOf('webpack/bootstrap') === 0);
@@ -202,8 +204,8 @@ var StackTracey$1 = StackTracey;
202
204
  const nixSlashes = (x) => x.replace(/\\/g, '/');
203
205
  const sourcemapCatch = {};
204
206
  function stacktracey(stacktrace, opts) {
205
- const parseStack = [];
206
207
  const stack = opts.preset.parseStacktrace(stacktrace);
208
+ let parseStack = Promise.resolve();
207
209
  stack.items.forEach((item, index) => {
208
210
  const fn = (item, index) => {
209
211
  const { line = 0, column = 0, file, fileName, fileRelative } = item;
@@ -254,10 +256,16 @@ function stacktracey(stacktrace, opts) {
254
256
  return Promise.resolve();
255
257
  }
256
258
  };
257
- parseStack.push(fn(item, index));
259
+ parseStack = parseStack.then(() => {
260
+ return new Promise((resolve, reject) => {
261
+ setTimeout(() => {
262
+ fn(item, index).then(resolve);
263
+ }, 0);
264
+ });
265
+ });
258
266
  });
259
- return new Promise((resolve, reject) => {
260
- Promise.all(parseStack)
267
+ const _promise = new Promise((resolve, reject) => {
268
+ parseStack
261
269
  .then(() => {
262
270
  const parseError = opts.preset.asTableStacktrace({
263
271
  stack,
@@ -274,20 +282,27 @@ function stacktracey(stacktrace, opts) {
274
282
  resolve(stacktrace);
275
283
  });
276
284
  });
285
+ return _promise;
277
286
  }
278
287
  function isThirdParty(relativePath) {
279
288
  return relativePath.indexOf('@dcloudio') !== -1;
280
289
  }
281
290
  function getConsumer(content) {
282
291
  return new Promise((resolve, reject) => {
283
- if (SourceMapConsumer.with) {
284
- SourceMapConsumer.with(content, null, (consumer) => {
292
+ try {
293
+ if (SourceMapConsumer.with) {
294
+ SourceMapConsumer.with(content, null, (consumer) => {
295
+ resolve(consumer);
296
+ });
297
+ }
298
+ else {
299
+ // @ts-ignore
300
+ const consumer = SourceMapConsumer(content);
285
301
  resolve(consumer);
286
- });
302
+ }
287
303
  }
288
- else {
289
- // @ts-ignore
290
- resolve(SourceMapConsumer(content));
304
+ catch (error) {
305
+ reject();
291
306
  }
292
307
  });
293
308
  }
@@ -300,8 +315,16 @@ function getSourceMapContent(sourcemapUrl) {
300
315
  uni.request({
301
316
  url: sourcemapUrl,
302
317
  success: (res) => {
303
- sourcemapCatch[sourcemapUrl] = res.data;
304
- resolve(sourcemapCatch[sourcemapUrl]);
318
+ if (res.statusCode === 200) {
319
+ sourcemapCatch[sourcemapUrl] = res.data;
320
+ resolve(sourcemapCatch[sourcemapUrl]);
321
+ }
322
+ else {
323
+ resolve((sourcemapCatch[sourcemapUrl] = ''));
324
+ }
325
+ },
326
+ fail() {
327
+ resolve((sourcemapCatch[sourcemapUrl] = ''));
305
328
  },
306
329
  });
307
330
  }
@@ -342,7 +365,7 @@ function joinItem(item) {
342
365
  return `${a}${b}${c}`;
343
366
  }
344
367
  function uniStracktraceyPreset(opts) {
345
- const { base, sourceRoot, splitThirdParty } = opts;
368
+ const { base, sourceRoot, splitThirdParty, uniPlatform } = opts;
346
369
  let stack;
347
370
  return {
348
371
  /**
@@ -365,7 +388,7 @@ function uniStracktraceyPreset(opts) {
365
388
  let baseAfter = '';
366
389
  if (stack.isMP) {
367
390
  if (fileRelative.indexOf('app-service.js') !== -1) {
368
- baseAfter = (base.match(/\w$/) ? '/' : '') + 'weixin';
391
+ baseAfter = (base.match(/\w$/) ? '/' : '') + '__WEIXIN__';
369
392
  if (fileRelative === fileName) {
370
393
  baseAfter += '/__APP__';
371
394
  }
@@ -384,7 +407,7 @@ function uniStracktraceyPreset(opts) {
384
407
  return Promise.resolve(getSourceMapContent(sourcemapUrl));
385
408
  },
386
409
  parseStacktrace(stacktrace) {
387
- stack = new StackTracey$1(stacktrace);
410
+ stack = new StackTracey$1(stacktrace, uniPlatform);
388
411
  return stack;
389
412
  },
390
413
  asTableStacktrace({ maxColumnWidths, stacktrace, stack }) {
@@ -416,6 +439,12 @@ function uniStracktraceyPreset(opts) {
416
439
  return userError + '\n' + thirdParty;
417
440
  }
418
441
  else {
442
+ if (splitThirdParty) {
443
+ return {
444
+ userError: errorName,
445
+ thirdParty: '',
446
+ };
447
+ }
419
448
  return errorName;
420
449
  }
421
450
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-stacktracey",
3
- "version": "3.0.0-alpha-3050020220623003",
3
+ "version": "3.0.0-alpha-3050020220623004",
4
4
  "description": "@dcloudio/uni-stacktracey",
5
5
  "main": "dist/uni-stacktracey.cjs.js",
6
6
  "module": "dist/uni-stacktracey.es.js",