@logbrew/sdk 0.1.26 → 0.1.27

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 (2) hide show
  1. package/issue-stack.cjs +11 -8
  2. package/package.json +1 -1
package/issue-stack.cjs CHANGED
@@ -49,8 +49,8 @@ function buildIssueStackHelpers({ SdkError }) {
49
49
  if (!filename || filename.length > 2048 || hasControlCharacter(filename)) {
50
50
  throw new SdkError("validation_error", "issue stack frame filename is invalid");
51
51
  }
52
- const line = positiveIntegerFromText(frame.line);
53
- const column = positiveIntegerFromText(frame.column);
52
+ const line = frameCoordinateFromText(frame.line);
53
+ const column = frameCoordinateFromText(frame.column);
54
54
  if (line === null || column === null || line > 2147483647 || column > 2147483647) {
55
55
  throw new SdkError("validation_error", "issue stack frame coordinates must be positive integers");
56
56
  }
@@ -136,12 +136,15 @@ function parseJavaScriptStackFrame(rawLine) {
136
136
  functionName = generatedFrameFunction(location.slice(0, marker));
137
137
  location = location.slice(marker + 1);
138
138
  }
139
+ const hermesBytecode = location.startsWith("address at ");
140
+ location = location.replace(/^address at /u, "");
139
141
  const parts = location.split(":");
140
142
  if (parts.length < 3) {
141
143
  return null;
142
144
  }
143
- const column = positiveIntegerFromText(parts.pop());
144
- const lineNumber = positiveIntegerFromText(parts.pop());
145
+ const rawColumn = parts.pop();
146
+ const lineNumber = frameCoordinateFromText(parts.pop());
147
+ const column = frameCoordinateFromText(rawColumn, hermesBytecode && lineNumber === 1 ? 1 : 0);
145
148
  const filename = sanitizeFrameFilename(parts.join(":"));
146
149
  if (!filename || lineNumber === null || column === null) {
147
150
  return null;
@@ -184,13 +187,13 @@ function generatedFrameFunction(value) {
184
187
  return functionName;
185
188
  }
186
189
 
187
- function positiveIntegerFromText(value) {
190
+ function frameCoordinateFromText(value, offset = 0) {
188
191
  const text = String(value);
189
- if (!/^[1-9][0-9]*$/u.test(text)) {
192
+ if (!/^(?:0|[1-9][0-9]*)$/u.test(text)) {
190
193
  return null;
191
194
  }
192
- const parsed = Number(text);
193
- return Number.isSafeInteger(parsed) ? parsed : null;
195
+ const parsed = Number(text) + offset;
196
+ return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;
194
197
  }
195
198
 
196
199
  function sanitizeFrameFilename(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logbrew/sdk",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "Public LogBrew JavaScript SDK for building, validating, and flushing event batches.",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",