@vue/shared 3.1.1 → 3.1.5
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/shared.cjs.js +14 -4
- package/dist/shared.cjs.prod.js +14 -4
- package/dist/shared.esm-bundler.js +14 -4
- package/package.json +1 -1
package/dist/shared.cjs.js
CHANGED
|
@@ -54,11 +54,20 @@ const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
|
|
|
54
54
|
|
|
55
55
|
const range = 2;
|
|
56
56
|
function generateCodeFrame(source, start = 0, end = source.length) {
|
|
57
|
-
|
|
57
|
+
// Split the content into individual lines but capture the newline sequence
|
|
58
|
+
// that separated each line. This is important because the actual sequence is
|
|
59
|
+
// needed to properly take into account the full line length for offset
|
|
60
|
+
// comparison
|
|
61
|
+
let lines = source.split(/(\r?\n)/);
|
|
62
|
+
// Separate the lines and newline sequences into separate arrays for easier referencing
|
|
63
|
+
const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
|
64
|
+
lines = lines.filter((_, idx) => idx % 2 === 0);
|
|
58
65
|
let count = 0;
|
|
59
66
|
const res = [];
|
|
60
67
|
for (let i = 0; i < lines.length; i++) {
|
|
61
|
-
count +=
|
|
68
|
+
count +=
|
|
69
|
+
lines[i].length +
|
|
70
|
+
((newlineSequences[i] && newlineSequences[i].length) || 0);
|
|
62
71
|
if (count >= start) {
|
|
63
72
|
for (let j = i - range; j <= i + range || end > count; j++) {
|
|
64
73
|
if (j < 0 || j >= lines.length)
|
|
@@ -66,9 +75,10 @@ function generateCodeFrame(source, start = 0, end = source.length) {
|
|
|
66
75
|
const line = j + 1;
|
|
67
76
|
res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
|
|
68
77
|
const lineLength = lines[j].length;
|
|
78
|
+
const newLineSeqLength = (newlineSequences[j] && newlineSequences[j].length) || 0;
|
|
69
79
|
if (j === i) {
|
|
70
80
|
// push underline
|
|
71
|
-
const pad = start - (count - lineLength
|
|
81
|
+
const pad = start - (count - (lineLength + newLineSeqLength));
|
|
72
82
|
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
73
83
|
res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
|
|
74
84
|
}
|
|
@@ -77,7 +87,7 @@ function generateCodeFrame(source, start = 0, end = source.length) {
|
|
|
77
87
|
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
78
88
|
res.push(` | ` + '^'.repeat(length));
|
|
79
89
|
}
|
|
80
|
-
count += lineLength +
|
|
90
|
+
count += lineLength + newLineSeqLength;
|
|
81
91
|
}
|
|
82
92
|
}
|
|
83
93
|
break;
|
package/dist/shared.cjs.prod.js
CHANGED
|
@@ -54,11 +54,20 @@ const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
|
|
|
54
54
|
|
|
55
55
|
const range = 2;
|
|
56
56
|
function generateCodeFrame(source, start = 0, end = source.length) {
|
|
57
|
-
|
|
57
|
+
// Split the content into individual lines but capture the newline sequence
|
|
58
|
+
// that separated each line. This is important because the actual sequence is
|
|
59
|
+
// needed to properly take into account the full line length for offset
|
|
60
|
+
// comparison
|
|
61
|
+
let lines = source.split(/(\r?\n)/);
|
|
62
|
+
// Separate the lines and newline sequences into separate arrays for easier referencing
|
|
63
|
+
const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
|
64
|
+
lines = lines.filter((_, idx) => idx % 2 === 0);
|
|
58
65
|
let count = 0;
|
|
59
66
|
const res = [];
|
|
60
67
|
for (let i = 0; i < lines.length; i++) {
|
|
61
|
-
count +=
|
|
68
|
+
count +=
|
|
69
|
+
lines[i].length +
|
|
70
|
+
((newlineSequences[i] && newlineSequences[i].length) || 0);
|
|
62
71
|
if (count >= start) {
|
|
63
72
|
for (let j = i - range; j <= i + range || end > count; j++) {
|
|
64
73
|
if (j < 0 || j >= lines.length)
|
|
@@ -66,9 +75,10 @@ function generateCodeFrame(source, start = 0, end = source.length) {
|
|
|
66
75
|
const line = j + 1;
|
|
67
76
|
res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
|
|
68
77
|
const lineLength = lines[j].length;
|
|
78
|
+
const newLineSeqLength = (newlineSequences[j] && newlineSequences[j].length) || 0;
|
|
69
79
|
if (j === i) {
|
|
70
80
|
// push underline
|
|
71
|
-
const pad = start - (count - lineLength
|
|
81
|
+
const pad = start - (count - (lineLength + newLineSeqLength));
|
|
72
82
|
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
73
83
|
res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
|
|
74
84
|
}
|
|
@@ -77,7 +87,7 @@ function generateCodeFrame(source, start = 0, end = source.length) {
|
|
|
77
87
|
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
78
88
|
res.push(` | ` + '^'.repeat(length));
|
|
79
89
|
}
|
|
80
|
-
count += lineLength +
|
|
90
|
+
count += lineLength + newLineSeqLength;
|
|
81
91
|
}
|
|
82
92
|
}
|
|
83
93
|
break;
|
|
@@ -50,11 +50,20 @@ const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
|
|
|
50
50
|
|
|
51
51
|
const range = 2;
|
|
52
52
|
function generateCodeFrame(source, start = 0, end = source.length) {
|
|
53
|
-
|
|
53
|
+
// Split the content into individual lines but capture the newline sequence
|
|
54
|
+
// that separated each line. This is important because the actual sequence is
|
|
55
|
+
// needed to properly take into account the full line length for offset
|
|
56
|
+
// comparison
|
|
57
|
+
let lines = source.split(/(\r?\n)/);
|
|
58
|
+
// Separate the lines and newline sequences into separate arrays for easier referencing
|
|
59
|
+
const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
|
60
|
+
lines = lines.filter((_, idx) => idx % 2 === 0);
|
|
54
61
|
let count = 0;
|
|
55
62
|
const res = [];
|
|
56
63
|
for (let i = 0; i < lines.length; i++) {
|
|
57
|
-
count +=
|
|
64
|
+
count +=
|
|
65
|
+
lines[i].length +
|
|
66
|
+
((newlineSequences[i] && newlineSequences[i].length) || 0);
|
|
58
67
|
if (count >= start) {
|
|
59
68
|
for (let j = i - range; j <= i + range || end > count; j++) {
|
|
60
69
|
if (j < 0 || j >= lines.length)
|
|
@@ -62,9 +71,10 @@ function generateCodeFrame(source, start = 0, end = source.length) {
|
|
|
62
71
|
const line = j + 1;
|
|
63
72
|
res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
|
|
64
73
|
const lineLength = lines[j].length;
|
|
74
|
+
const newLineSeqLength = (newlineSequences[j] && newlineSequences[j].length) || 0;
|
|
65
75
|
if (j === i) {
|
|
66
76
|
// push underline
|
|
67
|
-
const pad = start - (count - lineLength
|
|
77
|
+
const pad = start - (count - (lineLength + newLineSeqLength));
|
|
68
78
|
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
69
79
|
res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
|
|
70
80
|
}
|
|
@@ -73,7 +83,7 @@ function generateCodeFrame(source, start = 0, end = source.length) {
|
|
|
73
83
|
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
74
84
|
res.push(` | ` + '^'.repeat(length));
|
|
75
85
|
}
|
|
76
|
-
count += lineLength +
|
|
86
|
+
count += lineLength + newLineSeqLength;
|
|
77
87
|
}
|
|
78
88
|
}
|
|
79
89
|
break;
|