@parcel/utils 2.8.4-nightly.0 → 2.9.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/utils",
3
- "version": "2.8.4-nightly.0+7b79c6d",
3
+ "version": "2.9.1",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,11 +33,11 @@
33
33
  }
34
34
  },
35
35
  "dependencies": {
36
- "@parcel/codeframe": "2.8.4-nightly.0+7b79c6d",
37
- "@parcel/diagnostic": "2.8.4-nightly.0+7b79c6d",
38
- "@parcel/hash": "2.8.4-nightly.0+7b79c6d",
39
- "@parcel/logger": "2.8.4-nightly.0+7b79c6d",
40
- "@parcel/markdown-ansi": "2.8.4-nightly.0+7b79c6d",
36
+ "@parcel/codeframe": "2.9.1",
37
+ "@parcel/diagnostic": "2.9.1",
38
+ "@parcel/hash": "2.9.1",
39
+ "@parcel/logger": "2.9.1",
40
+ "@parcel/markdown-ansi": "2.9.1",
41
41
  "@parcel/source-map": "^2.1.1",
42
42
  "chalk": "^4.1.0",
43
43
  "nullthrows": "^1.1.1"
@@ -47,7 +47,7 @@
47
47
  "ansi-html-community": "0.0.8",
48
48
  "clone": "^2.1.1",
49
49
  "fast-glob": "^3.2.12",
50
- "fastest-levenshtein": "^1.0.8",
50
+ "fastest-levenshtein": "^1.0.16",
51
51
  "is-glob": "^4.0.0",
52
52
  "is-url": "^1.2.2",
53
53
  "json5": "^2.2.0",
@@ -65,5 +65,5 @@
65
65
  "./src/http-server.js": false,
66
66
  "./src/openInBrowser.js": false
67
67
  },
68
- "gitHead": "7b79c6d69ffabef89810a8db61e9abdeb70d6990"
68
+ "gitHead": "5c5dc302b559f0b0d8c57b4d638aac521c879b70"
69
69
  }
package/src/glob.js CHANGED
@@ -5,7 +5,7 @@ import type {FileSystem} from '@parcel/fs';
5
5
 
6
6
  import _isGlob from 'is-glob';
7
7
  import fastGlob, {type FastGlobOptions} from 'fast-glob';
8
- import {isMatch, makeRe, type Options} from 'micromatch';
8
+ import micromatch, {isMatch, makeRe, type Options} from 'micromatch';
9
9
  import {normalizeSeparators} from './path';
10
10
 
11
11
  export function isGlob(p: FilePath): any {
@@ -23,6 +23,18 @@ export function isGlobMatch(
23
23
  return isMatch(filePath, glob, opts);
24
24
  }
25
25
 
26
+ export function globMatch(
27
+ values: Array<string>,
28
+ glob: Glob | Array<Glob>,
29
+ opts?: Options,
30
+ ): Array<string> {
31
+ glob = Array.isArray(glob)
32
+ ? glob.map(normalizeSeparators)
33
+ : normalizeSeparators(glob);
34
+
35
+ return micromatch(values, glob, opts);
36
+ }
37
+
26
38
  export function globToRegex(glob: Glob, opts?: Options): RegExp {
27
39
  return makeRe(glob, opts);
28
40
  }
package/src/index.js CHANGED
@@ -49,7 +49,14 @@ export {
49
49
  export {DefaultMap, DefaultWeakMap} from './DefaultMap';
50
50
  export {makeDeferredWithPromise} from './Deferred';
51
51
  export {getProgressMessage} from './progress-message.js';
52
- export {isGlob, isGlobMatch, globSync, glob, globToRegex} from './glob';
52
+ export {
53
+ isGlob,
54
+ isGlobMatch,
55
+ globMatch,
56
+ globSync,
57
+ glob,
58
+ globToRegex,
59
+ } from './glob';
53
60
  export {hashStream, hashObject, hashFile} from './hash';
54
61
  export {SharedBuffer} from './shared-buffer';
55
62
  export {fuzzySearch} from './schema';
package/src/schema.js CHANGED
@@ -6,8 +6,7 @@ import ThrowableDiagnostic, {
6
6
  } from '@parcel/diagnostic';
7
7
  import type {Mapping} from '@mischnic/json-sourcemap';
8
8
  import nullthrows from 'nullthrows';
9
- // flowlint-next-line untyped-import:off
10
- import levenshtein from 'fastest-levenshtein';
9
+ import * as levenshtein from 'fastest-levenshtein';
11
10
 
12
11
  export type SchemaEntity =
13
12
  | SchemaObject
package/src/sourcemap.js CHANGED
@@ -94,8 +94,8 @@ export function remapSourceLocation(
94
94
  } = loc;
95
95
  let lineDiff = endLine - startLine;
96
96
  let colDiff = endCol - startCol;
97
- let start = originalMap.findClosestMapping(startLine, startCol);
98
- let end = originalMap.findClosestMapping(endLine, endCol);
97
+ let start = originalMap.findClosestMapping(startLine, startCol - 1);
98
+ let end = originalMap.findClosestMapping(endLine, endCol - 1);
99
99
 
100
100
  if (start?.original) {
101
101
  if (start.source) {
@@ -108,13 +108,16 @@ export function remapSourceLocation(
108
108
 
109
109
  if (end?.original) {
110
110
  ({line: endLine, column: endCol} = end.original);
111
- endCol++;
111
+ endCol++; // source map columns are 0-based
112
112
 
113
113
  if (endLine < startLine) {
114
114
  endLine = startLine;
115
115
  endCol = startCol;
116
116
  } else if (endLine === startLine && endCol < startCol && lineDiff === 0) {
117
117
  endCol = startCol + colDiff;
118
+ } else if (endLine === startLine && startCol === endCol && lineDiff === 0) {
119
+ // Prevent 0-length ranges
120
+ endCol = startCol + 1;
118
121
  }
119
122
  } else {
120
123
  endLine = startLine;