@danielx/civet 0.11.7 → 0.11.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.
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var ts_diagnostic_exports = {};
20
20
  __export(ts_diagnostic_exports, {
21
21
  flattenDiagnosticMessageText: () => flattenDiagnosticMessageText,
22
+ forwardMap: () => forwardMap,
22
23
  remapPosition: () => remapPosition,
23
24
  remapRange: () => remapRange
24
25
  });
@@ -59,6 +60,45 @@ function remapRange(range, sourcemapLines) {
59
60
  end: remapPosition(range.end, sourcemapLines)
60
61
  };
61
62
  }
63
+ const isFourTuple = (m) => m.length === 4;
64
+ function forwardMap(sourcemapLines, position) {
65
+ const { line: origLine, character: origOffset } = position;
66
+ let col = 0;
67
+ let bestLine = -1;
68
+ let bestOffset = -1;
69
+ let foundLine = -1;
70
+ let foundOffset = -1;
71
+ sourcemapLines.forEach((line, i) => {
72
+ col = 0;
73
+ return line.forEach((mapping) => {
74
+ col += mapping[0];
75
+ if (isFourTuple(mapping)) {
76
+ const [_p, _f, srcLine, srcOffset] = mapping;
77
+ if (srcLine <= origLine) {
78
+ if (srcLine > bestLine && srcOffset <= origOffset || srcLine === bestLine && srcOffset <= origOffset && srcOffset >= bestOffset) {
79
+ bestLine = srcLine;
80
+ bestOffset = srcOffset;
81
+ foundLine = i;
82
+ return foundOffset = col;
83
+ }
84
+ ;
85
+ return;
86
+ }
87
+ ;
88
+ return;
89
+ }
90
+ ;
91
+ return;
92
+ });
93
+ });
94
+ if (foundLine >= 0) {
95
+ return {
96
+ line: foundLine + origLine - bestLine,
97
+ character: foundOffset + origOffset - bestOffset
98
+ };
99
+ }
100
+ return position;
101
+ }
62
102
  function flattenDiagnosticMessageText(diag, indent = 0) {
63
103
  if (typeof diag === "string") {
64
104
  return diag;
@@ -84,6 +124,7 @@ function flattenDiagnosticMessageText(diag, indent = 0) {
84
124
  // Annotate the CommonJS export names for ESM import in node:
85
125
  0 && (module.exports = {
86
126
  flattenDiagnosticMessageText,
127
+ forwardMap,
87
128
  remapPosition,
88
129
  remapRange
89
130
  });
@@ -34,6 +34,45 @@ function remapRange(range, sourcemapLines) {
34
34
  end: remapPosition(range.end, sourcemapLines)
35
35
  };
36
36
  }
37
+ const isFourTuple = (m) => m.length === 4;
38
+ function forwardMap(sourcemapLines, position) {
39
+ const { line: origLine, character: origOffset } = position;
40
+ let col = 0;
41
+ let bestLine = -1;
42
+ let bestOffset = -1;
43
+ let foundLine = -1;
44
+ let foundOffset = -1;
45
+ sourcemapLines.forEach((line, i) => {
46
+ col = 0;
47
+ return line.forEach((mapping) => {
48
+ col += mapping[0];
49
+ if (isFourTuple(mapping)) {
50
+ const [_p, _f, srcLine, srcOffset] = mapping;
51
+ if (srcLine <= origLine) {
52
+ if (srcLine > bestLine && srcOffset <= origOffset || srcLine === bestLine && srcOffset <= origOffset && srcOffset >= bestOffset) {
53
+ bestLine = srcLine;
54
+ bestOffset = srcOffset;
55
+ foundLine = i;
56
+ return foundOffset = col;
57
+ }
58
+ ;
59
+ return;
60
+ }
61
+ ;
62
+ return;
63
+ }
64
+ ;
65
+ return;
66
+ });
67
+ });
68
+ if (foundLine >= 0) {
69
+ return {
70
+ line: foundLine + origLine - bestLine,
71
+ character: foundOffset + origOffset - bestOffset
72
+ };
73
+ }
74
+ return position;
75
+ }
37
76
  function flattenDiagnosticMessageText(diag, indent = 0) {
38
77
  if (typeof diag === "string") {
39
78
  return diag;
@@ -58,6 +97,7 @@ function flattenDiagnosticMessageText(diag, indent = 0) {
58
97
  }
59
98
  export {
60
99
  flattenDiagnosticMessageText,
100
+ forwardMap,
61
101
  remapPosition,
62
102
  remapRange
63
103
  };