@mnemonik/cli 7.114.2 → 7.115.0

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.
@@ -39,13 +39,15 @@ var require_ignore = __commonJS({
39
39
  var EMPTY = "";
40
40
  var SPACE = " ";
41
41
  var ESCAPE = "\\";
42
- var REGEX_TEST_BLANK_LINE = /^\s+$/;
42
+ var REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
43
+ var BOM = "\uFEFF";
43
44
  var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
44
45
  var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
45
46
  var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
46
47
  var REGEX_SPLITALL_CRLF = /\r?\n/g;
47
- var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
48
- var REGEX_TEST_TRAILING_SLASH = /\/$/;
48
+ var DOUBLE_SLASH = "//";
49
+ var SLASH_CODE = 47;
50
+ var DOT_CODE = 46;
49
51
  var SLASH = "/";
50
52
  var TMP_KEY_IGNORE = "node-ignore";
51
53
  if (typeof Symbol !== "undefined") {
@@ -56,44 +58,173 @@ var require_ignore = __commonJS({
56
58
  Object.defineProperty(object, key, { value });
57
59
  return value;
58
60
  };
59
- var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
60
61
  var RETURN_FALSE = () => false;
61
- var sanitizeRange = (range) => range.replace(
62
- REGEX_REGEXP_RANGE,
63
- (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
64
- );
65
- var negateRange = (range) => range.startsWith("!") || range.startsWith("\\^") ? `^${range.slice(range[0] === "!" ? 1 : 2)}` : range;
66
62
  var cleanRangeBackSlash = (slashes) => {
67
63
  const { length } = slashes;
68
64
  return slashes.slice(0, length - length % 2);
69
65
  };
66
+ var POSIX_CLASSES = {
67
+ alnum: "0-9A-Za-z",
68
+ alpha: "A-Za-z",
69
+ blank: " \\t",
70
+ cntrl: "\\x00-\\x1f\\x7f",
71
+ digit: "0-9",
72
+ graph: "!-.0-~",
73
+ lower: "a-z",
74
+ print: " -.0-~",
75
+ punct: "!-.:-@\\[-`{-~",
76
+ // git's `sane-ctype.h` classifies \v and \f as control, not space,
77
+ // unlike C's `isspace`
78
+ space: " \\t\\n\\r",
79
+ upper: "A-Z",
80
+ xdigit: "0-9A-Fa-f"
81
+ };
82
+ var CLASS_MEMBERS_TO_ESCAPE = "\\]^-[";
83
+ var escapeMember = (char) => CLASS_MEMBERS_TO_ESCAPE.indexOf(char) < 0 ? char : ESCAPE + char;
84
+ var NON_SLASH = "(?!\\/)";
85
+ var classSource = (negated, body2) => {
86
+ if (negated) {
87
+ return `[^\\/${body2}]`;
88
+ }
89
+ const source = `[${body2}]`;
90
+ return new RegExp(source).test("/") ? NON_SLASH + source : source;
91
+ };
92
+ var scanBracket = (pattern, start2) => {
93
+ const { length } = pattern;
94
+ let index = start2 + 1;
95
+ let negated = EMPTY;
96
+ const lead = pattern[index];
97
+ if (lead === "!" || lead === "^") {
98
+ negated = "^";
99
+ index++;
100
+ }
101
+ let body2 = EMPTY;
102
+ let prev = EMPTY;
103
+ for (; ; ) {
104
+ const char = pattern[index];
105
+ if (char === UNDEFINED) {
106
+ return null;
107
+ }
108
+ if (char === ESCAPE) {
109
+ const escaped = pattern[index + 1];
110
+ if (escaped === UNDEFINED) {
111
+ return null;
112
+ }
113
+ body2 += escapeMember(escaped);
114
+ prev = escaped;
115
+ index++;
116
+ } else if (char === "-" && prev && index + 1 < length && pattern[index + 1] !== "]") {
117
+ index++;
118
+ let to = pattern[index];
119
+ if (to === ESCAPE) {
120
+ to = pattern[index += 1];
121
+ }
122
+ if (prev <= to) {
123
+ body2 += `-${escapeMember(to)}`;
124
+ }
125
+ prev = EMPTY;
126
+ } else if (char === "[" && pattern[index + 1] === ":") {
127
+ const nameStart = index + 2;
128
+ let end = nameStart;
129
+ while (end < length && pattern[end] !== "]") {
130
+ end++;
131
+ }
132
+ if (end === length) {
133
+ return null;
134
+ }
135
+ if (end > nameStart && pattern[end - 1] === ":") {
136
+ const expanded = POSIX_CLASSES[pattern.slice(nameStart, end - 1)];
137
+ if (expanded === UNDEFINED) {
138
+ return null;
139
+ }
140
+ body2 += expanded;
141
+ prev = EMPTY;
142
+ index = end;
143
+ } else {
144
+ body2 += escapeMember("[");
145
+ prev = "[";
146
+ index = nameStart - 2;
147
+ }
148
+ } else {
149
+ body2 += escapeMember(char);
150
+ prev = char;
151
+ }
152
+ index++;
153
+ if (pattern[index] === "]") {
154
+ return {
155
+ end: index,
156
+ source: classSource(negated, body2)
157
+ };
158
+ }
159
+ }
160
+ };
161
+ var NEVER_MATCH = "[]";
162
+ var PLACEHOLDER = "\0";
163
+ var REGEX_RESTORE_PLACEHOLDER = new RegExp(
164
+ `${PLACEHOLDER}(\\d+)${PLACEHOLDER}`,
165
+ "g"
166
+ );
167
+ var TRAILING_WILDCARD = "\uE000";
168
+ var TRAILING_DOUBLESTAR = "\uE001";
169
+ var extractBrackets = (pattern) => {
170
+ const sources = [];
171
+ const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
172
+ const { length } = pattern;
173
+ let out2 = EMPTY;
174
+ let index = 0;
175
+ while (index < length) {
176
+ const char = pattern[index];
177
+ if (char === ESCAPE) {
178
+ const escaped = pattern[index + 1];
179
+ if (escaped === UNDEFINED || escaped === SLASH && index + 2 === length) {
180
+ out2 += hold(NEVER_MATCH);
181
+ } else if (escaped === "*" || escaped === "[" || escaped === SPACE || escaped === ESCAPE) {
182
+ out2 += pattern.slice(index, index + 2);
183
+ } else {
184
+ out2 += hold(
185
+ REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : escaped
186
+ );
187
+ }
188
+ index += 2;
189
+ } else if (char === PLACEHOLDER) {
190
+ out2 += hold(`[${PLACEHOLDER}]`);
191
+ index++;
192
+ } else if (char === "[") {
193
+ const scanned = scanBracket(pattern, index);
194
+ if (scanned === null) {
195
+ out2 += hold(NEVER_MATCH);
196
+ index = length;
197
+ } else {
198
+ out2 += hold(scanned.source);
199
+ index = scanned.end + 1;
200
+ }
201
+ } else {
202
+ out2 += char;
203
+ index++;
204
+ }
205
+ }
206
+ return {
207
+ source: out2,
208
+ sources
209
+ };
210
+ };
211
+ var DIRECT = null;
212
+ var REGEX_INNER_SLASH = /\/(?!$)/;
70
213
  var REPLACERS = [
71
- [
72
- // Remove BOM
73
- // TODO:
74
- // Other similar zero-width characters?
75
- /^\uFEFF/,
76
- () => EMPTY
77
- ],
78
- // > Trailing spaces are ignored unless they are quoted with backslash ("\")
79
- [
80
- // (a\ ) -> (a )
81
- // (a ) -> (a)
82
- // (a ) -> (a)
83
- // (a \ ) -> (a )
84
- /((?:\\\\)*?)(\\?\s+)$/,
85
- (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
86
- ],
87
214
  // Replace (\ ) with ' '
215
+ // Only a space: an escaped tab or other whitespace is already a literal by
216
+ // the time it reaches here, and a bare tab must be left as one, not turned
217
+ // into a space.
88
218
  // (\ ) -> ' '
89
219
  // (\\ ) -> '\\ '
90
220
  // (\\\ ) -> '\\ '
91
221
  [
92
- /(\\+?)\s/g,
93
- (_, m1) => {
94
- const { length } = m1;
95
- return m1.slice(0, length - length % 2) + SPACE;
96
- }
222
+ // A run of backslashes is taken whole, from its first one, so no match
223
+ // ever starts again inside it -- `(\\+?) ` did, which made a long run
224
+ // quadratic.
225
+ /(\\+)( ?)/g,
226
+ (_, run2, space) => space ? run2.slice(0, run2.length - run2.length % 2) + SPACE : run2,
227
+ ESCAPE + SPACE
97
228
  ],
98
229
  // Escape metacharacters
99
230
  // which is written down by users but means special for regular expressions.
@@ -118,7 +249,8 @@ var require_ignore = __commonJS({
118
249
  [
119
250
  // > a question mark (?) matches a single character
120
251
  /(?!\\)\?/g,
121
- () => "[^/]"
252
+ () => "[^/]",
253
+ "?"
122
254
  ],
123
255
  // leading slash
124
256
  [
@@ -126,12 +258,14 @@ var require_ignore = __commonJS({
126
258
  // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
127
259
  // A leading slash matches the beginning of the pathname
128
260
  /^\//,
129
- () => "^"
261
+ () => "^",
262
+ SLASH
130
263
  ],
131
264
  // replace special metacharacter slash after the leading slash
132
265
  [
133
266
  /\//g,
134
- () => "\\/"
267
+ () => "\\/",
268
+ SLASH
135
269
  ],
136
270
  [
137
271
  // > A leading "**" followed by a slash means match in all directories.
@@ -142,16 +276,21 @@ var require_ignore = __commonJS({
142
276
  // Notice that the '*'s have been replaced as '\\*'
143
277
  /^\^*(?:\\\*\\\*\\\/)+/,
144
278
  // '**/foo' <-> 'foo'
145
- () => "^(?:.*\\/)?"
279
+ () => "^(?:.*\\/)?",
280
+ "*"
146
281
  ],
147
282
  // starting
148
283
  [
149
284
  // there will be no leading '/'
150
285
  // (which has been replaced by section "leading slash")
151
286
  // If starts with '**', adding a '^' to the regular expression also works
152
- /^(?=[^^])/,
153
- function startingReplacer() {
154
- return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
287
+ DIRECT,
288
+ (source, pattern) => {
289
+ if (!source || source[0] === "^") {
290
+ return source;
291
+ }
292
+ const anchor = !REGEX_INNER_SLASH.test(pattern) ? "(?:^|\\/)" : "^";
293
+ return anchor + source;
155
294
  }
156
295
  ],
157
296
  // two globstars
@@ -161,7 +300,8 @@ var require_ignore = __commonJS({
161
300
  // Zero, one or several directories
162
301
  // should not use '*', or it will be replaced by the next replacer
163
302
  // Check if it is not the last `'/**'`
164
- (_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
303
+ (_, index, str) => index + 6 < str.length ? str.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
304
+ "*"
165
305
  ],
166
306
  // normal intermediate wildcards
167
307
  [
@@ -176,32 +316,56 @@ var require_ignore = __commonJS({
176
316
  (_, p1, p2) => {
177
317
  const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
178
318
  return p1 + unescaped;
179
- }
319
+ },
320
+ "*"
321
+ ],
322
+ // trailing wildcard, held apart from a literal star
323
+ [
324
+ // The step above leaves a trailing `*` alone, so a single `\*` is all that
325
+ // can be left at the end here. Whether it is a wildcard or a literal
326
+ // turns on the backslashes the user put in front of it: the escaper has
327
+ // since doubled every one, so what stands here is those `2N` doubled
328
+ // backslashes and then the star's own escape. An even number of the
329
+ // original `N` leaves the star unescaped -- a wildcard -- and an odd
330
+ // number escapes it -- a literal. This runs while the two are still
331
+ // distinct, before the unescape steps below collapse the literal onto
332
+ // the very `\*` a wildcard leaves behind.
333
+ /(^|[^\\])((?:\\\\)*)\\\*$/,
334
+ (match, p1, p2) => (
335
+ // `p2` holds the doubled user backslashes; half of them is `N`.
336
+ p2.length / 2 % 2 === 0 ? p1 + p2 + TRAILING_WILDCARD : match
337
+ ),
338
+ "*"
180
339
  ],
181
340
  [
182
341
  // unescape, revert step 3 except for back slash
183
342
  // For example, if a user escape a '\\*',
184
343
  // after step 3, the result will be '\\\\\\*'
185
344
  /\\\\\\(?=[$.|*+(){^])/g,
186
- () => ESCAPE
345
+ () => ESCAPE,
346
+ ESCAPE + ESCAPE
187
347
  ],
188
348
  [
189
349
  // '\\\\' -> '\\'
190
350
  /\\\\/g,
191
- () => ESCAPE
351
+ () => ESCAPE,
352
+ ESCAPE + ESCAPE
192
353
  ],
193
354
  [
194
- // > The range notation, e.g. [a-zA-Z],
195
- // > can be used to match one of the characters in a range.
355
+ // Every real bracket expression -- POSIX classes included -- has already
356
+ // been held aside by `extractBrackets`, so the only `[` left in the
357
+ // pattern is an escaped, literal one.
196
358
  // `\` is escaped by step 3
197
- /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
198
- (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${negateRange(sanitizeRange(range))}${endEscape}]` : "[]" : "[]"
359
+ /\\\[([^\]/]*?)(\\*)($|\])/g,
360
+ // '\\[bar]' -> '\\\\[bar\\]'
361
+ (match, range, endEscape, close) => `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`,
362
+ "["
199
363
  ],
200
364
  // ending
201
365
  [
202
366
  // 'js' will not match 'js.'
203
367
  // 'ab' will not match 'abc'
204
- /(?:[^*])$/,
368
+ DIRECT,
205
369
  // WTF!
206
370
  // https://git-scm.com/docs/gitignore
207
371
  // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
@@ -212,29 +376,175 @@ var require_ignore = __commonJS({
212
376
  // 'js*' will not match 'a.js'
213
377
  // 'js/' will not match 'a.js'
214
378
  // 'js' will match 'a.js' and 'a.js/'
215
- (match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
379
+ (source) => {
380
+ const last = source[source.length - 1];
381
+ if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) {
382
+ return source;
383
+ }
384
+ return last === SLASH ? `${source}$` : `${source}(?=$|\\/$)`;
385
+ }
216
386
  ]
217
387
  ];
218
- var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
388
+ var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/;
219
389
  var MODE_IGNORE = "regex";
220
390
  var MODE_CHECK_IGNORE = "checkRegex";
221
391
  var UNDERSCORE = "_";
222
- var TRAILING_WILD_CARD_REPLACERS = {
223
- [MODE_IGNORE](_, p1) {
224
- const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
225
- return `${prefix}(?=$|\\/$)`;
226
- },
227
- [MODE_CHECK_IGNORE](_, p1) {
228
- const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
229
- return `${prefix}(?=$|\\/$)`;
392
+ var replaceTrailingWildcard = (_, p1) => {
393
+ const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
394
+ return `${prefix}(?=$|\\/$)`;
395
+ };
396
+ var REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
397
+ var replaceTrailingDoublestar = () => ".+(?=$|\\/$)";
398
+ var WILDCARD = "[^\\/]*";
399
+ var separatorAfter = (run2, at) => {
400
+ let separator = EMPTY;
401
+ for (let index = at + 1; index < run2.length && !run2[index].wildcard; index++) {
402
+ separator += run2[index].single;
230
403
  }
404
+ return separator;
405
+ };
406
+ var pinWildcards = (source) => {
407
+ if (source.indexOf(WILDCARD) < 0) {
408
+ return source;
409
+ }
410
+ const tokens = [];
411
+ const { length } = source;
412
+ let index = 0;
413
+ while (index < length) {
414
+ const char = source[index];
415
+ if (source.startsWith(WILDCARD, index)) {
416
+ tokens.push({ wildcard: true });
417
+ index += WILDCARD.length;
418
+ } else if (char === "[") {
419
+ let end = index + 1;
420
+ if (source[end] === "^") {
421
+ end++;
422
+ }
423
+ if (source[end] === "]") {
424
+ end++;
425
+ }
426
+ while (end < length && source[end] !== "]") {
427
+ end += source[end] === ESCAPE ? 2 : 1;
428
+ }
429
+ end++;
430
+ tokens.push({ single: source.slice(index, end) });
431
+ index = end;
432
+ } else if (char === ESCAPE) {
433
+ tokens.push({ single: source.slice(index, index + 2) });
434
+ index += 2;
435
+ } else if (char === "(") {
436
+ let depth = 0;
437
+ let end = index;
438
+ do {
439
+ if (source[end] === ESCAPE) {
440
+ end++;
441
+ } else if (source[end] === "(") {
442
+ depth++;
443
+ } else if (source[end] === ")") {
444
+ depth--;
445
+ }
446
+ end++;
447
+ } while (end < length && depth > 0);
448
+ if ("*+?".indexOf(source[end]) >= 0) {
449
+ end++;
450
+ }
451
+ tokens.push({ boundary: source.slice(index, end) });
452
+ index = end;
453
+ } else if (char === "^" || char === "$") {
454
+ tokens.push({ boundary: char });
455
+ index++;
456
+ } else {
457
+ tokens.push({ single: char });
458
+ index++;
459
+ }
460
+ }
461
+ let out2 = EMPTY;
462
+ let run2 = [];
463
+ const flush = () => {
464
+ let lastWildcard;
465
+ run2.forEach((token, at) => {
466
+ if (token.wildcard) {
467
+ lastWildcard = at;
468
+ }
469
+ });
470
+ run2.forEach((token, at) => {
471
+ if (!token.wildcard) {
472
+ out2 += token.single;
473
+ return;
474
+ }
475
+ out2 += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run2, at)})[^\\/])*`;
476
+ });
477
+ run2 = [];
478
+ };
479
+ tokens.forEach((token) => {
480
+ if (token.boundary === void 0) {
481
+ run2.push(token);
482
+ return;
483
+ }
484
+ flush();
485
+ out2 += token.boundary;
486
+ });
487
+ flush();
488
+ return out2;
489
+ };
490
+ var makeRegexPrefix = (pattern) => {
491
+ const { source, sources } = extractBrackets(pattern);
492
+ const replaced = REPLACERS.reduce(
493
+ // A pass whose matcher finds nothing hands back the very string it was
494
+ // given, so asking first costs a search and saves a rewrite. Ten of the
495
+ // fifteen passes never fire for a typical .gitignore line, and between
496
+ // them they were 45% of this chain.
497
+ (prev, [matcher, replacer, required]) => {
498
+ if (matcher === DIRECT) {
499
+ return replacer(prev, pattern);
500
+ }
501
+ if (required !== UNDEFINED && prev.indexOf(required) < 0) {
502
+ return prev;
503
+ }
504
+ return matcher.test(prev) ? prev.replace(matcher, replacer.bind(pattern)) : prev;
505
+ },
506
+ source
507
+ );
508
+ return sources.length ? replaced.replace(
509
+ REGEX_RESTORE_PLACEHOLDER,
510
+ (match, index) => sources[index]
511
+ ) : replaced;
512
+ };
513
+ var checkSourceOf = (body2, prefix) => {
514
+ if (body2[body2.length - 1] === SLASH) {
515
+ prefix = makeRegexPrefix(body2.slice(0, -1));
516
+ }
517
+ const head = prefix.slice(0, -1);
518
+ const last = prefix[prefix.length - 1];
519
+ return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? `${head}.*$` : NEVER_MATCH;
520
+ };
521
+ var matchesBasename = (body2) => {
522
+ const index = body2.indexOf(SLASH);
523
+ return index < 0 || index === body2.length - 1;
524
+ };
525
+ var basenameOf = (path) => {
526
+ const end = path.length - 1;
527
+ const index = path.lastIndexOf(
528
+ SLASH,
529
+ path[end] === SLASH ? end - 1 : end
530
+ );
531
+ return index < 0 ? path : path.slice(index + 1);
532
+ };
533
+ var parentOf = (path) => {
534
+ if (path.charCodeAt(0) === SLASH_CODE || path.indexOf(DOUBLE_SLASH) >= 0) {
535
+ const slices = path.split(SLASH).filter(Boolean);
536
+ slices.pop();
537
+ return slices.length ? slices.join(SLASH) + SLASH : EMPTY;
538
+ }
539
+ const end = path.length - 1;
540
+ const cut = path.lastIndexOf(
541
+ SLASH,
542
+ path.charCodeAt(end) === SLASH_CODE ? end - 1 : end
543
+ );
544
+ return cut < 0 ? EMPTY : path.slice(0, cut + 1);
231
545
  };
232
- var makeRegexPrefix = (pattern) => REPLACERS.reduce(
233
- (prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)),
234
- pattern
235
- );
236
546
  var isString = (subject) => typeof subject === "string";
237
- var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
547
+ var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern);
238
548
  var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
239
549
  var IgnoreRule = class {
240
550
  constructor(pattern, mark, body2, ignoreCase, negative, prefix) {
@@ -245,6 +555,14 @@ var require_ignore = __commonJS({
245
555
  define(this, "ignoreCase", ignoreCase);
246
556
  define(this, "regexPrefix", prefix);
247
557
  }
558
+ // Worked out on first use and kept behind an own property, the way `regex`
559
+ // caches itself in `_regex`. Deciding it in the constructor instead would
560
+ // add a fourth `defineProperty` to every rule ever built, which cost 4% of
561
+ // every compile -- including the compiles of rules that are never matched
562
+ // against anything.
563
+ get _basenameOnly() {
564
+ return define(this, "_basenameOnly", matchesBasename(this.body));
565
+ }
248
566
  get regex() {
249
567
  const key = UNDERSCORE + MODE_IGNORE;
250
568
  if (this[key]) {
@@ -260,24 +578,51 @@ var require_ignore = __commonJS({
260
578
  return this._make(MODE_CHECK_IGNORE, key);
261
579
  }
262
580
  _make(mode, key) {
263
- const str = this.regexPrefix.replace(
264
- REGEX_REPLACE_TRAILING_WILDCARD,
265
- // It does not need to bind pattern
266
- TRAILING_WILD_CARD_REPLACERS[mode]
581
+ const str = pinWildcards(
582
+ mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix)
267
583
  );
268
584
  const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
269
585
  return define(this, key, regex);
270
586
  }
271
587
  };
588
+ var isLineEnd = (char) => char === "\r" || char === "\n";
589
+ var trimEnd = (body2) => {
590
+ let end = body2.length;
591
+ while (end && isLineEnd(body2[end - 1])) {
592
+ end--;
593
+ }
594
+ const lineEnd = end;
595
+ while (end && body2[end - 1] === SPACE) {
596
+ end--;
597
+ }
598
+ if (end === lineEnd) {
599
+ return body2.slice(0, end);
600
+ }
601
+ let backslashes = 0;
602
+ while (backslashes < end && body2[end - backslashes - 1] === ESCAPE) {
603
+ backslashes++;
604
+ }
605
+ return backslashes % 2 ? body2.slice(0, end - 1) + SPACE : body2.slice(0, end);
606
+ };
272
607
  var createRule = ({
273
608
  pattern,
274
609
  mark
275
610
  }, ignoreCase) => {
611
+ let body2 = pattern[0] === BOM ? pattern.slice(1) : pattern;
612
+ if (body2[0] === "#") {
613
+ return;
614
+ }
276
615
  let negative = false;
277
- let body2 = pattern;
278
- if (body2.indexOf("!") === 0) {
616
+ if (body2[0] === "!") {
279
617
  negative = true;
280
- body2 = body2.substr(1);
618
+ body2 = body2.slice(1);
619
+ }
620
+ const last = body2[body2.length - 1];
621
+ if (last === SPACE || last === "\r" || last === "\n") {
622
+ body2 = trimEnd(body2);
623
+ }
624
+ if (!body2) {
625
+ return;
281
626
  }
282
627
  body2 = body2.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
283
628
  const regexPrefix = makeRegexPrefix(body2);
@@ -294,10 +639,12 @@ var require_ignore = __commonJS({
294
639
  constructor(ignoreCase) {
295
640
  this._ignoreCase = ignoreCase;
296
641
  this._rules = [];
642
+ this._basenameCount = 0;
297
643
  }
298
644
  _add(pattern) {
299
645
  if (pattern && pattern[KEY_IGNORE]) {
300
646
  this._rules = this._rules.concat(pattern._rules._rules);
647
+ this._basenameCount += pattern._rules._basenameCount;
301
648
  this._added = true;
302
649
  return;
303
650
  }
@@ -306,10 +653,13 @@ var require_ignore = __commonJS({
306
653
  pattern
307
654
  };
308
655
  }
309
- if (checkPattern(pattern.pattern)) {
310
- const rule = createRule(pattern, this._ignoreCase);
656
+ const rule = checkPattern(pattern.pattern) && createRule(pattern, this._ignoreCase);
657
+ if (rule) {
311
658
  this._added = true;
312
659
  this._rules.push(rule);
660
+ if (matchesBasename(rule.body)) {
661
+ this._basenameCount++;
662
+ }
313
663
  }
314
664
  }
315
665
  // @param {Array<string> | string | Ignore} pattern
@@ -318,8 +668,39 @@ var require_ignore = __commonJS({
318
668
  makeArray(
319
669
  isString(pattern) ? splitPattern(pattern) : pattern
320
670
  ).forEach(this._add, this);
671
+ if (this._added) {
672
+ this._literalRules = UNDEFINED;
673
+ }
321
674
  return this._added;
322
675
  }
676
+ // Match the literal 'abc/' for `checkIgnore`, last rule wins. Only a rule
677
+ // ending in a wildcard can match it (see `checkSourceOf`), so the rest
678
+ // are left out once, rather than tested or compiled for every path.
679
+ testLiteral(path) {
680
+ const rules = this._literalRules || (this._literalRules = this._rules.filter(
681
+ ({ body: body2 }) => body2[body2.length - (body2[body2.length - 1] === SLASH ? 2 : 1)] === "*"
682
+ ));
683
+ let ignored = false;
684
+ let unignored = false;
685
+ let matchedRule;
686
+ for (let index = rules.length - 1; index >= 0; index--) {
687
+ const rule = rules[index];
688
+ if (rule.checkRegex.test(path)) {
689
+ ignored = !rule.negative;
690
+ unignored = rule.negative;
691
+ matchedRule = rule.negative ? UNDEFINED : rule;
692
+ break;
693
+ }
694
+ }
695
+ const ret = {
696
+ ignored,
697
+ unignored
698
+ };
699
+ if (matchedRule) {
700
+ ret.rule = matchedRule;
701
+ }
702
+ return ret;
703
+ }
323
704
  // Test one single path without recursively checking parent directories
324
705
  //
325
706
  // - checkUnignored `boolean` whether should check if the path is unignored,
@@ -331,19 +712,22 @@ var require_ignore = __commonJS({
331
712
  let ignored = false;
332
713
  let unignored = false;
333
714
  let matchedRule;
334
- this._rules.forEach((rule) => {
715
+ const rules = this._rules;
716
+ const { length } = rules;
717
+ const shortcut = this._basenameCount * 2 >= length;
718
+ const basename = shortcut ? basenameOf(path) : path;
719
+ for (let index = 0; index < length; index++) {
720
+ const rule = rules[index];
335
721
  const { negative } = rule;
336
- if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
337
- return;
722
+ const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
723
+ if (!skip && rule[mode].test(
724
+ shortcut && rule._basenameOnly ? basename : path
725
+ )) {
726
+ ignored = !negative;
727
+ unignored = negative;
728
+ matchedRule = negative ? UNDEFINED : rule;
338
729
  }
339
- const matched = rule[mode].test(path);
340
- if (!matched) {
341
- return;
342
- }
343
- ignored = !negative;
344
- unignored = negative;
345
- matchedRule = negative ? UNDEFINED : rule;
346
- });
730
+ }
347
731
  const ret = {
348
732
  ignored,
349
733
  unignored
@@ -376,7 +760,26 @@ var require_ignore = __commonJS({
376
760
  }
377
761
  return true;
378
762
  };
379
- var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
763
+ var isNotRelative = (path) => {
764
+ const first = path.charCodeAt(0);
765
+ if (first === SLASH_CODE) {
766
+ return true;
767
+ }
768
+ if (first !== DOT_CODE) {
769
+ return false;
770
+ }
771
+ if (path.length === 1) {
772
+ return true;
773
+ }
774
+ const second = path.charCodeAt(1);
775
+ if (second === SLASH_CODE) {
776
+ return true;
777
+ }
778
+ if (second !== DOT_CODE) {
779
+ return false;
780
+ }
781
+ return path.length === 2 || path.charCodeAt(2) === SLASH_CODE;
782
+ };
380
783
  checkPath.isNotRelative = isNotRelative;
381
784
  checkPath.convert = (p) => p;
382
785
  var Ignore = class {
@@ -405,52 +808,33 @@ var require_ignore = __commonJS({
405
808
  return this.add(pattern);
406
809
  }
407
810
  // @returns {TestResult}
408
- _test(originalPath, cache, checkUnignored, slices) {
811
+ _test(originalPath, cache, checkUnignored) {
409
812
  const path = originalPath && checkPath.convert(originalPath);
410
813
  checkPath(
411
814
  path,
412
815
  originalPath,
413
816
  this._strictPathCheck ? throwError : RETURN_FALSE
414
817
  );
415
- return this._t(path, cache, checkUnignored, slices);
818
+ return this._t(path, cache, checkUnignored);
416
819
  }
417
820
  checkIgnore(path) {
418
- if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
821
+ if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
419
822
  return this.test(path);
420
823
  }
421
- const slices = path.split(SLASH).filter(Boolean);
422
- slices.pop();
423
- if (slices.length) {
424
- const parent = this._t(
425
- slices.join(SLASH) + SLASH,
426
- this._testCache,
427
- true,
428
- slices
429
- );
430
- if (parent.ignored) {
431
- return parent;
432
- }
824
+ const dir = this._t(path, this._testCache, true);
825
+ if (dir.ignored) {
826
+ return dir;
433
827
  }
434
- return this._rules.test(path, false, MODE_CHECK_IGNORE);
828
+ const literal = this._rules.testLiteral(path);
829
+ return literal.ignored || literal.unignored ? literal : dir;
435
830
  }
436
- _t(path, cache, checkUnignored, slices) {
831
+ _t(path, cache, checkUnignored) {
437
832
  if (path in cache) {
438
833
  return cache[path];
439
834
  }
440
- if (!slices) {
441
- slices = path.split(SLASH).filter(Boolean);
442
- }
443
- slices.pop();
444
- if (!slices.length) {
445
- return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
446
- }
447
- const parent = this._t(
448
- slices.join(SLASH) + SLASH,
449
- cache,
450
- checkUnignored,
451
- slices
452
- );
453
- return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
835
+ const parentPath = parentOf(path);
836
+ const parent = parentPath ? this._t(parentPath, cache, checkUnignored) : UNDEFINED;
837
+ return cache[path] = parent && parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
454
838
  }
455
839
  ignores(path) {
456
840
  return this._test(path, this._ignoreCache, false).ignored;
@@ -707,6 +1091,18 @@ function setModule(module2) {
707
1091
  }
708
1092
  __name(setModule, "setModule");
709
1093
  var C;
1094
+ function newFinalizer(handler) {
1095
+ try {
1096
+ return new FinalizationRegistry(handler);
1097
+ } catch (e) {
1098
+ console.error("Unsupported FinalizationRegistry:", e);
1099
+ return;
1100
+ }
1101
+ }
1102
+ __name(newFinalizer, "newFinalizer");
1103
+ var finalizer = newFinalizer((address) => {
1104
+ C._ts_lookahead_iterator_delete(address);
1105
+ });
710
1106
  var LookaheadIterator = class {
711
1107
  static {
712
1108
  __name(this, "LookaheadIterator");
@@ -717,21 +1113,39 @@ var LookaheadIterator = class {
717
1113
  /** @internal */
718
1114
  language;
719
1115
  /** @internal */
1116
+ positioned = false;
1117
+ /** @internal */
720
1118
  constructor(internal, address, language) {
721
1119
  assertInternal(internal);
722
1120
  this[0] = address;
723
1121
  this.language = language;
1122
+ finalizer?.register(this, address, this);
724
1123
  }
725
- /** Get the current symbol of the lookahead iterator. */
1124
+ /**
1125
+ * Get the current symbol of the lookahead iterator.
1126
+ *
1127
+ * Returns `null` if the iterator is not positioned on a symbol:
1128
+ *
1129
+ * - Before the first iteration step
1130
+ * - After the iterator is exhausted
1131
+ * - After a {@link reset} or {@link resetState} call
1132
+ */
726
1133
  get currentTypeId() {
727
- return C._ts_lookahead_iterator_current_symbol(this[0]);
1134
+ return this.positioned ? C._ts_lookahead_iterator_current_symbol(this[0]) : null;
728
1135
  }
729
- /** Get the current symbol name of the lookahead iterator. */
1136
+ /**
1137
+ * Get the current symbol name of the lookahead iterator.
1138
+ *
1139
+ * Returns `null` if the iterator is not positioned on a symbol.
1140
+ */
730
1141
  get currentType() {
731
- return this.language.types[this.currentTypeId] || "ERROR";
1142
+ const id = this.currentTypeId;
1143
+ if (id === null) return null;
1144
+ return this.language.types[id] ?? C.UTF8ToString(C._ts_language_symbol_name(this.language[0], id));
732
1145
  }
733
1146
  /** Delete the lookahead iterator, freeing its resources. */
734
1147
  delete() {
1148
+ finalizer?.unregister(this);
735
1149
  C._ts_lookahead_iterator_delete(this[0]);
736
1150
  this[0] = 0;
737
1151
  }
@@ -744,6 +1158,7 @@ var LookaheadIterator = class {
744
1158
  reset(language, stateId) {
745
1159
  if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
746
1160
  this.language = language;
1161
+ this.positioned = false;
747
1162
  return true;
748
1163
  }
749
1164
  return false;
@@ -755,7 +1170,9 @@ var LookaheadIterator = class {
755
1170
  * `false` otherwise.
756
1171
  */
757
1172
  resetState(stateId) {
758
- return Boolean(C._ts_lookahead_iterator_reset_state(this[0], stateId));
1173
+ if (!C._ts_lookahead_iterator_reset_state(this[0], stateId)) return false;
1174
+ this.positioned = false;
1175
+ return true;
759
1176
  }
760
1177
  /**
761
1178
  * Returns an iterator that iterates over the symbols of the lookahead iterator.
@@ -766,10 +1183,9 @@ var LookaheadIterator = class {
766
1183
  [Symbol.iterator]() {
767
1184
  return {
768
1185
  next: /* @__PURE__ */ __name(() => {
769
- if (C._ts_lookahead_iterator_next(this[0])) {
770
- return { done: false, value: this.currentType };
771
- }
772
- return { done: true, value: "" };
1186
+ this.positioned = Boolean(C._ts_lookahead_iterator_next(this[0]));
1187
+ const value = this.currentType;
1188
+ return value === null ? { done: true, value: "" } : { done: false, value };
773
1189
  }, "next")
774
1190
  };
775
1191
  }
@@ -795,6 +1211,9 @@ function getText(tree, startIndex, endIndex, startPosition) {
795
1211
  return result ?? "";
796
1212
  }
797
1213
  __name(getText, "getText");
1214
+ var finalizer2 = newFinalizer((address) => {
1215
+ C._ts_tree_delete(address);
1216
+ });
798
1217
  var Tree = class _Tree {
799
1218
  static {
800
1219
  __name(this, "Tree");
@@ -812,6 +1231,7 @@ var Tree = class _Tree {
812
1231
  this[0] = address;
813
1232
  this.language = language;
814
1233
  this.textCallback = textCallback;
1234
+ finalizer2?.register(this, address, this);
815
1235
  }
816
1236
  /** Create a shallow copy of the syntax tree. This is very fast. */
817
1237
  copy() {
@@ -820,6 +1240,7 @@ var Tree = class _Tree {
820
1240
  }
821
1241
  /** Delete the syntax tree, freeing its resources. */
822
1242
  delete() {
1243
+ finalizer2?.unregister(this);
823
1244
  C._ts_tree_delete(this[0]);
824
1245
  this[0] = 0;
825
1246
  }
@@ -900,6 +1321,9 @@ var Tree = class _Tree {
900
1321
  return result;
901
1322
  }
902
1323
  };
1324
+ var finalizer3 = newFinalizer((address) => {
1325
+ C._ts_tree_cursor_delete_wasm(address);
1326
+ });
903
1327
  var TreeCursor = class _TreeCursor {
904
1328
  static {
905
1329
  __name(this, "TreeCursor");
@@ -927,6 +1351,7 @@ var TreeCursor = class _TreeCursor {
927
1351
  assertInternal(internal);
928
1352
  this.tree = tree;
929
1353
  unmarshalTreeCursor(this);
1354
+ finalizer3?.register(this, this.tree[0], this);
930
1355
  }
931
1356
  /** Creates a deep copy of the tree cursor. This allocates new memory. */
932
1357
  copy() {
@@ -937,6 +1362,7 @@ var TreeCursor = class _TreeCursor {
937
1362
  }
938
1363
  /** Delete the tree cursor, freeing its resources. */
939
1364
  delete() {
1365
+ finalizer3?.unregister(this);
940
1366
  marshalTreeCursor(this);
941
1367
  C._ts_tree_cursor_delete_wasm(this.tree[0]);
942
1368
  this[0] = this[1] = this[2] = 0;
@@ -2031,8 +2457,9 @@ var Language = class _Language {
2031
2457
  * This returns `null` if state is invalid for this language.
2032
2458
  *
2033
2459
  * Iterating {@link LookaheadIterator} will yield valid symbols in the given
2034
- * parse state. Newly created lookahead iterators will return the `ERROR`
2035
- * symbol from {@link LookaheadIterator#currentType}.
2460
+ * parse state. A newly created iterator is not positioned on a symbol, so
2461
+ * {@link LookaheadIterator#currentType} returns `null` until the first
2462
+ * iteration step.
2036
2463
  *
2037
2464
  * Lookahead iterators can be useful for generating suggestions and improving
2038
2465
  * syntax error diagnostics. To get symbols valid in an `ERROR` node, use the
@@ -2047,7 +2474,8 @@ var Language = class _Language {
2047
2474
  }
2048
2475
  /**
2049
2476
  * Load a language from a WebAssembly module.
2050
- * The module can be provided as a path to a file or as a buffer.
2477
+ * The module can be provided as a path to a file, a `URL` to a file, or as a
2478
+ * buffer.
2051
2479
  */
2052
2480
  static async load(input) {
2053
2481
  let binary2;
@@ -2074,16 +2502,27 @@ ${body2}`);
2074
2502
  }
2075
2503
  }
2076
2504
  const mod = await C.loadWebAssemblyModule(binary2, { loadAsync: true });
2505
+ return _Language.loadFromWasmExports(mod, { sync: false });
2506
+ }
2507
+ static loadFromWasmExports(mod, { sync }) {
2077
2508
  const symbolNames = Object.keys(mod);
2078
2509
  const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
2079
2510
  if (!functionName) {
2080
2511
  console.log(`Couldn't find language function in Wasm file. Symbols:
2081
2512
  ${JSON.stringify(symbolNames, null, 2)}`);
2082
- throw new Error("Language.load failed: no language function found in Wasm file");
2513
+ throw new Error(`Language.${sync ? "loadSync" : "load"} failed: no language function found in Wasm file`);
2083
2514
  }
2084
2515
  const languageAddress = mod[functionName]();
2085
2516
  return new _Language(INTERNAL, languageAddress);
2086
2517
  }
2518
+ /**
2519
+ * Load a language synchronously from a pre-compiled WebAssembly module.
2520
+ * Use this when the host environment provides a `WebAssembly.Module` directly.
2521
+ */
2522
+ static loadSync(wasmModule) {
2523
+ const mod = C.loadWebAssemblyModule(wasmModule, { loadAsync: false });
2524
+ return _Language.loadFromWasmExports(mod, { sync: true });
2525
+ }
2087
2526
  };
2088
2527
  async function Module2(moduleArg = {}) {
2089
2528
  var moduleRtn;
@@ -2606,7 +3045,7 @@ async function Module2(moduleArg = {}) {
2606
3045
  newDSO("__main__", 0, wasmImports);
2607
3046
  }
2608
3047
  };
2609
- var ___heap_base = 78240;
3048
+ var ___heap_base = 82240;
2610
3049
  var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
2611
3050
  var getMemory = /* @__PURE__ */ __name((size) => {
2612
3051
  if (runtimeInitialized) {
@@ -3171,12 +3610,12 @@ async function Module2(moduleArg = {}) {
3171
3610
  "value": "i32",
3172
3611
  "mutable": false
3173
3612
  }, 1024);
3174
- var ___stack_high = 78240;
3175
- var ___stack_low = 12704;
3613
+ var ___stack_high = 82240;
3614
+ var ___stack_low = 16704;
3176
3615
  var ___stack_pointer = new WebAssembly.Global({
3177
3616
  "value": "i32",
3178
3617
  "mutable": true
3179
- }, 78240);
3618
+ }, 82240);
3180
3619
  var ___table_base = new WebAssembly.Global({
3181
3620
  "value": "i32",
3182
3621
  "mutable": false
@@ -3437,7 +3876,7 @@ async function Module2(moduleArg = {}) {
3437
3876
  Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
3438
3877
  Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
3439
3878
  var ASM_CONSTS = {};
3440
- var _malloc, _calloc, _realloc, _free, _ts_range_edit, _memcmp, _ts_language_symbol_count, _ts_language_state_count, _ts_language_abi_version, _ts_language_name, _ts_language_field_count, _ts_language_next_state, _ts_language_symbol_name, _ts_language_symbol_for_name, _strncmp, _ts_language_symbol_type, _ts_language_field_name_for_id, _ts_lookahead_iterator_new, _ts_lookahead_iterator_delete, _ts_lookahead_iterator_reset_state, _ts_lookahead_iterator_reset, _ts_lookahead_iterator_next, _ts_lookahead_iterator_current_symbol, _ts_point_edit, _ts_parser_delete, _ts_parser_reset, _ts_parser_set_language, _ts_parser_set_included_ranges, _ts_query_new, _ts_query_delete, _iswspace, _iswalnum, _ts_query_pattern_count, _ts_query_capture_count, _ts_query_string_count, _ts_query_capture_name_for_id, _ts_query_capture_quantifier_for_id, _ts_query_string_value_for_id, _ts_query_predicates_for_pattern, _ts_query_start_byte_for_pattern, _ts_query_end_byte_for_pattern, _ts_query_is_pattern_rooted, _ts_query_is_pattern_non_local, _ts_query_is_pattern_guaranteed_at_step, _ts_query_disable_capture, _ts_query_disable_pattern, _ts_tree_copy, _ts_tree_delete, _ts_init, _ts_parser_new_wasm, _ts_parser_enable_logger_wasm, _ts_parser_parse_wasm, _ts_parser_included_ranges_wasm, _ts_language_type_is_named_wasm, _ts_language_type_is_visible_wasm, _ts_language_metadata_wasm, _ts_language_supertypes_wasm, _ts_language_subtypes_wasm, _ts_tree_root_node_wasm, _ts_tree_root_node_with_offset_wasm, _ts_tree_edit_wasm, _ts_tree_included_ranges_wasm, _ts_tree_get_changed_ranges_wasm, _ts_tree_cursor_new_wasm, _ts_tree_cursor_copy_wasm, _ts_tree_cursor_delete_wasm, _ts_tree_cursor_reset_wasm, _ts_tree_cursor_reset_to_wasm, _ts_tree_cursor_goto_first_child_wasm, _ts_tree_cursor_goto_last_child_wasm, _ts_tree_cursor_goto_first_child_for_index_wasm, _ts_tree_cursor_goto_first_child_for_position_wasm, _ts_tree_cursor_goto_next_sibling_wasm, _ts_tree_cursor_goto_previous_sibling_wasm, _ts_tree_cursor_goto_descendant_wasm, _ts_tree_cursor_goto_parent_wasm, _ts_tree_cursor_current_node_type_id_wasm, _ts_tree_cursor_current_node_state_id_wasm, _ts_tree_cursor_current_node_is_named_wasm, _ts_tree_cursor_current_node_is_missing_wasm, _ts_tree_cursor_current_node_id_wasm, _ts_tree_cursor_start_position_wasm, _ts_tree_cursor_end_position_wasm, _ts_tree_cursor_start_index_wasm, _ts_tree_cursor_end_index_wasm, _ts_tree_cursor_current_field_id_wasm, _ts_tree_cursor_current_depth_wasm, _ts_tree_cursor_current_descendant_index_wasm, _ts_tree_cursor_current_node_wasm, _ts_node_symbol_wasm, _ts_node_field_name_for_child_wasm, _ts_node_field_name_for_named_child_wasm, _ts_node_children_by_field_id_wasm, _ts_node_first_child_for_byte_wasm, _ts_node_first_named_child_for_byte_wasm, _ts_node_grammar_symbol_wasm, _ts_node_child_count_wasm, _ts_node_named_child_count_wasm, _ts_node_child_wasm, _ts_node_named_child_wasm, _ts_node_child_by_field_id_wasm, _ts_node_next_sibling_wasm, _ts_node_prev_sibling_wasm, _ts_node_next_named_sibling_wasm, _ts_node_prev_named_sibling_wasm, _ts_node_descendant_count_wasm, _ts_node_parent_wasm, _ts_node_child_with_descendant_wasm, _ts_node_descendant_for_index_wasm, _ts_node_named_descendant_for_index_wasm, _ts_node_descendant_for_position_wasm, _ts_node_named_descendant_for_position_wasm, _ts_node_start_point_wasm, _ts_node_end_point_wasm, _ts_node_start_index_wasm, _ts_node_end_index_wasm, _ts_node_to_string_wasm, _ts_node_children_wasm, _ts_node_named_children_wasm, _ts_node_descendants_of_type_wasm, _ts_node_is_named_wasm, _ts_node_has_changes_wasm, _ts_node_has_error_wasm, _ts_node_is_error_wasm, _ts_node_is_missing_wasm, _ts_node_is_extra_wasm, _ts_node_parse_state_wasm, _ts_node_next_parse_state_wasm, _ts_query_matches_wasm, _ts_query_captures_wasm, _memset, _memcpy, _memmove, _iswalpha, _iswblank, _iswdigit, _iswlower, _iswupper, _iswxdigit, _memchr, _strlen, _strcmp, _strncat, _strncpy, _towlower, _towupper, _setThrew, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, ___wasm_apply_data_relocs;
3879
+ var _malloc, _calloc, _realloc, _free, _ts_range_edit, _memcmp, _ts_language_symbol_count, _ts_language_state_count, _ts_language_abi_version, _ts_language_name, _ts_language_field_count, _ts_language_next_state, _ts_language_symbol_name, _ts_language_symbol_for_name, _strncmp, _ts_language_symbol_type, _ts_language_field_name_for_id, _ts_lookahead_iterator_new, _ts_lookahead_iterator_delete, _ts_lookahead_iterator_reset_state, _ts_lookahead_iterator_reset, _ts_lookahead_iterator_next, _ts_lookahead_iterator_current_symbol, _ts_point_edit, _ts_parser_delete, _ts_parser_reset, _ts_parser_set_language, _ts_parser_set_included_ranges, _ts_query_new, _ts_query_delete, _iswspace, _iswalnum, _ts_query_copy, _ts_query_pattern_count, _ts_query_capture_count, _ts_query_string_count, _ts_query_capture_name_for_id, _ts_query_capture_quantifier_for_id, _ts_query_string_value_for_id, _ts_query_predicates_for_pattern, _ts_query_start_byte_for_pattern, _ts_query_end_byte_for_pattern, _ts_query_is_pattern_rooted, _ts_query_is_pattern_non_local, _ts_query_is_pattern_guaranteed_at_step, _ts_query_disable_capture, _ts_query_disable_pattern, _ts_tree_copy, _ts_tree_delete, _ts_init, _ts_parser_new_wasm, _ts_parser_enable_logger_wasm, _ts_parser_parse_wasm, _ts_parser_included_ranges_wasm, _ts_language_type_is_named_wasm, _ts_language_type_is_visible_wasm, _ts_language_metadata_wasm, _ts_language_supertypes_wasm, _ts_language_subtypes_wasm, _ts_tree_root_node_wasm, _ts_tree_root_node_with_offset_wasm, _ts_tree_edit_wasm, _ts_tree_included_ranges_wasm, _ts_tree_get_changed_ranges_wasm, _ts_tree_cursor_new_wasm, _ts_tree_cursor_copy_wasm, _ts_tree_cursor_delete_wasm, _ts_tree_cursor_reset_wasm, _ts_tree_cursor_reset_to_wasm, _ts_tree_cursor_goto_first_child_wasm, _ts_tree_cursor_goto_last_child_wasm, _ts_tree_cursor_goto_first_child_for_index_wasm, _ts_tree_cursor_goto_first_child_for_position_wasm, _ts_tree_cursor_goto_next_sibling_wasm, _ts_tree_cursor_goto_previous_sibling_wasm, _ts_tree_cursor_goto_descendant_wasm, _ts_tree_cursor_goto_parent_wasm, _ts_tree_cursor_current_node_type_id_wasm, _ts_tree_cursor_current_node_state_id_wasm, _ts_tree_cursor_current_node_is_named_wasm, _ts_tree_cursor_current_node_is_missing_wasm, _ts_tree_cursor_current_node_id_wasm, _ts_tree_cursor_start_position_wasm, _ts_tree_cursor_end_position_wasm, _ts_tree_cursor_start_index_wasm, _ts_tree_cursor_end_index_wasm, _ts_tree_cursor_current_field_id_wasm, _ts_tree_cursor_current_depth_wasm, _ts_tree_cursor_current_descendant_index_wasm, _ts_tree_cursor_current_node_wasm, _ts_node_symbol_wasm, _ts_node_field_name_for_child_wasm, _ts_node_field_name_for_named_child_wasm, _ts_node_children_by_field_id_wasm, _ts_node_first_child_for_byte_wasm, _ts_node_first_named_child_for_byte_wasm, _ts_node_grammar_symbol_wasm, _ts_node_child_count_wasm, _ts_node_named_child_count_wasm, _ts_node_child_wasm, _ts_node_named_child_wasm, _ts_node_child_by_field_id_wasm, _ts_node_next_sibling_wasm, _ts_node_prev_sibling_wasm, _ts_node_next_named_sibling_wasm, _ts_node_prev_named_sibling_wasm, _ts_node_descendant_count_wasm, _ts_node_parent_wasm, _ts_node_child_with_descendant_wasm, _ts_node_descendant_for_index_wasm, _ts_node_named_descendant_for_index_wasm, _ts_node_descendant_for_position_wasm, _ts_node_named_descendant_for_position_wasm, _ts_node_start_point_wasm, _ts_node_end_point_wasm, _ts_node_start_index_wasm, _ts_node_end_index_wasm, _ts_node_to_string_wasm, _ts_node_children_wasm, _ts_node_named_children_wasm, _ts_node_descendants_of_type_wasm, _ts_node_is_named_wasm, _ts_node_has_changes_wasm, _ts_node_has_error_wasm, _ts_node_is_error_wasm, _ts_node_is_missing_wasm, _ts_node_is_extra_wasm, _ts_node_parse_state_wasm, _ts_node_next_parse_state_wasm, _ts_query_matches_wasm, _ts_query_captures_wasm, _memset, _memcpy, _memmove, _iswalpha, _iswblank, _iswdigit, _iswlower, _iswpunct, _iswupper, _iswxdigit, _memchr, _strlen, _strcmp, _strncat, _strncpy, _towlower, _towupper, _setThrew, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, ___wasm_apply_data_relocs;
3441
3880
  function assignWasmExports(wasmExports2) {
3442
3881
  Module["_malloc"] = _malloc = wasmExports2["malloc"];
3443
3882
  Module["_calloc"] = _calloc = wasmExports2["calloc"];
@@ -3471,6 +3910,7 @@ async function Module2(moduleArg = {}) {
3471
3910
  Module["_ts_query_delete"] = _ts_query_delete = wasmExports2["ts_query_delete"];
3472
3911
  Module["_iswspace"] = _iswspace = wasmExports2["iswspace"];
3473
3912
  Module["_iswalnum"] = _iswalnum = wasmExports2["iswalnum"];
3913
+ Module["_ts_query_copy"] = _ts_query_copy = wasmExports2["ts_query_copy"];
3474
3914
  Module["_ts_query_pattern_count"] = _ts_query_pattern_count = wasmExports2["ts_query_pattern_count"];
3475
3915
  Module["_ts_query_capture_count"] = _ts_query_capture_count = wasmExports2["ts_query_capture_count"];
3476
3916
  Module["_ts_query_string_count"] = _ts_query_string_count = wasmExports2["ts_query_string_count"];
@@ -3576,6 +4016,7 @@ async function Module2(moduleArg = {}) {
3576
4016
  Module["_iswblank"] = _iswblank = wasmExports2["iswblank"];
3577
4017
  Module["_iswdigit"] = _iswdigit = wasmExports2["iswdigit"];
3578
4018
  Module["_iswlower"] = _iswlower = wasmExports2["iswlower"];
4019
+ Module["_iswpunct"] = _iswpunct = wasmExports2["iswpunct"];
3579
4020
  Module["_iswupper"] = _iswupper = wasmExports2["iswupper"];
3580
4021
  Module["_iswxdigit"] = _iswxdigit = wasmExports2["iswxdigit"];
3581
4022
  Module["_memchr"] = _memchr = wasmExports2["memchr"];
@@ -3713,6 +4154,10 @@ __name(checkModule, "checkModule");
3713
4154
  var TRANSFER_BUFFER;
3714
4155
  var LANGUAGE_VERSION;
3715
4156
  var MIN_COMPATIBLE_VERSION;
4157
+ var finalizer4 = newFinalizer((addresses) => {
4158
+ C._ts_parser_delete(addresses[0]);
4159
+ C._free(addresses[1]);
4160
+ });
3716
4161
  var Parser = class {
3717
4162
  static {
3718
4163
  __name(this, "Parser");
@@ -3744,6 +4189,7 @@ var Parser = class {
3744
4189
  */
3745
4190
  constructor() {
3746
4191
  this.initialize();
4192
+ finalizer4?.register(this, [this[0], this[1]], this);
3747
4193
  }
3748
4194
  /** @internal */
3749
4195
  initialize() {
@@ -3756,6 +4202,7 @@ var Parser = class {
3756
4202
  }
3757
4203
  /** Delete the parser, freeing its resources. */
3758
4204
  delete() {
4205
+ finalizer4?.unregister(this);
3759
4206
  C._ts_parser_delete(this[0]);
3760
4207
  C._free(this[1]);
3761
4208
  this[0] = 0;
@@ -3931,6 +4378,10 @@ var QueryError = class _QueryError extends Error {
3931
4378
  this.length = length;
3932
4379
  this.name = "QueryError";
3933
4380
  }
4381
+ kind;
4382
+ info;
4383
+ index;
4384
+ length;
3934
4385
  static {
3935
4386
  __name(this, "QueryError");
3936
4387
  }
@@ -4126,6 +4577,9 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
4126
4577
  }
4127
4578
  }
4128
4579
  __name(parsePattern, "parsePattern");
4580
+ var finalizer5 = newFinalizer((address) => {
4581
+ C._ts_query_delete(address);
4582
+ });
4129
4583
  var Query = class {
4130
4584
  static {
4131
4585
  __name(this, "Query");
@@ -4280,9 +4734,11 @@ var Query = class {
4280
4734
  this.assertedProperties = assertedProperties;
4281
4735
  this.refutedProperties = refutedProperties;
4282
4736
  this.exceededMatchLimit = false;
4737
+ finalizer5?.register(this, address, this);
4283
4738
  }
4284
4739
  /** Delete the query, freeing its resources. */
4285
4740
  delete() {
4741
+ finalizer5?.unregister(this);
4286
4742
  C._ts_query_delete(this[0]);
4287
4743
  this[0] = 0;
4288
4744
  }