@dcloudio/uni-stacktracey 3.0.0-3060520221121001 → 3.0.0-3061320221209001
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/dist/uni-stacktracey.cjs.js +169 -4
- package/dist/uni-stacktracey.es.js +161 -3
- package/package.json +1 -1
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var fs = require('fs');
|
|
6
6
|
var path = require('path');
|
|
7
|
+
var os = require('os');
|
|
7
8
|
|
|
8
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
10
|
|
|
10
|
-
var
|
|
11
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
11
12
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
13
|
+
var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
|
|
12
14
|
|
|
13
15
|
/* ------------------------------------------------------------------------ */
|
|
14
16
|
const O = Object, isBrowser =
|
|
@@ -1662,7 +1664,7 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
|
|
|
1662
1664
|
var readWasm$1 = createCommonjsModule(function (module) {
|
|
1663
1665
|
{
|
|
1664
1666
|
// Node version of reading a wasm file into an array buffer.
|
|
1665
|
-
const fs =
|
|
1667
|
+
const fs = fs__default["default"];
|
|
1666
1668
|
const path = path__default["default"];
|
|
1667
1669
|
|
|
1668
1670
|
module.exports = function readWasm() {
|
|
@@ -3597,6 +3599,163 @@ var SourceMapConsumer =
|
|
|
3597
3599
|
require$$1.SourceMapConsumer;
|
|
3598
3600
|
require$$2.SourceNode;
|
|
3599
3601
|
|
|
3602
|
+
const splitRE = /\r?\n/;
|
|
3603
|
+
const range = 2;
|
|
3604
|
+
function posToNumber(source, pos) {
|
|
3605
|
+
if (typeof pos === 'number')
|
|
3606
|
+
return pos;
|
|
3607
|
+
const lines = source.split(splitRE);
|
|
3608
|
+
const { line, column } = pos;
|
|
3609
|
+
let start = 0;
|
|
3610
|
+
for (let i = 0; i < line - 1; i++) {
|
|
3611
|
+
start += lines[i].length + 1;
|
|
3612
|
+
}
|
|
3613
|
+
return start + column;
|
|
3614
|
+
}
|
|
3615
|
+
function generateCodeFrame(source, start = 0, end) {
|
|
3616
|
+
start = posToNumber(source, start);
|
|
3617
|
+
end = end || start;
|
|
3618
|
+
const lines = source.split(splitRE);
|
|
3619
|
+
let count = 0;
|
|
3620
|
+
const res = [];
|
|
3621
|
+
for (let i = 0; i < lines.length; i++) {
|
|
3622
|
+
count += lines[i].length + 1;
|
|
3623
|
+
if (count >= start) {
|
|
3624
|
+
for (let j = i - range; j <= i + range || end > count; j++) {
|
|
3625
|
+
if (j < 0 || j >= lines.length)
|
|
3626
|
+
continue;
|
|
3627
|
+
const line = j + 1;
|
|
3628
|
+
res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
|
|
3629
|
+
const lineLength = lines[j].length;
|
|
3630
|
+
if (j === i) {
|
|
3631
|
+
// push underline
|
|
3632
|
+
const pad = start - (count - lineLength) + 1;
|
|
3633
|
+
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
3634
|
+
res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
|
|
3635
|
+
}
|
|
3636
|
+
else if (j > i) {
|
|
3637
|
+
if (end > count) {
|
|
3638
|
+
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
3639
|
+
res.push(` | ` + '^'.repeat(length));
|
|
3640
|
+
}
|
|
3641
|
+
count += lineLength + 1;
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
break;
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
return res.join('\n');
|
|
3648
|
+
}
|
|
3649
|
+
const isWindows = os__default["default"].platform() === 'win32';
|
|
3650
|
+
function normalizePath(id) {
|
|
3651
|
+
return isWindows ? id.replace(/\\/g, '/') : id;
|
|
3652
|
+
}
|
|
3653
|
+
function generateCodeFrameSourceMapConsumer(consumer, m, options = {}) {
|
|
3654
|
+
if (m.file) {
|
|
3655
|
+
const res = consumer.originalPositionFor({
|
|
3656
|
+
line: m.line,
|
|
3657
|
+
column: m.column,
|
|
3658
|
+
});
|
|
3659
|
+
if (res.source != null && res.line != null && res.column != null) {
|
|
3660
|
+
let code = consumer.sourceContentFor(res.source, true);
|
|
3661
|
+
if (code) {
|
|
3662
|
+
code = generateCodeFrame(code, { line: res.line, column: res.column });
|
|
3663
|
+
if (options.replaceTabsWithSpace) {
|
|
3664
|
+
code = code.replace(/\t/g, ' ');
|
|
3665
|
+
}
|
|
3666
|
+
return {
|
|
3667
|
+
type: m.type,
|
|
3668
|
+
file: options.sourceRoot
|
|
3669
|
+
? normalizePath(path__default["default"].relative(options.sourceRoot, res.source.replace('\\\\?\\', '')))
|
|
3670
|
+
: res.source,
|
|
3671
|
+
line: res.line,
|
|
3672
|
+
column: res.column,
|
|
3673
|
+
message: m.message,
|
|
3674
|
+
code,
|
|
3675
|
+
};
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3680
|
+
function initConsumer(filename) {
|
|
3681
|
+
if (fs__default["default"].existsSync(filename)) {
|
|
3682
|
+
return new SourceMapConsumer(fs__default["default"].readFileSync(filename, 'utf8'));
|
|
3683
|
+
}
|
|
3684
|
+
return Promise.resolve(undefined);
|
|
3685
|
+
}
|
|
3686
|
+
function generateCodeFrameWithSourceMapPath(filename, messages, options = {}) {
|
|
3687
|
+
if (typeof messages === 'string') {
|
|
3688
|
+
try {
|
|
3689
|
+
messages = JSON.parse(messages);
|
|
3690
|
+
}
|
|
3691
|
+
catch (e) { }
|
|
3692
|
+
}
|
|
3693
|
+
if (Array.isArray(messages) && messages.length) {
|
|
3694
|
+
return new Promise((resolve) => {
|
|
3695
|
+
initConsumer(filename).then((consumer) => {
|
|
3696
|
+
resolve(messages
|
|
3697
|
+
.map((m) => {
|
|
3698
|
+
if (m.file && consumer) {
|
|
3699
|
+
const message = generateCodeFrameSourceMapConsumer(consumer, m, options);
|
|
3700
|
+
if (message) {
|
|
3701
|
+
return message;
|
|
3702
|
+
}
|
|
3703
|
+
}
|
|
3704
|
+
if (!m.file) {
|
|
3705
|
+
m.file = '';
|
|
3706
|
+
}
|
|
3707
|
+
return m;
|
|
3708
|
+
})
|
|
3709
|
+
.filter(Boolean));
|
|
3710
|
+
});
|
|
3711
|
+
});
|
|
3712
|
+
}
|
|
3713
|
+
return Promise.resolve([]);
|
|
3714
|
+
}
|
|
3715
|
+
function resolveSourceMapPath(sourceMapFilename, name, outputDir) {
|
|
3716
|
+
const is_uni_modules = path__default["default"].basename(path__default["default"].dirname(name)) === 'uni_modules';
|
|
3717
|
+
return path__default["default"].resolve(outputDir, '../.sourcemap/app', name, is_uni_modules ? 'utssdk' : '', sourceMapFilename);
|
|
3718
|
+
}
|
|
3719
|
+
function generateCodeFrameWithKotlinStacktrace(stacktrace, { name, inputDir, outputDir }) {
|
|
3720
|
+
const sourceMapFilename = resolveSourceMapPath('app-android/index.kt.map', name, outputDir);
|
|
3721
|
+
return generateCodeFrameWithStacktrace(stacktrace, /e:\s+(.*):\s+\(([0-9]+),\s+([0-9]+)\):\s+(.*)/g, {
|
|
3722
|
+
sourceRoot: inputDir,
|
|
3723
|
+
sourceMapFilename,
|
|
3724
|
+
});
|
|
3725
|
+
}
|
|
3726
|
+
function generateCodeFrameWithSwiftStacktrace(stacktrace, { name, inputDir, outputDir }) {
|
|
3727
|
+
const sourceMapFilename = resolveSourceMapPath('app-ios/index.swift.map', name, outputDir);
|
|
3728
|
+
return generateCodeFrameWithStacktrace(stacktrace, /(.*):([0-9]+):([0-9]+):\s+error:\s+(.*)/g, {
|
|
3729
|
+
sourceRoot: inputDir,
|
|
3730
|
+
sourceMapFilename,
|
|
3731
|
+
});
|
|
3732
|
+
}
|
|
3733
|
+
function generateCodeFrameWithStacktrace(stacktrace, regexp, { sourceRoot, sourceMapFilename, replaceTabsWithSpace, }) {
|
|
3734
|
+
return new Promise((resolve) => {
|
|
3735
|
+
initConsumer(sourceMapFilename).then((consumer) => {
|
|
3736
|
+
if (!consumer) {
|
|
3737
|
+
return resolve(stacktrace);
|
|
3738
|
+
}
|
|
3739
|
+
resolve(stacktrace.replace(regexp, (substring, file, line, column, message) => {
|
|
3740
|
+
const m = generateCodeFrameSourceMapConsumer(consumer, {
|
|
3741
|
+
type: 'error',
|
|
3742
|
+
file,
|
|
3743
|
+
message,
|
|
3744
|
+
line: parseInt(line),
|
|
3745
|
+
column: parseInt(column),
|
|
3746
|
+
}, { sourceRoot, replaceTabsWithSpace });
|
|
3747
|
+
if (!m) {
|
|
3748
|
+
return substring;
|
|
3749
|
+
}
|
|
3750
|
+
return `error: ${message}
|
|
3751
|
+
at ${m.file}:${m.line}:${m.column}
|
|
3752
|
+
${m.code}
|
|
3753
|
+
`;
|
|
3754
|
+
}));
|
|
3755
|
+
});
|
|
3756
|
+
});
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3600
3759
|
const nixSlashes = (x) => x.replace(/\\/g, '/');
|
|
3601
3760
|
const sourcemapCatch = {};
|
|
3602
3761
|
function stacktracey(stacktrace, opts) {
|
|
@@ -3727,7 +3886,7 @@ function getSourceMapContent(sourcemapUrl) {
|
|
|
3727
3886
|
});
|
|
3728
3887
|
}
|
|
3729
3888
|
else {
|
|
3730
|
-
sourcemapCatch[sourcemapUrl] =
|
|
3889
|
+
sourcemapCatch[sourcemapUrl] = fs__default["default"].readFileSync(sourcemapUrl, 'utf-8');
|
|
3731
3890
|
resolve(sourcemapCatch[sourcemapUrl]);
|
|
3732
3891
|
}
|
|
3733
3892
|
}
|
|
@@ -3919,6 +4078,12 @@ ${_stack.errMsg}`;
|
|
|
3919
4078
|
};
|
|
3920
4079
|
}
|
|
3921
4080
|
|
|
4081
|
+
exports.SourceMapConsumer = SourceMapConsumer;
|
|
4082
|
+
exports.generateCodeFrame = generateCodeFrame;
|
|
4083
|
+
exports.generateCodeFrameSourceMapConsumer = generateCodeFrameSourceMapConsumer;
|
|
4084
|
+
exports.generateCodeFrameWithKotlinStacktrace = generateCodeFrameWithKotlinStacktrace;
|
|
4085
|
+
exports.generateCodeFrameWithSourceMapPath = generateCodeFrameWithSourceMapPath;
|
|
4086
|
+
exports.generateCodeFrameWithSwiftStacktrace = generateCodeFrameWithSwiftStacktrace;
|
|
3922
4087
|
exports.stacktracey = stacktracey;
|
|
3923
4088
|
exports.uniStracktraceyPreset = uniStracktraceyPreset;
|
|
3924
4089
|
exports.utsStracktraceyPreset = utsStracktraceyPreset;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
3
4
|
|
|
4
5
|
/* ------------------------------------------------------------------------ */
|
|
5
6
|
const O = Object, isBrowser =
|
|
@@ -3581,6 +3582,163 @@ var SourceMapConsumer =
|
|
|
3581
3582
|
require$$1.SourceMapConsumer;
|
|
3582
3583
|
require$$2.SourceNode;
|
|
3583
3584
|
|
|
3585
|
+
const splitRE = /\r?\n/;
|
|
3586
|
+
const range = 2;
|
|
3587
|
+
function posToNumber(source, pos) {
|
|
3588
|
+
if (typeof pos === 'number')
|
|
3589
|
+
return pos;
|
|
3590
|
+
const lines = source.split(splitRE);
|
|
3591
|
+
const { line, column } = pos;
|
|
3592
|
+
let start = 0;
|
|
3593
|
+
for (let i = 0; i < line - 1; i++) {
|
|
3594
|
+
start += lines[i].length + 1;
|
|
3595
|
+
}
|
|
3596
|
+
return start + column;
|
|
3597
|
+
}
|
|
3598
|
+
function generateCodeFrame(source, start = 0, end) {
|
|
3599
|
+
start = posToNumber(source, start);
|
|
3600
|
+
end = end || start;
|
|
3601
|
+
const lines = source.split(splitRE);
|
|
3602
|
+
let count = 0;
|
|
3603
|
+
const res = [];
|
|
3604
|
+
for (let i = 0; i < lines.length; i++) {
|
|
3605
|
+
count += lines[i].length + 1;
|
|
3606
|
+
if (count >= start) {
|
|
3607
|
+
for (let j = i - range; j <= i + range || end > count; j++) {
|
|
3608
|
+
if (j < 0 || j >= lines.length)
|
|
3609
|
+
continue;
|
|
3610
|
+
const line = j + 1;
|
|
3611
|
+
res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
|
|
3612
|
+
const lineLength = lines[j].length;
|
|
3613
|
+
if (j === i) {
|
|
3614
|
+
// push underline
|
|
3615
|
+
const pad = start - (count - lineLength) + 1;
|
|
3616
|
+
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
3617
|
+
res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
|
|
3618
|
+
}
|
|
3619
|
+
else if (j > i) {
|
|
3620
|
+
if (end > count) {
|
|
3621
|
+
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
3622
|
+
res.push(` | ` + '^'.repeat(length));
|
|
3623
|
+
}
|
|
3624
|
+
count += lineLength + 1;
|
|
3625
|
+
}
|
|
3626
|
+
}
|
|
3627
|
+
break;
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
return res.join('\n');
|
|
3631
|
+
}
|
|
3632
|
+
const isWindows = os.platform() === 'win32';
|
|
3633
|
+
function normalizePath(id) {
|
|
3634
|
+
return isWindows ? id.replace(/\\/g, '/') : id;
|
|
3635
|
+
}
|
|
3636
|
+
function generateCodeFrameSourceMapConsumer(consumer, m, options = {}) {
|
|
3637
|
+
if (m.file) {
|
|
3638
|
+
const res = consumer.originalPositionFor({
|
|
3639
|
+
line: m.line,
|
|
3640
|
+
column: m.column,
|
|
3641
|
+
});
|
|
3642
|
+
if (res.source != null && res.line != null && res.column != null) {
|
|
3643
|
+
let code = consumer.sourceContentFor(res.source, true);
|
|
3644
|
+
if (code) {
|
|
3645
|
+
code = generateCodeFrame(code, { line: res.line, column: res.column });
|
|
3646
|
+
if (options.replaceTabsWithSpace) {
|
|
3647
|
+
code = code.replace(/\t/g, ' ');
|
|
3648
|
+
}
|
|
3649
|
+
return {
|
|
3650
|
+
type: m.type,
|
|
3651
|
+
file: options.sourceRoot
|
|
3652
|
+
? normalizePath(path.relative(options.sourceRoot, res.source.replace('\\\\?\\', '')))
|
|
3653
|
+
: res.source,
|
|
3654
|
+
line: res.line,
|
|
3655
|
+
column: res.column,
|
|
3656
|
+
message: m.message,
|
|
3657
|
+
code,
|
|
3658
|
+
};
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3662
|
+
}
|
|
3663
|
+
function initConsumer(filename) {
|
|
3664
|
+
if (fs.existsSync(filename)) {
|
|
3665
|
+
return new SourceMapConsumer(fs.readFileSync(filename, 'utf8'));
|
|
3666
|
+
}
|
|
3667
|
+
return Promise.resolve(undefined);
|
|
3668
|
+
}
|
|
3669
|
+
function generateCodeFrameWithSourceMapPath(filename, messages, options = {}) {
|
|
3670
|
+
if (typeof messages === 'string') {
|
|
3671
|
+
try {
|
|
3672
|
+
messages = JSON.parse(messages);
|
|
3673
|
+
}
|
|
3674
|
+
catch (e) { }
|
|
3675
|
+
}
|
|
3676
|
+
if (Array.isArray(messages) && messages.length) {
|
|
3677
|
+
return new Promise((resolve) => {
|
|
3678
|
+
initConsumer(filename).then((consumer) => {
|
|
3679
|
+
resolve(messages
|
|
3680
|
+
.map((m) => {
|
|
3681
|
+
if (m.file && consumer) {
|
|
3682
|
+
const message = generateCodeFrameSourceMapConsumer(consumer, m, options);
|
|
3683
|
+
if (message) {
|
|
3684
|
+
return message;
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
if (!m.file) {
|
|
3688
|
+
m.file = '';
|
|
3689
|
+
}
|
|
3690
|
+
return m;
|
|
3691
|
+
})
|
|
3692
|
+
.filter(Boolean));
|
|
3693
|
+
});
|
|
3694
|
+
});
|
|
3695
|
+
}
|
|
3696
|
+
return Promise.resolve([]);
|
|
3697
|
+
}
|
|
3698
|
+
function resolveSourceMapPath(sourceMapFilename, name, outputDir) {
|
|
3699
|
+
const is_uni_modules = path.basename(path.dirname(name)) === 'uni_modules';
|
|
3700
|
+
return path.resolve(outputDir, '../.sourcemap/app', name, is_uni_modules ? 'utssdk' : '', sourceMapFilename);
|
|
3701
|
+
}
|
|
3702
|
+
function generateCodeFrameWithKotlinStacktrace(stacktrace, { name, inputDir, outputDir }) {
|
|
3703
|
+
const sourceMapFilename = resolveSourceMapPath('app-android/index.kt.map', name, outputDir);
|
|
3704
|
+
return generateCodeFrameWithStacktrace(stacktrace, /e:\s+(.*):\s+\(([0-9]+),\s+([0-9]+)\):\s+(.*)/g, {
|
|
3705
|
+
sourceRoot: inputDir,
|
|
3706
|
+
sourceMapFilename,
|
|
3707
|
+
});
|
|
3708
|
+
}
|
|
3709
|
+
function generateCodeFrameWithSwiftStacktrace(stacktrace, { name, inputDir, outputDir }) {
|
|
3710
|
+
const sourceMapFilename = resolveSourceMapPath('app-ios/index.swift.map', name, outputDir);
|
|
3711
|
+
return generateCodeFrameWithStacktrace(stacktrace, /(.*):([0-9]+):([0-9]+):\s+error:\s+(.*)/g, {
|
|
3712
|
+
sourceRoot: inputDir,
|
|
3713
|
+
sourceMapFilename,
|
|
3714
|
+
});
|
|
3715
|
+
}
|
|
3716
|
+
function generateCodeFrameWithStacktrace(stacktrace, regexp, { sourceRoot, sourceMapFilename, replaceTabsWithSpace, }) {
|
|
3717
|
+
return new Promise((resolve) => {
|
|
3718
|
+
initConsumer(sourceMapFilename).then((consumer) => {
|
|
3719
|
+
if (!consumer) {
|
|
3720
|
+
return resolve(stacktrace);
|
|
3721
|
+
}
|
|
3722
|
+
resolve(stacktrace.replace(regexp, (substring, file, line, column, message) => {
|
|
3723
|
+
const m = generateCodeFrameSourceMapConsumer(consumer, {
|
|
3724
|
+
type: 'error',
|
|
3725
|
+
file,
|
|
3726
|
+
message,
|
|
3727
|
+
line: parseInt(line),
|
|
3728
|
+
column: parseInt(column),
|
|
3729
|
+
}, { sourceRoot, replaceTabsWithSpace });
|
|
3730
|
+
if (!m) {
|
|
3731
|
+
return substring;
|
|
3732
|
+
}
|
|
3733
|
+
return `error: ${message}
|
|
3734
|
+
at ${m.file}:${m.line}:${m.column}
|
|
3735
|
+
${m.code}
|
|
3736
|
+
`;
|
|
3737
|
+
}));
|
|
3738
|
+
});
|
|
3739
|
+
});
|
|
3740
|
+
}
|
|
3741
|
+
|
|
3584
3742
|
// @ts-ignore
|
|
3585
3743
|
{
|
|
3586
3744
|
// @ts-ignore
|
|
@@ -3721,7 +3879,7 @@ function getSourceMapContent(sourcemapUrl) {
|
|
|
3721
3879
|
});
|
|
3722
3880
|
}
|
|
3723
3881
|
else {
|
|
3724
|
-
sourcemapCatch[sourcemapUrl] =
|
|
3882
|
+
sourcemapCatch[sourcemapUrl] = fs.readFileSync(sourcemapUrl, 'utf-8');
|
|
3725
3883
|
resolve(sourcemapCatch[sourcemapUrl]);
|
|
3726
3884
|
}
|
|
3727
3885
|
}
|
|
@@ -3913,4 +4071,4 @@ ${_stack.errMsg}`;
|
|
|
3913
4071
|
};
|
|
3914
4072
|
}
|
|
3915
4073
|
|
|
3916
|
-
export { stacktracey, uniStracktraceyPreset, utsStracktraceyPreset };
|
|
4074
|
+
export { SourceMapConsumer, generateCodeFrame, generateCodeFrameSourceMapConsumer, generateCodeFrameWithKotlinStacktrace, generateCodeFrameWithSourceMapPath, generateCodeFrameWithSwiftStacktrace, stacktracey, uniStracktraceyPreset, utsStracktraceyPreset };
|
package/package.json
CHANGED