@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;
338
- }
339
- const matched = rule[mode].test(path);
340
- if (!matched) {
341
- 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;
342
729
  }
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;
@@ -651,6 +1035,18 @@ function setModule(module2) {
651
1035
  }
652
1036
  __name(setModule, "setModule");
653
1037
  var C;
1038
+ function newFinalizer(handler) {
1039
+ try {
1040
+ return new FinalizationRegistry(handler);
1041
+ } catch (e) {
1042
+ console.error("Unsupported FinalizationRegistry:", e);
1043
+ return;
1044
+ }
1045
+ }
1046
+ __name(newFinalizer, "newFinalizer");
1047
+ var finalizer = newFinalizer((address) => {
1048
+ C._ts_lookahead_iterator_delete(address);
1049
+ });
654
1050
  var LookaheadIterator = class {
655
1051
  static {
656
1052
  __name(this, "LookaheadIterator");
@@ -661,21 +1057,39 @@ var LookaheadIterator = class {
661
1057
  /** @internal */
662
1058
  language;
663
1059
  /** @internal */
1060
+ positioned = false;
1061
+ /** @internal */
664
1062
  constructor(internal, address, language) {
665
1063
  assertInternal(internal);
666
1064
  this[0] = address;
667
1065
  this.language = language;
1066
+ finalizer?.register(this, address, this);
668
1067
  }
669
- /** Get the current symbol of the lookahead iterator. */
1068
+ /**
1069
+ * Get the current symbol of the lookahead iterator.
1070
+ *
1071
+ * Returns `null` if the iterator is not positioned on a symbol:
1072
+ *
1073
+ * - Before the first iteration step
1074
+ * - After the iterator is exhausted
1075
+ * - After a {@link reset} or {@link resetState} call
1076
+ */
670
1077
  get currentTypeId() {
671
- return C._ts_lookahead_iterator_current_symbol(this[0]);
1078
+ return this.positioned ? C._ts_lookahead_iterator_current_symbol(this[0]) : null;
672
1079
  }
673
- /** Get the current symbol name of the lookahead iterator. */
1080
+ /**
1081
+ * Get the current symbol name of the lookahead iterator.
1082
+ *
1083
+ * Returns `null` if the iterator is not positioned on a symbol.
1084
+ */
674
1085
  get currentType() {
675
- return this.language.types[this.currentTypeId] || "ERROR";
1086
+ const id = this.currentTypeId;
1087
+ if (id === null) return null;
1088
+ return this.language.types[id] ?? C.UTF8ToString(C._ts_language_symbol_name(this.language[0], id));
676
1089
  }
677
1090
  /** Delete the lookahead iterator, freeing its resources. */
678
1091
  delete() {
1092
+ finalizer?.unregister(this);
679
1093
  C._ts_lookahead_iterator_delete(this[0]);
680
1094
  this[0] = 0;
681
1095
  }
@@ -688,6 +1102,7 @@ var LookaheadIterator = class {
688
1102
  reset(language, stateId) {
689
1103
  if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
690
1104
  this.language = language;
1105
+ this.positioned = false;
691
1106
  return true;
692
1107
  }
693
1108
  return false;
@@ -699,7 +1114,9 @@ var LookaheadIterator = class {
699
1114
  * `false` otherwise.
700
1115
  */
701
1116
  resetState(stateId) {
702
- return Boolean(C._ts_lookahead_iterator_reset_state(this[0], stateId));
1117
+ if (!C._ts_lookahead_iterator_reset_state(this[0], stateId)) return false;
1118
+ this.positioned = false;
1119
+ return true;
703
1120
  }
704
1121
  /**
705
1122
  * Returns an iterator that iterates over the symbols of the lookahead iterator.
@@ -710,10 +1127,9 @@ var LookaheadIterator = class {
710
1127
  [Symbol.iterator]() {
711
1128
  return {
712
1129
  next: /* @__PURE__ */ __name(() => {
713
- if (C._ts_lookahead_iterator_next(this[0])) {
714
- return { done: false, value: this.currentType };
715
- }
716
- return { done: true, value: "" };
1130
+ this.positioned = Boolean(C._ts_lookahead_iterator_next(this[0]));
1131
+ const value = this.currentType;
1132
+ return value === null ? { done: true, value: "" } : { done: false, value };
717
1133
  }, "next")
718
1134
  };
719
1135
  }
@@ -739,6 +1155,9 @@ function getText(tree, startIndex, endIndex, startPosition) {
739
1155
  return result ?? "";
740
1156
  }
741
1157
  __name(getText, "getText");
1158
+ var finalizer2 = newFinalizer((address) => {
1159
+ C._ts_tree_delete(address);
1160
+ });
742
1161
  var Tree = class _Tree {
743
1162
  static {
744
1163
  __name(this, "Tree");
@@ -756,6 +1175,7 @@ var Tree = class _Tree {
756
1175
  this[0] = address;
757
1176
  this.language = language;
758
1177
  this.textCallback = textCallback;
1178
+ finalizer2?.register(this, address, this);
759
1179
  }
760
1180
  /** Create a shallow copy of the syntax tree. This is very fast. */
761
1181
  copy() {
@@ -764,6 +1184,7 @@ var Tree = class _Tree {
764
1184
  }
765
1185
  /** Delete the syntax tree, freeing its resources. */
766
1186
  delete() {
1187
+ finalizer2?.unregister(this);
767
1188
  C._ts_tree_delete(this[0]);
768
1189
  this[0] = 0;
769
1190
  }
@@ -844,6 +1265,9 @@ var Tree = class _Tree {
844
1265
  return result;
845
1266
  }
846
1267
  };
1268
+ var finalizer3 = newFinalizer((address) => {
1269
+ C._ts_tree_cursor_delete_wasm(address);
1270
+ });
847
1271
  var TreeCursor = class _TreeCursor {
848
1272
  static {
849
1273
  __name(this, "TreeCursor");
@@ -871,6 +1295,7 @@ var TreeCursor = class _TreeCursor {
871
1295
  assertInternal(internal);
872
1296
  this.tree = tree;
873
1297
  unmarshalTreeCursor(this);
1298
+ finalizer3?.register(this, this.tree[0], this);
874
1299
  }
875
1300
  /** Creates a deep copy of the tree cursor. This allocates new memory. */
876
1301
  copy() {
@@ -881,6 +1306,7 @@ var TreeCursor = class _TreeCursor {
881
1306
  }
882
1307
  /** Delete the tree cursor, freeing its resources. */
883
1308
  delete() {
1309
+ finalizer3?.unregister(this);
884
1310
  marshalTreeCursor(this);
885
1311
  C._ts_tree_cursor_delete_wasm(this.tree[0]);
886
1312
  this[0] = this[1] = this[2] = 0;
@@ -1975,8 +2401,9 @@ var Language = class _Language {
1975
2401
  * This returns `null` if state is invalid for this language.
1976
2402
  *
1977
2403
  * Iterating {@link LookaheadIterator} will yield valid symbols in the given
1978
- * parse state. Newly created lookahead iterators will return the `ERROR`
1979
- * symbol from {@link LookaheadIterator#currentType}.
2404
+ * parse state. A newly created iterator is not positioned on a symbol, so
2405
+ * {@link LookaheadIterator#currentType} returns `null` until the first
2406
+ * iteration step.
1980
2407
  *
1981
2408
  * Lookahead iterators can be useful for generating suggestions and improving
1982
2409
  * syntax error diagnostics. To get symbols valid in an `ERROR` node, use the
@@ -1991,7 +2418,8 @@ var Language = class _Language {
1991
2418
  }
1992
2419
  /**
1993
2420
  * Load a language from a WebAssembly module.
1994
- * The module can be provided as a path to a file or as a buffer.
2421
+ * The module can be provided as a path to a file, a `URL` to a file, or as a
2422
+ * buffer.
1995
2423
  */
1996
2424
  static async load(input) {
1997
2425
  let binary2;
@@ -2018,16 +2446,27 @@ ${body2}`);
2018
2446
  }
2019
2447
  }
2020
2448
  const mod = await C.loadWebAssemblyModule(binary2, { loadAsync: true });
2449
+ return _Language.loadFromWasmExports(mod, { sync: false });
2450
+ }
2451
+ static loadFromWasmExports(mod, { sync }) {
2021
2452
  const symbolNames = Object.keys(mod);
2022
2453
  const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
2023
2454
  if (!functionName) {
2024
2455
  console.log(`Couldn't find language function in Wasm file. Symbols:
2025
2456
  ${JSON.stringify(symbolNames, null, 2)}`);
2026
- throw new Error("Language.load failed: no language function found in Wasm file");
2457
+ throw new Error(`Language.${sync ? "loadSync" : "load"} failed: no language function found in Wasm file`);
2027
2458
  }
2028
2459
  const languageAddress = mod[functionName]();
2029
2460
  return new _Language(INTERNAL, languageAddress);
2030
2461
  }
2462
+ /**
2463
+ * Load a language synchronously from a pre-compiled WebAssembly module.
2464
+ * Use this when the host environment provides a `WebAssembly.Module` directly.
2465
+ */
2466
+ static loadSync(wasmModule) {
2467
+ const mod = C.loadWebAssemblyModule(wasmModule, { loadAsync: false });
2468
+ return _Language.loadFromWasmExports(mod, { sync: true });
2469
+ }
2031
2470
  };
2032
2471
  async function Module2(moduleArg = {}) {
2033
2472
  var moduleRtn;
@@ -2550,7 +2989,7 @@ async function Module2(moduleArg = {}) {
2550
2989
  newDSO("__main__", 0, wasmImports);
2551
2990
  }
2552
2991
  };
2553
- var ___heap_base = 78240;
2992
+ var ___heap_base = 82240;
2554
2993
  var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
2555
2994
  var getMemory = /* @__PURE__ */ __name((size) => {
2556
2995
  if (runtimeInitialized) {
@@ -3115,12 +3554,12 @@ async function Module2(moduleArg = {}) {
3115
3554
  "value": "i32",
3116
3555
  "mutable": false
3117
3556
  }, 1024);
3118
- var ___stack_high = 78240;
3119
- var ___stack_low = 12704;
3557
+ var ___stack_high = 82240;
3558
+ var ___stack_low = 16704;
3120
3559
  var ___stack_pointer = new WebAssembly.Global({
3121
3560
  "value": "i32",
3122
3561
  "mutable": true
3123
- }, 78240);
3562
+ }, 82240);
3124
3563
  var ___table_base = new WebAssembly.Global({
3125
3564
  "value": "i32",
3126
3565
  "mutable": false
@@ -3381,7 +3820,7 @@ async function Module2(moduleArg = {}) {
3381
3820
  Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
3382
3821
  Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
3383
3822
  var ASM_CONSTS = {};
3384
- 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;
3823
+ 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;
3385
3824
  function assignWasmExports(wasmExports2) {
3386
3825
  Module["_malloc"] = _malloc = wasmExports2["malloc"];
3387
3826
  Module["_calloc"] = _calloc = wasmExports2["calloc"];
@@ -3415,6 +3854,7 @@ async function Module2(moduleArg = {}) {
3415
3854
  Module["_ts_query_delete"] = _ts_query_delete = wasmExports2["ts_query_delete"];
3416
3855
  Module["_iswspace"] = _iswspace = wasmExports2["iswspace"];
3417
3856
  Module["_iswalnum"] = _iswalnum = wasmExports2["iswalnum"];
3857
+ Module["_ts_query_copy"] = _ts_query_copy = wasmExports2["ts_query_copy"];
3418
3858
  Module["_ts_query_pattern_count"] = _ts_query_pattern_count = wasmExports2["ts_query_pattern_count"];
3419
3859
  Module["_ts_query_capture_count"] = _ts_query_capture_count = wasmExports2["ts_query_capture_count"];
3420
3860
  Module["_ts_query_string_count"] = _ts_query_string_count = wasmExports2["ts_query_string_count"];
@@ -3520,6 +3960,7 @@ async function Module2(moduleArg = {}) {
3520
3960
  Module["_iswblank"] = _iswblank = wasmExports2["iswblank"];
3521
3961
  Module["_iswdigit"] = _iswdigit = wasmExports2["iswdigit"];
3522
3962
  Module["_iswlower"] = _iswlower = wasmExports2["iswlower"];
3963
+ Module["_iswpunct"] = _iswpunct = wasmExports2["iswpunct"];
3523
3964
  Module["_iswupper"] = _iswupper = wasmExports2["iswupper"];
3524
3965
  Module["_iswxdigit"] = _iswxdigit = wasmExports2["iswxdigit"];
3525
3966
  Module["_memchr"] = _memchr = wasmExports2["memchr"];
@@ -3657,6 +4098,10 @@ __name(checkModule, "checkModule");
3657
4098
  var TRANSFER_BUFFER;
3658
4099
  var LANGUAGE_VERSION;
3659
4100
  var MIN_COMPATIBLE_VERSION;
4101
+ var finalizer4 = newFinalizer((addresses) => {
4102
+ C._ts_parser_delete(addresses[0]);
4103
+ C._free(addresses[1]);
4104
+ });
3660
4105
  var Parser = class {
3661
4106
  static {
3662
4107
  __name(this, "Parser");
@@ -3688,6 +4133,7 @@ var Parser = class {
3688
4133
  */
3689
4134
  constructor() {
3690
4135
  this.initialize();
4136
+ finalizer4?.register(this, [this[0], this[1]], this);
3691
4137
  }
3692
4138
  /** @internal */
3693
4139
  initialize() {
@@ -3700,6 +4146,7 @@ var Parser = class {
3700
4146
  }
3701
4147
  /** Delete the parser, freeing its resources. */
3702
4148
  delete() {
4149
+ finalizer4?.unregister(this);
3703
4150
  C._ts_parser_delete(this[0]);
3704
4151
  C._free(this[1]);
3705
4152
  this[0] = 0;
@@ -3875,6 +4322,10 @@ var QueryError = class _QueryError extends Error {
3875
4322
  this.length = length;
3876
4323
  this.name = "QueryError";
3877
4324
  }
4325
+ kind;
4326
+ info;
4327
+ index;
4328
+ length;
3878
4329
  static {
3879
4330
  __name(this, "QueryError");
3880
4331
  }
@@ -4070,6 +4521,9 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
4070
4521
  }
4071
4522
  }
4072
4523
  __name(parsePattern, "parsePattern");
4524
+ var finalizer5 = newFinalizer((address) => {
4525
+ C._ts_query_delete(address);
4526
+ });
4073
4527
  var Query = class {
4074
4528
  static {
4075
4529
  __name(this, "Query");
@@ -4224,9 +4678,11 @@ var Query = class {
4224
4678
  this.assertedProperties = assertedProperties;
4225
4679
  this.refutedProperties = refutedProperties;
4226
4680
  this.exceededMatchLimit = false;
4681
+ finalizer5?.register(this, address, this);
4227
4682
  }
4228
4683
  /** Delete the query, freeing its resources. */
4229
4684
  delete() {
4685
+ finalizer5?.unregister(this);
4230
4686
  C._ts_query_delete(this[0]);
4231
4687
  this[0] = 0;
4232
4688
  }