astro-eslint-parser 1.3.1 → 1.3.2

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/lib/index.d.mts CHANGED
@@ -314,7 +314,7 @@ declare class ParseError extends SyntaxError {
314
314
  }
315
315
 
316
316
  var name = "astro-eslint-parser";
317
- var version = "1.3.1";
317
+ var version = "1.3.2";
318
318
 
319
319
  declare const meta_name: typeof name;
320
320
  declare const meta_version: typeof version;
package/lib/index.d.ts CHANGED
@@ -314,7 +314,7 @@ declare class ParseError extends SyntaxError {
314
314
  }
315
315
 
316
316
  var name = "astro-eslint-parser";
317
- var version = "1.3.1";
317
+ var version = "1.3.2";
318
318
 
319
319
  declare const meta_name: typeof name;
320
320
  declare const meta_version: typeof version;
package/lib/index.js CHANGED
@@ -2325,17 +2325,30 @@ function adjustHTML(ast, htmlElement, ctx) {
2325
2325
  };
2326
2326
  }
2327
2327
  function buildComparableOffsetRemapper(code) {
2328
- if (Buffer.byteLength(code, "utf8") === code.length) {
2329
- return (offset) => offset;
2330
- }
2331
- const byteOffsets = [0];
2332
- const codeUnitOffsets = [0];
2328
+ let byteOffsets, codeUnitOffsets;
2333
2329
  for (let index = 0, byteOffset = 0; index < code.length; ) {
2334
2330
  const codePoint = code.codePointAt(index);
2335
- index += codePoint > 65535 ? 2 : 1;
2336
- byteOffset += getUTF8ByteLength(codePoint);
2337
- byteOffsets.push(byteOffset);
2338
- codeUnitOffsets.push(index);
2331
+ const codeUnitLength = codePoint > 65535 ? 2 : 1;
2332
+ const nextIndex = index + codeUnitLength;
2333
+ const nextByteOffset = byteOffset + getUTF8ByteLength(codePoint);
2334
+ if (byteOffsets) {
2335
+ byteOffsets.push(nextByteOffset);
2336
+ codeUnitOffsets.push(nextIndex);
2337
+ } else if (codePoint > 127) {
2338
+ byteOffsets = [0];
2339
+ codeUnitOffsets = [0];
2340
+ for (let asciiOffset = 1; asciiOffset <= index; asciiOffset++) {
2341
+ byteOffsets.push(asciiOffset);
2342
+ codeUnitOffsets.push(asciiOffset);
2343
+ }
2344
+ byteOffsets.push(nextByteOffset);
2345
+ codeUnitOffsets.push(nextIndex);
2346
+ }
2347
+ index = nextIndex;
2348
+ byteOffset = nextByteOffset;
2349
+ }
2350
+ if (!byteOffsets || !codeUnitOffsets) {
2351
+ return (offset) => offset;
2339
2352
  }
2340
2353
  return (offset) => {
2341
2354
  const index = sortedLastIndex(byteOffsets, (target) => target - offset) - 1;
@@ -2927,7 +2940,7 @@ __export(meta_exports, {
2927
2940
 
2928
2941
  // package.json
2929
2942
  var name = "astro-eslint-parser";
2930
- var version = "1.3.1";
2943
+ var version = "1.3.2";
2931
2944
 
2932
2945
  // src/index.ts
2933
2946
  function parseForESLint2(code, options) {
package/lib/index.mjs CHANGED
@@ -2300,17 +2300,30 @@ function adjustHTML(ast, htmlElement, ctx) {
2300
2300
  };
2301
2301
  }
2302
2302
  function buildComparableOffsetRemapper(code) {
2303
- if (Buffer.byteLength(code, "utf8") === code.length) {
2304
- return (offset) => offset;
2305
- }
2306
- const byteOffsets = [0];
2307
- const codeUnitOffsets = [0];
2303
+ let byteOffsets, codeUnitOffsets;
2308
2304
  for (let index = 0, byteOffset = 0; index < code.length; ) {
2309
2305
  const codePoint = code.codePointAt(index);
2310
- index += codePoint > 65535 ? 2 : 1;
2311
- byteOffset += getUTF8ByteLength(codePoint);
2312
- byteOffsets.push(byteOffset);
2313
- codeUnitOffsets.push(index);
2306
+ const codeUnitLength = codePoint > 65535 ? 2 : 1;
2307
+ const nextIndex = index + codeUnitLength;
2308
+ const nextByteOffset = byteOffset + getUTF8ByteLength(codePoint);
2309
+ if (byteOffsets) {
2310
+ byteOffsets.push(nextByteOffset);
2311
+ codeUnitOffsets.push(nextIndex);
2312
+ } else if (codePoint > 127) {
2313
+ byteOffsets = [0];
2314
+ codeUnitOffsets = [0];
2315
+ for (let asciiOffset = 1; asciiOffset <= index; asciiOffset++) {
2316
+ byteOffsets.push(asciiOffset);
2317
+ codeUnitOffsets.push(asciiOffset);
2318
+ }
2319
+ byteOffsets.push(nextByteOffset);
2320
+ codeUnitOffsets.push(nextIndex);
2321
+ }
2322
+ index = nextIndex;
2323
+ byteOffset = nextByteOffset;
2324
+ }
2325
+ if (!byteOffsets || !codeUnitOffsets) {
2326
+ return (offset) => offset;
2314
2327
  }
2315
2328
  return (offset) => {
2316
2329
  const index = sortedLastIndex(byteOffsets, (target) => target - offset) - 1;
@@ -2902,7 +2915,7 @@ __export(meta_exports, {
2902
2915
 
2903
2916
  // package.json
2904
2917
  var name = "astro-eslint-parser";
2905
- var version = "1.3.1";
2918
+ var version = "1.3.2";
2906
2919
 
2907
2920
  // src/index.ts
2908
2921
  function parseForESLint2(code, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-eslint-parser",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Astro component parser for ESLint",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",