pnpm 10.30.2 → 10.30.3

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,42 +19,51 @@
19
19
  "nopt@8.1.0": [
20
20
  "node_modules/nopt"
21
21
  ],
22
- "tar@7.5.9": [
23
- "node_modules/tar"
24
- ],
25
- "tinyglobby@0.2.15": [
26
- "node_modules/tinyglobby"
27
- ],
28
- "semver@7.7.4": [
29
- "node_modules/semver"
22
+ "which@5.0.0": [
23
+ "node_modules/which"
30
24
  ],
31
25
  "env-paths@2.2.1": [
32
26
  "node_modules/env-paths"
33
27
  ],
28
+ "tinyglobby@0.2.15": [
29
+ "node_modules/tinyglobby"
30
+ ],
34
31
  "proc-log@5.0.0": [
35
32
  "node_modules/proc-log"
36
33
  ],
37
34
  "exponential-backoff@3.1.3": [
38
35
  "node_modules/exponential-backoff"
39
36
  ],
40
- "which@5.0.0": [
41
- "node_modules/which"
37
+ "semver@7.7.4": [
38
+ "node_modules/semver"
42
39
  ],
43
40
  "graceful-fs@4.2.11": [
44
41
  "node_modules/graceful-fs"
45
42
  ],
43
+ "tar@7.5.9": [
44
+ "node_modules/tar"
45
+ ],
46
46
  "make-fetch-happen@14.0.3": [
47
47
  "node_modules/make-fetch-happen"
48
48
  ],
49
49
  "abbrev@3.0.1": [
50
50
  "node_modules/abbrev"
51
51
  ],
52
- "chownr@3.0.0": [
53
- "node_modules/chownr"
52
+ "isexe@3.1.1": [
53
+ "node_modules/isexe"
54
+ ],
55
+ "fdir@6.5.0(picomatch@4.0.3)": [
56
+ "node_modules/fdir"
57
+ ],
58
+ "picomatch@4.0.3": [
59
+ "node_modules/picomatch"
54
60
  ],
55
61
  "yallist@5.0.0": [
56
62
  "node_modules/yallist"
57
63
  ],
64
+ "chownr@3.0.0": [
65
+ "node_modules/chownr"
66
+ ],
58
67
  "@isaacs/fs-minipass@4.0.1": [
59
68
  "node_modules/@isaacs/fs-minipass"
60
69
  ],
@@ -64,36 +73,30 @@
64
73
  "minipass@7.1.3": [
65
74
  "node_modules/minipass"
66
75
  ],
67
- "fdir@6.5.0(picomatch@4.0.3)": [
68
- "node_modules/fdir"
76
+ "promise-retry@2.0.1": [
77
+ "node_modules/promise-retry"
69
78
  ],
70
- "picomatch@4.0.3": [
71
- "node_modules/picomatch"
79
+ "negotiator@1.0.0": [
80
+ "node_modules/negotiator"
72
81
  ],
73
- "isexe@3.1.1": [
74
- "node_modules/isexe"
82
+ "@npmcli/agent@3.0.0": [
83
+ "node_modules/@npmcli/agent"
75
84
  ],
76
85
  "ssri@12.0.0": [
77
86
  "node_modules/ssri"
78
87
  ],
79
- "cacache@19.0.1": [
80
- "node_modules/cacache"
81
- ],
82
- "negotiator@1.0.0": [
83
- "node_modules/negotiator"
84
- ],
85
88
  "minipass@3.3.6": [
86
- "node_modules/minipass-flush/node_modules/minipass",
87
89
  "node_modules/minipass-pipeline/node_modules/minipass",
90
+ "node_modules/minipass-flush/node_modules/minipass",
88
91
  "node_modules/minipass-sized/node_modules/minipass"
89
92
  ],
90
93
  "yallist@4.0.0": [
91
- "node_modules/minipass-flush/node_modules/yallist",
92
94
  "node_modules/minipass-pipeline/node_modules/yallist",
95
+ "node_modules/minipass-flush/node_modules/yallist",
93
96
  "node_modules/minipass-sized/node_modules/yallist"
94
97
  ],
95
- "promise-retry@2.0.1": [
96
- "node_modules/promise-retry"
98
+ "cacache@19.0.1": [
99
+ "node_modules/cacache"
97
100
  ],
98
101
  "minipass-fetch@4.0.1": [
99
102
  "node_modules/minipass-fetch"
@@ -101,8 +104,26 @@
101
104
  "http-cache-semantics@4.2.0": [
102
105
  "node_modules/http-cache-semantics"
103
106
  ],
104
- "@npmcli/agent@3.0.0": [
105
- "node_modules/@npmcli/agent"
107
+ "err-code@2.0.3": [
108
+ "node_modules/err-code"
109
+ ],
110
+ "retry@0.12.0": [
111
+ "node_modules/retry"
112
+ ],
113
+ "http-proxy-agent@7.0.2": [
114
+ "node_modules/http-proxy-agent"
115
+ ],
116
+ "https-proxy-agent@7.0.6": [
117
+ "node_modules/https-proxy-agent"
118
+ ],
119
+ "agent-base@7.1.4": [
120
+ "node_modules/agent-base"
121
+ ],
122
+ "socks-proxy-agent@8.0.5": [
123
+ "node_modules/socks-proxy-agent"
124
+ ],
125
+ "lru-cache@10.4.3": [
126
+ "node_modules/lru-cache"
106
127
  ],
107
128
  "unique-filename@4.0.0": [
108
129
  "node_modules/unique-filename"
@@ -110,41 +131,26 @@
110
131
  "minipass-collect@2.0.1": [
111
132
  "node_modules/minipass-collect"
112
133
  ],
113
- "@npmcli/fs@4.0.0": [
114
- "node_modules/@npmcli/fs"
115
- ],
116
134
  "fs-minipass@3.0.3": [
117
135
  "node_modules/fs-minipass"
118
136
  ],
119
137
  "p-map@7.0.4": [
120
138
  "node_modules/p-map"
121
139
  ],
122
- "lru-cache@10.4.3": [
123
- "node_modules/lru-cache"
140
+ "@npmcli/fs@4.0.0": [
141
+ "node_modules/@npmcli/fs"
124
142
  ],
125
143
  "glob@10.5.0": [
126
144
  "node_modules/glob"
127
145
  ],
128
- "retry@0.12.0": [
129
- "node_modules/retry"
130
- ],
131
- "err-code@2.0.3": [
132
- "node_modules/err-code"
133
- ],
134
146
  "encoding@0.1.13": [
135
147
  "node_modules/encoding"
136
148
  ],
137
- "https-proxy-agent@7.0.6": [
138
- "node_modules/https-proxy-agent"
139
- ],
140
- "http-proxy-agent@7.0.2": [
141
- "node_modules/http-proxy-agent"
142
- ],
143
- "socks-proxy-agent@8.0.5": [
144
- "node_modules/socks-proxy-agent"
149
+ "debug@4.4.3": [
150
+ "node_modules/debug"
145
151
  ],
146
- "agent-base@7.1.4": [
147
- "node_modules/agent-base"
152
+ "socks@2.8.7": [
153
+ "node_modules/socks"
148
154
  ],
149
155
  "unique-slug@5.0.0": [
150
156
  "node_modules/unique-slug"
@@ -161,30 +167,33 @@
161
167
  "path-scurry@1.11.1": [
162
168
  "node_modules/path-scurry"
163
169
  ],
164
- "minimatch@9.0.6": [
170
+ "minimatch@9.0.7": [
165
171
  "node_modules/minimatch"
166
172
  ],
167
173
  "iconv-lite@0.6.3": [
168
174
  "node_modules/iconv-lite"
169
175
  ],
170
- "debug@4.4.3": [
171
- "node_modules/debug"
176
+ "ms@2.1.3": [
177
+ "node_modules/ms"
172
178
  ],
173
- "socks@2.8.7": [
174
- "node_modules/socks"
179
+ "ip-address@10.1.0": [
180
+ "node_modules/ip-address"
181
+ ],
182
+ "smart-buffer@4.2.0": [
183
+ "node_modules/smart-buffer"
175
184
  ],
176
185
  "imurmurhash@0.1.4": [
177
186
  "node_modules/imurmurhash"
178
187
  ],
179
- "signal-exit@4.1.0": [
180
- "node_modules/signal-exit"
181
- ],
182
188
  "which@2.0.2": [
183
189
  "node_modules/cross-spawn/node_modules/which"
184
190
  ],
185
191
  "isexe@2.0.0": [
186
192
  "node_modules/cross-spawn/node_modules/isexe"
187
193
  ],
194
+ "signal-exit@4.1.0": [
195
+ "node_modules/signal-exit"
196
+ ],
188
197
  "@isaacs/cliui@8.0.2": [
189
198
  "node_modules/@isaacs/cliui"
190
199
  ],
@@ -197,21 +206,20 @@
197
206
  "safer-buffer@2.1.2": [
198
207
  "node_modules/safer-buffer"
199
208
  ],
200
- "ms@2.1.3": [
201
- "node_modules/ms"
202
- ],
203
- "smart-buffer@4.2.0": [
204
- "node_modules/smart-buffer"
205
- ],
206
- "ip-address@10.1.0": [
207
- "node_modules/ip-address"
208
- ],
209
209
  "shebang-command@2.0.0": [
210
210
  "node_modules/shebang-command"
211
211
  ],
212
212
  "path-key@3.1.1": [
213
213
  "node_modules/path-key"
214
214
  ],
215
+ "strip-ansi@7.1.2": [
216
+ "node_modules/strip-ansi"
217
+ ],
218
+ "ansi-regex@5.0.1": [
219
+ "node_modules/strip-ansi-cjs/node_modules/ansi-regex",
220
+ "node_modules/wrap-ansi-cjs/node_modules/ansi-regex",
221
+ "node_modules/string-width-cjs/node_modules/ansi-regex"
222
+ ],
215
223
  "wrap-ansi@8.1.0": [
216
224
  "node_modules/wrap-ansi"
217
225
  ],
@@ -227,18 +235,10 @@
227
235
  "ansi-styles@4.3.0": [
228
236
  "node_modules/wrap-ansi-cjs/node_modules/ansi-styles"
229
237
  ],
230
- "ansi-regex@5.0.1": [
231
- "node_modules/wrap-ansi-cjs/node_modules/ansi-regex",
232
- "node_modules/strip-ansi-cjs/node_modules/ansi-regex",
233
- "node_modules/string-width-cjs/node_modules/ansi-regex"
234
- ],
235
238
  "emoji-regex@8.0.0": [
236
239
  "node_modules/wrap-ansi-cjs/node_modules/emoji-regex",
237
240
  "node_modules/string-width-cjs/node_modules/emoji-regex"
238
241
  ],
239
- "strip-ansi@7.1.2": [
240
- "node_modules/strip-ansi"
241
- ],
242
242
  "string-width@5.1.2": [
243
243
  "node_modules/string-width"
244
244
  ],
@@ -248,6 +248,9 @@
248
248
  "shebang-regex@3.0.0": [
249
249
  "node_modules/shebang-regex"
250
250
  ],
251
+ "ansi-regex@6.2.2": [
252
+ "node_modules/ansi-regex"
253
+ ],
251
254
  "ansi-styles@6.2.3": [
252
255
  "node_modules/ansi-styles"
253
256
  ],
@@ -257,9 +260,6 @@
257
260
  "color-convert@2.0.1": [
258
261
  "node_modules/color-convert"
259
262
  ],
260
- "ansi-regex@6.2.2": [
261
- "node_modules/ansi-regex"
262
- ],
263
263
  "eastasianwidth@0.2.0": [
264
264
  "node_modules/eastasianwidth"
265
265
  ],
@@ -269,12 +269,12 @@
269
269
  "color-name@1.1.4": [
270
270
  "node_modules/color-name"
271
271
  ],
272
- "minipass-flush@1.0.5": [
273
- "node_modules/minipass-flush"
274
- ],
275
272
  "minipass-pipeline@1.2.4": [
276
273
  "node_modules/minipass-pipeline"
277
274
  ],
275
+ "minipass-flush@1.0.5": [
276
+ "node_modules/minipass-flush"
277
+ ],
278
278
  "minipass-sized@1.0.3": [
279
279
  "node_modules/minipass-sized"
280
280
  ],
@@ -289,7 +289,7 @@
289
289
  "packageManager": "pnpm@10.30.1",
290
290
  "pendingBuilds": [],
291
291
  "publicHoistPattern": [],
292
- "prunedAt": "Mon, 23 Feb 2026 23:54:27 GMT",
292
+ "prunedAt": "Thu, 26 Feb 2026 09:50:16 GMT",
293
293
  "registries": {
294
294
  "default": "https://registry.npmjs.org/",
295
295
  "@jsr": "https://npm.jsr.io/"
@@ -224,8 +224,8 @@ packages:
224
224
  resolution: {integrity: sha512-QMjGbFTP0blj97EeidG5hk/QhKQ3T4ICckQGLgz38QF7Vgbk6e6FTARN8KhKxyBbWn8R0HU+bnw8aSoFPD4qtQ==}
225
225
  engines: {node: ^18.17.0 || >=20.5.0}
226
226
 
227
- minimatch@9.0.6:
228
- resolution: {integrity: sha512-kQAVowdR33euIqeA0+VZTDqU+qo1IeVY+hrKYtZMio3Pg0P0vuh/kwRylLUddJhB6pf3q/botcOvRtx4IN1wqQ==}
227
+ minimatch@9.0.7:
228
+ resolution: {integrity: sha512-MOwgjc8tfrpn5QQEvjijjmDVtMw2oL88ugTevzxQnzRLm6l3fVEF2gzU0kYeYYKD8C66+IdGX6peJ4MyUlUnPg==}
229
229
  engines: {node: '>=16 || 14 >=14.17'}
230
230
 
231
231
  minipass-collect@2.0.1:
@@ -550,7 +550,7 @@ snapshots:
550
550
  dependencies:
551
551
  foreground-child: 3.3.1
552
552
  jackspeak: 3.4.3
553
- minimatch: 9.0.6
553
+ minimatch: 9.0.7
554
554
  minipass: 7.1.3
555
555
  package-json-from-dist: 1.0.1
556
556
  path-scurry: 1.11.1
@@ -625,7 +625,7 @@ snapshots:
625
625
  - supports-color
626
626
  optional: true
627
627
 
628
- minimatch@9.0.6:
628
+ minimatch@9.0.7:
629
629
  dependencies:
630
630
  brace-expansion: 5.0.3
631
631
  optional: true
@@ -1,5 +1,5 @@
1
1
  {
2
- "lastValidatedTimestamp": 1771890867810,
2
+ "lastValidatedTimestamp": 1772099416124,
3
3
  "projects": {},
4
4
  "pnpmfiles": [],
5
5
  "settings": {
@@ -1 +1 @@
1
- {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAwCvD,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAkCrD,qBAAa,GAAG;;IACd,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;gBAiBtB,IAAI,EAAE,WAAW,GAAG,IAAI,EACxB,MAAM,CAAC,EAAE,GAAG,EACZ,OAAO,GAAE,gBAAqB;IAahC,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAUlC;IAGD,QAAQ,IAAI,MAAM;IA+ClB,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE;IAY/B,MAAM;IAgBN,OAAO,IAAI,OAAO;IAgBlB,KAAK,IAAI,OAAO;IAYhB,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM;IAKzB,KAAK,CAAC,MAAM,EAAE,GAAG;IAsIjB,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB;IAQ/D,WAAW,IAAI,QAAQ,GAAG,MAAM;IA2BhC,IAAI,OAAO,qBAEV;IAuED,cAAc,CACZ,QAAQ,CAAC,EAAE,OAAO,GACjB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC;CAwMjE"}
1
+ {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAwCvD,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAiErD,qBAAa,GAAG;;IACd,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;gBAiBtB,IAAI,EAAE,WAAW,GAAG,IAAI,EACxB,MAAM,CAAC,EAAE,GAAG,EACZ,OAAO,GAAE,gBAAqB;IAahC,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAUlC;IAGD,QAAQ,IAAI,MAAM;IA+ClB,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE;IAY/B,MAAM;IAgBN,OAAO,IAAI,OAAO;IAgBlB,KAAK,IAAI,OAAO;IAYhB,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM;IAKzB,KAAK,CAAC,MAAM,EAAE,GAAG;IA0RjB,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB;IAQ/D,WAAW,IAAI,QAAQ,GAAG,MAAM;IA2BhC,IAAI,OAAO,qBAEV;IAuED,cAAc,CACZ,QAAQ,CAAC,EAAE,OAAO,GACjB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC;CA4MjE"}
@@ -1,11 +1,38 @@
1
1
  "use strict";
2
2
  // parse a single path portion
3
+ var _a;
3
4
  Object.defineProperty(exports, "__esModule", { value: true });
4
5
  exports.AST = void 0;
5
6
  const brace_expressions_js_1 = require("./brace-expressions.js");
6
7
  const unescape_js_1 = require("./unescape.js");
7
8
  const types = new Set(['!', '?', '+', '*', '@']);
8
9
  const isExtglobType = (c) => types.has(c);
10
+ const isExtglobAST = (c) => isExtglobType(c.type);
11
+ const adoptionMap = new Map([
12
+ ['!', ['@']],
13
+ ['?', ['?', '@']],
14
+ ['@', ['@']],
15
+ ['*', ['*', '+', '?', '@']],
16
+ ['+', ['+', '@']],
17
+ ]);
18
+ const adoptionWithSpaceMap = new Map([
19
+ ['!', ['?']],
20
+ ['@', ['?']],
21
+ ['+', ['?', '*']],
22
+ ]);
23
+ const adoptionAnyMap = new Map([
24
+ ['!', ['?', '@']],
25
+ ['?', ['?', '@']],
26
+ ['@', ['?', '@']],
27
+ ['*', ['*', '+', '?', '@']],
28
+ ['+', ['+', '@', '?', '*']],
29
+ ]);
30
+ const usurpMap = new Map([
31
+ ['!', new Map([['!', '@']])],
32
+ ['?', new Map([['*', '*'], ['+', '*']])],
33
+ ['@', new Map([['!', '!'], ['?', '?'], ['@', '@'], ['*', '*'], ['+', '+']])],
34
+ ['+', new Map([['?', '*'], ['*', '*']])],
35
+ ]);
9
36
  // Patterns that get prepended to bind to the start of either the
10
37
  // entire string, or just a single path portion, to prevent dots
11
38
  // and/or traversal patterns, when needed.
@@ -122,7 +149,7 @@ class AST {
122
149
  if (p === '')
123
150
  continue;
124
151
  /* c8 ignore start */
125
- if (typeof p !== 'string' && !(p instanceof AST && p.#parent === this)) {
152
+ if (typeof p !== 'string' && !(p instanceof _a && p.#parent === this)) {
126
153
  throw new Error('invalid part: ' + p);
127
154
  }
128
155
  /* c8 ignore stop */
@@ -154,7 +181,7 @@ class AST {
154
181
  const p = this.#parent;
155
182
  for (let i = 0; i < this.#parentIndex; i++) {
156
183
  const pp = p.#parts[i];
157
- if (!(pp instanceof AST && pp.type === '!')) {
184
+ if (!(pp instanceof _a && pp.type === '!')) {
158
185
  return false;
159
186
  }
160
187
  }
@@ -182,13 +209,14 @@ class AST {
182
209
  this.push(part.clone(this));
183
210
  }
184
211
  clone(parent) {
185
- const c = new AST(this.type, parent);
212
+ const c = new _a(this.type, parent);
186
213
  for (const p of this.#parts) {
187
214
  c.copyIn(p);
188
215
  }
189
216
  return c;
190
217
  }
191
- static #parseAST(str, ast, pos, opt) {
218
+ static #parseAST(str, ast, pos, opt, extDepth) {
219
+ const maxDepth = opt.maxExtglobRecursion ?? 2;
192
220
  let escaping = false;
193
221
  let inBrace = false;
194
222
  let braceStart = -1;
@@ -225,11 +253,15 @@ class AST {
225
253
  acc += c;
226
254
  continue;
227
255
  }
228
- if (!opt.noext && isExtglobType(c) && str.charAt(i) === '(') {
256
+ const doRecurse = !opt.noext &&
257
+ isExtglobType(c) &&
258
+ str.charAt(i) === '(' &&
259
+ extDepth <= maxDepth;
260
+ if (doRecurse) {
229
261
  ast.push(acc);
230
262
  acc = '';
231
- const ext = new AST(c, ast);
232
- i = AST.#parseAST(str, ext, i, opt);
263
+ const ext = new _a(c, ast);
264
+ i = _a.#parseAST(str, ext, i, opt, extDepth + 1);
233
265
  ast.push(ext);
234
266
  continue;
235
267
  }
@@ -241,7 +273,7 @@ class AST {
241
273
  // some kind of extglob, pos is at the (
242
274
  // find the next | or )
243
275
  let i = pos + 1;
244
- let part = new AST(null, ast);
276
+ let part = new _a(null, ast);
245
277
  const parts = [];
246
278
  let acc = '';
247
279
  while (i < str.length) {
@@ -272,19 +304,25 @@ class AST {
272
304
  acc += c;
273
305
  continue;
274
306
  }
275
- if (isExtglobType(c) && str.charAt(i) === '(') {
307
+ const doRecurse = isExtglobType(c) &&
308
+ str.charAt(i) === '(' &&
309
+ /* c8 ignore start - the maxDepth is sufficient here */
310
+ (extDepth <= maxDepth || (ast && ast.#canAdoptType(c)));
311
+ /* c8 ignore stop */
312
+ if (doRecurse) {
313
+ const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
276
314
  part.push(acc);
277
315
  acc = '';
278
- const ext = new AST(c, part);
316
+ const ext = new _a(c, part);
279
317
  part.push(ext);
280
- i = AST.#parseAST(str, ext, i, opt);
318
+ i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
281
319
  continue;
282
320
  }
283
321
  if (c === '|') {
284
322
  part.push(acc);
285
323
  acc = '';
286
324
  parts.push(part);
287
- part = new AST(null, ast);
325
+ part = new _a(null, ast);
288
326
  continue;
289
327
  }
290
328
  if (c === ')') {
@@ -306,9 +344,115 @@ class AST {
306
344
  ast.#parts = [str.substring(pos - 1)];
307
345
  return i;
308
346
  }
347
+ #canAdoptWithSpace(child) {
348
+ return this.#canAdopt(child, adoptionWithSpaceMap);
349
+ }
350
+ #canAdopt(child, map = adoptionMap) {
351
+ if (!child ||
352
+ typeof child !== 'object' ||
353
+ child.type !== null ||
354
+ child.#parts.length !== 1 ||
355
+ this.type === null) {
356
+ return false;
357
+ }
358
+ const gc = child.#parts[0];
359
+ if (!gc || typeof gc !== 'object' || gc.type === null) {
360
+ return false;
361
+ }
362
+ return this.#canAdoptType(gc.type, map);
363
+ }
364
+ #canAdoptType(c, map = adoptionAnyMap) {
365
+ return !!map.get(this.type)?.includes(c);
366
+ }
367
+ #adoptWithSpace(child, index) {
368
+ const gc = child.#parts[0];
369
+ const blank = new _a(null, gc, this.options);
370
+ blank.#parts.push('');
371
+ gc.push(blank);
372
+ this.#adopt(child, index);
373
+ }
374
+ #adopt(child, index) {
375
+ const gc = child.#parts[0];
376
+ this.#parts.splice(index, 1, ...gc.#parts);
377
+ for (const p of gc.#parts) {
378
+ if (typeof p === 'object')
379
+ p.#parent = this;
380
+ }
381
+ this.#toString = undefined;
382
+ }
383
+ #canUsurpType(c) {
384
+ const m = usurpMap.get(this.type);
385
+ return !!(m?.has(c));
386
+ }
387
+ #canUsurp(child) {
388
+ if (!child ||
389
+ typeof child !== 'object' ||
390
+ child.type !== null ||
391
+ child.#parts.length !== 1 ||
392
+ this.type === null ||
393
+ this.#parts.length !== 1) {
394
+ return false;
395
+ }
396
+ const gc = child.#parts[0];
397
+ if (!gc || typeof gc !== 'object' || gc.type === null) {
398
+ return false;
399
+ }
400
+ return this.#canUsurpType(gc.type);
401
+ }
402
+ #usurp(child) {
403
+ const m = usurpMap.get(this.type);
404
+ const gc = child.#parts[0];
405
+ const nt = m?.get(gc.type);
406
+ /* c8 ignore start - impossible */
407
+ if (!nt)
408
+ return false;
409
+ /* c8 ignore stop */
410
+ this.#parts = gc.#parts;
411
+ for (const p of this.#parts) {
412
+ if (typeof p === 'object')
413
+ p.#parent = this;
414
+ }
415
+ this.type = nt;
416
+ this.#toString = undefined;
417
+ this.#emptyExt = false;
418
+ }
419
+ #flatten() {
420
+ if (!isExtglobAST(this)) {
421
+ for (const p of this.#parts) {
422
+ if (typeof p === 'object')
423
+ p.#flatten();
424
+ }
425
+ }
426
+ else {
427
+ let iterations = 0;
428
+ let done = false;
429
+ do {
430
+ done = true;
431
+ for (let i = 0; i < this.#parts.length; i++) {
432
+ const c = this.#parts[i];
433
+ if (typeof c === 'object') {
434
+ c.#flatten();
435
+ if (this.#canAdopt(c)) {
436
+ done = false;
437
+ this.#adopt(c, i);
438
+ }
439
+ else if (this.#canAdoptWithSpace(c)) {
440
+ done = false;
441
+ this.#adoptWithSpace(c, i);
442
+ }
443
+ else if (this.#canUsurp(c)) {
444
+ done = false;
445
+ this.#usurp(c);
446
+ }
447
+ }
448
+ }
449
+ } while (!done && ++iterations < 10);
450
+ }
451
+ this.#toString = undefined;
452
+ }
309
453
  static fromGlob(pattern, options = {}) {
310
- const ast = new AST(null, undefined, options);
311
- AST.#parseAST(pattern, ast, 0, options);
454
+ const ast = new _a(null, undefined, options);
455
+ _a.#parseAST(pattern, ast, 0, options, 0);
312
456
  return ast;
313
457
  }
314
458
  // returns the regular expression if there's magic, or the unescaped
@@ -412,14 +556,16 @@ class AST {
412
556
  // or start or whatever) and prepend ^ or / at the Regexp construction.
413
557
  toRegExpSource(allowDot) {
414
558
  const dot = allowDot ?? !!this.#options.dot;
415
- if (this.#root === this)
559
+ if (this.#root === this) {
560
+ this.#flatten();
416
561
  this.#fillNegs();
417
- if (!this.type) {
562
+ }
563
+ if (!isExtglobAST(this)) {
418
564
  const noEmpty = this.isStart() && this.isEnd();
419
565
  const src = this.#parts
420
566
  .map(p => {
421
567
  const [re, _, hasMagic, uflag] = typeof p === 'string'
422
- ? AST.#parseGlob(p, this.#hasMagic, noEmpty)
568
+ ? _a.#parseGlob(p, this.#hasMagic, noEmpty)
423
569
  : p.toRegExpSource(allowDot);
424
570
  this.#hasMagic = this.#hasMagic || hasMagic;
425
571
  this.#uflag = this.#uflag || uflag;
@@ -478,9 +624,10 @@ class AST {
478
624
  // invalid extglob, has to at least be *something* present, if it's
479
625
  // the entire path portion.
480
626
  const s = this.toString();
481
- this.#parts = [s];
482
- this.type = null;
483
- this.#hasMagic = undefined;
627
+ const me = this;
628
+ me.#parts = [s];
629
+ me.type = null;
630
+ me.#hasMagic = undefined;
484
631
  return [s, (0, unescape_js_1.unescape)(this.toString()), false, false];
485
632
  }
486
633
  // XXX abstract out this map method
@@ -596,4 +743,5 @@ class AST {
596
743
  }
597
744
  }
598
745
  exports.AST = AST;
746
+ _a = AST;
599
747
  //# sourceMappingURL=ast.js.map